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 453323861962 for ; Thu, 12 Aug 2021 07:37:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 453323861962 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-229-ssLu07JhOmenoJKAQZfYbw-1; Thu, 12 Aug 2021 03:37:22 -0400 X-MC-Unique: ssLu07JhOmenoJKAQZfYbw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CD33F190D340 for ; Thu, 12 Aug 2021 07:37:21 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.193.120]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7A1233AA2 for ; Thu, 12 Aug 2021 07:37:21 +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 17C7bJjN1041606 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT) for ; Thu, 12 Aug 2021 09:37:19 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 17C7bG3e1041605 for gcc-patches@gcc.gnu.org; Thu, 12 Aug 2021 09:37:16 +0200 Date: Thu, 12 Aug 2021 09:37:16 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: openmp: Diagnose omp::directive/sequence on using-directive Message-ID: <20210812073716.GH2380439@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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: Thu, 12 Aug 2021 07:37:25 -0000 Hi! With the using-directive parsing changes, we now emit only a warning for [[omp::directive (...)]] on using-directive. While that is right without -fopenmp/-fopenmp-simd, when OpenMP is enabled, that should be an error as OpenMP (is going to) disallow such attributes there as they do not appertain to a statement. Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk. 2021-08-12 Jakub Jelinek * name-lookup.c (finish_using_directive): Diagnose omp::directive or omp::sequence attributes on using-directive. * g++.dg/gomp/attrs-11.C: Adjust expected diagnostics. --- gcc/cp/name-lookup.c.jj 2021-06-10 19:56:20.606335462 +0200 +++ gcc/cp/name-lookup.c 2021-08-11 22:33:51.367221663 +0200 @@ -8560,6 +8560,7 @@ finish_using_directive (tree target, tree attribs) add_using_namespace (current_binding_level->using_directives, ORIGINAL_NAMESPACE (target)); + bool diagnosed = false; if (attribs != error_mark_node) for (tree a = attribs; a; a = TREE_CHAIN (a)) { @@ -8572,6 +8573,16 @@ finish_using_directive (tree target, tree attribs) inform (DECL_SOURCE_LOCATION (target), "you can use an inline namespace instead"); } + else if ((flag_openmp || flag_openmp_simd) + && get_attribute_namespace (a) == omp_identifier + && (is_attribute_p ("directive", name) + || is_attribute_p ("sequence", name))) + { + if (!diagnosed) + error ("% not allowed to be specified in this " + "context", name); + diagnosed = true; + } else warning (OPT_Wattributes, "%qD attribute directive ignored", name); } --- gcc/testsuite/g++.dg/gomp/attrs-11.C.jj 2021-08-11 16:56:49.262489927 +0200 +++ gcc/testsuite/g++.dg/gomp/attrs-11.C 2021-08-11 22:34:59.427281071 +0200 @@ -11,7 +11,7 @@ foo () [[omp::directive (parallel)]] __extension__ asm (""); // { dg-error "expected" } __extension__ [[omp::directive (parallel)]] asm (""); // { dg-error "expected" } [[omp::directive (parallel)]] namespace M = ::N; // { dg-error "expected" } - [[omp::directive (parallel)]] using namespace N; // { dg-bogus "expected" "" { xfail *-*-* } } + [[omp::directive (parallel)]] using namespace N; // { dg-error "not allowed to be specified in this context" } [[omp::directive (parallel)]] using O::T; // { dg-error "expected" } [[omp::directive (parallel)]] __label__ foo; // { dg-error "expected" } [[omp::directive (parallel)]] static_assert (true, ""); // { dg-error "expected" } Jakub