From 0afbb81bb61b5ad8a3ed49690151afab9c7dce85 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 3 Feb 2016 23:40:22 +0100 Subject: [PATCH] re PR c/69627 (Conditional jump or move depends on uninitialised value(s) in (anonymous namespace)::layout::get_state_at_point) PR c/69627 * diagnostic-show-locus.c (layout::get_state_at_point): Don't read range->m_caret fields if range->m_show_caret_p is false. * gcc.dg/pr69627.c: New test. From-SVN: r233114 --- gcc/ChangeLog | 4 ++++ gcc/diagnostic-show-locus.c | 5 +++-- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/gcc.dg/pr69627.c | 27 +++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr69627.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a3fc634f46a..142e7a45208 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2016-02-03 Jakub Jelinek + PR c/69627 + * diagnostic-show-locus.c (layout::get_state_at_point): Don't read + range->m_caret fields if range->m_show_caret_p is false. + PR target/69644 * config/rs6000/rs6000.c (rs6000_expand_atomic_compare_and_swap): Force oldval into register if it does not satisfy reg_or_short_operand diff --git a/gcc/diagnostic-show-locus.c b/gcc/diagnostic-show-locus.c index d9b6750339b..3959a1db35e 100644 --- a/gcc/diagnostic-show-locus.c +++ b/gcc/diagnostic-show-locus.c @@ -722,9 +722,10 @@ layout::get_state_at_point (/* Inputs. */ /* Are we at the range's caret? is it visible? */ out_state->draw_caret_p = false; - if (row == range->m_caret.m_line + if (range->m_show_caret_p + && row == range->m_caret.m_line && column == range->m_caret.m_column) - out_state->draw_caret_p = range->m_show_caret_p; + out_state->draw_caret_p = true; /* Within a multiline range, don't display any underline in any leading or trailing whitespace on a line. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d192485acae..72356d164b9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2016-02-03 Jakub Jelinek + PR c/69627 + * gcc.dg/pr69627.c: New test. + PR target/69644 * gcc.dg/pr69644.c: New test. diff --git a/gcc/testsuite/gcc.dg/pr69627.c b/gcc/testsuite/gcc.dg/pr69627.c new file mode 100644 index 00000000000..b7f56cd4ac7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr69627.c @@ -0,0 +1,27 @@ +/* PR c/69627 */ +/* { dg-do compile } */ +/* { dg-options "-fdiagnostics-show-caret" } */ + +void +foo () +{ + float t[2] = { 1, 2 }; + int const *s = 0; + t[1] / s; /* { dg-error "invalid operands to binary /" } */ +/* { dg-begin-multiline-output "" } + t[1] / s; + ~~~~ ^ + { dg-end-multiline-output "" } */ +} + +void +bar () +{ + float t[2] = { 1, 2 }; + int const *s[2] = { 0, 0 }; + t[1] / s[0]; /* { dg-error "invalid operands to binary /" } */ +/* { dg-begin-multiline-output "" } + t[1] / s[0]; + ~~~~ ^ ~~~~ + { dg-end-multiline-output "" } */ +}