This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] fix bug 73
- To: gcc-patches at gcc dot gnu dot org
- Subject: [C++ PATCH] fix bug 73
- From: Nathan Sidwell <nathan at codesourcery dot com>
- Date: Wed, 06 Sep 2000 10:27:32 +0100
- Organization: Codesourcery LLC
Hi,
I've installed this patch for bug 73 where we got confused with
TYPENAME_TYPES. When comparing typename_types we were only looking at
the TYPE_IDENTIFIER which failed when a TEMPLATE_ID_EXPR was used as
in T::TPL<arg>.
Also noted that when printing out `typename T::S::R' we'd emit
an extra `typename', hence the patch to error.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
2000-09-05 Nathan Sidwell <nathan@codesourcery.com>
* error.c (dump_typename): New function, broken out of ...
(dump_type): ... here. Use it.
* typeck.c (same_type_p): Use cp_tree_equal for TYPENAME_TYPE.
Index: cp/error.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/error.c,v
retrieving revision 1.130
diff -c -3 -p -r1.130 error.c
*** error.c 2000/09/05 03:52:27 1.130
--- error.c 2000/09/05 14:09:49
*************** static const char *parm_to_string PARAM
*** 87,92 ****
--- 87,93 ----
static const char *type_to_string PARAMS ((tree, int));
static void dump_type PARAMS ((tree, enum tree_string_flags));
+ static void dump_typename PARAMS ((tree, enum tree_string_flags));
static void dump_simple_decl PARAMS ((tree, tree, enum tree_string_flags));
static void dump_decl PARAMS ((tree, enum tree_string_flags));
static void dump_template_decl PARAMS ((tree, enum tree_string_flags));
*************** dump_type (t, flags)
*** 503,511 ****
}
case TYPENAME_TYPE:
OB_PUTS ("typename ");
! dump_type (TYPE_CONTEXT (t), flags & ~TS_AGGR_TAGS);
! OB_PUTS ("::");
! dump_decl (TYPENAME_TYPE_FULLNAME (t), flags);
break;
case TYPEOF_TYPE:
--- 504,510 ----
}
case TYPENAME_TYPE:
OB_PUTS ("typename ");
! dump_typename (t, flags);
break;
case TYPEOF_TYPE:
*************** dump_type (t, flags)
*** 523,528 ****
--- 522,545 ----
OB_PUTS ("{type error}");
break;
}
+ }
+
+ /* Dump a TYPENAME_TYPE. We need to notice when the context is itself
+ a TYPENAME_TYPE. */
+
+ static void
+ dump_typename (t, flags)
+ tree t;
+ enum tree_string_flags flags;
+ {
+ tree ctx = TYPE_CONTEXT (t);
+
+ if (TREE_CODE (ctx) == TYPENAME_TYPE)
+ dump_typename (ctx, flags);
+ else
+ dump_type (ctx, flags & ~TS_AGGR_TAGS);
+ OB_PUTS ("::");
+ dump_decl (TYPENAME_TYPE_FULLNAME (t), flags);
}
/* Return the name of the supplied aggregate, or enumeral type. */
Index: cp/typeck.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/typeck.c,v
retrieving revision 1.308
diff -c -3 -p -r1.308 typeck.c
*** typeck.c 2000/09/05 00:57:57 1.308
--- typeck.c 2000/09/05 14:09:55
*************** comptypes (t1, t2, strict)
*** 1096,1103 ****
&& TEMPLATE_TYPE_LEVEL (t1) == TEMPLATE_TYPE_LEVEL (t2);
case TYPENAME_TYPE:
! if (TYPE_IDENTIFIER (t1) != TYPE_IDENTIFIER (t2))
! return 0;
return same_type_p (TYPE_CONTEXT (t1), TYPE_CONTEXT (t2));
case COMPLEX_TYPE:
--- 1096,1104 ----
&& TEMPLATE_TYPE_LEVEL (t1) == TEMPLATE_TYPE_LEVEL (t2);
case TYPENAME_TYPE:
! if (cp_tree_equal (TYPENAME_TYPE_FULLNAME (t1),
! TYPENAME_TYPE_FULLNAME (t2)) < 1)
! return 0;
return same_type_p (TYPE_CONTEXT (t1), TYPE_CONTEXT (t2));
case COMPLEX_TYPE:
// Build don't link:
//
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 5 Sept 2000 <nathan@codesourcery.com>
// bug 73. We failed to compare explicit arguments for a TEMPLATE_ID_EXPR in a
// TYPENAME_TYPE.
struct Plus {
template <class T>
struct Sig { typedef int Third;};
};
template <class T>
struct Ethel {
typedef int WrappedType;
};
struct Fred {
template <class Q, class LA, class LB>
Ethel<typename Q::Sig<typename LA::WrappedType>::Third> baz ();
template <class Z, class A, class B>
Ethel<typename Z::Sig<A>::Third>
foo ( const Z&, const Ethel<A>&, const Ethel<B>&) const;
};
int main() {
Fred f;
Ethel<int> e;
Plus p;
f.foo (p, e, e);
return 0;
}