Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cfrontend/CPragmas.ml
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,14 @@ let process_pragma name =
| _ ->
false

let supported_pragma name =
match Tokenize.string name with
| ("section" | "use_section" | "reserve_register") :: _ -> true
| _ -> false

let reset () =
reserved_registers := []

let initialize () =
Lexer.supported_pragma := supported_pragma;
C2C.process_pragma_hook := process_pragma
11 changes: 10 additions & 1 deletion cparser/Lexer.mll
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ let () =
(* We can ignore the __extension__ GCC keyword. *)
ignored_keywords := SSet.add "__extension__" !ignored_keywords

let supported_pragma : (string -> bool) ref = ref (fun _ -> false)

let init_ctx = SSet.of_list (List.map fst CBuiltins.builtins.C.builtin_typedefs)

let types_context : SSet.t ref = ref init_ctx
Expand Down Expand Up @@ -528,7 +530,14 @@ and hash = parse
"pragma"
whitespace_char_no_newline +
([^ '\n']* as s) '\n'
{ new_line lexbuf; PRAGMA (s, currentLoc lexbuf) }
{ if !supported_pragma s then begin
new_line lexbuf;
PRAGMA (s, currentLoc lexbuf)
end else begin
warning lexbuf Diagnostics.Unknown_pragmas "unknown pragma ignored";
new_line lexbuf;
initial_linebegin lexbuf
end }
| [^ '\n']* '\n'
{ warning lexbuf Diagnostics.Unnamed "unrecognized '#' line";
new_line lexbuf; initial_linebegin lexbuf }
Expand Down
Loading