Home | History | Annotate | Download | only in class.temporary
      1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
      2 
      3 namespace test0 {
      4   struct A {
      5     A() = default;
      6     int x;
      7     int y;
      8 
      9     A(const A&) = delete; // expected-note {{'A' has been explicitly marked deleted here}}
     10   };
     11 
     12   void foo(...);
     13 
     14   void test() {
     15     A a;
     16     foo(a); // expected-error {{call to deleted constructor of 'test0::A'}}
     17   }
     18 }
     19 
     20 namespace test1 {
     21   struct A {
     22     A() = default;
     23     int x;
     24     int y;
     25 
     26   private:
     27     A(const A&) = default; // expected-note {{declared private here}}
     28   };
     29 
     30   void foo(...);
     31 
     32   void test() {
     33     A a;
     34     foo(a); // expected-error {{calling a private constructor of class 'test1::A'}}
     35   }
     36 }
     37 
     38 // Don't enforce this in an unevaluated context.
     39 namespace test2 {
     40   struct A {
     41     A(const A&) = delete; // expected-note {{marked deleted here}}
     42   };
     43 
     44   typedef char one[1];
     45   typedef char two[2];
     46 
     47   one &meta(bool);
     48   two &meta(...);
     49 
     50   void a(A &a) {
     51     char check[sizeof(meta(a)) == 2 ? 1 : -1];
     52   }
     53 
     54   void b(A &a) {
     55     meta(a); // expected-error {{call to deleted constructor}}
     56   }
     57 }
     58