Page MenuHomePhabricator

Allow 'static' storage specifier on an out-of-line member function template declaration in MSVCCompat mode
Needs RevisionPublic

Authored by Manna on Tue, Jan 8, 8:28 PM.



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.

Diff Detail

Event Timeline

Manna created this revision.Tue, Jan 8, 8:28 PM
Manna edited the summary of this revision. (Show Details)Tue, Jan 8, 8:33 PM
mibintc requested changes to this revision.Wed, Jan 9, 12:15 PM

More info: gcc allows this with -fpermissive, Microsoft gives no message regardless of /permissive-

This revision now requires changes to proceed.Wed, Jan 9, 12:15 PM
aaron.ballman added inline comments.Thu, Jan 10, 12:19 PM

Should be an ExtWarn<> instead of Warning<> and should be named ext_static_out_of_line.


Nit: instead of duplicating the text, you can use err_static_out_of_line.Text instead.


of 'static' -> of a 'static'


I would use a ternary operator here instead of duplicating the code. e.g.,

     NewFD->getDescribedFunctionTemplate() && getLangOpts().MSVCCompat ? diag::warn_static_out_of_line : diag::err_static_out_of_line)
  << FixItHint::CreateRemoval(D.getDeclSpec().getStorageClassSpecLoc());

(only with better formatting)


Remove -fms-extensions from the RUN line as this is a compatibility feature


You should run this through clang-format to match the formatting guidelines.

rnk added a comment.Mon, Jan 14, 5:51 PM

Functionality seems reasonable, I'll let @aaron.ballman finish the review.