Skip to content

Commit d6518a9

Browse files
committed
White space lost in the pragma text for a "#pragma clang" directive [GH #213]
1 parent f0e30b6 commit d6518a9

21 files changed

Lines changed: 219 additions & 0 deletions

‎src/Changes‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
Version 7.1
2+
3+
10/5/26 [GH #213]
4+
White space lost in the pragma text for a "#pragma clang" directive
5+
6+
The changes for EDGcpfe/29033 (in version 7.0) introduced a regression in
7+
which the text recorded in the IL for a "#pragma clang" directive other than
8+
"#pragma clang riscv ..." lost the white space following "clang". For
9+
example, with --clang_version 230100:
10+
11+
#pragma clang diagnostic push
12+
13+
was previously recorded as "clangdiagnostic push". That is now fixed.
14+
15+
116
10/1/26 [GH #197]
217
Deducing noexcept-specifiers
318

‎src/preproc.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3315,9 +3315,14 @@ The position of the pragma ID is returned in id_position;
33153315
#if GNU_VECTOR_TYPES_ALLOWED && BUILTIN_FUNCTIONS_ENABLED
33163316
} else if (pkdp->kind == pk_clang_riscv) {
33173317
a_const_char *save_start_of_curr_token = start_of_curr_token;
3318+
a_const_char *save_curr_char_loc = curr_char_loc;
33183319
skip_white_space();
33193320
start_of_curr_token = save_start_of_curr_token;
33203321
if (strncmp(curr_char_loc, "riscv", 5U) != 0) {
3322+
/* Restore the scan position advanced by skip_white_space() so the
3323+
space after "clang" is preserved when recording the pragma
3324+
text. */
3325+
curr_char_loc = save_curr_char_loc;
33213326
pkdp = pkdp->next;
33223327
continue;
33233328
} /* if */

‎tests/expectations/edg_x86_32/edg.log‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ cmeerw/gnats-28966.sft.cpp:fp:-DTEST_NUMBER=3 --target linux_armv7:REQUIREMENTS
193193
cmeerw/gnats-28966.sft.cpp:fp:-DTEST_NUMBER=4 --target linux_aarch64:REQUIREMENTS NOT MET:
194194
cmeerw/gnats-28966.sft.cpp:fp:-DTEST_NUMBER=5 --target linux_riscv32:REQUIREMENTS NOT MET:
195195
cmeerw/gnats-28966.sft.cpp:fp:-DTEST_NUMBER=6 --target linux_riscv64:REQUIREMENTS NOT MET:
196+
cmeerw/pragma-clang-whitespace-cppbe.sft.cpp:cppbe:-DTEST_NUMBER=1 --c++20:REQUIREMENTS NOT MET:
197+
cmeerw/pragma-clang-whitespace-cppbe.sft.cpp:cppbe:-DTEST_NUMBER=2 --gn 160200:REQUIREMENTS NOT MET:
198+
cmeerw/pragma-clang-whitespace-cppbe.sft.cpp:cppbe:-DTEST_NUMBER=3 --clang_version 230100:REQUIREMENTS NOT MET:
196199
daveed/d00114a.sft.cpp:fp:-DTEST_NUMBER=1:CATASTROPHE:GNU C variable redeclaration with cv-mismatch
197200
daveed/d00116a.sft.cpp:cp:-DTEST_NUMBER=1:BADC:GNU C old-style definitions following prototypes with unpromoted types
198201
daveed/d00127a.sft.cpp:fn:-DTEST_NUMBER=1:CATASTROPHE:GNU C typedef initializer

‎tests/expectations/edg_x86_64/edg.log‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ ccs/gnats21047.sft.cpp:cp:-DTEST_NUMBER=1:REQUIREMENTS NOT MET:
1717
ccs/gnats21635.sft.cpp:cp:-DTEST_NUMBER=1:FAIL:
1818
ccs/gnats23024.sft.cpp:rp:-DTEST_NUMBER=1:REQUIREMENTS NOT MET:
1919
cmeerw/gnats-26621-run.sft.cpp:rp:-DTEST_NUMBER=1 --c++20 --no_exceptions --set_flag=no_checking_pragmas:BADC(COMPILE):
20+
cmeerw/pragma-clang-whitespace-cppbe.sft.cpp:cppbe:-DTEST_NUMBER=1 --c++20:REQUIREMENTS NOT MET:
21+
cmeerw/pragma-clang-whitespace-cppbe.sft.cpp:cppbe:-DTEST_NUMBER=2 --gn 160200:REQUIREMENTS NOT MET:
22+
cmeerw/pragma-clang-whitespace-cppbe.sft.cpp:cppbe:-DTEST_NUMBER=3 --clang_version 230100:REQUIREMENTS NOT MET:
2023
daveed/d00114a.sft.cpp:fp:-DTEST_NUMBER=1:CATASTROPHE:GNU C variable redeclaration with cv-mismatch
2124
daveed/d00116a.sft.cpp:cp:-DTEST_NUMBER=1:BADC:GNU C old-style definitions following prototypes with unpromoted types
2225
daveed/d00127a.sft.cpp:fn:-DTEST_NUMBER=1:CATASTROPHE:GNU C typedef initializer
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
cpfe -DTEST_NUMBER=1 -w --c++20 Test_name.c
2+
Generated file content for "Test_name.c":
3+
#line 1 "Test_name.c"
4+
#line 10
5+
#pragma clang diagnostic push
6+
#pragma clang diagnostic pop
7+
8+
#pragma GCC diagnostic push
9+
#pragma GCC diagnostic pop
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Matches for "#pragma clang diagnostic push":
2+
<-----------------------------------------------------------------------------
3+
#pragma clang diagnostic push
4+
----------------------------------------------------------------------------->
5+
Matches for "#pragma clang diagnostic pop":
6+
<-----------------------------------------------------------------------------
7+
#pragma clang diagnostic pop
8+
----------------------------------------------------------------------------->
9+
Matches for "#pragma GCC diagnostic push":
10+
<-----------------------------------------------------------------------------
11+
#pragma GCC diagnostic push
12+
----------------------------------------------------------------------------->
13+
Matches for "#pragma GCC diagnostic pop":
14+
<-----------------------------------------------------------------------------
15+
#pragma GCC diagnostic pop
16+
----------------------------------------------------------------------------->
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
cpfe -DTEST_NUMBER=2 -w --gn 160200 Test_name.c
2+
Generated file content for "Test_name.c":
3+
# 1 "Test_name.c"
4+
# 10
5+
#pragma clang diagnostic push
6+
#pragma clang diagnostic pop
7+
8+
#pragma GCC diagnostic push
9+
#pragma GCC diagnostic pop
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Matches for "#pragma clang diagnostic push":
2+
<-----------------------------------------------------------------------------
3+
#pragma clang diagnostic push
4+
----------------------------------------------------------------------------->
5+
Matches for "#pragma clang diagnostic pop":
6+
<-----------------------------------------------------------------------------
7+
#pragma clang diagnostic pop
8+
----------------------------------------------------------------------------->
9+
Matches for "#pragma GCC diagnostic push":
10+
<-----------------------------------------------------------------------------
11+
#pragma GCC diagnostic push
12+
----------------------------------------------------------------------------->
13+
Matches for "#pragma GCC diagnostic pop":
14+
<-----------------------------------------------------------------------------
15+
#pragma GCC diagnostic pop
16+
----------------------------------------------------------------------------->
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
cpfe -DTEST_NUMBER=3 -w --clang_version 230100 Test_name.c
2+
Generated file content for "Test_name.c":
3+
# 1 "Test_name.c"
4+
# 10
5+
#pragma clang diagnostic push
6+
#pragma clang diagnostic pop
7+
8+
#pragma GCC diagnostic push
9+
#pragma GCC diagnostic pop
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Matches for "#pragma clang diagnostic push":
2+
<-----------------------------------------------------------------------------
3+
#pragma clang diagnostic push
4+
----------------------------------------------------------------------------->
5+
Matches for "#pragma clang diagnostic pop":
6+
<-----------------------------------------------------------------------------
7+
#pragma clang diagnostic pop
8+
----------------------------------------------------------------------------->
9+
Matches for "#pragma GCC diagnostic push":
10+
<-----------------------------------------------------------------------------
11+
#pragma GCC diagnostic push
12+
----------------------------------------------------------------------------->
13+
Matches for "#pragma GCC diagnostic pop":
14+
<-----------------------------------------------------------------------------
15+
#pragma GCC diagnostic pop
16+
----------------------------------------------------------------------------->

0 commit comments

Comments
 (0)