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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to