This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[committed] Fix ICE in OpenMP array section handling (PR c/81006)


Hi!

Apparently TYPE_MAX_VALUE (TYPE_DOMAIN (type)) on some arrays doesn't
have expected sizetype type, but instead has ssizetype -1, which causes
the size_binop verification to ICE.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
committed to trunk, 7.x, 6.x and 5.x (on the last one with additional
xfail for the diagnostics - we only fix the ICE, but don't introduce
something we failed to diagnose).

2017-06-08  Jakub Jelinek  <jakub@redhat.com>

	PR c/81006
	* c-typeck.c (handle_omp_array_sections_1): Convert TYPE_MAX_VALUE
	to sizetype before size_binop.

	* semantics.c (handle_omp_array_sections_1): Convert TYPE_MAX_VALUE
	to sizetype before size_binop.

	* c-c++-common/gomp/pr81006.c: New test.

--- gcc/c/c-typeck.c.jj	2017-06-02 09:01:07.000000000 +0200
+++ gcc/c/c-typeck.c	2017-06-08 14:46:53.940730138 +0200
@@ -12362,9 +12362,9 @@ handle_omp_array_sections_1 (tree c, tre
 	  && TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
 			== INTEGER_CST)
 	{
-	  tree size = size_binop (PLUS_EXPR,
-				  TYPE_MAX_VALUE (TYPE_DOMAIN (type)),
-				  size_one_node);
+	  tree size
+	    = fold_convert (sizetype, TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
+	  size = size_binop (PLUS_EXPR, size, size_one_node);
 	  if (TREE_CODE (low_bound) == INTEGER_CST)
 	    {
 	      if (tree_int_cst_lt (size, low_bound))
--- gcc/cp/semantics.c.jj	2017-06-02 09:01:19.000000000 +0200
+++ gcc/cp/semantics.c	2017-06-08 14:40:34.141432913 +0200
@@ -4731,9 +4731,9 @@ handle_omp_array_sections_1 (tree c, tre
 	  && TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
 			== INTEGER_CST)
 	{
-	  tree size = size_binop (PLUS_EXPR,
-				  TYPE_MAX_VALUE (TYPE_DOMAIN (type)),
-				  size_one_node);
+	  tree size
+	    = fold_convert (sizetype, TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
+	  size = size_binop (PLUS_EXPR, size, size_one_node);
 	  if (TREE_CODE (low_bound) == INTEGER_CST)
 	    {
 	      if (tree_int_cst_lt (size, low_bound))
--- gcc/testsuite/c-c++-common/gomp/pr81006.c.jj	2017-06-08 14:50:15.195219648 +0200
+++ gcc/testsuite/c-c++-common/gomp/pr81006.c	2017-06-08 14:49:50.000000000 +0200
@@ -0,0 +1,10 @@
+/* PR c/81006 */
+/* { dg-do compile } */
+
+int a[] = {};
+
+void foo()
+{
+  #pragma omp task depend(out: a[:])	/* { dg-error "zero length array section in .depend. clause" } */
+    {}
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]