diff options
-rw-r--r-- | lib/Format/TokenAnnotator.cpp | 2 | ||||
-rw-r--r-- | unittests/Format/FormatTest.cpp | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 8267a25d03..4ac4c9b1b8 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -319,6 +319,8 @@ private: Tok->Type = TT_ObjCMethodSpecifier; break; case tok::colon: + if (Tok->Parent == NULL) + return false; // Colons from ?: are handled in parseConditional(). if (Tok->Parent->is(tok::r_paren) && Contexts.size() == 1) { Tok->Type = TT_CtorInitializerColon; diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 4ac9bce56b..e6ae81da5c 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -1068,6 +1068,8 @@ TEST_F(FormatTest, EmptyLinesInMacroDefinitions) { } TEST_F(FormatTest, MacroDefinitionsWithIncompleteCode) { + verifyFormat("#define A :"); + // FIXME: Improve formatting of case labels in macros. verifyFormat("#define SOMECASES \\\n" "case 1: \\\n" |