<div dir="ltr">Hello Nico,<br><br>This commit broke one of our builders:<br><br><a href="http://lab.llvm.org:8011/builders/ubuntu-gcc7.1-werror/builds/4701">http://lab.llvm.org:8011/builders/ubuntu-gcc7.1-werror/builds/4701</a><br>. . .<br>FAILED: /usr/local/gcc-7.1/bin/g++-7.1   -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/clang/lib/Format -I/home/buildslave/am1i-slv2/ubuntu-gcc7.1-werror/llvm/tools/clang/lib/Format -I/home/buildslave/am1i-slv2/ubuntu-gcc7.1-werror/llvm/tools/clang/include -Itools/clang/include -Iinclude -I/home/buildslave/am1i-slv2/ubuntu-gcc7.1-werror/llvm/include -Wno-noexcept-type -fPIC -fvisibility-inlines-hidden -Werror -Werror=date-time -std=c++11 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing -O3  -fPIC   -UNDEBUG  -fno-exceptions -fno-rtti -MD -MT tools/clang/lib/Format/CMakeFiles/clangFormat.dir/UnwrappedLineParser.cpp.o -MF tools/clang/lib/Format/CMakeFiles/clangFormat.dir/UnwrappedLineParser.cpp.o.d -o tools/clang/lib/Format/CMakeFiles/clangFormat.dir/UnwrappedLineParser.cpp.o -c /home/buildslave/am1i-slv2/ubuntu-gcc7.1-werror/llvm/tools/clang/lib/Format/UnwrappedLineParser.cpp<br>/home/buildslave/am1i-slv2/ubuntu-gcc7.1-werror/llvm/tools/clang/lib/Format/UnwrappedLineParser.cpp: In member function ‘void clang::format::UnwrappedLineParser::parseLevel(bool)’:<br>/home/buildslave/am1i-slv2/ubuntu-gcc7.1-werror/llvm/tools/clang/lib/Format/UnwrappedLineParser.cpp:345:7: error: this statement may fall through [-Werror=implicit-fallthrough=]<br>       }<br>       ^<br>/home/buildslave/am1i-slv2/ubuntu-gcc7.1-werror/llvm/tools/clang/lib/Format/UnwrappedLineParser.cpp:348:5: note: here<br>     case tok::kw_case:<br>     ^~~~<br>cc1plus: all warnings being treated as errors<br>ninja: build stopped: subcommand failed.<br><br>Please have a look?<br><br>Thanks<br><br>Galina<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 23, 2018 at 8:30 AM, Nico Weber via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: nico<br>
Date: Tue Jan 23 08:30:56 2018<br>
New Revision: 323218<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=323218&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=323218&view=rev</a><br>
Log:<br>
clang-format: Support formatting Java 8 interface default methods.<br>
<br>
Modified:<br>
    cfe/trunk/lib/Format/<wbr>UnwrappedLineParser.cpp<br>
    cfe/trunk/unittests/Format/<wbr>FormatTestJava.cpp<br>
<br>
Modified: cfe/trunk/lib/Format/<wbr>UnwrappedLineParser.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=323218&r1=323217&r2=323218&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Format/<wbr>UnwrappedLineParser.cpp?rev=<wbr>323218&r1=323217&r2=323218&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Format/<wbr>UnwrappedLineParser.cpp (original)<br>
+++ cfe/trunk/lib/Format/<wbr>UnwrappedLineParser.cpp Tue Jan 23 08:30:56 2018<br>
@@ -333,7 +333,18 @@ void UnwrappedLineParser::<wbr>parseLevel(boo<br>
       nextToken();<br>
       addUnwrappedLine();<br>
       break;<br>
-    case tok::kw_default:<br>
+    case tok::kw_default: {<br>
+      unsigned StoredPosition = Tokens->getPosition();<br>
+      FormatToken *Next = Tokens->getNextToken();<br>
+      FormatTok = Tokens->setPosition(<wbr>StoredPosition);<br>
+      if (Next && Next->isNot(tok::colon)) {<br>
+        // default not followed by ':' is not a case label; treat it like<br>
+        // an identifier.<br>
+        parseStructuralElement();<br>
+        break;<br>
+      }<br>
+      // Else, if it is 'default:', fall through to the case handling.<br>
+    }<br>
     case tok::kw_case:<br>
       if (Style.Language == FormatStyle::LK_JavaScript &&<br>
           Line->MustBeDeclaration) {<br>
@@ -1032,8 +1043,12 @@ void UnwrappedLineParser::<wbr>parseStructura<br>
       // 'default: string' field declaration.<br>
       break;<br>
     nextToken();<br>
-    parseLabel();<br>
-    return;<br>
+    if (FormatTok->is(tok::colon)) {<br>
+      parseLabel();<br>
+      return;<br>
+    }<br>
+    // e.g. "default void f() {}" in a Java interface.<br>
+    break;<br>
   case tok::kw_case:<br>
     if (Style.Language == FormatStyle::LK_JavaScript && Line->MustBeDeclaration)<br>
       // 'case: string' field declaration.<br>
<br>
Modified: cfe/trunk/unittests/Format/<wbr>FormatTestJava.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJava.cpp?rev=323218&r1=323217&r2=323218&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/unittests/<wbr>Format/FormatTestJava.cpp?rev=<wbr>323218&r1=323217&r2=323218&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/unittests/Format/<wbr>FormatTestJava.cpp (original)<br>
+++ cfe/trunk/unittests/Format/<wbr>FormatTestJava.cpp Tue Jan 23 08:30:56 2018<br>
@@ -144,6 +144,7 @@ TEST_F(FormatTestJava, ClassDeclarations<br>
   verifyFormat("public interface SomeInterface {\n"<br>
                "  void doStuff(int theStuff);\n"<br>
                "  void doMoreStuff(int moreStuff);\n"<br>
+               "  default void doStuffWithDefault() {}\n"<br>
                "}");<br>
   verifyFormat("@interface SomeInterface {\n"<br>
                "  void doStuff(int theStuff);\n"<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>