Rename TYPE_ANONYMOUS_P to TYPE_UNNAMED_P.

* cp-tree.h (TYPE_UNNAMED_P): Rename from TYPE_ANONYMOUS_P.
	(TYPE_WAS_UNNAMED): Rename from TYPE_WAS_ANONYMOUS.
	* class.c, decl.c, decl2.c, error.c, lambda.c, mangle.c,
	name-lookup.c, parser.c, pt.c, semantics.c, tree.c: Adjust.

From-SVN: r239137
This commit is contained in:
Jason Merrill 2016-08-04 12:06:17 -04:00 committed by Jason Merrill
parent 99676625e6
commit 6a7b92036b
21 changed files with 60 additions and 54 deletions

View File

@ -1,5 +1,10 @@
2016-08-04 Jason Merrill <jason@redhat.com>
* cp-tree.h (TYPE_UNNAMED_P): Rename from TYPE_ANONYMOUS_P.
(TYPE_WAS_UNNAMED): Rename from TYPE_WAS_ANONYMOUS.
* class.c, decl.c, decl2.c, error.c, lambda.c, mangle.c,
name-lookup.c, parser.c, pt.c, semantics.c, tree.c: Adjust.
PR c++/72796
* typeck.c (finish_class_member_access_expr): Avoid stripping
SCOPE_REF to dependent base.

View File

