]> granicus.if.org Git - clang/commitdiff
Parse: Handle __declspec in a lambda definition
authorDavid Majnemer <david.majnemer@gmail.com>
Wed, 4 Feb 2015 08:22:46 +0000 (08:22 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Wed, 4 Feb 2015 08:22:46 +0000 (08:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@228121 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseExprCXX.cpp
test/SemaCXX/ms-novtable.cpp

index 10ae450fe893bb16f42d19d2dcad3dccc3768ae1..445967bfab8f69c0730fd58699fa0526a8c55b33 100644 (file)
@@ -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))
index 6dd949d57dbf0146e331e15afa0315dba1dbe8e2..2d55c48df3c71d7557f6a37a8f4d591038448d9b 100644 (file)
@@ -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}}