From ccbfd6c29661bacd81758db6527191bb7efa2c90 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Mon, 1 Aug 2016 16:39:29 +0000 Subject: [PATCH] [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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@277352 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Parse/ParseStmt.cpp | 3 ++- test/Parser/MicrosoftExtensions.c | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp index 9043ebb9a2..d0557b8a62 100644 --- a/lib/Parse/ParseStmt.cpp +++ b/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/test/Parser/MicrosoftExtensions.c b/test/Parser/MicrosoftExtensions.c index 39ab51f31f..2af6c421bc 100644 --- a/test/Parser/MicrosoftExtensions.c +++ b/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; + } +} -- 2.40.0