c-typeck.c (convert_for_assignment): Don't allow conversions between pointers and...
authorJason Merrill <jason@redhat.com>
Wed, 13 Mar 2002 09:58:55 +0000 (04:58 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 13 Mar 2002 09:58:55 +0000 (04:58 -0500)
        * c-typeck.c (convert_for_assignment): Don't allow conversions
        between pointers and references.  Only allow lvalues to convert to
        reference.

From-SVN: r50731

gcc/ChangeLog
gcc/c-typeck.c

index de7683535729a546c578b3387c2a6929a6b2cec5..3c1aaaf1224c8744e225ab38415e32f73756e319 100644 (file)
@@ -1,3 +1,9 @@
+2002-03-12  Jason Merrill  <jason@redhat.com>
+
+       * c-typeck.c (convert_for_assignment): Don't allow conversions
+       between pointers and references.  Only allow lvalues to convert to
+       reference.
+
 2002-03-13  Hartmut Penner  <hpenner@de.ibm.com>
 
         * config/s390/s390.h (PROFILE_BEFORE_PROLOGUE): Emit profile code
index 0ecc4dbd394ae8ee14b8cd85930ed3acab4ed2dc..b28466122fa04a34e990f33686f630ed4090ebcb 100644 (file)
@@ -4027,6 +4027,11 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum)
   if (codel == REFERENCE_TYPE
       && comptypes (TREE_TYPE (type), TREE_TYPE (rhs)) == 1)
     {
+      if (!lvalue_p (rhs))
+       {
+         error ("cannot pass rvalue to reference parameter");
+         return error_mark_node;
+       }
       if (mark_addressable (rhs) == 0)
        return error_mark_node;
       rhs = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (rhs)), rhs);
@@ -4146,7 +4151,7 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum)
 
   /* Conversions among pointers */
   else if ((codel == POINTER_TYPE || codel == REFERENCE_TYPE)
-          && (coder == POINTER_TYPE || coder == REFERENCE_TYPE))
+          && (coder == codel))
     {
       tree ttl = TREE_TYPE (type);
       tree ttr = TREE_TYPE (rhstype);