From patchwork Wed Feb 1 13:24:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 722524 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vD3lN075zz9svs for ; Thu, 2 Feb 2017 00:25:03 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="TZfPjVNl"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=hVs/q+yc713MmX3uZVmaD3kAGoWak7WOfBxpbL79oHTSa44bGs 6IPzTn27VkyI5fNuWGyn0o9lxIx/wT345RAp39RF8gVvkVOxO6qqQEk3fzQQl9KY dhG9kxGHqDOIuJbGzKGvUrjpxF5Hz96ekZ/RG1RY6+kEAVT0/MWXFnIko= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=DnJYenC9FI3V+dniiMFB3HrlezI=; b=TZfPjVNlHP2WDIdtv0Kt WKDZrRs3Q+gliTpwAn56Xj+mI22dtjcH5A5wKZ5P9zz3BtDRqVJ/Hw9Teuug03gb VIKta1injcDlPS/fc+LHWfJEgyliF+VvanwjzutGVglrjTY/gkus6C9qc3ZUQ/ZE GdDilGEfdavpasKBFaXhhQE= Received: (qmail 127405 invoked by alias); 1 Feb 2017 13:24:55 -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 126850 invoked by uid 89); 1 Feb 2017 13:24:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.3 required=5.0 tests=BAYES_05, KAM_ASCII_DIVIDERS, RP_MATCHES_RCVD, SPF_PASS autolearn=no version=3.3.2 spammy=decl2c, decl2.c, UD:decl2.c, sk:TEMPLAT X-HELO: userp1040.oracle.com Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 01 Feb 2017 13:24:44 +0000 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v11DOfsq032359 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 1 Feb 2017 13:24:42 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.13.8/8.14.4) with ESMTP id v11DOeIc014858 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 1 Feb 2017 13:24:41 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v11DOdDl028212; Wed, 1 Feb 2017 13:24:39 GMT Received: from [192.168.1.4] (/79.19.239.4) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 01 Feb 2017 05:24:39 -0800 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] PR 69637 Message-ID: <3eec85dc-878a-4bb5-6a19-8efe7a0aaa78@oracle.com> Date: Wed, 1 Feb 2017 14:24:35 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, I'm still working on a number of ICEs on invalid happening during error recovery... In these cases, after a meaningful diagnostic, we ICE in cxx_eval_constant_expression because it doesn't handle OVERLOADs and TEMPLATE_ID_EXPRs in the main switch. I tried a number of different approaches, but I think the most straightforward one is the below: avoid setting up in grokbitfield DECL_INITIAL (and SET_DECL_C_BIT_FIELD) after the early diagnostic, exactly as currently happens when the width passed to the function is an error_mark_node. In particular, the approach seems robust because the callers don't use the the width information afterward (it's only passed to grokbitfield). Tested x86_64-linux. Thanks, Paolo. /////////////////// /cp 2017-02-01 Paolo Carlini PR c++/69637 * decl2.c (grokbitfield): In case of error don't set-up DECL_INITIAL to the width. /testsuite 2017-02-01 Paolo Carlini PR c++/69637 * g++.dg/cpp0x/pr69637-1.C: New. * g++.dg/cpp0x/pr69637-2.C: Likewise. Index: cp/decl2.c =================================================================== --- cp/decl2.c (revision 245084) +++ cp/decl2.c (working copy) @@ -1059,8 +1059,11 @@ grokbitfield (const cp_declarator *declarator, && !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; - SET_DECL_C_BIT_FIELD (value); + else + { + DECL_INITIAL (value) = width; + SET_DECL_C_BIT_FIELD (value); + } } DECL_IN_AGGR_P (value) = 1; Index: testsuite/g++.dg/cpp0x/pr69637-1.C =================================================================== --- testsuite/g++.dg/cpp0x/pr69637-1.C (revision 0) +++ testsuite/g++.dg/cpp0x/pr69637-1.C (working copy) @@ -0,0 +1,8 @@ +// { dg-do compile { target c++11 } } + +template +int foo () { return 1; } + +struct B { + unsigned c: foo; // { dg-error "non-integral type" } +}; Index: testsuite/g++.dg/cpp0x/pr69637-2.C =================================================================== --- testsuite/g++.dg/cpp0x/pr69637-2.C (revision 0) +++ testsuite/g++.dg/cpp0x/pr69637-2.C (working copy) @@ -0,0 +1,6 @@ +// { dg-do compile { target c++11 } } + +template +constexpr int foo () { return N; } + +struct B { unsigned c: foo, 3(); }; // { dg-error "non-integral type|expected" }