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

int* f1() {
  int x = 0;
  return &x; // expected-warning{{Address of stack memory associated with local variable 'x' returned.}} expected-warning{{address of stack memory associated with local variable 'x' returned}}
}

int* f2(int y) {
  return &y;  // expected-warning{{Address of stack memory associated with local variable 'y' returned.}} expected-warning{{address of stack memory associated with local variable 'y' returned}}
}

int* f3(int x, int *y) {
  int w = 0;
  
  if (x)
    y = &w;
    
  return y; // expected-warning{{Address of stack memory associated with local variable 'w' returned.}}
}

void* compound_literal(int x) {
  if (x)
    return &(unsigned short){((unsigned short)0x22EF)}; // expected-warning{{Address of stack memory}} expected-warning{{braces around scalar initializer}}
  
  struct s { int z; double y; int w; };
  return &((struct s){ 2, 0.4, 5 * 8 });
}


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

int* f1() {
  int x = 0;
  return &x; // expected-warning{{Address of stack memory associated with local variable 'x' returned.}} expected-warning{{address of stack memory associated with local variable 'x' returned}}
}

int* f2(int y) {
  return &y;  // expected-warning{{Address of stack memory associated with local variable 'y' returned.}} expected-warning{{address of stack memory associated with local variable 'y' returned}}
}

int* f3(int x, int *y) {
  int w = 0;
  
  if (x)
    y = &w;
    
  return y; // expected-warning{{Address of stack memory associated with local variable 'w' returned.}}
}

unsigned short* compound_literal() {
  return &(unsigned short){((unsigned short)0x22EF)}; // expected-warning{{Address of stack memory}} expected-warning{{braces around scalar initializer}}
}


--- 
+++ 
@@ -18,7 +18,11 @@
   return y; // expected-warning{{Address of stack memory associated with local variable 'w' returned.}}
 }
 
-unsigned short* compound_literal() {
-  return &(unsigned short){((unsigned short)0x22EF)}; // expected-warning{{Address of stack memory}} expected-warning{{braces around scalar initializer}}
+void* compound_literal(int x) {
+  if (x)
+    return &(unsigned short){((unsigned short)0x22EF)}; // expected-warning{{Address of stack memory}} expected-warning{{braces around scalar initializer}}
+  
+  struct s { int z; double y; int w; };
+  return &((struct s){ 2, 0.4, 5 * 8 });
 }
 
Improve compound literal test case.


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