Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td @@ -1585,6 +1585,9 @@ def err_static_not_bitfield : Error<"static member %0 cannot be a bit-field">; def err_static_out_of_line : Error< "'static' can only be specified inside the class definition">; +def ext_static_out_of_line : ExtWarn< + err_static_out_of_line.Text>, + InGroup; def err_storage_class_for_static_member : Error< "static data member definition cannot specify a storage class">; def err_typedef_not_bitfield : Error<"typedef member %0 cannot be a bit-field">; Index: cfe/trunk/lib/Sema/SemaDecl.cpp =================================================================== --- cfe/trunk/lib/Sema/SemaDecl.cpp +++ cfe/trunk/lib/Sema/SemaDecl.cpp @@ -8625,8 +8625,12 @@ // Complain about the 'static' specifier if it's on an out-of-line // member function definition. + + // MSVC permits the use of a 'static' storage specifier on an out-of-line + // member function template declaration, warn about this. Diag(D.getDeclSpec().getStorageClassSpecLoc(), - diag::err_static_out_of_line) + NewFD->getDescribedFunctionTemplate() && getLangOpts().MSVCCompat + ? diag::ext_static_out_of_line : diag::err_static_out_of_line) << FixItHint::CreateRemoval(D.getDeclSpec().getStorageClassSpecLoc()); } Index: cfe/trunk/test/SemaCXX/warn-static-outside-class-definition.cpp =================================================================== --- cfe/trunk/test/SemaCXX/warn-static-outside-class-definition.cpp +++ cfe/trunk/test/SemaCXX/warn-static-outside-class-definition.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -fms-compatibility -fsyntax-only -verify %s + +struct C { + template static int foo(T); +}; + +template static int C::foo(T) { + //expected-warning@-1 {{'static' can only be specified inside the class definition}} + return 0; +} +