xref: /llvm-project/clang/test/SemaTemplate/equivalence.cpp (revision 7f0ef7f304b1b91694f14e5c9c10de2aa6f38c95)
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 
3 // Ensure we undo the rewrite from `a++` to a binary `a ++ 0` before profiling.
4 namespace PostIncDec {
5   // Increment / decrement as UnaryOperator.
inc(T & a)6   template<typename T> auto inc(T &a) -> decltype(a++) {} // expected-note {{previous}}
dec(T & a)7   template<typename T> auto dec(T &a) -> decltype(a--) {} // expected-note {{previous}}
8 
9   struct X {};
10   void operator++(X&, int);
11   void operator--(X&, int);
12   // Increment / decrement as CXXOverloadedCallExpr. These are redefinitions.
inc(T & a)13   template<typename T> auto inc(T &a) -> decltype(a++) {} // expected-error {{redefinition}} expected-note {{candidate}}
dec(T & a)14   template<typename T> auto dec(T &a) -> decltype(a--) {} // expected-error {{redefinition}} expected-note {{candidate}}
15 
16   // These are not ambiguous calls.
f(X x)17   void f(X x) {
18     // FIXME: Don't produce these follow-on errors.
19     inc(x); // expected-error {{no match}}
20     dec(x); // expected-error {{no match}}
21   }
22 }
23