From patchwork Mon Nov 11 20:07:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1193108 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-512998-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="PuEyAzMn"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="hRunL/ev"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47Bhk42XQ0z9sP3 for ; Tue, 12 Nov 2019 07:07:24 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:reply-to:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=iL+4H4LW/4p0EQHb 1f2SvSGNAypnjeFq7phzvMMJj4Q0HqQrgB/+HPrp9oPOZeGV+tiMpVpHYuX0OAl2 njqZbrARX+36bIu8pQCjk5fhogtqzE/1prRVFh6YktWOXYlDEKwSF/DDSlaMmCq/ dO4jxl5jAuy4ZlRkHgvUy/ZK1/4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:reply-to:mime-version:content-type :content-transfer-encoding; s=default; bh=DUWbAC9ZBC7xbpVxQShAsX fYS9g=; b=PuEyAzMnLtUphcrHkN/6VMnzZMCNGcnJ4T2hbxPuq7aj3LSgPkuEXR P3+DnTuTKyc6NUh9bRpNo0guZe12ra9Vrhe1qzivnKyb7u6hqsb0/IiAxq1K/Ub/ CvU76UUDdrXhQcSep///1iAuNcB7jmOuHU5ITlMg+Vj10XWo1hsis= Received: (qmail 103095 invoked by alias); 11 Nov 2019 20:07:17 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 103086 invoked by uid 89); 11 Nov 2019 20:07:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=isn, 69, sk:declare, 2019-11-02 X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (207.211.31.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 11 Nov 2019 20:07:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573502834; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ptMeJdRarPktG9JsyI3ilZl/ZgyFqIU3vYlZkr0EfoQ=; b=hRunL/evtwnJnXo40m0JaLc0X5ua7SQyBk0ICPmbgELuPEdCuoHgJPg1gyJqhYvVPt0VeA Li23Ixwa6nTCO6/Du9mcORIzVCHzzMJPZCOI3MhufH491l0RsTvlaL7l8fpVtxB93865+J TvJKTtHJ6wXeO8yDS05klsq2tKAB/L0= 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-37-QVqLi7nCNJ2OGMYrQ7geWw-1; Mon, 11 Nov 2019 15:07:13 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 49ED4911E8 for ; Mon, 11 Nov 2019 20:07:12 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.36.118.135]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E74776106A for ; Mon, 11 Nov 2019 20:07:11 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id xABK79sD026562 for ; Mon, 11 Nov 2019 21:07:10 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id xABK79Q4026561 for gcc-patches@gcc.gnu.org; Mon, 11 Nov 2019 21:07:09 +0100 Date: Mon, 11 Nov 2019 21:07:09 +0100 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] Diagnose #pragma omp declare target without corresponding #pragma omp end declare target Message-ID: <20191111200709.GY4650@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 User-Agent: Mutt/1.11.3 (2019-02-01) X-Mimecast-Spam-Score: 0 Content-Disposition: inline X-IsSubscribed: yes Hi! I found a bug in OpenMP 5.0 examples that GCC didn't flag as an error. The following patch implements the missing diagnostics. Bootstrapped/regtested on powerpc64le-linux, committed to trunk. 2019-11-11 Jakub Jelinek * c-parser.c (c_parser_translation_unit): Diagnose declare target without corresponding end declare target. * semantics.c (finish_translation_unit): Diagnose declare target without corresponding end declare target. * c-c++-common/gomp/declare-target-5.c: New test. Jakub --- gcc/c/c-parser.c.jj 2019-11-08 09:03:56.271250390 +0100 +++ gcc/c/c-parser.c 2019-11-11 11:09:46.910702347 +0100 @@ -1554,6 +1554,14 @@ c_parser_translation_unit (c_parser *par FOR_EACH_VEC_ELT (incomplete_record_decls, i, decl) if (DECL_SIZE (decl) == NULL_TREE && TREE_TYPE (decl) != error_mark_node) error ("storage size of %q+D isn%'t known", decl); + + if (current_omp_declare_target_attribute) + { + if (!errorcount) + error ("%<#pragma omp declare target%> without corresponding " + "%<#pragma omp end declare target%>"); + current_omp_declare_target_attribute = 0; + } } /* Parse an external declaration (C90 6.7, C99 6.9, C11 6.9). --- gcc/cp/semantics.c.jj 2019-11-02 00:26:48.932847353 +0100 +++ gcc/cp/semantics.c 2019-11-11 11:29:55.009396475 +0100 @@ -3048,6 +3048,14 @@ finish_translation_unit (void) /* Do file scope __FUNCTION__ et al. */ finish_fname_decls (); + + if (scope_chain->omp_declare_target_attribute) + { + if (!errorcount) + error ("%<#pragma omp declare target%> without corresponding " + "%<#pragma omp end declare target%>"); + scope_chain->omp_declare_target_attribute = 0; + } } /* Finish a template type parameter, specified as AGGR IDENTIFIER. --- gcc/testsuite/c-c++-common/gomp/declare-target-5.c.jj 2019-11-11 11:11:04.577524594 +0100 +++ gcc/testsuite/c-c++-common/gomp/declare-target-5.c 2019-11-11 11:18:40.289619051 +0100 @@ -0,0 +1,2 @@ +#pragma omp declare target +void foo (void); /* { dg-error "'#pragma omp declare target' without corresponding '#pragma omp end declare target'" } */