Commit f8c3b097 by Paolo Carlini Committed by Paolo Carlini

re PR c++/27211 (Bogus error "template definition of non-template" when there is no non-template)

/cp
2007-08-14  Paolo Carlini  <pcarlini@suse.de>

	PR c++/27211
	* decl2.c (check_classfn): Return error_mark_node in case of error;
	in that case, do not call add_method.
	* decl.c (start_decl): Deal with check_classfn returning
	error_mark_node.
	(grokfndecl): Likewise.
	* pt.c (tsubst_friend_function): Likewise.

/testsuite
2007-08-14  Paolo Carlini  <pcarlini@suse.de>

	PR c++/27211
	* g++.dg/template/error27.C: New.
	* g++.dg/template/error28.C: New.
	* g++.dg/other/pr28304.C: Adjust.
	* g++.old-deja/g++.mike/p811.C: Likewise.

From-SVN: r127492
parent 7b0e48fb
2007-08-14 Paolo Carlini <pcarlini@suse.de>
PR c++/27211
* decl2.c (check_classfn): Return error_mark_node in case of error;
in that case, do not call add_method.
* decl.c (start_decl): Deal with check_classfn returning
error_mark_node.
(grokfndecl): Likewise.
* pt.c (tsubst_friend_function): Likewise.
2007-08-14 Andrew Pinski <pinskia@gmail.com>
PR c++/30428
......
......@@ -3938,7 +3938,8 @@ start_decl (const cp_declarator *declarator,
> template_class_depth (context))
? current_template_parms
: NULL_TREE);
if (field && duplicate_decls (decl, field,
if (field && field != error_mark_node
&& duplicate_decls (decl, field,
/*newdecl_is_friend=*/false))
decl = field;
}
......@@ -6365,13 +6366,15 @@ grokfndecl (tree ctype,
&& (! TYPE_FOR_JAVA (ctype) || check_java_method (decl))
&& check)
{
tree old_decl;
old_decl = check_classfn (ctype, decl,
tree old_decl = check_classfn (ctype, decl,
(processing_template_decl
> template_class_depth (ctype))
? current_template_parms
: NULL_TREE);
if (old_decl == error_mark_node)
return NULL_TREE;
if (old_decl)
{
tree ok;
......
......@@ -540,8 +540,8 @@ check_java_method (tree method)
TEMPLATE_DECL, it can be NULL since the parameters can be extracted
from the declaration. If the function is not a function template, it
must be NULL.
It returns the original declaration for the function, or NULL_TREE
if no declaration was found (and an error was emitted). */
It returns the original declaration for the function, NULL_TREE if
no declaration was found, error_mark_node if an error was emitted. */
tree
check_classfn (tree ctype, tree function, tree template_parms)
......@@ -677,16 +677,9 @@ check_classfn (tree ctype, tree function, tree template_parms)
error ("no %q#D member function declared in class %qT",
function, ctype);
/* If we did not find the method in the class, add it to avoid
spurious errors (unless the CTYPE is not yet defined, in which
case we'll only confuse ourselves when the function is declared
properly within the class. */
if (COMPLETE_TYPE_P (ctype))
add_method (ctype, function, NULL_TREE);
if (pushed_scope)
pop_scope (pushed_scope);
return NULL_TREE;
return error_mark_node;
}
/* DECL is a function with vague linkage. Remember it so that at the
......
2007-08-14 Paolo Carlini <pcarlini@suse.de>
PR c++/27211
* g++.dg/template/error27.C: New.
* g++.dg/template/error28.C: New.
* g++.dg/other/pr28304.C: Adjust.
* g++.old-deja/g++.mike/p811.C: Likewise.
2007-08-14 Rask Ingemann Lambertsen <rask@sygehus.dk>
PR target/30315
......@@ -7,5 +7,5 @@ template<typename T> void A::foo(T) {} // { dg-error "" }
void bar()
{
A::foo(1); // { dg-error "no matching function for call" }
A::foo(1); // { dg-error "not a member" }
}
// PR c++/27211
struct A {};
template<int> void A::foo() {} // { dg-error "member function" }
// PR c++/27211
struct A {};
template<int> void A::foo(); // { dg-error "member function" }
......@@ -525,7 +525,7 @@ public:
char *
X::stringify() const // { dg-error "does not match" }
{
return "stringify"; // { dg-warning "deprecated" }
return "stringify";
}
const char *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment