Commit 3e636daf by Marek Polacek Committed by Marek Polacek

c-decl.c: Use RECORD_OR_UNION_TYPE_P throughout.

	* c-decl.c: Use RECORD_OR_UNION_TYPE_P throughout.
	* c-typeck.c: Likewise.

From-SVN: r230375
parent 9bd6766d
2015-11-14 Marek Polacek <polacek@redhat.com>
* c-decl.c: Use RECORD_OR_UNION_TYPE_P throughout.
* c-typeck.c: Likewise.
2015-11-13 David Malcolm <dmalcolm@redhat.com> 2015-11-13 David Malcolm <dmalcolm@redhat.com>
* c-decl.c (warn_defaults_to): Pass line_table to * c-decl.c (warn_defaults_to): Pass line_table to
......
...@@ -3048,8 +3048,7 @@ pushdecl (tree x) ...@@ -3048,8 +3048,7 @@ pushdecl (tree x)
element = TREE_TYPE (element); element = TREE_TYPE (element);
element = TYPE_MAIN_VARIANT (element); element = TYPE_MAIN_VARIANT (element);
if ((TREE_CODE (element) == RECORD_TYPE if (RECORD_OR_UNION_TYPE_P (element)
|| TREE_CODE (element) == UNION_TYPE)
&& (TREE_CODE (x) != TYPE_DECL && (TREE_CODE (x) != TYPE_DECL
|| TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE) || TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE)
&& !COMPLETE_TYPE_P (element)) && !COMPLETE_TYPE_P (element))
...@@ -4643,8 +4642,7 @@ diagnose_uninitialized_cst_member (tree decl, tree type) ...@@ -4643,8 +4642,7 @@ diagnose_uninitialized_cst_member (tree decl, tree type)
inform (DECL_SOURCE_LOCATION (field), "%qD should be initialized", field); inform (DECL_SOURCE_LOCATION (field), "%qD should be initialized", field);
} }
if (TREE_CODE (field_type) == RECORD_TYPE if (RECORD_OR_UNION_TYPE_P (field_type))
|| TREE_CODE (field_type) == UNION_TYPE)
diagnose_uninitialized_cst_member (decl, field_type); diagnose_uninitialized_cst_member (decl, field_type);
} }
} }
...@@ -4966,8 +4964,7 @@ finish_decl (tree decl, location_t init_loc, tree init, ...@@ -4966,8 +4964,7 @@ finish_decl (tree decl, location_t init_loc, tree init,
if (TREE_READONLY (decl)) if (TREE_READONLY (decl))
warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat, warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat,
"uninitialized const %qD is invalid in C++", decl); "uninitialized const %qD is invalid in C++", decl);
else if ((TREE_CODE (type) == RECORD_TYPE else if (RECORD_OR_UNION_TYPE_P (type)
|| TREE_CODE (type) == UNION_TYPE)
&& C_TYPE_FIELDS_READONLY (type)) && C_TYPE_FIELDS_READONLY (type))
diagnose_uninitialized_cst_member (decl, type); diagnose_uninitialized_cst_member (decl, type);
} }
...@@ -6726,8 +6723,7 @@ grokdeclarator (const struct c_declarator *declarator, ...@@ -6726,8 +6723,7 @@ grokdeclarator (const struct c_declarator *declarator,
&& VAR_P (decl) && VAR_P (decl)
&& TREE_PUBLIC (decl) && TREE_PUBLIC (decl)
&& TREE_STATIC (decl) && TREE_STATIC (decl)
&& (TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE && (RECORD_OR_UNION_TYPE_P (TREE_TYPE (decl))
|| TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE
|| TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE) || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
&& TYPE_NAME (TREE_TYPE (decl)) == NULL_TREE) && TYPE_NAME (TREE_TYPE (decl)) == NULL_TREE)
warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat, warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat,
...@@ -7282,8 +7278,7 @@ grokfield (location_t loc, ...@@ -7282,8 +7278,7 @@ grokfield (location_t loc,
that took root before someone noticed the bug... */ that took root before someone noticed the bug... */
tree type = declspecs->type; tree type = declspecs->type;
bool type_ok = (TREE_CODE (type) == RECORD_TYPE bool type_ok = RECORD_OR_UNION_TYPE_P (type);
|| TREE_CODE (type) == UNION_TYPE);
bool ok = false; bool ok = false;
if (type_ok if (type_ok
...@@ -7359,7 +7354,7 @@ is_duplicate_field (tree x, tree y) ...@@ -7359,7 +7354,7 @@ is_duplicate_field (tree x, tree y)
xt = TREE_TYPE (x); xt = TREE_TYPE (x);
if (DECL_NAME (x) != NULL_TREE) if (DECL_NAME (x) != NULL_TREE)
xn = DECL_NAME (x); xn = DECL_NAME (x);
else if ((TREE_CODE (xt) == RECORD_TYPE || TREE_CODE (xt) == UNION_TYPE) else if (RECORD_OR_UNION_TYPE_P (xt)
&& TYPE_NAME (xt) != NULL_TREE && TYPE_NAME (xt) != NULL_TREE
&& TREE_CODE (TYPE_NAME (xt)) == TYPE_DECL) && TREE_CODE (TYPE_NAME (xt)) == TYPE_DECL)
xn = DECL_NAME (TYPE_NAME (xt)); xn = DECL_NAME (TYPE_NAME (xt));
...@@ -7369,7 +7364,7 @@ is_duplicate_field (tree x, tree y) ...@@ -7369,7 +7364,7 @@ is_duplicate_field (tree x, tree y)
yt = TREE_TYPE (y); yt = TREE_TYPE (y);
if (DECL_NAME (y) != NULL_TREE) if (DECL_NAME (y) != NULL_TREE)
yn = DECL_NAME (y); yn = DECL_NAME (y);
else if ((TREE_CODE (yt) == RECORD_TYPE || TREE_CODE (yt) == UNION_TYPE) else if (RECORD_OR_UNION_TYPE_P (yt)
&& TYPE_NAME (yt) != NULL_TREE && TYPE_NAME (yt) != NULL_TREE
&& TREE_CODE (TYPE_NAME (yt)) == TYPE_DECL) && TREE_CODE (TYPE_NAME (yt)) == TYPE_DECL)
yn = DECL_NAME (TYPE_NAME (yt)); yn = DECL_NAME (TYPE_NAME (yt));
...@@ -7404,8 +7399,7 @@ detect_field_duplicates_hash (tree fieldlist, ...@@ -7404,8 +7399,7 @@ detect_field_duplicates_hash (tree fieldlist,
} }
*slot = y; *slot = y;
} }
else if (TREE_CODE (TREE_TYPE (x)) == RECORD_TYPE else if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (x)))
|| TREE_CODE (TREE_TYPE (x)) == UNION_TYPE)
{ {
detect_field_duplicates_hash (TYPE_FIELDS (TREE_TYPE (x)), htab); detect_field_duplicates_hash (TYPE_FIELDS (TREE_TYPE (x)), htab);
...@@ -7456,8 +7450,7 @@ detect_field_duplicates (tree fieldlist) ...@@ -7456,8 +7450,7 @@ detect_field_duplicates (tree fieldlist)
do { do {
timeout--; timeout--;
if (DECL_NAME (x) == NULL_TREE if (DECL_NAME (x) == NULL_TREE
&& (TREE_CODE (TREE_TYPE (x)) == RECORD_TYPE && RECORD_OR_UNION_TYPE_P (TREE_TYPE (x)))
|| TREE_CODE (TREE_TYPE (x)) == UNION_TYPE))
timeout = 0; timeout = 0;
x = DECL_CHAIN (x); x = DECL_CHAIN (x);
} while (timeout > 0 && x); } while (timeout > 0 && x);
...@@ -7473,8 +7466,7 @@ detect_field_duplicates (tree fieldlist) ...@@ -7473,8 +7466,7 @@ detect_field_duplicates (tree fieldlist)
if (DECL_NAME (x) if (DECL_NAME (x)
|| (flag_plan9_extensions || (flag_plan9_extensions
&& DECL_NAME (x) == NULL_TREE && DECL_NAME (x) == NULL_TREE
&& (TREE_CODE (TREE_TYPE (x)) == RECORD_TYPE && RECORD_OR_UNION_TYPE_P (TREE_TYPE (x))
|| TREE_CODE (TREE_TYPE (x)) == UNION_TYPE)
&& TYPE_NAME (TREE_TYPE (x)) != NULL_TREE && TYPE_NAME (TREE_TYPE (x)) != NULL_TREE
&& TREE_CODE (TYPE_NAME (TREE_TYPE (x))) == TYPE_DECL)) && TREE_CODE (TYPE_NAME (TREE_TYPE (x))) == TYPE_DECL))
{ {
...@@ -7587,9 +7579,7 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes, ...@@ -7587,9 +7579,7 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
{ {
if (DECL_NAME (x) != 0) if (DECL_NAME (x) != 0)
break; break;
if (flag_isoc11 if (flag_isoc11 && RECORD_OR_UNION_TYPE_P (TREE_TYPE (x)))
&& (TREE_CODE (TREE_TYPE (x)) == RECORD_TYPE
|| TREE_CODE (TREE_TYPE (x)) == UNION_TYPE))
break; break;
} }
...@@ -7634,8 +7624,7 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes, ...@@ -7634,8 +7624,7 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
{ {
/* A field that is pseudo-const makes the structure likewise. */ /* A field that is pseudo-const makes the structure likewise. */
tree t1 = strip_array_types (TREE_TYPE (x)); tree t1 = strip_array_types (TREE_TYPE (x));
if ((TREE_CODE (t1) == RECORD_TYPE || TREE_CODE (t1) == UNION_TYPE) if (RECORD_OR_UNION_TYPE_P (t1) && C_TYPE_FIELDS_READONLY (t1))
&& C_TYPE_FIELDS_READONLY (t1))
C_TYPE_FIELDS_READONLY (t) = 1; C_TYPE_FIELDS_READONLY (t) = 1;
} }
...@@ -7693,8 +7682,7 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes, ...@@ -7693,8 +7682,7 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
"invalid use of structure with flexible array member"); "invalid use of structure with flexible array member");
if (DECL_NAME (x) if (DECL_NAME (x)
|| TREE_CODE (TREE_TYPE (x)) == RECORD_TYPE || RECORD_OR_UNION_TYPE_P (TREE_TYPE (x)))
|| TREE_CODE (TREE_TYPE (x)) == UNION_TYPE)
saw_named_field = 1; saw_named_field = 1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment