/* Classes [gram.class] */
static tree cp_parser_class_name
- (cp_parser *, bool, bool, enum tag_types, bool, bool, bool);
+ (cp_parser *, bool, bool, enum tag_types, bool, bool, bool, bool = false);
static tree cp_parser_class_specifier
(cp_parser *);
static tree cp_parser_class_head
return;
/* If the lookup found a template-name, it means that the user forgot
to specify an argument list. Emit a useful error message. */
- if (TREE_CODE (decl) == TEMPLATE_DECL)
- error_at (location,
- "invalid use of template-name %qE without an argument list",
- decl);
+ if (DECL_TYPE_TEMPLATE_P (decl))
+ {
+ error_at (location,
+ "invalid use of template-name %qE without an argument list",
+ decl);
+ inform (DECL_SOURCE_LOCATION (decl), "%qD declared here", decl);
+ }
else if (TREE_CODE (id) == BIT_NOT_EXPR)
error_at (location, "invalid use of destructor %qD as a type", id);
else if (TREE_CODE (decl) == TYPE_DECL)
error_at (location_of (id),
"%qE in namespace %qE does not name a type",
id, parser->scope);
+ if (DECL_P (decl))
+ inform (DECL_SOURCE_LOCATION (decl), "%qD declared here", decl);
}
else if (CLASS_TYPE_P (parser->scope)
&& constructor_name_p (id, parser->scope))
error_at (location_of (id),
"%qE in %q#T does not name a type",
id, parser->scope);
+ if (DECL_P (decl))
+ inform (DECL_SOURCE_LOCATION (decl), "%qD declared here", decl);
}
else
gcc_unreachable ();
type_p ? class_type : none_type,
check_dependency_p,
/*class_head_p=*/false,
- is_declaration);
+ is_declaration,
+ /*enum_ok=*/cxx_dialect > cxx98);
successful_parse_p = only_class_p || cp_parser_parse_definitely (parser);
- /* If that didn't work and we're in C++0x mode, try for a type-name. */
- if (!only_class_p
- && cxx_dialect != cxx98
- && !successful_parse_p)
- {
- /* Restore the saved scope. */
- parser->scope = saved_scope;
- parser->qualifying_scope = saved_qualifying_scope;
- parser->object_scope = saved_object_scope;
-
- /* Parse tentatively. */
- cp_parser_parse_tentatively (parser);
-
- /* Parse a type-name */
- scope = cp_parser_type_name (parser);
-
- /* "If the name found does not designate a namespace or a class,
- enumeration, or dependent type, the program is ill-formed."
-
- We cover classes and dependent types above and namespaces below,
- so this code is only looking for enums. */
- if (!scope || TREE_CODE (scope) != TYPE_DECL
- || TREE_CODE (TREE_TYPE (scope)) != ENUMERAL_TYPE)
- cp_parser_simulate_error (parser);
-
- successful_parse_p = cp_parser_parse_definitely (parser);
- }
/* If that didn't work, try for a namespace-name. */
if (!only_class_p && !successful_parse_p)
{
is a template. TAG_TYPE indicates the explicit tag given before
the type name, if any. If CHECK_DEPENDENCY_P is FALSE, names are
looked up in dependent scopes. If CLASS_HEAD_P is TRUE, this class
- is the class being defined in a class-head.
+ is the class being defined in a class-head. If ENUM_OK is TRUE,
+ enum-names are also accepted.
Returns the TYPE_DECL representing the class. */
enum tag_types tag_type,
bool check_dependency_p,
bool class_head_p,
- bool is_declaration)
+ bool is_declaration,
+ bool enum_ok)
{
tree decl;
tree scope;
}
else if (TREE_CODE (decl) != TYPE_DECL
|| TREE_TYPE (decl) == error_mark_node
- || !MAYBE_CLASS_TYPE_P (TREE_TYPE (decl))
+ || !(MAYBE_CLASS_TYPE_P (TREE_TYPE (decl))
+ || (enum_ok && TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE))
/* In Objective-C 2.0, a classname followed by '.' starts a
dot-syntax expression, and it's not a type-name. */
|| (c_dialect_objc ()