summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2004-03-01 02:25:06 +0000
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2004-03-01 02:25:06 +0000
commit16bd3ffed031d062b8fa0366e16f7e610f7767fb (patch)
tree37c4fdcbc66bbb8c2b3f88b4271cc9b1c6b3fa8e /gcc
parent6fc4d3a2bc1d4660784658f29cf6f2a1d004a046 (diff)
downloadgcc-16bd3ffed031d062b8fa0366e16f7e610f7767fb.tar.gz
PR c++/14267
* typeck.c (build_modify_expr): Remove more of the cast-as-lvalue extension. PR c++/14267 * g++.dg/expr/crash2.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@78689 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/typeck.c47
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/expr/crash2.C14
4 files changed, 22 insertions, 46 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 979f578c091..82de3a9e19c 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2004-02-29 Mark Mitchell <mark@codesourcery.com>
+ PR c++/14267
+ * typeck.c (build_modify_expr): Remove more of the cast-as-lvalue
+ extension.
+
PR debug/12103
* class.c (update_vtable_entry_for_fn): Do not go through
covariance machinery if the type returned by an overrider is the
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index aa85df50bb8..d5d832b4094 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -5098,52 +5098,7 @@ build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs)
20011220);
}
- /* Handle a cast used as an "lvalue".
- We have already performed any binary operator using the value as cast.
- Now convert the result to the cast type of the lhs,
- and then true type of the lhs and store it there;
- then convert result back to the cast type to be the value
- of the assignment. */
-
- switch (TREE_CODE (lhs))
- {
- case NOP_EXPR:
- case CONVERT_EXPR:
- case FLOAT_EXPR:
- case FIX_TRUNC_EXPR:
- case FIX_FLOOR_EXPR:
- case FIX_ROUND_EXPR:
- case FIX_CEIL_EXPR:
- {
- tree inner_lhs = TREE_OPERAND (lhs, 0);
- tree result;
-
- if (TREE_CODE (TREE_TYPE (newrhs)) == ARRAY_TYPE
- || TREE_CODE (TREE_TYPE (newrhs)) == FUNCTION_TYPE
- || TREE_CODE (TREE_TYPE (newrhs)) == METHOD_TYPE
- || TREE_CODE (TREE_TYPE (newrhs)) == OFFSET_TYPE)
- newrhs = decay_conversion (newrhs);
-
- /* ISO C++ 5.4/1: The result is an lvalue if T is a reference
- type, otherwise the result is an rvalue. */
- if (! lvalue_p (lhs))
- pedwarn ("ISO C++ forbids cast to non-reference type used as lvalue");
-
- result = build_modify_expr (inner_lhs, NOP_EXPR,
- cp_convert (TREE_TYPE (inner_lhs),
- cp_convert (lhstype, newrhs)));
- if (result == error_mark_node)
- return result;
- return cp_convert (TREE_TYPE (lhs), result);
- }
-
- default:
- break;
- }
-
- /* Now we have handled acceptable kinds of LHS that are not truly lvalues.
- Reject anything strange now. */
-
+ /* The left-hand side must be an lvalue. */
if (!lvalue_or_else (lhs, "assignment"))
return error_mark_node;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 74be633db11..c6dbd88042f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2004-02-29 Mark Mitchell <mark@codesourcery.com>
+ PR c++/14267
+ * g++.dg/expr/crash2.C: New test.
+
PR middle-end/13448
* gcc.dg/inline-5.c: New test.
* gcc.dg/always-inline.c: Split out tests into ...
diff --git a/gcc/testsuite/g++.dg/expr/crash2.C b/gcc/testsuite/g++.dg/expr/crash2.C
new file mode 100644
index 00000000000..5379bb159d1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/expr/crash2.C
@@ -0,0 +1,14 @@
+// PR c++/14267
+
+class foo {
+public: static int& x;
+};
+int temp;
+int& foo::x=temp;
+
+int main() {
+ int x = 3;
+ &foo::x = x; // { dg-error "" }
+ return 0;
+}
+