@@ -6752,49 +6752,39 @@ find_flexarrays (tree t, flexmems_t *fmem, bool base_p,
typedef struct { int i, a[], j; } S; // bug c++/72753
S s [2]; // bug c++/68489
*/
- bool anon_type_p
- = (TREE_CODE (fld) == TYPE_DECL
- && DECL_IMPLICIT_TYPEDEF_P (fld)
- && anon_aggrname_p (DECL_NAME (fld)));
+ if (TREE_CODE (fld) == TYPE_DECL
+ && DECL_IMPLICIT_TYPEDEF_P (fld)
+ && CLASS_TYPE_P (TREE_TYPE (fld))
+ && anon_aggrname_p (DECL_NAME (fld)))
+ {
+ /* Check the nested unnamed type referenced via a typedef
+ independently of FMEM (since it's not a data member of
+ the enclosing class). */
+ check_flexarrays (TREE_TYPE (fld));
+ continue;
+ }
/* Skip anything that's GCC-generated or not a (non-static) data
- member or typedef. */
- if ((DECL_ARTIFICIAL (fld) && !anon_type_p)
- || (TREE_CODE (fld) != FIELD_DECL && TREE_CODE (fld) != TYPE_DECL))
+ member. */
+ if (DECL_ARTIFICIAL (fld) || TREE_CODE (fld) != FIELD_DECL)
continue;
/* Type of the member. */
- tree fldtype = TREE_CODE (fld) == FIELD_DECL ? TREE_TYPE (fld) : fld;
+ tree fldtype = TREE_TYPE (fld);
if (fldtype == error_mark_node)
return;
/* Determine the type of the array element or object referenced
by the member so that it can be checked for flexible array
members if it hasn't been yet. */
- tree eltype = TREE_TYPE (fld);
- if (eltype == error_mark_node)
- return;
-
+ tree eltype = fldtype;
while (TREE_CODE (eltype) == ARRAY_TYPE
|| TREE_CODE (eltype) == POINTER_TYPE
|| TREE_CODE (eltype) == REFERENCE_TYPE)
eltype = TREE_TYPE (eltype);
- if (TREE_CODE (fld) == TYPE_DECL
- && TYPE_CANONICAL (eltype) == TYPE_CANONICAL (t))
- continue;
-
if (RECORD_OR_UNION_TYPE_P (eltype))
{
- if (anon_type_p)
- {
- /* Check the nested unnamed type referenced via a typedef
- independently of FMEM (since it's not a data member of
- the enclosing class). */
- check_flexarrays (eltype);
- continue;
- }
-
if (fmem->array && !fmem->after[bool (pun)])
{
/* Once the member after the flexible array has been found
@@ -6843,8 +6833,6 @@ find_flexarrays (tree t, flexmems_t *fmem, bool base_p,
if (base_p)
continue;
}
- else if (TREE_CODE (fld) == TYPE_DECL)
- continue;
}
if (field_nonempty_p (fld))