summaryrefslogtreecommitdiffstats
path: root/clang/test/Parser/warn-misleading-indentation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/Parser/warn-misleading-indentation.cpp')
-rw-r--r--clang/test/Parser/warn-misleading-indentation.cpp84
1 files changed, 82 insertions, 2 deletions
diff --git a/clang/test/Parser/warn-misleading-indentation.cpp b/clang/test/Parser/warn-misleading-indentation.cpp
index d366db767e6..4b9d45b19ca 100644
--- a/clang/test/Parser/warn-misleading-indentation.cpp
+++ b/clang/test/Parser/warn-misleading-indentation.cpp
@@ -1,7 +1,9 @@
// RUN: %clang_cc1 -x c -fsyntax-only -verify %s
-// RUN: %clang_cc1 -x c -fsyntax-only -verify -Wmisleading-indentation -DWITH_WARN %s
-// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify -Wall -Wno-unused -DWITH_WARN -DCXX17 %s
// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify -Wall -Wno-unused -Wno-misleading-indentation -DCXX17 %s
+// RUN: %clang_cc1 -x c -fsyntax-only -verify -Wmisleading-indentation -DWITH_WARN -ftabstop 8 -DTAB_SIZE=8 %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify -Wall -Wno-unused -DWITH_WARN -ftabstop 4 -DTAB_SIZE=4 -DCXX17 %s
+// RUN: %clang_cc1 -x c -fsyntax-only -verify -Wall -Wno-unused -DWITH_WARN -ftabstop 1 -DTAB_SIZE=1 %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify -Wall -Wno-unused -Wmisleading-indentation -DCXX17 -DWITH_WARN -ftabstop 2 -DTAB_SIZE=2 %s
#ifndef WITH_WARN
// expected-no-diagnostics
@@ -225,3 +227,81 @@ void s(int num) {
// expected-warning@-2 {{misleading indentation; statement is not part of the previous 'if'}}
#endif
}
+int a4()
+{
+ if (0)
+ return 1;
+ return 0;
+#if (TAB_SIZE == 1)
+// expected-warning@-2 {{misleading indentation; statement is not part of the previous 'if'}}
+// expected-note@-5 {{here}}
+#endif
+}
+
+int a5()
+{
+ if (0)
+ return 1;
+ return 0;
+#if WITH_WARN
+// expected-warning@-2 {{misleading indentation; statement is not part of the previous 'if'}}
+// expected-note@-5 {{here}}
+#endif
+}
+
+int a6()
+{
+ if (0)
+ return 1;
+ return 0;
+#if (TAB_SIZE == 8)
+// expected-warning@-2 {{misleading indentation; statement is not part of the previous 'if'}}
+// expected-note@-5 {{here}}
+#endif
+}
+
+#define FOO \
+ goto fail
+
+int main(int argc, char* argv[]) {
+ if (5 != 0)
+ goto fail;
+ else
+ goto fail;
+
+ if (1) {
+ if (1)
+ goto fail;
+ else if (1)
+ goto fail;
+ else if (1)
+ goto fail;
+ else
+ goto fail;
+ } else if (1) {
+ if (1)
+ goto fail;
+ }
+
+ if (1) {
+ if (1)
+ goto fail;
+ } else if (1)
+ goto fail;
+
+
+ if (1) goto fail; goto fail;
+
+ if (0)
+ goto fail;
+
+ goto fail;
+
+ if (0)
+ FOO;
+
+ goto fail;
+
+fail:;
+}
+
OpenPOWER on IntegriCloud