xref: /aosp_15_r20/external/clang/test/SemaCXX/ref-init-ambiguous.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
2*67e74705SXin Li 
3*67e74705SXin Li enum E2 { };
4*67e74705SXin Li 
5*67e74705SXin Li struct A {
6*67e74705SXin Li   operator E2&(); // expected-note 3 {{candidate function}}
7*67e74705SXin Li };
8*67e74705SXin Li 
9*67e74705SXin Li struct B {
10*67e74705SXin Li   operator E2&(); // expected-note 3 {{candidate function}}
11*67e74705SXin Li };
12*67e74705SXin Li 
13*67e74705SXin Li struct C : B, A {
14*67e74705SXin Li };
15*67e74705SXin Li 
test(C c)16*67e74705SXin Li void test(C c) {
17*67e74705SXin Li   const E2 &e2 = c; // expected-error {{reference initialization of type 'const E2 &' with initializer of type 'C' is ambiguous}}
18*67e74705SXin Li }
19*67e74705SXin Li 
20*67e74705SXin Li void foo(const E2 &);// expected-note{{passing argument to parameter here}}
21*67e74705SXin Li 
re(C c)22*67e74705SXin Li const E2 & re(C c) {
23*67e74705SXin Li     foo(c); // expected-error {{reference initialization of type 'const E2 &' with initializer of type 'C' is ambiguous}}
24*67e74705SXin Li 
25*67e74705SXin Li     return c; // expected-error {{reference initialization of type 'const E2 &' with initializer of type 'C' is ambiguous}}
26*67e74705SXin Li }
27*67e74705SXin Li 
28*67e74705SXin Li 
29