[Ada] Bit_Order cannot be defined for record extensions
authorJavier Miranda <miranda@adacore.com>
Mon, 16 Jul 2018 14:10:53 +0000 (14:10 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Mon, 16 Jul 2018 14:10:53 +0000 (14:10 +0000)
This patch allows the compiler to report an error on Bit_Order when
defined for a record extension.

2018-07-16  Javier Miranda  <miranda@adacore.com>

gcc/ada/

* sem_ch13.adb (Analyze_Attribute_Definition_Clause): Report an error
on Bit_Order when defined for a record extension.

gcc/testsuite/

* gnat.dg/bit_order1.adb: New testcase.

From-SVN: r262712

gcc/ada/ChangeLog
gcc/ada/sem_ch13.adb
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/bit_order1.adb [new file with mode: 0644]

index a09f67fda09dd2dfcb75be0f9a162f999a9db5e7..51b73f8bf2377c5ab7bfb74ca8a7c0a6cb3599f7 100644 (file)
@@ -1,3 +1,8 @@
+2018-07-16  Javier Miranda  <miranda@adacore.com>
+
+       * sem_ch13.adb (Analyze_Attribute_Definition_Clause): Report an error
+       on Bit_Order when defined for a record extension.
+
 2018-07-16  Arnaud Charlet  <charlet@adacore.com>
 
        * libgnat/s-objrea.ads: Minor code clean up.
index ad9e9a140c96097cc1589189323aa9706e53f857..17b138d38d0351806792001361fac35184e12fbf 100644 (file)
@@ -5331,6 +5331,12 @@ package body Sem_Ch13 is
                Error_Msg_N
                  ("Bit_Order can only be defined for record type", Nam);
 
+            elsif Is_Tagged_Type (U_Ent)
+               and then Is_Derived_Type (U_Ent)
+            then
+               Error_Msg_N
+                 ("Bit_Order cannot be defined for record extensions", Nam);
+
             elsif Duplicate_Clause then
                null;
 
index f73096e0f30e8c4fb9192b980639d190a69457b4..df006b691194a814010085ec9af61f2a1822e1fc 100644 (file)
@@ -1,3 +1,7 @@
+2018-07-16  Javier Miranda  <miranda@adacore.com>
+
+       * gnat.dg/bit_order1.adb: New testcase.
+
 2018-07-16  Javier Miranda  <miranda@adacore.com>
 
        * gnat.dg/iter2.adb, gnat.dg/iter2.ads: New testcase.
diff --git a/gcc/testsuite/gnat.dg/bit_order1.adb b/gcc/testsuite/gnat.dg/bit_order1.adb
new file mode 100644 (file)
index 0000000..5fe813b
--- /dev/null
@@ -0,0 +1,18 @@
+--  { dg-do compile }
+
+with System;
+
+procedure Bit_Order1 is
+
+   type Sample_Ttype is tagged record
+      Data : Natural;
+   end record;
+
+   type Other_Type is new Sample_Ttype with record
+      Other_Data : String (1 .. 100);
+   end record;
+
+   for Other_Type'Bit_Order use System.High_Order_First; --  { dg-error "Bit_Order cannot be defined for record extensions" }
+begin
+   null;
+end;