From patchwork Thu Nov 24 00:37:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 127409 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]) by ozlabs.org (Postfix) with SMTP id 4E7CCB6F92 for ; Thu, 24 Nov 2011 11:38:43 +1100 (EST) Received: (qmail 15202 invoked by alias); 24 Nov 2011 00:38:41 -0000 Received: (qmail 15141 invoked by uid 22791); 24 Nov 2011 00:38:40 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from rcsinet15.oracle.com (HELO rcsinet15.oracle.com) (148.87.113.117) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 24 Nov 2011 00:38:25 +0000 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by rcsinet15.oracle.com (Switch-3.4.4/Switch-3.4.4) with ESMTP id pAO0cNnX000873 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 24 Nov 2011 00:38:24 GMT Received: from acsmt357.oracle.com (acsmt357.oracle.com [141.146.40.157]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id pAO0cM7O014364 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 24 Nov 2011 00:38:23 GMT Received: from abhmt114.oracle.com (abhmt114.oracle.com [141.146.116.66]) by acsmt357.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id pAO0cHZF027801; Wed, 23 Nov 2011 18:38:17 -0600 Received: from [192.168.1.4] (/79.52.211.129) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 23 Nov 2011 16:38:17 -0800 Message-ID: <4ECD91CE.10408@oracle.com> Date: Thu, 24 Nov 2011 01:37:34 +0100 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: Re: [RFC] PR C++/51225 References: <4ECD5E18.4060901@oracle.com> In-Reply-To: <4ECD5E18.4060901@oracle.com> X-IsSubscribed: yes 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 Hi again, > Thus, what to do? Definitely adding CAST_EXPR to the switch works, but > I'm wondering if we could do something else... but doesn't seem easy > to me given the above. For example, I suppose changing > potential_constant_expression to return true for error_mark_node would > be catastrophic, even if error_mark_node is definitely constant ;) Thus I decided to do the experiment: the below passes the testsuite, eh! Interestingly the tweak to the testcase below *align* the error messages produced to those produced with -std=c++98, just a little more terse. Thus, is my idea really crazy after all? (of course, given the analysis in the previous message, c++/51225 is also fixed) Thanks, Paolo. ///////////////// Index: testsuite/g++.dg/cpp0x/regress/error-recovery1.C =================================================================== --- testsuite/g++.dg/cpp0x/regress/error-recovery1.C (revision 181678) +++ testsuite/g++.dg/cpp0x/regress/error-recovery1.C (working copy) @@ -5,7 +5,7 @@ template < bool > void foo () { const bool b =; // { dg-error "" } - foo < b > (); // { dg-error "constant expression" } + foo < b > (); }; // { dg-error "no match" "" { target *-*-* } 8 } Index: cp/semantics.c =================================================================== --- cp/semantics.c (revision 181678) +++ cp/semantics.c (working copy) @@ -7923,9 +7923,7 @@ potential_constant_expression_1 (tree t, bool want if (cxx_dialect < cxx0x) return true; - if (t == error_mark_node) - return false; - if (t == NULL_TREE) + if (t == NULL_TREE || t == error_mark_node) return true; if (TREE_THIS_VOLATILE (t)) {