mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-14 01:50:35 +08:00
re PR middle-end/40340 (Fortification warning no longer emitted in inlines)
PR middle-end/40340 * tree-ssa-live.c (remove_unused_scope_block_p): Don't prune inlined_function_outer_scope_p blocks for artificial inlines even at -g0/-g1. * tree.c (tree_nonartificial_location): Rewrite using block_nonartificial_location. * gcc.dg/pr40340-1.c: New test. * gcc.dg/pr40340-2.c: New test. * gcc.dg/pr40340-3.c: New test. * gcc.dg/pr40340-4.c: New test. * gcc.dg/pr40340-5.c: New test. * gcc.dg/pr40340.h: New file. From-SVN: r148212
This commit is contained in:
parent
8f439681a9
commit
9f706f23d1
@ -1,3 +1,19 @@
|
||||
2009-06-05 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR middle-end/40340
|
||||
* tree-ssa-live.c (remove_unused_scope_block_p): Don't prune
|
||||
inlined_function_outer_scope_p blocks for artificial inlines
|
||||
even at -g0/-g1.
|
||||
* tree.c (tree_nonartificial_location): Rewrite using
|
||||
block_nonartificial_location.
|
||||
|
||||
* gcc.dg/pr40340-1.c: New test.
|
||||
* gcc.dg/pr40340-2.c: New test.
|
||||
* gcc.dg/pr40340-3.c: New test.
|
||||
* gcc.dg/pr40340-4.c: New test.
|
||||
* gcc.dg/pr40340-5.c: New test.
|
||||
* gcc.dg/pr40340.h: New file.
|
||||
|
||||
2009-06-05 Revital Eres <eres@il.ibm.com>
|
||||
Leehod Baruch <leehod@il.ibm.com>
|
||||
|
||||
@ -21,7 +37,7 @@
|
||||
* dwarf2out.c (dwarf2out_begin_function): Mark discriminator
|
||||
as possibly unused.
|
||||
|
||||
2009-06-04 Jakub Jelinek <jakub@redhat.com>
|
||||
2009-06-05 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
* config/s390/s390.c (global_not_special_regno_p): New static inline.
|
||||
(save_gprs): Don't tell unwinder when a global register is saved.
|
||||
|
24
gcc/testsuite/gcc.dg/pr40340-1.c
Normal file
24
gcc/testsuite/gcc.dg/pr40340-1.c
Normal file
@ -0,0 +1,24 @@
|
||||
/* PR middle-end/40340 */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2 -Wall -Wno-system-headers" } */
|
||||
|
||||
#include "pr40340.h"
|
||||
|
||||
static inline
|
||||
__attribute__ ((always_inline))
|
||||
void
|
||||
test (char *p)
|
||||
{
|
||||
memset (p, 0, 6);
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
char buf[4];
|
||||
test (buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* { dg-warning "will always overflow destination buffer" "" { target *-*-* } 10 } */
|
||||
/* { dg-message "file included" "In file included" { target *-*-* } 0 } */
|
16
gcc/testsuite/gcc.dg/pr40340-2.c
Normal file
16
gcc/testsuite/gcc.dg/pr40340-2.c
Normal file
@ -0,0 +1,16 @@
|
||||
/* PR middle-end/40340 */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2 -Wall -Wno-system-headers" } */
|
||||
|
||||
#include "pr40340.h"
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
char buf[4];
|
||||
memset (buf, 0, 6);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* { dg-warning "will always overflow destination buffer" "" { target *-*-* } 10 } */
|
||||
/* { dg-message "file included" "In file included" { target *-*-* } 0 } */
|
15
gcc/testsuite/gcc.dg/pr40340-3.c
Normal file
15
gcc/testsuite/gcc.dg/pr40340-3.c
Normal file
@ -0,0 +1,15 @@
|
||||
/* PR middle-end/40340 */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2 -Wall -Wno-system-headers" } */
|
||||
|
||||
#define TEST2
|
||||
#include "pr40340.h"
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
test2 ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* { dg-bogus "will always overflow destination buffer" "" { target *-*-* } 10 } */
|
16
gcc/testsuite/gcc.dg/pr40340-4.c
Normal file
16
gcc/testsuite/gcc.dg/pr40340-4.c
Normal file
@ -0,0 +1,16 @@
|
||||
/* PR middle-end/40340 */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2 -Wall -Wno-system-headers -g" } */
|
||||
|
||||
#define TEST3
|
||||
#include "pr40340.h"
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
char buf[4];
|
||||
test3 (buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* { dg-bogus "will always overflow destination buffer" "" { target *-*-* } 10 } */
|
17
gcc/testsuite/gcc.dg/pr40340-5.c
Normal file
17
gcc/testsuite/gcc.dg/pr40340-5.c
Normal file
@ -0,0 +1,17 @@
|
||||
/* PR middle-end/40340 */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2 -Wall -Wsystem-headers -g" } */
|
||||
|
||||
#define TEST3
|
||||
#include "pr40340.h"
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
char buf[4];
|
||||
test3 (buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* { dg-warning "will always overflow destination buffer" "" { target *-*-* } 10 } */
|
||||
/* { dg-message "file included" "In file included" { target *-*-* } 0 } */
|
31
gcc/testsuite/gcc.dg/pr40340.h
Normal file
31
gcc/testsuite/gcc.dg/pr40340.h
Normal file
@ -0,0 +1,31 @@
|
||||
#pragma GCC system_header
|
||||
typedef __SIZE_TYPE__ size_t;
|
||||
extern void *memset (void *s, int c, size_t n)
|
||||
__attribute__ ((nothrow, nonnull (1)));
|
||||
extern inline
|
||||
__attribute__ ((always_inline, artificial, gnu_inline, nothrow))
|
||||
void *
|
||||
memset (void *dest, int ch, size_t len)
|
||||
{
|
||||
return __builtin___memset_chk (dest, ch, len,
|
||||
__builtin_object_size (dest, 0));
|
||||
}
|
||||
|
||||
#ifdef TEST2
|
||||
static void
|
||||
__attribute__ ((noinline))
|
||||
test2 (void)
|
||||
{
|
||||
char buf[4];
|
||||
memset (buf, 0, 6);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TEST3
|
||||
static inline void
|
||||
__attribute__ ((always_inline))
|
||||
test3 (char *p)
|
||||
{
|
||||
memset (p, 0, 6);
|
||||
}
|
||||
#endif
|
@ -536,7 +536,25 @@ remove_unused_scope_block_p (tree scope)
|
||||
/* For terse debug info we can eliminate info on unused variables. */
|
||||
else if (debug_info_level == DINFO_LEVEL_NONE
|
||||
|| debug_info_level == DINFO_LEVEL_TERSE)
|
||||
;
|
||||
{
|
||||
/* Even for -g0/-g1 don't prune outer scopes from artificial
|
||||
functions, otherwise diagnostics using tree_nonartificial_location
|
||||
will not be emitted properly. */
|
||||
if (inlined_function_outer_scope_p (scope))
|
||||
{
|
||||
tree ao = scope;
|
||||
|
||||
while (ao
|
||||
&& TREE_CODE (ao) == BLOCK
|
||||
&& BLOCK_ABSTRACT_ORIGIN (ao) != ao)
|
||||
ao = BLOCK_ABSTRACT_ORIGIN (ao);
|
||||
if (ao
|
||||
&& TREE_CODE (ao) == FUNCTION_DECL
|
||||
&& DECL_DECLARED_INLINE_P (ao)
|
||||
&& lookup_attribute ("artificial", DECL_ATTRIBUTES (ao)))
|
||||
unused = false;
|
||||
}
|
||||
}
|
||||
else if (BLOCK_VARS (scope) || BLOCK_NUM_NONLOCALIZED_VARS (scope))
|
||||
unused = false;
|
||||
/* See if this block is important for representation of inlined function.
|
||||
|
30
gcc/tree.c
30
gcc/tree.c
@ -9224,32 +9224,12 @@ block_nonartificial_location (tree block)
|
||||
location_t
|
||||
tree_nonartificial_location (tree exp)
|
||||
{
|
||||
tree block = TREE_BLOCK (exp);
|
||||
location_t *loc = block_nonartificial_location (TREE_BLOCK (exp));
|
||||
|
||||
while (block
|
||||
&& TREE_CODE (block) == BLOCK
|
||||
&& BLOCK_ABSTRACT_ORIGIN (block))
|
||||
{
|
||||
tree ao = BLOCK_ABSTRACT_ORIGIN (block);
|
||||
|
||||
do
|
||||
{
|
||||
if (TREE_CODE (ao) == FUNCTION_DECL
|
||||
&& DECL_DECLARED_INLINE_P (ao)
|
||||
&& lookup_attribute ("artificial", DECL_ATTRIBUTES (ao)))
|
||||
return BLOCK_SOURCE_LOCATION (block);
|
||||
else if (TREE_CODE (ao) == BLOCK
|
||||
&& BLOCK_SUPERCONTEXT (ao) != ao)
|
||||
ao = BLOCK_SUPERCONTEXT (ao);
|
||||
else
|
||||
break;
|
||||
}
|
||||
while (ao);
|
||||
|
||||
block = BLOCK_SUPERCONTEXT (block);
|
||||
}
|
||||
|
||||
return EXPR_LOCATION (exp);
|
||||
if (loc)
|
||||
return *loc;
|
||||
else
|
||||
return EXPR_LOCATION (exp);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user