typeck.c (build_const_cast): Handle references here instead of handing off to convert...
authorJason Merrill <jason@yorick.cygnus.com>
Thu, 27 Nov 1997 22:18:28 +0000 (22:18 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 27 Nov 1997 22:18:28 +0000 (17:18 -0500)
* typeck.c (build_const_cast): Handle references here instead of
handing off to convert_to_reference.

From-SVN: r16810

gcc/cp/ChangeLog
gcc/cp/typeck.c

index 7ab1e62..0b1b931 100644 (file)
@@ -1,5 +1,8 @@
 Thu Nov 27 00:59:46 1997  Jason Merrill  <jason@yorick.cygnus.com>
 
+       * typeck.c (build_const_cast): Handle references here instead of
+       handing off to convert_to_reference.
+
        * except.c: Lose Unexpected, SetTerminate, SetUnexpected,
        TerminateFunctionCall.
        (init_exception_processing): Likewise.  Terminate et al are now
index bd5a43c..34bbf97 100644 (file)
@@ -5488,9 +5488,11 @@ build_const_cast (type, expr)
        }
 
       if (comp_ptr_ttypes_const (TREE_TYPE (type), intype))
-       return (convert_from_reference
-               (convert_to_reference (type, expr, CONV_CONST|CONV_IMPLICIT,
-                                      LOOKUP_COMPLAIN, NULL_TREE)));
+       {
+         expr = build_unary_op (ADDR_EXPR, expr, 0);
+         expr = build1 (NOP_EXPR, type, expr);
+         return convert_from_reference (expr);
+       }
     }
   else if (TREE_CODE (type) == POINTER_TYPE
           && TREE_CODE (intype) == POINTER_TYPE