aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-decl.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2009-02-04 00:59:21 +0000
committerJoseph Myers <jsm28@gcc.gnu.org>2009-02-04 00:59:21 +0000
commit062c4bb37ac6f2af6753060d8f8db5230bc18b49 (patch)
treee3c8d3d5d76924587be86ae6609bd1a94db4b04f /gcc/c-decl.c
parent244c6ba0d3f7121fa0ee163c028a3ba066945e45 (diff)
downloadgcc-062c4bb37ac6f2af6753060d8f8db5230bc18b49.zip
gcc-062c4bb37ac6f2af6753060d8f8db5230bc18b49.tar.gz
gcc-062c4bb37ac6f2af6753060d8f8db5230bc18b49.tar.bz2
re PR c/29129 ([DR#341] unnamed parameters using [*])
PR c/29129 * c-decl.c (grokdeclarator): Mark [*] arrays in field declarators as having variable size. Do not give an error for unnamed parameters with [*] declarators. Give a warning for type names with [*] declarators and mark them as variable size. * c-parser.c (c_parser_sizeof_expression): Do not give an error for sizeof applied to [*] type names. testsuite: * c90-arraydecl-1.c: Do not expect error for [*] in abstract declarator. * vla-6.c: Likewise. Expect warning not error for [*] lexically inside function prototype but not part of parameter declarator. * vla-11.c: New test. From-SVN: r143918
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r--gcc/c-decl.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 262d9d9..35a9c4b 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -4389,7 +4389,14 @@ grokdeclarator (const struct c_declarator *declarator,
}
else if (decl_context == FIELD)
{
- if (pedantic && !flag_isoc99 && !in_system_header)
+ if (array_parm_vla_unspec_p)
+ /* Field names can in fact have function prototype
+ scope so [*] is disallowed here through making
+ the field variably modified, not through being
+ something other than a declaration with function
+ prototype scope. */
+ size_varies = 1;
+ else if (pedantic && !flag_isoc99 && !in_system_header)
pedwarn (input_location, OPT_pedantic,
"ISO C90 does not support flexible array members");
@@ -4401,12 +4408,6 @@ grokdeclarator (const struct c_declarator *declarator,
{
if (array_parm_vla_unspec_p)
{
- if (! orig_name)
- {
- /* C99 6.7.5.2p4 */
- error ("%<[*]%> not allowed in other than a declaration");
- }
-
itype = build_range_type (sizetype, size_zero_node, NULL_TREE);
size_varies = 1;
}
@@ -4415,12 +4416,14 @@ grokdeclarator (const struct c_declarator *declarator,
{
if (array_parm_vla_unspec_p)
{
- /* The error is printed elsewhere. We use this to
- avoid messing up with incomplete array types of
- the same type, that would otherwise be modified
- below. */
+ /* C99 6.7.5.2p4 */
+ warning (0, "%<[*]%> not in a declaration");
+ /* We use this to avoid messing up with incomplete
+ array types of the same type, that would
+ otherwise be modified below. */
itype = build_range_type (sizetype, size_zero_node,
NULL_TREE);
+ size_varies = 1;
}
}