aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <doug.gregor@gmail.com>2006-11-21 20:22:05 +0000
committerDoug Gregor <dgregor@gcc.gnu.org>2006-11-21 20:22:05 +0000
commit200d648149c0f505e0b1962e30f7f6975077fdbf (patch)
tree6b4f5015e15fd2cc6ed53ed05dfdbbf4835430a0
parenta3b9719911e4d66d880178486b2527cff196e1cc (diff)
downloadgcc-200d648149c0f505e0b1962e30f7f6975077fdbf.zip
gcc-200d648149c0f505e0b1962e30f7f6975077fdbf.tar.gz
gcc-200d648149c0f505e0b1962e30f7f6975077fdbf.tar.bz2
static_assert1.C: New.
2006-11-21 Douglas Gregor <doug.gregor@gmail.com> * g++.dg/cpp0x/static_assert1.C: New. * g++.dg/cpp0x/static_assert2.C: New. * g++.dg/cpp0x/static_assert3.C: New. From-SVN: r119063
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/static_assert1.C14
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/static_assert2.C35
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/static_assert3.C3
4 files changed, 58 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b6d5d4a..5927943 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2006-11-21 Douglas Gregor <doug.gregor@gmail.com>
+
+ * g++.dg/cpp0x/static_assert1.C: New.
+ * g++.dg/cpp0x/static_assert2.C: New.
+ * g++.dg/cpp0x/static_assert3.C: New.
+
2006-11-21 Richard Guenther <rguenther@suse.de>
* gcc.dg/vect/vect-pow-1.c: New testcase.
diff --git a/gcc/testsuite/g++.dg/cpp0x/static_assert1.C b/gcc/testsuite/g++.dg/cpp0x/static_assert1.C
new file mode 100644
index 0000000..a546175
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/static_assert1.C
@@ -0,0 +1,14 @@
+// { dg-options "-std=c++0x" }
+void foo()
+{
+ static_assert(1, "okay");
+ static_assert (0 == 1, "zero is never equal to one"); // { dg-error "never equal" }
+}
+
+class X {
+ static_assert(1, "okay");
+ static_assert (0 == 1, "zero is never equal to one"); // { dg-error "never equal" }
+};
+
+static_assert(1, "okay");
+static_assert (0 == 1, "zero is never equal to one"); // { dg-error "never equal" }
diff --git a/gcc/testsuite/g++.dg/cpp0x/static_assert2.C b/gcc/testsuite/g++.dg/cpp0x/static_assert2.C
new file mode 100644
index 0000000..3e74bb1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/static_assert2.C
@@ -0,0 +1,35 @@
+// { dg-options "-std=c++0x" }
+template<int I>
+struct accept_evens {
+ static_assert( I % 2 == 0, "I must be an even number"); // { dg-error "even number" }
+};
+
+template<int I>
+struct accept_evens_ok {
+ static_assert( I % 2 == 0, "I must be an even number");
+};
+
+template<int I>
+void accept_odds() {
+ static_assert( I % 2 == 1, "I must be an odd number"); // { dg-error "odd number" }
+}
+
+template<int I>
+void accept_odds_ok() {
+ static_assert( I % 2 == 1, "I must be an odd number");
+}
+
+void f()
+{
+ accept_odds<1>();
+ accept_odds<2>();
+ accept_odds<3>();
+ accept_odds_ok<5>();
+ accept_odds_ok<7>();
+}
+
+accept_evens<0> ok0;
+accept_evens<1> error1;
+accept_evens<2> ok2;
+accept_evens_ok<4> ok4;
+accept_evens_ok<6> ok6;
diff --git a/gcc/testsuite/g++.dg/cpp0x/static_assert3.C b/gcc/testsuite/g++.dg/cpp0x/static_assert3.C
new file mode 100644
index 0000000..69f93ab
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/static_assert3.C
@@ -0,0 +1,3 @@
+// { dg-options "-std=c++0x" }
+static_assert(7 / 0, "X"); // { dg-error "non-constant condition" }
+// { dg-warning "division by zero" "" { target *-*-* } 2 }