aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-decl.c
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2006-10-13 09:41:53 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2006-10-13 07:41:53 +0000
commit1a4259dca6f29ce22b34d346322529aa206eeac0 (patch)
tree9cf5e1fef9d79611e2bc7d2a99b097d464dfecda /gcc/c-decl.c
parentf19218e50496219b72a5c7ddb62fca4df8980343 (diff)
downloadgcc-1a4259dca6f29ce22b34d346322529aa206eeac0.zip
gcc-1a4259dca6f29ce22b34d346322529aa206eeac0.tar.gz
gcc-1a4259dca6f29ce22b34d346322529aa206eeac0.tar.bz2
re PR c/28419 (ICE using __FUNCTION__ in invalid code)
PR c/28419 * c-decl.c (c_make_fname_decl): Do not segfault in case where current_function_decl is set but current_function_scope is not. * gcc.dg/pr28319.c: New test. From-SVN: r117684
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r--gcc/c-decl.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 3897bea..4b3ee62 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -2791,7 +2791,16 @@ c_make_fname_decl (tree id, int type_dep)
TREE_USED (decl) = 1;
- if (current_function_decl)
+ if (current_function_decl
+ /* For invalid programs like this:
+
+ void foo()
+ const char* p = __FUNCTION__;
+
+ the __FUNCTION__ is believed to appear in K&R style function
+ parameter declarator. In that case we still don't have
+ function_scope. */
+ && (!errorcount || current_function_scope))
{
DECL_CONTEXT (decl) = current_function_decl;
bind (id, decl, current_function_scope,