From patchwork Sat Jul 28 15:28:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 173873 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 B7D492C007D for ; Sun, 29 Jul 2012 01:29:10 +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=1344094151; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Message-ID:Date:From:User-Agent:MIME-Version: To:CC:Subject:Content-Type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=mzTrVrfgyAk1G5iAXgEUl4ho0Gk=; b=EH9vArBhTiCJGVk a2tURaaGpaHlI9NfSLLJD1E5JYmLMXrFTiZYy3jStINhtYF+Gt4UQupCipEJ6g4H tjwzCmkQPD2M5pADqijIB15655hFclaHBN2d7DjRZt1Ay5P7Vsc23zV00yEYUvax 4tcqCRuS1fQXMwj2r4xl+PJyBVGE= 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:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=XoNR+bL2AHXSD5nrNcJZ331J3MNutqyQflcxBjIx9qjKhhAIF4sbocN74yrwFB Fz9116NcTO3qHKwLl0uFfjWbb7YE8Syool0rzFVO/sDMUF1JUYibERFKp77/jXB1 xRkt2478dXiZbjtmvxstMpL9M9OTqDFCIkXz9bmBc0mWo=; Received: (qmail 9573 invoked by alias); 28 Jul 2012 15:29:04 -0000 Received: (qmail 9564 invoked by uid 22791); 28 Jul 2012 15:29:03 -0000 X-SWARE-Spam-Status: No, hits=-6.7 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_W, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from rcsinet15.oracle.com (HELO rcsinet15.oracle.com) (148.87.113.117) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 28 Jul 2012 15:28:49 +0000 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by rcsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q6SFSlWr021869 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 28 Jul 2012 15:28:48 GMT Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q6SFSlTh007435 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 28 Jul 2012 15:28:47 GMT Received: from abhmt103.oracle.com (abhmt103.oracle.com [141.146.116.55]) by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q6SFSkuV015185; Sat, 28 Jul 2012 10:28:46 -0500 Received: from [192.168.1.4] (/79.33.222.93) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 28 Jul 2012 08:28:46 -0700 Message-ID: <5014052C.1080208@oracle.com> Date: Sat, 28 Jul 2012 17:28:44 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] PR 53624 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 Hi, as the testcase shows (merge of 53624 & 54104), in case of local types (possibly synthesized for a lambda) we check for the default template arguments of the synthesized template parameters according to the rules for *types* (instead of those for functions) and we spuriously reject. As far as I can see we should just return early in such cases, because we already checked upstream, thus I figured out logic that apparently works, but I'm not sure it's the most precise and concise we can have. Bootstrap and regression tests are fine, anyway. Thanks, Paolo. ////////////////////////// /cp 2012-07-28 Paolo Carlini PR c++/53624 * pt.c (check_default_tmpl_args): Return early for local types. /testsuite 2012-07-28 Paolo Carlini PR c++/53624 * testsuite/g++.dg/cpp0x/temp_default5.C: New. Index: testsuite/g++.dg/cpp0x/temp_default5.C =================================================================== --- testsuite/g++.dg/cpp0x/temp_default5.C (revision 0) +++ testsuite/g++.dg/cpp0x/temp_default5.C (revision 0) @@ -0,0 +1,13 @@ +// { dg-options "-std=c++11" } + +template +void Foo(T) +{ + struct X {}; +} + +template +void f(const U&) +{ + auto g = [] () {}; +} Index: cp/pt.c =================================================================== --- cp/pt.c (revision 189925) +++ cp/pt.c (working copy) @@ -4229,6 +4229,7 @@ check_default_tmpl_args (tree decl, tree parms, in const char *msg; int last_level_to_check; tree parm_level; + tree type = TREE_TYPE (decl); bool no_errors = true; /* [temp.param] @@ -4244,6 +4245,10 @@ check_default_tmpl_args (tree decl, tree parms, in local scope. */ return true; + if (type && TREE_CODE (decl) != FUNCTION_DECL + && TREE_CODE (CP_TYPE_CONTEXT (type)) == FUNCTION_DECL) + return true; + if (current_class_type && !TYPE_BEING_DEFINED (current_class_type) && DECL_LANG_SPECIFIC (decl)