public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/45997] New: __unknown__ type name for typedef'd int
@ 2010-10-13  4:48 dje at google dot com
  2010-10-27 23:00 ` [Bug debug/45997] [4.6 Regression] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: dje at google dot com @ 2010-10-13  4:48 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45997

           Summary: __unknown__ type name for typedef'd int
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: dje@google.com


Earlier versions of gcc (e.g. 4.4.3) would emit a DW_TAG_base_type without a
name.  svn head emits one with name "__unknown__".


typedef int my_int;
typedef const my_int const_my_int;
typedef volatile const_my_int volatile_const_my_int;

my_int v_my_int (0);
const_my_int v_const_my_int (1);
volatile_const_my_int v_volatile_const_my_int (4);

int
main ()
{
  return 0;
}


g++ -g -S -dA foo.cc -o - | grep __unknown__
-->
        .long   .LASF3  # DW_AT_name: "__unknown__"
        .string "__unknown__"


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug debug/45997] [4.6 Regression] __unknown__ type name for typedef'd int
  2010-10-13  4:48 [Bug debug/45997] New: __unknown__ type name for typedef'd int dje at google dot com
@ 2010-10-27 23:00 ` pinskia at gcc dot gnu.org
  2010-11-03 13:21 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2010-10-27 23:00 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45997

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2010.10.27 23:00:32
            Version|unknown                     |4.6.0
   Target Milestone|---                         |4.6.0
            Summary|__unknown__ type name for   |[4.6 Regression]
                   |typedef'd int               |__unknown__ type name for
                   |                            |typedef'd int
     Ever Confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2010-10-27 23:00:32 UTC ---
4.5.0 20100401 (experimental) [trunk revision 157933] did not do it either.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug debug/45997] [4.6 Regression] __unknown__ type name for typedef'd int
  2010-10-13  4:48 [Bug debug/45997] New: __unknown__ type name for typedef'd int dje at google dot com
  2010-10-27 23:00 ` [Bug debug/45997] [4.6 Regression] " pinskia at gcc dot gnu.org
@ 2010-11-03 13:21 ` jakub at gcc dot gnu.org
  2010-11-03 14:08 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2010-11-03 13:21 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45997

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dodji at gcc dot gnu.org,
                   |                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2010-11-03 13:20:55 UTC ---
The DWARF standard requires a name to be emitted and that's why we do emit
there something, to follow the standard.  There are talks about changing this,
but no changes have been made yet.

That said, ideally we wouldn't be emitting nameless base types or __unknown__
named base types in this case, I guess the problem is just that we try to
remove const/volatile in a fixed order and your testcase has it exactly in the
opposite order.  With:

typedef int my_int;
typedef volatile my_int volatile_my_int;
typedef const volatile_my_int const_volatile_my_int;

my_int v_my_int = 0;
volatile_my_int v_volatile_my_int = 1;
const_volatile_my_int v_const_volatile_my_int = 4;

int
main ()
{
  return 0;
}

the result is expected, always refering to the previous typedef DIE.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug debug/45997] [4.6 Regression] __unknown__ type name for typedef'd int
  2010-10-13  4:48 [Bug debug/45997] New: __unknown__ type name for typedef'd int dje at google dot com
  2010-10-27 23:00 ` [Bug debug/45997] [4.6 Regression] " pinskia at gcc dot gnu.org
  2010-11-03 13:21 ` jakub at gcc dot gnu.org
@ 2010-11-03 14:08 ` jakub at gcc dot gnu.org
  2010-11-08 22:39 ` dodji at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2010-11-03 14:08 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45997

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |jakub at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 2010-11-03 14:08:21 UTC ---
Created attachment 22251
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22251
gcc46-pr45997.patch

That said, I think this patch should fix this case (while of course not ruling
out other possibilities to get __unknown__ base type; but that really is a
matter of the DWARF wording being relaxed or not) and is IMHO the right thing
to do.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug debug/45997] [4.6 Regression] __unknown__ type name for typedef'd int
  2010-10-13  4:48 [Bug debug/45997] New: __unknown__ type name for typedef'd int dje at google dot com
                   ` (2 preceding siblings ...)
  2010-11-03 14:08 ` jakub at gcc dot gnu.org
@ 2010-11-08 22:39 ` dodji at gcc dot gnu.org
  2010-11-12 11:59 ` dodji at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: dodji at gcc dot gnu.org @ 2010-11-08 22:39 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45997

