1 // RUN: %clang_analyze_cc1 -analyze -triple x86_64-apple-darwin10 \ 2 // RUN: -analyzer-checker=core,debug.ExprInspection -verify %s 3 4 void clang_analyzer_warnIfReached(); 5 6 typedef struct { 7 int value; 8 } Struct; 9 10 typedef union { 11 Struct *ptr; 12 long num; 13 } __attribute__((transparent_union)) Alias; 14 15 void foo(Struct *x); foo(Alias y)16void foo(Alias y) { 17 if (y.ptr == 0) { 18 // no-crash 19 } 20 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}} 21 } 22 void foobar(long z); foobar(Alias z)23void foobar(Alias z) { 24 if (z.num != 42) { 25 // no-crash 26 } 27 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}} 28 } 29 foobaz(Alias x)30void foobaz(Alias x) { 31 if (x.ptr == 0) { 32 // no-crash 33 } 34 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}} 35 } bar(Struct arg)36void bar(Struct arg) { 37 foo(&arg); 38 foobar(42); 39 foobaz(&arg); 40 } 41