diff options
author | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-10-13 07:41:53 +0000 |
---|---|---|
committer | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-10-13 07:41:53 +0000 |
commit | c902ba74ea5fa3bb0fd6785e77faa9ed82bbe48a (patch) | |
tree | 9cf5e1fef9d79611e2bc7d2a99b097d464dfecda /gcc/c-decl.c | |
parent | 79c835c9e5dc1f8a317ffde69517dbbde42163b2 (diff) | |
download | ppe42-gcc-c902ba74ea5fa3bb0fd6785e77faa9ed82bbe48a.tar.gz ppe42-gcc-c902ba74ea5fa3bb0fd6785e77faa9ed82bbe48a.zip |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@117684 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r-- | gcc/c-decl.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 3897bea36b6..4b3ee627cec 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, |