From 0e542acb983bb667cdc6e52948510c47c2ba28e9 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Wed, 4 Feb 2015 08:22:46 +0000 Subject: [PATCH] Parse: Handle __declspec in a lambda definition git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@228121 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Parse/ParseExprCXX.cpp | 5 +++++ test/SemaCXX/ms-novtable.cpp | 1 + 2 files changed, 6 insertions(+) diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp index 10ae450fe8..445967bfab 100644 --- a/lib/Parse/ParseExprCXX.cpp +++ b/lib/Parse/ParseExprCXX.cpp @@ -1085,6 +1085,11 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer( // compatible with GCC. MaybeParseGNUAttributes(Attr, &DeclEndLoc); + // MSVC-style attributes must be parsed before the mutable specifier to be + // compatible with MSVC. + while (Tok.is(tok::kw___declspec)) + ParseMicrosoftDeclSpec(Attr); + // Parse 'mutable'[opt]. SourceLocation MutableLoc; if (TryConsumeToken(tok::kw_mutable, MutableLoc)) diff --git a/test/SemaCXX/ms-novtable.cpp b/test/SemaCXX/ms-novtable.cpp index 6dd949d57d..2d55c48df3 100644 --- a/test/SemaCXX/ms-novtable.cpp +++ b/test/SemaCXX/ms-novtable.cpp @@ -4,3 +4,4 @@ struct __declspec(novtable) S {}; enum __declspec(novtable) E {}; // expected-warning{{'novtable' attribute only applies to classes}} int __declspec(novtable) I; // expected-warning{{'novtable' attribute only applies to classes}} typedef struct T __declspec(novtable) U; // expected-warning{{'novtable' attribute only applies to classes}} +auto z = []() __declspec(novtable) { return nullptr; }; // expected-warning{{'novtable' attribute only applies to classes}} -- 2.40.0