xref: /llvm-project/clang/test/SemaCXX/decl-init-ref.cpp (revision 3e1e527826048b8ae3b9f597729fc888664a233c)
1 // RUN: clang-cc -fsyntax-only -verify -std=c++0x %s
2 
3 struct A {}; // expected-note {{candidate function}}
4 
5 struct BASE {
6   operator A(); // expected-note {{candidate function}}
7 };
8 
9 struct BASE1 {
10  operator A();  // expected-note {{candidate function}}
11 };
12 
13 class B : public BASE , public BASE1
14 {
15   public:
16   B();
17 } b;
18 
19 extern B f();
20 
21 const int& ri = (void)0; // expected-error {{invalid initialization of reference of type 'int const &' from expression of type 'void'}}
22 
23 int main() {
24         const A& rca = f(); // expected-error {{conversion from 'class B' to 'struct A const' is ambiguous}}
25         A& ra = f(); // expected-error {{non-const lvalue reference to type 'struct A' cannot bind to a temporary of type 'class B'}}
26 }
27