summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/class.cc2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/initlist128.C16
2 files changed, 18 insertions, 0 deletions
diff --git a/gcc/cp/class.cc b/gcc/cp/class.cc
index 5db3722ae46..696155714e8 100644
--- a/gcc/cp/class.cc
+++ b/gcc/cp/class.cc
@@ -7766,6 +7766,8 @@ finish_struct (tree t, tree attributes)
ok = true;
}
}
+ /* It also cannot be a union. */
+ ok &= NON_UNION_CLASS_TYPE_P (t);
if (!ok)
fatal_error (input_location, "definition of %qD does not match "
"%<#include <initializer_list>%>", TYPE_NAME (t));
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist128.C b/gcc/testsuite/g++.dg/cpp0x/initlist128.C
new file mode 100644
index 00000000000..22246860f4e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist128.C
@@ -0,0 +1,16 @@
+// PR c++/102434
+// { dg-do compile { target c++11 } }
+
+using size_t = decltype(sizeof 0);
+
+namespace std {
+ template<typename T> union initializer_list { // { dg-error "definition of .*std::initializer_list.* does not match" }
+ const T *ptr;
+ size_t n;
+ };
+}
+template<typename T>
+void Task() {}
+auto b = { &Task<int> };
+
+// { dg-prune-output "compilation terminated" }