gcc/gcc43-pr35751.patch
Jakub Jelinek 08a0a12f84 4.3.0-6
2008-04-04 12:50:28 +00:00

115 lines
2.6 KiB
Diff

2008-04-03 Jakub Jelinek <jakub@redhat.com>
PR c/35751
* c-decl.c (finish_decl): If extern or static var has variable
size, set TREE_TYPE (decl) to error_mark_node.
* decl.c (layout_var_decl): If extern or static var has variable
size, set TREE_TYPE (decl) to error_mark_node.
* gcc.dg/gomp/pr35751.c: New test.
* g++.dg/gomp/pr35751.C: New test.
--- gcc/c-decl.c.jj 2008-04-03 09:41:42.000000000 +0200
+++ gcc/c-decl.c 2008-04-03 18:20:52.000000000 +0200
@@ -3481,7 +3481,10 @@ finish_decl (tree decl, tree init, tree
if (TREE_CODE (DECL_SIZE (decl)) == INTEGER_CST)
constant_expression_warning (DECL_SIZE (decl));
else
- error ("storage size of %q+D isn%'t constant", decl);
+ {
+ error ("storage size of %q+D isn%'t constant", decl);
+ TREE_TYPE (decl) = error_mark_node;
+ }
}
if (TREE_USED (type))
--- gcc/cp/decl.c.jj 2008-03-31 23:54:40.000000000 +0200
+++ gcc/cp/decl.c 2008-04-03 18:30:19.000000000 +0200
@@ -4442,7 +4442,10 @@ layout_var_decl (tree decl)
if (TREE_CODE (DECL_SIZE (decl)) == INTEGER_CST)
constant_expression_warning (DECL_SIZE (decl));
else
- error ("storage size of %qD isn't constant", decl);
+ {
+ error ("storage size of %qD isn't constant", decl);
+ TREE_TYPE (decl) = error_mark_node;
+ }
}
}
--- gcc/testsuite/gcc.dg/gomp/pr35751.c.jj 2008-04-03 18:26:12.000000000 +0200
+++ gcc/testsuite/gcc.dg/gomp/pr35751.c 2008-04-03 18:25:51.000000000 +0200
@@ -0,0 +1,34 @@
+/* PR c/35751 */
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+void
+foo (int i)
+{
+ extern int a[i]; /* { dg-error "must have no linkage|storage size of" } */
+ static int b[i]; /* { dg-error "storage size of" } */
+
+#pragma omp parallel
+ {
+ a[0] = 0;
+ b[0] = 0;
+ }
+
+#pragma omp parallel shared (a, b)
+ {
+ a[0] = 0;
+ b[0] = 0;
+ }
+
+#pragma omp parallel private (a, b)
+ {
+ a[0] = 0;
+ b[0] = 0;
+ }
+
+#pragma omp parallel firstprivate (a, b)
+ {
+ a[0] = 0;
+ b[0] = 0;
+ }
+}
--- gcc/testsuite/g++.dg/gomp/pr35751.C.jj 2008-04-03 18:32:13.000000000 +0200
+++ gcc/testsuite/g++.dg/gomp/pr35751.C 2008-04-03 18:32:32.000000000 +0200
@@ -0,0 +1,34 @@
+// PR c/35751
+// { dg-do compile }
+// { dg-options "-fopenmp" }
+
+void
+foo (int i)
+{
+ extern int a[i]; // { dg-error "storage size of" }
+ static int b[i]; // { dg-error "storage size of" }
+
+#pragma omp parallel
+ {
+ a[0] = 0;
+ b[0] = 0;
+ }
+
+#pragma omp parallel shared (a, b)
+ {
+ a[0] = 0;
+ b[0] = 0;
+ }
+
+#pragma omp parallel private (a, b)
+ {
+ a[0] = 0;
+ b[0] = 0;
+ }
+
+#pragma omp parallel firstprivate (a, b)
+ {
+ a[0] = 0;
+ b[0] = 0;
+ }
+}