(C++) template error-handling patch
Jason Merrill
jason@cygnus.com
Mon Feb 15 23:43:00 GMT 1999
At some point, grokfndecl started returning error_mark_node in some cases.
But all the callers of grokdeclarator were not updated accordingly, and I
decided just to change it back.
1999-02-13 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (grokfndecl): Return NULL_TREE instead of error_mark_node.
(grokdeclarator): Don't expect error_mark_node from grokfndecl.
* pt.c (maybe_process_partial_specialization): Complain about
'template <>' on non-specialization.
Index: decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.307
diff -c -p -r1.307 decl.c
*** decl.c 1999/02/11 00:00:26 1.307
--- decl.c 1999/02/16 07:42:26
*************** bad_specifiers (object, type, virtualp,
*** 8344,8350 ****
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.
! Returns `error_mark_node' if something goes wrong, after issuing
applicable error messages. */
static tree
--- 8344,8350 ----
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.
! Returns `NULL_TREE' if something goes wrong, after issuing
applicable error messages. */
static tree
*************** grokfndecl (ctype, type, declarator, ori
*** 8496,8502 ****
/* Something like `template <class T> friend void f<T>()'. */
cp_error ("template-id `%D' in declaration of primary template",
orig_declarator);
! return error_mark_node;
}
/* A friend declaration of the form friend void f<>(). Record
--- 8496,8502 ----
/* Something like `template <class T> friend void f<T>()'. */
cp_error ("template-id `%D' in declaration of primary template",
orig_declarator);
! return NULL_TREE;
}
/* A friend declaration of the form friend void f<>(). Record
*************** grokfndecl (ctype, type, declarator, ori
*** 8544,8550 ****
2 * (funcdef_flag != 0) +
4 * (friendp != 0));
if (decl == error_mark_node)
! return error_mark_node;
if ((! TYPE_FOR_JAVA (ctype) || check_java_method (decl))
&& check)
--- 8544,8550 ----
2 * (funcdef_flag != 0) +
4 * (friendp != 0));
if (decl == error_mark_node)
! return NULL_TREE;
if ((! TYPE_FOR_JAVA (ctype) || check_java_method (decl))
&& check)
*************** grokfndecl (ctype, type, declarator, ori
*** 8560,8566 ****
return tmp;
}
if (! grok_ctor_properties (ctype, decl))
! return error_mark_node;
}
else
{
--- 8560,8566 ----
return tmp;
}
if (! grok_ctor_properties (ctype, decl))
! return NULL_TREE;
}
else
{
*************** grokfndecl (ctype, type, declarator, ori
*** 8577,8583 ****
2 * (funcdef_flag != 0) +
4 * (friendp != 0));
if (decl == error_mark_node)
! return error_mark_node;
if (ctype != NULL_TREE
&& (! TYPE_FOR_JAVA (ctype) || check_java_method (decl))
--- 8577,8583 ----
2 * (funcdef_flag != 0) +
4 * (friendp != 0));
if (decl == error_mark_node)
! return NULL_TREE;
if (ctype != NULL_TREE
&& (! TYPE_FOR_JAVA (ctype) || check_java_method (decl))
*************** grokdeclarator (declarator, declspecs, d
*** 10931,10937 ****
virtualp, flags, quals, raises, attrlist,
friendp ? -1 : 0, friendp, publicp, inlinep,
funcdef_flag, template_count, in_namespace);
! if (decl == NULL_TREE || decl == error_mark_node)
return decl;
#if 0
/* This clobbers the attrs stored in `decl' from `attrlist'. */
--- 10931,10937 ----
virtualp, flags, quals, raises, attrlist,
friendp ? -1 : 0, friendp, publicp, inlinep,
funcdef_flag, template_count, in_namespace);
! if (decl == NULL_TREE)
return decl;
#if 0
/* This clobbers the attrs stored in `decl' from `attrlist'. */
*************** grokdeclarator (declarator, declspecs, d
*** 11177,11187 ****
template_count, in_namespace);
if (decl == NULL_TREE)
return NULL_TREE;
-
- /* Among other times, could occur from check_explicit_specialization
- returning an error_mark_node. */
- if (decl == error_mark_node)
- return error_mark_node;
if (staticp == 1)
{
--- 11177,11182 ----
Index: pt.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/pt.c,v
retrieving revision 1.260
diff -c -p -r1.260 pt.c
*** pt.c 1999/02/10 10:46:30 1.260
--- pt.c 1999/02/16 07:42:27
*************** maybe_process_partial_specialization (ty
*** 688,693 ****
--- 688,695 ----
else if (CLASSTYPE_TEMPLATE_INSTANTIATION (type))
cp_error ("specialization of `%T' after instantiation", type);
}
+ else if (processing_specialization)
+ cp_error ("explicit specialization of non-template `%T'", type);
}
/* Retrieve the specialization (in the sense of [temp.spec] - a
More information about the Gcc-patches
mailing list