diff options
author | Jason Merrill <jason@redhat.com> | 2012-07-17 14:09:10 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2012-07-17 14:09:10 -0400 |
commit | 947296ca906e03d78715ac7ed64cf21cea553c6c (patch) | |
tree | ea5e9a29a4648072055624e6c1d7e0a183a13051 /gcc/cp | |
parent | ec44e46396e6bc7f393ceb10d84df22b9b45f820 (diff) | |
download | gcc-947296ca906e03d78715ac7ed64cf21cea553c6c.zip gcc-947296ca906e03d78715ac7ed64cf21cea553c6c.tar.gz gcc-947296ca906e03d78715ac7ed64cf21cea553c6c.tar.bz2 |
decl.c (xref_basetypes): Complain about incomplete template base.
* decl.c (xref_basetypes): Complain about incomplete template base.
* class.c (finish_struct): Adjust variants in templates, too.
From-SVN: r189583
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/cp/class.c | 9 | ||||
-rw-r--r-- | gcc/cp/decl.c | 9 |
3 files changed, 20 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 142a866..3325f1a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2012-07-17 Jason Merrill <jason@redhat.com> + * decl.c (xref_basetypes): Complain about incomplete template base. + * class.c (finish_struct): Adjust variants in templates, too. + PR c++/53549 * parser.c (cp_parser_class_head): Call xref_basetypes here. (cp_parser_class_specifier_1): Not here. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 3877a27..82c28fa 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -6325,6 +6325,15 @@ finish_struct (tree t, tree attributes) /* Remember current #pragma pack value. */ TYPE_PRECISION (t) = maximum_field_alignment; + + /* Fix up any variants we've already built. */ + for (x = TYPE_NEXT_VARIANT (t); x; x = TYPE_NEXT_VARIANT (x)) + { + TYPE_SIZE (x) = TYPE_SIZE (t); + TYPE_SIZE_UNIT (x) = TYPE_SIZE_UNIT (t); + TYPE_FIELDS (x) = TYPE_FIELDS (t); + TYPE_METHODS (x) = TYPE_METHODS (t); + } } else finish_struct_1 (t); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 842c2d8..84b78f6 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -11843,7 +11843,14 @@ xref_basetypes (tree ref, tree base_list) { tree basetype = TREE_VALUE (*basep); - if (!(processing_template_decl && uses_template_parms (basetype)) + /* The dependent_type_p call below should really be dependent_scope_p + so that we give a hard error about using an incomplete type as a + base, but we allow it with a pedwarn for backward + compatibility. */ + if (processing_template_decl + && CLASS_TYPE_P (basetype) && TYPE_BEING_DEFINED (basetype)) + cxx_incomplete_type_diagnostic (NULL_TREE, basetype, DK_PEDWARN); + if (!dependent_type_p (basetype) && !complete_type_or_else (basetype, NULL)) /* An incomplete type. Remove it from the list. */ *basep = TREE_CHAIN (*basep); |