This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Roger Sayle <roger@eyesopen.com> wrote: > Hi Giovanni, > I suspect a patch something like this might work: > > --- 3752,3759 ---- > { > if (!noconvert) > arg = default_conversion (arg); > ! if (real_lvalue_p (arg)) > ! arg = build1 (NON_LVALUE_EXPR, TREE_TYPE (arg), arg); > } > break; > > > I believe that the real source of the problem is that INTEGER_CSTs > should never be wrapped in NON_LVALUE_EXPRs, No, the frontend actually needs this for this testcase: int n = 0; +n = 3; Otherwise, one of the build_modify_expr family function will succeed its test for lvalueness of the LHS, thus failing to reject this code. > Both of Joseph's examples will get the NON_LVALUE_EXPR they require, > but your X<+1> template instantiation should be fixed. I would like to get rid of NON_LVALUE_EXPR instead, if possible at all. In build_unary_op, the unary expression comes with a wrapping CONVERT_EXPR of the same underlying type. This is a nifty trick to make the expression a rvalue without a specific node. All we have to do is to preserve the CONVERT_EXPR. Tested on i686-pc-linux-gnu, no new regressions (including the new testcases I committed this morning). OK for mainline? Giovanni Bajo cp/ PR c++/18354 * typeck.c (build_unary_op) <CONVERT_EXPR, NEGATE_EXPR>: Unify code. Make sure unary plus is a lvalue, but avoid NON_LVALUE_EXPR. testsuite/ PR c++/18354 * g++.dg/template/nontype11.C: New test.
Attachment:
patch-pr18354.txt
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |