* cp-tree.h (identifier_p): New.
* call.c: Throughout, call identifier_p insstead of direct
comparaison of TREE_CODE against IDENTIFIER_NODE.
* decl.c: Likewisse.
* decl2.c: Likewise.
* init.c: Likewise.
* mangle.c: Likewise.
* name-lookup.c: Likewise.
* parser.c: Likewise.
* pt.c: Likewise.
* search.c: Likewise.
* semantics.c: Likewise.
* tree.c: Likewise.
* typeck.c: Likewise.
* typeck2.c: Likewise.
From-SVN: r196897
+2013-03-21 Gabriel Dos Reis <gdr@integrable-solutions.net>
+
+ * cp-tree.h (identifier_p): New.
+ * call.c: Throughout, call identifier_p insstead of direct
+ comparaison of TREE_CODE against IDENTIFIER_NODE.
+ * decl.c: Likewisse.
+ * decl2.c: Likewise.
+ * init.c: Likewise.
+ * mangle.c: Likewise.
+ * name-lookup.c: Likewise.
+ * parser.c: Likewise.
+ * pt.c: Likewise.
+ * search.c: Likewise.
+ * semantics.c: Likewise.
+ * tree.c: Likewise.
+ * typeck.c: Likewise.
+ * typeck2.c: Likewise.
+
2013-03-21 Jakub Jelinek <jakub@redhat.com>
PR middle-end/48087
name = TREE_TYPE (name);
else if (TYPE_P (name))
/* OK */;
- else if (TREE_CODE (name) == IDENTIFIER_NODE)
+ else if (identifier_p (name))
{
if ((MAYBE_CLASS_TYPE_P (basetype)
&& name == constructor_name (basetype))
: ACONCAT ((msgstr, " ", NULL)));
location_t cloc = location_of (candidate->fn);
- if (TREE_CODE (candidate->fn) == IDENTIFIER_NODE)
+ if (identifier_p (candidate->fn))
{
cloc = loc;
if (candidate->num_convs == 3)
- do not have the same parameter type list as any non-template
non-member candidate. */
- if (TREE_CODE (cand1->fn) == IDENTIFIER_NODE
- || TREE_CODE (cand2->fn) == IDENTIFIER_NODE)
+ if (identifier_p (cand1->fn) || identifier_p (cand2->fn))
{
for (i = 0; i < len; ++i)
if (!same_type_p (cand1->convs[i]->type,
if (cand1->fn == cand2->fn)
/* Two built-in candidates; arbitrarily pick one. */
return 1;
- else if (TREE_CODE (cand1->fn) == IDENTIFIER_NODE)
+ else if (identifier_p (cand1->fn))
/* cand1 is built-in; prefer cand2. */
return -1;
else
tree label_value;
};
+/* Return a typed pointer version of T if it designates a
+ C++ front-end identifier. */
+inline lang_identifier*
+identifier_p (tree t)
+{
+ if (TREE_CODE (t) == IDENTIFIER_NODE)
+ return (lang_identifier*) t;
+ return NULL;
+}
+
/* In an IDENTIFIER_NODE, nonzero if this identifier is actually a
keyword. C_RID_CODE (node) is then the RID_* value of the keyword,
and C_RID_YYCODE is the token number wanted by Yacc. */
error ("%qD used without template parameters", name);
return error_mark_node;
}
- gcc_assert (TREE_CODE (name) == IDENTIFIER_NODE);
+ gcc_assert (identifier_p (name));
gcc_assert (TYPE_P (context));
if (!MAYBE_CLASS_TYPE_P (context))
name = TYPE_IDENTIFIER (name);
else if (DECL_P (name))
name = DECL_NAME (name);
- gcc_assert (TREE_CODE (name) == IDENTIFIER_NODE);
+ gcc_assert (identifier_p (name));
if (!dependent_type_p (context)
|| currently_open_class (context))
}
else
{
- gcc_assert (TREE_CODE (ce->index) == IDENTIFIER_NODE);
+ gcc_assert (identifier_p (ce->index));
error ("name %qD used in a GNU-style designated "
"initializer for an array", ce->index);
}
== current_class_type);
fns = TREE_OPERAND (fns, 1);
}
- gcc_assert (TREE_CODE (fns) == IDENTIFIER_NODE
- || TREE_CODE (fns) == OVERLOAD);
+ gcc_assert (identifier_p (fns) || TREE_CODE (fns) == OVERLOAD);
DECL_TEMPLATE_INFO (decl) = build_template_info (fns, args);
for (t = TYPE_ARG_TYPES (TREE_TYPE (decl)); t; t = TREE_CHAIN (t))
tree decl;
tree explicit_scope;
- gcc_assert (!name || TREE_CODE (name) == IDENTIFIER_NODE);
+ gcc_assert (!name || identifier_p (name));
/* Compute the scope in which to place the variable, but remember
whether or not that scope was explicitly specified by the user. */
{
if (!identifier)
error ("unnamed variable or field declared void");
- else if (TREE_CODE (identifier) == IDENTIFIER_NODE)
+ else if (identifier_p (identifier))
{
gcc_assert (!IDENTIFIER_OPNAME_P (identifier));
error ("variable or field %qE declared void", identifier);
tree fns = TREE_OPERAND (decl, 0);
dname = fns;
- if (TREE_CODE (dname) != IDENTIFIER_NODE)
+ if (!identifier_p (dname))
{
gcc_assert (is_overloaded_fn (dname));
dname = DECL_NAME (get_first_fn (dname));
/* Fall through. */
case IDENTIFIER_NODE:
- if (TREE_CODE (decl) == IDENTIFIER_NODE)
+ if (identifier_p (decl))
dname = decl;
if (C_IS_RESERVED_WORD (dname))
}
if (dname
- && TREE_CODE (dname) == IDENTIFIER_NODE
+ && identifier_p (dname)
&& UDLIT_OPER_P (dname)
&& innermost_code != cdk_function)
{
common. With no options, it is allowed. With -Wreturn-type,
it is a warning. It is only an error with -pedantic-errors. */
is_main = (funcdef_flag
- && dname && TREE_CODE (dname) == IDENTIFIER_NODE
+ && dname && identifier_p (dname)
&& MAIN_NAME_P (dname)
&& ctype == NULL_TREE
&& in_namespace == NULL_TREE
tree context = NULL_TREE;
tag_scope scope;
- gcc_assert (TREE_CODE (name) == IDENTIFIER_NODE);
+ gcc_assert (identifier_p (name));
switch (tag_code)
{
bool scoped_enum_p, bool *is_new)
{
tree prevtype = NULL_TREE;
- gcc_assert (TREE_CODE (name) == IDENTIFIER_NODE);
+ gcc_assert (identifier_p (name));
if (is_new)
*is_new = false;
second and following arguments. Attributes like mode, format,
cleanup and several target specific attributes aren't late
just because they have an IDENTIFIER_NODE as first argument. */
- if (arg == args && TREE_CODE (t) == IDENTIFIER_NODE)
+ if (arg == args && identifier_p (t))
continue;
if (value_dependent_expression_p (t)
}
else
{
- if (TREE_CODE (name) == IDENTIFIER_NODE)
+ if (identifier_p (name))
field = lookup_field (current_class_type, name, 1, false);
else
field = name;
{
MANGLE_TRACE_TREE ("unqualified-name", decl);
- if (TREE_CODE (decl) == IDENTIFIER_NODE)
+ if (identifier_p (decl))
{
write_unqualified_id (decl);
return;
static void
write_member_name (tree member)
{
- if (TREE_CODE (member) == IDENTIFIER_NODE)
+ if (identifier_p (member))
write_unqualified_id (member);
else if (DECL_P (member))
write_unqualified_name (member);
{
write_expression (TREE_OPERAND (expr, 0));
}
- else if (TREE_CODE (expr) == IDENTIFIER_NODE)
+ else if (identifier_p (expr))
{
/* An operator name appearing as a dependent name needs to be
specially marked to disambiguate between a use of the operator
if (!name)
return false;
- if (TREE_CODE (name) != IDENTIFIER_NODE)
+ if (!identifier_p (name))
return false;
/* These don't have names. */
gcc_assert (function && TREE_CODE (function) == FUNCTION_DECL);
name = DECL_NAME (function);
- gcc_assert (name && TREE_CODE (name) == IDENTIFIER_NODE);
+ gcc_assert (name && identifier_p (name));
for (iter = IDENTIFIER_NAMESPACE_BINDINGS (name);
iter;
tree decl;
gcc_assert (TREE_CODE (scope) == NAMESPACE_DECL);
- gcc_assert (TREE_CODE (name) == IDENTIFIER_NODE);
+ gcc_assert (identifier_p (name));
for (decl = current_binding_level->usings; decl; decl = DECL_CHAIN (decl))
if (USING_DECL_SCOPE (decl) == scope && DECL_NAME (decl) == name)
break;
|| COMPLETE_TYPE_P (b->this_entity))))
b = b->level_chain;
- gcc_assert (TREE_CODE (name) == IDENTIFIER_NODE);
+ gcc_assert (identifier_p (name));
/* Do C++ gratuitous typedefing. */
if (identifier_type_value_1 (name) != type)
case CPP_KEYWORD:
/* Some keywords have a value that is not an IDENTIFIER_NODE.
For example, `struct' is mapped to an INTEGER_CST. */
- if (TREE_CODE (token->u.value) != IDENTIFIER_NODE)
+ if (!identifier_p (token->u.value))
break;
/* else fall through */
case CPP_NAME:
if (qualifying_scope && TYPE_P (qualifying_scope))
qualifying_scope = TYPE_MAIN_VARIANT (qualifying_scope);
- gcc_assert (TREE_CODE (unqualified_name) == IDENTIFIER_NODE
+ gcc_assert (identifier_p (unqualified_name)
|| TREE_CODE (unqualified_name) == BIT_NOT_EXPR
|| TREE_CODE (unqualified_name) == TEMPLATE_ID_EXPR);
{
if (TYPE_P (type))
error_at (location, "%qT is not a template", type);
- else if (TREE_CODE (type) == IDENTIFIER_NODE)
+ else if (identifier_p (type))
{
if (tag_type != none_type)
error_at (location, "%qE is not a class template", type);
tree id, location_t id_location)
{
tree result;
- if (TREE_CODE (id) == IDENTIFIER_NODE)
+ if (identifier_p (id))
{
result = make_typename_type (scope, id, typename_type,
/*complain=*/tf_none);
while (true)
{
if (idk == CP_ID_KIND_UNQUALIFIED
- && TREE_CODE (postfix_expression) == IDENTIFIER_NODE
+ && identifier_p (postfix_expression)
&& cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_PAREN))
/* It is not a Koenig lookup function call. */
postfix_expression
if (idk == CP_ID_KIND_UNQUALIFIED
|| idk == CP_ID_KIND_TEMPLATE_ID)
{
- if (TREE_CODE (postfix_expression) == IDENTIFIER_NODE)
+ if (identifier_p (postfix_expression))
{
if (!args->is_empty ())
{
cp_id_kind idk;
const char *error_msg;
- if (TREE_CODE (expr) == IDENTIFIER_NODE)
+ if (identifier_p (expr))
/* Lookup the name we got back from the id-expression. */
expr = cp_parser_lookup_name (parser, expr,
none_type,
}
/* Build a representation of the specialization. */
- if (TREE_CODE (templ) == IDENTIFIER_NODE)
+ if (identifier_p (templ))
template_id = build_min_nt_loc (next_token->location,
TEMPLATE_ID_EXPR,
templ, arguments);
&& !global_p
&& !qualified_p
&& TREE_CODE (type) == TYPE_DECL
- && TREE_CODE (DECL_NAME (type)) == IDENTIFIER_NODE)
+ && identifier_p (DECL_NAME (type)))
maybe_note_name_used_in_class (DECL_NAME (type), type);
/* If it didn't work out, we don't have a TYPE. */
if ((flags & CP_PARSER_FLAGS_OPTIONAL)
depending on what scope we are in. */
if (qscope == error_mark_node || identifier == error_mark_node)
;
- else if (TREE_CODE (identifier) != IDENTIFIER_NODE
+ else if (!identifier_p (identifier)
&& TREE_CODE (identifier) != BIT_NOT_EXPR)
/* [namespace.udecl]
unqualified_name = error_mark_node;
else if (unqualified_name
&& (qualifying_scope
- || (TREE_CODE (unqualified_name)
- != IDENTIFIER_NODE)))
+ || (!identifier_p (unqualified_name))))
{
cp_parser_error (parser, "expected unqualified-id");
unqualified_name = error_mark_node;
/* Check to see that it is really the name of a class. */
if (TREE_CODE (decl) == TEMPLATE_ID_EXPR
- && TREE_CODE (TREE_OPERAND (decl, 0)) == IDENTIFIER_NODE
+ && identifier_p (TREE_OPERAND (decl, 0))
&& cp_lexer_next_token_is (parser->lexer, CPP_SCOPE))
/* Situations like this:
/* By this point, the NAME should be an ordinary identifier. If
the id-expression was a qualified name, the qualifying scope is
stored in PARSER->SCOPE at this point. */
- gcc_assert (TREE_CODE (name) == IDENTIFIER_NODE);
+ gcc_assert (identifier_p (name));
/* Perform the lookup. */
if (parser->scope)
node = token->u.value;
- while (node && TREE_CODE (node) == IDENTIFIER_NODE
+ while (node && identifier_p (node)
&& (node == ridpointers [(int) RID_IN]
|| node == ridpointers [(int) RID_OUT]
|| node == ridpointers [(int) RID_INOUT]
{
tree fns;
- gcc_assert (TREE_CODE (declarator) == IDENTIFIER_NODE);
+ gcc_assert (identifier_p (declarator));
if (ctype)
fns = dname;
else
return decl;
}
else if (ctype != NULL_TREE
- && (TREE_CODE (TREE_OPERAND (declarator, 0)) ==
- IDENTIFIER_NODE))
+ && (identifier_p (TREE_OPERAND (declarator, 0))))
{
/* Find the list of functions in ctype that have the same
name as the declared function. */
gcc_assert (!arglist || TREE_CODE (arglist) == TREE_VEC);
- if (!is_overloaded_fn (fns) && TREE_CODE (fns) != IDENTIFIER_NODE)
+ if (!is_overloaded_fn (fns) && !identifier_p (fns))
{
error ("%q#D is not a function template", fns);
return error_mark_node;
spec_entry elt;
hashval_t hash;
- if (TREE_CODE (d1) == IDENTIFIER_NODE)
+ if (identifier_p (d1))
{
tree value = innermost_non_namespace_value (d1);
if (value && DECL_TEMPLATE_TEMPLATE_PARM_P (value))
|| TREE_CODE (t) == TEMPLATE_PARM_INDEX
|| TREE_CODE (t) == OVERLOAD
|| BASELINK_P (t)
- || TREE_CODE (t) == IDENTIFIER_NODE
+ || identifier_p (t)
|| TREE_CODE (t) == TRAIT_EXPR
|| TREE_CODE (t) == CONSTRUCTOR
|| CONSTANT_CLASS_P (t))
if (TREE_VALUE (t)
&& TREE_CODE (TREE_VALUE (t)) == TREE_LIST
&& TREE_VALUE (TREE_VALUE (t))
- && (TREE_CODE (TREE_VALUE (TREE_VALUE (t)))
- == IDENTIFIER_NODE))
+ && (identifier_p (TREE_VALUE (TREE_VALUE (t)))))
{
tree chain
= tsubst_expr (TREE_CHAIN (TREE_VALUE (t)), args, complain,
input_location);
if (error_msg)
error (error_msg);
- if (!function_p && TREE_CODE (decl) == IDENTIFIER_NODE)
+ if (!function_p && identifier_p (decl))
{
if (complain & tf_error)
unqualified_name_lookup_error (decl);
/*done=*/false,
/*address_p=*/false);
}
- else if (koenig_p && TREE_CODE (function) == IDENTIFIER_NODE)
+ else if (koenig_p && identifier_p (function))
{
/* Do nothing; calling tsubst_copy_and_build on an identifier
would incorrectly perform unqualified lookup again.
not appropriate, even if an unqualified-name was used
to denote the function. */
&& !DECL_FUNCTION_MEMBER_P (get_first_fn (function)))
- || TREE_CODE (function) == IDENTIFIER_NODE)
+ || identifier_p (function))
/* Only do this when substitution turns a dependent call
into a non-dependent call. */
&& type_dependent_expression_p_push (t)
function = perform_koenig_lookup (function, call_args, false,
tf_none);
- if (TREE_CODE (function) == IDENTIFIER_NODE
+ if (identifier_p (function)
&& !any_type_dependent_arguments_p (call_args))
{
if (koenig_p && (complain & tf_warning_or_error))
function = unq;
}
}
- if (TREE_CODE (function) == IDENTIFIER_NODE)
+ if (identifier_p (function))
{
if (complain & tf_error)
unqualified_name_lookup_error (function);
return false;
/* An unresolved name is always dependent. */
- if (TREE_CODE (expression) == IDENTIFIER_NODE
- || TREE_CODE (expression) == USING_DECL)
+ if (identifier_p (expression) || TREE_CODE (expression) == USING_DECL)
return true;
/* Some expression forms are never type-dependent. */
if (type_dependent_expression_p (TREE_OPERAND (expression, 0)))
return true;
expression = TREE_OPERAND (expression, 1);
- if (TREE_CODE (expression) == IDENTIFIER_NODE)
+ if (identifier_p (expression))
return false;
}
/* SCOPE_REF with non-null TREE_TYPE is always non-dependent. */
return NULL_TREE;
case COMPONENT_REF:
- if (TREE_CODE (TREE_OPERAND (*tp, 1)) == IDENTIFIER_NODE)
+ if (identifier_p (TREE_OPERAND (*tp, 1)))
/* In a template, finish_class_member_access_expr creates a
COMPONENT_REF with an IDENTIFIER_NODE for op1 even if it isn't
type-dependent, so that we can check access control at
|| TREE_CODE (tmpl) == TEMPLATE_TEMPLATE_PARM)
return true;
/* So are names that have not been looked up. */
- if (TREE_CODE (tmpl) == SCOPE_REF
- || TREE_CODE (tmpl) == IDENTIFIER_NODE)
+ if (TREE_CODE (tmpl) == SCOPE_REF || identifier_p (tmpl))
return true;
/* So are member templates of dependent classes. */
if (TYPE_P (CP_DECL_CONTEXT (tmpl)))
find a TEMPLATE_DECL. Otherwise, we want to find a TYPE_DECL. */
if (!decl)
/*nop*/;
- else if (TREE_CODE (TYPENAME_TYPE_FULLNAME (type)) == IDENTIFIER_NODE
+ else if (identifier_p (TYPENAME_TYPE_FULLNAME (type))
&& TREE_CODE (decl) == TYPE_DECL)
{
result = TREE_TYPE (decl);
{
tree field;
- gcc_assert (TREE_CODE (name) == IDENTIFIER_NODE);
+ gcc_assert (identifier_p (name));
if (TREE_CODE (type) == TEMPLATE_TYPE_PARM
|| TREE_CODE (type) == BOUND_TEMPLATE_TEMPLATE_PARM
|| xbasetype == error_mark_node)
return NULL_TREE;
- gcc_assert (TREE_CODE (name) == IDENTIFIER_NODE);
+ gcc_assert (identifier_p (name));
if (TREE_CODE (xbasetype) == TREE_BINFO)
{
tree
finish_goto_stmt (tree destination)
{
- if (TREE_CODE (destination) == IDENTIFIER_NODE)
+ if (identifier_p (destination))
destination = lookup_label (destination);
/* We warn about unused labels with -Wunused. That means we have to
}
/* Find the name of the overloaded function. */
- if (TREE_CODE (fn) == IDENTIFIER_NODE)
+ if (identifier_p (fn))
identifier = fn;
else if (is_overloaded_fn (fn))
{
if (scope
&& (!TYPE_P (scope)
|| (!dependent_type_p (scope)
- && !(TREE_CODE (id_expression) == IDENTIFIER_NODE
+ && !(identifier_p (id_expression)
&& IDENTIFIER_TYPENAME_P (id_expression)
&& dependent_type_p (TREE_TYPE (id_expression))))))
{
the current class so that we can check later to see if
the meaning would have been different after the class
was entirely defined. */
- if (!scope && decl != error_mark_node
- && TREE_CODE (id_expression) == IDENTIFIER_NODE)
+ if (!scope && decl != error_mark_node && identifier_p (id_expression))
maybe_note_name_used_in_class (id_expression, decl);
/* Disallow uses of local variables from containing functions, except
/* A template-id where the name of the template was not resolved
is definitely dependent. */
else if (TREE_CODE (decl) == TEMPLATE_ID_EXPR
- && (TREE_CODE (TREE_OPERAND (decl, 0))
- == IDENTIFIER_NODE))
+ && (identifier_p (TREE_OPERAND (decl, 0))))
dependent_p = true;
/* For anything except an overloaded function, just check its
type. */
[expr.ref]), decltype(e) is defined as the type of the entity
named by e. If there is no such entity, or e names a set of
overloaded functions, the program is ill-formed. */
- if (TREE_CODE (expr) == IDENTIFIER_NODE)
+ if (identifier_p (expr))
expr = lookup_name (expr);
if (TREE_CODE (expr) == INDIRECT_REF)
tree
dependent_name (tree x)
{
- if (TREE_CODE (x) == IDENTIFIER_NODE)
+ if (identifier_p (x))
return x;
if (TREE_CODE (x) != COMPONENT_REF
&& TREE_CODE (x) != OFFSET_REF
scope, dtor_type);
return error_mark_node;
}
- if (TREE_CODE (dtor_type) == IDENTIFIER_NODE)
+ if (identifier_p (dtor_type))
{
/* In a template, names we can't find a match for are still accepted
destructor names, and we check them here. */
dependent_type_p (object_type)
/* If NAME is just an IDENTIFIER_NODE, then the expression
is dependent. */
- || TREE_CODE (object) == IDENTIFIER_NODE
+ || identifier_p (object)
/* If NAME is "f<args>", where either 'f' or 'args' is
dependent, then the expression is dependent. */
|| (TREE_CODE (name) == TEMPLATE_ID_EXPR
object = build_non_dependent_expr (object);
}
else if (c_dialect_objc ()
- && TREE_CODE (name) == IDENTIFIER_NODE
+ && identifier_p (name)
&& (expr = objc_maybe_build_component_ref (object, name)))
return expr;
}
gcc_assert (CLASS_TYPE_P (scope));
- gcc_assert (TREE_CODE (name) == IDENTIFIER_NODE
- || TREE_CODE (name) == BIT_NOT_EXPR);
+ gcc_assert (identifier_p (name) || TREE_CODE (name) == BIT_NOT_EXPR);
if (constructor_name_p (name, scope))
{
arg = mark_lvalue_use (arg);
argtype = lvalue_type (arg);
- gcc_assert (TREE_CODE (arg) != IDENTIFIER_NODE
- || !IDENTIFIER_OPNAME_P (arg));
+ gcc_assert (!identifier_p (arg) || !IDENTIFIER_OPNAME_P (arg));
if (TREE_CODE (arg) == COMPONENT_REF && type_unknown_p (arg)
&& !really_overloaded_fn (TREE_OPERAND (arg, 1)))
void **slot;
struct pending_abstract_type *pat;
- gcc_assert (!decl || DECL_P (decl)
- || TREE_CODE (decl) == IDENTIFIER_NODE);
+ gcc_assert (!decl || DECL_P (decl) || identifier_p (decl));
if (!abstract_pending_vars)
abstract_pending_vars = htab_create_ggc (31, &pat_calc_hash,
error ("invalid abstract return type for member function %q+#D", decl);
else if (TREE_CODE (decl) == FUNCTION_DECL)
error ("invalid abstract return type for function %q+#D", decl);
- else if (TREE_CODE (decl) == IDENTIFIER_NODE)
+ else if (identifier_p (decl))
/* Here we do not have location information. */
error ("invalid abstract type %qT for %qE", type, decl);
else
latter case can happen in templates where lookup has to be
deferred. */
gcc_assert (TREE_CODE (ce->index) == FIELD_DECL
- || TREE_CODE (ce->index) == IDENTIFIER_NODE);
+ || identifier_p (ce->index));
if (ce->index != field
&& ce->index != DECL_NAME (field))
{
{
if (TREE_CODE (ce->index) == FIELD_DECL)
;
- else if (TREE_CODE (ce->index) == IDENTIFIER_NODE)
+ else if (identifier_p (ce->index))
{
/* This can happen within a cast, see g++.dg/opt/cse2.C. */
tree name = ce->index;