Repository navigation
Commit 1eac8e8
Ignore unknown pragmas during lexing (#597)
Currently, the parser accepts `#pragma` directives that occur in declaration position. Elab ignores (with a warning) pragmas that are not global declarations. C2C ignores (with a warning) all remaining pragmas except the `section`, `use_section` and `reserve_register` pragmas handled in cfrontend/CPragmas.ml.
However, `#pragma` directives can occur anywhere in a C source file, incl. in the middle of a statement or an expression. Some system header files includes such weird pragmas.
This PR recognizes `#pragma` directives that are not handled in cfrontend/CPragmas.ml during lexical analysis and ignores them (with a warning). No `PRAGMA` token is generated for unhandled pragmas. This way, unhandled pragmas can occur anywhere in the source file and will not cause parsing errors.
Co-authored-by: Bernhard Schommer <bernhardschommer@gmail.com>1 parent 74cbdbf commit 1eac8e8
2 files changed
Lines changed: 16 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
90 | 95 | | |
91 | 96 | | |
92 | 97 | | |
93 | 98 | | |
| 99 | + | |
94 | 100 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
| 103 | + | |
102 | 104 | | |
103 | 105 | | |
104 | 106 | | |
| |||
528 | 530 | | |
529 | 531 | | |
530 | 532 | | |
531 | | - | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
532 | 541 | | |
533 | 542 | | |
534 | 543 | | |
| |||
0 commit comments