<html>
    <head>
      <base href="http://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Incorrect clang syntax warning with -Wgcc-compat"
   href="http://bugs.llvm.org/show_bug.cgi?id=32648">32648</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Incorrect clang syntax warning with -Wgcc-compat
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>cmtice@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When I compile the test file below (taken from a larger real program) clang
raises the following warning unless gcc-compat is disabled:

clang_gcc_compat.c:17:13: warning: 'break' is bound to current loop, GCC binds
      it to the enclosing loop [-Wgcc-compat]
    } while(__m(1));
            ^
clang_gcc_compat.c:8:3: note: expanded from macro '__m'
                break;                          \
                ^
1 warning generated.
/usr/x86_64-cros-linux-gnu/usr/lib/../lib64/Scrt1.o:function _start: error:
undefined reference to 'main'
clang-4.0: error: linker command failed with exit code 1 (use -v to see
invocation)


Since the break statement is clearly part of the switch construct and not in
any way, shape or form referring to the loop, this is an erroneous, confusing
warning.



The source code for clang_gcc_compat.c is below:

/* x86_64-cros-linux-gnu-clang tmp/clang_gcc_compat.c */

#define __m(x) \
({                                              \
        switch (x) {                            \
        case 1:                                 \
        {                                       \
                break;                          \
        }                                       \
        }                                       \
        42;                                     \
})

void f() {
  for (;;) {
    do {
    } while(__m(1));
  }</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>