| 1 |
// RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 |
typedef int INT; |
| 3 |
|
| 4 |
class Foo { |
| 5 |
Foo(); |
| 6 |
(Foo)(float) { } |
| 7 |
explicit Foo(int); // expected-note {{previous declaration is here}} |
| 8 |
Foo(const Foo&); |
| 9 |
|
| 10 |
((Foo))(INT); // expected-error{{cannot be redeclared}} |
| 11 |
|
| 12 |
Foo(Foo foo, int i = 17, int j = 42); // expected-error{{copy constructor must pass its first argument by reference}} |
| 13 |
|
| 14 |
static Foo(short, short); // expected-error{{constructor cannot be declared 'static'}} |
| 15 |
virtual Foo(double); // expected-error{{constructor cannot be declared 'virtual'}} |
| 16 |
Foo(long) const; // expected-error{{'const' qualifier is not allowed on a constructor}} |
| 17 |
|
| 18 |
int Foo(int, int); // expected-error{{constructor cannot have a return type}} |
| 19 |
|
| 20 |
volatile Foo(float); // expected-error{{constructor cannot have a return type}} |
| 21 |
}; |
| 22 |
|
| 23 |
Foo::Foo(const Foo&) { } |
| 24 |
|
| 25 |
typedef struct { |
| 26 |
int version; |
| 27 |
} Anon; |
| 28 |
extern const Anon anon; |
| 29 |
extern "C" const Anon anon2; |
| 30 |
|
| 31 |
// PR3188: The extern declaration complained about not having an appropriate |
| 32 |
// constructor. |
| 33 |
struct x; |
| 34 |
extern x a; |
| 35 |
|
| 36 |
// A similar case. |
| 37 |
struct y { |
| 38 |
y(int); |
| 39 |
}; |
| 40 |
extern y b; |
| 41 |
|
| 42 |
struct Length { |
| 43 |
Length l() const { return *this; } |
| 44 |
}; |
| 45 |
|
| 46 |
struct mmst_reg{ |
| 47 |
char mmst_reg[10]; |
| 48 |
}; |
| 49 |
|
| 50 |
// PR3948 |
| 51 |
namespace PR3948 { |
| 52 |
// PR3948 |
| 53 |
class a { |
| 54 |
public: |
| 55 |
int b(int a()); |
| 56 |
}; |
| 57 |
int x(); |
| 58 |
void y() { |
| 59 |
a z; z.b(x); |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
namespace A { |
| 64 |
struct S { |
| 65 |
S(); |
| 66 |
S(int); |
| 67 |
void f1(); |
| 68 |
void f2(); |
| 69 |
operator int (); |
| 70 |
~S(); |
| 71 |
}; |
| 72 |
} |
| 73 |
|
| 74 |
A::S::S() {} |
| 75 |
|
| 76 |
void A::S::f1() {} |
| 77 |
|
| 78 |
struct S {}; |
| 79 |
|
| 80 |
A::S::S(int) {} |
| 81 |
|
| 82 |
void A::S::f2() {} |
| 83 |
|
| 84 |
A::S::operator int() { return 1; } |
| 85 |
|
| 86 |
A::S::~S() {} |
| 87 |
|
| 88 |
namespace PR38286 { |
| 89 |
// FIXME: It'd be nice to give more consistent diagnostics for these cases |
| 90 |
// (but they're all failing for somewhat different reasons...). |
| 91 |
template<typename> struct A; |
| 92 |
template<typename T> A<T>::A() {} // expected-error {{incomplete type 'A' named in nested name specifier}} |
| 93 |
/*FIXME: needed to recover properly from previous error*/; |
| 94 |
template<typename> struct B; |
| 95 |
template<typename T> void B<T>::f() {} // expected-error {{out-of-line definition of 'f' from class 'PR38286::B<type-parameter-0-0>'}} |
| 96 |
template<typename> struct C; // expected-note {{non-type declaration found}} |
| 97 |
template<typename T> C<T>::~C() {} // expected-error {{identifier 'C' after '~' in destructor name does not name a type}} |
| 98 |
} |
| 99 |
|
| 100 |
namespace GH121706 { |
| 101 |
|
| 102 |
struct A { |
| 103 |
*&A(); // expected-error {{invalid constructor declaration}} |
| 104 |
}; |
| 105 |
|
| 106 |
struct B { |
| 107 |
*&&B(); // expected-error {{invalid constructor declaration}} |
| 108 |
}; |
| 109 |
|
| 110 |
struct C { |
| 111 |
*const C(); // expected-error {{invalid constructor declaration}} |
| 112 |
}; |
| 113 |
|
| 114 |
struct D { |
| 115 |
*const *D(); // expected-error {{invalid constructor declaration}} |
| 116 |
}; |
| 117 |
|
| 118 |
struct E { |
| 119 |
*E::*E(); // expected-error {{invalid constructor declaration}} |
| 120 |
}; |
| 121 |
|
| 122 |
struct F { |
| 123 |
*F::*const F(); // expected-error {{invalid constructor declaration}} |
| 124 |
}; |
| 125 |
|
| 126 |
struct G { |
| 127 |
****G(); // expected-error {{invalid constructor declaration}} |
| 128 |
}; |
| 129 |
|
| 130 |
struct H { |
| 131 |
**H(const H &); // expected-error {{invalid constructor declaration}} |
| 132 |
}; |
| 133 |
|
| 134 |
struct I { |
| 135 |
*I(I &&); // expected-error {{invalid constructor declaration}} |
| 136 |
}; |
| 137 |
|
| 138 |
struct J { |
| 139 |
*&(J)(); // expected-error {{invalid constructor declaration}} |
| 140 |
}; |
| 141 |
|
| 142 |
struct K { |
| 143 |
**&&(K)(); // expected-error {{invalid constructor declaration}} |
| 144 |
}; |
| 145 |
|
| 146 |
struct L { |
| 147 |
*L(L&& other); // expected-error {{invalid constructor declaration}} |
| 148 |
}; |
| 149 |
|
| 150 |
struct M { |
| 151 |
*M(M& other); // expected-error {{invalid constructor declaration}} |
| 152 |
}; |
| 153 |
|
| 154 |
struct N { |
| 155 |
int N(); // expected-error {{constructor cannot have a return type}} |
| 156 |
}; |
| 157 |
|
| 158 |
struct O { |
| 159 |
static O(); // expected-error {{constructor cannot be declared 'static'}} |
| 160 |
}; |
| 161 |
|
| 162 |
struct P { |
| 163 |
explicit P(); |
| 164 |
}; |
| 165 |
|
| 166 |
struct Q { |
| 167 |
constexpr Q(); |
| 168 |
}; |
| 169 |
|
| 170 |
struct R { |
| 171 |
R(); |
| 172 |
friend R::R(); |
| 173 |
}; |
| 174 |
|
| 175 |
} |