Laundry Lists for C Compiler Projects
Types you are Actually Supposed to Handle
- int (char, long etc all refer to 32-bit signed integers)
- floats (float and double refer to 64-bit signed floats)
- FILE and WINDOW predefined types
- structs whose fields may be any of the above types
- 1-D pointers to base types (int *, char *, float *)
No arrays of arrays, pointers to pointers, structs of structs...
no multilevel things, period.
Semantic Errors that You Should Detect
- Undeclared variables, including undeclared functions.
- Conflicting declarations for a variable (variable redeclared).
This includes trying to declare a variable whose name is a
typedef-name, or trying to typedef the name of a declared variable.
- Type mismatches, e.g. assigning a struct to an array variable.
This includes passing the wrong type of parameter to a function,
as well as misusing function return types.
- Falling off the end of a non-void function
- Returning a value from a void function
Unimplemented Features
You should report occurrences of these features as a fatal semantic error.
Note that function prototypes and typedef's involving these features should
be accepted; variable declarations (including parameters) of these types
should result in an error. The goal is to support almost all system header
files, even though only a subset of the language is implemented.
- Floats and doubles
- Bit fields
- Enumeration types
- Unions
- Pointers to pointers
- Pointers to functions
- Variables declared inside local blocks, i.e. inside code blocks other
than the outermost level of function
Equivalent types
- short, long : int
- signed, unsigned : signed
Note that treating unions as equivalent to struct's would be cool, but
I'd written earlier that you didn't have to implement them, so it shall be.
But that means you have to produce "unimplemented" messages for them, which
might be more work than treating union as another name for struct.