From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 493FF3896C02 for ; Wed, 4 Aug 2021 09:57:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 493FF3896C02 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-315-cwTQyLkRPiKlbkTjxc05Ww-1; Wed, 04 Aug 2021 05:57:50 -0400 X-MC-Unique: cwTQyLkRPiKlbkTjxc05Ww-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C754D1026200 for ; Wed, 4 Aug 2021 09:57:49 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.193.120]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 729F3544F1 for ; Wed, 4 Aug 2021 09:57:49 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 1749viV5866718 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT) for ; Wed, 4 Aug 2021 11:57:44 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 1749vhUc866717 for gcc-patches@gcc.gnu.org; Wed, 4 Aug 2021 11:57:43 +0200 Date: Wed, 4 Aug 2021 11:57:43 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] c++: Fix up #pragma omp declare {simd,variant} and acc routine parsing Message-ID: <20210804095743.GF2380545@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Aug 2021 09:57:53 -0000 Hi! 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. Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk, will backport eventually. 2021-08-04 Jakub Jelinek 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. --- gcc/cp/parser.c.jj 2021-08-03 17:38:07.541725977 +0200 +++ gcc/cp/parser.c 2021-08-03 19:23:08.693843077 +0200 @@ -24509,6 +24509,8 @@ cp_parser_default_argument (cp_parser *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; --- gcc/testsuite/g++.dg/gomp/pr101759.C.jj 2021-08-03 19:32:56.091725711 +0200 +++ gcc/testsuite/g++.dg/gomp/pr101759.C 2021-08-03 19:36:03.762138412 +0200 @@ -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; }()); --- gcc/testsuite/g++.dg/goacc/pr101759.C.jj 2021-08-03 19:33:15.079463941 +0200 +++ gcc/testsuite/g++.dg/goacc/pr101759.C 2021-08-03 19:35:53.148284738 +0200 @@ -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; }()); Jakub