From patchwork Sat Dec 15 04:02:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 206602 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 98B2F2C00BD for ; Sat, 15 Dec 2012 15:02:59 +1100 (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=1356148980; h=Comment: DomainKey-Signature: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=vIyVQyu jAToXPoctsSiNeaUit3E=; b=M49O6ZGI21JylqlSHxWmtQETfFFiRHNKnLw/3av nESLgaKACmHcSNUrmbT2eSSua7X6Dvg6jU/nQsOC1XQGOpGKaWFnk9T9qAxueTpC 3GlfgxK+IvtVNLVvdW8ulmT86kqtfd42WUJusM1MFxDCdh1kTvj5ZtjlaVmc/uy4 HoFo= 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: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; b=FycDWvQzSnWwcJYRm3+aQ+cBwZWa+N6HWEb9XBAqebB4H5hpaMu082Ph7Oyh5w 3hTRzhF3FTZeC1das7EjvD45Cp+5de1Ag+igSTDuCQw4k12JSoqmDDM0hvF2cF7K X8YrcBqTSkbaNIR3MVRugtCiirqfPeQLKLchfwQuja4v8=; Received: (qmail 2753 invoked by alias); 15 Dec 2012 04:02:53 -0000 Received: (qmail 2731 invoked by uid 22791); 15 Dec 2012 04:02:52 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SPF_HELO_PASS 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; Sat, 15 Dec 2012 04:02:44 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBF42hAY005690 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 14 Dec 2012 23:02:43 -0500 Received: from [10.3.113.19] ([10.3.113.19]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id qBF42c9x001194; Fri, 14 Dec 2012 23:02:43 -0500 Message-ID: <50CBF65E.8080308@redhat.com> Date: Fri, 14 Dec 2012 23:02:38 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: gcc-patches List CC: Jakub Jelinek Subject: C++ PATCH for c++/55685 (ICE with sizeof in template) 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 Here the problem was that tsubst_copy_and_build wasn't guarding the SIZEOF_EXPR_TYPE_P code with processing_template_decl like we do in the parser. It's still necessary here because sometimes tsubsting happens when we're still in a template. Fixed by updating the code to match. Tested x86_64-pc-linux-gnu, applying to trunk. commit f415d192e2b16069344b5b9bea9c48dc2a217f99 Author: Jason Merrill Date: Fri Dec 14 16:10:39 2012 -0500 PR c++/55685 * pt.c (tsubst_copy_and_build): Don't use SIZEOF_EXPR_TYPE_P in templates. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 91450d8..a21522b 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -13563,7 +13563,7 @@ tsubst_copy_and_build (tree t, { if (TREE_CODE (r) != SIZEOF_EXPR || TYPE_P (op1)) { - if (TYPE_P (op1)) + if (!processing_template_decl && TYPE_P (op1)) { r = build_min (SIZEOF_EXPR, size_type_node, build1 (NOP_EXPR, op1, error_mark_node)); diff --git a/gcc/testsuite/g++.dg/template/sizeof15.C b/gcc/testsuite/g++.dg/template/sizeof15.C new file mode 100644 index 0000000..3298dad3 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/sizeof15.C @@ -0,0 +1,13 @@ +// PR c++/55685 + +typedef __SIZE_TYPE__ size_t; +template +struct A; + +template struct B +{ + static A x; +}; + +template +A B ::x;