aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorLewis Hyatt <lhyatt@gmail.com>2022-11-02 16:04:36 -0400
committerLewis Hyatt <lhyatt@gmail.com>2022-11-21 17:47:19 -0500
commit6f46d14d4989b2711379807e4565585123c48118 (patch)
tree4d9b583c7133a103c323aa9271fa6507ebb0de54 /gcc
parent5c0d171f67d082c353ddc319859111d3b9126c17 (diff)
downloadgcc-6f46d14d4989b2711379807e4565585123c48118.zip
gcc-6f46d14d4989b2711379807e4565585123c48118.tar.gz
gcc-6f46d14d4989b2711379807e4565585123c48118.tar.bz2
libcpp: Fix paste error with unknown pragma after macro expansion
In directives.cc, do_pragma() contains logic to handle a case such as the new testcase pragma-omp-unknown.c, where an unknown pragma was the result of macro expansion (for pragma namespaces that permit expansion). This no longer works correctly as shown by the testcase, fixed by adding PREV_WHITE to the flags on the second token to prevent an unwanted paste. Also fixed the memory leak, since the temporary tokens are pushed on their own context, nothing prevents freeing of the buffer that holds them when the context is eventually popped. libcpp/ChangeLog: * directives.cc (do_pragma): Fix memory leak in token buffer. Fix unwanted paste between two tokens. gcc/testsuite/ChangeLog: * c-c++-common/gomp/pragma-omp-unknown.c: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/c-c++-common/gomp/pragma-omp-unknown.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/testsuite/c-c++-common/gomp/pragma-omp-unknown.c b/gcc/testsuite/c-c++-common/gomp/pragma-omp-unknown.c
new file mode 100644
index 0000000..04881f7
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/pragma-omp-unknown.c
@@ -0,0 +1,10 @@
+/* { dg-do preprocess } */
+/* { dg-options "-fopenmp" } */
+
+#define X UNKNOWN1
+#pragma omp X
+/* { dg-final { scan-file pragma-omp-unknown.i "#pragma omp UNKNOWN1" } } */
+
+#define Y UNKNOWN2
+_Pragma("omp Y")
+/* { dg-final { scan-file pragma-omp-unknown.i "#pragma omp UNKNOWN2" } } */