From patchwork Sat Jun 28 21:42:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 365320 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 A037814001A for ; Sun, 29 Jun 2014 07:46:24 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=pSz2t6xkYJLGYedB8xobky24ZpK+2ddbj5MUq9QViWH wBra9GgZJnInW5hQaBffngo7sFPIv9J/ACKO6Bmc2lqzi51lmflH8h1rQcxZ4oTv LfCuMtZrQsV+F2ke9lGmdMk2CadLaVXfpLRkGd5+kKTeKqTatj5o+6+SRf0tK8fo = 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 :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=FDHBhDgQ/07oclUjrlX5ebI23mI=; b=sw62oqKnFe0/04/Y1 b2U0kjApa4t2Ve0IBJ64rCqg/9gDq1Q3B92wecFGl6z4LdSEyIeuX4da4m6Xd3CG 21V2bQbzjKoi/AmkmfnKSmeXk8SF4Q9nRjkDgUJfenDBECiaHgrJL5SDE2I0dOW0 Ln6/9+VO4/8MaKgcC3E4Fsjanw= Received: (qmail 24867 invoked by alias); 28 Jun 2014 21:46:16 -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 24842 invoked by uid 89); 28 Jun 2014 21:46:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL, BAYES_00, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: aserp1040.oracle.com Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Sat, 28 Jun 2014 21:46:14 +0000 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s5SLkAcX011806 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 28 Jun 2014 21:46:10 GMT Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s5SLk7bs021081 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Sat, 28 Jun 2014 21:46:09 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s5SLk7oF019008; Sat, 28 Jun 2014 21:46:07 GMT Received: from [192.168.1.4] (/87.16.208.185) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 28 Jun 2014 14:46:07 -0700 Message-ID: <53AF36CB.7080200@oracle.com> Date: Sat, 28 Jun 2014 23:42:35 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] PR 51400 X-IsSubscribed: yes Hi, this issue manifests itself as an ICE on the gcc_assert toward the end of start_decl: if (VAR_P (decl) && DECL_NAMESPACE_SCOPE_P (decl) && !TREE_PUBLIC (decl) && !was_public && !DECL_THIS_STATIC (decl) && !DECL_ARTIFICIAL (decl)) { /* This is a const variable with implicit 'static'. Set DECL_THIS_STATIC so we can tell it from variables that are !TREE_PUBLIC because of the anonymous namespace. */ gcc_assert (CP_TYPE_CONST_P (TREE_TYPE (decl)) || errorcount); DECL_THIS_STATIC (decl) = 1; } and the reason seems clear to me: both handle_noreturn_attribute and handle_const_attribute call build_pointer_type and discard the TYPE_QUALS on the original POINTER_TYPE. That seems obviously incorrect. The below fixes the ICE and passes testing. Thanks! Paolo. ///////////////// /c-family 2014-06-28 Paolo Carlini PR c++/51400 * c-common.c (handle_noreturn_attribute, handle_const_attribute): Do not discard TYPE_QUALS of type. /testsuite 2014-06-28 Paolo Carlini PR c++/51400 * g++.dg/cpp0x/constexpr-attribute3.C: New. Index: c-family/c-common.c =================================================================== --- c-family/c-common.c (revision 212104) +++ c-family/c-common.c (working copy) @@ -6575,9 +6575,11 @@ handle_noreturn_attribute (tree *node, tree name, else if (TREE_CODE (type) == POINTER_TYPE && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE) TREE_TYPE (*node) - = build_pointer_type - (build_type_variant (TREE_TYPE (type), - TYPE_READONLY (TREE_TYPE (type)), 1)); + = (build_qualified_type + (build_pointer_type + (build_type_variant (TREE_TYPE (type), + TYPE_READONLY (TREE_TYPE (type)), 1)), + TYPE_QUALS (type))); else { warning (OPT_Wattributes, "%qE attribute ignored", name); @@ -6988,9 +6990,11 @@ handle_const_attribute (tree *node, tree name, tre else if (TREE_CODE (type) == POINTER_TYPE && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE) TREE_TYPE (*node) - = build_pointer_type - (build_type_variant (TREE_TYPE (type), 1, - TREE_THIS_VOLATILE (TREE_TYPE (type)))); + = (build_qualified_type + (build_pointer_type + (build_type_variant (TREE_TYPE (type), 1, + TREE_THIS_VOLATILE (TREE_TYPE (type)))), + TYPE_QUALS (type))); else { warning (OPT_Wattributes, "%qE attribute ignored", name); Index: testsuite/g++.dg/cpp0x/constexpr-attribute3.C =================================================================== --- testsuite/g++.dg/cpp0x/constexpr-attribute3.C (revision 0) +++ testsuite/g++.dg/cpp0x/constexpr-attribute3.C (working copy) @@ -0,0 +1,5 @@ +// PR c++/51400 +// { dg-do compile { target c++11 } } + +constexpr int (*f)() __attribute__((noreturn)) = 0; +constexpr int (*g)() __attribute__((const)) = 0;