This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH]: Add tf_user flag
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: Mark Mitchell <mitchell at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 25 Jul 2003 15:49:09 +0100
- Subject: [C++ PATCH]: Add tf_user flag
- Organization: Codesourcery LLC
Mark,
this patch adds a tf_user flag to the tsubst_flags enumeration. This is used
by lookup_template_class to tell whether it should find a user visible
template (rather than the implicit template for a member function of a template
class). Currently, lookup_template_class uses the form of the ARGLIST
parameter to infer the requirement -- this patch makes it explicit.
Obviously the goal is to remove the list representation of template
argument lists much earlier on ...
booted & tested on i686-pc-linux-gnu, ok?
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
The voices in my head said this was stupid too
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
2003-07-25 Nathan Sidwell <nathan@codesourcery.com>
* cp-tree.h (enum tsubst_flags_t): Add tf_user.
* decl.c (make_typename_type): Pass it.
* pt.c (lookup_template_class): Use it.
(resolve_typename_type): Pass it.
* semantics.c (finish_template_type): Pass it.
Index: cp/cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.887
diff -c -3 -p -r1.887 cp-tree.h
*** cp/cp-tree.h 24 Jul 2003 23:33:25 -0000 1.887
--- cp/cp-tree.h 25 Jul 2003 14:34:05 -0000
*************** typedef enum tsubst_flags_t {
*** 3054,3061 ****
tf_ignore_bad_quals = 1 << 2, /* ignore bad cvr qualifiers */
tf_keep_type_decl = 1 << 3, /* retain typedef type decls
(make_typename_type use) */
! tf_ptrmem_ok = 1 << 4 /* pointers to member ok (internal
! instantiate_type use) */
} tsubst_flags_t;
/* The kind of checking we can do looking in a class hierarchy. */
--- 3054,3063 ----
tf_ignore_bad_quals = 1 << 2, /* ignore bad cvr qualifiers */
tf_keep_type_decl = 1 << 3, /* retain typedef type decls
(make_typename_type use) */
! tf_ptrmem_ok = 1 << 4, /* pointers to member ok (internal
! instantiate_type use) */
! tf_user = 1 << 5 /* Found template must be a user template
! (lookup_template_class use) */
} tsubst_flags_t;
/* The kind of checking we can do looking in a class hierarchy. */
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1099
diff -c -3 -p -r1.1099 decl.c
*** cp/decl.c 25 Jul 2003 04:04:28 -0000 1.1099
--- cp/decl.c 25 Jul 2003 14:34:35 -0000
*************** make_typename_type (tree context, tree n
*** 5523,5529 ****
TREE_OPERAND (fullname, 1),
NULL_TREE, context,
/*entering_scope=*/0,
! tf_error | tf_warning);
}
else
{
--- 5523,5529 ----
TREE_OPERAND (fullname, 1),
NULL_TREE, context,
/*entering_scope=*/0,
! tf_error | tf_warning | tf_user);
}
else
{
Index: cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.736
diff -c -3 -p -r1.736 pt.c
*** cp/pt.c 25 Jul 2003 10:20:09 -0000 1.736
--- cp/pt.c 25 Jul 2003 14:34:59 -0000
*************** lookup_template_class (tree d1,
*** 3957,3964 ****
{
tree template = NULL_TREE, parmlist;
tree t;
!
timevar_push (TV_NAME_LOOKUP);
if (TREE_CODE (d1) == IDENTIFIER_NODE)
{
if (IDENTIFIER_VALUE (d1)
--- 3957,3967 ----
{
tree template = NULL_TREE, parmlist;
tree t;
!
timevar_push (TV_NAME_LOOKUP);
+ my_friendly_assert ((!arglist || TREE_CODE (arglist) == TREE_LIST)
+ == ((complain & tf_user) != 0), 20030724);
+
if (TREE_CODE (d1) == IDENTIFIER_NODE)
{
if (IDENTIFIER_VALUE (d1)
*************** lookup_template_class (tree d1,
*** 4018,4028 ****
}
if (TREE_CODE (template) != TEMPLATE_DECL
! /* If we're called from the parser, make sure it's a user visible
! template. */
! || ((!arglist || TREE_CODE (arglist) == TREE_LIST)
! && !DECL_TEMPLATE_PARM_P (template)
! && !PRIMARY_TEMPLATE_P (template)))
{
if (complain & tf_error)
{
--- 4021,4030 ----
}
if (TREE_CODE (template) != TEMPLATE_DECL
! /* Make sure it's a user visible template, if it was named by
! the user. */
! || ((complain & tf_user) && !DECL_TEMPLATE_PARM_P (template)
! && !PRIMARY_TEMPLATE_P (template)))
{
if (complain & tf_error)
{
*************** lookup_template_class (tree d1,
*** 4033,4038 ****
--- 4035,4042 ----
POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, error_mark_node);
}
+ complain &= ~tf_user;
+
if (DECL_TEMPLATE_TEMPLATE_PARM_P (template))
{
/* Create a new TEMPLATE_DECL and TEMPLATE_TEMPLATE_PARM node to store
*************** resolve_typename_type (tree type, bool o
*** 11794,11801 ****
args = TREE_OPERAND (TYPENAME_TYPE_FULLNAME (type), 1);
/* Instantiate the template. */
type = lookup_template_class (tmpl, args, NULL_TREE, NULL_TREE,
! /*entering_scope=*/0,
! tf_error);
}
else
type = error_mark_node;
--- 11798,11804 ----
args = TREE_OPERAND (TYPENAME_TYPE_FULLNAME (type), 1);
/* Instantiate the template. */
type = lookup_template_class (tmpl, args, NULL_TREE, NULL_TREE,
! /*entering_scope=*/0, tf_error | tf_user);
}
else
type = error_mark_node;
Index: cp/semantics.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/semantics.c,v
retrieving revision 1.333
diff -c -3 -p -r1.333 semantics.c
*** cp/semantics.c 22 Jul 2003 23:30:20 -0000 1.333
--- cp/semantics.c 25 Jul 2003 14:35:05 -0000
*************** finish_template_type (tree name, tree ar
*** 2183,2190 ****
tree decl;
decl = lookup_template_class (name, args,
! NULL_TREE, NULL_TREE,
! entering_scope, /*complain=*/1);
if (decl != error_mark_node)
decl = TYPE_STUB_DECL (decl);
--- 2183,2190 ----
tree decl;
decl = lookup_template_class (name, args,
! NULL_TREE, NULL_TREE, entering_scope,
! tf_error | tf_warning | tf_user);
if (decl != error_mark_node)
decl = TYPE_STUB_DECL (decl);