[llvm-bugs] [Bug 35845] New: Glitch in documentation of diagnose_if attribute (assigning void return values to int variables)
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Jan 6 07:54:57 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=35845
Bug ID: 35845
Summary: Glitch in documentation of diagnose_if attribute
(assigning void return values to int variables)
Product: Documentation
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: General docs
Assignee: unassignedbugs at nondot.org
Reporter: jonathan.leffler+llvm at gmail.com
CC: llvm-bugs at lists.llvm.org
https://clang.llvm.org/docs/AttributeReference.html#diagnose-if
The code there is shown as:
void abs(int a)
__attribute__((diagnose_if(a >= 0, "Redundant abs call", "warning")));
void must_abs(int a)
__attribute__((diagnose_if(a >= 0, "Redundant abs call", "error")));
int val = abs(1); // warning: Redundant abs call
int val2 = must_abs(1); // error: Redundant abs call
int val3 = abs(val);
int val4 = must_abs(val);
My understanding is that functions that return void can't be used on the RHS of
an assignment, regardless of what happens with the arguments and attributes.
The occurrences of void could become int (at least, that seems to me to be the
easiest fix).
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180106/c9b8821d/attachment.html>
More information about the llvm-bugs
mailing list