aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gnat.dg/inline22.adb19
-rw-r--r--gcc/tree-inline.c15
2 files changed, 23 insertions, 11 deletions
diff --git a/gcc/testsuite/gnat.dg/inline22.adb b/gcc/testsuite/gnat.dg/inline22.adb
new file mode 100644
index 0000000..5812c2f
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/inline22.adb
@@ -0,0 +1,19 @@
+-- { dg-compile }
+
+procedure Inline22 (L, U : Integer) is
+
+ type Arr is array (Integer range L .. U) of Boolean;
+
+ function Get_Zero return Arr;
+ pragma Inline_Always (Get_Zero);
+
+ function Get_Zero return Arr is
+ begin
+ return (others => False);
+ end;
+
+ A : Arr;
+
+begin
+ A := Get_Zero;
+end;
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 5396131..05d1a25 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -4025,17 +4025,10 @@ inline_forbidden_p (tree fndecl)
wi.info = (void *) fndecl;
wi.pset = &visited_nodes;
- /* We cannot inline a function with a VLA typed argument or result since
- we have no implementation materializing a variable of such type in
- the caller. */
- if (COMPLETE_TYPE_P (TREE_TYPE (TREE_TYPE (fndecl)))
- && !poly_int_tree_p (TYPE_SIZE (TREE_TYPE (TREE_TYPE (fndecl)))))
- {
- inline_forbidden_reason
- = G_("function %q+F can never be inlined because "
- "it has a VLA return argument");
- return true;
- }
+ /* We cannot inline a function with a variable-sized parameter because we
+ cannot materialize a temporary of such a type in the caller if need be.
+ Note that the return case is not symmetrical because we can guarantee
+ that a temporary is not needed by means of CALL_EXPR_RETURN_SLOT_OPT. */
for (tree parm = DECL_ARGUMENTS (fndecl); parm; parm = DECL_CHAIN (parm))
if (!poly_int_tree_p (DECL_SIZE (parm)))
{