diff options
author | Joseph Myers <joseph@codesourcery.com> | 2006-06-05 01:51:45 +0100 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2006-06-05 01:51:45 +0100 |
commit | 5c076987a461e1ae0e30d0d9e52aa4e1f15fb8a8 (patch) | |
tree | 8ee70774544831e67bf621351fbe7a811f974759 /gcc/c-decl.c | |
parent | 1ac8104c2f17d63ea8272c358c0cf3650b66532e (diff) | |
download | gcc-5c076987a461e1ae0e30d0d9e52aa4e1f15fb8a8.zip gcc-5c076987a461e1ae0e30d0d9e52aa4e1f15fb8a8.tar.gz gcc-5c076987a461e1ae0e30d0d9e52aa4e1f15fb8a8.tar.bz2 |
re PR c/25161 (Internal compiler error (segfault) instead of error message)
PR c/25161
PR c/27020
* c-decl.c (grokdeclarator): Disallow variably modified types at
file scope. Avoid marking shared array type of constant size as
VLA.
testsuite:
* gcc.dg/array-10.c: New test.
From-SVN: r114378
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r-- | gcc/c-decl.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index ddf068a..22b6dab 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -3936,6 +3936,14 @@ grokdeclarator (const struct c_declarator *declarator, if (declspecs->deprecated_p && deprecated_state != DEPRECATED_SUPPRESS) warn_deprecated_use (declspecs->type); + if ((decl_context == NORMAL || decl_context == FIELD) + && current_scope == file_scope + && variably_modified_type_p (type, NULL_TREE)) + { + error ("variably modified %qs at file scope", name); + type = integer_type_node; + } + typedef_type = type; size_varies = C_TYPE_VARIABLE_SIZE (type); @@ -4206,6 +4214,12 @@ grokdeclarator (const struct c_declarator *declarator, size = integer_one_node; } } + else if ((decl_context == NORMAL || decl_context == FIELD) + && current_scope == file_scope) + { + error ("variably modified %qs at file scope", name); + size = integer_one_node; + } else { /* Make sure the array size remains visibly @@ -4304,7 +4318,12 @@ grokdeclarator (const struct c_declarator *declarator, if (type != error_mark_node) { if (size_varies) - C_TYPE_VARIABLE_SIZE (type) = 1; + { + if (size && TREE_CODE (size) == INTEGER_CST) + type + = build_distinct_type_copy (TYPE_MAIN_VARIANT (type)); + C_TYPE_VARIABLE_SIZE (type) = 1; + } /* The GCC extension for zero-length arrays differs from ISO flexible array members in that sizeof yields |