aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2019-11-20 07:33:19 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2019-11-20 07:33:19 +0000
commit3e00ba47b932a13b57061b2d2c95c768ab811d1b (patch)
treebb2b932e36924ca3737f2da2a580c0a839e4b93a /gcc/c
parent54bf2539c55b886ea60d407a7ef2f56f0a19e861 (diff)
downloadgcc-3e00ba47b932a13b57061b2d2c95c768ab811d1b.zip
gcc-3e00ba47b932a13b57061b2d2c95c768ab811d1b.tar.gz
gcc-3e00ba47b932a13b57061b2d2c95c768ab811d1b.tar.bz2
re PR c/92088 (aggregates with VLAs and nested functions are broken)
2019-11-20 Richard Biener <rguenther@suse.de> 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
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/ChangeLog6
-rw-r--r--gcc/c/c-decl.c17
2 files changed, 23 insertions, 0 deletions
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 <rguenther@suse.de>
+
+ PR c/92088
+ * c-decl.c (grokdeclarator): Prevent inlining of nested
+ function with VLA arguments.
+
2019-11-20 Joseph Myers <joseph@codesourcery.com>
* 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. */