diff options
author | Jason Merrill <jason@redhat.com> | 2002-03-13 04:58:55 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2002-03-13 04:58:55 -0500 |
commit | a1652cee9a2e7c8d25c0179aed8addf8f9c4f0aa (patch) | |
tree | bdf27f82803ff9a102d12fe10a1e14225d617cf6 /gcc | |
parent | c52a375d2133d16ceb3788344801271d30ca87b6 (diff) | |
download | gcc-a1652cee9a2e7c8d25c0179aed8addf8f9c4f0aa.zip gcc-a1652cee9a2e7c8d25c0179aed8addf8f9c4f0aa.tar.gz gcc-a1652cee9a2e7c8d25c0179aed8addf8f9c4f0aa.tar.bz2 |
c-typeck.c (convert_for_assignment): Don't allow conversions between pointers and references.
* c-typeck.c (convert_for_assignment): Don't allow conversions
between pointers and references. Only allow lvalues to convert to
reference.
From-SVN: r50731
Diffstat (limited to 'gcc')
-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); |