From: pmderodat Date: Tue, 11 Dec 2018 11:10:22 +0000 (+0000) Subject: [Ada] Stubs that complete generic subprogram do have a "prior declaration" X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f735bd19ebb140c83e9b0f2219e7a23be0ea64c6;p=thirdparty%2Fgcc.git [Ada] Stubs that complete generic subprogram do have a "prior declaration" The intuition behind the Is_Subprogram_Stub_Without_Prior_Declaration utility routine is to detect stubs that act as subprogram declarations and False on stubs that act as completions. This behaviour is now fixed for stubs that correspond to generic subprogram declarations. This patch affects a routine that is only used in GNATprove, so no frontend test provided. An example where the result changed from True to False is: ----------- -- p.ads -- ----------- package P is generic procedure Proc; end P; ----------- -- p.adb -- ----------- package body P is procedure Proc is separate; -- now we return False for this stub end P; ---------------- -- p-proc.adb -- ---------------- separate (P) procedure Proc is begin null; end; 2018-12-11 Piotr Trojanek gcc/ada/ * sem_util.adb (Is_Subprogram_Stub_Without_Prior_Declaration): Return False on stubs that complete a generic subprogram. * sem_util.ads: Update corresponding comment. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@266992 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 827ac096daca..8e2f54c0c5fd 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2018-12-11 Piotr Trojanek + + * sem_util.adb (Is_Subprogram_Stub_Without_Prior_Declaration): + Return False on stubs that complete a generic subprogram. + * sem_util.ads: Update corresponding comment. + 2018-12-11 Ed Schonberg * sem_ch4.adb (Analyze_Allocator): In GNATprove mode build a diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index c5a194486bce..120f1015bb5e 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -17471,12 +17471,30 @@ package body Sem_Util is (N : Node_Id) return Boolean is begin - -- A subprogram stub without prior declaration serves as declaration for - -- the actual subprogram body. As such, it has an attached defining - -- entity of E_[Generic_]Function or E_[Generic_]Procedure. + pragma Assert (Nkind (N) = N_Subprogram_Body_Stub); - return Nkind (N) = N_Subprogram_Body_Stub - and then Ekind (Defining_Entity (N)) /= E_Subprogram_Body; + case Ekind (Defining_Entity (N)) is + + -- A subprogram stub without prior declaration serves as declaration + -- for the actual subprogram body. As such, it has an attached + -- defining entity of E_Function or E_Procedure. + + when E_Function + | E_Procedure + => + return True; + + -- Otherwise, it is completes a [generic] subprogram declaration + + when E_Generic_Function + | E_Generic_Procedure + | E_Subprogram_Body + => + return False; + + when others => + raise Program_Error; + end case; end Is_Subprogram_Stub_Without_Prior_Declaration; --------------------------- diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads index b287946e43ea..39bb01fb8380 100644 --- a/gcc/ada/sem_util.ads +++ b/gcc/ada/sem_util.ads @@ -2001,8 +2001,8 @@ package Sem_Util is function Is_Subprogram_Stub_Without_Prior_Declaration (N : Node_Id) return Boolean; - -- Return True if N is a subprogram stub with no prior subprogram - -- declaration. + -- Given an N_Subprogram_Body_Stub node N, return True if N is a subprogram + -- stub with no prior subprogram declaration. function Is_Suitable_Primitive (Subp_Id : Entity_Id) return Boolean; -- Determine whether arbitrary subprogram Subp_Id may act as a primitive of