[PATCH] D29868: Recover more gracefully when __declspec is not supported as a keyword

Saleem Abdulrasool via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 11 15:18:00 PST 2017


compnerd added inline comments.


================
Comment at: lib/Parse/ParseDecl.cpp:2973
+      // recognize that scenario and recover gracefully.
+      if (!getLangOpts().MicrosoftExt && Tok.is(tok::identifier) &&
+          Tok.getIdentifierInfo()->getName().equals("__declspec")) {
----------------
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.


================
Comment at: lib/Parse/ParseDecl.cpp:2989
+
+          Diag(Loc, diag::err_ms_attributes_not_enabled);
+          continue;
----------------
I think that we want to emit the diagnostic even if there is no parenthesis as `__declspec` is a reserved identifier, and we would normally diagnose the bad `__declspec` (expected '(' after '__declspec').


https://reviews.llvm.org/D29868





More information about the cfe-commits mailing list