1762bb9d0ad20320b9f97a841dce57ba5e8e48b07Richard Smith// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s 21d79faf915cc01739664c3817220ed25ad08a367Anders Carlsson 31d79faf915cc01739664c3817220ed25ad08a367Anders Carlssontypedef double A; 41d79faf915cc01739664c3817220ed25ad08a367Anders Carlssontemplate<typename T> class B { 51d79faf915cc01739664c3817220ed25ad08a367Anders Carlsson typedef int A; 61d79faf915cc01739664c3817220ed25ad08a367Anders Carlsson}; 71d79faf915cc01739664c3817220ed25ad08a367Anders Carlsson 81d79faf915cc01739664c3817220ed25ad08a367Anders Carlssontemplate<typename T> struct X : B<T> { 91d79faf915cc01739664c3817220ed25ad08a367Anders Carlsson static A a; 101d79faf915cc01739664c3817220ed25ad08a367Anders Carlsson}; 111d79faf915cc01739664c3817220ed25ad08a367Anders Carlsson 121d79faf915cc01739664c3817220ed25ad08a367Anders Carlssonint a0[sizeof(X<int>::a) == sizeof(double) ? 1 : -1]; 131d79faf915cc01739664c3817220ed25ad08a367Anders Carlsson 141d79faf915cc01739664c3817220ed25ad08a367Anders Carlsson// PR4365. 151d79faf915cc01739664c3817220ed25ad08a367Anders Carlssontemplate<class T> class Q; 161d79faf915cc01739664c3817220ed25ad08a367Anders Carlssontemplate<class T> class R : Q<T> {T current;}; 1726416068d3eb883a280fdceeffa74fffc9131031John McCall 1826416068d3eb883a280fdceeffa74fffc9131031John McCall 1926416068d3eb883a280fdceeffa74fffc9131031John McCallnamespace test0 { 2026416068d3eb883a280fdceeffa74fffc9131031John McCall template <class T> class Base { 217002f4c03c2d0544f4e8bea8d3a5636519081e35John McCall public: 2226416068d3eb883a280fdceeffa74fffc9131031John McCall void instance_foo(); 2326416068d3eb883a280fdceeffa74fffc9131031John McCall static void static_foo(); 2426416068d3eb883a280fdceeffa74fffc9131031John McCall class Inner { 257002f4c03c2d0544f4e8bea8d3a5636519081e35John McCall public: 2626416068d3eb883a280fdceeffa74fffc9131031John McCall void instance_foo(); 2726416068d3eb883a280fdceeffa74fffc9131031John McCall static void static_foo(); 2826416068d3eb883a280fdceeffa74fffc9131031John McCall }; 2926416068d3eb883a280fdceeffa74fffc9131031John McCall }; 3026416068d3eb883a280fdceeffa74fffc9131031John McCall 3126416068d3eb883a280fdceeffa74fffc9131031John McCall template <class T> class Derived1 : Base<T> { 327002f4c03c2d0544f4e8bea8d3a5636519081e35John McCall public: 3326416068d3eb883a280fdceeffa74fffc9131031John McCall void test0() { 3426416068d3eb883a280fdceeffa74fffc9131031John McCall Base<T>::static_foo(); 3526416068d3eb883a280fdceeffa74fffc9131031John McCall Base<T>::instance_foo(); 3626416068d3eb883a280fdceeffa74fffc9131031John McCall } 3726416068d3eb883a280fdceeffa74fffc9131031John McCall 3826416068d3eb883a280fdceeffa74fffc9131031John McCall void test1() { 3926416068d3eb883a280fdceeffa74fffc9131031John McCall Base<T>::Inner::static_foo(); 4026416068d3eb883a280fdceeffa74fffc9131031John McCall Base<T>::Inner::instance_foo(); // expected-error {{call to non-static member function without an object argument}} 4126416068d3eb883a280fdceeffa74fffc9131031John McCall } 4226416068d3eb883a280fdceeffa74fffc9131031John McCall 4326416068d3eb883a280fdceeffa74fffc9131031John McCall static void test2() { 4426416068d3eb883a280fdceeffa74fffc9131031John McCall Base<T>::static_foo(); 4526416068d3eb883a280fdceeffa74fffc9131031John McCall Base<T>::instance_foo(); // expected-error {{call to non-static member function without an object argument}} 4626416068d3eb883a280fdceeffa74fffc9131031John McCall } 4726416068d3eb883a280fdceeffa74fffc9131031John McCall 4826416068d3eb883a280fdceeffa74fffc9131031John McCall static void test3() { 4926416068d3eb883a280fdceeffa74fffc9131031John McCall Base<T>::Inner::static_foo(); 5026416068d3eb883a280fdceeffa74fffc9131031John McCall Base<T>::Inner::instance_foo(); // expected-error {{call to non-static member function without an object argument}} 5126416068d3eb883a280fdceeffa74fffc9131031John McCall } 5226416068d3eb883a280fdceeffa74fffc9131031John McCall }; 5326416068d3eb883a280fdceeffa74fffc9131031John McCall 5426416068d3eb883a280fdceeffa74fffc9131031John McCall template <class T> class Derived2 : Base<T>::Inner { 557002f4c03c2d0544f4e8bea8d3a5636519081e35John McCall public: 5626416068d3eb883a280fdceeffa74fffc9131031John McCall void test0() { 5726416068d3eb883a280fdceeffa74fffc9131031John McCall Base<T>::static_foo(); 5826416068d3eb883a280fdceeffa74fffc9131031John McCall Base<T>::instance_foo(); // expected-error {{call to non-static member function without an object argument}} 5926416068d3eb883a280fdceeffa74fffc9131031John McCall } 6026416068d3eb883a280fdceeffa74fffc9131031John McCall 6126416068d3eb883a280fdceeffa74fffc9131031John McCall void test1() { 6226416068d3eb883a280fdceeffa74fffc9131031John McCall Base<T>::Inner::static_foo(); 6326416068d3eb883a280fdceeffa74fffc9131031John McCall Base<T>::Inner::instance_foo(); 6426416068d3eb883a280fdceeffa74fffc9131031John McCall } 6526416068d3eb883a280fdceeffa74fffc9131031John McCall 6626416068d3eb883a280fdceeffa74fffc9131031John McCall static void test2() { 6726416068d3eb883a280fdceeffa74fffc9131031John McCall Base<T>::static_foo(); 6826416068d3eb883a280fdceeffa74fffc9131031John McCall Base<T>::instance_foo(); // expected-error {{call to non-static member function without an object argument}} 6926416068d3eb883a280fdceeffa74fffc9131031John McCall } 7026416068d3eb883a280fdceeffa74fffc9131031John McCall 7126416068d3eb883a280fdceeffa74fffc9131031John McCall static void test3() { 7226416068d3eb883a280fdceeffa74fffc9131031John McCall Base<T>::Inner::static_foo(); 7326416068d3eb883a280fdceeffa74fffc9131031John McCall Base<T>::Inner::instance_foo(); // expected-error {{call to non-static member function without an object argument}} 7426416068d3eb883a280fdceeffa74fffc9131031John McCall } 7526416068d3eb883a280fdceeffa74fffc9131031John McCall }; 7626416068d3eb883a280fdceeffa74fffc9131031John McCall 7726416068d3eb883a280fdceeffa74fffc9131031John McCall void test0() { 7826416068d3eb883a280fdceeffa74fffc9131031John McCall Derived1<int> d1; 7926416068d3eb883a280fdceeffa74fffc9131031John McCall d1.test0(); 8026416068d3eb883a280fdceeffa74fffc9131031John McCall d1.test1(); // expected-note {{in instantiation of member function}} 8126416068d3eb883a280fdceeffa74fffc9131031John McCall d1.test2(); // expected-note {{in instantiation of member function}} 8226416068d3eb883a280fdceeffa74fffc9131031John McCall d1.test3(); // expected-note {{in instantiation of member function}} 8326416068d3eb883a280fdceeffa74fffc9131031John McCall 8426416068d3eb883a280fdceeffa74fffc9131031John McCall Derived2<int> d2; 8526416068d3eb883a280fdceeffa74fffc9131031John McCall d2.test0(); // expected-note {{in instantiation of member function}} 8626416068d3eb883a280fdceeffa74fffc9131031John McCall d2.test1(); 8726416068d3eb883a280fdceeffa74fffc9131031John McCall d2.test2(); // expected-note {{in instantiation of member function}} 8826416068d3eb883a280fdceeffa74fffc9131031John McCall d2.test3(); // expected-note {{in instantiation of member function}} 8926416068d3eb883a280fdceeffa74fffc9131031John McCall } 9026416068d3eb883a280fdceeffa74fffc9131031John McCall} 91578b69b186d9cba0a6ae1dd7f4c04cd6a49f0aacJohn McCall 92578b69b186d9cba0a6ae1dd7f4c04cd6a49f0aacJohn McCallnamespace test1 { 93578b69b186d9cba0a6ae1dd7f4c04cd6a49f0aacJohn McCall template <class T> struct Base { 94578b69b186d9cba0a6ae1dd7f4c04cd6a49f0aacJohn McCall void foo(T); // expected-note {{must qualify identifier to find this declaration in dependent base class}} 95578b69b186d9cba0a6ae1dd7f4c04cd6a49f0aacJohn McCall }; 96578b69b186d9cba0a6ae1dd7f4c04cd6a49f0aacJohn McCall 97578b69b186d9cba0a6ae1dd7f4c04cd6a49f0aacJohn McCall template <class T> struct Derived : Base<T> { 98578b69b186d9cba0a6ae1dd7f4c04cd6a49f0aacJohn McCall void doFoo(T v) { 993b4294e5c1e904a2e0f74449dbc3f52f69cc8e9fJohn McCall foo(v); // expected-error {{use of undeclared identifier}} 100578b69b186d9cba0a6ae1dd7f4c04cd6a49f0aacJohn McCall } 101578b69b186d9cba0a6ae1dd7f4c04cd6a49f0aacJohn McCall }; 102578b69b186d9cba0a6ae1dd7f4c04cd6a49f0aacJohn McCall 103578b69b186d9cba0a6ae1dd7f4c04cd6a49f0aacJohn McCall template struct Derived<int>; // expected-note {{requested here}} 104578b69b186d9cba0a6ae1dd7f4c04cd6a49f0aacJohn McCall} 1052f9f89c6938a788a904c3be3ae7a64f4297c90a6Douglas Gregor 1062f9f89c6938a788a904c3be3ae7a64f4297c90a6Douglas Gregornamespace PR8966 { 1072f9f89c6938a788a904c3be3ae7a64f4297c90a6Douglas Gregor template <class T> 1082f9f89c6938a788a904c3be3ae7a64f4297c90a6Douglas Gregor class MyClassCore 1092f9f89c6938a788a904c3be3ae7a64f4297c90a6Douglas Gregor { 1102f9f89c6938a788a904c3be3ae7a64f4297c90a6Douglas Gregor }; 1112f9f89c6938a788a904c3be3ae7a64f4297c90a6Douglas Gregor 1122f9f89c6938a788a904c3be3ae7a64f4297c90a6Douglas Gregor template <class T> 1132f9f89c6938a788a904c3be3ae7a64f4297c90a6Douglas Gregor class MyClass : public MyClassCore<T> 1142f9f89c6938a788a904c3be3ae7a64f4297c90a6Douglas Gregor { 1152f9f89c6938a788a904c3be3ae7a64f4297c90a6Douglas Gregor public: 1162f9f89c6938a788a904c3be3ae7a64f4297c90a6Douglas Gregor enum { 1172f9f89c6938a788a904c3be3ae7a64f4297c90a6Douglas Gregor N 1182f9f89c6938a788a904c3be3ae7a64f4297c90a6Douglas Gregor }; 1192f9f89c6938a788a904c3be3ae7a64f4297c90a6Douglas Gregor 1202f9f89c6938a788a904c3be3ae7a64f4297c90a6Douglas Gregor // static member declaration 1212f9f89c6938a788a904c3be3ae7a64f4297c90a6Douglas Gregor static const char* array [N]; 1222f9f89c6938a788a904c3be3ae7a64f4297c90a6Douglas Gregor 1232f9f89c6938a788a904c3be3ae7a64f4297c90a6Douglas Gregor void f() { 1242f9f89c6938a788a904c3be3ae7a64f4297c90a6Douglas Gregor MyClass<T>::InBase = 17; 1252f9f89c6938a788a904c3be3ae7a64f4297c90a6Douglas Gregor } 1262f9f89c6938a788a904c3be3ae7a64f4297c90a6Douglas Gregor }; 1272f9f89c6938a788a904c3be3ae7a64f4297c90a6Douglas Gregor 1282f9f89c6938a788a904c3be3ae7a64f4297c90a6Douglas Gregor // static member definition 1292f9f89c6938a788a904c3be3ae7a64f4297c90a6Douglas Gregor template <class T> 1302f9f89c6938a788a904c3be3ae7a64f4297c90a6Douglas Gregor const char* MyClass<T>::array [MyClass<T>::N] = { "A", "B", "C" }; 1312f9f89c6938a788a904c3be3ae7a64f4297c90a6Douglas Gregor} 132f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith 133f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smithnamespace std { 134f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith inline namespace v1 { 135f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith template<typename T> struct basic_ostream; 136f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith } 137f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith namespace inner { 138f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith template<typename T> struct vector {}; 139f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith } 140f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith using inner::vector; 141f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith template<typename T, typename U> struct pair {}; 142f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith typedef basic_ostream<char> ostream; 143f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith extern ostream cout; 144f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith std::ostream &operator<<(std::ostream &out, const char *); 145f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith} 146f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith 147f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smithnamespace PR10053 { 148f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith template<typename T> struct A { 149f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith T t; 150f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith A() { 1512a00b8347bdf0064cc106295a070c00669ded9a9Jay Foad f(t); // expected-error {{call to function 'f' that is neither visible in the template definition nor found by argument-dependent lookup}} 152f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith } 153f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith }; 154f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith 155f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith void f(int&); // expected-note {{'f' should be declared prior to the call site}} 156f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith 157f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith A<int> a; // expected-note {{in instantiation of member function}} 158f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith 159f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith 160f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith namespace N { 161f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith namespace M { 162f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith template<typename T> int g(T t) { 1632a00b8347bdf0064cc106295a070c00669ded9a9Jay Foad f(t); // expected-error {{call to function 'f' that is neither visible in the template definition nor found by argument-dependent lookup}} 164f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith }; 165f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith } 166f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith 167f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith void f(char&); // expected-note {{'f' should be declared prior to the call site}} 168f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith } 169f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith 170f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith void f(char&); 171f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith 172f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith int k = N::M::g<char>(0);; // expected-note {{in instantiation of function}} 173f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith 174f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith 175f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith namespace O { 176f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith void f(char&); // expected-note {{candidate function not viable}} 177f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith 178f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith template<typename T> struct C { 179f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith static const int n = f(T()); // expected-error {{no matching function}} 180f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith }; 181f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith } 182f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith 183f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith int f(double); // no note, shadowed by O::f 184f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith O::C<double> c; // expected-note {{requested here}} 185f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith 186f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith 187f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith // Example from www/compatibility.html 188f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith namespace my_file { 189f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith template <typename T> T Squared(T x) { 1902a00b8347bdf0064cc106295a070c00669ded9a9Jay Foad return Multiply(x, x); // expected-error {{neither visible in the template definition nor found by argument-dependent lookup}} 191f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith } 192f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith 193f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith int Multiply(int x, int y) { // expected-note {{should be declared prior to the call site}} 194f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith return x * y; 195f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith } 196f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith 197f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith int main() { 198f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith Squared(5); // expected-note {{here}} 199f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith } 200f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith } 201f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith 202f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith // Example from www/compatibility.html 203f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith namespace my_file2 { 204f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith template<typename T> 205f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith void Dump(const T& value) { 2062a00b8347bdf0064cc106295a070c00669ded9a9Jay Foad std::cout << value << "\n"; // expected-error {{neither visible in the template definition nor found by argument-dependent lookup}} 207f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith } 208f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith 209f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith namespace ns { 210f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith struct Data {}; 211f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith } 212f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith 213f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith std::ostream& operator<<(std::ostream& out, ns::Data data) { // expected-note {{should be declared prior to the call site or in namespace 'PR10053::my_file2::ns'}} 214f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith return out << "Some data"; 215f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith } 216f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith 217f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith void Use() { 218f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith Dump(ns::Data()); // expected-note {{here}} 219f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith } 220f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith } 221f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith 222f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith namespace my_file2_a { 223f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith template<typename T> 224f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith void Dump(const T &value) { 2252a00b8347bdf0064cc106295a070c00669ded9a9Jay Foad print(std::cout, value); // expected-error 4{{neither visible in the template definition nor found by argument-dependent lookup}} 226f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith } 227f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith 228f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith namespace ns { 229f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith struct Data {}; 230f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith } 231f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith namespace ns2 { 232f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith struct Data {}; 233f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith } 234f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith 235651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines std::ostream &print(std::ostream &out, int); // expected-note-re {{should be declared prior to the call site{{$}}}} 236f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith std::ostream &print(std::ostream &out, ns::Data); // expected-note {{should be declared prior to the call site or in namespace 'PR10053::my_file2_a::ns'}} 237f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith std::ostream &print(std::ostream &out, std::vector<ns2::Data>); // expected-note {{should be declared prior to the call site or in namespace 'PR10053::my_file2_a::ns2'}} 238f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith std::ostream &print(std::ostream &out, std::pair<ns::Data, ns2::Data>); // expected-note {{should be declared prior to the call site or in an associated namespace of one of its arguments}} 239f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith 240f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith void Use() { 241f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith Dump(0); // expected-note {{requested here}} 242f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith Dump(ns::Data()); // expected-note {{requested here}} 243f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith Dump(std::vector<ns2::Data>()); // expected-note {{requested here}} 244f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith Dump(std::pair<ns::Data, ns2::Data>()); // expected-note {{requested here}} 245f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith } 246f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith } 247f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith 248f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith namespace unary { 249f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith template<typename T> 250f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith T Negate(const T& value) { 2512a00b8347bdf0064cc106295a070c00669ded9a9Jay Foad return !value; // expected-error {{call to function 'operator!' that is neither visible in the template definition nor found by argument-dependent lookup}} 252f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith } 253f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith 254f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith namespace ns { 255f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith struct Data {}; 256f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith } 257f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith 258f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith ns::Data operator!(ns::Data); // expected-note {{should be declared prior to the call site or in namespace 'PR10053::unary::ns'}} 259f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith 260f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith void Use() { 261f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith Negate(ns::Data()); // expected-note {{requested here}} 262f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith } 263f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith } 264f50e88a793dd5bc7073c717fec78912e3234e95aRichard Smith} 2652ced044c34311d8e6301f2b4566f4b612bc8b628Richard Smith 2662ced044c34311d8e6301f2b4566f4b612bc8b628Richard Smithnamespace PR10187 { 267dc7a4f5d7a7e3b60d4dc4a80338d7a2728540998Richard Smith namespace A1 { 2682ced044c34311d8e6301f2b4566f4b612bc8b628Richard Smith template<typename T> 2692ced044c34311d8e6301f2b4566f4b612bc8b628Richard Smith struct S { 2702ced044c34311d8e6301f2b4566f4b612bc8b628Richard Smith void f() { 2712ced044c34311d8e6301f2b4566f4b612bc8b628Richard Smith for (auto &a : e) 2722ced044c34311d8e6301f2b4566f4b612bc8b628Richard Smith __range(a); // expected-error {{undeclared identifier '__range'}} 2732ced044c34311d8e6301f2b4566f4b612bc8b628Richard Smith } 2742ced044c34311d8e6301f2b4566f4b612bc8b628Richard Smith int e[10]; 2752ced044c34311d8e6301f2b4566f4b612bc8b628Richard Smith }; 2762ced044c34311d8e6301f2b4566f4b612bc8b628Richard Smith void g() { 2772ced044c34311d8e6301f2b4566f4b612bc8b628Richard Smith S<int>().f(); // expected-note {{here}} 2782ced044c34311d8e6301f2b4566f4b612bc8b628Richard Smith } 2792ced044c34311d8e6301f2b4566f4b612bc8b628Richard Smith } 2802ced044c34311d8e6301f2b4566f4b612bc8b628Richard Smith 281dc7a4f5d7a7e3b60d4dc4a80338d7a2728540998Richard Smith namespace A2 { 282dc7a4f5d7a7e3b60d4dc4a80338d7a2728540998Richard Smith template<typename T> 283dc7a4f5d7a7e3b60d4dc4a80338d7a2728540998Richard Smith struct S { 284dc7a4f5d7a7e3b60d4dc4a80338d7a2728540998Richard Smith void f() { 285dc7a4f5d7a7e3b60d4dc4a80338d7a2728540998Richard Smith for (auto &a : e) 286dc7a4f5d7a7e3b60d4dc4a80338d7a2728540998Richard Smith __range(a); // expected-error {{undeclared identifier '__range'}} 287dc7a4f5d7a7e3b60d4dc4a80338d7a2728540998Richard Smith } 288dc7a4f5d7a7e3b60d4dc4a80338d7a2728540998Richard Smith T e[10]; 289dc7a4f5d7a7e3b60d4dc4a80338d7a2728540998Richard Smith }; 290dc7a4f5d7a7e3b60d4dc4a80338d7a2728540998Richard Smith void g() { 291dc7a4f5d7a7e3b60d4dc4a80338d7a2728540998Richard Smith S<int>().f(); // expected-note {{here}} 292dc7a4f5d7a7e3b60d4dc4a80338d7a2728540998Richard Smith } 293dc7a4f5d7a7e3b60d4dc4a80338d7a2728540998Richard Smith struct X {}; 294dc7a4f5d7a7e3b60d4dc4a80338d7a2728540998Richard Smith void __range(X); 295dc7a4f5d7a7e3b60d4dc4a80338d7a2728540998Richard Smith void h() { 296dc7a4f5d7a7e3b60d4dc4a80338d7a2728540998Richard Smith S<X>().f(); 297dc7a4f5d7a7e3b60d4dc4a80338d7a2728540998Richard Smith } 298dc7a4f5d7a7e3b60d4dc4a80338d7a2728540998Richard Smith } 299dc7a4f5d7a7e3b60d4dc4a80338d7a2728540998Richard Smith 3002ced044c34311d8e6301f2b4566f4b612bc8b628Richard Smith namespace B { 3012ced044c34311d8e6301f2b4566f4b612bc8b628Richard Smith template<typename T> void g(); // expected-note {{not viable}} 3022ced044c34311d8e6301f2b4566f4b612bc8b628Richard Smith template<typename T> void f() { 3032ced044c34311d8e6301f2b4566f4b612bc8b628Richard Smith g<int>(T()); // expected-error {{no matching function}} 3042ced044c34311d8e6301f2b4566f4b612bc8b628Richard Smith } 3052ced044c34311d8e6301f2b4566f4b612bc8b628Richard Smith 3062ced044c34311d8e6301f2b4566f4b612bc8b628Richard Smith namespace { 3072ced044c34311d8e6301f2b4566f4b612bc8b628Richard Smith struct S {}; 3082ced044c34311d8e6301f2b4566f4b612bc8b628Richard Smith } 3092ced044c34311d8e6301f2b4566f4b612bc8b628Richard Smith void g(S); 3102ced044c34311d8e6301f2b4566f4b612bc8b628Richard Smith 3112ced044c34311d8e6301f2b4566f4b612bc8b628Richard Smith template void f<S>(); // expected-note {{here}} 3122ced044c34311d8e6301f2b4566f4b612bc8b628Richard Smith } 3132ced044c34311d8e6301f2b4566f4b612bc8b628Richard Smith} 314ad579916bc402cf617793e94770bab78e9bdaec8Argyrios Kyrtzidis 315ad579916bc402cf617793e94770bab78e9bdaec8Argyrios Kyrtzidisnamespace rdar11242625 { 316ad579916bc402cf617793e94770bab78e9bdaec8Argyrios Kyrtzidis 317ad579916bc402cf617793e94770bab78e9bdaec8Argyrios Kyrtzidistemplate <typename T> 318ad579916bc402cf617793e94770bab78e9bdaec8Argyrios Kyrtzidisstruct Main { 319ad579916bc402cf617793e94770bab78e9bdaec8Argyrios Kyrtzidis struct default_names { 320ad579916bc402cf617793e94770bab78e9bdaec8Argyrios Kyrtzidis typedef int id; 321ad579916bc402cf617793e94770bab78e9bdaec8Argyrios Kyrtzidis }; 322ad579916bc402cf617793e94770bab78e9bdaec8Argyrios Kyrtzidis 323ad579916bc402cf617793e94770bab78e9bdaec8Argyrios Kyrtzidis template <typename T2 = typename default_names::id> 324ad579916bc402cf617793e94770bab78e9bdaec8Argyrios Kyrtzidis struct TS { 325ad579916bc402cf617793e94770bab78e9bdaec8Argyrios Kyrtzidis T2 q; 326ad579916bc402cf617793e94770bab78e9bdaec8Argyrios Kyrtzidis }; 327ad579916bc402cf617793e94770bab78e9bdaec8Argyrios Kyrtzidis}; 328ad579916bc402cf617793e94770bab78e9bdaec8Argyrios Kyrtzidis 329ad579916bc402cf617793e94770bab78e9bdaec8Argyrios Kyrtzidisstruct Sub : public Main<int> { 330ad579916bc402cf617793e94770bab78e9bdaec8Argyrios Kyrtzidis TS<> ff; 331ad579916bc402cf617793e94770bab78e9bdaec8Argyrios Kyrtzidis}; 332ad579916bc402cf617793e94770bab78e9bdaec8Argyrios Kyrtzidis 333ad579916bc402cf617793e94770bab78e9bdaec8Argyrios Kyrtzidisint arr[sizeof(Sub)]; 334ad579916bc402cf617793e94770bab78e9bdaec8Argyrios Kyrtzidis 335ad579916bc402cf617793e94770bab78e9bdaec8Argyrios Kyrtzidis} 336ad579916bc402cf617793e94770bab78e9bdaec8Argyrios Kyrtzidis 337ad579916bc402cf617793e94770bab78e9bdaec8Argyrios Kyrtzidisnamespace PR11421 { 338ad579916bc402cf617793e94770bab78e9bdaec8Argyrios Kyrtzidistemplate < unsigned > struct X { 339ad579916bc402cf617793e94770bab78e9bdaec8Argyrios Kyrtzidis static const unsigned dimension = 3; 340ad579916bc402cf617793e94770bab78e9bdaec8Argyrios Kyrtzidis template<unsigned dim=dimension> 341d777e2845110469182809e4efc577899395805f7Douglas Gregor struct Y: Y<dim> { }; // expected-error{{circular inheritance between 'Y<dim>' and 'Y<dim>'}} 342ad579916bc402cf617793e94770bab78e9bdaec8Argyrios Kyrtzidis}; 343ad579916bc402cf617793e94770bab78e9bdaec8Argyrios Kyrtzidistypedef X<3> X3; 344d777e2845110469182809e4efc577899395805f7Douglas GregorX3::Y<>::iterator it; // expected-error {{no type named 'iterator' in 'PR11421::X<3>::Y<3>'}} 345d777e2845110469182809e4efc577899395805f7Douglas Gregor} 346d777e2845110469182809e4efc577899395805f7Douglas Gregor 347d777e2845110469182809e4efc577899395805f7Douglas Gregornamespace rdar12629723 { 348d777e2845110469182809e4efc577899395805f7Douglas Gregor template<class T> 349d777e2845110469182809e4efc577899395805f7Douglas Gregor struct X { 350d777e2845110469182809e4efc577899395805f7Douglas Gregor struct C : public C { }; // expected-error{{circular inheritance between 'rdar12629723::X::C' and 'rdar12629723::X::C'}} 351d777e2845110469182809e4efc577899395805f7Douglas Gregor 352d777e2845110469182809e4efc577899395805f7Douglas Gregor struct B; 353d777e2845110469182809e4efc577899395805f7Douglas Gregor 354d777e2845110469182809e4efc577899395805f7Douglas Gregor struct A : public B { // expected-note{{'rdar12629723::X::A' declared here}} 355d777e2845110469182809e4efc577899395805f7Douglas Gregor virtual void foo() { } 356d777e2845110469182809e4efc577899395805f7Douglas Gregor }; 357229d47aef27e6f65fe4dc3beb22f622dd81104adDouglas Gregor 358229d47aef27e6f65fe4dc3beb22f622dd81104adDouglas Gregor struct D : T::foo { }; 359229d47aef27e6f65fe4dc3beb22f622dd81104adDouglas Gregor struct E : D { }; 360d777e2845110469182809e4efc577899395805f7Douglas Gregor }; 361d777e2845110469182809e4efc577899395805f7Douglas Gregor 362d777e2845110469182809e4efc577899395805f7Douglas Gregor template<class T> 363d777e2845110469182809e4efc577899395805f7Douglas Gregor struct X<T>::B : public A { // expected-error{{circular inheritance between 'rdar12629723::X::A' and 'rdar12629723::X::B'}} 364d777e2845110469182809e4efc577899395805f7Douglas Gregor virtual void foo() { } 365d777e2845110469182809e4efc577899395805f7Douglas Gregor }; 366ad579916bc402cf617793e94770bab78e9bdaec8Argyrios Kyrtzidis} 367d05df512cd6dfa32a696bcdd3dced825efe94bc4Nick Lewycky 368d05df512cd6dfa32a696bcdd3dced825efe94bc4Nick Lewyckynamespace test_reserved_identifiers { 369d05df512cd6dfa32a696bcdd3dced825efe94bc4Nick Lewycky template<typename A, typename B> void tempf(A a, B b) { 370d05df512cd6dfa32a696bcdd3dced825efe94bc4Nick Lewycky a + b; // expected-error{{call to function 'operator+' that is neither visible in the template definition nor found by argument-dependent lookup}} 371d05df512cd6dfa32a696bcdd3dced825efe94bc4Nick Lewycky } 372d05df512cd6dfa32a696bcdd3dced825efe94bc4Nick Lewycky namespace __gnu_cxx { struct X {}; } 373d05df512cd6dfa32a696bcdd3dced825efe94bc4Nick Lewycky namespace ns { struct Y {}; } 374d05df512cd6dfa32a696bcdd3dced825efe94bc4Nick Lewycky void operator+(__gnu_cxx::X, ns::Y); // expected-note{{or in namespace 'test_reserved_identifiers::ns'}} 375d05df512cd6dfa32a696bcdd3dced825efe94bc4Nick Lewycky void test() { 376d05df512cd6dfa32a696bcdd3dced825efe94bc4Nick Lewycky __gnu_cxx::X x; 377d05df512cd6dfa32a696bcdd3dced825efe94bc4Nick Lewycky ns::Y y; 378d05df512cd6dfa32a696bcdd3dced825efe94bc4Nick Lewycky tempf(x, y); // expected-note{{in instantiation of}} 379d05df512cd6dfa32a696bcdd3dced825efe94bc4Nick Lewycky } 380d05df512cd6dfa32a696bcdd3dced825efe94bc4Nick Lewycky} 38119e0d959171860e207205d31af223b27c925fbecRichard Smith 38219e0d959171860e207205d31af223b27c925fbecRichard Smith// This test must live in the global namespace. 38319e0d959171860e207205d31af223b27c925fbecRichard Smithstruct PR14695_X {}; 38419e0d959171860e207205d31af223b27c925fbecRichard Smith// FIXME: This note is bogus; it is the using directive which would need to move 38519e0d959171860e207205d31af223b27c925fbecRichard Smith// to prior to the call site to fix the problem. 38619e0d959171860e207205d31af223b27c925fbecRichard Smithnamespace PR14695_A { void PR14695_f(PR14695_X); } // expected-note {{'PR14695_f' should be declared prior to the call site or in the global namespace}} 38719e0d959171860e207205d31af223b27c925fbecRichard Smithtemplate<typename T> void PR14695_g(T t) { PR14695_f(t); } // expected-error {{call to function 'PR14695_f' that is neither visible in the template definition nor found by argument-dependent lookup}} 38819e0d959171860e207205d31af223b27c925fbecRichard Smithusing namespace PR14695_A; 38919e0d959171860e207205d31af223b27c925fbecRichard Smithtemplate void PR14695_g(PR14695_X); // expected-note{{requested here}} 390d3ff325a8d95a58783a3ea2675e2d59a393bd637Richard Smith 391d3ff325a8d95a58783a3ea2675e2d59a393bd637Richard Smithnamespace OperatorNew { 392d3ff325a8d95a58783a3ea2675e2d59a393bd637Richard Smith template<typename T> void f(T t) { 393d3ff325a8d95a58783a3ea2675e2d59a393bd637Richard Smith operator new(100, t); // expected-error{{call to function 'operator new' that is neither visible in the template definition nor found by argument-dependent lookup}} 394d3ff325a8d95a58783a3ea2675e2d59a393bd637Richard Smith // FIXME: This should give the same error. 395d3ff325a8d95a58783a3ea2675e2d59a393bd637Richard Smith new (t) int; 396d3ff325a8d95a58783a3ea2675e2d59a393bd637Richard Smith } 397d3ff325a8d95a58783a3ea2675e2d59a393bd637Richard Smith struct X {}; 398d3ff325a8d95a58783a3ea2675e2d59a393bd637Richard Smith}; 399d3ff325a8d95a58783a3ea2675e2d59a393bd637Richard Smithusing size_t = decltype(sizeof(0)); 400651f13cea278ec967336033dd032faef0e9fc2ecStephen Hinesvoid *operator new(size_t, OperatorNew::X); // expected-note-re {{should be declared prior to the call site{{$}}}} 401d3ff325a8d95a58783a3ea2675e2d59a393bd637Richard Smithtemplate void OperatorNew::f(OperatorNew::X); // expected-note {{instantiation of}} 402ef8225444452a1486bd721f3285301fe84643b00Stephen Hines 403ef8225444452a1486bd721f3285301fe84643b00Stephen Hinesnamespace PR19936 { 404ef8225444452a1486bd721f3285301fe84643b00Stephen Hines template<typename T> decltype(*T()) f() {} // expected-note {{previous}} 405ef8225444452a1486bd721f3285301fe84643b00Stephen Hines template<typename T> decltype(T() * T()) g() {} // expected-note {{previous}} 406ef8225444452a1486bd721f3285301fe84643b00Stephen Hines 407ef8225444452a1486bd721f3285301fe84643b00Stephen Hines // Create some overloaded operators so we build an overload operator call 408ef8225444452a1486bd721f3285301fe84643b00Stephen Hines // instead of a builtin operator call for the dependent expression. 409ef8225444452a1486bd721f3285301fe84643b00Stephen Hines enum E {}; 410ef8225444452a1486bd721f3285301fe84643b00Stephen Hines int operator*(E); 411ef8225444452a1486bd721f3285301fe84643b00Stephen Hines int operator*(E, E); 412ef8225444452a1486bd721f3285301fe84643b00Stephen Hines 413ef8225444452a1486bd721f3285301fe84643b00Stephen Hines // Check that they still profile the same. 414ef8225444452a1486bd721f3285301fe84643b00Stephen Hines template<typename T> decltype(*T()) f() {} // expected-error {{redefinition}} 415ef8225444452a1486bd721f3285301fe84643b00Stephen Hines template<typename T> decltype(T() * T()) g() {} // expected-error {{redefinition}} 416ef8225444452a1486bd721f3285301fe84643b00Stephen Hines} 417