[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Analysis / transparent_union_bug.c
blob5f8a5a4a706ec272b5f2cb19032cba32a7bdb473
1 // RUN: %clang_analyze_cc1 -analyze -triple x86_64-apple-darwin10 \
2 // RUN: -analyzer-checker=core,debug.ExprInspection -verify %s
4 void clang_analyzer_warnIfReached(void);
6 typedef struct {
7 int value;
8 } Struct;
10 typedef union {
11 Struct *ptr;
12 long num;
13 } __attribute__((transparent_union)) Alias;
15 void foo(Struct *x);
16 void foo(Alias y) {
17 if (y.ptr == 0) {
18 // no-crash
20 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
22 void foobar(long z);
23 void foobar(Alias z) {
24 if (z.num != 42) {
25 // no-crash
27 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
30 void foobaz(Alias x) {
31 if (x.ptr == 0) {
32 // no-crash
34 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
36 void bar(Struct arg) {
37 foo(&arg);
38 foobar(42);
39 foobaz(&arg);