From 0d2a8b1b82b35370545d9fe9784d466314a9adf2 Mon Sep 17 00:00:00 2001 From: Benjamin Kosnik Date: Mon, 17 Aug 1998 15:44:47 +0000 Subject: [PATCH] decl.c (grokdeclarator): Allow anonymous types to be cv-qualified. 1998-08-17 Benjamin Kosnik * decl.c (grokdeclarator): Allow anonymous types to be cv-qualified. fixes g++/16824 From-SVN: r21791 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/decl.c | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a356da2ab55..3f3fa49bf9b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +1998-08-17 Benjamin Kosnik + + * decl.c (grokdeclarator): Allow anonymous types to be cv-qualified. + Mon Aug 17 10:40:18 1998 Jeffrey A Law (law@cygnus.com) * cp-tree.h (set_identifier_local_value): Provide prototype. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 1fa4abf70d2..ccaf75732d3 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -9957,11 +9957,16 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) refer to it, so nothing needs know about the name change. The TYPE_NAME field was filled in by build_struct_xref. */ if (type != error_mark_node - && !TYPE_READONLY (type) && !TYPE_VOLATILE (type) && TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL && ANON_AGGRNAME_P (TYPE_IDENTIFIER (type))) { + /* For anonymous structs that are cv-qualified, need to use + TYPE_MAIN_VARIANT so that name will mangle correctly. As + type not referenced after this block, don't bother + resetting type to original type, ie. TREE_TYPE (decl). */ + type = TYPE_MAIN_VARIANT (type); + /* Replace the anonymous name with the real name everywhere. */ lookup_tag_reverse (type, declarator); TYPE_NAME (type) = decl; -- 2.30.2