// RUN: %clang_cc1 -fsyntax-only -verify %s typedef __typeof__(((int*)0)-((int*)0)) ptrdiff_t; namespace DontResolveTooEarly_WaitForOverloadResolution { template T* f(int); // #1 template T& f(U); // #2 void g() { int *ip = f(1); // calls #1 } template T* f2(int); template T& f2(U); void g2() { int*ip = (f2)(1); // ok } } // End namespace template void twoT() { } template void twoT(T) { } void two() { }; //expected-note 5{{candidate}} void two(int) { }; //expected-note 5{{candidate}} void one() { } template void oneT() { } template void cant_resolve() { } //expected-note 3{{candidate}} template void cant_resolve(T) { }//expected-note 3{{candidate}} int main() { { static_cast(one); } { (void)(one); } { static_cast(oneT); } { (void)(oneT); } { static_cast(two); } // expected-error {{address of overloaded}} { (void)(two); } // expected-error {{address of overloaded}} { static_cast(twoT); } { (void)(twoT); } { ptrdiff_t x = reinterpret_cast(oneT); } { (void) reinterpret_cast(oneT); } { (void) reinterpret_cast(one); } { (void) reinterpret_cast(one); } { ptrdiff_t x = reinterpret_cast(twoT); } { (void) reinterpret_cast(twoT); } { (void) reinterpret_cast(two); } //expected-error {{reinterpret_cast}} { (void) static_cast(two); } //ok { (void) reinterpret_cast(two); } //expected-error {{reinterpret_cast}} { (void) reinterpret_cast(two); } //expected-error {{reinterpret_cast}} { bool b = (twoT); } // ok { bool b = (twoT); } //ok { bool b = &twoT; //&foo; } b = &(twoT); } { ptrdiff_t x = (ptrdiff_t) &twoT; x = (ptrdiff_t) &twoT; } { ptrdiff_t x = (ptrdiff_t) twoT; x = (ptrdiff_t) twoT; } { ptrdiff_t x = (ptrdiff_t) &twoT; x = (ptrdiff_t) &twoT; } { oneT; &oneT; } //expected-warning 2{{ expression result unused }} { static_cast(cant_resolve); } // expected-error {{address of overload}} { bool b = cant_resolve; } // expected-error {{address of overload}} { (void) cant_resolve; } // expected-error {{address of overload}} }