aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-decl.c
diff options
context:
space:
mode:
authorPaolo Bonzini <bonzini@gnu.org>2010-11-13 09:52:00 +0000
committerPaolo Bonzini <bonzini@gcc.gnu.org>2010-11-13 09:52:00 +0000
commit9e5b21156632fd14bfaeea24919c614e56645989 (patch)
treeeb7240972890ab86d11f88bf6522ea66910f938f /gcc/c-decl.c
parent18406601136a40c875005c3f11563f657fc1f0ca (diff)
downloadgcc-9e5b21156632fd14bfaeea24919c614e56645989.zip
gcc-9e5b21156632fd14bfaeea24919c614e56645989.tar.gz
gcc-9e5b21156632fd14bfaeea24919c614e56645989.tar.bz2
c-tree.h (enum c_typespec_kind): Add ctsk_none.
2010-11-13 Paolo Bonzini <bonzini@gnu.org> * c-tree.h (enum c_typespec_kind): Add ctsk_none. (struct c_declspecs): Replace tagdef_seen_p and type_seen_p with typespec_kind. * c-decl.c (build_null_declspecs): Initialize typespec_kind. (shadow_tag_warned, check_compound_literal_type): Adjust uses of tag_defined_p. (declspecs_add_type): Set typespec_kind. * c-parser.c (c_parser_declaration_or_fndef, c_parser_declspecs, c_parser_struct_declaration, c_parser_parameter_declaration, c_parser_type_name, c_parser_objc_diagnose_bad_element_prefix): Adjust uses of type_seen_p. * c-typeck.c (c_cast_expr): Use typespec_kind instead of tag_defined_p, pass ctsk_firstref through. testsuite: 2010-11-13 Paolo Bonzini <bonzini@gnu.org> * gcc.dg/Wcxx-compat-8.c: Add testcases involving incomplete types. From-SVN: r166699
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r--gcc/c-decl.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index e1f1402..c0d5a49 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -3634,7 +3634,8 @@ shadow_tag_warned (const struct c_declspecs *declspecs, int warned)
warned = 1;
}
}
- else if (!declspecs->tag_defined_p
+ else if (declspecs->typespec_kind != ctsk_tagdef
+ && declspecs->typespec_kind != ctsk_tagfirstref
&& declspecs->storage_class != csc_none)
{
if (warned != 1)
@@ -3644,7 +3645,8 @@ shadow_tag_warned (const struct c_declspecs *declspecs, int warned)
warned = 1;
pending_xref_error ();
}
- else if (!declspecs->tag_defined_p
+ else if (declspecs->typespec_kind != ctsk_tagdef
+ && declspecs->typespec_kind != ctsk_tagfirstref
&& (declspecs->const_p
|| declspecs->volatile_p
|| declspecs->restrict_p
@@ -4580,7 +4582,9 @@ build_compound_literal (location_t loc, tree type, tree init, bool non_const)
void
check_compound_literal_type (location_t loc, struct c_type_name *type_name)
{
- if (warn_cxx_compat && type_name->specs->tag_defined_p)
+ if (warn_cxx_compat
+ && (type_name->specs->typespec_kind == ctsk_tagdef
+ || type_name->specs->typespec_kind == ctsk_tagfirstref))
warning_at (loc, OPT_Wc___compat,
"defining a type in a compound literal is invalid in C++");
}
@@ -8616,10 +8620,9 @@ build_null_declspecs (void)
ret->storage_class = csc_none;
ret->expr_const_operands = true;
ret->declspecs_seen_p = false;
- ret->type_seen_p = false;
+ ret->typespec_kind = ctsk_none;
ret->non_sc_seen_p = false;
ret->typedef_p = false;
- ret->tag_defined_p = false;
ret->explicit_signed_p = false;
ret->deprecated_p = false;
ret->default_int_p = false;
@@ -8703,7 +8706,7 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs,
tree type = spec.spec;
specs->non_sc_seen_p = true;
specs->declspecs_seen_p = true;
- specs->type_seen_p = true;
+ specs->typespec_kind = spec.kind;
if (TREE_DEPRECATED (type))
specs->deprecated_p = true;
@@ -9306,8 +9309,6 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs,
}
else if (TREE_CODE (type) != ERROR_MARK)
{
- if (spec.kind == ctsk_tagdef || spec.kind == ctsk_tagfirstref)
- specs->tag_defined_p = true;
if (spec.kind == ctsk_typeof)
{
specs->typedef_p = true;