OSDN Git Service

/cp
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 27 Nov 2009 10:44:49 +0000 (10:44 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 27 Nov 2009 10:44:49 +0000 (10:44 +0000)
2009-11-27  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/35112
* pt.c (print_overloaded_functions): New.
(print_candidates): Call the latter.
* parser.c (cp_parser_class_name): Do not duplicate the diagnostics
after the cp_parser_lookup_name call.

/testsuite
2009-11-27  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/35112
* g++.dg/parse/crash53.C: New.
* g++.dg/parse/error17.C: Adjust, error messages are not
duplicated anymore.
* g++.dg/template/dtor7.C: Remove xfail-ed dg-bogus directives.

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

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/crash53.C [new file with mode: 0644]
gcc/testsuite/g++.dg/parse/error17.C
gcc/testsuite/g++.dg/template/dtor7.C

index a4142a2..032afa0 100644 (file)
@@ -1,3 +1,11 @@
+2009-11-27  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/35112
+       * pt.c (print_overloaded_functions): New.
+       (print_candidates): Call the latter.
+       * parser.c (cp_parser_class_name): Do not duplicate the diagnostics
+       after the cp_parser_lookup_name call.
+
 2009-11-26  Jason Merrill  <jason@redhat.com>
 
        PR c++/42026, DR 239
index cd0382e..5c8dbcb 100644 (file)
@@ -15738,14 +15738,8 @@ cp_parser_class_name (cp_parser *parser,
                                        identifier_token->location);
          if (ambiguous_decls)
            {
-             error_at (identifier_token->location,
-                       "reference to %qD is ambiguous", identifier);
-             print_candidates (ambiguous_decls);
              if (cp_parser_parsing_tentatively (parser))
-               {
-                 identifier_token->ambiguous_p = true;
-                 cp_parser_simulate_error (parser);
-               }
+               cp_parser_simulate_error (parser);
              return error_mark_node;
            }
        }
index dfe7791..db3956b 100644 (file)
@@ -1646,29 +1646,36 @@ explicit_class_specialization_p (tree type)
   return !uses_template_parms (CLASSTYPE_TI_ARGS (type));
 }
 
+/* Print the list of overloaded FNS in an error message.   */
+
+static void
+print_overloaded_functions (tree fns, const char **str)
+{
+  tree fn;
+  for (fn = fns; fn; fn = OVL_NEXT (fn))
+    {
+      if (TREE_CODE (fn) == TREE_LIST)
+       print_candidates (fn);
+      else
+       error ("%s %+#D", *str, OVL_CURRENT (fn));
+      *str = "               ";
+    }
+}
+
 /* Print the list of candidate FNS in an error message.  */
 
 void
 print_candidates (tree fns)
 {
-  tree fn;
-  tree f;
-
   const char *str = "candidates are:";
 
   if (is_overloaded_fn (fns))
+    print_overloaded_functions (fns, &str);
+  else
     {
-      for (f = fns; f; f = OVL_NEXT (f))
-       {
-         error ("%s %+#D", str, OVL_CURRENT (f));
-         str = "               ";
-       }
-    }
-  else for (fn = fns; fn != NULL_TREE; fn = TREE_CHAIN (fn))
-    {
-      for (f = TREE_VALUE (fn); f; f = OVL_NEXT (f))
-       error ("%s %+#D", str, OVL_CURRENT (f));
-      str = "               ";
+      tree fn;
+      for (fn = fns; fn != NULL_TREE; fn = TREE_CHAIN (fn))
+       print_overloaded_functions (TREE_VALUE (fn), &str);
     }
 }
 
index f2ba2da..cd4c631 100644 (file)
@@ -1,3 +1,11 @@
+2009-11-27  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/35112
+       * g++.dg/parse/crash53.C: New.
+       * g++.dg/parse/error17.C: Adjust, error messages are not
+       duplicated anymore.
+       * g++.dg/template/dtor7.C: Remove xfail-ed dg-bogus directives.
+
 2009-11-27  Uros Bizjak  <ubizjak@gmail.com>
 
        * gcc.target/i386/vperm-v4sf-1.c (dg-options): Use -msse2.
diff --git a/gcc/testsuite/g++.dg/parse/crash53.C b/gcc/testsuite/g++.dg/parse/crash53.C
new file mode 100644 (file)
index 0000000..de6d412
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/35112
+
+namespace X { struct A; }  // { dg-error "struct X::A" }
+namespace Y { struct A; }  // { dg-error "struct Y::A" }
+namespace Z { struct A; }  // { dg-error "struct Z::A" }
+namespace W { struct A; }  // { dg-error "struct W::A" }
+
+using namespace X;
+using namespace Y;
+using namespace Z;
+using namespace W;
+
+A* p; // { dg-error "reference to 'A' is ambiguous|'A' does not name a type" }
index 4cd4044..b308c91 100644 (file)
@@ -2,10 +2,8 @@
 // PR c++/16965
 
 template <typename T> struct B { 
-  static int Bar(T); // { dg-error "14:candidates are: " "1" }
-  // { dg-error "14:with T = int" "2" { target *-*-* } 5 }
+  static int Bar(T); // { dg-error "14:candidates are: |with T = int" }
 }; 
 struct D : B<int>, B<char> {}; 
  
-int i2 = D::Bar(2); // { dg-error "13:reference to 'Bar' is ambiguous" }
-// { dg-error "10:reference to 'Bar' is ambiguous" "2" { target *-*-* } 10 }
+int i2 = D::Bar(2); // { dg-error "10:reference to 'Bar' is ambiguous" }
index 0dac69e..e96f563 100644 (file)
@@ -1,10 +1,10 @@
 // PR c++/40373
 // { dg-compile }
 
-struct A;      // { dg-bogus "candidates are" "" { xfail *-*-* } }
+struct A;
 namespace
 {
-  struct A;    // { dg-bogus "struct" "" { xfail *-*-* } }
+  struct A;
 }
 
 struct B {};
@@ -20,5 +20,3 @@ bar ()
 {
   foo (B ());  // { dg-bogus "instantiated from here" "" { xfail *-*-* } }
 }
-
-// { dg-bogus "is ambiguous" "" { xfail *-*-* } 15 }