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