From: David Majnemer Date: Mon, 1 Aug 2016 16:39:29 +0000 (+0000) Subject: [Parse] Let declarations follow labels in -fms-extensions mode X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6ac7dd19f7c3b2deb0450a349152bf75a92e987a;p=platform%2Fupstream%2Fllvm.git [Parse] Let declarations follow labels in -fms-extensions mode MSVC permits declarations in these places as conforming extension (it is a constraint violation otherwise). This fixes PR28782. llvm-svn: 277352 --- diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp index 9043ebb..d0557b8 100644 --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/lib/Parse/ParseStmt.cpp @@ -206,7 +206,8 @@ Retry: } default: { - if ((getLangOpts().CPlusPlus || Allowed == ACK_Any) && + if ((getLangOpts().CPlusPlus || getLangOpts().MicrosoftExt || + Allowed == ACK_Any) && isDeclarationStatement()) { SourceLocation DeclStart = Tok.getLocation(), DeclEnd; DeclGroupPtrTy Decl = ParseDeclaration(Declarator::BlockContext, diff --git a/clang/test/Parser/MicrosoftExtensions.c b/clang/test/Parser/MicrosoftExtensions.c index 39ab51f..2af6c42 100644 --- a/clang/test/Parser/MicrosoftExtensions.c +++ b/clang/test/Parser/MicrosoftExtensions.c @@ -106,3 +106,12 @@ __declspec(align(16)) struct align_before_key3 {} *align_before_key3_var; _Static_assert(__alignof(struct align_before_key1) == 16, ""); _Static_assert(__alignof(struct align_before_key2) == 16, ""); _Static_assert(__alignof(struct align_before_key3) == 16, ""); + +void PR28782(int i) { +foo: + int n; + switch (i) { + case 0: + int m; + } +}