From patchwork Fri Jun 1 19:55:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 162364 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 32F4BB6FFE for ; Sat, 2 Jun 2012 05:56:08 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1339185369; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject: References:In-Reply-To:Content-Type:Content-Transfer-Encoding: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=WnFqQWHxtCQLinvnp5VI cT+1Lks=; b=mC8311zOswjO7Ltm/vqbm9q9JRU6jXF6OT7EMJuRy47RUQKKja7M 5L2e9w87oLtlk+0h7SPLiooFrfYg2Pb8slTPB734R2o6G6c+nVCzHDfwA/BUGlZ/ a6Uja4UX7MsSr8AiUTI6jlD0d/11VA4o0auB4Aok5h1U6p391r4/gug= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:Content-Transfer-Encoding:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=qu/nZOU69n3F82xZChusFOEYe0FtSVgkFMDJJm/hSpOSfMLEQIf5FR9+bo0xbS eIO+ZLu5nRQsh7HNBFJ7/0I1JV3nXF4APYPHZBfGNV700peCFsjE6ophPJf9gBW0 XPpK2FOZymQoMp2PPrvHPqcNKjq7Y2uuq9accTaSbS03g=; Received: (qmail 19394 invoked by alias); 1 Jun 2012 19:56:04 -0000 Received: (qmail 19386 invoked by uid 22791); 1 Jun 2012 19:56:03 -0000 X-SWARE-Spam-Status: No, hits=-7.4 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_THREADED, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 01 Jun 2012 19:55:48 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q51JtlGF023798 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 1 Jun 2012 15:55:48 -0400 Received: from dhcp-5-241.str.redhat.com (ovpn-116-78.ams2.redhat.com [10.36.116.78]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q51Jtjwb003149 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Fri, 1 Jun 2012 15:55:47 -0400 Message-ID: <4FC91E41.1080406@redhat.com> Date: Fri, 01 Jun 2012 21:55:45 +0200 From: Florian Weimer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: Jason Merrill CC: gcc-patches@gcc.gnu.org Subject: Re: [C++] Reject variably modified types in operator new References: <4FC4F2AE.2090106@redhat.com> <4FC88495.60607@redhat.com> <4FC8B116.6000607@redhat.com> <4FC8E1B1.70605@redhat.com> <4FC8E258.3070008@redhat.com> <4FC8EB82.8010605@redhat.com> In-Reply-To: <4FC8EB82.8010605@redhat.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 On 06/01/2012 06:19 PM, Jason Merrill wrote: > On 06/01/2012 11:40 AM, Florian Weimer wrote: >> I'm puzzled why build_new is even invoked after detecting that there is >> a non-constant expression. > > I'd accept a patch to change that. I don't really now what I'm doing here. But I noticed that in cp_parser_constant_expression, a failure in require_potential_rvalue_constant_expression is not reported to the caller. This changes error reporting, and a few test cases need adjustment. In some, reporting is better, in others, it's slightly worse. I need to make a second pass over the changes to make sure that they are alright. Does this change make any sense at all? Index: gcc/cp/parser.c =================================================================== --- gcc/cp/parser.c (revision 188104) +++ gcc/cp/parser.c (working copy) @@ -7701,8 +7701,9 @@ cp_parser_constant_expression (cp_parser* parser, separately in e.g. cp_parser_template_argument. */ bool is_const = potential_rvalue_constant_expression (expression); parser->non_integral_constant_expression_p = !is_const; - if (!is_const && !allow_non_constant_p) - require_potential_rvalue_constant_expression (expression); + if (!is_const && !allow_non_constant_p + && !require_potential_rvalue_constant_expression (expression)) + expression = error_mark_node; } if (allow_non_constant_p) *non_constant_p = parser->non_integral_constant_expression_p;