From: Tom Tromey <tro...@adacore.com>

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.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/gcc-interface/decl.cc  |  5 ++++-
 gcc/ada/gcc-interface/trans.cc | 15 ++++++++++-----
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
index ee913a017d2..ae756b35fdb 100644
--- a/gcc/ada/gcc-interface/decl.cc
+++ b/gcc/ada/gcc-interface/decl.cc
@@ -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)
diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc
index f5eadbbc895..fd85facaf70 100644
--- a/gcc/ada/gcc-interface/trans.cc
+++ b/gcc/ada/gcc-interface/trans.cc
@@ -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.  */
-- 
2.40.0

Reply via email to