From e2cd7f1b65dcf4eae695360c87fd4dd6159d54ca Mon Sep 17 00:00:00 2001 From: mpolacek Date: Wed, 17 May 2017 09:59:20 +0000 Subject: 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. Change-Id: I7565aba65e49836947e0faf2eb5ea668b46a0d87 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@248143138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/c/ChangeLog | 6 ++++++ gcc/c/c-decl.c | 4 ++-- gcc/testsuite/ChangeLog | 6 ++++++ testsuite/gcc.dg/asan/pr80659.c | 13 +++++++++++++ 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 testsuite/gcc.dg/asan/pr80659.c diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 2b1f71855ad..de88c936df5 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2017-05-17 Marek Polacek + + 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 PR c/77767 diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 7f9d8825bd8..93c11cc53f6 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -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); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0cfd70fbfa3..fcfdf8437d7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -19,6 +19,12 @@ PR sanitizer/81111 * g++.dg/ubsan/pr81111.C: New test. +2017-05-17 Marek Polacek + + PR sanitizer/80659 + * gcc.dg/asan/pr80659.c: New test. + + 2017-04-13 Denis Khalikov PR sanitizer/80414 diff --git a/testsuite/gcc.dg/asan/pr80659.c b/testsuite/gcc.dg/asan/pr80659.c new file mode 100644 index 00000000000..0cbf2e498f7 --- /dev/null +++ b/testsuite/gcc.dg/asan/pr80659.c @@ -0,0 +1,13 @@ +/* PR sanitizer/80659 */ +/* { dg-do compile } */ + +void +foo (int a) +{ + switch (a) + { + case 0: + (int[3]) { }; + int h; + } +} -- cgit v1.2.3