On 12/20/24 6:17 AM, Nathaniel Shead wrote:
Bootstrapped and regtested on x86_64-pc-linux-gnu, OK for trunk and
maybe release branches?

OK for all.

-- >8 --

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 <nathanielosh...@gmail.com>
---
  gcc/cp/parser.cc                          |  1 -
  gcc/testsuite/g++.dg/cpp0x/nsdmi-defer7.C | 13 +++++++++++++
  2 files changed, 13 insertions(+), 1 deletion(-)
  create mode 100644 gcc/testsuite/g++.dg/cpp0x/nsdmi-defer7.C

diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 23c6a2fd30e..527a858ea52 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -36316,7 +36316,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 00000000000..3bef636ccbd
--- /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" }

Reply via email to