r277352 - [Parse] Let declarations follow labels in -fms-extensions mode

David Majnemer via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 1 09:39:30 PDT 2016


Author: majnemer
Date: Mon Aug  1 11:39:29 2016
New Revision: 277352

URL: http://llvm.org/viewvc/llvm-project?rev=277352&view=rev
Log:
[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.

Modified:
    cfe/trunk/lib/Parse/ParseStmt.cpp
    cfe/trunk/test/Parser/MicrosoftExtensions.c

Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=277352&r1=277351&r2=277352&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Mon Aug  1 11:39:29 2016
@@ -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,

Modified: cfe/trunk/test/Parser/MicrosoftExtensions.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/MicrosoftExtensions.c?rev=277352&r1=277351&r2=277352&view=diff
==============================================================================
--- cfe/trunk/test/Parser/MicrosoftExtensions.c (original)
+++ cfe/trunk/test/Parser/MicrosoftExtensions.c Mon Aug  1 11:39:29 2016
@@ -106,3 +106,12 @@ __declspec(align(16)) struct align_befor
 _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;
+  }
+}




More information about the cfe-commits mailing list