From: Eric Botcazou Date: Fri, 14 Dec 2018 10:53:41 +0000 (+0000) Subject: dwarf2out.c (analyze_discr_in_predicate): Simplify. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fcdc7fd55df451a405f040733c29b8fe3d20cff1;p=gcc.git dwarf2out.c (analyze_discr_in_predicate): Simplify. * 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f97c40106db..3e3402201cd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-12-14 Eric Botcazou + + * dwarf2out.c (analyze_discr_in_predicate): Simplify. + (analyze_variants_discr): Deal with naked boolean discriminants. + 2018-12-14 Claudiu Zissulescu * config/arc/arc.c (arc_restore_callee_milli) Don't clobber off diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index f04a052adec..9fa05898b2d 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2018-12-14 Eric Botcazou + + * 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 PR ada/88429 @@ -170,8 +175,8 @@ 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 + a boolean discriminant attached to a variant part. 2018-12-11 Ed Schonberg @@ -289,8 +294,7 @@ * 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. diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index b2f92296a1a..0ad06f1a9f1 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -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, diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 99ac40f0b9f..cb5cc0129e1 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -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: for a boolean discriminant. + This sub-expression matches boolean_true_node. */ + new_node = ggc_cleared_alloc (); + 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. */