re PR c++/64489 (A simple struct wrapping a const int is not trivially copyable)

PR c++/64489
	* class.c (check_field_decls): Make copy assignment operators
	complex only in c++98 mode.

From-SVN: r219265
This commit is contained in:
Ville Voutilainen 2015-01-06 22:44:32 +02:00 committed by Jason Merrill
parent 512ef94939
commit 864822bd88
3 changed files with 29 additions and 14 deletions

View File

@ -1,3 +1,9 @@
2015-01-06 Ville Voutilainen <ville.voutilainen@gmail.com>
PR c++/64489
* class.c (check_field_decls): Make copy assignment operators
complex only in c++98 mode.
2015-01-05 Trevor Saunders <tsaunders@mozilla.com> 2015-01-05 Trevor Saunders <tsaunders@mozilla.com>
PR c++/31397 PR c++/31397

View File

@ -3607,7 +3607,8 @@ check_field_decls (tree t, tree *access_decls,
CLASSTYPE_NON_STD_LAYOUT (t) = 1; CLASSTYPE_NON_STD_LAYOUT (t) = 1;
if (DECL_INITIAL (x) == NULL_TREE) if (DECL_INITIAL (x) == NULL_TREE)
SET_CLASSTYPE_REF_FIELDS_NEED_INIT (t, 1); SET_CLASSTYPE_REF_FIELDS_NEED_INIT (t, 1);
if (cxx_dialect < cxx11)
{
/* ARM $12.6.2: [A member initializer list] (or, for an /* ARM $12.6.2: [A member initializer list] (or, for an
aggregate, initialization by a brace-enclosed list) is the aggregate, initialization by a brace-enclosed list) is the
only way to initialize nonstatic const and reference only way to initialize nonstatic const and reference
@ -3615,6 +3616,7 @@ check_field_decls (tree t, tree *access_decls,
TYPE_HAS_COMPLEX_COPY_ASSIGN (t) = 1; TYPE_HAS_COMPLEX_COPY_ASSIGN (t) = 1;
TYPE_HAS_COMPLEX_MOVE_ASSIGN (t) = 1; TYPE_HAS_COMPLEX_MOVE_ASSIGN (t) = 1;
} }
}
type = strip_array_types (type); type = strip_array_types (type);
@ -3715,7 +3717,8 @@ check_field_decls (tree t, tree *access_decls,
C_TYPE_FIELDS_READONLY (t) = 1; C_TYPE_FIELDS_READONLY (t) = 1;
if (DECL_INITIAL (x) == NULL_TREE) if (DECL_INITIAL (x) == NULL_TREE)
SET_CLASSTYPE_READONLY_FIELDS_NEED_INIT (t, 1); SET_CLASSTYPE_READONLY_FIELDS_NEED_INIT (t, 1);
if (cxx_dialect < cxx11)
{
/* ARM $12.6.2: [A member initializer list] (or, for an /* ARM $12.6.2: [A member initializer list] (or, for an
aggregate, initialization by a brace-enclosed list) is the aggregate, initialization by a brace-enclosed list) is the
only way to initialize nonstatic const and reference only way to initialize nonstatic const and reference
@ -3723,6 +3726,7 @@ check_field_decls (tree t, tree *access_decls,
TYPE_HAS_COMPLEX_COPY_ASSIGN (t) = 1; TYPE_HAS_COMPLEX_COPY_ASSIGN (t) = 1;
TYPE_HAS_COMPLEX_MOVE_ASSIGN (t) = 1; TYPE_HAS_COMPLEX_MOVE_ASSIGN (t) = 1;
} }
}
/* A field that is pseudo-const makes the structure likewise. */ /* A field that is pseudo-const makes the structure likewise. */
else if (CLASS_TYPE_P (type)) else if (CLASS_TYPE_P (type))
{ {

View File

@ -36,3 +36,8 @@ SA(!__is_trivially_constructible(D));
SA(__is_trivially_copyable(int)); SA(__is_trivially_copyable(int));
SA(!__is_trivially_copyable(volatile int)); SA(!__is_trivially_copyable(volatile int));
struct E1 {const int val;};
SA(__is_trivially_copyable(E1));
struct E2 {int& val;};
SA(__is_trivially_copyable(E2));