From 50aaebab9410ae7afd6875fb396bdc23f6e4c32f Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 19 Feb 2019 09:40:07 +0100 Subject: [PATCH] re PR c++/89391 (ICE in build_target_expr_with_type, at cp/tree.c:795) PR c++/89391 * typeck.c (build_reinterpret_cast_1): Don't handle void to && conversion go through build_target_expr_with_type. * g++.dg/cpp0x/reinterpret_cast2.C: New test. From-SVN: r269008 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/typeck.c | 2 +- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/cpp0x/reinterpret_cast2.C | 10 ++++++++++ 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/reinterpret_cast2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 21979b564f8..1398d48392f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2019-02-19 Jakub Jelinek + PR c++/89391 + * typeck.c (build_reinterpret_cast_1): Don't handle void to + && conversion go through build_target_expr_with_type. + PR c++/89390 * error.c (qualified_name_lookup_error): Only call suggest_alternative_in_scoped_enum if name is IDENTIFIER_NODE. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 70452845529..1db9333b5ff 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -7477,7 +7477,7 @@ build_reinterpret_cast_1 (tree type, tree expr, bool c_cast_p, reinterpret_cast. */ if (TYPE_REF_P (type)) { - if (TYPE_REF_IS_RVALUE (type)) + if (TYPE_REF_IS_RVALUE (type) && !VOID_TYPE_P (intype)) { if (!obvalue_p (expr)) /* Perform the temporary materialization conversion. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d12d51ff2d6..925e82e1625 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2019-02-19 Jakub Jelinek + PR c++/89391 + * g++.dg/cpp0x/reinterpret_cast2.C: New test. + PR c++/89390 * g++.dg/diagnostic/pr89390.C: New test. diff --git a/gcc/testsuite/g++.dg/cpp0x/reinterpret_cast2.C b/gcc/testsuite/g++.dg/cpp0x/reinterpret_cast2.C new file mode 100644 index 00000000000..59f39324c7c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/reinterpret_cast2.C @@ -0,0 +1,10 @@ +// PR c++/89391 +// { dg-do compile { target c++11 } } + +struct S { }; + +void +foo () +{ + auto a = reinterpret_cast(foo ()); // { dg-error "invalid cast of an rvalue expression of type 'void' to type" } +} -- 2.30.2