From: ebotcazou Date: Fri, 8 Feb 2019 11:20:23 +0000 (+0000) Subject: * gcc-interface/utils.c (max_size) : Be prepared for an X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=62a6ebbd3edc069e8d35e48ab6e3b3ebe5afd2d4;p=thirdparty%2Fgcc.git * gcc-interface/utils.c (max_size) : Be prepared for an operand with VOID_TYPE. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@268675 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index c1a0d2499207..b120650cda8c 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2019-02-08 Eric Botcazou + + * gcc-interface/utils.c (max_size) : Be prepared for an + operand with VOID_TYPE. + 2019-02-08 Eric Botcazou * gcc-interface/trans.c (elaborate_all_entities): Do not elaborate the diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index 2ff664ba04e3..65b7e0f3cac9 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -3642,7 +3642,10 @@ fntype_same_flags_p (const_tree t, tree cico_list, bool return_unconstrained_p, /* EXP is an expression for the size of an object. If this size contains discriminant references, replace them with the maximum (if MAX_P) or - minimum (if !MAX_P) possible value of the discriminant. */ + minimum (if !MAX_P) possible value of the discriminant. + + Note that the expression may have already been gimplified,in which case + COND_EXPRs have VOID_TYPE and no operands, and this must be handled. */ tree max_size (tree exp, bool max_p) @@ -3714,11 +3717,15 @@ max_size (tree exp, bool max_p) return build_int_cst (type, max_p ? 1 : 0); case tcc_unary: + op0 = TREE_OPERAND (exp, 0); + if (code == NON_LVALUE_EXPR) - return max_size (TREE_OPERAND (exp, 0), max_p); + return max_size (op0, max_p); + + if (VOID_TYPE_P (TREE_TYPE (op0))) + return max_p ? TYPE_MAX_VALUE (type) : TYPE_MIN_VALUE (type); - op0 = max_size (TREE_OPERAND (exp, 0), - code == NEGATE_EXPR ? !max_p : max_p); + op0 = max_size (op0, code == NEGATE_EXPR ? !max_p : max_p); if (op0 == TREE_OPERAND (exp, 0)) return exp;