]> gcc.gnu.org Git - gcc.git/commitdiff
ada: Use new typedefs in gcc-interface
authorTom Tromey <tromey@adacore.com>
Thu, 29 Jun 2023 15:56:59 +0000 (09:56 -0600)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 18 Jul 2023 13:11:48 +0000 (15:11 +0200)
This changes gcc-interface to use the typedefs that were recently
introduced in gnat.  This is another step toward switching the code
generator to emit enums rather than preprocessor defines.

In a couple of spots, a 'default' case is also added.  These avoid
warnings from -Wswitch when the typedefs are changed to be enums.

gcc/ada/

* gcc-interface/decl.cc (check_ok_for_atomic_type): Use Pragma_Id.
* gcc-interface/trans.cc (lvalue_required_p, Pragma_to_gnu): Use
Pragma_Id.
(get_type_length, Attribute_to_gnu, get_atomic_access): Use
Attribute_Id.

gcc/ada/gcc-interface/decl.cc
gcc/ada/gcc-interface/trans.cc

index ee913a017d23c72eaa1cc6724676cd965b457134..ae756b35fdb38d581be621312313bf48b0becc91 100644 (file)
@@ -6875,6 +6875,9 @@ elaborate_entity (Entity_Id gnat_entity)
        }
       break;
 
+      /* -Wswitch warning avoidance.  */
+    default:
+      break;
     }
 }
 
@@ -9705,7 +9708,7 @@ check_ok_for_atomic_type (tree type, Entity_Id gnat_entity, bool component_p)
        gnat_node = Next_Rep_Item (gnat_node))
     if (Nkind (gnat_node) == N_Pragma)
       {
-       unsigned char pragma_id
+       const Pragma_Id pragma_id
          = Get_Pragma_Id (Chars (Pragma_Identifier (gnat_node)));
 
        if ((pragma_id == Pragma_Atomic && !component_p)
index f5eadbbc895b99e80eb9dbb1b8d38e5887bdaec5..fd85facaf70fb3cf43ecd0ce006aed721413b87a 100644 (file)
@@ -814,7 +814,7 @@ lvalue_required_p (Node_Id gnat_node, tree gnu_type, bool constant,
     case N_Pragma:
       if (Is_Pragma_Name (Chars (Pragma_Identifier (gnat_parent))))
        {
-         const unsigned char id
+         const Pragma_Id id
            = Get_Pragma_Id (Chars (Pragma_Identifier (gnat_parent)));
          return id == Pragma_Inspection_Point;
        }
@@ -1331,7 +1331,7 @@ Pragma_to_gnu (Node_Id gnat_node)
   if (!Is_Pragma_Name (Chars (Pragma_Identifier (gnat_node))))
     return gnu_result;
 
-  const unsigned char id
+  const Pragma_Id id
     = Get_Pragma_Id (Chars (Pragma_Identifier (gnat_node)));
 
   /* Save the expression of pragma Compile_Time_{Error|Warning} for later.  */
@@ -1670,7 +1670,8 @@ get_type_length (tree type, tree result_type)
    should place the result type.  ATTRIBUTE is the attribute ID.  */
 
 static tree
-Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute)
+Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p,
+                 Attribute_Id attribute)
 {
   const Node_Id gnat_prefix = Prefix (gnat_node);
   tree gnu_prefix = gnat_to_gnu (gnat_prefix);
@@ -2370,6 +2371,10 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute)
          case Attr_Bit_Position:
            gnu_result = gnu_field_bitpos;
            break;
+
+           /* -Wswitch warning avoidance.  */
+         default:
+           break;
          }
 
        /* If this has a PLACEHOLDER_EXPR, qualify it by the object we are
@@ -4292,7 +4297,7 @@ static void
 get_atomic_access (Node_Id gnat_node, atomic_acces_t *type, bool *sync)
 {
   Node_Id gnat_parent, gnat_temp;
-  unsigned char attr_id;
+  Attribute_Id attr_id;
 
   /* First, scan the parent to filter out irrelevant cases.  */
   gnat_parent = Parent (gnat_node);
@@ -6854,7 +6859,7 @@ gnat_to_gnu (Node_Id gnat_node)
     case N_Attribute_Reference:
       {
        /* The attribute designator.  */
-       const int attr = Get_Attribute_Id (Attribute_Name (gnat_node));
+       const Attribute_Id attr = Get_Attribute_Id (Attribute_Name (gnat_node));
 
        /* The Elab_Spec and Elab_Body attributes are special in that Prefix
           is a unit, not an object with a GCC equivalent.  */
This page took 0.083655 seconds and 5 git commands to generate.