aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorLewis Hyatt <lhyatt@gmail.com>2024-03-22 15:42:43 -0400
committerLewis Hyatt <lhyatt@gcc.gnu.org>2024-10-14 09:52:02 -0400
commit8c56d697b35d3d2ef802d068cad6b3bd026a2a1a (patch)
tree8386eb00a3b4e0d69afec801df82c55517157877 /gcc
parent998eb2a126d33ab622a6f12c7e1faccf4429835c (diff)
downloadgcc-8c56d697b35d3d2ef802d068cad6b3bd026a2a1a.zip
gcc-8c56d697b35d3d2ef802d068cad6b3bd026a2a1a.tar.gz
gcc-8c56d697b35d3d2ef802d068cad6b3bd026a2a1a.tar.bz2
libcpp: Fix _Pragma("GCC system_header") [PR114436]
_Pragma("GCC system_header") currently takes effect only partially. It does succeed in updating the line_map, so that checks like in_system_header_at() return correctly, but it does not update pfile->buffer->sysp. One result is that a subsequent #include does not set up the system header state properly for the newly included file, as pointed out in the PR. Fix by propagating the new system header state back to the buffer after processing the pragma. libcpp/ChangeLog: PR preprocessor/114436 * directives.cc (destringize_and_run): If the _Pragma changed the buffer system header state (e.g. because it was "GCC system_header"), propagate that change back to the actual buffer too. gcc/testsuite/ChangeLog: PR preprocessor/114436 * c-c++-common/cpp/pragma-system-header-1.h: New test. * c-c++-common/cpp/pragma-system-header-2.h: New test. * c-c++-common/cpp/pragma-system-header.c: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/c-c++-common/cpp/pragma-system-header-1.h1
-rw-r--r--gcc/testsuite/c-c++-common/cpp/pragma-system-header-2.h5
-rw-r--r--gcc/testsuite/c-c++-common/cpp/pragma-system-header.c3
3 files changed, 9 insertions, 0 deletions
diff --git a/gcc/testsuite/c-c++-common/cpp/pragma-system-header-1.h b/gcc/testsuite/c-c++-common/cpp/pragma-system-header-1.h
new file mode 100644
index 0000000..bd9ff0c
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cpp/pragma-system-header-1.h
@@ -0,0 +1 @@
+#pragma GCC warning "this warning should not be output (1)"
diff --git a/gcc/testsuite/c-c++-common/cpp/pragma-system-header-2.h b/gcc/testsuite/c-c++-common/cpp/pragma-system-header-2.h
new file mode 100644
index 0000000..a62d9e2
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cpp/pragma-system-header-2.h
@@ -0,0 +1,5 @@
+_Pragma("GCC system_header")
+#include "pragma-system-header-1.h"
+#pragma GCC warning "this warning should not be output (2)"
+_Pragma("unknown")
+#include "pragma-system-header-1.h"
diff --git a/gcc/testsuite/c-c++-common/cpp/pragma-system-header.c b/gcc/testsuite/c-c++-common/cpp/pragma-system-header.c
new file mode 100644
index 0000000..fdea120
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cpp/pragma-system-header.c
@@ -0,0 +1,3 @@
+#include "pragma-system-header-2.h" /* { dg-bogus "this warning should not be output" } */
+/* { dg-do preprocess } */
+/* PR preprocessor/114436 */