From patchwork Mon Jun 17 20:08:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 252054 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 7CEAA2C0299 for ; Tue, 18 Jun 2013 06:08:17 +1000 (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=AnN6b5SMhQuJHdSIROZGbZmbYn5Pco0lw5QMlA+Q1R3 lC+/+u47HUWGAFqcCpoQPrryfoPxr3qIxRnzDhVb93vSlktn1Rr/O4phvLgAQxOg uTdoI8THaECZbVk2EFId+25Fhr831WyCPOUb9V+ptr8v0vHBtlycHnM+eUsThelg = 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=2CGIfLyjBKuyw90JI6JQCExal74=; b=xDcr+W2qkE2G4i+6K 3DfhEvjG7CtrpwX+uOaWNd1rBHIU6FVbp1QTgLYAQcVyS6ZewmXp1f28ron2NByk e2lzR0LTro2T7fmpLYJzQfjAQcqWUuuUd0/4Jrsu+QAD3uhiXrjKwfYcNXSxfkPI QUz/PHZezloWSFcpAopxc60tcc= Received: (qmail 10048 invoked by alias); 17 Jun 2013 20:08:11 -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 10032 invoked by uid 89); 17 Jun 2013 20:08:10 -0000 X-Spam-SWARE-Status: No, score=-5.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, SPF_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 17 Jun 2013 20:08:09 +0000 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r5HK844j023120 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 17 Jun 2013 20:08:05 GMT Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r5HK86OJ005072 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 17 Jun 2013 20:08:06 GMT Received: from abhmt117.oracle.com (abhmt117.oracle.com [141.146.116.69]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r5HK85tw002306; Mon, 17 Jun 2013 20:08:05 GMT Received: from poldo4.casa (/79.52.193.146) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2013 13:08:05 -0700 Message-ID: <51BF6CA3.1050200@oracle.com> Date: Mon, 17 Jun 2013 22:08:03 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch / RFC] PR 53211 X-Virus-Found: No Hi, while triaging this PR (the original issue is already fixed) Jonathan added to the audit trail the attached testcase, which we are still mishandling. It seems to me that something is wrong in instantiation_dependent_expression_p: when finish_decltype_type is called the first time by the parser, and calls in turns instantiation_dependent_expression_p on the VAR_DECL arr, it returns *false*, whereas of course the type of arr, as far as the number of elements is concerned, depends on the actual variadic Args. Thus I tried the patchlet below, which works, but I'm not sure if it's papering over a deeper issue, or, in case the approach makes sense in general, whether the check should be tweaked somehow. It's what I have at the moment, anyway... Thanks! Paolo. ////////////////////// Index: cp/pt.c =================================================================== --- cp/pt.c (revision 200151) +++ cp/pt.c (working copy) @@ -20148,6 +20148,11 @@ instantiation_dependent_r (tree *tp, int *walk_sub return NULL_TREE; case VAR_DECL: + if (TREE_CODE (TREE_TYPE (*tp)) == ARRAY_TYPE + && !TYPE_DOMAIN (TREE_TYPE (*tp)) + && DECL_INITIAL (*tp) + && type_dependent_expression_p (DECL_INITIAL (*tp))) + return *tp; case CONST_DECL: /* A constant with a dependent initializer is dependent. */ if (value_dependent_expression_p (*tp)) Index: testsuite/g++.dg/cpp0x/decltype55.C =================================================================== --- testsuite/g++.dg/cpp0x/decltype55.C (revision 0) +++ testsuite/g++.dg/cpp0x/decltype55.C (working copy) @@ -0,0 +1,20 @@ +// PR c++/53211 +// { dg-do compile { target c++11 } } + +template + struct is_same { static const bool value = false; }; + +template + struct is_same { static const bool value = true; }; + +template +void func(Args... args) +{ + int arr[] = { args... }; + static_assert (is_same::value, ""); +} + +int main() +{ + func(1, 2, 3, 4); +}