Skip to content

Thread Safety Analysis "guarded_by" attribute doesn't work for struct fields in C code #20777

@llvmbot

Description

@llvmbot
Bugzilla Link 20403
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @AaronBallman,@benvanik,@LebedevRI,@mikaelholmen,@nashidau,@zygoloid

Extended Description

$ cat demo.c
struct mutex {
        int x;
};

struct guarded_int {
        struct mutex mu;
        int value __attribute__((guarded_by(mu))); 
};

$ clang -c demo.c
demo.c:7:38: error: use of undeclared identifier 'mu'
        int value __attribute__((guarded_by(mu)));
                                            ^
1 error generated.

Clang compiles the code okay with "-x c++", so it seems to be a bug in how Thread Safety Analysis is wired into the C frontend.

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