diff options
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 528ad4b78c0..4e1b6f22bc3 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -3087,6 +3087,15 @@ TEST_F(FormatTest, IndentPreprocessorDirectives) { "#endif\n" "#endif\n", Style); + // Don't crash if there is an #elif directive without a condition. + verifyFormat("#if 1\n" + "int x;\n" + "#elif\n" + "int y;\n" + "#else\n" + "int z;\n" + "#endif", + Style); // FIXME: This doesn't handle the case where there's code between the // #ifndef and #define but all other conditions hold. This is because when // the #define line is parsed, UnwrappedLineParser::Lines doesn't hold the |