From patchwork Thu Apr 14 20:12:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 610637 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 3qmBfT2V39z9sC3 for ; Fri, 15 Apr 2016 06:12:17 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=rsbFppJv; 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:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=BETpDIuZ0jd6XxW6xsvYoLkD/NdyWD+seCz8x7jNMawzYg4gFF W/10Lx1Cm03Vl2zPhGqWb8Jc65dIW2pgE397uxc52Kv+fMBYBwghdOHnU+LeVce+ 5vu47eL4q8Xlp4SlIVoPSDm3XQtmKtK2QwLOkk7cACAv1+46U38TnSdaM= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=iYu5ehY60jwJ3Kg4QSz49oPh3XE=; b=rsbFppJvTz+QqomNa8si uK4FDe3pWJxaozosN+NEE90oi3S7xxpMCgohvDlXGyabGCXkqsrYwDn9i2NpSnsq 2D277md7FPNnQWgOMwZaHC4Ku35sfGP6FWmI/OYnwM0ak9u0nPtCdPJBfIIJm8Un CLvZFAn1h1uwtjk3jnHOmc8= Received: (qmail 89083 invoked by alias); 14 Apr 2016 20:12:06 -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 89071 invoked by uid 89); 14 Apr 2016 20:12:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1530 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 14 Apr 2016 20:12:05 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3F210C04B30C for ; Thu, 14 Apr 2016 20:12:04 +0000 (UTC) Received: from [10.10.116.23] (ovpn-116-23.rdu2.redhat.com [10.10.116.23]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3EKC04j032704 for ; Thu, 14 Apr 2016 16:12:03 -0400 To: gcc-patches List From: Jason Merrill Subject: C++ PATCH for c++/70543 (wrong error with static const as array bound) Message-ID: <570FF990.9080603@redhat.com> Date: Thu, 14 Apr 2016 16:12:00 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 When we consider whether the initializer for a constant variable makes it value-dependent, we should check type-dependence as well as value-dependence. Tested x86_64-pc-linux-gnu, applying to trunk. commit 4af96532b224029a20b192be2e7cedc60b9d12d0 Author: Jason Merrill Date: Thu Apr 14 13:23:44 2016 -0400 PR c++/70543 * pt.c (value_dependent_expression_p) [VAR_DECL]: A type-dependent initializer also makes the variable value-dependent. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index d066e55..4a00530 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -22670,6 +22670,7 @@ value_dependent_expression_p (tree expression) && (TREE_CODE (DECL_INITIAL (expression)) == TREE_LIST /* cp_finish_decl doesn't fold reference initializers. */ || TREE_CODE (TREE_TYPE (expression)) == REFERENCE_TYPE + || type_dependent_expression_p (DECL_INITIAL (expression)) || value_dependent_expression_p (DECL_INITIAL (expression)))) return true; return false; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-template9.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-template9.C new file mode 100644 index 0000000..2ca641d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-template9.C @@ -0,0 +1,17 @@ +// PR c++/70543 +// { dg-do compile { target c++11 } } + +template +struct X +{ + template + static constexpr int + calc (void) + { + return 0; + } + + static constexpr unsigned int value = calc (); + + char foo[value]; +};