aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMichael Matz <matz@suse.de>2004-01-30 17:05:09 +0000
committerMichael Matz <matz@gcc.gnu.org>2004-01-30 17:05:09 +0000
commit48ef529f41516b02d71d415a5b38ae8cb8e068cb (patch)
tree0a714b51277d81f870311ab5860c190f0fcc34cf /gcc
parent98ce043beda605c6125c1b1289fb83d91cbf8407 (diff)
downloadgcc-48ef529f41516b02d71d415a5b38ae8cb8e068cb.zip
gcc-48ef529f41516b02d71d415a5b38ae8cb8e068cb.tar.gz
gcc-48ef529f41516b02d71d415a5b38ae8cb8e068cb.tar.bz2
case-range1.C, [...]: New tests.
* g++.dg/ext/case-range1.C, g++.dg/ext/case-range2.C, g++.dg/ext/case-range3.C: New tests. From-SVN: r76973
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/ext/case-range1.C23
-rw-r--r--gcc/testsuite/g++.dg/ext/case-range2.C27
-rw-r--r--gcc/testsuite/g++.dg/ext/case-range3.C23
4 files changed, 78 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d4138f7..979a0457 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2004-01-30 Michael Matz <matz@suse.de>
+
+ * g++.dg/ext/case-range1.C, g++.dg/ext/case-range2.C,
+ g++.dg/ext/case-range3.C: New tests.
+
2004-01-30 Giovanni Bajo <giovannibajo@gcc.gnu.org>
DR206
diff --git a/gcc/testsuite/g++.dg/ext/case-range1.C b/gcc/testsuite/g++.dg/ext/case-range1.C
new file mode 100644
index 0000000..0e313d6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/case-range1.C
@@ -0,0 +1,23 @@
+// { dg-do compile }
+// Tests if case ranges (a GNU extension) are accepted
+// { dg-options "" }
+const int low = -2;
+const int high = 15;
+
+template <typename T>
+T f2 (T i)
+{
+ switch (i)
+ {
+ case low ... high : return i + 1;
+ default : return 0;
+ }
+}
+
+int f (int i)
+{
+ switch (i) {
+ case 1 ... 10: return i + 1;
+ default: return f2 (i);
+ }
+}
diff --git a/gcc/testsuite/g++.dg/ext/case-range2.C b/gcc/testsuite/g++.dg/ext/case-range2.C
new file mode 100644
index 0000000..33befbd
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/case-range2.C
@@ -0,0 +1,27 @@
+// { dg-do compile }
+// Tests if case ranges (a GNU extension) correctly emit messages
+// about overlapping ranges.
+// { dg-options "" }
+
+const int low = -2;
+const int high = 15;
+
+template <typename T>
+T f2 (T i)
+{
+ switch (i)
+ {
+ case low ... high : return i + 1; // { dg-error "" }
+ case 5 : return i + 2; // { dg-error "duplicate" }
+ default : return 0;
+ }
+}
+
+int f (int i)
+{
+ switch (i) {
+ case 1 ... 10: return i + 1; // { dg-error "" }
+ case 3 ... 5 : return i + 3; // { dg-error "duplicate" }
+ default: return f2 (i); // { dg-error "" }
+ }
+}
diff --git a/gcc/testsuite/g++.dg/ext/case-range3.C b/gcc/testsuite/g++.dg/ext/case-range3.C
new file mode 100644
index 0000000..569ce62
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/case-range3.C
@@ -0,0 +1,23 @@
+// { dg-do compile }
+// Tests if case ranges (a GNU extension) emit errors in ISO mode
+// { dg-options "-pedantic" }
+const int low = -2;
+const int high = 15;
+
+template <typename T>
+T f2 (T i)
+{
+ switch (i)
+ {
+ case low ... high : return i + 1; // { dg-error "non-standard" }
+ default : return 0;
+ }
+}
+
+int f (int i)
+{
+ switch (i) {
+ case 1 ... 10: return i + 1; // { dg-error "non-standard" }
+ default: return f2 (i); // { dg-error "" }
+ }
+}