aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-parser.c
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2006-05-18 18:22:12 +0000
committerMike Stump <mrs@gcc.gnu.org>2006-05-18 18:22:12 +0000
commit52ffd86eb62d0320ccf64138e5d7d37ab7a6f7c5 (patch)
tree3393aa88e335ad0c151ee642c9e17e8807ed52e9 /gcc/c-parser.c
parent4f9533c7722fa07511a94d005227961f4a4dec23 (diff)
downloadgcc-52ffd86eb62d0320ccf64138e5d7d37ab7a6f7c5.zip
gcc-52ffd86eb62d0320ccf64138e5d7d37ab7a6f7c5.tar.gz
gcc-52ffd86eb62d0320ccf64138e5d7d37ab7a6f7c5.tar.bz2
Fix up vla, vm and [*] sematics.
PR c/18740 PR c/7948 PR c/25802 * c-tree.h (struct c_arg_info): Add had_vla_unspec. (c_vla_unspec_p): Add. (c_vla_type_p): Add. * c-decl.c (struct c_scope): Add had_vla_unspec. (build_array_declarator): Add support for [*]. (grokdeclarator): Likewise. (grokparms): Likewise. (get_parm_info): Likewise. * c-objc-common.c (c_vla_unspec_p): Likewise. * c-objc-common.h (LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P): Likewise. * c-parser.c (c_parser_typeof_specifier): Evaluate arguments to typeof when argument is a variably modified type not inside sizeof or alignof. (c_parser_direct_declarator_inner): Propagate errors. (c_parser_sizeof_expression): Add support for [*]. * c-typeck.c (c_vla_type_p): Add. (composite_type): Add support for vla compositing. (comptypes_internal): Add support for vla compatibility. (c_expr_sizeof_expr): Evaluate vla arguments. * tree.c (variably_modified_type_p): Update comment for [*]. testsuite: * gcc.dg/c90-arraydecl-1.c: Update for vla, vm [*] fixups. * gcc.dg/vla-4.c: Add. * gcc.dg/vla-5.c: Add. * gcc.dg/vla-6.c: Add. From-SVN: r113888
Diffstat (limited to 'gcc/c-parser.c')
-rw-r--r--gcc/c-parser.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/gcc/c-parser.c b/gcc/c-parser.c
index 8f6cafd..5a67653 100644
--- a/gcc/c-parser.c
+++ b/gcc/c-parser.c
@@ -2148,6 +2148,7 @@ c_parser_typeof_specifier (c_parser *parser)
}
else
{
+ bool was_vm;
struct c_expr expr = c_parser_expression (parser);
skip_evaluation--;
in_typeof--;
@@ -2155,7 +2156,13 @@ c_parser_typeof_specifier (c_parser *parser)
&& DECL_C_BIT_FIELD (TREE_OPERAND (expr.value, 1)))
error ("%<typeof%> applied to a bit-field");
ret.spec = TREE_TYPE (expr.value);
- pop_maybe_used (variably_modified_type_p (ret.spec, NULL_TREE));
+ was_vm = variably_modified_type_p (ret.spec, NULL_TREE);
+ /* This should be returned with the type so that when the type
+ is evaluated, this can be evaluated. For now, we avoid
+ evaluation when the context might. */
+ if (!skip_evaluation && was_vm)
+ c_finish_expr_stmt (expr.value);
+ pop_maybe_used (was_vm);
}
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>");
return ret;
@@ -2451,6 +2458,8 @@ c_parser_direct_declarator_inner (c_parser *parser, bool id_present,
}
declarator = build_array_declarator (dimen, quals_attrs, static_seen,
star_seen);
+ if (declarator == NULL)
+ return NULL;
inner = set_array_declarator_inner (declarator, inner, !id_present);
return c_parser_direct_declarator_inner (parser, id_present, inner);
}
@@ -4868,6 +4877,12 @@ c_parser_sizeof_expression (c_parser *parser)
/* sizeof ( type-name ). */
skip_evaluation--;
in_sizeof--;
+ if (type_name->declarator->kind == cdk_array
+ && type_name->declarator->u.array.vla_unspec_p)
+ {
+ /* C99 6.7.5.2p4 */
+ error ("%<[*]%> not allowed in other than a declaration");
+ }
return c_expr_sizeof_type (type_name);
}
else