Commit 0d80ab91 by David Malcolm Committed by David Malcolm

Fix wording of -Wmisleading-indentation (PR c++/71497)

gcc/c-family/ChangeLog:
	PR c++/71497
	* c-indentation.c (warn_for_misleading_indentation): Use the past
	subjunctive in the note.

gcc/testsuite/ChangeLog:
	PR c++/71497
	* c-c++-common/Wmisleading-indentation-3.c: Update wording of
	expected messages.
	* c-c++-common/Wmisleading-indentation.c: Likewise.

From-SVN: r244536
parent 31b61548
2017-01-17 David Malcolm <dmalcolm@redhat.com>
PR c++/71497
* c-indentation.c (warn_for_misleading_indentation): Use the past
subjunctive in the note.
2017-01-17 Aldy Hernandez <aldyh@redhat.com> 2017-01-17 Aldy Hernandez <aldyh@redhat.com>
PR c/79116 PR c/79116
......
...@@ -608,7 +608,7 @@ warn_for_misleading_indentation (const token_indent_info &guard_tinfo, ...@@ -608,7 +608,7 @@ warn_for_misleading_indentation (const token_indent_info &guard_tinfo,
guard_tinfo_to_string (guard_tinfo))) guard_tinfo_to_string (guard_tinfo)))
inform (next_tinfo.location, inform (next_tinfo.location,
("...this statement, but the latter is misleadingly indented" ("...this statement, but the latter is misleadingly indented"
" as if it is guarded by the %qs"), " as if it were guarded by the %qs"),
guard_tinfo_to_string (guard_tinfo)); guard_tinfo_to_string (guard_tinfo));
} }
} }
2017-01-17 David Malcolm <dmalcolm@redhat.com>
PR c++/71497
* c-c++-common/Wmisleading-indentation-3.c: Update wording of
expected messages.
* c-c++-common/Wmisleading-indentation.c: Likewise.
2017-01-17 Vladimir Makarov <vmakarov@redhat.com> 2017-01-17 Vladimir Makarov <vmakarov@redhat.com>
PR target/79058 PR target/79058
......
...@@ -17,7 +17,7 @@ fn_5 (double *a, double *b, double *sum, double *prod) ...@@ -17,7 +17,7 @@ fn_5 (double *a, double *b, double *sum, double *prod)
int i = 0; int i = 0;
for (i = 0; i < 10; i++) /* { dg-warning "3: this 'for' clause does not guard..." } */ for (i = 0; i < 10; i++) /* { dg-warning "3: this 'for' clause does not guard..." } */
sum[i] = a[i] * b[i]; sum[i] = a[i] * b[i];
prod[i] = a[i] * b[i]; /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'for'" } */ prod[i] = a[i] * b[i]; /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'" } */
/* { dg-begin-multiline-output "" } /* { dg-begin-multiline-output "" }
for (i = 0; i < 10; i++) for (i = 0; i < 10; i++)
^~~ ^~~
...@@ -38,7 +38,7 @@ int fn_6 (int a, int b, int c) ...@@ -38,7 +38,7 @@ int fn_6 (int a, int b, int c)
goto fail; goto fail;
if ((err = foo (b)) != 0) /* { dg-message "2: this 'if' clause does not guard..." } */ if ((err = foo (b)) != 0) /* { dg-message "2: this 'if' clause does not guard..." } */
goto fail; goto fail;
goto fail; /* { dg-message "3: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */ goto fail; /* { dg-message "3: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'" } */
if ((err = foo (c)) != 0) if ((err = foo (c)) != 0)
goto fail; goto fail;
/* ... */ /* ... */
...@@ -64,7 +64,7 @@ void fn_14 (void) ...@@ -64,7 +64,7 @@ void fn_14 (void)
int i; int i;
FOR_EACH (i, 0, 10) /* { dg-message "in expansion of macro .FOR_EACH." } */ FOR_EACH (i, 0, 10) /* { dg-message "in expansion of macro .FOR_EACH." } */
foo (i); foo (i);
bar (i, i); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'for'" } */ bar (i, i); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'" } */
/* { dg-begin-multiline-output "" } /* { dg-begin-multiline-output "" }
for ((VAR) = (START); (VAR) < (STOP); (VAR++)) for ((VAR) = (START); (VAR) < (STOP); (VAR++))
......
...@@ -14,7 +14,7 @@ fn_1 (int flag) ...@@ -14,7 +14,7 @@ fn_1 (int flag)
int x = 4, y = 5; int x = 4, y = 5;
if (flag) /* { dg-warning "3: this 'if' clause does not guard..." } */ if (flag) /* { dg-warning "3: this 'if' clause does not guard..." } */
x = 3; x = 3;
y = 2; /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */ y = 2; /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'" } */
return x * y; return x * y;
} }
...@@ -22,7 +22,7 @@ int ...@@ -22,7 +22,7 @@ int
fn_2 (int flag, int x, int y) fn_2 (int flag, int x, int y)
{ {
if (flag) /* { dg-warning "3: this 'if' clause does not guard..." } */ if (flag) /* { dg-warning "3: this 'if' clause does not guard..." } */
x++; y++; /* { dg-message "10: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */ x++; y++; /* { dg-message "10: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'" } */
return x * y; return x * y;
} }
...@@ -35,7 +35,7 @@ fn_3 (int flag) ...@@ -35,7 +35,7 @@ fn_3 (int flag)
x = 3; x = 3;
else /* { dg-warning "3: this 'else' clause does not guard..." } */ else /* { dg-warning "3: this 'else' clause does not guard..." } */
x = 2; x = 2;
y = 2; /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'else'" } */ y = 2; /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'" } */
return x * y; return x * y;
} }
...@@ -45,7 +45,7 @@ fn_4 (double *a, double *b, double *c) ...@@ -45,7 +45,7 @@ fn_4 (double *a, double *b, double *c)
int i = 0; int i = 0;
while (i < 10) /* { dg-warning "3: this 'while' clause does not guard..." } */ while (i < 10) /* { dg-warning "3: this 'while' clause does not guard..." } */
a[i] = b[i] * c[i]; a[i] = b[i] * c[i];
i++; /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'while'" } */ i++; /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'" } */
} }
void void
...@@ -54,7 +54,7 @@ fn_5 (double *a, double *b, double *sum, double *prod) ...@@ -54,7 +54,7 @@ fn_5 (double *a, double *b, double *sum, double *prod)
int i = 0; int i = 0;
for (i = 0; i < 10; i++) /* { dg-warning "3: this 'for' clause does not guard..." } */ for (i = 0; i < 10; i++) /* { dg-warning "3: this 'for' clause does not guard..." } */
sum[i] = a[i] * b[i]; sum[i] = a[i] * b[i];
prod[i] = a[i] * b[i]; /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'for'" } */ prod[i] = a[i] * b[i]; /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'" } */
} }
/* Based on CVE-2014-1266 aka "goto fail" */ /* Based on CVE-2014-1266 aka "goto fail" */
...@@ -67,7 +67,7 @@ int fn_6 (int a, int b, int c) ...@@ -67,7 +67,7 @@ int fn_6 (int a, int b, int c)
goto fail; goto fail;
if ((err = foo (b)) != 0) /* { dg-message "2: this 'if' clause does not guard..." } */ if ((err = foo (b)) != 0) /* { dg-message "2: this 'if' clause does not guard..." } */
goto fail; goto fail;
goto fail; /* { dg-message "3: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */ goto fail; /* { dg-message "3: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'" } */
if ((err = foo (c)) != 0) if ((err = foo (c)) != 0)
goto fail; goto fail;
/* ... */ /* ... */
...@@ -81,7 +81,7 @@ int fn_7 (int p, int q, int r, int s, int t) ...@@ -81,7 +81,7 @@ int fn_7 (int p, int q, int r, int s, int t)
if (bar (p, q)) if (bar (p, q))
{ {
if (p) /* { dg-message "7: this 'if' clause does not guard..." } */ if (p) /* { dg-message "7: this 'if' clause does not guard..." } */
q++; r++; /* { dg-message "14: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */ q++; r++; /* { dg-message "14: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'" } */
t++; t++;
} }
return p + q + r + s + t; return p + q + r + s + t;
...@@ -97,7 +97,7 @@ void fn_9 (int flag) ...@@ -97,7 +97,7 @@ void fn_9 (int flag)
{ {
if (flag) /* { dg-warning "3: this 'if' clause does not guard..." } */ if (flag) /* { dg-warning "3: this 'if' clause does not guard..." } */
foo (0); foo (0);
foo (1); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */ foo (1); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'" } */
} }
void fn_10 (int flag) void fn_10 (int flag)
...@@ -108,7 +108,7 @@ void fn_10 (int flag) ...@@ -108,7 +108,7 @@ void fn_10 (int flag)
foo (0); foo (0);
foo (1); foo (1);
} }
foo (2); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */ foo (2); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'" } */
foo (3); foo (3);
} }
...@@ -118,7 +118,7 @@ void fn_11 (void) ...@@ -118,7 +118,7 @@ void fn_11 (void)
if (flagB) if (flagB)
if (flagC) /* { dg-message "7: this 'if' clause does not guard..." } */ if (flagC) /* { dg-message "7: this 'if' clause does not guard..." } */
foo (0); foo (0);
bar (1, 2); /* { dg-message "9: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */ bar (1, 2); /* { dg-message "9: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'" } */
} }
void fn_12 (void) void fn_12 (void)
...@@ -127,7 +127,7 @@ void fn_12 (void) ...@@ -127,7 +127,7 @@ void fn_12 (void)
if (flagB) /* { dg-message "5: this 'if' clause does not guard..." } */ if (flagB) /* { dg-message "5: this 'if' clause does not guard..." } */
if (flagC) if (flagC)
foo (0); foo (0);
bar (1, 2); /* { dg-message "7: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */ bar (1, 2); /* { dg-message "7: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'" } */
} }
void fn_13 (void) void fn_13 (void)
...@@ -136,7 +136,7 @@ void fn_13 (void) ...@@ -136,7 +136,7 @@ void fn_13 (void)
if (flagB) if (flagB)
if (flagC) if (flagC)
foo (0); foo (0);
bar (1, 2); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */ bar (1, 2); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'" } */
} }
#define FOR_EACH(VAR, START, STOP) \ #define FOR_EACH(VAR, START, STOP) \
...@@ -147,7 +147,7 @@ void fn_14 (void) ...@@ -147,7 +147,7 @@ void fn_14 (void)
int i; int i;
FOR_EACH (i, 0, 10) /* { dg-message "in expansion of macro .FOR_EACH." } */ FOR_EACH (i, 0, 10) /* { dg-message "in expansion of macro .FOR_EACH." } */
foo (i); foo (i);
bar (i, i); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'for'" } */ bar (i, i); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'" } */
} }
#undef FOR_EACH #undef FOR_EACH
...@@ -157,7 +157,7 @@ void fn_15 (void) ...@@ -157,7 +157,7 @@ void fn_15 (void)
int i; int i;
FOR_EACH (i, 0, 10) /* { dg-message "in expansion of macro .FOR_EACH." } */ FOR_EACH (i, 0, 10) /* { dg-message "in expansion of macro .FOR_EACH." } */
foo (i); foo (i);
bar (i, i); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'for'" } */ bar (i, i); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'" } */
} }
#undef FOR_EACH #undef FOR_EACH
...@@ -168,7 +168,7 @@ void fn_16_spaces (void) ...@@ -168,7 +168,7 @@ void fn_16_spaces (void)
while (flagA) while (flagA)
if (flagB) /* { dg-message "7: this 'if' clause does not guard..." } */ if (flagB) /* { dg-message "7: this 'if' clause does not guard..." } */
foo (0); foo (0);
foo (1); /* { dg-message "9: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */ foo (1); /* { dg-message "9: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'" } */
} }
void fn_16_tabs (void) void fn_16_tabs (void)
...@@ -178,7 +178,7 @@ void fn_16_tabs (void) ...@@ -178,7 +178,7 @@ void fn_16_tabs (void)
while (flagA) while (flagA)
if (flagB) /* { dg-message "7: this 'if' clause does not guard..." } */ if (flagB) /* { dg-message "7: this 'if' clause does not guard..." } */
foo (0); foo (0);
foo (1);/* { dg-message "2: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */ foo (1);/* { dg-message "2: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'" } */
} }
void fn_17_spaces (void) void fn_17_spaces (void)
...@@ -188,7 +188,7 @@ void fn_17_spaces (void) ...@@ -188,7 +188,7 @@ void fn_17_spaces (void)
while (flagA) while (flagA)
if (flagB) if (flagB)
foo (0); foo (0);
foo (1);/* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'for'" } */ foo (1);/* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'" } */
} }
void fn_17_tabs (void) void fn_17_tabs (void)
...@@ -198,7 +198,7 @@ void fn_17_tabs (void) ...@@ -198,7 +198,7 @@ void fn_17_tabs (void)
while (flagA) while (flagA)
if (flagB) if (flagB)
foo (0); foo (0);
foo (1);/* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'for'" } */ foo (1);/* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'" } */
} }
void fn_18_spaces (void) void fn_18_spaces (void)
...@@ -208,7 +208,7 @@ void fn_18_spaces (void) ...@@ -208,7 +208,7 @@ void fn_18_spaces (void)
while (flagA) /* { dg-message "5: this 'while' clause does not guard..." } */ while (flagA) /* { dg-message "5: this 'while' clause does not guard..." } */
if (flagB) if (flagB)
foo (0); foo (0);
foo (1);/* { dg-message "7: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'while'" } */ foo (1);/* { dg-message "7: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'" } */
} }
void fn_18_tabs (void) void fn_18_tabs (void)
...@@ -218,7 +218,7 @@ void fn_18_tabs (void) ...@@ -218,7 +218,7 @@ void fn_18_tabs (void)
while (flagA) /* { dg-message "5: this 'while' clause does not guard..." } */ while (flagA) /* { dg-message "5: this 'while' clause does not guard..." } */
if (flagB) if (flagB)
foo (0); foo (0);
foo (1);/* { dg-message "7: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'while'" } */ foo (1);/* { dg-message "7: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'" } */
} }
/* This shouldn't lead to a warning. */ /* This shouldn't lead to a warning. */
...@@ -704,37 +704,37 @@ fn_37 (void) ...@@ -704,37 +704,37 @@ fn_37 (void)
#define FOR_EACH(VAR, START, STOP) for (VAR = START; VAR < STOP; VAR++) /* { dg-warning "this 'for' clause" } */ #define FOR_EACH(VAR, START, STOP) for (VAR = START; VAR < STOP; VAR++) /* { dg-warning "this 'for' clause" } */
while (flagA); /* { dg-warning "3: this 'while' clause" } */ while (flagA); /* { dg-warning "3: this 'while' clause" } */
foo (0); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'while'" } */ foo (0); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'" } */
if (flagA) if (flagA)
; ;
else if (flagB); /* { dg-warning "8: this 'if' clause" } */ else if (flagB); /* { dg-warning "8: this 'if' clause" } */
foo (0); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */ foo (0); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'" } */
while (flagA) /* { dg-warning "3: this 'while' clause" } */ while (flagA) /* { dg-warning "3: this 'while' clause" } */
/* blah */; /* blah */;
foo (0); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'while'" } */ foo (0); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'" } */
if (flagA) if (flagA)
; ;
else if (flagB) /* { dg-warning "8: this 'if' clause" } */ else if (flagB) /* { dg-warning "8: this 'if' clause" } */
foo (1); foo (1);
foo (2); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */ foo (2); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'" } */
if (flagA) if (flagA)
foo (1); foo (1);
else if (flagB) /* { dg-warning "8: this 'if' clause" } */ else if (flagB) /* { dg-warning "8: this 'if' clause" } */
foo (2); foo (2);
foo (3); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */ foo (3); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'" } */
if (flagB) /* { dg-warning "3: this 'if' clause" } */ if (flagB) /* { dg-warning "3: this 'if' clause" } */
/* blah */; /* blah */;
{ /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */ { /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'" } */
foo (0); foo (0);
} }
if (flagB) /* { dg-warning "3: this 'if' clause" } */ if (flagB) /* { dg-warning "3: this 'if' clause" } */
/* blah */; /* blah */;
{ /* { dg-message "4: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */ { /* { dg-message "4: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'" } */
foo (0); foo (0);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment