From patchwork Tue Mar 29 18:57:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 88833 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 4180DB6EEA for ; Wed, 30 Mar 2011 05:57:45 +1100 (EST) Received: (qmail 9860 invoked by alias); 29 Mar 2011 18:57:44 -0000 Received: (qmail 9849 invoked by uid 22791); 29 Mar 2011 18:57:43 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, 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; Tue, 29 Mar 2011 18:57:32 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p2TIvW8t028151 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 29 Mar 2011 14:57:32 -0400 Received: from [127.0.0.1] ([10.3.113.2]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p2TIvVwt019585 for ; Tue, 29 Mar 2011 14:57:31 -0400 Message-ID: <4D922B9A.3050600@redhat.com> Date: Tue, 29 Mar 2011 14:57:30 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Lightning/1.0b2 Thunderbird/3.1.9 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/48319 (ICE with value-dependent call) 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 In this testcase, we were failing to consider declval<_Args1> as value-dependent, even though it is due to the use of a type parameter. We previously just handled TEMPLATE_ID_EXPR as a normal binary expression and assumed that a TREE_VEC was always non-dependent. Tested x86_64-pc-linux-gnu, applied to trunk and 4.6. commit 877698d7630d958bfbe1e7a7a69c8a4290c486a2 Author: Jason Merrill Date: Tue Mar 29 13:05:08 2011 -0400 PR c++/48319 * pt.c (value_dependent_expression_p): Handle TEMPLATE_ID_EXPR. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index dfc726a..aa0901b 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -18218,6 +18218,11 @@ value_dependent_expression_p (tree expression) return false; } + case TEMPLATE_ID_EXPR: + /* If a TEMPLATE_ID_EXPR involves a dependent name, it will be + type-dependent. */ + return type_dependent_expression_p (expression); + default: /* A constant expression is value-dependent if any subexpression is value-dependent. */ diff --git a/gcc/testsuite/g++.dg/cpp0x/dependent1.C b/gcc/testsuite/g++.dg/cpp0x/dependent1.C new file mode 100644 index 0000000..1ceeeaf --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/dependent1.C @@ -0,0 +1,25 @@ +// PR c++/48319 +// { dg-options -std=c++0x } +// We were failing to recognize declval<_Args1> as dependent. + +template Tp declval() noexcept; + +template +class __is_constructible_helper +{ + typedef char __one; + typedef struct { char __arr[2]; } __two; + + template + static decltype(_Tp1(declval<_Args1>()...), __one()) __test(int); + + template + static __two __test(...); + +public: + static const bool __value = sizeof(__test<_Tp>(0)) == 1; +}; + +int main() { + return __is_constructible_helper::__value; +}