[llvm-bugs] [Bug 42854] New: Can't fully activate -Wconsumed using #pragma clang diagnostic

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jul 31 14:43:04 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=42854

            Bug ID: 42854
           Summary: Can't fully activate -Wconsumed using #pragma clang
                    diagnostic
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: comexk at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

If you activate -Wconsumed using a pragma rather than on the command line, it
seemingly doesn't trigger the consumed analysis pass.

Given the following example code:
---

#pragma clang diagnostic error "-Wconsumed"

struct [[clang::consumable(unconsumed)]] Linear {
    [[clang::return_typestate(unconsumed)]]
    Linear() {}
    [[clang::callable_when(consumed)]]
    ~Linear() {}
};

void a() {
    Linear l;
}

---

Compiling the code as is, without passing -Wconsumed on the command line, I get
no warnings or errors.

The pragma does enable -Wconsumed warnings about malformed declarations: if I
e.g. comment out the consumable attribute on Linear, I get:

> error: consumed analysis attribute is attached to member of class 'Linear' which isn't marked as consumable [-Werror,-Wconsumed]

However, without commenting anything out, I expect this diagnostic from a():

> error: invalid invocation of method '~Linear' on object 'l' while it is in the 'unconsumed' state [-Werror,-Wconsumed]

I get this if and only if I pass -Wconsumed on the command line.

Tested on Compiler Explorer's "x86-64 clang (trunk)".

-- 
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/20190731/62aa6c57/attachment-0001.html>


More information about the llvm-bugs mailing list