aboutsummaryrefslogtreecommitdiff
path: root/gcc/dwarf2out.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2018-12-14 10:53:41 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2018-12-14 10:53:41 +0000
commitfcdc7fd55df451a405f040733c29b8fe3d20cff1 (patch)
tree4df96b3c4eb8310d8d483978186ec49bb6cb75de /gcc/dwarf2out.c
parent544a4843e8873ce0dc08b2e1cde8978b15d23628 (diff)
downloadgcc-fcdc7fd55df451a405f040733c29b8fe3d20cff1.zip
gcc-fcdc7fd55df451a405f040733c29b8fe3d20cff1.tar.gz
gcc-fcdc7fd55df451a405f040733c29b8fe3d20cff1.tar.bz2
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
Diffstat (limited to 'gcc/dwarf2out.c')
-rw-r--r--gcc/dwarf2out.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 99ac40f..cb5cc01 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: <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. */