re PR sanitizer/80659 (-fsanitize=address evokes ICE in in gimplify_switch_expr)
authorMarek Polacek <polacek@redhat.com>
Wed, 17 May 2017 09:59:20 +0000 (09:59 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Wed, 17 May 2017 09:59:20 +0000 (09:59 +0000)
PR sanitizer/80659
* c-decl.c (build_compound_literal): Set DECL_ARTIFICIAL and
DECL_IGNORED_P even for non-static compound literals.

* gcc.dg/asan/pr80659.c: New test.

From-SVN: r248143

gcc/c/ChangeLog
gcc/c/c-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/asan/pr80659.c [new file with mode: 0644]

index e0c1e9933c4f9fc71910b9be89ab6475bbe43ca7..6862b536dc67d557f3ea7c0ec1568da4accdbc9a 100644 (file)
@@ -1,3 +1,9 @@
+2017-05-17  Marek Polacek  <polacek@redhat.com>
+
+       PR sanitizer/80659
+       * c-decl.c (build_compound_literal): Set DECL_ARTIFICIAL and
+       DECL_IGNORED_P even for non-static compound literals.
+
 2017-05-17  Martin Liska  <mliska@suse.cz>
 
        * c-decl.c (c_parse_final_cleanups): Introduce dump_flags_t type and
index 5b4bb4946c64a9afb72a7a0ef57798cf68e52909..bd6c4c1c9e05ca84df3ee45a09f2c6aba04cc602 100644 (file)
@@ -5261,6 +5261,8 @@ build_compound_literal (location_t loc, tree type, tree init, bool non_const)
   DECL_CONTEXT (decl) = current_function_decl;
   TREE_USED (decl) = 1;
   DECL_READ_P (decl) = 1;
+  DECL_ARTIFICIAL (decl) = 1;
+  DECL_IGNORED_P (decl) = 1;
   TREE_TYPE (decl) = type;
   TREE_READONLY (decl) = (TYPE_READONLY (type)
                          || (TREE_CODE (type) == ARRAY_TYPE
@@ -5297,8 +5299,6 @@ build_compound_literal (location_t loc, tree type, tree init, bool non_const)
       set_compound_literal_name (decl);
       DECL_DEFER_OUTPUT (decl) = 1;
       DECL_COMDAT (decl) = 1;
-      DECL_ARTIFICIAL (decl) = 1;
-      DECL_IGNORED_P (decl) = 1;
       pushdecl (decl);
       rest_of_decl_compilation (decl, 1, 0);
     }
index c4f76871aee7c5e164b6f566c257cf491554881b..44f5841c74a1c8254e3a4d6b0ea451b3ec61cc56 100644 (file)
@@ -1,3 +1,8 @@
+2017-05-17  Marek Polacek  <polacek@redhat.com>
+
+       PR sanitizer/80659
+       * gcc.dg/asan/pr80659.c: New test.
+
 2017-05-17  Senthil Kumar Selvaraj  <senthil_kumar.selvaraj@atmel.com>
 
        * gcc.dg/tree-ssa/pr78886.c: Use __SIZE_TYPE__ instead of
diff --git a/gcc/testsuite/gcc.dg/asan/pr80659.c b/gcc/testsuite/gcc.dg/asan/pr80659.c
new file mode 100644 (file)
index 0000000..0cbf2e4
--- /dev/null
@@ -0,0 +1,13 @@
+/* PR sanitizer/80659 */
+/* { dg-do compile } */
+
+void
+foo (int a)
+{
+  switch (a)
+    {
+    case 0:
+      (int[3]) { };
+      int h;
+    }
+}