summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp0x/auto4.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/cpp0x/auto4.C')
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/auto4.C28
1 files changed, 28 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp0x/auto4.C b/gcc/testsuite/g++.dg/cpp0x/auto4.C
new file mode 100644
index 000000000..d47bca436
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/auto4.C
@@ -0,0 +1,28 @@
+// Testcase for deduction of std::initializer_list for auto.
+// { dg-do run }
+// { dg-options "-std=c++0x" }
+
+#include <typeinfo>
+#include <initializer_list>
+extern "C" void abort();
+
+template <class T>
+void f (T t)
+{
+ auto ilt = { &t, &t };
+ if (typeid(ilt) != typeid(std::initializer_list<T*>))
+ abort();
+
+ auto il = { 1, 2, 3 };
+ if (typeid(il) != typeid(std::initializer_list<int>))
+ abort();
+}
+
+int main()
+{
+ auto il = { 1, 2, 3 };
+ if (typeid(il) != typeid(std::initializer_list<int>))
+ abort();
+
+ f('c');
+}