public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-2726] c++: Fix up #pragma omp declare {simd, variant} and acc routine parsing Date: Wed, 4 Aug 2021 09:56:06 +0000 (GMT) [thread overview] Message-ID: <20210804095606.EE4B6393C86B@sourceware.org> (raw) https://gcc.gnu.org/g:af31cab04770f7a1a1da069415ab62ca2ef54fc4 commit r12-2726-gaf31cab04770f7a1a1da069415ab62ca2ef54fc4 Author: Jakub Jelinek <jakub@redhat.com> Date: Wed Aug 4 11:53:48 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. Diff: --- gcc/cp/parser.c | 2 ++ gcc/testsuite/g++.dg/goacc/pr101759.C | 5 +++++ gcc/testsuite/g++.dg/gomp/pr101759.C | 8 ++++++++ 3 files changed, 15 insertions(+) diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 47bf7d9ad1f..02ce9543b86 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -24488,6 +24488,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/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; }());
reply other threads:[~2021-08-04 9:56 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210804095606.EE4B6393C86B@sourceware.org \ --to=jakub@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).