Master the fundamental concepts of semantic analysis through this focused micro-challenge.
Before ANSI C prototypes, calling foo(1, 2, 3) when foo expected two ints was undefined behavior. Clang's Sema checks arity and parameter types on every call. The Linux kernel builds with -Werror=implicit-function-declaration because signature mismatches cause real production bugs.
Look up the function in the symbol table. Verify argument count equals parameter count. For each position, verify the argument type is compatible with the parameter type, applying permitted coercions (e.g., int to float).
cLoading…
Production compilers embed this step inside a longer pipeline. GCC flows through cpp, cc1, assembly, and ld; Clang uses the driver, Sema, LLVM IR passes, and a target backend. LLVM bitcode, JVM bytecode, and WASM are other familiar IRs at the same layer. The exercise isolates one pass so you can test it alone before chaining it to the next stage.
You will implement function signature checking that validates argument count and types at call sites. This exercise requires storing signatures in your symbol table and comparing each call against the declared parameter list.
Implement function signature checking with type verification.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github