]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Bail out rather than crashing in array_type_nelts if TYPE_MAX_VALUE is null.
authorDuncan Sands <baldrick@free.fr>
Sat, 9 Apr 2011 16:21:20 +0000 (18:21 +0200)
committerDuncan Sands <baldrick@gcc.gnu.org>
Sat, 9 Apr 2011 16:21:20 +0000 (16:21 +0000)
From-SVN: r172228

gcc/ChangeLog
gcc/tree.c

index b8d07e93ccf22ffd4705d4808236fb83ec9e5db4..fb4d53ff174cdf614549a5e452f05fcce1a2c8d2 100644 (file)
@@ -1,3 +1,7 @@
+2011-04-09  Duncan Sands  <baldrick@free.fr>
+
+       * tree.c (array_type_nelts): Bail out if TYPE_MAX_VALUE not set.
+
 2011-04-07  Uros Bizjak  <ubizjak@gmail.com>
 
        * config/i386/sse.md (avx_cmps<ssemodesuffixf2c><mode>3): Add
index 4b1bfac42ae9c4256e882584e1e6b9ebc2bc56a9..7bf2e3e086b4468db6cc6185ca46efad6b7281df 100644 (file)
@@ -2337,6 +2337,10 @@ array_type_nelts (const_tree type)
   min = TYPE_MIN_VALUE (index_type);
   max = TYPE_MAX_VALUE (index_type);
 
+  /* TYPE_MAX_VALUE may not be set if the array has unknown length.  */
+  if (!max)
+    return error_mark_node;
+
   return (integer_zerop (min)
          ? max
          : fold_build2 (MINUS_EXPR, TREE_TYPE (max), max, min));