diff options
| -rw-r--r-- | gcc/ChangeLog | 6 | ||||
| -rw-r--r-- | gcc/c-typeck.c | 7 |
2 files changed, 12 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index de76835..3c1aaaf 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 0ecc4db..b284661 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -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); |
