https://bugs.llvm.org/show_bug.cgi?id=45520
Bug ID: 45520
Summary: 'nodiscard' can be applied to function pointers
Product: clang
Version: 10.0
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: C++17
Assignee: unassignedclangb...@nondot.org
Reporter: tiagomacar...@gmail.com
CC: blitzrak...@gmail.com, erik.pilking...@gmail.com,
llvm-bugs@lists.llvm.org, richard-l...@metafoo.co.uk
clang, gcc, and cl disagree on the diagnostics for the code below:
https://godbolt.org/z/-zaSRh
[[nodiscard]] bool (*f)();
void _(){
f();
}
clang:
<source>:4:3: warning: ignoring return value of function declared with
'nodiscard' attribute [-Wunused-result]
f();
^
1 warning generated.
Compiler returned: 0
gcc:
<source>:1:25: warning: 'nodiscard' attribute can only be applied to functions
or to class or enumeration types [-Wattributes]
1 | [[nodiscard]] bool (*f)();
| ^
Compiler returned: 0
cl:
example.cpp
Compiler returned: 0
Looking at the standard I would think that gcc's behavior is correct?
http://eel.is/c++draft/dcl.attr.nodiscard#1.sentence-1
"The attribute-token nodiscard may be applied to the declarator-id in a
function declaration or to the declaration of a class or enumeration."
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs