xref: /llvm-project/clang/test/Misc/tabstop.c (revision f63155aaa6467bd2610820dfd1996af3bb6029a7)
1 // RUN: %clang_cc1 -ftabstop 3 -fsyntax-only -Wno-error=int-conversion -fno-diagnostics-show-line-numbers %s 2>&1 | FileCheck -check-prefix=CHECK-3 -strict-whitespace %s
2 // RUN: %clang_cc1 -ftabstop 4 -fsyntax-only -Wno-error=int-conversion -fno-diagnostics-show-line-numbers %s 2>&1 | FileCheck -check-prefix=CHECK-4 -strict-whitespace %s
3 // RUN: %clang_cc1 -ftabstop 5 -fsyntax-only -Wno-error=int-conversion -fno-diagnostics-show-line-numbers %s 2>&1 | FileCheck -check-prefix=CHECK-5 -strict-whitespace %s
4 // RUN: %clang_cc1 -ftabstop 101 -fsyntax-only -Wno-error=int-conversion -fno-diagnostics-show-line-numbers %s 2>&1 | FileCheck -check-prefix=CHECK-101 -strict-whitespace %s
5 
6 // tab
7 	void* a = 1;
8 
9 // tab tab
10 		void* b = 1;
11 
12 // 3x space tab
13    	void* c = 1;
14 
15 // tab at column 10
16 void* d =	1;
17 
18 //CHECK-3: {{^   void\* a = 1;}}
19 //CHECK-3: {{^      void\* b = 1;}}
20 //CHECK-3: {{^      void\* c = 1;}}
21 //CHECK-3: {{^void\* d =   1;}}
22 
23 //CHECK-4: {{^    void\* a = 1;}}
24 //CHECK-4: {{^        void\* b = 1;}}
25 //CHECK-4: {{^    void\* c = 1;}}
26 //CHECK-4: {{^void\* d =   1;}}
27 
28 //CHECK-5: {{^     void\* a = 1;}}
29 //CHECK-5: {{^          void\* b = 1;}}
30 //CHECK-5: {{^     void\* c = 1;}}
31 //CHECK-5: {{^void\* d = 1;}}
32 
33 // Test code modification hints
34 
f(void)35 void f(void)
36 {
37 	if (0	& 1	== 1)
38 	{}
39 
40 	if (1 == 0	& 1)
41 	{}
42 }
43 
44 // CHECK-3: {{^   }}if (0 & 1   == 1)
45 // CHECK-3: {{^   }}        (       )
46 // CHECK-3: {{^   }}if (1 == 0  & 1)
47 // CHECK-3: {{^   }}    (     )
48 
49 // CHECK-4: {{^    }}if (0   & 1 == 1)
50 // CHECK-4: {{^    }}          (     )
51 // CHECK-4: {{^    }}if (1 == 0  & 1)
52 // CHECK-4: {{^    }}    (     )
53 
54 // CHECK-5: {{^     }}if (0     & 1  == 1)
55 // CHECK-5: {{^     }}            (      )
56 // CHECK-5: {{^     }}if (1 == 0     & 1)
57 // CHECK-5: {{^     }}    (     )
58 
59 // CHECK-101: warning: ignoring invalid -ftabstop value '101', using default value 8
60