]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
opt.ads (Warn_On_Biased_Representation): New flag
authorArnaud Charlet <charlet@gcc.gnu.org>
Tue, 5 Aug 2008 13:24:27 +0000 (15:24 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Tue, 5 Aug 2008 13:24:27 +0000 (15:24 +0200)
2008-08-05  Robert Dewar  <dewar@adacore.com>

* opt.ads (Warn_On_Biased_Representation): New flag

* sem_ch13.adb:
(Analyze_Attribute_Definition_Clause): Issue warning when biased
representation is required.
(Minimum_Size): Don't allow biasing if enum rep clause case

* sem_warn.adb:
(Set_Dot_Warning_Switch): Add handling of -gnatw.b/B switches
(Set_Warning_Switch): Include -gnatw.b in -gnatwa, -gnatw.B in gnatws

* usage.adb: Add lines for -gnatw.b/B switches

From-SVN: r138704

gcc/ada/ChangeLog
gcc/ada/opt.ads
gcc/ada/sem_ch13.adb
gcc/ada/sem_warn.adb
gcc/ada/usage.adb

index 2628acedb223e875d55e536143ae99c4ecf76759..c78970e24d648747b0c8e8dd1a71f2979d82539a 100644 (file)
@@ -1,3 +1,28 @@
+2008-08-05  Robert Dewar  <dewar@adacore.com>
+
+       * opt.ads (Warn_On_Biased_Representation): New flag
+       
+       * sem_ch13.adb:
+       (Analyze_Attribute_Definition_Clause): Issue warning when biased
+       representation is required.
+       (Minimum_Size): Don't allow biasing if enum rep clause case
+       
+       * sem_warn.adb:
+       (Set_Dot_Warning_Switch): Add handling of -gnatw.b/B switches
+       (Set_Warning_Switch): Include -gnatw.b in -gnatwa, -gnatw.B in gnatws
+       
+       * usage.adb: Add lines for -gnatw.b/B switches
+
+2008-08-05  Pascal Obry  <obry@adacore.com>
+
+       * a-coinve.adb: Reorder the code to avoid uninitialized warning.
+
+       * adaint.c: In UNIX cases do not call __gnat_stat but stat directly.
+
+2008-08-05  Thomas Quinot  <quinot@adacore.com>
+
+       * socket.c: Minor reformatting.
+
 2008-08-05  Robert Dewar  <dewar@adacore.com>
 
        * sem_ch3.adb: Minor reformatting
index 68bf246919acf39ed1485565a7b6261ae12b4bf0..b0bde56b50dfb04c29c42ff0f0f1782139922c08 100644 (file)
@@ -1240,6 +1240,12 @@ package Opt is
    --  Set to True to generate warnings for static fixed-point expression
    --  values that are not an exact multiple of the small value of the type.
 
+   Warn_On_Biased_Representation : Boolean := True;
+   --  GNAT
+   --  Set to True to generate warnings for size clauses, component clauses
+   --  and component_size clauses that force biased representation. Set False
+   --  by -gnatw.B.
+
    Warn_On_Constant : Boolean := False;
    --  GNAT
    --  Set to True to generate warnings for variables that could be declared
index f72ffff6397a837cde8bb50d434bac8b71d07808..fe5305fa40f5cd31b22f91a003e8f1c88987e9cd 100644 (file)
@@ -1131,6 +1131,12 @@ package body Sem_Ch13 is
                      Set_Associated_Node_For_Itype (New_Ctyp, U_Ent);
 
                      Set_Component_Type (Btype, New_Ctyp);
+
+                     if Warn_On_Biased_Representation then
+                        Error_Msg_N
+                          ("?component size clause forces biased "
+                           & "representation", N);
+                     end if;
                   end if;
 
                   Set_Component_Size (Btype, Csize);
@@ -1330,7 +1336,12 @@ package body Sem_Ch13 is
                  or else Has_Small_Clause (U_Ent)
                then
                   Check_Size (Expr, Etyp, Size, Biased);
-                  Set_Has_Biased_Representation (U_Ent, Biased);
+                     Set_Has_Biased_Representation (U_Ent, Biased);
+
+                  if Biased and Warn_On_Biased_Representation then
+                     Error_Msg_N
+                       ("?size clause forces biased representation", N);
+                  end if;
                end if;
 
                --  For types set RM_Size and Esize if possible
@@ -1708,6 +1719,11 @@ package body Sem_Ch13 is
                if Is_Elementary_Type (U_Ent) then
                   Check_Size (Expr, U_Ent, Size, Biased);
                   Set_Has_Biased_Representation (U_Ent, Biased);
+
+                  if Biased and Warn_On_Biased_Representation then
+                     Error_Msg_N
+                       ("?value size clause forces biased representation", N);
+                  end if;
                end if;
 
                Set_RM_Size (U_Ent, Size);
@@ -2491,6 +2507,12 @@ package body Sem_Ch13 is
 
                         Set_Has_Biased_Representation (Comp, Biased);
 
+                        if Biased and Warn_On_Biased_Representation then
+                           Error_Msg_F
+                             ("?component clause forces biased "
+                              & "representation", CC);
+                        end if;
+
                         if Present (Ocomp) then
                            Set_Component_Clause     (Ocomp, CC);
                            Set_Component_Bit_Offset (Ocomp, Fbit);
@@ -3570,7 +3592,10 @@ package body Sem_Ch13 is
 
       --  Fall through with Hi and Lo set. Deal with biased case
 
-      if (Biased and then not Is_Fixed_Point_Type (T))
+      if (Biased
+           and then not Is_Fixed_Point_Type (T)
+           and then not (Is_Enumeration_Type (T)
+                          and then Has_Non_Standard_Rep (T)))
         or else Has_Biased_Representation (T)
       then
          Hi := Hi - Lo;
index 5fe97432e05c75606d6cc87faa30a368bb77a2ea..c22d0ce475ae095b232cfae728c7a5aba6986a27 100644 (file)
@@ -2817,6 +2817,12 @@ package body Sem_Warn is
          when 'A' =>
             Warn_On_Assertion_Failure           := False;
 
+         when 'b' =>
+            Warn_On_Biased_Representation       := True;
+
+         when 'B' =>
+            Warn_On_Biased_Representation       := False;
+
          when 'c' =>
             Warn_On_Unrepped_Components         := True;
 
@@ -2837,12 +2843,12 @@ package body Sem_Warn is
             Warn_On_Assertion_Failure           := True;
             Warn_On_Assumed_Low_Bound           := True;
             Warn_On_Bad_Fixed_Value             := True;
+            Warn_On_Biased_Representation       := True;
             Warn_On_Constant                    := True;
             Warn_On_Deleted_Code                := True;
             Warn_On_Dereference                 := True;
             Warn_On_Export_Import               := True;
             Warn_On_Hiding                      := True;
-            Ineffective_Inline_Warnings         := True;
             Warn_On_Modified_Unread             := True;
             Warn_On_No_Value_Assigned           := True;
             Warn_On_Non_Local_Exception         := True;
@@ -2910,6 +2916,7 @@ package body Sem_Warn is
             Warn_On_Assertion_Failure           := True;
             Warn_On_Assumed_Low_Bound           := True;
             Warn_On_Bad_Fixed_Value             := True;
+            Warn_On_Biased_Representation       := True;
             Warn_On_Constant                    := True;
             Warn_On_Export_Import               := True;
             Warn_On_Modified_Unread             := True;
@@ -2936,6 +2943,7 @@ package body Sem_Warn is
             Warn_On_Assertion_Failure           := False;
             Warn_On_Assumed_Low_Bound           := False;
             Warn_On_Bad_Fixed_Value             := False;
+            Warn_On_Biased_Representation       := False;
             Warn_On_Constant                    := False;
             Warn_On_Deleted_Code                := False;
             Warn_On_Dereference                 := False;
index e4a9446ef2cdc77f9737c4177388913742dc59ec..74780107da3773166bd7ec1473124abdfde9b78b 100644 (file)
@@ -378,12 +378,14 @@ begin
    Write_Line ("        a    turn on all optional warnings " &
                                                   "(except dhl.ot.w)");
    Write_Line ("        A    turn off all optional warnings");
-   Write_Line ("        .a*  turn on warnings for failing assertions");
-   Write_Line ("        .A   turn off warnings for failing assertions");
+   Write_Line ("        .a*  turn on warnings for failing assertion");
+   Write_Line ("        .A   turn off warnings for failing assertion");
    Write_Line ("        b    turn on warnings for bad fixed value " &
                                                   "(not multiple of small)");
    Write_Line ("        B*   turn off warnings for bad fixed value " &
                                                   "(not multiple of small)");
+   Write_Line ("        .b*  turn on warnings for biased representation");
+   Write_Line ("        .B   turn off warnings for biased representation");
    Write_Line ("        c    turn on warnings for constant conditional");
    Write_Line ("        C*   turn off warnings for constant conditional");
    Write_Line ("        .c   turn on warnings for unrepped components");
@@ -396,7 +398,7 @@ begin
    Write_Line ("        F*   turn off warnings for unreferenced formal");
    Write_Line ("        g*   turn on warnings for unrecognized pragma");
    Write_Line ("        G    turn off warnings for unrecognized pragma");
-   Write_Line ("        h    turn on warnings for hiding variable ");
+   Write_Line ("        h    turn on warnings for hiding variable");
    Write_Line ("        H*   turn off warnings for hiding variable");
    Write_Line ("        i*   turn on warnings for implementation unit");
    Write_Line ("        I    turn off warnings for implementation unit");
@@ -430,9 +432,9 @@ begin
    Write_Line ("        .P*  turn off warnings for suspicious parameter " &
                                                   "order");
    Write_Line ("        q*   turn on warnings for questionable " &
-                                                  "missing parentheses");
+                                                  "missing parenthesis");
    Write_Line ("        Q    turn off warnings for questionable " &
-                                                  "missing parentheses");
+                                                  "missing parenthesis");
    Write_Line ("        r    turn on warnings for redundant construct");
    Write_Line ("        R*   turn off warnings for redundant construct");
    Write_Line ("        .r   turn on warnings for object renaming function");
@@ -451,8 +453,8 @@ begin
    Write_Line ("        .w*  turn off warnings on pragma Warnings Off");
    Write_Line ("        x*   turn on warnings for export/import");
    Write_Line ("        X    turn off warnings for export/import");
-   Write_Line ("        .x   turn on warnings for non-local exceptions");
-   Write_Line ("        .X*  turn off warnings for non-local exceptions");
+   Write_Line ("        .x   turn on warnings for non-local exception");
+   Write_Line ("        .X*  turn off warnings for non-local exception");
    Write_Line ("        y*   turn on warnings for Ada 2005 incompatibility");
    Write_Line ("        Y    turn off warnings for Ada 2005 incompatibility");
    Write_Line ("        z*   turn on warnings for convention/size/align " &