decl.c (grokfndecl): Improve error-recovery.

* decl.c (grokfndecl): Improve error-recovery.
	* decl2.c (grokfield): Likewise.
	* pt.c (finish_member_template_decl): Likewise.

From-SVN: r22549
This commit is contained in:
Mark Mitchell 1998-09-22 11:58:41 +00:00 committed by Mark Mitchell
parent a105e36f8c
commit 3ddfb0e624
5 changed files with 24 additions and 9 deletions

View File

@ -1,3 +1,9 @@
1998-09-22 Mark Mitchell <mark@markmitchell.com>
* decl.c (grokfndecl): Improve error-recovery.
* decl2.c (grokfield): Likewise.
* pt.c (finish_member_template_decl): Likewise.
1998-09-20 Martin von Löwis <loewis@informatik.hu-berlin.de>
* method.c (hack_identifier): Finding multiple members is always

View File

@ -7866,7 +7866,10 @@ bad_specifiers (object, type, virtualp, quals, inlinep, friendp, raises)
or `volatile'.
RAISES is a list of exceptions that this function can raise.
CHECK is 1 if we must find this method in CTYPE, 0 if we should
not look, and -1 if we should not call `grokclassfn' at all. */
not look, and -1 if we should not call `grokclassfn' at all.
Returns `error_mark_node' if something goes wrong, after issuing
applicable error messages. */
static tree
grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals,
@ -8046,7 +8049,7 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals,
return tmp;
}
if (! grok_ctor_properties (ctype, decl))
return NULL_TREE;
return error_mark_node;
if (check == 0 && ! current_function_decl)
{
@ -10342,8 +10345,8 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
virtualp, flags, quals, raises, attrlist,
friendp ? -1 : 0, friendp, publicp, inlinep,
funcdef_flag, template_count, in_namespace);
if (decl == NULL_TREE)
return NULL_TREE;
if (decl == NULL_TREE || decl == error_mark_node)
return decl;
#if 0
/* This clobbers the attrs stored in `decl' from `attrlist'. */
/* The decl and setting of decl_machine_attr is also turned off. */

View File

@ -1607,7 +1607,8 @@ grokfield (declarator, declspecs, init, asmspec_tree, attrlist)
value = grokdeclarator (declarator, declspecs, FIELD, init != 0, NULL_TREE);
if (! value || value == error_mark_node)
return NULL_TREE; /* friend or constructor went bad. */
/* friend or constructor went bad. */
return value;
/* Pass friendly classes back. */
if (TREE_CODE (value) == VOID_TYPE)

View File

@ -204,6 +204,10 @@ finish_member_template_decl (template_parameters, decl)
if (decl == NULL_TREE || decl == void_type_node)
return NULL_TREE;
else if (decl == error_mark_node)
/* By returning NULL_TREE, the parser will just ignore this
declaration. We have already issued the error. */
return NULL_TREE;
else if (TREE_CODE (decl) == TREE_LIST)
{
/* Assume that the class is the only declspec. */
@ -229,7 +233,6 @@ finish_member_template_decl (template_parameters, decl)
}
else
cp_error ("invalid member template declaration `%D'", decl);
return error_mark_node;
}
@ -584,6 +587,7 @@ void
check_specialization_scope ()
{
tree scope = current_scope ();
/* [temp.expl.spec]
An explicit specialization shall be declared in the namespace of
@ -596,6 +600,7 @@ check_specialization_scope ()
if (scope && TREE_CODE (scope) != NAMESPACE_DECL)
cp_error ("explicit specialization in non-namespace scope `%D'",
scope);
/* [temp.expl.spec]
In an explicit specialization declaration for a member of a class

View File

@ -11,11 +11,11 @@
template <class A, class B> void foo();
template <class C> class bar {
int i;
template <class B> friend void foo<C,B>();
template <class B> friend void foo<C,B>(); // ERROR - bogus declaration
};
template <class A, class B> void foo() {
bar<A> baz; baz.i = 1;
bar<int> buz; buz.i = 1; // ERROR - foo<void,void> cannot access bar<int>::i - XFAIL *-*-*
bar<A> baz; baz.i = 1; // ERROR - foo cannot access bar<int>::i
bar<int> buz; buz.i = 1; // ERROR - foo cannot access bar<int>::i
}
int main() {
foo<void,void>();