From patchwork Mon Mar 25 23:40:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 231027 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 38F3E2C00E5 for ; Tue, 26 Mar 2013 10:40:49 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=id4GmekCQFMjq6AF/iwZDMyVdO6JsEvRyZoFEpDbevs EsWQfLqylxSt+3ZX59yd6gefT5apcC0HvrolLVpGMGSD8/dp4fF8sBmtEy3qpMRc GY+evrxwcANGEyQ7ZFKDS0itV/4T/uIzz126B1Ea49HajNc8RwL1pXeFUXJwIMA8 = 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 :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=H1Mqs2lvcXq0vmWGE/K8httdtFY=; b=oQqw174gfH1ENCOLU TnJ12C86sntYkOKybQU7R3h56du+DKIac1WieFWTMgegnqaHb24n/kBFsD+Ed2/1 b3tlisdJq4rc9b+cqMUSSwIhxncsH1d9IAWZw7yapthpaRtwUM5XuogaCD67fMX2 4zjUL6uwe9BanEOTKXC441EoPo= Received: (qmail 2376 invoked by alias); 25 Mar 2013 23:40:39 -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 2358 invoked by uid 89); 25 Mar 2013 23:40:31 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 25 Mar 2013 23:40:31 +0000 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r2PNeSli032711 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 25 Mar 2013 23:40:29 GMT Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156]) by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r2PNeRAp002829 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 25 Mar 2013 23:40:28 GMT Received: from abhmt111.oracle.com (abhmt111.oracle.com [141.146.116.63]) by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id r2PNeR69002214; Mon, 25 Mar 2013 18:40:27 -0500 Received: from [192.168.1.4] (/79.53.234.117) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 25 Mar 2013 16:40:27 -0700 Message-ID: <5150E065.60306@oracle.com> Date: Tue, 26 Mar 2013 00:40:21 +0100 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130307 Thunderbird/17.0.4 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] Handle separately and in grokfndecl error messages X-Virus-Found: No Hi, I split out two - rather straightforward IMHO - changes from the largish patch I posted a few days ago: this one improves the accuracy of some error messages produced by grokfndecl. Tested x86_64-linux. Thanks, Paolo. ////////////////////// /cp 2013-03-25 Paolo Carlini * decl.c (grokfndecl): Handle separately and error messages. /testsuite 2013-03-25 Paolo Carlini * g++.dg/cpp0x/constexpr-friend-2.C: New. * g++.dg/cpp0x/constexpr-main.C: Likewise. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 197053) +++ cp/decl.c (working copy) @@ -7426,13 +7426,16 @@ grokfndecl (tree ctype, return NULL_TREE; } + if (inlinep & 1) + error ("% is not allowed in declaration of friend " + "template specialization %qD", + decl); + if (inlinep & 2) + error ("% is not allowed in declaration of friend " + "template specialization %qD", + decl); if (inlinep) - { - error ("% is not allowed in declaration of friend " - "template specialization %qD", - decl); - return NULL_TREE; - } + return NULL_TREE; } } @@ -7471,8 +7474,10 @@ grokfndecl (tree ctype, { if (PROCESSING_REAL_TEMPLATE_DECL_P()) error ("cannot declare %<::main%> to be a template"); - if (inlinep) + if (inlinep & 1) error ("cannot declare %<::main%> to be inline"); + if (inlinep & 2) + error ("cannot declare %<::main%> to be constexpr"); if (!publicp) error ("cannot declare %<::main%> to be static"); inlinep = 0; Index: testsuite/g++.dg/cpp0x/constexpr-friend-2.C =================================================================== --- testsuite/g++.dg/cpp0x/constexpr-friend-2.C (revision 0) +++ testsuite/g++.dg/cpp0x/constexpr-friend-2.C (working copy) @@ -0,0 +1,7 @@ +// { dg-do compile { target c++11 } } + +template void f(T); + +template class A { + friend constexpr void f<>(int); // { dg-error "'constexpr' is not allowed" } +}; Index: testsuite/g++.dg/cpp0x/constexpr-main.C =================================================================== --- testsuite/g++.dg/cpp0x/constexpr-main.C (revision 0) +++ testsuite/g++.dg/cpp0x/constexpr-main.C (working copy) @@ -0,0 +1,3 @@ +// { dg-do compile { target c++11 } } + +constexpr int main (); // { dg-error "constexpr" }