aboutsummaryrefslogtreecommitdiff
path: root/gcc/c/c-decl.c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2015-02-14 11:25:19 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2015-02-14 11:25:19 +0000
commit065d214ce4129853330cb0c992b981830c950909 (patch)
tree577ba5fb4fedac8f082c3b7d52e8e3fe27c2e462 /gcc/c/c-decl.c
parent952e216e5a092b5072894b3889f18bc5f76dcf72 (diff)
downloadgcc-065d214ce4129853330cb0c992b981830c950909.zip
gcc-065d214ce4129853330cb0c992b981830c950909.tar.gz
gcc-065d214ce4129853330cb0c992b981830c950909.tar.bz2
re PR c/64768 (internal compiler error: tree check: expected tree that contains ‘decl with RTL’ structure, have ‘field_decl’ in set_decl_rtl, at emit-rtl.c:1274)
PR c/64768 * c-decl.c (grokdeclarator): Set the range of a flexible array member declared through a typedef name. * gcc.dg/array-11.c: New test. * gcc.dg/array-12.c: New test. * gcc.dg/array-13.c: New test. * gcc.dg/array-14.c: New test. * gcc.dg/c99-flex-array-typedef-1.c: New test. * gcc.dg/c99-flex-array-typedef-2.c: New test. * gcc.dg/c99-flex-array-typedef-3.c: New test. * gcc.dg/c99-flex-array-typedef-5.c: New test. * gcc.dg/c99-flex-array-typedef-7.c: New test. * gcc.dg/c99-flex-array-typedef-8.c: New test. From-SVN: r220708
Diffstat (limited to 'gcc/c/c-decl.c')
-rw-r--r--gcc/c/c-decl.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index 4fd3239..8eeee9c 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -6515,6 +6515,19 @@ grokdeclarator (const struct c_declarator *declarator,
error_at (loc, "unnamed field has incomplete type");
type = error_mark_node;
}
+ else if (TREE_CODE (type) == ARRAY_TYPE
+ && TYPE_DOMAIN (type) == NULL_TREE)
+ {
+ /* We have a flexible array member through a typedef.
+ Set suitable range. Whether this is a correct position
+ for a flexible array member will be determined elsewhere. */
+ if (!in_system_header_at (input_location))
+ pedwarn_c90 (loc, OPT_Wpedantic, "ISO C90 does not "
+ "support flexible array members");
+ type = build_distinct_type_copy (TYPE_MAIN_VARIANT (type));
+ TYPE_DOMAIN (type) = build_range_type (sizetype, size_zero_node,
+ NULL_TREE);
+ }
type = c_build_qualified_type (type, type_quals);
decl = build_decl (declarator->id_loc,
FIELD_DECL, declarator->u.id, type);