From 3e00ba47b932a13b57061b2d2c95c768ab811d1b Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 20 Nov 2019 07:33:19 +0000 Subject: re PR c/92088 (aggregates with VLAs and nested functions are broken) 2019-11-20 Richard Biener PR c/92088 c/ * c-decl.c (grokdeclarator): Prevent inlining of nested function with VLA arguments. * builtins.c (compute_objsize): Deal with VLAs. * gcc.dg/torture/pr92088-1.c: New testcase. * gcc.dg/torture/pr92088-2.c: Likewise. From-SVN: r278477 --- gcc/c/ChangeLog | 6 ++++++ gcc/c/c-decl.c | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 3f42e40..7b37842 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2019-11-20 Richard Biener + + PR c/92088 + * c-decl.c (grokdeclarator): Prevent inlining of nested + function with VLA arguments. + 2019-11-20 Joseph Myers * c-decl.c (c_warn_type_attributes): New function. diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index d153de2..caa9c85 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -7405,6 +7405,23 @@ grokdeclarator (const struct c_declarator *declarator, "no linkage"); } + /* For nested functions disqualify ones taking VLAs by value + from inlining since the middle-end cannot deal with this. + ??? We should arrange for those to be passed by reference + with emitting the copy on the caller side in the frontend. */ + if (storage_class == csc_none + && TREE_CODE (type) == FUNCTION_TYPE) + for (tree al = TYPE_ARG_TYPES (type); al; al = TREE_CHAIN (al)) + { + tree arg = TREE_VALUE (al); + if (arg != error_mark_node + && C_TYPE_VARIABLE_SIZE (arg)) + { + DECL_UNINLINABLE (decl) = 1; + break; + } + } + /* Record `register' declaration for warnings on & and in case doing stupid register allocation. */ -- cgit v1.1