summaryrefslogtreecommitdiff
path: root/gcc/c/c-decl.c
diff options
context:
space:
mode:
authorprathamesh3492 <prathamesh3492@138bc75d-0d04-0410-961f-82ee72b054a4>2016-01-20 16:25:23 +0000
committerprathamesh3492 <prathamesh3492@138bc75d-0d04-0410-961f-82ee72b054a4>2016-01-20 16:25:23 +0000
commit16d4186faed46e54fc5960782c5d04d398894d25 (patch)
tree8f34e243e6c141a45fea0369c0d2d05d4e2954cf /gcc/c/c-decl.c
parente4e403abdf28a275edb94513bf799123fce35dd8 (diff)
downloadgcc-16d4186faed46e54fc5960782c5d04d398894d25.tar.gz
2016-01-15 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
PR c/24293 * c-tree.h (incomplete_record_decls): Declare. * c-parser.c (incomplete_record_decls): Define. (c_parser_translation_unit): Iterate through incomplete_record_decls and report error if any decl has zero size. * c-decl.c (finish_decl): Append static decl with incomplete struct/union or enum type to incomplete_record_decls. testsuite/ * gcc.dg/pr24293.c: New test. * gcc.dg/Wcxx-compat-8.c: Adjust to accept error due to incomplete struct type. * gcc.dg/declspec-1.c: Likewise. * gcc.dg/pr63549.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@232622 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c/c-decl.c')
-rw-r--r--gcc/c/c-decl.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index 5830e22a7fc..1ec60420db9 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -4791,6 +4791,12 @@ finish_decl (tree decl, location_t init_loc, tree init,
TREE_TYPE (decl) = error_mark_node;
}
+ if ((RECORD_OR_UNION_TYPE_P (TREE_TYPE (decl))
+ || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
+ && DECL_SIZE (decl) == NULL_TREE
+ && TREE_STATIC (decl))
+ incomplete_record_decls.safe_push (decl);
+
if (is_global_var (decl) && DECL_SIZE (decl) != 0)
{
if (TREE_CODE (DECL_SIZE (decl)) == INTEGER_CST)