xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/ambiguous-builtin-unary-operator.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc struct A {
4*f4a2713aSLionel Sambuc   operator int&();
5*f4a2713aSLionel Sambuc   operator long*& ();
6*f4a2713aSLionel Sambuc };
7*f4a2713aSLionel Sambuc 
8*f4a2713aSLionel Sambuc struct B {
9*f4a2713aSLionel Sambuc   operator long&();
10*f4a2713aSLionel Sambuc   operator int*& ();
11*f4a2713aSLionel Sambuc };
12*f4a2713aSLionel Sambuc 
13*f4a2713aSLionel Sambuc struct C : B, A { };
14*f4a2713aSLionel Sambuc 
test(C c)15*f4a2713aSLionel Sambuc void test(C c) {
16*f4a2713aSLionel Sambuc   ++c; // expected-error {{use of overloaded operator '++' is ambiguous}}\
17*f4a2713aSLionel Sambuc        // expected-note {{built-in candidate operator++(int &)}} \
18*f4a2713aSLionel Sambuc        // expected-note {{built-in candidate operator++(long &)}} \
19*f4a2713aSLionel Sambuc        // expected-note {{built-in candidate operator++(long *&)}} \
20*f4a2713aSLionel Sambuc        // expected-note {{built-in candidate operator++(int *&)}}
21*f4a2713aSLionel Sambuc }
22*f4a2713aSLionel Sambuc 
23*f4a2713aSLionel Sambuc struct A1 { operator volatile int&(); };
24*f4a2713aSLionel Sambuc 
25*f4a2713aSLionel Sambuc struct B1 { operator volatile long&(); };
26*f4a2713aSLionel Sambuc 
27*f4a2713aSLionel Sambuc struct C1 : B1, A1 { };
28*f4a2713aSLionel Sambuc 
test(C1 c)29*f4a2713aSLionel Sambuc void test(C1 c) {
30*f4a2713aSLionel Sambuc   ++c;	// expected-error {{use of overloaded operator '++' is ambiguous}} \
31*f4a2713aSLionel Sambuc 	// expected-note {{built-in candidate operator++(volatile int &)}} \
32*f4a2713aSLionel Sambuc 	// expected-note {{built-in candidate operator++(volatile long &)}}
33*f4a2713aSLionel Sambuc }
34*f4a2713aSLionel Sambuc 
35