In r238238, we removed declspec as a universally-accepted keyword -- instead, it is only enabled as a supported keyword when -fms-extensions or -fdeclspec is passed to the driver. However, this had an unfortunate side-effect in that it made for bad diagnostics in the presence of a declspec when neither of those flags are passed. For instance:
__declspec(naked) void f(void) {}
clang -fsyntax-only -fno-ms-extensions -Wall -pedantic main.c
main.cpp:1:24: error: parameter named 'f' is missing
__declspec(naked) void f(void) {}
^
main.cpp:1:31: error: expected ';' at end of declaration
__declspec(naked) void f(void) {}
^ ;
main.cpp:1:12: warning: parameter 'naked' was not declared, defaulting to type 'int' [-Wpedantic]
__declspec(naked) void f(void) {}
^
main.cpp:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
__declspec(naked) void f(void) {}
This patch addresses the poor diagnostics by noticing when a __declspec has been used but is not enabled. It eats the attribute, diagnoses the use, and then attempts to continue parsing.
Shouldn't this be getLangOpts().DeclSpecKeyword since you don't need the Microsoft extensions as much as you need the declspec keyword to be processed. Having MicrosoftExt implicitly enable DeclSpecKeyword (just as borland mode enables it as well). I suppose that it would fail anyways as Tok.is(tok::identifier) would fail.