p2.cpp revision 5e513042ca50f0c19e8fa66ced95d8043415b31c
191305bf1b2e75937fb60db03cca766ad983fffdbDouglas Gregor// RUN: %clang_cc1 -fsyntax-only -verify %s 291305bf1b2e75937fb60db03cca766ad983fffdbDouglas Gregortemplate<class T> struct A { 391305bf1b2e75937fb60db03cca766ad983fffdbDouglas Gregor static T t; // expected-error{{static data member instantiated with function type 'int ()'}} 491305bf1b2e75937fb60db03cca766ad983fffdbDouglas Gregor}; 591305bf1b2e75937fb60db03cca766ad983fffdbDouglas Gregortypedef int function(); 691305bf1b2e75937fb60db03cca766ad983fffdbDouglas GregorA<function> a; // expected-note{{instantiation of}} 791305bf1b2e75937fb60db03cca766ad983fffdbDouglas Gregor 891305bf1b2e75937fb60db03cca766ad983fffdbDouglas Gregortemplate<typename T> struct B { 991305bf1b2e75937fb60db03cca766ad983fffdbDouglas Gregor B() { T t; } // expected-error{{variable instantiated with function type 'int ()'}} 1091305bf1b2e75937fb60db03cca766ad983fffdbDouglas Gregor}; 1191305bf1b2e75937fb60db03cca766ad983fffdbDouglas GregorB<function> b; // expected-note{{instantiation of}} 1291305bf1b2e75937fb60db03cca766ad983fffdbDouglas Gregor 13d7092324128ecd14933040b3854037090a7672daDouglas Gregortemplate <typename T> int f0(void *, const T&); // expected-note{{candidate template ignored: substitution failure}} 145e513042ca50f0c19e8fa66ced95d8043415b31cDouglas Gregorenum {e}; // expected-note{{unnamed type used in template argument was declared here}} 15d7092324128ecd14933040b3854037090a7672daDouglas Gregor 16d7092324128ecd14933040b3854037090a7672daDouglas Gregorvoid test_f0(int n) { 175e513042ca50f0c19e8fa66ced95d8043415b31cDouglas Gregor int i = f0(0, e); // expected-warning{{template argument uses unnamed type}} 18d7092324128ecd14933040b3854037090a7672daDouglas Gregor int vla[n]; 19d7092324128ecd14933040b3854037090a7672daDouglas Gregor f0(0, vla); // expected-error{{no matching function for call to 'f0'}} 20d7092324128ecd14933040b3854037090a7672daDouglas Gregor} 21d7092324128ecd14933040b3854037090a7672daDouglas Gregor 225e513042ca50f0c19e8fa66ced95d8043415b31cDouglas Gregornamespace N0 { 235e513042ca50f0c19e8fa66ced95d8043415b31cDouglas Gregor template <typename R, typename A1> void f0(R (*)(A1)); 245e513042ca50f0c19e8fa66ced95d8043415b31cDouglas Gregor template <typename T> int f1(T); 255e513042ca50f0c19e8fa66ced95d8043415b31cDouglas Gregor template <typename T, typename U> int f1(T, U); 265e513042ca50f0c19e8fa66ced95d8043415b31cDouglas Gregor enum {e1}; // expected-note 2{{unnamed type used in template argument was declared here}} 275e513042ca50f0c19e8fa66ced95d8043415b31cDouglas Gregor enum {e2}; // expected-note 2{{unnamed type used in template argument was declared here}} 285e513042ca50f0c19e8fa66ced95d8043415b31cDouglas Gregor enum {e3}; // FIXME: expected unnamed type used in template argument was declared here 295e513042ca50f0c19e8fa66ced95d8043415b31cDouglas Gregor 305e513042ca50f0c19e8fa66ced95d8043415b31cDouglas Gregor template<typename T> struct X; 315e513042ca50f0c19e8fa66ced95d8043415b31cDouglas Gregor template<typename T> struct X<T*> { }; 325e513042ca50f0c19e8fa66ced95d8043415b31cDouglas Gregor 335e513042ca50f0c19e8fa66ced95d8043415b31cDouglas Gregor void f() { 345e513042ca50f0c19e8fa66ced95d8043415b31cDouglas Gregor f0( // expected-warning{{template argument uses unnamed type}} 355e513042ca50f0c19e8fa66ced95d8043415b31cDouglas Gregor &f1<__typeof__(e1)>); // expected-warning{{template argument uses unnamed type}} 365e513042ca50f0c19e8fa66ced95d8043415b31cDouglas Gregor int (*fp1)(int, __typeof__(e2)) = f1; // expected-warning{{template argument uses unnamed type}} 375e513042ca50f0c19e8fa66ced95d8043415b31cDouglas Gregor f1(e2); // expected-warning{{template argument uses unnamed type}} 385e513042ca50f0c19e8fa66ced95d8043415b31cDouglas Gregor f1(e2); 395e513042ca50f0c19e8fa66ced95d8043415b31cDouglas Gregor 405e513042ca50f0c19e8fa66ced95d8043415b31cDouglas Gregor X<__typeof__(e3)*> x; // FIXME: should warn about unnamed type 415e513042ca50f0c19e8fa66ced95d8043415b31cDouglas Gregor } 425e513042ca50f0c19e8fa66ced95d8043415b31cDouglas Gregor} 43