diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-06-06 16:01:37 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-06-06 16:01:37 +0000 |
commit | a0771737785702d15016325848a314e68582403c (patch) | |
tree | 66b582dce11988db429d9434ea9bf376af8fd140 /gcc/cp | |
parent | 9cc12bedca6a5f3bbcbb6e06e1ed81f93a784653 (diff) | |
download | gcc-a0771737785702d15016325848a314e68582403c.tar.gz |
/cp
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.
/testsuite
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@211318 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/class.c | 17 |
2 files changed, 16 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 053155ae4ac..54c7948bb88 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +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 diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 110dbf4f305..25fc89bc013 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -3480,22 +3480,25 @@ check_field_decls (tree t, tree *access_decls, /* 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; } } |