aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathaniel Shead <nathanieloshead@gmail.com>2024-12-20 22:09:39 +1100
committerNathaniel Shead <nathanieloshead@gmail.com>2025-01-17 23:50:32 +1100
commitf3ccc57e5f044031a1b07e79330de9220e93afe7 (patch)
tree9f1c696d20ea0354128b52ef16b8b8fce11ee343
parent3347ac3cbc7704c7f1d69b6875b65129c6d7dae5 (diff)
downloadgcc-f3ccc57e5f044031a1b07e79330de9220e93afe7.zip
gcc-f3ccc57e5f044031a1b07e79330de9220e93afe7.tar.gz
gcc-f3ccc57e5f044031a1b07e79330de9220e93afe7.tar.bz2
c++: Allow pragmas in NSDMIs [PR118147]
This patch removes the (unnecessary) CPP_PRAGMA_EOL case from cp_parser_cache_defarg, which currently has the result that any pragmas in the NSDMI cause an error. PR c++/118147 gcc/cp/ChangeLog: * parser.cc (cp_parser_cache_defarg): Don't error when CPP_PRAGMA_EOL. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/nsdmi-defer7.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
-rw-r--r--gcc/cp/parser.cc1
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nsdmi-defer7.C13
2 files changed, 13 insertions, 1 deletions
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index c030a18..ff58a8e 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -36264,7 +36264,6 @@ cp_parser_cache_defarg (cp_parser *parser, bool nsdmi)
/* If we run out of tokens, issue an error message. */
case CPP_EOF:
- case CPP_PRAGMA_EOL:
error_at (token->location, "file ends in default argument");
return error_mark_node;
diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-defer7.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-defer7.C
new file mode 100644
index 0000000..3bef636
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi-defer7.C
@@ -0,0 +1,13 @@
+// PR c++/118147
+// { dg-do compile { target c++11 } }
+
+struct F {
+ int i = []{
+ #pragma message "test" // { dg-message "test" }
+ return 1;
+ }();
+};
+
+struct G {
+ int i =
+ #pragma GCC diagnostic push // { dg-error "file ends in default argument|expected" }