@ -3077,11 +3077,11 @@ finish_struct_anon_r (tree field, bool complain)
the TYPE_DECL that we create implicitly. You're
allowed to put one anonymous union inside another,
though, so we explicitly tolerate that. We use
TYPE_ANONYMOUS_P rather than ANON_AGGR_TYPE_P so that
TYPE_UNNAMED_P rather than ANON_AGGR_TYPE_P so that
we also allow unnamed types used for defining fields. */
if (DECL_ARTIFICIAL (elt)
&& (!DECL_IMPLICIT_TYPEDEF_P (elt)
|| TYPE_ANONYMOUS_P (TREE_TYPE (elt))))
|| TYPE_UNNAMED_P (TREE_TYPE (elt))))
continue;
if (TREE_CODE (elt) != FIELD_DECL)
@ -6718,7 +6718,7 @@ find_flexarrays (tree t, flexmems_t *fmem)
tree fldtype = TREE_TYPE (fld);
if (TREE_CODE (fld) != TYPE_DECL
&& RECORD_OR_UNION_TYPE_P (fldtype)
&& TYPE_ANONYMOUS_P (fldtype))
&& TYPE_UNNAMED_P (fldtype))
{
/* Members of anonymous structs and unions are treated as if
they were members of the containing class. Descend into
@ -6798,7 +6798,7 @@ diagnose_flexarrays (tree t, const flexmems_t *fmem)
{
/* Members of anonymous structs and unions are considered to be members
of the containing struct or union. */
if (TYPE_ANONYMOUS_P (t) || !fmem->array)
if (TYPE_UNNAMED_P (t) || !fmem->array)
return;
const char *msg = 0;

View File

@ -761,7 +761,7 @@ struct GTY (()) tree_trait_expr {
enum cp_trait_kind kind;
};
/* Based off of TYPE_ANONYMOUS_P. */
/* Based off of TYPE_UNNAMED_P. */
#define LAMBDA_TYPE_P(NODE) \
(CLASS_TYPE_P (NODE) && CLASSTYPE_LAMBDA_EXPR (NODE))
@ -1553,7 +1553,7 @@ enum languages { lang_c, lang_cplusplus, lang_java };
#define TYPE_NAME_LENGTH(NODE) (IDENTIFIER_LENGTH (TYPE_IDENTIFIER (NODE)))
/* Nonzero if NODE has no name for linkage purposes. */
#define TYPE_ANONYMOUS_P(NODE) \
#define TYPE_UNNAMED_P(NODE) \
(OVERLOAD_TYPE_P (NODE) && anon_aggrname_p (TYPE_LINKAGE_IDENTIFIER (NODE)))
/* The _DECL for this _TYPE. */
@ -4116,7 +4116,8 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
/* Define fields and accessors for nodes representing declared names. */
#define TYPE_WAS_ANONYMOUS(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->was_anonymous)
/* Nonzero if TYPE is an unnamed class with a typedef for linkage purposes. */
#define TYPE_WAS_UNNAMED(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->was_anonymous)
/* C++: all of these are overloaded! These apply only to TYPE_DECLs. */
@ -4270,8 +4271,8 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
equivalent to `struct S {}; typedef struct S S;' in C.
DECL_IMPLICIT_TYPEDEF_P will hold for the typedef indicated in this
example. In C++, there is a second implicit typedef for each
class, in the scope of `S' itself, so that you can say `S::S'.
DECL_SELF_REFERENCE_P will hold for that second typedef. */
class, called the injected-class-name, in the scope of `S' itself, so that
you can say `S::S'. DECL_SELF_REFERENCE_P will hold for that typedef. */
#define DECL_IMPLICIT_TYPEDEF_P(NODE) \
(TREE_CODE (NODE) == TYPE_DECL && DECL_LANG_FLAG_2 (NODE))
#define SET_DECL_IMPLICIT_TYPEDEF_P(NODE) \

View File

@ -4614,7 +4614,7 @@ check_tag_decl (cp_decl_specifier_seq *declspecs,
}
/* Check for an anonymous union. */
else if (declared_type && RECORD_OR_UNION_CODE_P (TREE_CODE (declared_type))
&& TYPE_ANONYMOUS_P (declared_type))
&& TYPE_UNNAMED_P (declared_type))
{
/* 7/3 In a simple-declaration, the optional init-declarator-list
can be omitted only when declaring a class (clause 9) or
@ -10773,7 +10773,7 @@ grokdeclarator (const cp_declarator *declarator,
&& unqualified_id
&& TYPE_NAME (type)
&& TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
&& TYPE_ANONYMOUS_P (type)
&& TYPE_UNNAMED_P (type)
&& declspecs->type_definition_p
&& attributes_naming_typedef_ok (*attrlist)
&& cp_type_quals (type) == TYPE_UNQUALIFIED)
@ -10785,7 +10785,7 @@ grokdeclarator (const cp_declarator *declarator,
{
if (anon_aggrname_p (TYPE_IDENTIFIER (t)))
/* We do not rename the debug info representing the
anonymous tagged type because the standard says in
unnamed tagged type because the standard says in
[dcl.typedef] that the naming applies only for
linkage purposes. */
/*debug_hooks->set_name (t, decl);*/
@ -10793,7 +10793,7 @@ grokdeclarator (const cp_declarator *declarator,
}
if (TYPE_LANG_SPECIFIC (type))
TYPE_WAS_ANONYMOUS (type) = 1;
TYPE_WAS_UNNAMED (type) = 1;
/* If this is a typedef within a template class, the nested
type is a (non-primary) template. The name for the
@ -10802,7 +10802,7 @@ grokdeclarator (const cp_declarator *declarator,
DECL_NAME (CLASSTYPE_TI_TEMPLATE (type))
= TYPE_IDENTIFIER (type);
/* Adjust linkage now that we aren't anonymous anymore. */
/* Adjust linkage now that we aren't unnamed anymore. */
reset_type_linkage (type);
/* FIXME remangle member functions; member functions of a

View File

@ -838,7 +838,7 @@ finish_static_data_member_decl (tree decl,
else
for (tree t = current_class_type; TYPE_P (t);
t = CP_TYPE_CONTEXT (t))
if (TYPE_ANONYMOUS_P (t))
if (TYPE_UNNAMED_P (t))
{
if (permerror (DECL_SOURCE_LOCATION (decl),
"static data member %qD in unnamed class", decl))
@ -1306,7 +1306,7 @@ save_template_attributes (tree *attr_p, tree *decl_p)
}
/* Return true iff ATTRS are acceptable attributes to be applied in-place
to a typedef which gives a previously anonymous class or enum a name for
to a typedef which gives a previously unnamed class or enum a name for
linkage purposes. */
bool
@ -4257,12 +4257,12 @@ no_linkage_error (tree decl)
else if (CLASS_TYPE_P (t) && TYPE_BEING_DEFINED (t))
/* The type might end up having a typedef name for linkage purposes. */
vec_safe_push (no_linkage_decls, decl);
else if (TYPE_ANONYMOUS_P (t))
else if (TYPE_UNNAMED_P (t))
{
bool d = false;
if (cxx_dialect >= cxx11)
d = permerror (DECL_SOURCE_LOCATION (decl), "%q#D, declared using "
"anonymous type, is used but never defined", decl);
"unnamed type, is used but never defined", decl);
else if (DECL_EXTERN_C_P (decl))
/* Allow this; it's pretty common in C. */;
else if (VAR_P (decl))
@ -4270,11 +4270,11 @@ no_linkage_error (tree decl)
no linkage can only be used to declare extern "C"
entities. Since it's not always an error in the
ISO C++ 90 Standard, we only issue a warning. */
d = warning_at (DECL_SOURCE_LOCATION (decl), 0, "anonymous type "
d = warning_at (DECL_SOURCE_LOCATION (decl), 0, "unnamed type "
"with no linkage used to declare variable %q#D with "
"linkage", decl);
else
d = permerror (DECL_SOURCE_LOCATION (decl), "anonymous type with no "
d = permerror (DECL_SOURCE_LOCATION (decl), "unnamed type with no "
"linkage used to declare function %q#D with linkage",
decl);
if (d && is_typedef_decl (TYPE_NAME (t)))

View File

@ -679,9 +679,9 @@ dump_aggr_type (cxx_pretty_printer *pp, tree t, int flags)
if (name == 0 || anon_aggrname_p (name))
{
if (flags & TFF_CLASS_KEY_OR_ENUM)
pp_string (pp, M_("<anonymous>"));
pp_string (pp, M_("<unnamed>"));
else
pp_printf (pp, M_("<anonymous %s>"), variety);
pp_printf (pp, M_("<unnamed %s>"), variety);
}
else if (LAMBDA_TYPE_P (t))
{
@ -1745,7 +1745,7 @@ dump_function_name (cxx_pretty_printer *pp, tree t, int flags)
{
if (LAMBDA_TYPE_P (DECL_CONTEXT (t)))
name = get_identifier ("<lambda>");
else if (TYPE_ANONYMOUS_P (DECL_CONTEXT (t)))
else if (TYPE_UNNAMED_P (DECL_CONTEXT (t)))
name = get_identifier ("<constructor>");
else
name = constructor_name (DECL_CONTEXT (t));

View File

@ -134,7 +134,7 @@ begin_lambda_type (tree lambda)
{
/* Unique name. This is just like an unnamed class, but we cannot use
make_anon_name because of certain checks against TYPE_ANONYMOUS_P. */
make_anon_name because of certain checks against TYPE_UNNAMED_P. */
tree name;
name = make_lambda_name ();

View File

@ -1320,7 +1320,7 @@ write_unqualified_name (tree decl)
tree type = TREE_TYPE (decl);
if (TREE_CODE (decl) == TYPE_DECL
&& TYPE_ANONYMOUS_P (type))
&& TYPE_UNNAMED_P (type))
write_unnamed_type_name (type);
else if (TREE_CODE (decl) == TYPE_DECL
&& LAMBDA_TYPE_P (type))
@ -1449,7 +1449,7 @@ nested_anon_class_index (tree type)
tree memtype = TREE_TYPE (member);
if (memtype == type)
return index;
else if (TYPE_ANONYMOUS_P (memtype))
else if (TYPE_UNNAMED_P (memtype))
++index;
}
@ -1734,7 +1734,7 @@ static int
local_class_index (tree entity)
{
int ix, discriminator = 0;
tree name = (TYPE_ANONYMOUS_P (entity) ? NULL_TREE
tree name = (TYPE_UNNAMED_P (entity) ? NULL_TREE
: TYPE_IDENTIFIER (entity));
tree ctx = TYPE_CONTEXT (entity);
for (ix = 0; ; ix++)
@ -1744,7 +1744,7 @@ local_class_index (tree entity)
return discriminator;
if (TYPE_CONTEXT (type) == ctx
&& (name ? TYPE_IDENTIFIER (type) == name
: TYPE_ANONYMOUS_P (type)))
: TYPE_UNNAMED_P (type)))
++discriminator;
}
gcc_unreachable ();
@ -1772,7 +1772,7 @@ discriminator_for_local_entity (tree entity)
entity = TREE_TYPE (entity);
/* Lambdas and unnamed types have their own discriminators. */
if (LAMBDA_TYPE_P (entity) || TYPE_ANONYMOUS_P (entity))
if (LAMBDA_TYPE_P (entity) || TYPE_UNNAMED_P (entity))
return 0;
return local_class_index (entity);

View File

@ -2089,7 +2089,7 @@ constructor_name_p (tree name, tree type)
static GTY(()) int anon_cnt;
/* Return an IDENTIFIER which can be used as a name for
anonymous structs and unions. */
unnamed structs and unions. */
tree
make_anon_name (void)
@ -2103,7 +2103,7 @@ make_anon_name (void)
/* This code is practically identical to that for creating
anonymous names, but is just used for lambdas instead. This isn't really
necessary, but it's convenient to avoid treating lambdas like other
anonymous types. */
unnamed types. */
static GTY(()) int lambda_cnt = 0;

View File

@ -17043,7 +17043,7 @@ cp_parser_enum_specifier (cp_parser* parser)
bool nested_being_defined = false;
bool new_value_list = false;
bool is_new_type = false;
bool is_anonymous = false;
bool is_unnamed = false;
tree underlying_type = NULL_TREE;
cp_token *type_start_token = NULL;
bool saved_colon_corrects_to_scope_p = parser->colon_corrects_to_scope_p;
@ -17137,10 +17137,10 @@ cp_parser_enum_specifier (cp_parser* parser)
else
{
identifier = make_anon_name ();
is_anonymous = true;
is_unnamed = true;
if (scoped_enum_p)
error_at (type_start_token->location,
"anonymous scoped enum is not allowed");
"unnamed scoped enum is not allowed");
}
}
pop_deferring_access_checks ();
@ -17321,9 +17321,9 @@ cp_parser_enum_specifier (cp_parser* parser)
/* If the next token is not '}', then there are some enumerators. */
else if (cp_lexer_next_token_is (parser->lexer, CPP_CLOSE_BRACE))
{
if (is_anonymous && !scoped_enum_p)
if (is_unnamed && !scoped_enum_p)
pedwarn (type_start_token->location, OPT_Wpedantic,
"ISO C++ forbids empty anonymous enum");
"ISO C++ forbids empty unnamed enum");
}
else
cp_parser_enumerator_list (parser, type);
@ -17341,7 +17341,7 @@ cp_parser_enum_specifier (cp_parser* parser)
and additional restrictions apply. */
if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON))
{
if (is_anonymous)
if (is_unnamed)
error_at (type_start_token->location,
"opaque-enum-specifier without name");
else if (nested_name_specifier)
@ -19347,9 +19347,9 @@ cp_parser_direct_declarator (cp_parser* parser,
else if (IDENTIFIER_TYPENAME_P (unqualified_name))
sfk = sfk_conversion;
else if (/* There's no way to declare a constructor
for an anonymous type, even if the type
for an unnamed type, even if the type
got a name for linkage purposes. */
!TYPE_WAS_ANONYMOUS (class_type)
!TYPE_WAS_UNNAMED (class_type)
/* Handle correctly (c++/19200):
struct S {

View File

@ -17340,8 +17340,8 @@ check_instantiated_arg (tree tmpl, tree t, tsubst_flags_t complain)
type deduction to fail. */
if (complain & tf_error)
{
if (TYPE_ANONYMOUS_P (nt))
error ("%qT is/uses anonymous type", t);
if (TYPE_UNNAMED_P (nt))
error ("%qT is/uses unnamed type", t);
else
error ("template argument for %qD uses local type %qT",
tmpl, t);

View File

@ -2916,7 +2916,7 @@ begin_class_definition (tree t)
/* Reset the interface data, at the earliest possible
moment, as it might have been set via a class foo;
before. */
if (! TYPE_ANONYMOUS_P (t))
if (! TYPE_UNNAMED_P (t))
{
struct c_fileinfo *finfo = \
get_fileinfo (LOCATION_FILE (input_location));

View File

@ -2353,9 +2353,9 @@ no_linkage_check (tree t, bool relaxed_p)
return NULL_TREE;
/* Fall through. */
case ENUMERAL_TYPE:
/* Only treat anonymous types as having no linkage if they're at
/* Only treat unnamed types as having no linkage if they're at
namespace scope. This is core issue 966. */
if (TYPE_ANONYMOUS_P (t) && TYPE_NAMESPACE_SCOPE_P (t))
if (TYPE_UNNAMED_P (t) && TYPE_NAMESPACE_SCOPE_P (t))
return t;
for (r = CP_TYPE_CONTEXT (t); ; )

View File

@ -553,7 +553,7 @@ encode_aggregate_within (tree type, int curtype, int format, int left,
args as a composite struct tag name. */
if (name && TREE_CODE (name) == IDENTIFIER_NODE
/* Did this struct have a tag? */
&& !TYPE_WAS_ANONYMOUS (type))
&& !TYPE_WAS_UNNAMED (type))
obstack_grow (&util_obstack,
decl_as_string (type, TFF_DECL_SPECIFIERS | TFF_UNQUALIFIED_NAME),
strlen (decl_as_string (type, TFF_DECL_SPECIFIERS | TFF_UNQUALIFIED_NAME)));

View File

@ -2,8 +2,8 @@
// { dg-do compile { target c++11 } }
// { dg-options "-pedantic" }
enum {}; // { dg-warning "empty anonymous" }
enum {}; // { dg-warning "empty unnamed" }
enum class {}; // { dg-error "anonymous" }
enum class {}; // { dg-error "unnamed" }
enum class { x }; // { dg-error "anonymous" }
enum class { x }; // { dg-error "unnamed" }

View File

@ -1,5 +1,5 @@
// PR c++/14401
struct { struct { int& i ; } bar ; } foo ; // { dg-error "deleted|uninitialized" "uninit" }
// { dg-warning "anonymous" "anon" { target { ! c++11 } } 3 }
// { dg-warning "unnamed" "anon" { target { ! c++11 } } 3 }
// { dg-message "should be initialized" "ref-uninit" { target { ! c++11 } } 3 }

View File

@ -4,6 +4,6 @@
// Make sure we issue a diagnostic if a type with no linkage is used
// to declare a a variable that has linkage.
struct { int i; } a; // { dg-warning "anonymous type" }
struct { int i; } a; // { dg-warning "unnamed type" }
void foo() { a.i; }

View File

@ -4,4 +4,4 @@
// { dg-do compile }
enum { a = 3 } x; // { dg-warning "anonymous type" "" { target { ! c++11 } } }
enum { a = 3 } x; // { dg-warning "unnamed type" "" { target { ! c++11 } } }

View File

@ -59,7 +59,7 @@ struct has_anon
int test7 (struct has_anon *ptr)
{
return ptr->s.colour; /* { dg-error "'struct has_anon::<anonymous>' has no member named 'colour'; did you mean 'color'?" } */
return ptr->s.colour; /* { dg-error "'struct has_anon::<unnamed>' has no member named 'colour'; did you mean 'color'?" } */
}
int test8 (foo &ref)

View File

@ -68,7 +68,7 @@ int func2(S1 *p)
p->u1.field5 = g1 + p->field7;
p->u2.field9; /* { dg-warning "'S1::u2' is deprecated: Please avoid u2" "" } */
return p->u1.field6 + p->field8; /* { dg-warning "'S1::<anonymous union>::field6' is deprecated: Please avoid field6" "" } */
return p->u1.field6 + p->field8; /* { dg-warning "'S1::<unnamed union>::field6' is deprecated: Please avoid field6" "" } */
/* { dg-warning "'S1::field8' is deprecated: Please avoid field8" "field8" { target *-*-* } 71 } */
}

View File

@ -70,7 +70,7 @@ int func2(S1 *p)
p->u1.field5 = g1 + p->field7;
p->u2.field9; /* { dg-warning "'S1::u2' is deprecated" "" } */
return p->u1.field6 + p->field8; /* { dg-warning "'S1::<anonymous union>::field6' is deprecated" "" } */
return p->u1.field6 + p->field8; /* { dg-warning "'S1::<unnamed union>::field6' is deprecated" "" } */
/* { dg-warning "'S1::field8' is deprecated" "field8" { target *-*-* } 73 } */
}