[C++ PATCH] Fix name lookup inconsistency
Kriang Lerdsuwanakij
lerdsuwa@users.sourceforge.net
Fri Jan 3 17:31:00 GMT 2003
Hi
This following patch corrects an inconsistency in name lookup code.
When doing name lookup a class template preferring a type,
lookup_name returns a TEMPLATE_DECL for an ordinary class template
but returns a TYPE_DECL for a member class template. With the patch,
a TEMPLATE_DECL is always returned. This would help fixing some
template vs class bugs like PR8442 I am working on.
Bootstrapped and tested on i686-pc-linux-gnu with no regressions.
OK to commit to main trunk?
--Kriang
2003-01-03 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
* cp-tree.h (LOOKUP_TEMPLATES_EXPECTED): Remove.
* decl (qualify_lookup): Adjust.
diff -cpr gcc-main-save/gcc/cp/cp-tree.h gcc-main-new/gcc/cp/cp-tree.h
*** gcc-main-save/gcc/cp/cp-tree.h Tue Dec 31 23:28:54 2002
--- gcc-main-new/gcc/cp/cp-tree.h Fri Jan 3 23:13:12 2003
*************** enum overload_flags { NO_SPECIAL = 0, DT
*** 3384,3392 ****
LOOKUP_PREFER_TYPES means not to accept objects, and possibly namespaces.
LOOKUP_PREFER_NAMESPACES means not to accept objects, and possibly types.
! LOOKUP_PREFER_BOTH means class-or-namespace-name.
! LOOKUP_TEMPLATES_EXPECTED means that class templates also count
! as types. */
#define LOOKUP_PROTECT (1)
#define LOOKUP_COMPLAIN (2)
--- 3384,3390 ----
LOOKUP_PREFER_TYPES means not to accept objects, and possibly namespaces.
LOOKUP_PREFER_NAMESPACES means not to accept objects, and possibly types.
! LOOKUP_PREFER_BOTH means class-or-namespace-name. */
#define LOOKUP_PROTECT (1)
#define LOOKUP_COMPLAIN (2)
*************** enum overload_flags { NO_SPECIAL = 0, DT
*** 3402,3408 ****
#define LOOKUP_PREFER_TYPES (2048)
#define LOOKUP_PREFER_NAMESPACES (4096)
#define LOOKUP_PREFER_BOTH (6144)
- #define LOOKUP_TEMPLATES_EXPECTED (8192)
#define LOOKUP_NAMESPACES_ONLY(F) \
(((F) & LOOKUP_PREFER_NAMESPACES) && !((F) & LOOKUP_PREFER_TYPES))
--- 3400,3405 ----
diff -cpr gcc-main-save/gcc/cp/decl.c gcc-main-new/gcc/cp/decl.c
*** gcc-main-save/gcc/cp/decl.c Tue Dec 31 23:28:55 2002
--- gcc-main-new/gcc/cp/decl.c Fri Jan 3 22:47:31 2003
*************** qualify_lookup (val, flags)
*** 5940,5947 ****
return val;
if ((flags & LOOKUP_PREFER_TYPES)
&& (TREE_CODE (val) == TYPE_DECL
! || ((flags & LOOKUP_TEMPLATES_EXPECTED)
! && DECL_CLASS_TEMPLATE_P (val))))
return val;
if (flags & (LOOKUP_PREFER_NAMESPACES | LOOKUP_PREFER_TYPES))
return NULL_TREE;
--- 5940,5946 ----
return val;
if ((flags & LOOKUP_PREFER_TYPES)
&& (TREE_CODE (val) == TYPE_DECL
! || DECL_CLASS_TEMPLATE_P (val)))
return val;
if (flags & (LOOKUP_PREFER_NAMESPACES | LOOKUP_PREFER_TYPES))
return NULL_TREE;
More information about the Gcc-patches
mailing list