跳转到内容

Compiler 2015: Semantic specification

来自ACM Class Wiki

General Considerations

  • continue and break must be in a loop
  • In a.b, b must be a field of a'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), and expr must be int/char

Scoping


  • 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.