--- Comment #4 from Dodji Seketeli <dodji at gcc dot gnu.org> 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)


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug debug/45997] [4.6 Regression] __unknown__ type name for typedef'd int
  2010-10-13  4:48 [Bug debug/45997] New: __unknown__ type name for typedef'd int dje at google dot com
                   ` (3 preceding siblings ...)
  2010-11-08 22:39 ` dodji at gcc dot gnu.org
@ 2010-11-12 11:59 ` dodji at gcc dot gnu.org
  2010-11-12 12:05 ` dodji at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: dodji at gcc dot gnu.org @ 2010-11-12 11:59 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45997

--- Comment #5 from Dodji Seketeli <dodji at gcc dot gnu.org> 2010-11-12 11:54:42 UTC ---
Hmmh, finally that patch wasn't good enough. I modified it and posted
another one to http://gcc.gnu.org/ml/gcc-patches/2010-11/msg01277.html


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug debug/45997] [4.6 Regression] __unknown__ type name for typedef'd int
  2010-10-13  4:48 [Bug debug/45997] New: __unknown__ type name for typedef'd int dje at google dot com
                   ` (4 preceding siblings ...)
  2010-11-12 11:59 ` dodji at gcc dot gnu.org
@ 2010-11-12 12:05 ` dodji at gcc dot gnu.org
  2010-12-06 19:34 ` jakub at gcc dot gnu.org
  2010-12-06 19:41 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: dodji at gcc dot gnu.org @ 2010-11-12 12:05 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45997

--- Comment #6 from Dodji Seketeli <dodji at gcc dot gnu.org> 2010-11-12 12:04:52 UTC ---
"dodji at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> writes:

> --- Comment #5 from Dodji Seketeli <dodji at gcc dot gnu.org> 2010-11-12 11:54:42 UTC ---
> Hmmh, finally that patch wasn't good enough. I modified it and posted
> another one to http://gcc.gnu.org/ml/gcc-patches/2010-11/msg01277.html

Woops, sorry. This comment is for PR debug/45088, not for this one.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug debug/45997] [4.6 Regression] __unknown__ type name for typedef'd int
  2010-10-13  4:48 [Bug debug/45997] New: __unknown__ type name for typedef'd int dje at google dot com
                   ` (5 preceding siblings ...)
  2010-11-12 12:05 ` dodji at gcc dot gnu.org
@ 2010-12-06 19:34 ` jakub at gcc dot gnu.org
  2010-12-06 19:41 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2010-12-06 19:34 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45997

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> 2010-12-06 19:33:56 UTC ---
Author: jakub
Date: Mon Dec  6 19:33:52 2010
New Revision: 167517

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=167517
Log:
    PR debug/45997
    * dwarf2out.c (modified_type_die): If both is_const_type and
    is_volatile_type is set, start with DW_TAG_const_type or
    DW_TAG_volatile_type depending on where we get qualified type
    in the recursive call.

    * g++.dg/debug/dwarf2/pr45997-1.C: New test.
    * g++.dg/debug/dwarf2/pr45997-2.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/debug/dwarf2/pr45997-1.C
    trunk/gcc/testsuite/g++.dg/debug/dwarf2/pr45997-2.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/dwarf2out.c
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug debug/45997] [4.6 Regression] __unknown__ type name for typedef'd int
  2010-10-13  4:48 [Bug debug/45997] New: __unknown__ type name for typedef'd int dje at google dot com
                   ` (6 preceding siblings ...)
  2010-12-06 19:34 ` jakub at gcc dot gnu.org
@ 2010-12-06 19:41 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2010-12-06 19:41 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45997

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> 2010-12-06 19:41:40 UTC ---
Fixed.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-12-06 19:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-13  4:48 [Bug debug/45997] New: __unknown__ type name for typedef'd int dje at google dot com
2010-10-27 23:00 ` [Bug debug/45997] [4.6 Regression] " pinskia at gcc dot gnu.org
2010-11-03 13:21 ` jakub at gcc dot gnu.org
2010-11-03 14:08 ` jakub at gcc dot gnu.org
2010-11-08 22:39 ` dodji at gcc dot gnu.org
2010-11-12 11:59 ` dodji at gcc dot gnu.org
2010-11-12 12:05 ` dodji at gcc dot gnu.org
2010-12-06 19:34 ` jakub at gcc dot gnu.org
2010-12-06 19:41 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).