diff options
author | Paolo Carlini <pcarlini@suse.de> | 2007-08-14 22:07:31 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2007-08-14 22:07:31 +0000 |
commit | f8c3b097ed6ce43f64f9dfceac2698b0727969ac (patch) | |
tree | cfdef9633c5c66f00701d87609abaf55113a1456 | |
parent | 7b0e48fb44b44241ae79e34a666edc87fdfbeb78 (diff) | |
download | gcc-f8c3b097ed6ce43f64f9dfceac2698b0727969ac.zip gcc-f8c3b097ed6ce43f64f9dfceac2698b0727969ac.tar.gz gcc-f8c3b097ed6ce43f64f9dfceac2698b0727969ac.tar.bz2 |
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
-rw-r--r-- | gcc/cp/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/cp/decl.c | 19 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/other/pr28304.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/error27.C | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/error28.C | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.mike/p811.C | 2 |
8 files changed, 44 insertions, 20 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d7706af..b9fe07f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +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 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 6edb79d..9a9436a 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -3938,8 +3938,9 @@ start_decl (const cp_declarator *declarator, > template_class_depth (context)) ? current_template_parms : NULL_TREE); - if (field && duplicate_decls (decl, field, - /*newdecl_is_friend=*/false)) + 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; + 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; - old_decl = check_classfn (ctype, decl, - (processing_template_decl - > template_class_depth (ctype)) - ? current_template_parms - : NULL_TREE); if (old_decl) { tree ok; diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 3548350..d66b731 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 124a822..1baa094 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +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 diff --git a/gcc/testsuite/g++.dg/other/pr28304.C b/gcc/testsuite/g++.dg/other/pr28304.C index c86efd4..9a0e9cd 100644 --- a/gcc/testsuite/g++.dg/other/pr28304.C +++ b/gcc/testsuite/g++.dg/other/pr28304.C @@ -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" } } diff --git a/gcc/testsuite/g++.dg/template/error27.C b/gcc/testsuite/g++.dg/template/error27.C new file mode 100644 index 0000000..8d41d02 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/error27.C @@ -0,0 +1,5 @@ +// PR c++/27211 + +struct A {}; + +template<int> void A::foo() {} // { dg-error "member function" } diff --git a/gcc/testsuite/g++.dg/template/error28.C b/gcc/testsuite/g++.dg/template/error28.C new file mode 100644 index 0000000..e87d542 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/error28.C @@ -0,0 +1,5 @@ +// PR c++/27211 + +struct A {}; + +template<int> void A::foo(); // { dg-error "member function" } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p811.C b/gcc/testsuite/g++.old-deja/g++.mike/p811.C index 7097eee..260c645 100644 --- a/gcc/testsuite/g++.old-deja/g++.mike/p811.C +++ b/gcc/testsuite/g++.old-deja/g++.mike/p811.C @@ -525,7 +525,7 @@ public: char * X::stringify() const // { dg-error "does not match" } { - return "stringify"; // { dg-warning "deprecated" } + return "stringify"; } const char * |