decl.c (grokdeclarator): Strip the injected-class-name typedef if we are building...
authorJason Merrill <jason@redhat.com>
Wed, 11 Apr 2012 17:55:25 +0000 (13:55 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 11 Apr 2012 17:55:25 +0000 (13:55 -0400)
* decl.c (grokdeclarator): Strip the injected-class-name typedef
if we are building a declaration or compound type.

From-SVN: r186346

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/debug/dwarf2/self-ref-1.C
gcc/testsuite/g++.dg/debug/dwarf2/self-ref-2.C

index 1f346008035f187431c124c8c82cfbb92bcc470e..525ce996d1c8e1de37369503814a6d740adb18f4 100644 (file)
@@ -1,5 +1,9 @@
 2012-04-11  Jason Merrill  <jason@redhat.com>
 
+       PR debug/45088
+       * decl.c (grokdeclarator): Strip the injected-class-name typedef
+       if we are building a declaration or compound type.
+
        PR c++/52906
        * decl.c (check_tag_decl): Don't complain about attributes if we
        don't even have a type.
index 8b22192987fcbc78cea68f5bdec254cec60002b1..711ceef7a8d57600105c97fea5b822acf2d34004 100644 (file)
@@ -8943,6 +8943,17 @@ grokdeclarator (const cp_declarator *declarator,
     error ("qualifiers are not allowed on declaration of %<operator %T%>",
           ctor_return_type);
 
+  /* If we're using the injected-class-name to form a compound type or a
+     declaration, replace it with the underlying class so we don't get
+     redundant typedefs in the debug output.  But if we are returning the
+     type unchanged, leave it alone so that it's available to
+     maybe_get_template_decl_from_type_decl.  */
+  if (CLASS_TYPE_P (type)
+      && DECL_SELF_REFERENCE_P (TYPE_NAME (type))
+      && type == TREE_TYPE (TYPE_NAME (type))
+      && (declarator || type_quals))
+    type = DECL_ORIGINAL_TYPE (TYPE_NAME (type));
+
   type_quals |= cp_type_quals (type);
   type = cp_build_qualified_type_real
     (type, type_quals, ((typedef_decl && !DECL_ARTIFICIAL (typedef_decl)
index 5fbbcfc84932789be569c0c292a16fa9f7ed15a9..7773d30f2ae3252a0e4f3af0ed88a16a1d2ccbe7 100644 (file)
@@ -1,5 +1,9 @@
 2012-04-11  Jason Merrill  <jason@redhat.com>
 
+       PR debug/45088
+       * g++.dg/debug/dwarf2/self-ref-1.C: Define virtual destructor.
+       * g++.dg/debug/dwarf2/self-ref-1.C: Likewise.
+
        PR c++/52906
        * g++.dg/ext/attrib45.C: New.
 
index 81bcb2775aa5517e5750ced3b1962edc9563a69d..06db9dcf6363210ee79db57f56f8e21837ac4928 100644 (file)
@@ -5,7 +5,7 @@
 
 struct A
 {
-    virtual ~A();
+    virtual ~A(){}
 };
 
 struct B : public A
index b1c5401da0711ba2eaa59e9fff4a75992e64b8c8..d5463c03e22e5442d0da976187485a658d99747f 100644 (file)
@@ -6,7 +6,7 @@
 template<class T>
 struct A
 {
-    virtual ~A();
+    virtual ~A(){}
 };
 
 struct B : public A<int>