diff options
Diffstat (limited to 'clang/test/Analysis/uninit-asm-goto.cpp')
-rw-r--r-- | clang/test/Analysis/uninit-asm-goto.cpp | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/clang/test/Analysis/uninit-asm-goto.cpp b/clang/test/Analysis/uninit-asm-goto.cpp index 9da21584ec86..1b9d1689b036 100644 --- a/clang/test/Analysis/uninit-asm-goto.cpp +++ b/clang/test/Analysis/uninit-asm-goto.cpp @@ -3,19 +3,19 @@ // test1: Expect no diagnostics int test1(int x) { int y; - asm goto("nop" : "=r"(y) : "r"(x) : : err); + asm goto("" : "=r"(y) : "r"(x) : : err); return y; err: return -1; } int test2(int x) { - int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}} \ - // expected-note {{initialize the variable}} + int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}} + // expected-note@-1 {{initialize the variable}} if (x < 42) - asm volatile goto("testl %0, %0; testl %1, %2; jne %l3" : "+S"(x), "+D"(y) : "r"(x) :: indirect_1, indirect_2); + asm goto("" : "+S"(x), "+D"(y) : "r"(x) :: indirect_1, indirect_2); else - asm volatile goto("testl %0, %1; testl %2, %3; jne %l5" : "+S"(x), "+D"(y) : "r"(x), "r"(y) :: indirect_1, indirect_2); + asm goto("" : "+S"(x), "+D"(y) : "r"(x), "r"(y) :: indirect_1, indirect_2); return x + y; indirect_1: return -42; @@ -24,9 +24,9 @@ indirect_2: } int test3(int x) { - int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}} \ - // expected-note {{initialize the variable}} - asm goto("xorl %1, %0; jmp %l2" : "=&r"(y) : "r"(x) : : fail); + int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}} + // expected-note@-1 {{initialize the variable}} + asm goto("" : "=&r"(y) : "r"(x) : : fail); normal: y += x; return y; @@ -38,20 +38,20 @@ fail: } int test4(int x) { - int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}} \ - // expected-note {{initialize the variable}} + int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}} + // expected-note@-1 {{initialize the variable}} goto forward; backward: return y; // expected-note {{uninitialized use occurs here}} forward: - asm goto("# %0 %1 %2" : "=r"(y) : "r"(x) : : backward); + asm goto("" : "=r"(y) : "r"(x) : : backward); return y; } // test5: Expect no diagnostics int test5(int x) { int y; - asm volatile goto("testl %0, %0; testl %1, %2; jne %l3" : "+S"(x), "+D"(y) : "r"(x) :: indirect, fallthrough); + asm goto("" : "+S"(x), "+D"(y) : "r"(x) :: indirect, fallthrough); fallthrough: return y; indirect: @@ -63,9 +63,30 @@ int test6(unsigned int *x) { unsigned int val; // See through casts and unary operators. - asm goto("nop" : "=r" (*(unsigned int *)(&val)) ::: indirect); + asm goto("" : "=r" (*(unsigned int *)(&val)) ::: indirect); *x = val; return 0; indirect: return -1; } + +int test7(int z) { + int x; // expected-warning {{variable 'x' is used uninitialized whenever its declaration is reached}} + // expected-note@-1 {{initialize the variable 'x' to silence this warning}} + if (z) + asm goto ("":"=r"(x):::A1,A2); + return 0; + A1: + A2: + return x; // expected-note {{uninitialized use occurs here}} +} + +int test8() { + int x = 0; // expected-warning {{variable 'x' is used uninitialized whenever its declaration is reached}} + // expected-note@-1 {{variable 'x' is declared here}} + asm goto ("":"=r"(x):::A1,A2); + return 0; + A1: + A2: + return x; // expected-note {{uninitialized use occurs here}} +} |