From 4af362a9571170538b66411d9cf7b6dc87745854 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Fri, 24 Feb 2017 09:52:31 +0000 Subject: [PATCH] utils.c (max_size): Flip the second argument when recursing on TRUTH_NOT_EXPR. * gcc-interface/utils.c (max_size) : Flip the second argument when recursing on TRUTH_NOT_EXPR. From-SVN: r245697 --- gcc/ada/ChangeLog | 5 +++++ gcc/ada/gcc-interface/utils.c | 3 ++- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gnat.dg/discr47.adb | 19 +++++++++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gnat.dg/discr47.adb diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 053ca00254f..a7edb4158cc 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2017-02-24 Eric Botcazou + + * gcc-interface/utils.c (max_size) : Flip the second + argument when recursing on TRUTH_NOT_EXPR. + 2017-02-12 John Marino * system-freebsd-x86.ads: Rename into... diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index 3cda63196e7..33a37cea2f6 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -3635,7 +3635,8 @@ max_size (tree exp, bool max_p) return exp; return fold_build1 (code, type, - max_size (TREE_OPERAND (exp, 0), max_p)); + max_size (TREE_OPERAND (exp, 0), + code == TRUTH_NOT_EXPR ? !max_p : max_p)); case 2: if (code == COMPOUND_EXPR) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6b62ae8dc0e..dc2cf4ee2af 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2017-02-24 Eric Botcazou + + * gnat.dg/discr47.adb: New test. + 2017-02-24 Richard Biener PR tree-optimization/79389 diff --git a/gcc/testsuite/gnat.dg/discr47.adb b/gcc/testsuite/gnat.dg/discr47.adb new file mode 100644 index 00000000000..0aaa655ca78 --- /dev/null +++ b/gcc/testsuite/gnat.dg/discr47.adb @@ -0,0 +1,19 @@ +-- { dg-do run } +-- { dg-options "-O -gnatws" } + +procedure Discr47 is + + type Rec (D : Boolean := False) is record + case D is + when True => null; + when False => C : Character; + end case; + end record; + + R : Rec; + +begin + if R'Size /= 16 then + raise Program_Error; + end if; +end; -- 2.30.2