* 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
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.
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)
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
{
/* 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;
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))
#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. */
/* 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. */
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) \
}
/* 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
&& 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)
{
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);*/
}
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
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
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))
}
/* 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
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))
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)))
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))
{
{
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));
{
/* 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 ();
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))
tree memtype = TREE_TYPE (member);
if (memtype == type)
return index;
- else if (TYPE_ANONYMOUS_P (memtype))
+ else if (TYPE_UNNAMED_P (memtype))
++index;
}
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++)
return discriminator;
if (TYPE_CONTEXT (type) == ctx
&& (name ? TYPE_IDENTIFIER (type) == name
- : TYPE_ANONYMOUS_P (type)))
+ : TYPE_UNNAMED_P (type)))
++discriminator;
}
gcc_unreachable ();
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);
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)
/* 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;
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;
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 ();
/* 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);
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)
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 {
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);
/* 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));
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); ; )
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)));
// { 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" }
// 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 }
// 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; }
// { 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 } } }
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)
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 } */
}
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 } */
}