blob: 42b9286852c7521fcb83b82c3236df193dc57c0d [file] [log] [blame]
Stephen Hines176edba2014-12-01 14:53:08 -08001// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -Wno-uninitialized
Fariborz Jahanian51bebc82009-09-23 20:55:32 +00002
Douglas Gregor8dde14e2011-01-24 16:14:37 +00003struct A {};
Fariborz Jahanian51bebc82009-09-23 20:55:32 +00004
5struct BASE {
6 operator A(); // expected-note {{candidate function}}
7};
8
9struct BASE1 {
10 operator A(); // expected-note {{candidate function}}
11};
12
13class B : public BASE , public BASE1
14{
15 public:
16 B();
17} b;
18
19extern B f();
20
Chris Lattner58f9e132010-09-05 00:04:01 +000021const int& ri = (void)0; // expected-error {{reference to type 'const int' could not bind to an rvalue of type 'void'}}
Fariborz Jahanian893f9552009-09-30 21:23:30 +000022
Fariborz Jahanian51bebc82009-09-23 20:55:32 +000023int main() {
Chris Lattner0c42bb62010-09-05 00:17:29 +000024 const A& rca = f(); // expected-error {{reference initialization of type 'const A &' with initializer of type 'B' is ambiguous}}
John McCall7c2342d2010-03-10 11:27:22 +000025 A& ra = f(); // expected-error {{non-const lvalue reference to type 'A' cannot bind to a temporary of type 'B'}}
Fariborz Jahanian51bebc82009-09-23 20:55:32 +000026}
Douglas Gregor2c792812010-02-09 00:50:06 +000027
Douglas Gregore180ed22010-02-09 01:02:53 +000028struct PR6139 { A (&x)[1]; };
Richard Smith6242a452013-05-31 02:56:17 +000029PR6139 x = {{A()}}; // expected-error{{non-const lvalue reference to type 'A [1]' cannot bind to an initializer list temporary}}
30
31struct PR6139b { A (&x)[1]; };
32PR6139b y = {A()}; // expected-error{{non-const lvalue reference to type 'A [1]' cannot bind to a temporary of type 'A'}}
Richard Smith3c3af142013-07-01 06:08:20 +000033
34namespace PR16502 {
35 struct A { int &&temporary; int x, y; };
36 int f();
37 const A &c = { 10, ++c.temporary };
38}