// RUN: clang -checker-simple -verify %s

struct FPRec {
  void (*my_func)(int * x);  
};

int bar(int x);

int f1_a(struct FPRec* foo) {
  int x;
  (*foo->my_func)(&x);
  return bar(x)+1; // no-warning
}

int f1_b() {
  int x;
  return bar(x)+1;  // expected-warning{{Pass-by-value argument in function is undefined.}}
}

int f2() {
  
  int x;
  
  if (x+1)  // expected-warning{{Branch}}
    return 1;
    
  return 2;  
}

int f2_b() {
  int x;
  
  return ((x+1)+2+((x))) + 1 ? 1 : 2; // expected-warning{{Branch}}
}

int f3(void) {
  int i;
  int *p = &i;
  if (*p > 0) // expected-warning{{Branch condition evaluates to an uninitialized value}}
    return 0;
  else
    return 1;
}

// RUN: clang -checker-simple -analyzer-store-region -verify %s

struct s {
  int data;
};

struct s global;

void g(int);

void f4() {
  int a;
  if (global.data == 0)
    a = 3;
  if (global.data == 0)
    g(a); // no-warning
}

// RUN: clang -checker-simple -verify %s

struct FPRec {
  void (*my_func)(int * x);  
};

int bar(int x);

int f1_a(struct FPRec* foo) {
  int x;
  (*foo->my_func)(&x);
  return bar(x)+1; // no-warning
}

int f1_b() {
  int x;
  return bar(x)+1;  // expected-warning{{Pass-by-value argument in function is undefined.}}
}

int f2() {
  
  int x;
  
  if (x+1)  // expected-warning{{Branch}}
    return 1;
    
  return 2;  
}

int f2_b() {
  int x;
  
  return ((x+1)+2+((x))) + 1 ? 1 : 2; // expected-warning{{Branch}}
}

int f3(void) {
  int i;
  int *p = &i;
  if (*p > 0) // expected-warning{{Branch condition evaluates to an uninitialized value}}
    return 0;
  else
    return 1;
}

--- 
+++ 
@@ -41,3 +41,21 @@
   else
     return 1;
 }
+
+// RUN: clang -checker-simple -analyzer-store-region -verify %s
+
+struct s {
+  int data;
+};
+
+struct s global;
+
+void g(int);
+
+void f4() {
+  int a;
+  if (global.data == 0)
+    a = 3;
+  if (global.data == 0)
+    g(a); // no-warning
+}
Add test for path-sensitive uninit-val detection involving struct field.

git-svn-id: ffe668792ed300d6c2daa1f6eba2e0aa28d7ec6c@59620 91177308-0d34-0410-b5e6-96231b3b80d8
