opnsense-src/test/SemaCXX/decl-init-ref.cpp

30 lines
948 B
C++
Raw Normal View History

2010-01-01 05:34:51 -05:00
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
2009-10-14 14:03:49 -04:00
2010-01-15 10:39:40 -05:00
struct A {}; // expected-note {{candidate is the implicit copy constructor}}
2009-10-14 14:03:49 -04: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-01-01 05:34:51 -05:00
const int& ri = (void)0; // expected-error {{reference to type 'int const' could not bind to an rvalue of type 'void'}}
2009-10-14 14:03:49 -04:00
int main() {
2010-01-01 05:34:51 -05:00
const A& rca = f(); // expected-error {{reference initialization of type 'struct A const &' with initializer of type 'class B' is ambiguous}}
2009-12-15 13:49:47 -05:00
A& ra = f(); // expected-error {{non-const lvalue reference to type 'struct A' cannot bind to a temporary of type 'class B'}}
2009-10-14 14:03:49 -04:00
}
2010-02-16 04:31:36 -05:00
struct PR6139 { A (&x)[1]; };
PR6139 x = {{A()}}; // expected-error{{non-const lvalue reference to type 'struct A [1]' cannot bind to a temporary of type 'struct A'}}