PR sanitizer/80659 46/190546/3
authormpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 17 May 2017 09:59:20 +0000 (09:59 +0000)
committerMikhail Kashkarov <m.kashkarov@partner.samsung.com>
Thu, 18 Oct 2018 13:20:10 +0000 (16:20 +0300)
  * 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.

Change-Id: I7565aba65e49836947e0faf2eb5ea668b46a0d87
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@248143138bc75d-0d04-0410-961f-82ee72b054a4

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

index 2b1f718..de88c93 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.
+
 2016-12-21  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/77767
index 7f9d882..93c11cc 100644 (file)
@@ -5091,6 +5091,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
@@ -5127,8 +5129,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 0cfd70f..fcfdf84 100644 (file)
        PR sanitizer/81111
        * g++.dg/ubsan/pr81111.C: New test.
 
+2017-05-17  Marek Polacek  <polacek@redhat.com>
+
+       PR sanitizer/80659
+       * gcc.dg/asan/pr80659.c: New test.
+
+
 2017-04-13  Denis Khalikov  <d.khalikov@partner.samsung.com>
 
         PR sanitizer/80414
diff --git a/testsuite/gcc.dg/asan/pr80659.c b/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;
+    }
+}