public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] Fix ICE in OpenMP array section handling (PR c/81006)
@ 2017-06-08 19:26 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2017-06-08 19:26 UTC (permalink / raw)
  To: gcc-patches

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-06-08 19:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-08 19:26 [committed] Fix ICE in OpenMP array section handling (PR c/81006) Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).