Skip to content

nonnull attribute generates a warning for transparent unions #10483

@llvmbot

Description

@llvmbot
Bugzilla Link 10111
Resolution FIXED
Resolved on Jun 27, 2011 16:14
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @tkremenek

Extended Description

typedef struct {
char *str;
} Class;

typedef union {
Class *object;
} Instance attribute((transparent_union));

attribute((nonnull(1))) void Class_init(Instance this, char *str) {
this.object->str = str;
}

int main(void) {
Class obj;
Class_init(0, "Hello World");
}

Clang reports: "nonnull attribute only applies to pointer arguments". However, as transparent unions are guaranteed to contain only pointers, using nonnull is safe.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions