From patchwork Tue May 31 15:49:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 628303 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3rJycW5cFVz9t3Z for ; Wed, 1 Jun 2016 01:50:19 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=YrHWqpn3; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:in-reply-to:references:date:message-id:mime-version :content-type; q=dns; s=default; b=c4HweKG6RJd4LvpmARiKn/JYA8IRS 85DTdcgQp+YUeiycK4tCU3oMN5iAsuVXyKR8I/OM/CvoDhQz+ka4qfWbzEBeUgcA 8Zu6d5k+yrfYQWutygIXIFpHuMVV+jSJrr+ESEF1An3NTtahUDVlZZFTA2gxTzJs hihOGw8TJAYigk= 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:from :to:subject:in-reply-to:references:date:message-id:mime-version :content-type; s=default; bh=180G8uoNrPN3FGt+aMMZdqMIyPI=; b=YrH Wqpn3cwRK3THs2ECrA9GPD9TYfJzDDmtmZiPOH8NWLCYiVg3rax79lsVC+ZzGX59 wBXbBIa46qiPJfBoHpTMMcOTvbs0gelHmOuUOE+88Vm5ywH2AwWHDK3SemKYsj8p Fh+l2uypxuc1QEg9CW6gRIV018KNSvNENh04VoFg= Received: (qmail 56425 invoked by alias); 31 May 2016 15:50:10 -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 56408 invoked by uid 89); 31 May 2016 15:50:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=worker, Nathan, Baz, qux X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 31 May 2016 15:50:00 +0000 Received: from svr-orw-fem-04.mgc.mentorg.com ([147.34.97.41]) by relay1.mentorg.com with esmtp id 1b7lva-0003h6-EH from Thomas_Schwinge@mentor.com ; Tue, 31 May 2016 08:49:58 -0700 Received: from tftp-cs (147.34.91.1) by svr-orw-fem-04.mgc.mentorg.com (147.34.97.41) with Microsoft SMTP Server id 14.3.224.2; Tue, 31 May 2016 08:49:58 -0700 Received: by tftp-cs (Postfix, from userid 49978) id 902BAC22F4; Tue, 31 May 2016 08:49:57 -0700 (PDT) From: Thomas Schwinge To: Nathan Sidwell , Jakub Jelinek , Subject: Re: C/C++ OpenACC routine directive, undeclared name error: try to help the user, once In-Reply-To: <26f00f51-ba6f-afa0-958b-786cba73689b@acm.org> References: <877fejto7r.fsf@hertz.schwinge.homeip.net> <26f00f51-ba6f-afa0-958b-786cba73689b@acm.org> User-Agent: Notmuch/0.9-125-g4686d11 (http://notmuchmail.org) Emacs/24.5.1 (i586-pc-linux-gnu) Date: Tue, 31 May 2016 17:49:49 +0200 Message-ID: <87shwyqlb6.fsf@kepler.schwinge.homeip.net> MIME-Version: 1.0 Hi! On Tue, 31 May 2016 10:26:14 -0400, Nathan Sidwell wrote: > 'lexically following' is implementor-speak. [...] Thanks for the review, and wording suggestion. OK for trunk, as follows? commit 3289032bf7fd7e4a0cce37e7acd71e3330729d83 Author: Thomas Schwinge Date: Tue May 31 17:46:26 2016 +0200 C/C++ OpenACC routine directive, undeclared name error: try to help the user, once gcc/c/ * c-parser.c (c_parser_oacc_routine): If running into an undeclared name error, try to help the user, once. gcc/cp/ * parser.c (cp_parser_oacc_routine): If running into an undeclared name error, try to help the user, once. gcc/testsuite/ * c-c++-common/goacc/routine-5.c: Update. --- gcc/c/c-parser.c | 16 ++++++++++++++-- gcc/cp/parser.c | 16 ++++++++++++++-- gcc/testsuite/c-c++-common/goacc/routine-5.c | 15 ++++++++++++++- 3 files changed, 42 insertions(+), 5 deletions(-) Grüße Thomas diff --git gcc/c/c-parser.c gcc/c/c-parser.c index 993c0a0..d3cab69 100644 --- gcc/c/c-parser.c +++ gcc/c/c-parser.c @@ -14003,8 +14003,20 @@ c_parser_oacc_routine (c_parser *parser, enum pragma_context context) { decl = lookup_name (token->value); if (!decl) - error_at (token->location, "%qE has not been declared", - token->value); + { + error_at (token->location, "%qE has not been declared", + token->value); + static bool informed_once = false; + if (!informed_once) + { + inform (token->location, + "omit the %<(%E)%>, if you want to mark the" + " immediately following function, or place this" + " pragma after a declaration of the function to be" + " marked", token->value); + informed_once = true; + } + } c_parser_consume_token (parser); } else diff --git gcc/cp/parser.c gcc/cp/parser.c index 8841666..0c67608 100644 --- gcc/cp/parser.c +++ gcc/cp/parser.c @@ -36528,8 +36528,20 @@ cp_parser_oacc_routine (cp_parser *parser, cp_token *pragma_tok, /*optional_p=*/false); decl = cp_parser_lookup_name_simple (parser, id, token->location); if (id != error_mark_node && decl == error_mark_node) - cp_parser_name_lookup_error (parser, id, decl, NLE_NULL, - token->location); + { + cp_parser_name_lookup_error (parser, id, decl, NLE_NULL, + token->location); + static bool informed_once = false; + if (!informed_once) + { + inform (token->location, + "omit the %<(%E)%>, if you want to mark the" + " immediately following function, or place this" + " pragma after a declaration of the function to be" + " marked", id); + informed_once = true; + } + } if (decl == error_mark_node || !cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN)) diff --git gcc/testsuite/c-c++-common/goacc/routine-5.c gcc/testsuite/c-c++-common/goacc/routine-5.c index 1efd154..def78cd 100644 --- gcc/testsuite/c-c++-common/goacc/routine-5.c +++ gcc/testsuite/c-c++-common/goacc/routine-5.c @@ -71,7 +71,20 @@ void Foo () #pragma acc routine (Foo) gang // { dg-error "must be applied before definition" } -#pragma acc routine (Baz) // { dg-error "not been declared" } +#pragma acc routine (Baz) worker +/* { dg-error ".Baz. has not been declared" "" { target *-*-* } 74 } + Try to help the user: + { dg-message "note: omit the .\\(Baz\\)., if" "" { target *-*-* } 74 } */ + +#pragma acc routine (Baz) vector +/* { dg-error ".Baz. has not been declared" "" { target *-*-* } 79 } + Don't try to help the user again: + { dg-bogus "note: omit the .\\(Baz\\)., if" "" { target *-*-* } 79 } */ + +#pragma acc routine (Qux) seq +/* { dg-error ".Qux. has not been declared" "" { target *-*-* } 84 } + Don't try to help the user again: + { dg-bogus "note: omit the .\\(Qux\\)., if" "" { target *-*-* } 84 } */ int vb1; /* { dg-error "directive for use" } */