Allow 'static' storage specifier on an out-of-line member function template
declaration in MSVCCompat mode
Microsoft compiler permits the use of 'static' storage specifier outside
of a class definition if it's on an out-of-line member function template
declaration.
This patch allows 'static' storage specifier on an out-of-line member
function template declaration with a warning in Clang (To be compatible
with Microsoft).
Intel C/C++ compiler allows the 'static' keyword with a warning in
Microsoft mode. GCC allows this with -fpermissive.
Patch By: Manna
Differential Revision: https://reviews.llvm.org/D56473
Change-Id: I97b2d9e9d57cecbcd545d17e2523142a85ca2702
llvm-svn: 352219
diff --git a/clang/test/SemaCXX/warn-static-outside-class-definition.cpp b/clang/test/SemaCXX/warn-static-outside-class-definition.cpp
new file mode 100644
index 0000000..5235d35
--- /dev/null
+++ b/clang/test/SemaCXX/warn-static-outside-class-definition.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fms-compatibility -fsyntax-only -verify %s
+
+struct C {
+ template <typename T> static int foo(T);
+};
+
+template <typename T> static int C::foo(T) {
+ //expected-warning@-1 {{'static' can only be specified inside the class definition}}
+ return 0;
+}
+