From patchwork Tue Mar 1 22:37:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 84995 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 F2DC6B7088 for ; Wed, 2 Mar 2011 09:37:31 +1100 (EST) Received: (qmail 5697 invoked by alias); 1 Mar 2011 22:37:29 -0000 Received: (qmail 5581 invoked by uid 22791); 1 Mar 2011 22:37:27 -0000 X-SWARE-Spam-Status: No, hits=-6.2 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, 01 Mar 2011 22:37:16 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p21MbFcf012039 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 1 Mar 2011 17:37:15 -0500 Received: from [127.0.0.1] (ovpn-113-31.phx2.redhat.com [10.3.113.31]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p21MbEe7031644 for ; Tue, 1 Mar 2011 17:37:15 -0500 Message-ID: <4D6D751A.2070609@redhat.com> Date: Tue, 01 Mar 2011 17:37:14 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b2 Thunderbird/3.1.7 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/46282 (ICE on invalid in grokbitfield) 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 Testing the code of TREE_TYPE (width) doesn't work too well if TREE_TYPE (width) is null, as for a type-dependent expression. Tested x86_64-pc-linux-gnu, applied to trunk. commit 48accfb6db3a227ccecbcaef809cfb89db42484d Author: Jason Merrill Date: Tue Mar 1 01:32:00 2011 -0500 PR c++/46282 * decl2.c (grokbitfield): Handle type-dependent width. diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 93d44a4..eb5d4f5 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1052,7 +1052,8 @@ grokbitfield (const cp_declarator *declarator, if (width != error_mark_node) { /* The width must be an integer type. */ - if (!INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P (TREE_TYPE (width))) + if (!type_dependent_expression_p (width) + && !INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P (TREE_TYPE (width))) error ("width of bit-field %qD has non-integral type %qT", value, TREE_TYPE (width)); DECL_INITIAL (value) = width; diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/bitfield-err1.C b/gcc/testsuite/g++.dg/cpp0x/regress/bitfield-err1.C new file mode 100644 index 0000000..a2e9d47 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/bitfield-err1.C @@ -0,0 +1,9 @@ +// PR c++/46282 +// { dg-options -std=c++0x } + +template +class A +{ + A : i() {} // { dg-message "" } + int i; +};