aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2009-11-27 10:44:49 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2009-11-27 10:44:49 +0000
commit85539630e3abdad70f84d87eb0a4458f44961e03 (patch)
tree59ae17451dd4756e0353b1b70eebf9b16b659d14 /gcc
parent58b9741ecbe673531ce7757810a1b24e1a01a96b (diff)
downloadgcc-85539630e3abdad70f84d87eb0a4458f44961e03.zip
gcc-85539630e3abdad70f84d87eb0a4458f44961e03.tar.gz
gcc-85539630e3abdad70f84d87eb0a4458f44961e03.tar.bz2
re PR c++/35112 (ICE and broken diagnostic with ambiguous class name)
/cp 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. From-SVN: r154698
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/parser.c8
-rw-r--r--gcc/cp/pt.c35
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/g++.dg/parse/crash53.C13
-rw-r--r--gcc/testsuite/g++.dg/parse/error17.C6
-rw-r--r--gcc/testsuite/g++.dg/template/dtor7.C6
7 files changed, 55 insertions, 29 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a4142a2..032afa0 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index cd0382e..5c8dbcb 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -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;
}
}
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index dfe7791..db3956b 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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);
}
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f2ba2da..cd4c631 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..de6d412
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/crash53.C
@@ -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" }
diff --git a/gcc/testsuite/g++.dg/parse/error17.C b/gcc/testsuite/g++.dg/parse/error17.C
index 4cd4044..b308c91 100644
--- a/gcc/testsuite/g++.dg/parse/error17.C
+++ b/gcc/testsuite/g++.dg/parse/error17.C
@@ -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" }
diff --git a/gcc/testsuite/g++.dg/template/dtor7.C b/gcc/testsuite/g++.dg/template/dtor7.C
index 0dac69e..e96f563 100644
--- a/gcc/testsuite/g++.dg/template/dtor7.C
+++ b/gcc/testsuite/g++.dg/template/dtor7.C
@@ -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 }