public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/omp/gcc-11] c++: Fix up #pragma omp declare {simd, variant} and acc routine parsing
@ 2021-08-12 10:00 Tobias Burnus
  0 siblings, 0 replies; only message in thread
From: Tobias Burnus @ 2021-08-12 10:00 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:1f1509520fc653af3f0b2c883bc6d7370d33638c

commit 1f1509520fc653af3f0b2c883bc6d7370d33638c
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Aug 12 11:09:00 2021 +0200

    c++: Fix up #pragma omp declare {simd,variant} and acc routine parsing
    
    When parsing default arguments, we need to temporarily clear parser->omp_declare_simd
    and parser->oacc_routine, otherwise it can clash with further declarations
    inside of e.g. lambdas inside of those default arguments.
    
    2021-08-04  Jakub Jelinek  <jakub@redhat.com>
    
            PR c++/101759
            * parser.c (cp_parser_default_argument): Temporarily override
            parser->omp_declare_simd and parser->oacc_routine to NULL.
    
            * g++.dg/gomp/pr101759.C: New test.
            * g++.dg/goacc/pr101759.C: New test.
    
    (cherry picked from commit af31cab04770f7a1a1da069415ab62ca2ef54fc4)

Diff:
---
 gcc/cp/ChangeLog.omp                  | 9 +++++++++
 gcc/cp/parser.c                       | 2 ++
 gcc/testsuite/ChangeLog.omp           | 9 +++++++++
 gcc/testsuite/g++.dg/goacc/pr101759.C | 5 +++++
 gcc/testsuite/g++.dg/gomp/pr101759.C  | 8 ++++++++
 5 files changed, 33 insertions(+)

diff --git a/gcc/cp/ChangeLog.omp b/gcc/cp/ChangeLog.omp
index 8c1d85ba82a..93811091094 100644
--- a/gcc/cp/ChangeLog.omp
+++ b/gcc/cp/ChangeLog.omp
@@ -1,3 +1,12 @@
+2021-08-12  Tobias Burnus  <tobias@codesourcery.com>
+
+	Backported from master:
+	2021-08-04  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/101759
+	* parser.c (cp_parser_default_argument): Temporarily override
+	parser->omp_declare_simd and parser->oacc_routine to NULL.
+
 2021-08-12  Tobias Burnus  <tobias@codesourcery.com>
 
 	Backported from master:
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 824c8288f40..b5192a40875 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -24566,6 +24566,8 @@ cp_parser_default_argument (cp_parser *parser, bool template_parm_p)
      set correctly.  */
   saved_greater_than_is_operator_p = parser->greater_than_is_operator_p;
   parser->greater_than_is_operator_p = !template_parm_p;
+  auto odsd = make_temp_override (parser->omp_declare_simd, NULL);
+  auto ord = make_temp_override (parser->oacc_routine, NULL);
   /* Local variable names (and the `this' keyword) may not
      appear in a default argument.  */
   saved_local_variables_forbidden_p = parser->local_variables_forbidden_p;
diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index bb0605f1918..a9aeb55a10a 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -1,3 +1,12 @@
+2021-08-12  Tobias Burnus  <tobias@codesourcery.com>
+
+	Backported from master:
+	2021-08-04  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/101759
+	* g++.dg/gomp/pr101759.C: New test.
+	* g++.dg/goacc/pr101759.C: New test.
+
 2021-08-12  Tobias Burnus  <tobias@codesourcery.com>
 
 	Backported from master:
diff --git a/gcc/testsuite/g++.dg/goacc/pr101759.C b/gcc/testsuite/g++.dg/goacc/pr101759.C
new file mode 100644
index 00000000000..522a5d4d4e8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/goacc/pr101759.C
@@ -0,0 +1,5 @@
+// PR c++/101759
+// { dg-do compile { target c++11 } }
+
+#pragma acc routine
+int foo (int x = []() { extern int bar (int); return 1; }());
diff --git a/gcc/testsuite/g++.dg/gomp/pr101759.C b/gcc/testsuite/g++.dg/gomp/pr101759.C
new file mode 100644
index 00000000000..905b8755135
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gomp/pr101759.C
@@ -0,0 +1,8 @@
+// PR c++/101759
+// { dg-do compile { target c++11 } }
+
+#pragma omp declare simd
+int foo (int x = []() { extern int bar (int); return 1; }());
+int corge (int = 1);
+#pragma omp declare variant (corge) match (user={condition(true)})
+int baz (int x = []() { extern int qux (int); return 1; }());


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-12 10:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-12 10:00 [gcc/devel/omp/gcc-11] c++: Fix up #pragma omp declare {simd, variant} and acc routine parsing Tobias Burnus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).