dwarf2out.c (analyze_discr_in_predicate): Simplify.
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 14 Dec 2018 10:53:41 +0000 (10:53 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Fri, 14 Dec 2018 10:53:41 +0000 (10:53 +0000)
* dwarf2out.c (analyze_discr_in_predicate): Simplify.
(analyze_variants_discr): Deal with naked boolean discriminants.
ada/
* gcc-interface/decl.c (choices_to_gnu): Directly use a naked boolean
discriminant if the value is the boolean true.

From-SVN: r267130

gcc/ChangeLog
gcc/ada/ChangeLog
gcc/ada/gcc-interface/decl.c
gcc/dwarf2out.c

index f97c40106dbeac4dff3b0d1dddd23a1f089ab864..3e3402201cdb63b7dde555a8711c42d6dafe076c 100644 (file)
@@ -1,3 +1,8 @@
+2018-12-14  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * dwarf2out.c (analyze_discr_in_predicate): Simplify.
+       (analyze_variants_discr): Deal with naked boolean discriminants.
+
 2018-12-14  Claudiu Zissulescu  <claziss@synopsys.com>
 
        * config/arc/arc.c (arc_restore_callee_milli) Don't clobber off
index f04a052adec574dc10b10615969fc5e2980af441..9fa05898b2db15cdaf28228a1d73f109d9ea0eb8 100644 (file)
@@ -1,3 +1,8 @@
+2018-12-14  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/decl.c (choices_to_gnu): Directly use a naked boolean
+       discriminant if the value is the boolean true.
+
 2018-12-11  Eric Botcazou  <ebotcazou@adacore.com>
 
        PR ada/88429
        retrieve directly its RM size.
        (components_to_record): Minor tweak.
        (set_rm_size): Remove useless test.
-       * gcc-interface/trans.c (gnat_to_gnu): Do wrap the instance of a
-       boolean discriminant attached to a variant part.
+       * gcc-interface/trans.c (gnat_to_gnu): Do not wrap the instance of
+       boolean discriminant attached to a variant part.
 
 2018-12-11  Ed Schonberg  <schonberg@adacore.com>
 
 
        * fe.h (Is_Atomic_Object): Declare.
        (Is_Volatile_Object): Likewise.
-       * gcc-interface/trans.c (atomic_or_volatile_copy_required_p):
-       New.
+       * gcc-interface/trans.c (atomic_or_volatile_copy_required_p): New.
        (Call_to_gnu): Generate a copy for an actual parameter passed by
        reference if the conditions set forth by RM C.6(19) are met and
        specificially deal with an atomic actual parameter.
index b2f92296a1a089623ab5eb570311eb5f297bf327..0ad06f1a9f1149efc9217d6f55cef4e8d3a84b03 100644 (file)
@@ -6848,6 +6848,9 @@ choices_to_gnu (tree gnu_operand, Node_Id gnat_choices)
                             build_binary_op (LE_EXPR, boolean_type_node,
                                              gnu_operand, gnu_high, true),
                             true);
+      else if (gnu_low == boolean_true_node
+              && TREE_TYPE (gnu_operand) == boolean_type_node)
+       gnu_test = gnu_operand;
       else if (gnu_low)
        gnu_test
          = build_binary_op (EQ_EXPR, boolean_type_node, gnu_operand, gnu_low,
index 99ac40f0b9f89b4062a39898b0c4a5b457935aeb..cb5cc0129e1f622a183aa2c9c67c46d4d1127964 100644 (file)
@@ -24537,6 +24537,7 @@ gen_inheritance_die (tree binfo, tree access, tree type,
 
 /* Return whether DECL is a FIELD_DECL that represents the variant part of a
    structure.  */
+
 static bool
 is_variant_part (tree decl)
 {
@@ -24550,17 +24551,8 @@ is_variant_part (tree decl)
 static tree
 analyze_discr_in_predicate (tree operand, tree struct_type)
 {
-  bool continue_stripping = true;
-  while (continue_stripping)
-    switch (TREE_CODE (operand))
-      {
-      CASE_CONVERT:
-       operand = TREE_OPERAND (operand, 0);
-       break;
-      default:
-       continue_stripping = false;
-       break;
-      }
+  while (CONVERT_EXPR_P (operand))
+    operand = TREE_OPERAND (operand, 0);
 
   /* Match field access to members of struct_type only.  */
   if (TREE_CODE (operand) == COMPONENT_REF
@@ -24780,6 +24772,19 @@ analyze_variants_discr (tree variant_part_decl,
              new_node->dw_discr_range = true;
            }
 
+         else if ((candidate_discr
+                     = analyze_discr_in_predicate (match_expr, struct_type))
+                  && TREE_TYPE (candidate_discr) == boolean_type_node)
+           {
+             /* We are matching:  <discr_field> for a boolean discriminant.
+                This sub-expression matches boolean_true_node.  */
+             new_node = ggc_cleared_alloc<dw_discr_list_node> ();
+             if (!get_discr_value (boolean_true_node,
+                                   &new_node->dw_discr_lower_bound))
+               goto abort;
+             new_node->dw_discr_range = false;
+           }
+
          else
            /* Unsupported sub-expression: we cannot determine the set of
               matching discriminant values.  Abort everything.  */