<html>
    <head>
      <base href="http://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 --- - Support multiple instances of the nonnull function attribute"
   href="http://llvm.org/bugs/show_bug.cgi?id=18063">18063</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Support multiple instances of the nonnull function attribute
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.3
          </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>bugzilla@tecnocode.co.uk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>GCC supports specifying the nonnull attribute[1] multiple times for the same
function, and it collects the argument indices from all of them.

e.g. The following two code snippets are equivalent for GCC:
    void my_func (void *p1, void *p2)
        __attribute__((nonnull(1)))
        __attribute__((nonnull(2)));
and
    void my_func (void *p1, void *p2)
        __attribute__((nonnull(1, 2)));

Currently, however, Clang ignores all except the final attribute, so for Clang,
the code:
    void my_func (void *p1, void *p2)
        __attribute__((nonnull(1)))
        __attribute__((nonnull(2)));
is actually equivalent to:
    void my_func (void *p1, void *p2)
        __attribute__((nonnull(2)));

It would be nice if Clang followed the GCC behaviour here. Specifically, this
would be nice for GLib: we have a G_GNUC_NON_NULL(P) macro which expands to
__attribute__((nonnull(P))) if the attribute is supported. We can’t make the
macro variadic, as we still need to support old compilers (such as MS Visual
C), but we can allow the macro to be instantiated several times.

[1]:
<a href="http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html#index-g_t_0040code_007bnonnull_007d-function-attribute-2825">http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html#index-g_t_0040code_007bnonnull_007d-function-attribute-2825</a>
[2]: <a href="https://bugzilla.gnome.org/show_bug.cgi?id=113075">https://bugzilla.gnome.org/show_bug.cgi?id=113075</a></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>