Compiler 2014: Semantic specification
外观
General Considerations
continue
andbreak
must be in a loop- In
a.b
,b
must be a field ofa
's type - Variable declarations are not allowed in loop conditions
- Void-type variables are not writable
Typing
- The type of the expression in a
return
statement must match the return type of the function - The arguments of a function must match the arguments of a call of that function
return
statements are not mandatory, even in a non-void function- In
a[expr]
,a
must be a pointer (or array), andexpr
must be int/char
Scoping
- Field names should be unique within a
struct
- Function names should be unique
- Variables in the same level/scope should be unique
- Reading: http://stackoverflow.com/questions/3793952/understanding-c-namespaces
- I will discuss these topics in the next class. :) You can see the testcases to check more.
- Dynamic array should be considered as valid. To simplify the project, we will not test it. (Will be explained later.)
- Refer to gcc 4.7.1 for any semantic issues not mentioned above.