gnu: gcc: Fix 'gcc-strmov-store-file-names.patch'.

Fixes <https://bugs.gnu.org/31708>.

Previously GCC would crash when encountering a 'static const' element
without an initializer, as in:

  #define _GNU_SOURCE
  #include <string.h>

  void foo (char *x)
  {
    static const char buf[12];
    memcpy (x, buf, 12);
  }

* gnu/packages/patches/gcc-strmov-store-file-names.patch: Return false
when DECL_INITIAL returns NULL_TREE.
This commit is contained in:
Ludovic Courtès 2018-06-13 23:02:31 +02:00
parent 53411dfcd6
commit 243ea8673f
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 8 additions and 4 deletions

View File

@ -15,7 +15,7 @@ and <https://bugs.gnu.org/30395>.
--- gcc-5.3.0/gcc/builtins.c 2016-10-18 10:50:46.080616285 +0200
+++ gcc-5.3.0/gcc/builtins.c 2016-11-09 15:26:43.693042737 +0100
@@ -3192,6 +3192,54 @@ determine_block_size (tree len, rtx len_
@@ -3192,6 +3192,58 @@ determine_block_size (tree len, rtx len_
GET_MODE_MASK (GET_MODE (len_rtx)));
}
@ -35,9 +35,13 @@ and <https://bugs.gnu.org/30395>.
+ if (TREE_CODE (str) == VAR_DECL
+ && TREE_STATIC (str)
+ && TREE_READONLY (str))
+ {
+ /* STR may be a 'static const' variable whose initial value
+ is a string constant. See <https://bugs.gnu.org/30395>. */
+ str = DECL_INITIAL (str);
+ if (str == NULL_TREE)
+ return false;
+ }
+
+ if (TREE_CODE (str) != STRING_CST)
+ return false;