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 bug 147


Hi,
I've installed this patch and test case for bug 147, where we ICE'd on a
TEMPLATE_ID_EXPR featuring a LOOKUP_EXPR in a namespace. This
just moves some code around and then reconstructs
the TEMPLATE_ID_EXPR (a similar reconstruction already happens for
member functions).

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
2000-09-05  Nathan Sidwell  <nathan@codesourcery.com>

	* init.c (build_offset_ref): Deal with namespace scoped
	TEMPLATE_ID_EXPRs.

Index: cp/init.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/init.c,v
retrieving revision 1.215
diff -c -3 -p -r1.215 init.c
*** init.c	2000/09/05 00:57:56	1.215
--- init.c	2000/09/05 09:51:42
*************** build_offset_ref (type, name)
*** 1624,1644 ****
    if (processing_template_decl || uses_template_parms (type))
      return build_min_nt (SCOPE_REF, type, name);
  
-   /* Handle namespace names fully here.  */
-   if (TREE_CODE (type) == NAMESPACE_DECL)
-     {
-       t = lookup_namespace_name (type, name);
-       if (t != error_mark_node && ! type_unknown_p (t))
- 	{
- 	  mark_used (t);
- 	  t = convert_from_reference (t);
- 	}
-       return t;
-     }
- 
-   if (type == NULL_TREE || ! is_aggr_type (type, 1))
-     return error_mark_node;
- 
    if (TREE_CODE (name) == TEMPLATE_ID_EXPR)
      {
        /* If the NAME is a TEMPLATE_ID_EXPR, we are looking at
--- 1624,1629 ----
*************** build_offset_ref (type, name)
*** 1665,1670 ****
--- 1650,1679 ----
  
        my_friendly_assert (TREE_CODE (name) == IDENTIFIER_NODE, 0);
      }
+ 
+   if (type == NULL_TREE)
+     return error_mark_node;
+   
+   /* Handle namespace names fully here.  */
+   if (TREE_CODE (type) == NAMESPACE_DECL)
+     {
+       t = lookup_namespace_name (type, name);
+       if (t == error_mark_node)
+         return t;
+       if (TREE_CODE (orig_name) == TEMPLATE_ID_EXPR)
+         /* Reconstruct the TEMPLATE_ID_EXPR.  */
+         t = build (TEMPLATE_ID_EXPR, TREE_TYPE (t),
+                    t, TREE_OPERAND (orig_name, 1));
+       if (! type_unknown_p (t))
+ 	{
+ 	  mark_used (t);
+ 	  t = convert_from_reference (t);
+ 	}
+       return t;
+     }
+ 
+   if (! is_aggr_type (type, 1))
+     return error_mark_node;
  
    if (TREE_CODE (name) == BIT_NOT_EXPR)
      {
// Build don't link:
// 
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 5 Sept 2000 <nathan@codesourcery.com>

// bug 147. We ICE'd on an unprocessed LOOKUP_EXPR during tsubsting

namespace EManip {
    template <class T> void do_assign(T* d);  // ERROR - candidate
};
template <class T> void do_assign(T* d);    // ERROR - candidate

template <class T>
struct MatrixC
{
  void foo () {
    EManip::do_assign<T> (0);
    &EManip::do_assign<T>;
    &do_assign<T>;
    EManip::do_assign<T>;       // WARNING - not a call
    do_assign<T>;               // WARNING - not a call
  }
};
void foo(MatrixC <double> *ptr)
{
  EManip::do_assign<double>;    // WARNING - not a call
  &EManip::do_assign<double>;
  ptr->foo ();
  void (*p1) (int *) = &do_assign<double>;       // ERROR - cannot convert
  void (*p2) (int *) = &EManip::do_assign<double>; // ERROR - cannot convert
  void (*p3) (int *) = &do_assign;
  void (*p4) (int *) = &EManip::do_assign;
}

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