<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 --- - Nested macros producing different locations due to whitespace changes"
   href="https://llvm.org/bugs/show_bug.cgi?id=26247">26247</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Nested macros producing different locations due to whitespace changes
          </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>rtrieu@google.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>Created <span class=""><a href="attachment.cgi?id=15686" name="attach_15686" title="Test Case">attachment 15686</a> <a href="attachment.cgi?id=15686&action=edit" title="Test Case">[details]</a></span>
Test Case

I was attempting to track down an issue with a warning and nesting macros,
specifically the NULL macro.  That was when I discovered the warning behavior
was dependent on the whitespace inside one of the macro definitions.  In the
attached test case, a warning is generated for "assert(test1());" while no
warning is emitted for "assert(test2());"  However, the definition of test1 and
test2 only differ by two spaces.

The warning logic is in SemaChecking.cpp:7045 in the DiagnoseNullConversion
function.  The difference is that one will have the MacroName of "NULL" while
the one does not.  The warning depends on finding the NULL macro name to
perform the analysis properly.

>From the lexing side, one location difference was found in TokenLexer.cpp:796
inside updateConsecutiveMacroArgTokens.  The extra whitespace pushes one of the
macros over the relative offset limit of 50, splitting the macro tokens among
different SLoc's.  Remove the condition of "RelOffs > 50" appears to fix the
SourceLocation issue, but I'm not sure what else with macro handling that
condition affects.</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>