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: unassignedb...@nondot.org
          Reporter: jonathan.leffler+l...@gmail.com
                CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to