Compiler 2015: Semantic specification
外观
General Considerations
continueandbreakmust be in a loop- In
a.b,bmust 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
returnstatement must match the return type of the function - The arguments of a function must match the arguments of a call of that function
returnstatements are not mandatory, even in a non-void function- In
a[expr],amust be a pointer (or array), andexprmust 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.