]> granicus.if.org Git - clang/commitdiff
Add a missing test for the __if_exists extension
authorReid Kleckner <reid@kleckner.net>
Wed, 25 Jun 2014 00:10:50 +0000 (00:10 +0000)
committerReid Kleckner <reid@kleckner.net>
Wed, 25 Jun 2014 00:10:50 +0000 (00:10 +0000)
MSVC does not create a new scope for the body of an __if_exists compound
statement.  Clang already gets this right today, but it was untested.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211650 91177308-0d34-0410-b5e6-96231b3b80d8

test/Parser/ms-if-exists.cpp

index f1cfbcfdfe439f817e4fb0c4699f92d4bc2a5d07..2d4a957f1276b23c908015c80f035579a89b6409 100644 (file)
@@ -25,6 +25,16 @@ void test_if_exists_stmts() {
   }
 }
 
+int if_exists_creates_no_scope() {
+  __if_exists(MayExist::Type) {
+    int x;  // 'x' is declared in the parent scope.
+  }
+  __if_not_exists(MayExist::Type_not) {
+    x++;
+  }
+  return x;
+}
+
 __if_exists(MayExist::Type) {
   int var23;
 }