diff mbox

[c++] PR c++/80682

Message ID CAFk2RUYqW8dfWRzo_MEYaw9fX8X50rj-wj7bLczFgFy++xsREA@mail.gmail.com
State New
Headers show

Commit Message

Ville Voutilainen May 9, 2017, 1:17 p.m. UTC
On 9 May 2017 at 16:12, Marc Glisse <marc.glisse@inria.fr> wrote:
> On Tue, 9 May 2017, Ville Voutilainen wrote:
>
>> Tested on Linux-x64, not tested with the full suite yet.
>>
>> 2017-05-09  Ville Voutilainen  <ville.voutilainen@gmail.com>
>>
>>    gcc/
>>
>>    PR c++/80682
>>    * cp/method.c (is_trivially_xible): Reject void types.
>>
>>    testsuite/
>>
>>    PR c++/80682
>>    * g++.dg/ext/is_trivially_constructible1.C: Add tests for void target.
>
>
> What happens for "const void" and other variants?


They don't work. New patch attached.

Comments

Jakub Jelinek May 9, 2017, 1:25 p.m. UTC | #1
On Tue, May 09, 2017 at 04:17:07PM +0300, Ville Voutilainen wrote:
> On 9 May 2017 at 16:12, Marc Glisse <marc.glisse@inria.fr> wrote:
> > On Tue, 9 May 2017, Ville Voutilainen wrote:
> >
> >> Tested on Linux-x64, not tested with the full suite yet.
> >>
> >> 2017-05-09  Ville Voutilainen  <ville.voutilainen@gmail.com>
> >>
> >>    gcc/
> >>
> >>    PR c++/80682
> >>    * cp/method.c (is_trivially_xible): Reject void types.

No cp/ in cp/ChangeLog entries.

> >>    testsuite/
> >>
> >>    PR c++/80682
> >>    * g++.dg/ext/is_trivially_constructible1.C: Add tests for void target.
> >
> >
> > What happens for "const void" and other variants?
> 
> 
> They don't work. New patch attached.

> diff --git a/gcc/cp/method.c b/gcc/cp/method.c
> index b4c1f60..9b17ef1 100644
> --- a/gcc/cp/method.c
> +++ b/gcc/cp/method.c
> @@ -1207,6 +1207,8 @@ constructible_expr (tree to, tree from)
>  bool
>  is_trivially_xible (enum tree_code code, tree to, tree from)
>  {
> +  if (cv_unqualified (to) == void_type_node)
> +    return false;

Can't this be checked more cheaply as if (TYPE_MAIN_VARIANT (to) == void_type_node) ?

	Jakub
diff mbox

Patch

diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index b4c1f60..9b17ef1 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -1207,6 +1207,8 @@  constructible_expr (tree to, tree from)
 bool
 is_trivially_xible (enum tree_code code, tree to, tree from)
 {
+  if (cv_unqualified (to) == void_type_node)
+    return false;
   tree expr;
   if (code == MODIFY_EXPR)
     expr = assignable_expr (to, from);
diff --git a/gcc/testsuite/g++.dg/ext/is_trivially_constructible1.C b/gcc/testsuite/g++.dg/ext/is_trivially_constructible1.C
index a5bac7b..175eae9 100644
--- a/gcc/testsuite/g++.dg/ext/is_trivially_constructible1.C
+++ b/gcc/testsuite/g++.dg/ext/is_trivially_constructible1.C
@@ -27,10 +27,18 @@  SA(!__is_trivially_constructible(C,C&));
 SA(__is_trivially_assignable(C,C&));
 SA(!__is_trivially_assignable(C,C));
 SA(!__is_trivially_assignable(C,C&&));
+SA(!__is_trivially_assignable(void,int));
+SA(!__is_trivially_assignable(const void,int));
+SA(!__is_trivially_assignable(volatile void,int));
+SA(!__is_trivially_assignable(const volatile void,int));
 
 SA(__is_trivially_constructible(int,int));
 SA(__is_trivially_constructible(int,double));
 SA(!__is_trivially_constructible(int,B));
+SA(!__is_trivially_constructible(void,int));
+SA(!__is_trivially_constructible(const void,int));
+SA(!__is_trivially_constructible(volatile void,int));
+SA(!__is_trivially_constructible(const volatile void,int));
 
 SA(!__is_trivially_constructible(D));