• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -verify %s -std=c++11
2 
3 // A function that is explicitly defaulted shall
4 struct A {
5   // -- be a special member function,
6   A(int) = default; // expected-error {{only special member functions may be defaulted}}
7 
8   // -- have the same declared function type as if it had been implicitly
9   //    declared
10   void operator=(const A &) = default; // expected-error {{must return 'A &'}}
11   A(...) = default; // expected-error {{cannot be variadic}}
12   A(const A &, ...) = default; // expected-error {{cannot be variadic}}
13 
14   //    (except for possibly differing ref-qualifiers
15   A &operator=(A &&) & = default;
16 
17   //    and except that in the case of a copy constructor or copy assignment
18   //    operator, the parameter type may be "reference to non-const T")
19   A(A &) = default;
20   A &operator=(A &) = default;
21 
22   // -- not have default arguments
23   A(double = 0.0) = default; // expected-error {{cannot have default arguments}}
24   A(const A & = 0) = default; // expected-error {{cannot have default arguments}}
25 };
26