[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
Sun Feb 12 14:35:24 PST 2017


compnerd added inline comments.


================
Comment at: lib/Parse/ParseDecl.cpp:2989
+
+          Diag(Loc, diag::err_ms_attributes_not_enabled);
+          continue;
----------------
aaron.ballman wrote:
> compnerd wrote:
> > 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').
> Yes, but it could also lead to a rejecting code that we used to accept and properly handle when __declspec is an identifier rather than a keyword. e.g.,
> ```
> struct __declspec {};
> 
> __declspec some_func(void);
> ```
> By looking for the paren, we run less risk of breaking working code, even if that code abuses the implementation namespace (after all, __declspec it not a keyword in this scenario).
But we would reject that code under `-fdeclspec` anyways.  I think having the code be more portable is a bit nicer.


https://reviews.llvm.org/D29868





More information about the cfe-commits mailing list