<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - in -traditional mode, the preprocessor should only process directives whose '#' appears in column 1"
   href="https://llvm.org/bugs/show_bug.cgi?id=31886">31886</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>in -traditional mode, the preprocessor should only process directives whose '#' appears in column 1
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </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>froydnj@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Relaying this bug report on behalf of Zack Weinberg:

In -traditional mode, the preprocessor should only process directives
whose '#' appears in column 1.  For instance, in this fragment ...

    #ifndef foo
        #ifdef bar
            quux
        #endif
    #endif

... no tokens survive preprocessing in the standard mode, but the
expected output of 'cc -E -traditional' (ignoring blank lines and line
number annotations) is

        #ifdef bar
            quux
        #endif

clang, however, has a bug in which the nested #endif is *not* ignored,
causing the subsequent non-nested #endif to trigger an error:

        #ifdef bar
            quux
    test.c:5:2: error: #endif without #if
    #endif
     ^
    1 error generated.

This may not just affect #endif: clang preprocesses *this* fragment ...

    /* this comment is not indented */
        #ifdef bar
            quux
        #else
            greeble
        #endif

... to just 'greeble' and no errors, with or without -traditional.

I observe this behavior with both
'clang version 3.8.1-17 (tags/RELEASE_381/final)' and
'clang version 3.9.1-4 (tags/RELEASE_391/rc2)' as supplied by Debian.
Another person has reported identical behavior with
'Apple LLVM version 8.0.0 (clang-800.0.42.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>