re PR c++/89391 (ICE in build_target_expr_with_type, at cp/tree.c:795)
authorJakub Jelinek <jakub@redhat.com>
Tue, 19 Feb 2019 08:40:07 +0000 (09:40 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 19 Feb 2019 08:40:07 +0000 (09:40 +0100)
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
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/reinterpret_cast2.C [new file with mode: 0644]

index 21979b564f8f53eaf3b932843a30375db3e98dfc..1398d48392f464aa0d889e7c63d655e7e83e1057 100644 (file)
@@ -1,5 +1,9 @@
 2019-02-19  Jakub Jelinek  <jakub@redhat.com>
 
+       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.
index 7045284552975fd3c4ff9216f88d4b9974945a83..1db9333b5ff437601395f1e9296b880fb9af1ba3 100644 (file)
@@ -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.  */
index d12d51ff2d6c72efb2ad840f124e7fe9deb9116b..925e82e1625393c676e1b0c66180df93038a63e3 100644 (file)
@@ -1,5 +1,8 @@
 2019-02-19  Jakub Jelinek  <jakub@redhat.com>
 
+       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 (file)
index 0000000..59f3932
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/89391
+// { dg-do compile { target c++11 } }
+
+struct S { };
+
+void
+foo ()
+{
+  auto a = reinterpret_cast<S&&>(foo ());      // { dg-error "invalid cast of an rvalue expression of type 'void' to type" }
+}