diff options
author | DJ Delorie <dj@redhat.com> | 2001-10-08 15:44:53 -0400 |
---|---|---|
committer | DJ Delorie <dj@gcc.gnu.org> | 2001-10-08 15:44:53 -0400 |
commit | 3e96a2fd0c33ebf78db50bf040624b7cbf8f86b6 (patch) | |
tree | 57957d9b9f531e9eefc55ddc7c9826a3fc7e0004 /gcc/c-decl.c | |
parent | 1dde5a4edc74e724f3881ad730a7db116e34ecc4 (diff) | |
download | gcc-3e96a2fd0c33ebf78db50bf040624b7cbf8f86b6.zip gcc-3e96a2fd0c33ebf78db50bf040624b7cbf8f86b6.tar.gz gcc-3e96a2fd0c33ebf78db50bf040624b7cbf8f86b6.tar.bz2 |
c-decl.c (grokfield): Make sure the only unnamed fields we're allowing are either structs or unions.
* c-decl.c (grokfield): Make sure the only unnamed fields
we're allowing are either structs or unions.
* doc/extend.texi: Add documentation for the unnamed field
extension.
From-SVN: r46088
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r-- | gcc/c-decl.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 4ec34ea..d167ddf 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -5392,6 +5392,18 @@ grokfield (filename, line, declarator, declspecs, width) { tree value; + if (declarator == NULL_TREE && width == NULL_TREE) + { + /* This is an unnamed decl. We only support unnamed + structs/unions, so check for other things and refuse them. */ + if (TREE_CODE (TREE_VALUE (declspecs)) != RECORD_TYPE + && TREE_CODE (TREE_VALUE (declspecs)) != UNION_TYPE) + { + error ("unnamed fields of type other than struct or union are not allowed"); + return NULL_TREE; + } + } + value = grokdeclarator (declarator, declspecs, width ? BITFIELD : FIELD, 0); finish_decl (value, NULL_TREE, NULL_TREE); |