summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgiovannibajo <giovannibajo@138bc75d-0d04-0410-961f-82ee72b054a4>2004-01-29 04:26:50 +0000
committergiovannibajo <giovannibajo@138bc75d-0d04-0410-961f-82ee72b054a4>2004-01-29 04:26:50 +0000
commitcd2e98f7191430f5706d75b1e7cc38427d4c2be3 (patch)
tree2d01ccc1d596460bb302a07555bebf3549c9f19b
parentc8d5ab7972079b4b92fdc6efde5e4264ed6a8c0a (diff)
downloadgcc-cd2e98f7191430f5706d75b1e7cc38427d4c2be3.tar.gz
* g++.dg/parse/error11.C: New test.
* g++.dg/parse/error12.C: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@76846 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/parse/error11.C53
-rw-r--r--gcc/testsuite/g++.dg/parse/error12.C12
3 files changed, 70 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 482ea7a0184..7b7f692228b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2004-01-28 Giovanni Bajo <giovannibajo@gcc.gnu.org>
+
+ * g++.dg/parse/error11.C: New test.
+ * g++.dg/parse/error12.C: Likewise.
+
2004-01-28 Ziemowit Laski <zlaski@apple.com>
* objc.dg/proto-qual-1.m (ROUND, aligned_sizeof): New.
diff --git a/gcc/testsuite/g++.dg/parse/error11.C b/gcc/testsuite/g++.dg/parse/error11.C
new file mode 100644
index 00000000000..6b3deec178a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/error11.C
@@ -0,0 +1,53 @@
+// { dg-do compile }
+// Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
+// Try to find out when the digraph '<:' is used as a mistake, and parse it
+// correctly to avoid cascaded errors.
+
+struct B;
+
+template <class A>
+struct Foo
+{
+ template <class T>
+ struct Nested
+ {
+ static void method(void) {}
+ };
+
+ void method(void) {
+ typename Foo<::B>::template Nested<::B> n; // { dg-error "cannot begin|alternate spelling" }
+ n.template Nested<B>::method();
+ n.template Nested<::B>::method(); // { dg-error "cannot begin|alternate spelling" }
+ Nested<B>::method();
+ Nested<::B>::method(); // { dg-error "cannot begin|alternate spelling" }
+ }
+};
+
+template <int N> struct Foo2 {};
+template struct Foo2<::B>; // { dg-error "cannot begin|alternate spelling|type/value mismatch|expected a constant" }
+
+int value = 0;
+
+void func(void)
+{
+ Foo<::B> f; // { dg-error "cannot begin|alternate spelling" }
+ f.Foo<B>::method();
+ f.Foo<::B>::method(); // { dg-error "cannot begin|alternate spelling" }
+
+ // Check cases where we the token sequence is the correct one, but there
+ // was no digraph or whitespaces in the middle, so we should not emit
+ // the special error message.
+ Foo<: :B> k2; // { dg-bogus "cannot begin|alternate spelling" "smart error should not be triggered here" }
+ Foo[:B> k1; // { dg-bogus "cannot begin|alternate spelling" "smart error should not be triggered here" }
+// { dg-error "" "" { target *-*-* } 40 }
+// { dg-error "" "" { target *-*-* } 41 }
+
+ int Foo[2];
+ Foo[::value] = 0;
+}
+
+template struct Foo<::B>; // { dg-error "cannot begin|alternate spelling" }
+
+// On the first error message, an additional note about the use of
+// -fpermissive should be present
+// { dg-error "-fpermissive" "" { target *-*-* } 18 }
diff --git a/gcc/testsuite/g++.dg/parse/error12.C b/gcc/testsuite/g++.dg/parse/error12.C
new file mode 100644
index 00000000000..ea04fd06d11
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/error12.C
@@ -0,0 +1,12 @@
+// { dg-do compile }
+// Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
+// Make sure the error about '<:' can be turned into a warning
+// { dg-options "-fpermissive" }
+
+struct B;
+
+template <class A>
+struct Foo {};
+
+Foo<::B> foo; // { dg-bogus "error" "error in place of warning" }
+// { dg-error "" "" { target *-*-* } 11 }