diff options
| author | Mark Mitchell <mark@codesourcery.com> | 2006-04-19 16:58:23 +0000 |
|---|---|---|
| committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2006-04-19 16:58:23 +0000 |
| commit | fa6098f8177ea7e73cfdcc291209cd47d40196ee (patch) | |
| tree | 8697179a09947548fbbcca23b0493738bd1f5cb1 /gcc/cp/class.c | |
| parent | 74c96e0c149acb69337d704bfcd32d1e60724307 (diff) | |
| download | gcc-fa6098f8177ea7e73cfdcc291209cd47d40196ee.zip gcc-fa6098f8177ea7e73cfdcc291209cd47d40196ee.tar.gz gcc-fa6098f8177ea7e73cfdcc291209cd47d40196ee.tar.bz2 | |
re PR c++/27102 (ICE with invalid class name in function template)
PR c++/27102
* class.c (currently_open_class): Tidy.
* decl.c (grokdeclarator): If we encounter an erroneous
declarator, assume that we have already issued an error message
and return. Return error_mark_node instead of NULL_TREE in more
places. Issue errors about function definitions that do not have
a function declarator. Check for complete types for all function
definitions.
* cp-tree.h (cp_error_declarator): Remove.
(currently_open_class): Change return type.
* parser.c (cp_parser_id_expression): Add optional_p parameter.
(cp_parser_parse_diagnose_invalid_type_name): Adjust calls.
(cp_parser_id_expression): Likewise.
(cp_parser_unqualified_id): If the name is optional, return
NULL_TREE.
(cp_parser_postfix_dot_deref_expression): Adjust calls.
(cp_parser_type_parameter): Likewise.
(cp_parser_unqualified_id): Likewise.
(cp_parser_direct_declarator): Likewise.
(cp_parser_declarator_id): Add optional_p parameter.
(cp_parser_function_definition_from_specifiers_and_declarator):
Assume that start_function indicates failure only if it has issued
an error.
(cp_parser_omp_var_list_no_open): Adjust calls.
PR c++/27102
* g++.dg/template/crash35.C: Tweak error markers.
* g++.dg/template/crash46.C: New test.
* g++.old-deja/g++.brendan/friend4.C: Tweak error markers.
* g++.old-deja/g++.pt/incomplete1.C: Likewise.
From-SVN: r113081
Diffstat (limited to 'gcc/cp/class.c')
| -rw-r--r-- | gcc/cp/class.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 0edade8..cc26cb8 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -5496,25 +5496,33 @@ pop_class_stack (void) --current_class_stack[current_class_depth - 1].hidden; } -/* Returns 1 if current_class_type is either T or a nested type of T. - We start looking from 1 because entry 0 is from global scope, and has - no type. */ +/* Returns 1 if the class type currently being defined is either T or + a nested type of T. */ -int +bool currently_open_class (tree t) { int i; - if (current_class_type && same_type_p (t, current_class_type)) - return 1; - for (i = current_class_depth - 1; i > 0; --i) + + /* We start looking from 1 because entry 0 is from global scope, + and has no type. */ + for (i = current_class_depth; i > 0; --i) { - if (current_class_stack[i].hidden) - break; - if (current_class_stack[i].type - && same_type_p (current_class_stack [i].type, t)) - return 1; + tree c; + if (i == current_class_depth) + c = current_class_type; + else + { + if (current_class_stack[i].hidden) + break; + c = current_class_stack[i].type; + } + if (!c) + continue; + if (same_type_p (c, t)) + return true; } - return 0; + return false; } /* If either current_class_type or one of its enclosing classes are derived |
