re PR c++/60848 (Crash while experimenting with c++-0x initializer lists)
authorJason Merrill <jason@redhat.com>
Tue, 3 Jun 2014 14:11:10 +0000 (10:11 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 3 Jun 2014 14:11:10 +0000 (10:11 -0400)
PR c++/60848
* call.c (is_std_init_list): Check CLASSTYPE_TEMPLATE_INFO.

From-SVN: r211179

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/g++.dg/cpp0x/initlist85.C [new file with mode: 0644]

index fae8da1..2ed9f15 100644 (file)
@@ -1,3 +1,8 @@
+2014-06-03  Jason Merrill  <jason@redhat.com>
+
+       PR c++/60848
+       * call.c (is_std_init_list): Check CLASSTYPE_TEMPLATE_INFO.
+
 2014-06-02  Jason Merrill  <jason@redhat.com>
 
        PR c++/61046
index 77aa8ca..b60bab7 100644 (file)
@@ -9675,6 +9675,7 @@ is_std_init_list (tree type)
   type = TYPE_MAIN_VARIANT (type);
   return (CLASS_TYPE_P (type)
          && CP_TYPE_CONTEXT (type) == std_node
+         && CLASSTYPE_TEMPLATE_INFO (type)
          && strcmp (TYPE_NAME_STRING (type), "initializer_list") == 0);
 }
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist85.C b/gcc/testsuite/g++.dg/cpp0x/initlist85.C
new file mode 100644 (file)
index 0000000..0eb8e26
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/60848
+// { dg-do compile { target c++11 } }
+
+namespace std
+{
+  struct initializer_list {};
+}
+
+void foo(std::initializer_list &);
+
+void f()
+{
+  foo({1, 2});                 // { dg-error "" }
+}