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]

[C++ PATCH]: Fix 2664


Hi,
I've installed the attached patch on both mainline and branch,
to fix 2.95 regression 2664.

We were letting expressions develop with reference type. It's rather
awkward to fix that inside pt.c.

built & tested on i686-pc-linux-gnu, approved by Mark.

nathan
-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2001-04-29  Nathan Sidwell  <nathan@codesourcery.com>

	* call.c (build_new_op): Convert args from reference here.
	(build_conditional_expr): Don't convert here.

Index: cp/call.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/call.c,v
retrieving revision 1.267
diff -c -3 -p -r1.267 call.c
*** call.c	2001/04/20 08:17:18	1.267
--- call.c	2001/04/29 14:23:29
*************** build_conditional_expr (arg1, arg2, arg3
*** 2892,2902 ****
        || TREE_TYPE (arg3) == error_mark_node)
      return error_mark_node;
  
-   /* Convert from reference types to ordinary types; no expressions
-      really have reference type in C++.  */
-   arg2 = convert_from_reference (arg2);
-   arg3 = convert_from_reference (arg3);
-      
    /* [expr.cond]
  
       If either the second or the third operand has type (possibly
--- 2892,2897 ----
*************** build_new_op (code, flags, arg1, arg2, a
*** 3244,3249 ****
--- 3239,3250 ----
    if (arg3 && TREE_CODE (arg3) == OFFSET_REF)
      arg3 = resolve_offset_ref (arg3);
  
+   arg1 = convert_from_reference (arg1);
+   if (arg2)
+     arg2 = convert_from_reference (arg2);
+   if (arg3)
+     arg3 = convert_from_reference (arg3);
+   
    if (code == COND_EXPR)
      {
        if (arg2 == NULL_TREE
// Build don't link:
// 
// Copyright (C) 2001 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 29 Apr 2001 <nathan@codesourcery.com>

// Bug 2664. We failed to convert_from_reference for non-type
// template parms.

struct cow { };

cow c;

void func     (cow &c) {}
void operator-(cow &c) {}

template<cow &C> void test()
{
  func(C); //OK
  -C;      //bogus error
}

int main()
{
  test<c> ();
}

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