summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp0x/constexpr-function3.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/cpp0x/constexpr-function3.C')
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/constexpr-function3.C30
1 files changed, 30 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-function3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-function3.C
new file mode 100644
index 000000000..e8ca7bc68
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-function3.C
@@ -0,0 +1,30 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// From N2235
+
+// function template 1
+template<typename T>
+ constexpr int bytesize(T t)
+ { return sizeof (t); } // OK
+
+char buf[bytesize(0)]; // OK -- not C99 VLA
+
+
+// function template 2
+template<typename _Tp>
+ constexpr _Tp
+ square(_Tp x) { return x; }
+
+// Explicit specialization
+template<>
+ constexpr unsigned long
+ square(unsigned long x) { return x * x; }
+
+// Explicit instantiation
+template int square(int);
+
+class A { };
+template A square(A);
+
+template long square(long);