File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,6 +20,21 @@ C++-generating back end: inaccessible or out-of-scope template arguments
2020In certain complex cases, the C++-generating back end could put out a
2121template argument that uses an inaccessible or out-of-scope name, making
2222the generated code uncompilable. This is now fixed.
23+ 10/6/26 [GH #203]
24+ Assertion failure on an empty diag_suppress pragma
25+
26+ A diag_suppress (or similar) pragma with no arguments, or with a trailing
27+ comma, diagnosed the missing argument and then read past the end of the
28+ directive. That, in turn, could lead to an assertion failure in
29+ process_immediate_pragmas. For example:
30+
31+ #pragma diagnostic push
32+ #pragma diag_suppress
33+ int f() { int a; return a; }
34+ #pragma diagnostic pop
35+
36+ That is now fixed: The missing argument is still diagnosed, and the code after
37+ the pragma is parsed.
2338
2439
254010/5/26 [GH #213]
Original file line number Diff line number Diff line change @@ -8176,8 +8176,11 @@ as _Pragma that are not parsed except during instantiations).
81768176 err = TRUE;
81778177 pos_warning (ec_exp_error_argument , & pos_curr_token );
81788178 } /* if */
8179- /* Bypass the token just processed. */
8180- (void )get_token ();
8179+ /* Advance past the argument. Do not consume tok_end_of_source here.
8180+ Fetching that terminator already popped the pragma token cache, so
8181+ another get_token would read the source that follows the pragma and
8182+ could queue later pragmas while this one is still being processed. */
8183+ if (curr_token != tok_end_of_source ) (void )get_token ();
81818184 if (curr_token != tok_comma && curr_token != tok_end_of_source ) {
81828185 pos_warning (ec_exp_comma , & pos_curr_token );
81838186 error_in_pragma = TRUE;
Original file line number Diff line number Diff line change 1+ fe_only -DTEST_NUMBER=1 Test_name.c
2+ "Test_name.c", line 9: warning: expected an error number or error tag
3+ #pragma diag_suppress
4+ ^
5+
6+ "Test_name.c", line 13: warning: variable "a" is used before its value is set
7+ return a;
8+ ^
9+
10+ "Test_name.c", line 20: warning: variable "b" is used before its value is set
11+ return b;
12+ ^
13+
14+ "Test_name.c", line 23: warning: expected an error number or error tag
15+ #pragma diag_suppress =
16+ ^
17+
18+ "Test_name.c", line 27: warning: variable "c" is used before its value is set
19+ return c;
20+ ^
21+
22+ "Test_name.c", line 30: warning: expected an error number or error tag
23+ #pragma diag_suppress 123,
24+ ^
25+
26+ "Test_name.c", line 34: warning: variable "d" is used before its value is set
27+ return d;
28+ ^
29+
30+ "Test_name.c", line 41: warning: variable "e" is used before its value is set
31+ return e;
32+ ^
33+
Original file line number Diff line number Diff line change 1+ // type:fp
2+ // remark:[GH #19] Assertion failure on an empty diag_suppress pragma
3+ // 10/3/26 [GH #19]
4+ //
5+ // An empty #pragma diag_suppress used to read past the directive and assert
6+ // in process_immediate_pragmas. The functions below must still be compiled.
7+
8+ #pragma diagnostic push
9+ #pragma diag_suppress
10+ int get_free_no_warn ()
11+ {
12+ int a;
13+ return a;
14+ }
15+ #pragma diagnostic pop
16+
17+ int get_free_warn ()
18+ {
19+ int b;
20+ return b;
21+ }
22+
23+ #pragma diag_suppress =
24+ int after_bare_equals ()
25+ {
26+ int c;
27+ return c;
28+ }
29+
30+ #pragma diag_suppress 123,
31+ int after_trailing_comma ()
32+ {
33+ int d;
34+ return d;
35+ }
36+
37+ #pragma diag_suppress = 123
38+ int after_valid_pragma ()
39+ {
40+ int e;
41+ return e;
42+ }
43+ #pragma diag_default 123
You can’t perform that action at this time.
0 commit comments