+2014-06-06 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/60184
+ * class.c (check_field_decls): In C++11 mode do not reject
+ static data members and reference-type members in unions.
+
2014-06-05 Jason Merrill <jason@redhat.com>
PR c++/43453
/* When this goes into scope, it will be a non-local reference. */
DECL_NONLOCAL (x) = 1;
- if (TREE_CODE (t) == UNION_TYPE)
+ if (TREE_CODE (t) == UNION_TYPE
+ && cxx_dialect < cxx11)
{
- /* [class.union]
+ /* [class.union] (C++98)
If a union contains a static data member, or a member of
- reference type, the program is ill-formed. */
+ reference type, the program is ill-formed.
+
+ In C++11 this limitation doesn't exist anymore. */
if (VAR_P (x))
{
- error ("%q+D may not be static because it is a member of a union", x);
+ error ("in C++98 %q+D may not be static because it is "
+ "a member of a union", x);
continue;
}
if (TREE_CODE (type) == REFERENCE_TYPE)
{
- error ("%q+D may not have reference type %qT because"
- " it is a member of a union",
- x, type);
+ error ("in C++98 %q+D may not have reference type %qT "
+ "because it is a member of a union", x, type);
continue;
}
}
+2014-06-06 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/60184
+ * g++.dg/cpp0x/constexpr-union6.C: New.
+ * g++.dg/cpp0x/union6.C: Likewise.
+ * g++.dg/init/ref14.C: Adjust.
+ * g++.dg/init/union1.C: Likewise.
+
2014-06-06 Richard Biener <rguenther@suse.de>
PR tree-optimization/59299
--- /dev/null
+// PR c++/60184
+// { dg-do compile { target c++11 } }
+
+union Test1 {
+ static int kConstant;
+};
+
+union Test2 {
+ static const int kConstant;
+};
+
+const int Test2::kConstant = 10;
+
+union Test3 {
+ int& kConstant;
+};
+
+union Test4 {
+ const int& kConstant = 10;
+};