+2016-01-05 David Malcolm <dmalcolm@redhat.com>
+
+ PR c/69122
+ * c-indentation.c (get_visual_column): Remove default argument.
+ (should_warn_for_misleading_indentation): For the multiline case,
+ update call to get_visual_column for next_stmt_exploc so that it
+ captures the location of the first non-whitespace character in the
+ relevant line. Don't issue warnings if there is non-whitespace
+ before the next statement.
+
2016-01-04 Jakub Jelinek <jakub@redhat.com>
Update copyright years.
static bool
get_visual_column (expanded_location exploc,
unsigned int *out,
- unsigned int *first_nws = NULL)
+ unsigned int *first_nws)
{
int line_len;
const char *line = location_get_source_line (exploc.file, exploc.line,
;
foo ();
^ DON'T WARN HERE
+
+ #define emit
+ if (flag)
+ foo ();
+ emit bar ();
+ ^ DON'T WARN HERE
+
*/
if (next_stmt_exploc.line > body_exploc.line)
{
/* Determine if GUARD_LOC and NEXT_STMT_LOC are aligned on the same
"visual column"... */
unsigned int next_stmt_vis_column;
+ unsigned int next_stmt_line_first_nws;
unsigned int body_vis_column;
unsigned int body_line_first_nws;
unsigned int guard_vis_column;
the case for input files containing #line directives, and these
are often for autogenerated sources (e.g. from .md files), where
it's not clear that it's meaningful to look at indentation. */
- if (!get_visual_column (next_stmt_exploc, &next_stmt_vis_column))
+ if (!get_visual_column (next_stmt_exploc, &next_stmt_vis_column,
+ &next_stmt_line_first_nws))
return false;
if (!get_visual_column (body_exploc,
&body_vis_column,
&guard_line_first_nws))
return false;
+ /* If the line where the next stmt starts has non-whitespace
+ on it before the stmt, then don't warn:
+ #define emit
+ if (flag)
+ foo ();
+ emit bar ();
+ ^ DON'T WARN HERE
+ (PR c/69122). */
+ if (next_stmt_line_first_nws < next_stmt_vis_column)
+ return false;
+
if ((body_type != CPP_SEMICOLON
&& next_stmt_vis_column == body_vis_column)
/* As a special case handle the case where the body is a semicolon