<html>
    <head>
      <base href="https://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 - function attribute "diagnose_if" doesn't show error if the argument uses statements and declarations in expressions"
   href="https://bugs.llvm.org/show_bug.cgi?id=38111">38111</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>function attribute "diagnose_if" doesn't show error if the argument uses statements and declarations in expressions
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>6.0
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>naruse@airemix.jp
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>If the target function of "diagnose_if" attribute receives an argument which
uses GCC extension, statements and declarations in expressions, clang doesn't
show error.
If there're only statements, it works.
But if there're also declarations, it doesn't show any errors.

```
%  cat b.c
int scan_args(char *fmt)
    __attribute__((diagnose_if(fmt[0]!=2,"invalid format string","error")))
{
    return 0;
}


int
main(int argc, char **argv) {
    return scan_args(__extension__({"20";}));
}
%  clang b.c
b.c:10:44: error: invalid format string
    return scan_args(__extension__({"20";}));
                                           ^
b.c:2:20: note: from 'diagnose_if' attribute on 'scan_args':
    __attribute__((diagnose_if(fmt[0]!=2,"invalid format string","error")))
                   ^           ~~~~~~~~~
1 error generated.
```

```
%  cat b.c
int scan_args(char *fmt)
    __attribute__((diagnose_if(fmt[0]!=2,"invalid format string","error")))
{
    return 0;
}


int
main(int argc, char **argv) {
    return scan_args(__extension__({char *s="20";s;}));
}
%  clang b.c
```</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>