blob: a34ee4fcb024f91ced41569c77962dfb3e062451 [file] [log] [blame]
Richard Smith762bb9d2011-10-13 22:29:44 +00001// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
Sean Hunt059ce0d2011-05-01 07:04:31 +00002
3struct foo {
4 int i;
5 foo();
6 foo(int);
7 foo(int, int);
8 foo(bool);
9 foo(char);
Sean Huntb76af9c2011-05-03 23:05:34 +000010 foo(const float*);
11 foo(const float&);
12 foo(void*);
Sean Hunt059ce0d2011-05-01 07:04:31 +000013};
14
15// Good
16foo::foo (int i) : i(i) {
17}
18// Good
19foo::foo () : foo(-1) {
20}
21// Good
22foo::foo (int, int) : foo() {
23}
24
Sean Huntfe57eef2011-05-04 05:57:24 +000025foo::foo (bool) : foo(true) { // expected-error{{creates a delegation cycle}}
Sean Hunt059ce0d2011-05-01 07:04:31 +000026}
27
28// Good
Sean Huntfe57eef2011-05-04 05:57:24 +000029foo::foo (const float* f) : foo(*f) { // expected-note{{it delegates to}}
Sean Hunt059ce0d2011-05-01 07:04:31 +000030}
31
Sean Huntfe57eef2011-05-04 05:57:24 +000032foo::foo (const float &f) : foo(&f) { //expected-error{{creates a delegation cycle}} \
33 //expected-note{{which delegates to}}
Sean Hunt059ce0d2011-05-01 07:04:31 +000034}
35
Richard Smitha6ddea62012-09-14 18:21:10 +000036foo::foo (char) :
37 i(3),
38 foo(3) { // expected-error{{must appear alone}}
Sean Hunt059ce0d2011-05-01 07:04:31 +000039}
Sean Huntb76af9c2011-05-03 23:05:34 +000040
41// This should not cause an infinite loop
42foo::foo (void*) : foo(4.0f) {
43}
44
45struct deleted_dtor {
46 ~deleted_dtor() = delete; // expected-note{{function has been explicitly marked deleted here}}
47 deleted_dtor();
48 deleted_dtor(int) : deleted_dtor() // expected-error{{attempt to use a deleted function}}
49 {}
50};