Commit 35e2b11d authored by Xavier Leroy's avatar Xavier Leroy
Browse files

Ignore and warn about pragmas inside functions

Pragmas can occur either outside external declarations, at the top level
of a compilation unit, or within a compound statement, inside a function
definition.

The parse tree in cparse/C.mli cannot represent pragmas occuring within
a compound statement.

In this case, the elaborator used to silently move the pragma to top
level, just before the function definition where the pragma occurs.

It looks safer to just ignore pragmas occurring inside a function
definition, and emit a specific warning.
parent aba0e740
......@@ -2871,7 +2871,10 @@ let elab_definition (for_loop: bool) (local: bool) (nonstatic_inline: bool)
(* pragma *)
| PRAGMA(s, loc) ->
emit_elab env loc (Gpragma s);
if local then
warning loc Unknown_pragmas "pragmas are ignored inside functions"
else
emit_elab env loc (Gpragma s);
([], env)
(* static assertion *)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment