[LLVMbugs] [Bug 18063] New: Support multiple instances of the nonnull function attribute

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Nov 26 03:26:55 PST 2013


http://llvm.org/bugs/show_bug.cgi?id=18063

            Bug ID: 18063
           Summary: Support multiple instances of the nonnull function
                    attribute
           Product: clang
           Version: 3.3
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: bugzilla at tecnocode.co.uk
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

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

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20131126/e0c4ba21/attachment.html>


More information about the llvm-bugs mailing list