From patchwork Tue Jan 5 14:42:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 563148 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 944DB140324 for ; Wed, 6 Jan 2016 01:42:36 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=v/S/Fx6Y; 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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=orsWrxnfuwkNLtzPp xYR4Nw3yjGYxlDRalMcj8pEYqVMa4Qn4IYwYbP3WKhxgQkN/e5Vhje1o6a8EvJlN +jGeJb6l3y9/YCd8P3tWPj6cUQ9ibEsMS/veZmVVdVJ4kMD4nACppCCmYEcbIVfi l5PJ4fpOxN2/2wuaBK6K+ayKoE= 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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=OmfaOwD+ebTb4XkdqdQIaHU nZhY=; b=v/S/Fx6YBRrd/4MwwXyN57Sow4pOEcAQMVTDsYuAaMDMsPcIrUCoOcW fb6AiQ7Uo2EVx9gqT5nz/Ju9h3g2tAxWT37poYkwtccGOkjtQStI6BGO/q71ZZDF iqhnBHOqgh4FhGK/XTfB3mYPch0Wy4SMgOg9rzcz+l5Blz3q4mUo= Received: (qmail 25399 invoked by alias); 5 Jan 2016 14:42:30 -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 25380 invoked by uid 89); 5 Jan 2016 14:42:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=BAYES_00, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 spammy=preserve, emphasize X-HELO: mail-qg0-f42.google.com Received: from mail-qg0-f42.google.com (HELO mail-qg0-f42.google.com) (209.85.192.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 05 Jan 2016 14:42:28 +0000 Received: by mail-qg0-f42.google.com with SMTP id 6so201026885qgy.1 for ; Tue, 05 Jan 2016 06:42:28 -0800 (PST) X-Received: by 10.140.129.203 with SMTP id 194mr48836200qhb.57.1452004946434; Tue, 05 Jan 2016 06:42:26 -0800 (PST) Received: from ?IPv6:2601:181:c000:c497:a2a8:cdff:fe3e:b48? ([2601:181:c000:c497:a2a8:cdff:fe3e:b48]) by smtp.googlemail.com with ESMTPSA id n91sm33534683qkh.11.2016.01.05.06.42.25 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 05 Jan 2016 06:42:26 -0800 (PST) Subject: Re: [Bug c++/58583] NSDMI parsing To: Jason Merrill References: <56855221.3030002@acm.org> <5685A2DA.4040303@redhat.com> Cc: GCC Patches , Richard Guenther From: Nathan Sidwell Message-ID: <568BD651.3060205@acm.org> Date: Tue, 5 Jan 2016 09:42:25 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <5685A2DA.4040303@redhat.com> On 12/31/15 16:49, Jason Merrill wrote: > Maybe disable the fold if parsing_nsdmi()? thanks. I've applied the attached. Richard, I've augmented the comment about the folding to emphasize the checkingness. nathan 2016-01-05 Nathan Sidwell gcc/cp/ PR c++/58583 * pt.c (build_non_dependent_expr): Don't try a checking fold when parsing an nsdmi. gcc/testsuite/ PR c++/58583 * g++.dg/cpp0x/nsdmi-template14.C: Adjust test & errors. Index: cp/pt.c =================================================================== --- cp/pt.c (revision 232074) +++ cp/pt.c (working copy) @@ -23416,9 +23416,13 @@ build_non_dependent_expr (tree expr) { tree inner_expr; - /* Try to get a constant value for all non-dependent expressions in - order to expose bugs in *_dependent_expression_p and constexpr. */ - if (flag_checking && cxx_dialect >= cxx11) + /* When checking, try to get a constant value for all non-dependent + expressions in order to expose bugs in *_dependent_expression_p + and constexpr. */ + if (flag_checking && cxx_dialect >= cxx11 + /* Don't do this during nsdmi parsing as it can lead to + unexpected recursive instantiations. */ + && !parsing_nsdmi ()) fold_non_dependent_expr (expr); /* Preserve OVERLOADs; the functions must be available to resolve Index: testsuite/g++.dg/cpp0x/nsdmi-template14.C =================================================================== --- testsuite/g++.dg/cpp0x/nsdmi-template14.C (revision 232074) +++ testsuite/g++.dg/cpp0x/nsdmi-template14.C (working copy) @@ -1,11 +1,13 @@ // PR c++/58583 // { dg-do compile { target c++11 } } -template struct A // { dg-error "has been parsed" } +template struct A { - int i = (A<0>(), 0); // { dg-error "has been parsed" } + int i = (A<0>(), 0); // { dg-error "recursive instantiation of non-static data" } }; +A<0> a; + template struct B { B* p = new B; // { dg-error "recursive instantiation of non-static data" }