/cp
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 Aug 2007 22:07:31 +0000 (22:07 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 Aug 2007 22:07:31 +0000 (22:07 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@127492 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/decl2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/pr28304.C
gcc/testsuite/g++.dg/template/error27.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/error28.C [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.mike/p811.C

index d7706af..b9fe07f 100644 (file)
@@ -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
index 6edb79d..9a9436a 100644 (file)
@@ -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;
index 3548350..d66b731 100644 (file)
@@ -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
index 124a822..1baa094 100644 (file)
@@ -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
index c86efd4..9a0e9cd 100644 (file)
@@ -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 (file)
index 0000000..8d41d02
--- /dev/null
@@ -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 (file)
index 0000000..e87d542
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/27211
+
+struct A {};
+
+template<int> void A::foo(); // { dg-error "member function" }
index 7097eee..260c645 100644 (file)
@@ -525,7 +525,7 @@ public:
 char *
 X::stringify() const  // { dg-error "does not match" }
 {
-    return "stringify";         // { dg-warning "deprecated" }
+    return "stringify";
 }
 
 const char *