From patchwork Fri Jan 24 23:13:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 314100 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 228F62C007E for ; Sat, 25 Jan 2014 10:14:14 +1100 (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=LuE8lJ5zMBfU8fgTtR7L/e7l3JmFXpOBNlXtBG1B4oY bf9z8KilEcK5o65hVZx4+ApySJlj3+v0vRpORP96x9DSHohwBBWRqvobsUlTPkBB Icz1mMV/qS9LD8wTtRpyiDUeEM+CAvziDrMLMoym6qdUP2XHsOB7Z7d7a8H/NMqQ = 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=UVXJC98gJf6bdATGUj33A63xua4=; b=TLJBXx72j3qA9tJv+ 7nERDU0DGUvBMm4zYyA0hlUlndW+ah9lqbbCwFaBDC1w4Jo1zXs4lDDG3OT7yJUH VSH24dnJ0opLwWW7wWaT5syppDqNfMnqX4kBCeVx5E1l++DHedLx5sM0w8dUv0n0 cpHmIIy7QgoV81z45dz3sAaCCw= Received: (qmail 7703 invoked by alias); 24 Jan 2014 23:14:06 -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 7690 invoked by uid 89); 24 Jan 2014 23:14:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL, BAYES_00, FSL_NEW_HELO_USER, RP_MATCHES_RCVD, SPF_PASS autolearn=no version=3.3.2 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 (AES256-SHA encrypted) ESMTPS; Fri, 24 Jan 2014 23:14:04 +0000 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s0ONE1Ve005937 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 24 Jan 2014 23:14:02 GMT Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s0ONE0vn012320 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 24 Jan 2014 23:14:01 GMT Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s0ONE0Gw001981; Fri, 24 Jan 2014 23:14:00 GMT Received: from [192.168.1.4] (/79.40.56.44) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 24 Jan 2014 15:14:00 -0800 Message-ID: <52E2F3B6.4050003@oracle.com> Date: Sat, 25 Jan 2014 00:13:58 +0100 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ RFC/Patch] PR 58561 X-IsSubscribed: yes Hi, in this bug we ICE in dwarf2out.c:is_base_type with -g, because it doesn't know how to handle the TEMPLATE_TYPE_PARM coming from the C++ front-end and representing 'auto' in this kind of C++1y code. That it shouldn't ICE and return 0 instead I'm pretty sure, I'm less sure about the next problem, that is what gen_type_die_with_usage should do: build a DW_TAG_unspecified_type, like happens for NULLPTR_TYPE or LANG_TYPE?!? Anyway, my wild guessing resulted in adding an hook, per the below draft (in any case, tentative names and comments but passes testing). Or we want something completely different? Thanks, Paolo. /////////////////////// Index: cp/cp-lang.c =================================================================== --- cp/cp-lang.c (revision 207048) +++ cp/cp-lang.c (working copy) @@ -68,6 +68,9 @@ static tree get_template_argument_pack_elems_folde #undef LANG_HOOKS_GENERIC_GENERIC_PARAMETER_DECL_P #define LANG_HOOKS_GENERIC_GENERIC_PARAMETER_DECL_P \ template_template_parameter_p +#undef LANG_HOOKS_IS_AUTO +#define LANG_HOOKS_IS_AUTO \ + is_auto #undef LANG_HOOKS_FUNCTION_PARM_EXPANDED_FROM_PACK_P #define LANG_HOOKS_FUNCTION_PARM_EXPANDED_FROM_PACK_P \ function_parameter_expanded_from_pack_p Index: dwarf2out.c =================================================================== --- dwarf2out.c (revision 207048) +++ dwarf2out.c (working copy) @@ -10222,6 +10222,9 @@ base_type_die (tree type) static inline int is_base_type (tree type) { + if (lang_hooks.decls.is_auto (type)) + return 0; + switch (TREE_CODE (type)) { case ERROR_MARK: @@ -19653,6 +19656,23 @@ gen_tagged_type_die (tree type, when appropriate. */ } +/* Generate a DIE for an unspecified type. */ + +static void +gen_unspecified_type_die (tree type) +{ + dw_die_ref type_die = lookup_type_die (type); + if (type_die == NULL) + { + tree name = TYPE_NAME (type); + if (TREE_CODE (name) == TYPE_DECL) + name = DECL_NAME (name); + type_die = new_die (DW_TAG_unspecified_type, comp_unit_die (), type); + add_name_attribute (type_die, IDENTIFIER_POINTER (name)); + equate_type_number_to_die (type, type_die); + } +} + /* Generate a type description DIE. */ static void @@ -19718,6 +19738,13 @@ gen_type_die_with_usage (tree type, dw_die_ref con return; } + if (lang_hooks.decls.is_auto (type)) + { + gen_unspecified_type_die (type); + TREE_ASM_WRITTEN (type) = 1; + return; + } + /* We are going to output a DIE to represent the unqualified version of this type (i.e. without any const or volatile qualifiers) so get the main variant (i.e. the unqualified version) of this type @@ -19805,18 +19832,7 @@ gen_type_die_with_usage (tree type, dw_die_ref con case NULLPTR_TYPE: case LANG_TYPE: /* Just use DW_TAG_unspecified_type. */ - { - dw_die_ref type_die = lookup_type_die (type); - if (type_die == NULL) - { - tree name = TYPE_NAME (type); - if (TREE_CODE (name) == TYPE_DECL) - name = DECL_NAME (name); - type_die = new_die (DW_TAG_unspecified_type, comp_unit_die (), type); - add_name_attribute (type_die, IDENTIFIER_POINTER (name)); - equate_type_number_to_die (type, type_die); - } - } + gen_unspecified_type_die (type); break; default: Index: langhooks-def.h =================================================================== --- langhooks-def.h (revision 207048) +++ langhooks-def.h (working copy) @@ -159,6 +159,7 @@ extern tree lhd_make_node (enum tree_code); #define LANG_HOOKS_FUNCTION_PARAMETER_PACK_P hook_bool_const_tree_false #define LANG_HOOKS_GET_ARGUMENT_PACK_ELEMS hook_tree_const_tree_null #define LANG_HOOKS_GENERIC_GENERIC_PARAMETER_DECL_P hook_bool_const_tree_false +#define LANG_HOOKS_IS_AUTO hook_bool_const_tree_false #define LANG_HOOKS_FUNCTION_PARM_EXPANDED_FROM_PACK_P \ hook_bool_tree_tree_false #define LANG_HOOKS_GET_GENERIC_FUNCTION_DECL hook_tree_const_tree_null @@ -220,6 +221,7 @@ extern tree lhd_make_node (enum tree_code); LANG_HOOKS_GETDECLS, \ LANG_HOOKS_FUNCTION_DECL_EXPLICIT_P, \ LANG_HOOKS_GENERIC_GENERIC_PARAMETER_DECL_P, \ + LANG_HOOKS_IS_AUTO, \ LANG_HOOKS_FUNCTION_PARM_EXPANDED_FROM_PACK_P, \ LANG_HOOKS_GET_GENERIC_FUNCTION_DECL, \ LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL, \ Index: langhooks.h =================================================================== --- langhooks.h (revision 207048) +++ langhooks.h (working copy) @@ -164,6 +164,9 @@ struct lang_hooks_for_decls of a generic type, e.g a template template parameter for the C++ FE. */ bool (*generic_generic_parameter_decl_p) (const_tree); + /* Returns true if the parameter represents 'auto' or 'decltype(auto)'. */ + bool (*is_auto) (const_tree); + /* Determine if a function parameter got expanded from a function parameter pack. */ bool (*function_parm_expanded_from_pack_p) (tree, tree); Index: testsuite/g++.dg/cpp1y/auto-fn22.C =================================================================== --- testsuite/g++.dg/cpp1y/auto-fn22.C (revision 0) +++ testsuite/g++.dg/cpp1y/auto-fn22.C (working copy) @@ -0,0 +1,9 @@ +// PR c++/58561 +// { dg-options "-std=c++1y -g" } + +auto foo(); + +namespace N +{ + using ::foo; +}