aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2006-08-25 23:01:16 +0000
committerJoseph Myers <joseph@codesourcery.com>2006-08-25 23:01:16 +0000
commita05ed1ef78be718ccc009942c4af387424c96d9e (patch)
tree6486b3e2d432444b8f03be5770b966b4e48e6344
parentdfc37df9861a83cb20d58d1e1c1d0a52b6204c2a (diff)
PR c/27893
* gimplify.c (gimplify_decl_expr, gimplify_init_ctor_preeval, omp_add_variable): Treat sizes as variable whenever not INTEGER_CST. testsuite: * gcc.c-torture/compile/vla-const-1.c, gcc.c-torture/compile/vla-const-2.c: New tests. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@116450 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/c-pretty-print.c4
-rw-r--r--gcc/gimplify.c8
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/vla-const-1.c5
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/vla-const-2.c4
6 files changed, 28 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c18b80e375e..ec1b234506a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2006-08-25 Joseph S. Myers <joseph@codesourcery.com>
+
+ PR c/27893
+ * gimplify.c (gimplify_decl_expr, gimplify_init_ctor_preeval,
+ omp_add_variable): Treat sizes as variable whenever not
+ INTEGER_CST.
+
2006-08-26 Richard Guenther <rguenther@suse.de>
PR middle-end/28814
diff --git a/gcc/c-pretty-print.c b/gcc/c-pretty-print.c
index 4f1dbbc00db..5225ea3dd96 100644
--- a/gcc/c-pretty-print.c
+++ b/gcc/c-pretty-print.c
@@ -528,8 +528,8 @@ pp_c_direct_abstract_declarator (c_pretty_printer *pp, tree t)
if (host_integerp (maxval, 0))
pp_wide_integer (pp, tree_low_cst (maxval, 0) + 1);
else
- pp_expression (pp, fold_build2 (PLUS_EXPR, type, maxval,
- build_int_cst (type, 1)));
+ pp_expression (pp, fold (build2 (PLUS_EXPR, type, maxval,
+ build_int_cst (type, 1))));
}
pp_c_right_bracket (pp);
pp_direct_abstract_declarator (pp, TREE_TYPE (t));
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index fd9e1e56157..cf48770c84f 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -1219,7 +1219,7 @@ gimplify_decl_expr (tree *stmt_p)
{
tree init = DECL_INITIAL (decl);
- if (!TREE_CONSTANT (DECL_SIZE (decl)))
+ if (TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST)
{
/* This is a variable-sized decl. Simplify its size and mark it
for deferred expansion. Note that mudflap depends on the format
@@ -2696,7 +2696,7 @@ gimplify_init_ctor_preeval (tree *expr_p, tree *pre_p, tree *post_p,
/* If this is of variable size, we have no choice but to assume it doesn't
overlap since we can't make a temporary for it. */
- if (!TREE_CONSTANT (TYPE_SIZE (TREE_TYPE (*expr_p))))
+ if (TREE_CODE (TYPE_SIZE (TREE_TYPE (*expr_p))) != INTEGER_CST)
return;
/* Otherwise, we must search for overlap ... */
@@ -4384,7 +4384,7 @@ omp_add_variable (struct gimplify_omp_ctx *ctx, tree decl, unsigned int flags)
/* When adding a variable-sized variable, we have to handle all sorts
of additional bits of data: the pointer replacement variable, and
the parameters of the type. */
- if (DECL_SIZE (decl) && !TREE_CONSTANT (DECL_SIZE (decl)))
+ if (DECL_SIZE (decl) && TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST)
{
/* Add the pointer replacement variable as PRIVATE if the variable
replacement is private, else FIRSTPRIVATE since we'll need the
@@ -4431,7 +4431,7 @@ omp_add_variable (struct gimplify_omp_ctx *ctx, tree decl, unsigned int flags)
if ((flags & GOVD_SHARED) == 0)
{
t = TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (decl)));
- if (!TREE_CONSTANT (t))
+ if (TREE_CODE (t) != INTEGER_CST)
omp_notice_variable (ctx, t, true);
}
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9194e7fb2a5..f74ad90653a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2006-08-25 Joseph S. Myers <joseph@codesourcery.com>
+
+ PR c/27893
+ * gcc.c-torture/compile/vla-const-1.c,
+ gcc.c-torture/compile/vla-const-2.c: New tests.
+
2006-08-26 Richard Guenther <rguenther@suse.de>
PR middle-end/28814
diff --git a/gcc/testsuite/gcc.c-torture/compile/vla-const-1.c b/gcc/testsuite/gcc.c-torture/compile/vla-const-1.c
new file mode 100644
index 00000000000..6acc3d83050
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/vla-const-1.c
@@ -0,0 +1,5 @@
+/* Test TREE_CONSTANT VLA size: bug 27893. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+int a;
+void g(void *);
+void f(void) { int b[(__SIZE_TYPE__)&a]; g(b); }
diff --git a/gcc/testsuite/gcc.c-torture/compile/vla-const-2.c b/gcc/testsuite/gcc.c-torture/compile/vla-const-2.c
new file mode 100644
index 00000000000..913a730b458
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/vla-const-2.c
@@ -0,0 +1,4 @@
+/* Test TREE_CONSTANT VLA size: bug 27893. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+void g(void *);
+void f(void) { int b[1/0]; g(b); }