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]

Re: [C++ PATCH] [PR18354] Unary plus as template argument


On Sun, 14 Nov 2004, Giovanni Bajo wrote:
> As for (b), I accept suggestions about how to fix it without reintroducing
> NON_LVALUE_EXPR. Otherwise, I will have to just strip that code in
> convert_nontype_argument to avoid the failure.

Hi Giovanni,

I suspect a patch something like this might work:


Index: typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/typeck.c,v
retrieving revision 1.596
diff -c -3 -p -r1.596 typeck.c
*** typeck.c    11 Nov 2004 03:13:03 -0000      1.596
--- typeck.c    14 Nov 2004 16:13:06 -0000
*************** build_unary_op (enum tree_code code, tre
*** 3752,3758 ****
        {
          if (!noconvert)
            arg = default_conversion (arg);
!         arg = build1 (NON_LVALUE_EXPR, TREE_TYPE (arg), arg);
        }
        break;

--- 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, and indeed this is the
only one of the five remaining places in GCC that create
NON_LVALUE_EXPR nodes without checking whether it is actually
needed or not.

Both of Joseph's examples will get the NON_LVALUE_EXPR they require,
but your X<+1> template instantiation should be fixed.

I hope this helps.

Roger
--


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]