Commit f560955
committed
Fix declaration error when using clang
When compile the rv32emu using clang, the error log shows the following:
src/emulate.c:1127:5: error: expected expression
rv_insn_t ir;
According to [1], syntax of lebeled-statement stated in the following:
labeled-statement:
identifier : statement
case constant-expression : statement
default : statement
Obviously, only the statement is valid after labeled-statement. When
refering to [2], the following are the valid statements, excluding the
declaration.
statement:
labeled-statement
compound-statement
expression-statement
selection-statement
iteration-statement
jump-statement
Thus, move the declaration of ir before the labeled-statement eliminates
the clang compile error.
[1] C99 6.8.1 Labeled statements
[2] C99 6.8 Statement and blocks1 parent d8bf69a commit f560955
1 file changed
+3
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1122 | 1122 | | |
1123 | 1123 | | |
1124 | 1124 | | |
1125 | | - | |
1126 | | - | |
1127 | 1125 | | |
| 1126 | + | |
| 1127 | + | |
1128 | 1128 | | |
1129 | 1129 | | |
| 1130 | + | |
1130 | 1131 | | |
1131 | 1132 | | |
1132 | 1133 | | |
| |||
0 commit comments