Skip to content

__attribute__((warn_unused_result)) does not work when applied to pointers to functions #4382

@llvmbot

Description

@llvmbot
Bugzilla Link 4010
Resolution FIXED
Resolved on Feb 22, 2010 12:49
Version unspecified
OS MacOS X
Attachments Example demonstrating problem
Reporter LLVM Bugzilla Contributor
CC @nunoplopes,@sirainen

Extended Description

version used: checker-186

Clang does not allow attribute((warn_unused_result)) to be applied to pointers to functions. For example:

char *(*functionPointerTest)(void) attribute((warn_unused_result));

Clang gives the following warning:

warnbug.c:8:57: warning: 'warn_unused_result' attribute only applies to function types
char *(*functionPointerTest)(void) attribute((warn_unused_result));
^

Expected behavior: You should be able to apply warn_unused_result to pointers to functions just as you would a common function prototype.

Attached is an example that demonstrates the problem. When run with scan-build gcc -c -Wall -Wextra warnbug.c, gcc correctly handles the attribute and correctly warns for the line that does not check/use the result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclangClang issues not falling into any other category

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions