diff options
author | Joseph Myers <joseph@codesourcery.com> | 2020-01-15 02:54:27 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2020-01-15 02:54:27 +0000 |
commit | e2346a33b05871fc065815d4cfd531dfa0195507 (patch) | |
tree | 68cb8ed2cb75abd6f81449339a0c2f4a11bb1684 /gcc/c/c-decl.c | |
parent | ab7c7b46c35ed1be68d4c020a2f20ee96f68b64b (diff) | |
download | gcc-e2346a33b05871fc065815d4cfd531dfa0195507.zip gcc-e2346a33b05871fc065815d4cfd531dfa0195507.tar.gz gcc-e2346a33b05871fc065815d4cfd531dfa0195507.tar.bz2 |
Fix setting of DECL_CONTEXT in pushdecl (PR c/93072).
Bug 93072 is a case where the C front end (a) wrongly interprets an
inline declaration at block scope as indicating that DECL_CONTEXT
should be set for an inline function and (b) this results in an ICE.
This is a regression resulting from a previous fix of mine for other
bugs involving such declarations being wrongly interpreted elsewhere
as nested function declarations. The fix is similar to the previous
fix: use TREE_PUBLIC instead of DECL_EXTERNAL in another place as the
relevant test to determine whether to set DECL_CONTEXT. (When a
variable reaches the code in question in pushdecl, the two are
equivalent.)
Bootstrapped with no regressions for x86_64-pc-linux-gnu.
PR c/93072
gcc/c:
* c-decl.c (pushdecl): Use TREE_PUBLIC, not DECL_EXTERNAL, to
determine whether to set DECL_CONTEXT.
gcc/testsuite:
* gcc.dg/inline-42.c, gcc.dg/inline-43.c: New tests.
Diffstat (limited to 'gcc/c/c-decl.c')
-rw-r--r-- | gcc/c/c-decl.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index fa834d9..8281af7 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -3048,7 +3048,7 @@ pushdecl (tree x) unless they have initializers (which generate code). */ if (current_function_decl && (!VAR_OR_FUNCTION_DECL_P (x) - || DECL_INITIAL (x) || !DECL_EXTERNAL (x))) + || DECL_INITIAL (x) || !TREE_PUBLIC (x))) DECL_CONTEXT (x) = current_function_decl; /* Anonymous decls are just inserted in the scope. */ |