[llvm-bugs] [Bug 33814] New: if (!@available) doesn't work and has confusing diagnostic

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jul 17 07:32:36 PDT 2017


            Bug ID: 33814
           Summary: if (!@available) doesn't work and has confusing
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nicolasweber at gmx.de
                CC: llvm-bugs at lists.llvm.org

We're using @available some in chrome, and I'm getting feedback that people are
confused about writing `if (!@available`. That's kind of understandable, here's
the current experience:

thakis at thakis:~/src/chrome/src$ cat test.mm
void f() {
  if (!@available(macos 10.10, *)) {
  // 10.10-only code here
thakis at thakis:~/src/chrome/src$
third_party/llvm-build/Release+Asserts/bin/clang -c test.mm -target
test.mm:2:8: warning: @available does not guard availability here; use if
(@available) instead [-Wunsupported-availability-guard]
  if (!@available(macos 10.10, *)) {

It'd be cool if this pattern just worked somehow (full CFG-awareness likely
isn't needed).

Even just `if (!@available()) {} else {}` so that the else block gets the
available OS would be nice.

If that isn't feasible, making the error message more explicit might help.

(But maybe just having the docs is good enough too, most people who are
confused about this haven't read the docs we added on Friday yet.)

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/20170717/d167a379/attachment-0001.html>

More information about the llvm-bugs mailing list