diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-10-14 00:50:26 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-10-14 00:50:26 +0000 |
commit | 634488866ed61164231d04c182ab48a296d6da81 (patch) | |
tree | 283b19d2c2c5d3a03c65074a0f46db161fb0c68e /gcc/cp | |
parent | c6151f87c276e56b47a644270ad6e493b98bb80e (diff) | |
download | gcc-634488866ed61164231d04c182ab48a296d6da81.tar.gz |
PR c++/45984
* class.c (fixup_attribute_variants): New fn.
* cp-tree.h: Declare it.
* pt.c (instantiate_class_template): Call it.
* semantics.c (begin_class_definition): Call it.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@165443 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/class.c | 23 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 1 | ||||
-rw-r--r-- | gcc/cp/pt.c | 1 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 1 |
5 files changed, 32 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 683e439ac47..ec897554a22 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2010-10-13 Jason Merrill <jason@redhat.com> + + PR c++/45984 + * class.c (fixup_attribute_variants): New fn. + * cp-tree.h: Declare it. + * pt.c (instantiate_class_template): Call it. + * semantics.c (begin_class_definition): Call it. + 2010-10-13 Richard Henderson <rth@redhat.com> * cp-lang.c (cp_eh_personality): Update call to diff --git a/gcc/cp/class.c b/gcc/cp/class.c index b093ce0fcc5..f76c2bed3d8 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1515,12 +1515,31 @@ fixup_type_variants (tree t) TYPE_VFIELD (variants) = TYPE_VFIELD (t); TYPE_METHODS (variants) = TYPE_METHODS (t); TYPE_FIELDS (variants) = TYPE_FIELDS (t); + } +} + +/* Early variant fixups: we apply attributes at the beginning of the class + definition, and we need to fix up any variants that have already been + made via elaborated-type-specifier so that check_qualified_type works. */ + +void +fixup_attribute_variants (tree t) +{ + tree variants; - /* All variants of a class have the same attributes. */ + if (!t) + return; + + for (variants = TYPE_NEXT_VARIANT (t); + variants; + variants = TYPE_NEXT_VARIANT (variants)) + { + /* These are the two fields that check_qualified_type looks at and + are affected by attributes. */ TYPE_ATTRIBUTES (variants) = TYPE_ATTRIBUTES (t); + TYPE_ALIGN (variants) = TYPE_ALIGN (t); } } - /* Set memoizing fields and bits of T (and its variants) for later use. */ diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index bfc6fd3d27b..29a4bdb01ca 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4711,6 +4711,7 @@ extern bool type_has_move_assign (tree); extern void defaulted_late_check (tree); extern bool defaultable_fn_check (tree); extern void fixup_type_variants (tree); +extern void fixup_attribute_variants (tree); extern tree* decl_cloned_function_p (const_tree, bool); extern void clone_function_decl (tree, int); extern void adjust_clone_args (tree); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 84901d30673..9ddb4fd465c 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -7943,6 +7943,7 @@ instantiate_class_template (tree type) apply_late_template_attributes (&type, TYPE_ATTRIBUTES (pattern), (int) ATTR_FLAG_TYPE_IN_PLACE, args, tf_error, NULL_TREE); + fixup_attribute_variants (type); /* Now that our base classes are set up, enter the scope of the class, so that name lookups into base classes, etc. will work diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index b73dffb0560..787c72c17fc 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2391,6 +2391,7 @@ begin_class_definition (tree t, tree attributes) TYPE_BEING_DEFINED (t) = 1; cplus_decl_attributes (&t, attributes, (int) ATTR_FLAG_TYPE_IN_PLACE); + fixup_attribute_variants (t); if (flag_pack_struct) { |