From 6a091e8bd882c308cd7ad0a7feb1b14443b26fb8 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 11 Apr 2012 13:55:25 -0400 Subject: [PATCH] decl.c (grokdeclarator): Strip the injected-class-name typedef if we are building a declaration or... * decl.c (grokdeclarator): Strip the injected-class-name typedef if we are building a declaration or compound type. From-SVN: r186346 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/decl.c | 11 +++++++++++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.dg/debug/dwarf2/self-ref-1.C | 2 +- gcc/testsuite/g++.dg/debug/dwarf2/self-ref-2.C | 2 +- 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1f346008035..525ce996d1c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2012-04-11 Jason Merrill + 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. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 8b22192987f..711ceef7a8d 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -8943,6 +8943,17 @@ grokdeclarator (const cp_declarator *declarator, error ("qualifiers are not allowed on declaration of %", 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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5fbbcfc8493..7773d30f2ae 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2012-04-11 Jason Merrill + 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. diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/self-ref-1.C b/gcc/testsuite/g++.dg/debug/dwarf2/self-ref-1.C index 81bcb2775aa..06db9dcf636 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/self-ref-1.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/self-ref-1.C @@ -5,7 +5,7 @@ struct A { - virtual ~A(); + virtual ~A(){} }; struct B : public A diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/self-ref-2.C b/gcc/testsuite/g++.dg/debug/dwarf2/self-ref-2.C index b1c5401da07..d5463c03e22 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/self-ref-2.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/self-ref-2.C @@ -6,7 +6,7 @@ template struct A { - virtual ~A(); + virtual ~A(){} }; struct B : public A -- 2.30.2