From: Thomas Quinot Date: Thu, 11 Jul 2019 08:01:44 +0000 (+0000) Subject: [Ada] Fix crash on dynamic predicate when generating SCOs X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e2a2d49440c8f8253d15054b6147810a88a10242;p=gcc.git [Ada] Fix crash on dynamic predicate when generating SCOs A pragma Check for Dynamic_Predicate does not correspond to any source construct that has a provisionally-disabled SCO. 2019-07-11 Thomas Quinot gcc/ada/ * sem_prag.adb (Analyze_Pragma, case pragma Check): Do not call Set_SCO_Pragma_Enabled for the dynamic predicate case. gcc/testsuite/ * gnat.dg/scos1.adb: New testcase. From-SVN: r273384 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 93a6fdc5db5..79ee0b11ed4 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2019-07-11 Thomas Quinot + + * sem_prag.adb (Analyze_Pragma, case pragma Check): Do not call + Set_SCO_Pragma_Enabled for the dynamic predicate case. + 2019-07-11 Hristian Kirtchev * exp_util.ads, exp_util.adb (Needs_Finalization): Move to diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 969820ee6f2..1a2a759017c 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -14113,9 +14113,14 @@ package body Sem_Prag is Expr := Get_Pragma_Arg (Arg2); - -- Deal with SCO generation + -- Mark the pragma (or, if rewritten from an aspect, the original + -- aspect) as enabled. Nothing to do for an internally generated + -- check for a dynamic predicate. - if Is_Checked (N) and then not Split_PPC (N) then + if Is_Checked (N) + and then not Split_PPC (N) + and then Cname /= Name_Dynamic_Predicate + then Set_SCO_Pragma_Enabled (Loc); end if; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3b393fb60cd..66d1e3ed5be 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-07-11 Thomas Quinot + + * gnat.dg/scos1.adb: New testcase. + 2019-07-11 Justin Squirek * gnat.dg/access7.adb: New testcase. diff --git a/gcc/testsuite/gnat.dg/scos1.adb b/gcc/testsuite/gnat.dg/scos1.adb new file mode 100644 index 00000000000..778c0716f25 --- /dev/null +++ b/gcc/testsuite/gnat.dg/scos1.adb @@ -0,0 +1,26 @@ +-- { dg-do compile } +-- { dg-options "-gnata -gnateS" } + +procedure SCOs1 with SPARK_Mode => On is + + LEN_IN_BITS : constant := 20; + + M_SIZE_BYTES : constant := 2 ** LEN_IN_BITS; + ET_BYTES : constant := (M_SIZE_BYTES - 4); + + type T_BYTES is new Integer range 0 .. ET_BYTES with Size => 32; + subtype TYPE5_SCALAR is T_BYTES + with Dynamic_Predicate => TYPE5_SCALAR mod 4 = 0; + + type E_16_BYTES is new Integer; + subtype RD_BYTES is E_16_BYTES + with Dynamic_Predicate => RD_BYTES mod 4 = 0; + + function "-" (left : TYPE5_SCALAR; right : RD_BYTES) return TYPE5_SCALAR + is ( left - TYPE5_SCALAR(right) ) + with Pre => TYPE5_SCALAR(right) <= left and then + left - TYPE5_SCALAR(right) <= T_BYTES'Last, Inline_Always; + +begin + null; +end SCOs1;