diff options
author | Marek Polacek <polacek@redhat.com> | 2019-05-20 19:10:57 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2019-05-20 19:10:57 +0000 |
commit | be9e458d8bed984fe13bd7a6daf76bb34ef3ed7f (patch) | |
tree | 79965ad0b9b9ae9d443f1d8e5c49d9dd87b6bfaa /gcc | |
parent | f12ea6acdeb3b62ddb8324bc71a67c6a189f6c3c (diff) | |
download | gcc-be9e458d8bed984fe13bd7a6daf76bb34ef3ed7f.zip gcc-be9e458d8bed984fe13bd7a6daf76bb34ef3ed7f.tar.gz gcc-be9e458d8bed984fe13bd7a6daf76bb34ef3ed7f.tar.bz2 |
CWG 2094 - volatile scalars are trivially copyable.
PR c++/85679
* tree.c (trivially_copyable_p): Don't check CP_TYPE_VOLATILE_P for
scalar types.
* g++.dg/ext/is_trivially_constructible1.C: Change the expected result
for volatile int.
* g++.dg/ext/is_trivially_copyable.C: New test.
* testsuite/20_util/is_trivially_copyable/value.cc: Change the expected
result for volatile int.
From-SVN: r271435
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/tree.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/is_trivially_constructible1.C | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/is_trivially_copyable.C | 16 |
5 files changed, 36 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 88275f0..f5f6c44 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,12 @@ 2019-05-20 Marek Polacek <polacek@redhat.com> + CWG 2094 - volatile scalars are trivially copyable. + PR c++/85679 + * tree.c (trivially_copyable_p): Don't check CP_TYPE_VOLATILE_P for + scalar types. + +2019-05-20 Marek Polacek <polacek@redhat.com> + * pt.c (convert_template_argument): Add a diagnostic for the [temp.arg]/2 ambiguity case. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 8d7f7a2..7813932 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -4098,7 +4098,8 @@ trivially_copyable_p (const_tree t) && !TYPE_HAS_COMPLEX_MOVE_ASSIGN (t) && TYPE_HAS_TRIVIAL_DESTRUCTOR (t)); else - return !CP_TYPE_VOLATILE_P (t) && scalarish_type_p (t); + /* CWG 2094 makes volatile-qualified scalars trivially copyable again. */ + return scalarish_type_p (t); } /* Returns 1 iff type T is a trivial type, as defined in [basic.types] and diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index be4e7eb..c100f6a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,13 @@ 2019-05-20 Marek Polacek <polacek@redhat.com> + CWG 2094 - volatile scalars are trivially copyable. + PR c++/85679 + * g++.dg/ext/is_trivially_constructible1.C: Change the expected result + for volatile int. + * g++.dg/ext/is_trivially_copyable.C: New test. + +2019-05-20 Marek Polacek <polacek@redhat.com> + * g++.dg/ext/utf8-2.C: Accept both "char" and "char8_t" in aka. * g++.dg/cpp2a/nontype-class17.C: New test. diff --git a/gcc/testsuite/g++.dg/ext/is_trivially_constructible1.C b/gcc/testsuite/g++.dg/ext/is_trivially_constructible1.C index 191b696..d28f2f7 100644 --- a/gcc/testsuite/g++.dg/ext/is_trivially_constructible1.C +++ b/gcc/testsuite/g++.dg/ext/is_trivially_constructible1.C @@ -48,7 +48,9 @@ SA(!__is_trivially_constructible(int*, const int*)); SA(!__is_trivially_constructible(D)); SA(__is_trivially_copyable(int)); -SA(!__is_trivially_copyable(volatile int)); +// Changed in CWG 2094, which made volatile-qualified scalars trivially +// copyable. +SA(__is_trivially_copyable(volatile int)); struct E1 {const int val;}; SA(__is_trivially_copyable(E1)); diff --git a/gcc/testsuite/g++.dg/ext/is_trivially_copyable.C b/gcc/testsuite/g++.dg/ext/is_trivially_copyable.C new file mode 100644 index 0000000..6f93602 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/is_trivially_copyable.C @@ -0,0 +1,16 @@ +// CWG 2094 - volatile scalars are trivially copyable. +// PR c++/85679 +// { dg-do compile { target c++11 } } + +#define SA(X) static_assert((X),#X) + +struct S{}; + +SA(__is_trivially_copyable(S volatile)); +SA(__is_trivially_copyable(S volatile[])); +SA(__is_trivially_copyable(S const volatile)); +SA(__is_trivially_copyable(S const volatile[])); +SA(__is_trivially_copyable(int volatile)); +SA(__is_trivially_copyable(int volatile[])); +SA(__is_trivially_copyable(int const volatile)); +SA(__is_trivially_copyable(int const volatile[])); |