diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2016-01-18 10:27:10 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2016-01-18 10:27:10 +0000 |
commit | ae5a77fa960564c8a5b2a00c22b38d954aecddb8 (patch) | |
tree | 5486d174dcc6cd9fdc4fe4ff7c111e83870f9c3f /gcc | |
parent | 11e57fc6e53d1072c1da6e3e661716f47fa5d859 (diff) | |
download | gcc-ae5a77fa960564c8a5b2a00c22b38d954aecddb8.zip gcc-ae5a77fa960564c8a5b2a00c22b38d954aecddb8.tar.gz gcc-ae5a77fa960564c8a5b2a00c22b38d954aecddb8.tar.bz2 |
re PR ada/69219 (error on nested subprograms with Inline_Always and Intrinsic)
PR ada/69219
* gcc-interface/trans.c (check_inlining_for_nested_subprog): Consider
the parent function instead of the current function in order to issue
the warning or the error. Add guard for ignored functions.
From-SVN: r232498
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/trans.c | 29 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/inline12.adb | 23 |
4 files changed, 50 insertions, 13 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index d3369b6..01025b2 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2016-01-18 Eric Botcazou <ebotcazou@adacore.com> + + PR ada/69219 + * gcc-interface/trans.c (check_inlining_for_nested_subprog): Consider + the parent function instead of the current function in order to issue + the warning or the error. Add guard for ignored functions. + 2016-01-17 Jakub Jelinek <jakub@redhat.com> * adaint.c (__gnat_killprocesstree): Avoid -Wparentheses warning. diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index ae1d287..8f8778e 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -1487,7 +1487,7 @@ Pragma_to_gnu (Node_Id gnat_node) } -/* Check the inlining status of nested function FNDECL in the current context. +/* Check the inline status of nested function FNDECL wrt its parent function. If a non-inline nested function is referenced from an inline external function, we cannot honor both requests at the same time without cloning @@ -1495,24 +1495,27 @@ Pragma_to_gnu (Node_Id gnat_node) We could inline it as well but it's probably better to err on the side of too little inlining. - This must be invoked only on nested functions present in the source code + This must be done only on nested functions present in the source code and not on nested functions generated by the compiler, e.g. finalizers, - because they are not marked inline and we don't want them to block the - inlining of the parent function. */ + because they may be not marked inline and we don't want them to block + the inlining of the parent function. */ static void check_inlining_for_nested_subprog (tree fndecl) { - if (!DECL_DECLARED_INLINE_P (fndecl) - && current_function_decl - && DECL_EXTERNAL (current_function_decl) - && DECL_DECLARED_INLINE_P (current_function_decl)) + if (DECL_IGNORED_P (current_function_decl) || DECL_IGNORED_P (fndecl)) + return; + + if (DECL_DECLARED_INLINE_P (fndecl)) + return; + + tree parent_decl = decl_function_context (fndecl); + if (DECL_EXTERNAL (parent_decl) && DECL_DECLARED_INLINE_P (parent_decl)) { const location_t loc1 = DECL_SOURCE_LOCATION (fndecl); - const location_t loc2 = DECL_SOURCE_LOCATION (current_function_decl); + const location_t loc2 = DECL_SOURCE_LOCATION (parent_decl); - if (lookup_attribute ("always_inline", - DECL_ATTRIBUTES (current_function_decl))) + if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (parent_decl))) { error_at (loc1, "subprogram %q+F not marked Inline_Always", fndecl); error_at (loc2, "parent subprogram cannot be inlined"); @@ -1524,8 +1527,8 @@ check_inlining_for_nested_subprog (tree fndecl) warning_at (loc2, OPT_Winline, "parent subprogram cannot be inlined"); } - DECL_DECLARED_INLINE_P (current_function_decl) = 0; - DECL_UNINLINABLE (current_function_decl) = 1; + DECL_DECLARED_INLINE_P (parent_decl) = 0; + DECL_UNINLINABLE (parent_decl) = 1; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d4202ad..7d93a493 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2016-01-18 Eric Botcazou <ebotcazou@adacore.com> + + * gnat.dg/inline12.adb: New test. + 2016-01-18 Bin Cheng <bin.cheng@arm.com> PR tree-optimization/66797 diff --git a/gcc/testsuite/gnat.dg/inline12.adb b/gcc/testsuite/gnat.dg/inline12.adb new file mode 100644 index 0000000..e73f3c1 --- /dev/null +++ b/gcc/testsuite/gnat.dg/inline12.adb @@ -0,0 +1,23 @@ +-- PR ada/69219 +-- Testcae by yuta tomino <demoonlit@panathenaia.halfmoon.jp> */ + +-- { dg-do compile } + +procedure Inline12 is + + procedure NI; + + procedure IA; + pragma Convention (Intrinsic, IA); + pragma Inline_Always (IA); + + procedure IA is + begin + NI; + end; + + procedure NI is null; + +begin + IA; +end; |