Skip to content
Closed
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
17 changes: 17 additions & 0 deletions src/Changes
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,23 @@ example, with --clang_version 230100:
was previously recorded as "clangdiagnostic push". That is now fixed.


10/3/26 [GH #19]
Assertion failure on an empty diag_suppress pragma

A diag_* pragma with no arguments, or with a trailing comma, diagnosed the
missing argument and then read past the end of the directive. That consumed
the following source and could assert in process_immediate_pragmas. For
example:

#pragma diagnostic push
#pragma diag_suppress
int f() { int a; return a; }
#pragma diagnostic pop

The missing argument is still diagnosed, and the code after the pragma is
parsed.


10/1/26 [GH #197]
Deducing noexcept-specifiers

Expand Down
7 changes: 5 additions & 2 deletions src/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -8176,8 +8176,11 @@ as _Pragma that are not parsed except during instantiations).
err = TRUE;
pos_warning(ec_exp_error_argument, &pos_curr_token);
} /* if */
/* Bypass the token just processed. */
(void)get_token();
/* Advance past the argument. Do not consume tok_end_of_source here.
Fetching that terminator already popped the pragma token cache, so
another get_token would read the source that follows the pragma and
could queue later pragmas while this one is still being processed. */
if (curr_token != tok_end_of_source) (void)get_token();
if (curr_token != tok_comma && curr_token != tok_end_of_source) {
pos_warning(ec_exp_comma, &pos_curr_token);
error_in_pragma = TRUE;
Expand Down
33 changes: 33 additions & 0 deletions tests/tests/changes/.GH19.rto/default.1.1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
fe_only -DTEST_NUMBER=1 Test_name.c
"Test_name.c", line 9: warning: expected an error number or error tag
#pragma diag_suppress
^

"Test_name.c", line 13: warning: variable "a" is used before its value is set
return a;
^

"Test_name.c", line 20: warning: variable "b" is used before its value is set
return b;
^

"Test_name.c", line 23: warning: expected an error number or error tag
#pragma diag_suppress =
^

"Test_name.c", line 27: warning: variable "c" is used before its value is set
return c;
^

"Test_name.c", line 30: warning: expected an error number or error tag
#pragma diag_suppress 123,
^

"Test_name.c", line 34: warning: variable "d" is used before its value is set
return d;
^

"Test_name.c", line 41: warning: variable "e" is used before its value is set
return e;
^

43 changes: 43 additions & 0 deletions tests/tests/changes/GH19.sft.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//type:fp
//remark:[GH #19] Assertion failure on an empty diag_suppress pragma
// 10/3/26 [GH #19]
//
// An empty #pragma diag_suppress used to read past the directive and assert
// in process_immediate_pragmas. The functions below must still be compiled.

#pragma diagnostic push
#pragma diag_suppress
int get_free_no_warn()
{
int a;
return a;
}
#pragma diagnostic pop

int get_free_warn()
{
int b;
return b;
}

#pragma diag_suppress =
int after_bare_equals()
{
int c;
return c;
}

#pragma diag_suppress 123,
int after_trailing_comma()
{
int d;
return d;
}

#pragma diag_suppress = 123
int after_valid_pragma()
{
int e;
return e;
}
#pragma diag_default 123
Loading