diff options
author | Bob Duff <duff@adacore.com> | 2019-08-14 09:52:24 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2019-08-14 09:52:24 +0000 |
commit | dba246bfabc54c9a97304f4ab65fda62bd2936c8 (patch) | |
tree | 802500001857fadec9dcc6a5b14f93c9223b3321 /gcc/ada/inline.adb | |
parent | 2d1439c7ad59625fea5598dda6679c6f3be1fa1c (diff) | |
download | gcc-dba246bfabc54c9a97304f4ab65fda62bd2936c8.zip gcc-dba246bfabc54c9a97304f4ab65fda62bd2936c8.tar.gz gcc-dba246bfabc54c9a97304f4ab65fda62bd2936c8.tar.bz2 |
[Ada] Incorrect error on inline protected function
This patch fixes a bug where if a protected function has a pragma
Inline, and has no local variables, and the body consists of a single
extended_return_statement, and the result type is an indefinite
composite subtype, and inlining is enabled, the compiler gives an error,
even though the program is legal.
2019-08-14 Bob Duff <duff@adacore.com>
gcc/ada/
* inline.adb (Check_And_Split_Unconstrained_Function): Ignore
protected functions to get rid of spurious error. The
transformation done by this procedure triggers legality errors
in the generated code in this case.
gcc/testsuite/
* gnat.dg/inline19.adb, gnat.dg/inline19.ads: New testcase.
From-SVN: r274467
Diffstat (limited to 'gcc/ada/inline.adb')
-rw-r--r-- | gcc/ada/inline.adb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/ada/inline.adb b/gcc/ada/inline.adb index 05830e1..5dbd9a1 100644 --- a/gcc/ada/inline.adb +++ b/gcc/ada/inline.adb @@ -2041,6 +2041,8 @@ package body Inline is Original_Body : Node_Id; Body_To_Analyze : Node_Id; + -- Start of processing for Build_Body_To_Inline + begin pragma Assert (Current_Scope = Spec_Id); @@ -2448,6 +2450,18 @@ package body Inline is elsif Present (Body_To_Inline (Decl)) then return; + -- Do not generate a body to inline for protected functions, because the + -- transformation generates a call to a protected procedure, causing + -- spurious errors. We don't inline protected operations anyway, so + -- this is no loss. We might as well ignore intrinsics and foreign + -- conventions as well -- just allow Ada conventions. + + elsif not (Convention (Spec_Id) = Convention_Ada + or else Convention (Spec_Id) = Convention_Ada_Pass_By_Copy + or else Convention (Spec_Id) = Convention_Ada_Pass_By_Reference) + then + return; + -- Check excluded declarations elsif Present (Declarations (N)) |