* cp-tree.def (LOOKUP_EXPR): Remove.
* cp-tree.h (cp_id_kind): Add CP_ID_KIND_UNQUALIFIED_DEPENDENT.
(LOOKUP_EXPR_GLOBAL): Remove.
(get_bindings): Remove.
(is_aggr_type_2): Remove.
* call.c (resolved_scoped_fn_name): Remove support for
LOOKUP_EXPR.
* decl.c (grokfndecl): Likewise.
(grokdeclarator): Likewise.
* error.c (dump_decl): Likewise.
(dump_expr): Likewise.
* friend.c (do_friend): Likewise.
* init.c (build_offset_ref): Likewise.
* lex.c (unqualified_fn_lookup_error): Use pedwarn. Do not create
LOOKUP_EXPRs
* mangle.c (write_expression): Remove support for LOOKUP_EXPR.
* parser.c (cp_parser_postfix_expression): Modify Koenig lookup
test.
* pt.c (get_bindings): Give it internal linkage.
(check_explicit_specialization): Remove support for LOOKUP_EXPR.
(lookup_template_function): Likewise.
(for_each_tempalte_parm_r): Likewise.
(tsubst_decl): Likewise.
(tsubst_qualified_id): Handle template template parameters.
(tsubst_copy): Remove support for LOOKUP_EXPR.
(tsubst_copy_and_build): Likewise.
(most_general_template): Likewise.
(value_dependent_expression_p): Likewise.
(type_dependent_expression_p): Note that IDENTIFIER_NODEs are
always dependent.
* semantics.c (perform_koenig_lookup): Do not create
IDENTIFIER_NODEs.
(finish_fname): Likewise.
(finish_id_expression): Likewise.
* tree.c (is_aggr_type_2): Remove.
From-SVN: r69427
+2003-07-15 Mark Mitchell <mark@codesourcery.com>
+
+ * cp-tree.def (LOOKUP_EXPR): Remove.
+ * cp-tree.h (cp_id_kind): Add CP_ID_KIND_UNQUALIFIED_DEPENDENT.
+ (LOOKUP_EXPR_GLOBAL): Remove.
+ (get_bindings): Remove.
+ (is_aggr_type_2): Remove.
+ * call.c (resolved_scoped_fn_name): Remove support for
+ LOOKUP_EXPR.
+ * decl.c (grokfndecl): Likewise.
+ (grokdeclarator): Likewise.
+ * error.c (dump_decl): Likewise.
+ (dump_expr): Likewise.
+ * friend.c (do_friend): Likewise.
+ * init.c (build_offset_ref): Likewise.
+ * lex.c (unqualified_fn_lookup_error): Use pedwarn. Do not create
+ LOOKUP_EXPRs
+ * mangle.c (write_expression): Remove support for LOOKUP_EXPR.
+ * parser.c (cp_parser_postfix_expression): Modify Koenig lookup
+ test.
+ * pt.c (get_bindings): Give it internal linkage.
+ (check_explicit_specialization): Remove support for LOOKUP_EXPR.
+ (lookup_template_function): Likewise.
+ (for_each_tempalte_parm_r): Likewise.
+ (tsubst_decl): Likewise.
+ (tsubst_qualified_id): Handle template template parameters.
+ (tsubst_copy): Remove support for LOOKUP_EXPR.
+ (tsubst_copy_and_build): Likewise.
+ (most_general_template): Likewise.
+ (value_dependent_expression_p): Likewise.
+ (type_dependent_expression_p): Note that IDENTIFIER_NODEs are
+ always dependent.
+ * semantics.c (perform_koenig_lookup): Do not create
+ IDENTIFIER_NODEs.
+ (finish_fname): Likewise.
+ (finish_id_expression): Likewise.
+ * tree.c (is_aggr_type_2): Remove.
+
2003-07-16 Gabriel Dos Reis <gdr@integrable-solutions.net>
PR c++/11531
/* Find the possibly overloaded set of functions corresponding to a
call of the form SCOPE::NAME (...). NAME might be a
- TEMPLATE_ID_EXPR, OVERLOAD, _DECL, IDENTIFIER_NODE or LOOKUP_EXPR. */
+ TEMPLATE_ID_EXPR, OVERLOAD, _DECL, or IDENTIFIER_NODE. */
tree
resolve_scoped_fn_name (tree scope, tree name)
}
if (TREE_CODE (name) == OVERLOAD)
name = DECL_NAME (get_first_fn (name));
- else if (TREE_CODE (name) == LOOKUP_EXPR)
- name = TREE_OPERAND (name, 0);
if (TREE_CODE (scope) == NAMESPACE_DECL)
fn = lookup_namespace_name (scope, name);
The second is the TREE_LIST or TREE_VEC of explicitly specified
arguments. The template will be a FUNCTION_DECL, TEMPLATE_DECL, or
an OVERLOAD. If the template-id refers to a member template, the
- template may be an IDENTIFIER_NODE. In an uninstantiated template,
- the template may be a LOOKUP_EXPR. */
+ template may be an IDENTIFIER_NODE. */
DEFTREECODE (TEMPLATE_ID_EXPR, "template_id_expr", 'e', 2)
/* A list-like node for chaining overloading candidates. TREE_TYPE is
tree structure. */
DEFTREECODE (WRAPPER, "wrapper", 'x', 0)
-/* Used to represent deferred name lookup for dependent names while
- parsing a template declaration. The first argument is an
- IDENTIFIER_NODE for the name in question. The TREE_TYPE is
- unused. */
-DEFTREECODE (LOOKUP_EXPR, "lookup_expr", 'e', 1)
-
/* A whole bunch of tree codes for the initial, superficial parsing of
templates. */
DEFTREECODE (MODOP_EXPR, "modop_expr", 'e', 3)
IDENTIFIER_MARKED (IDENTIFIER_NODEs)
NEW_EXPR_USE_GLOBAL (in NEW_EXPR).
DELETE_EXPR_USE_GLOBAL (in DELETE_EXPR).
- LOOKUP_EXPR_GLOBAL (in LOOKUP_EXPR).
TREE_INDIRECT_USING (in NAMESPACE_DECL).
ICS_USER_FLAG (in _CONV)
CLEANUP_P (in TRY_BLOCK)
CP_ID_KIND_NONE,
/* An unqualified-id that is not a template-id. */
CP_ID_KIND_UNQUALIFIED,
+ /* An uqualified-id that is a dependent name. */
+ CP_ID_KIND_UNQUALIFIED_DEPENDENT,
/* An unqualified template-id. */
CP_ID_KIND_TEMPLATE_ID,
/* A qualified-id. */
DECL_TI_TEMPLATE, `template <class U> S<int>::f<U>'.
As a special case, for a member friend template of a template
- class, this value will not be a TEMPLATE_DECL, but rather a
- LOOKUP_EXPR, IDENTIFIER_NODE or OVERLOAD indicating the name of
- the template and any explicit template arguments provided. For
- example, in:
+ class, this value will not be a TEMPLATE_DECL, but rather an
+ IDENTIFIER_NODE or OVERLOAD indicating the name of the template and
+ any explicit template arguments provided. For example, in:
template <class T> struct S { friend void f<int>(int, double); }
- the DECL_TI_TEMPLATE will be a LOOKUP_EXPR for `f' and the
+ the DECL_TI_TEMPLATE will be an IDENTIFIER_NODE for `f' and the
DECL_TI_ARGS will be {int}. */
#define DECL_TI_TEMPLATE(NODE) TI_TEMPLATE (DECL_TEMPLATE_INFO (NODE))
#define NEW_EXPR_USE_GLOBAL(NODE) TREE_LANG_FLAG_0 (NODE)
#define DELETE_EXPR_USE_GLOBAL(NODE) TREE_LANG_FLAG_0 (NODE)
#define DELETE_EXPR_USE_VEC(NODE) TREE_LANG_FLAG_1 (NODE)
-#define LOOKUP_EXPR_GLOBAL(NODE) TREE_LANG_FLAG_0 (NODE)
/* Nonzero if this AGGR_INIT_EXPR provides for initialization via a
constructor call, rather than an ordinary function call. */
extern void do_decl_instantiation (tree, tree);
extern void do_type_instantiation (tree, tree, tsubst_flags_t);
extern tree instantiate_decl (tree, int);
-extern tree get_bindings (tree, tree, tree);
extern int push_tinst_level (tree);
extern void pop_tinst_level (void);
extern int more_specialized_class (tree, tree, tree);
extern tree build_overload (tree, tree);
extern tree function_arg_chain (tree);
extern int promotes_to_aggr_type (tree, enum tree_code);
-extern int is_aggr_type_2 (tree, tree);
extern const char *cxx_printable_name (tree, int);
extern tree build_exception_variant (tree, tree);
extern tree bind_template_template_parm (tree, tree);
fns = TREE_OPERAND (fns, 1);
}
my_friendly_assert (TREE_CODE (fns) == IDENTIFIER_NODE
- || TREE_CODE (fns) == LOOKUP_EXPR
|| TREE_CODE (fns) == OVERLOAD, 20001120);
DECL_TEMPLATE_INFO (decl) = tree_cons (fns, args, NULL_TREE);
{
tree fns = TREE_OPERAND (decl, 0);
- if (TREE_CODE (fns) == LOOKUP_EXPR)
- fns = TREE_OPERAND (fns, 0);
-
dname = fns;
if (TREE_CODE (dname) == COMPONENT_REF)
dname = TREE_OPERAND (dname, 1);
}
break;
- case LOOKUP_EXPR:
- dump_decl (TREE_OPERAND (t, 0), flags);
- break;
-
case LABEL_DECL:
print_tree_identifier (scratch_buffer, DECL_NAME (t));
break;
print_right_paren (scratch_buffer);
break;
- case LOOKUP_EXPR:
- print_tree_identifier (scratch_buffer, TREE_OPERAND (t, 0));
- break;
-
case ARROW_EXPR:
dump_expr (TREE_OPERAND (t, 0), flags);
output_add_string (scratch_buffer, "->");
if (TREE_CODE (declarator) == TEMPLATE_ID_EXPR)
{
declarator = TREE_OPERAND (declarator, 0);
- if (TREE_CODE (declarator) == LOOKUP_EXPR)
- declarator = TREE_OPERAND (declarator, 0);
if (is_overloaded_fn (declarator))
declarator = DECL_NAME (get_first_fn (declarator));
}
name = DECL_NAME (name);
else
{
- if (TREE_CODE (name) == LOOKUP_EXPR)
- /* This can happen during tsubst'ing. */
- name = TREE_OPERAND (name, 0);
- else
- {
- if (TREE_CODE (name) == COMPONENT_REF)
- name = TREE_OPERAND (name, 1);
- if (TREE_CODE (name) == OVERLOAD)
- name = DECL_NAME (OVL_CURRENT (name));
- }
+ if (TREE_CODE (name) == COMPONENT_REF)
+ name = TREE_OPERAND (name, 1);
+ if (TREE_CODE (name) == OVERLOAD)
+ name = DECL_NAME (OVL_CURRENT (name));
}
my_friendly_assert (TREE_CODE (name) == IDENTIFIER_NODE, 0);
declaration of "f" is available. Historically, G++ and most
other compilers accepted that usage; explain to the user what
is going wrong. */
- (flag_permissive ? warning : error)
- ("there are no arguments to `%D' that depend on a template "
- "parameter, so a declaration of `%D' must be available", name,
- name);
+ pedwarn ("there are no arguments to `%D' that depend on a template "
+ "parameter, so a declaration of `%D' must be available",
+ name, name);
if (!flag_permissive)
{
hint = true;
}
}
- return build_min_nt (LOOKUP_EXPR, name);
+ return name;
}
return unqualified_name_lookup_error (name);
{
template_args = TREE_OPERAND (member, 1);
member = TREE_OPERAND (member, 0);
- if (TREE_CODE (member) == LOOKUP_EXPR)
- member = TREE_OPERAND (member, 0);
}
else
template_args = NULL_TREE;
/* Keep looping until the postfix-expression is complete. */
while (true)
{
- if (TREE_CODE (postfix_expression) == IDENTIFIER_NODE
+ if (idk == CP_ID_KIND_UNQUALIFIED
+ && TREE_CODE (postfix_expression) == IDENTIFIER_NODE
&& cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_PAREN))
/* It is not a Koenig lookup function call. */
postfix_expression
static tree tsubst_friend_function (tree, tree);
static tree tsubst_friend_class (tree, tree);
static int can_complete_type_without_circularity (tree);
+static tree get_bindings (tree, tree, tree);
static tree get_bindings_real (tree, tree, tree, int, int, int);
static int template_decl_level (tree);
static int check_cv_quals_for_unify (int, tree, tree);
return decl;
}
- else if (TREE_CODE (TREE_OPERAND (declarator, 0)) == LOOKUP_EXPR)
- {
- /* A friend declaration. We can't do much, because we don't
- know what this resolves to, yet. */
- my_friendly_assert (is_friend != 0, 0);
- my_friendly_assert (!explicit_instantiation, 0);
- SET_DECL_IMPLICIT_INSTANTIATION (decl);
- return decl;
- }
else if (ctype != NULL_TREE
&& (TREE_CODE (TREE_OPERAND (declarator, 0)) ==
IDENTIFIER_NODE))
my_friendly_assert (TREE_CODE (fns) == TEMPLATE_DECL
|| TREE_CODE (fns) == OVERLOAD
|| BASELINK_P (fns)
- || TREE_CODE (fns) == IDENTIFIER_NODE
- || TREE_CODE (fns) == LOOKUP_EXPR,
+ || TREE_CODE (fns) == IDENTIFIER_NODE,
20020730);
if (BASELINK_P (fns))
case ARROW_EXPR:
case DOTSTAR_EXPR:
case TYPEID_EXPR:
- case LOOKUP_EXPR:
case PSEUDO_DTOR_EXPR:
if (!fn)
return error_mark_node;
};
Here, the DECL_TI_TEMPLATE for the friend declaration
- will be a LOOKUP_EXPR or an IDENTIFIER_NODE. We are
- being called from tsubst_friend_function, and we want
- only to create a new decl (R) with appropriate types so
- that we can call determine_specialization. */
+ will be an IDENTIFIER_NODE. We are being called from
+ tsubst_friend_function, and we want only to create a
+ new decl (R) with appropriate types so that we can call
+ determine_specialization. */
gen_tmpl = NULL_TREE;
}
}
else
expr = name;
+
+ /* This case can occur while determining which of two templates is
+ the more specialized. After performing argument deduction, we
+ check that no invalid types are created. During that phase, we
+ may seem uninstantiated template parameters. */
+ if (TREE_CODE (scope) == BOUND_TEMPLATE_TEMPLATE_PARM)
+ {
+ if (is_template)
+ expr = lookup_template_function (expr, template_args);
+ return build_nt (SCOPE_REF, scope, expr);
+ }
+
if (!BASELINK_P (name) && !DECL_P (expr))
expr = lookup_qualified_name (scope, expr, /*is_type_p=*/0,
(complain & tf_error) != 0);
}
if (is_template)
- lookup_template_function (expr, template_args);
+ expr = lookup_template_function (expr, template_args);
if (TYPE_P (scope))
{
/* Ordinary template template argument. */
return t;
- case LOOKUP_EXPR:
- {
- /* We must tsubst into a LOOKUP_EXPR in case the names to
- which it refers is a conversion operator; in that case the
- name will change. We avoid making unnecessary copies,
- however. */
-
- tree id = tsubst_copy (TREE_OPERAND (t, 0), args, complain, in_decl);
-
- if (id != TREE_OPERAND (t, 0))
- {
- r = build_nt (LOOKUP_EXPR, id);
- LOOKUP_EXPR_GLOBAL (r) = LOOKUP_EXPR_GLOBAL (t);
- t = r;
- }
-
- return t;
- }
-
case CAST_EXPR:
case REINTERPRET_CAST_EXPR:
case CONST_CAST_EXPR:
switch (TREE_CODE (t))
{
- case LOOKUP_EXPR:
case IDENTIFIER_NODE:
{
tree decl;
- tree scope;
cp_id_kind idk;
tree qualifying_class;
bool non_constant_expression_p;
const char *error_msg;
- /* Remember whether this identifier was explicitly qualified
- with "::". */
- if (TREE_CODE (t) == LOOKUP_EXPR && LOOKUP_EXPR_GLOBAL (t))
- scope = global_namespace;
- else
- scope = NULL_TREE;
- /* Get at the underlying identifier. */
- if (TREE_CODE (t) == LOOKUP_EXPR)
- t = TREE_OPERAND (t, 0);
-
if (IDENTIFIER_TYPENAME_P (t))
{
tree new_type = tsubst (TREE_TYPE (t), args, complain, in_decl);
}
/* Look up the name. */
- if (scope == global_namespace)
- decl = IDENTIFIER_GLOBAL_VALUE (t);
- else
- decl = lookup_name (t, 0);
+ decl = lookup_name (t, 0);
/* By convention, expressions use ERROR_MARK_NODE to indicate
failure, not NULL_TREE. */
if (decl == NULL_TREE)
decl = error_mark_node;
- decl = finish_id_expression (t, decl, scope,
+ decl = finish_id_expression (t, decl, NULL_TREE,
&idk,
&qualifying_class,
/*constant_expression_p=*/false,
/* Look for more and more general templates. */
while (DECL_TEMPLATE_INFO (decl))
{
- /* The DECL_TI_TEMPLATE can be a LOOKUP_EXPR or IDENTIFIER_NODE
- in some cases. (See cp-tree.h for details.) */
+ /* The DECL_TI_TEMPLATE can be an IDENTIFIER_NODE in some cases.
+ (See cp-tree.h for details.) */
if (TREE_CODE (DECL_TI_TEMPLATE (decl)) != TEMPLATE_DECL)
break;
return false;
/* A name declared with a dependent type. */
- if (TREE_CODE (expression) == LOOKUP_EXPR
+ if (TREE_CODE (expression) == IDENTIFIER_NODE
|| (DECL_P (expression)
&& type_dependent_expression_p (expression)))
return true;
if (expression == error_mark_node)
return false;
+
+ /* An unresolved name is always dependent. */
+ if (TREE_CODE (expression) == IDENTIFIER_NODE)
+ return true;
/* Some expression forms are never type-dependent. */
if (TREE_CODE (expression) == PSEUDO_DTOR_EXPR
fn = unqualified_fn_lookup_error (identifier);
}
else
- fn = build_min_nt (LOOKUP_EXPR, identifier);
+ fn = identifier;
return fn;
}
decl = fname_decl (C_RID_CODE (id), id);
if (processing_template_decl)
- decl = build_min_nt (LOOKUP_EXPR, DECL_NAME (decl));
+ decl = DECL_NAME (decl);
return decl;
}
An id-expression is type-dependent if it contains an
identifier that was declared with a dependent type.
- As an optimization, we could choose not to create a
- LOOKUP_EXPR for a name that resolved to a local variable in
- the template function that we are currently declaring; such a
- name cannot ever resolve to anything else. If we did that we
- would not have to look up these names at instantiation time.
-
The standard is not very specific about an id-expression that
names a set of overloaded functions. What if some of them
have dependent types and some of them do not? Presumably,
constant when things are instantiated. */
if (constant_expression_p)
*non_constant_expression_p = true;
- /* Create a LOOKUP_EXPR for other unqualified names. */
- return build_min_nt (LOOKUP_EXPR, id_expression);
+ *idk = CP_ID_KIND_UNQUALIFIED_DEPENDENT;
+ return id_expression;
}
/* Only certain kinds of names are allowed in constant
return ovl_cons (decl, chain);
}
-int
-is_aggr_type_2 (tree t1, tree t2)
-{
- if (TREE_CODE (t1) != TREE_CODE (t2))
- return 0;
- return IS_AGGR_TYPE (t1) && IS_AGGR_TYPE (t2);
-}
\f
#define PRINT_RING_SIZE 4