From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5152 invoked by alias); 8 Nov 2010 22:39:26 -0000 Received: (qmail 5081 invoked by uid 22791); 8 Nov 2010 22:39:25 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 08 Nov 2010 22:39:19 +0000 From: "dodji at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug debug/45997] [4.6 Regression] __unknown__ type name for typedef'd int X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: debug X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dodji at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.6.0 X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Mon, 08 Nov 2010 22:39:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-11/txt/msg01025.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45997 --- Comment #4 from Dodji Seketeli 2010-11-08 22:39:09 UTC --- At some point modified_type_die is called for volatile_const_my_int with is_volatile and is_const_type set to 0, meaning we want to emit the DIE of the cv-unqualified version of volatile_const_my_int i.e, my_int. The problem is that the line /* See if we already have the appropriately qualified variant of this type. */ qualified_type = get_qualified_type (type, ((is_const_type ? TYPE_QUAL_CONST : 0) | (is_volatile_type ? TYPE_QUAL_VOLATILE : 0))); fails to give us the the my_int (cv-unqualified version of volatile_const_my_int) we want and returns NULL instead. That's because get_qualified_type doesn't look through typedefs as it must preserve TYPE_NAMEs (see the comment in get_qualified_type). From this point, I think we are likely to loose. So, maybe if we try harder to come up with the cv-unqualified version of the input type, things will get better? This patch that (only lightly tested seems) to fix the problem too. What do you think? diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 9bb569b..f639e24 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -12715,6 +12715,19 @@ modified_type_die (tree type, int is_const_type, int is_volatile_type, ((is_const_type ? TYPE_QUAL_CONST : 0) | (is_volatile_type ? TYPE_QUAL_VOLATILE : 0))); + /* If TYPE is a typedef and we want its cv-unqualified version, + get_qualified_type just returns NULL because it doesn't look + through typedefs; In that case, let's use the underlying type of + the typedef. */ + if (qualified_type == NULL + && typedef_variant_p (type) + && (is_const_type < TYPE_READONLY (type) + || is_volatile_type < TYPE_VOLATILE (type))) + qualified_type = + get_qualified_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type)), + ((is_const_type ? TYPE_QUAL_CONST : 0) + | (is_volatile_type ? TYPE_QUAL_VOLATILE : 0))); + if (qualified_type == sizetype && TYPE_NAME (qualified_type) && TREE_CODE (TYPE_NAME (qualified_type)) == TYPE_DECL)