1 /* Verify -Wmisleading-indentation with source-printing.
2 This is a subset of Wmisleading-indentation.c. */
4 /* { dg-options "-Wmisleading-indentation -fdiagnostics-show-caret" } */
5 /* { dg-do compile } */
8 extern int bar (int, int);
15 fn_5 (double *a
, double *b
, double *sum
, double *prod
)
18 for (i
= 0; i
< 10; i
++) /* { dg-warning "3: this 'for' clause does not guard..." } */
20 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'" } */
21 /* { dg-begin-multiline-output "" }
22 for (i = 0; i < 10; i++)
24 { dg-end-multiline-output "" } */
25 /* { dg-begin-multiline-output "" }
26 prod[i] = a[i] * b[i];
28 { dg-end-multiline-output "" } */
31 /* Based on CVE-2014-1266 aka "goto fail" */
32 int fn_6 (int a
, int b
, int c
)
37 if ((err
= foo (a
)) != 0)
39 if ((err
= foo (b
)) != 0) /* { dg-message "2: this 'if' clause does not guard..." } */
41 goto fail
; /* { dg-message "3: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'" } */
42 if ((err
= foo (c
)) != 0)
46 /* { dg-begin-multiline-output "" }
47 if ((err = foo (b)) != 0)
49 { dg-end-multiline-output "" } */
50 /* { dg-begin-multiline-output "" }
53 { dg-end-multiline-output "" } */
59 #define FOR_EACH(VAR, START, STOP) \
60 for ((VAR) = (START); (VAR) < (STOP); (VAR++)) /* { dg-warning "3: this 'for' clause does not guard..." } */
65 FOR_EACH (i
, 0, 10) /* { dg-message "in expansion of macro .FOR_EACH." } */
67 bar (i
, i
); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'" } */
69 /* { dg-begin-multiline-output "" }
70 for ((VAR) = (START); (VAR) < (STOP); (VAR++))
72 { dg-end-multiline-output "" } */
73 /* { dg-begin-multiline-output "" }
76 { dg-end-multiline-output "" } */
77 /* { dg-begin-multiline-output "" }
80 { dg-end-multiline-output "" } */