3
3
// test1: Expect no diagnostics
4
4
int test1 (int x) {
5
5
int y;
6
- asm goto (" nop " : " =r" (y) : " r" (x) : : err);
6
+ asm goto (" " : " =r" (y) : " r" (x) : : err);
7
7
return y;
8
8
err:
9
9
return -1 ;
10
10
}
11
11
12
12
int test2 (int x) {
13
- int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}} \
14
- // expected-note {{initialize the variable}}
13
+ int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}}
14
+ // expected-note@-1 {{initialize the variable}}
15
15
if (x < 42 )
16
- asm volatile goto (" testl %0, %0; testl %1, %2; jne %l3 " : " +S" (x), " +D" (y) : " r" (x) :: indirect_1, indirect_2);
16
+ asm goto (" " : " +S" (x), " +D" (y) : " r" (x) :: indirect_1, indirect_2);
17
17
else
18
- asm volatile goto (" testl %0, %1; testl %2, %3; jne %l5 " : " +S" (x), " +D" (y) : " r" (x), " r" (y) :: indirect_1, indirect_2);
18
+ asm goto (" " : " +S" (x), " +D" (y) : " r" (x), " r" (y) :: indirect_1, indirect_2);
19
19
return x + y;
20
20
indirect_1:
21
21
return -42 ;
@@ -24,9 +24,9 @@ int test2(int x) {
24
24
}
25
25
26
26
int test3 (int x) {
27
- int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}} \
28
- // expected-note {{initialize the variable}}
29
- asm goto (" xorl %1, %0; jmp %l2 " : " =&r" (y) : " r" (x) : : fail);
27
+ int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}}
28
+ // expected-note@-1 {{initialize the variable}}
29
+ asm goto (" " : " =&r" (y) : " r" (x) : : fail);
30
30
normal:
31
31
y += x;
32
32
return y;
@@ -38,20 +38,20 @@ int test3(int x) {
38
38
}
39
39
40
40
int test4 (int x) {
41
- int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}} \
42
- // expected-note {{initialize the variable}}
41
+ int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}}
42
+ // expected-note@-1 {{initialize the variable}}
43
43
goto forward;
44
44
backward:
45
45
return y; // expected-note {{uninitialized use occurs here}}
46
46
forward:
47
- asm goto (" # %0 %1 %2 " : " =r" (y) : " r" (x) : : backward);
47
+ asm goto (" " : " =r" (y) : " r" (x) : : backward);
48
48
return y;
49
49
}
50
50
51
51
// test5: Expect no diagnostics
52
52
int test5 (int x) {
53
53
int y;
54
- asm volatile goto (" testl %0, %0; testl %1, %2; jne %l3 " : " +S" (x), " +D" (y) : " r" (x) :: indirect, fallthrough);
54
+ asm goto (" " : " +S" (x), " +D" (y) : " r" (x) :: indirect, fallthrough);
55
55
fallthrough:
56
56
return y;
57
57
indirect:
@@ -63,9 +63,30 @@ int test6(unsigned int *x) {
63
63
unsigned int val;
64
64
65
65
// See through casts and unary operators.
66
- asm goto (" nop " : " =r" (*(unsigned int *)(&val)) ::: indirect);
66
+ asm goto (" " : " =r" (*(unsigned int *)(&val)) ::: indirect);
67
67
*x = val;
68
68
return 0 ;
69
69
indirect:
70
70
return -1 ;
71
71
}
72
+
73
+ int test7 (int z) {
74
+ int x; // expected-warning {{variable 'x' is used uninitialized whenever its declaration is reached}}
75
+ // expected-note@-1 {{initialize the variable 'x' to silence this warning}}
76
+ if (z)
77
+ asm goto (" " :" =r" (x):::A1,A2);
78
+ return 0 ;
79
+ A1:
80
+ A2:
81
+ return x; // expected-note {{uninitialized use occurs here}}
82
+ }
83
+
84
+ int test8 () {
85
+ int x = 0 ; // expected-warning {{variable 'x' is used uninitialized whenever its declaration is reached}}
86
+ // expected-note@-1 {{variable 'x' is declared here}}
87
+ asm goto (" " :" =r" (x):::A1,A2);
88
+ return 0 ;
89
+ A1:
90
+ A2:
91
+ return x; // expected-note {{uninitialized use occurs here}}
92
+ }
0 commit comments