From: Patrick Palka Date: Fri, 18 Dec 2015 23:16:33 +0000 (+0000) Subject: Fix PR c++/68978 (bogus error: lvalue required as left operand of assignment) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=46ab17dbae559b0823d43f6f8ffb12f9dc0d10d5;p=gcc.git Fix PR c++/68978 (bogus error: lvalue required as left operand of assignment) gcc/cp/ChangeLog: PR c++/68978 * tree.c (lvalue_kind) [MODOP_EXPR]: New case. gcc/testsuite/ChangeLog: PR c++/68978 * g++.dg/template/pr68978.C: New test. From-SVN: r231841 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d471721f21c..9b8c2ffc6f4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2015-12-18 Patrick Palka + + PR c++/68978 + * tree.c (lvalue_kind) [MODOP_EXPR]: New case. + 2015-12-18 Paolo Carlini PR c++/67592 diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index ae176d00f6d..250fe274669 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -185,6 +185,12 @@ lvalue_kind (const_tree ref) op2_lvalue_kind = lvalue_kind (TREE_OPERAND (ref, 2)); break; + case MODOP_EXPR: + /* We expect to see unlowered MODOP_EXPRs only during + template processing. */ + gcc_assert (processing_template_decl); + return clk_ordinary; + case MODIFY_EXPR: case TYPEID_EXPR: return clk_ordinary; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ceba598dc4e..20ac322ae5d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-12-18 Patrick Palka + + PR c++/68978 + * g++.dg/template/pr68978.C: New test. + 2015-12-18 Jakub Jelinek PR debug/68860 diff --git a/gcc/testsuite/g++.dg/template/pr68978.C b/gcc/testsuite/g++.dg/template/pr68978.C new file mode 100644 index 00000000000..19045329f01 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr68978.C @@ -0,0 +1,39 @@ +// PR c++/68978 + +int i = 0, c = 0, radix = 10, max = 0x7fffffff; + +template int toi_1() { + if (max < ((i *= radix) += c)) + return 0; + return i; +} + +template int toi_2() { + if (max < ((i = radix) = c)) + return 0; + return i; +} + +template int toi_3() { + if (max < ((i = radix) += c)) + return 0; + return i; +} + +template int toi_4() { + if (max < ((i += radix) = c)) + return 0; + return i; +} + +template int toi_5() { + if (max < (((i = radix) += (c += 5)) *= 30)) + return 0; + return i; +} + +int x = toi_1 (); +int y = toi_2 (); +int z = toi_3 (); +int w = toi_4 (); +int r = toi_5 ();