Home | History | Annotate | Download | only in SemaCXX
      1 // RUN: %clang_cc1 -fsyntax-only -verify %s -fblocks -std=c++11
      2 // expected-no-diagnostics
      3 
      4 extern "C" int exit(int);
      5 
      6 typedef struct {
      7     unsigned long ps[30];
      8     int qs[30];
      9 } BobTheStruct;
     10 
     11 int main (int argc, const char * argv[]) {
     12     BobTheStruct inny;
     13     BobTheStruct outty;
     14     BobTheStruct (^copyStruct)(BobTheStruct);
     15     int i;
     16 
     17     for(i=0; i<30; i++) {
     18         inny.ps[i] = i * i * i;
     19         inny.qs[i] = -i * i * i;
     20     }
     21 
     22     copyStruct = ^(BobTheStruct aBigStruct){ return aBigStruct; };  // pass-by-value intrinsically copies the argument
     23 
     24     outty = copyStruct(inny);
     25 
     26     if ( &inny == &outty ) {
     27         exit(1);
     28     }
     29     for(i=0; i<30; i++) {
     30         if ( (inny.ps[i] != outty.ps[i]) || (inny.qs[i] != outty.qs[i]) ) {
     31             exit(1);
     32         }
     33     }
     34 
     35     return 0;
     36 }
     37 
     38 namespace rdar8134521 {
     39   void foo() {
     40     int (^P)(int) = reinterpret_cast<int(^)(int)>(1);
     41     P = (int(^)(int))(1);
     42 
     43     P = reinterpret_cast<int(^)(int)>((void*)1);
     44     P = (int(^)(int))((void*)1);
     45   }
     46 }
     47 
     48 namespace rdar11055105 {
     49   struct A {
     50     void foo();
     51   };
     52 
     53   template <class T> void foo(T &x) noexcept(noexcept(x.foo()));
     54 
     55   void (^block)() = ^{
     56     A a;
     57     foo(a);
     58   };
     59 }
     60