From eeb23c11c0f58d2927f94cae3dac10848507420c Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Sat, 6 Dec 2003 04:59:55 +0000 Subject: [PATCH] re PR c++/13314 (ICE when omitting template parameter of a sub-class) PR c++/13314 * emit-rtl.c (set_mem_attributes_minus_bitpos): Robustify. PR c++/13314 * parser.c (cp_parser_class_specifier): Match push_scope/pop_scope calls. (cp_parser_class_head): Likewise. PR c++/13314 * g++.dg/template/error7.C: New test. From-SVN: r74359 --- gcc/ChangeLog | 5 +++++ gcc/cp/ChangeLog | 7 +++++++ gcc/cp/parser.c | 9 +++++++-- gcc/emit-rtl.c | 2 ++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/error7.C | 6 ++++++ 6 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/error7.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9649c837e3f..9cd85d751b6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2003-12-05 Mark Mitchell + + PR c++/13314 + * emit-rtl.c (set_mem_attributes_minus_bitpos): Robustify. + 2003-12-05 Andrew Pinski PR driver/13211 diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6e2239bbf0b..39dd385d2a6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2003-12-05 Mark Mitchell + + PR c++/13314 + * parser.c (cp_parser_class_specifier): Match push_scope/pop_scope + calls. + (cp_parser_class_head): Likewise. + 2003-12-05 Kriang Lerdsuwanakij PR c++/13166 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 5f1b4736b01..97d32834d6a 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -11447,6 +11447,8 @@ cp_parser_class_specifier (cp_parser* parser) parser->num_template_parameter_lists = 0; /* Start the class. */ + if (nested_name_specifier_p) + push_scope (CP_DECL_CONTEXT (TYPE_MAIN_DECL (type))); type = begin_class_definition (type); if (type == error_mark_node) /* If the type is erroneous, skip the entire body of the class. */ @@ -11737,7 +11739,7 @@ cp_parser_class_head (cp_parser* parser, it is not, try to recover gracefully. */ if (at_namespace_scope_p () && parser->num_template_parameter_lists == 0 - && num_templates == 1) + && template_id_p) { error ("an explicit specialization must be preceded by 'template <>'"); invalid_explicit_specialization_p = true; @@ -11836,7 +11838,10 @@ cp_parser_class_head (cp_parser* parser, type = push_template_decl (type); type = TREE_TYPE (type); if (nested_name_specifier) - *nested_name_specifier_p = true; + { + *nested_name_specifier_p = true; + pop_scope (nested_name_specifier); + } } /* Indicate whether this class was declared as a `class' or as a `struct'. */ diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index 0f7e677e3ef..8be71ae64fb 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -1826,6 +1826,8 @@ set_mem_attributes_minus_bitpos (rtx ref, tree t, int objectp, return; type = TYPE_P (t) ? t : TREE_TYPE (t); + if (type == error_mark_node) + return; /* If we have already set DECL_RTL = ref, get_alias_set will get the wrong answer, as it assumes that DECL_RTL already has the right alias diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2000b1c5fb5..aba0ad31fdb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-12-05 Mark Mitchell + + PR c++/13314 + * g++.dg/template/error7.C: New test. + 2003-12-05 Stuart Menefy J"orn Rennecke diff --git a/gcc/testsuite/g++.dg/template/error7.C b/gcc/testsuite/g++.dg/template/error7.C new file mode 100644 index 00000000000..3c1a0e1f21b --- /dev/null +++ b/gcc/testsuite/g++.dg/template/error7.C @@ -0,0 +1,6 @@ +// PR c++/13314 +// { dg-options "-O2" } + +struct A { template struct B; }; +struct A::B {}; // { dg-error "" } +A::B<0> b; // { dg-error "" }