[PATCH] D56473: Allow 'static' storage specifier on an out-of-line member function template declaration in MSVCCompat mode
Erich Keane via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 25 09:02:54 PST 2019
This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL352219: Allow 'static' storage specifier on an out-of-line member function template (authored by erichkeane, committed by ).
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D56473?vs=183230&id=183557#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D56473/new/
https://reviews.llvm.org/D56473
Files:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/warn-static-outside-class-definition.cpp
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/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<MicrosoftTemplate>;
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/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 <typename T> static int foo(T);
+};
+
+template <typename T> static int C::foo(T) {
+ //expected-warning at -1 {{'static' can only be specified inside the class definition}}
+ return 0;
+}
+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56473.183557.patch
Type: text/x-patch
Size: 2125 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190125/7a92f2c0/attachment.bin>
More information about the llvm-commits
mailing list