From b430e8d98964bc1866199ac6eb5faecdbd963be1 Mon Sep 17 00:00:00 2001 From: rguenth Date: Tue, 3 Mar 2009 13:05:53 +0000 Subject: 2009-03-03 Richard Guenther PR middle-end/39272 * tree.c (tree_nonartificial_location): New function. * tree.h (tree_nonartificial_location): Declare. * builtins.c (expand_builtin_memory_chk): Provide location of the call location for artificial function pieces. (maybe_emit_chk_warning): Likewise. (maybe_emit_sprintf_chk_warning): Likewise. (maybe_emit_free_warning): Likewise. * expr.c (expand_expr_real_1): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@144573 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'gcc/tree.c') diff --git a/gcc/tree.c b/gcc/tree.c index 423c8681cf2..d0117a0a4fe 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -9071,6 +9071,42 @@ block_nonartificial_location (tree block) return ret; } + +/* If EXP is inlined from an __attribute__((__artificial__)) + function, return the location of the original call expression. */ + +location_t +tree_nonartificial_location (tree exp) +{ + tree block = 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); +} + + /* These are the hash table functions for the hash table of OPTIMIZATION_NODEq nodes. */ -- cgit v1.2.1