xref: /llvm-project/clang/test/Misc/diag-style.cpp (revision ef5217b3c0dcbb58927fe43400b6d1faa677bf98)
1 // RUN: not %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck -strict-whitespace %s
2 
3 /// empty lines in multi-line diagnostic snippets are preserved.
4 static_assert(false &&
5 
6               true, "");
7 // CHECK: static assertion failed
8 // CHECK-NEXT: {{^}}    4 | static_assert(false &&{{$}}
9 // CHECK-NEXT: {{^}}      |               ^~~~~~~~{{$}}
10 // CHECK-NEXT: {{^}}    5 | {{$}}
11 // CHECK-NEXT: {{^}}    6 |               true, "");{{$}}
12 // CHECK-NEXT: {{^}}      |               ~~~~{{$}}
13 
14 
15 /// #line pragmas are respected
16 void printf(const char *a, ...) __attribute__((__format__(__printf__, 1, 2)));
17 #line 10
f(int x)18 void f(int x) {
19   printf("%f",
20          x);
21 }
22 // CHECK: 12:10: warning: format specifies type
23 // CHECK-NEXT: {{^}}   11 |
24 // CHECK-NEXT: {{^}}      |
25 // CHECK-NEXT: {{^}}      |
26 // CHECK-NEXT: {{^}}   12 |
27 
28 #line 10
29 int func(
30   int a, int b,
31   int&
32   r);
33 
test()34 void test() {
35   func(3, 4, 5);
36 }
37 // CHECK: 10:5: note: candidate function not viable
38 // CHECK-NEXT: {{^}}   10 |
39 // CHECK-NEXT: {{^}}      |
40 // CHECK-NEXT: {{^}}   11 |
41 // CHECK-NEXT: {{^}}   12 |
42 // CHECK-NEXT: {{^}}      |
43 // CHECK-NEXT: {{^}}   13 |
44 // CHECK-NEXT: {{^}}      |
45 
46