2014-09-25 09:15:40 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -Wno-uninitialized
|
2009-09-24 04:55:32 +08:00
|
|
|
|
2011-01-25 00:14:37 +08:00
|
|
|
struct A {};
|
2009-09-24 04:55:32 +08:00
|
|
|
|
|
|
|
struct BASE {
|
|
|
|
operator A(); // expected-note {{candidate function}}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct BASE1 {
|
|
|
|
operator A(); // expected-note {{candidate function}}
|
|
|
|
};
|
|
|
|
|
|
|
|
class B : public BASE , public BASE1
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
B();
|
|
|
|
} b;
|
|
|
|
|
|
|
|
extern B f();
|
|
|
|
|
2010-09-05 08:04:01 +08:00
|
|
|
const int& ri = (void)0; // expected-error {{reference to type 'const int' could not bind to an rvalue of type 'void'}}
|
2009-10-01 05:23:30 +08:00
|
|
|
|
2009-09-24 04:55:32 +08:00
|
|
|
int main() {
|
2010-09-05 08:17:29 +08:00
|
|
|
const A& rca = f(); // expected-error {{reference initialization of type 'const A &' with initializer of type 'B' is ambiguous}}
|
2010-03-10 19:27:22 +08:00
|
|
|
A& ra = f(); // expected-error {{non-const lvalue reference to type 'A' cannot bind to a temporary of type 'B'}}
|
2009-09-24 04:55:32 +08:00
|
|
|
}
|
2010-02-09 08:50:06 +08:00
|
|
|
|
2010-02-09 09:02:53 +08:00
|
|
|
struct PR6139 { A (&x)[1]; };
|
2013-05-31 10:56:17 +08:00
|
|
|
PR6139 x = {{A()}}; // expected-error{{non-const lvalue reference to type 'A [1]' cannot bind to an initializer list temporary}}
|
|
|
|
|
|
|
|
struct PR6139b { A (&x)[1]; };
|
|
|
|
PR6139b y = {A()}; // expected-error{{non-const lvalue reference to type 'A [1]' cannot bind to a temporary of type 'A'}}
|
2013-07-01 14:08:20 +08:00
|
|
|
|
|
|
|
namespace PR16502 {
|
|
|
|
struct A { int &&temporary; int x, y; };
|
|
|
|
int f();
|
|
|
|
const A &c = { 10, ++c.temporary };
|
|
|
|
}
|