<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/107556>107556</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang] Clang must diagnose the use of [[lifetimebound]] annotation in void-returning functions
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang,
            clang:frontend
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          usx95
      </td>
    </tr>
</table>

<pre>
    https://godbolt.org/z/rcPnrWrr7

```cpp
#include <string>
struct S {
    void setS(const std::string& s [[clang::lifetimebound]]) { this->s = &s; }
    const std::string* s;
};

void foo() {
    S s;
 s.setS(std::string());
}
```

Lifetime analysis is currently not defined for parameters annotated with `[[lifetimebound]]` in void-returning function.
Current analysis only enforces that the annotated parameter outlives the **return** value. With no return value, this analysis is silently disabled.


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VMGOozgQ_RpzKQUREyAcOCShc9rDSn3os7FN8MqxI1c5u9mvXxnYTnpmeiTLGJfrvVevMALRXJzWHauOrOozEWnyoYv4T1tlg1ePbiK6ISsPjJ8ZP1-8Gryl3IcL4-d_GT8H-acLHyE0rOhZcVjnuliGvN3WHV4aJ21UGlh5QgrGXVj5tgSRQpQE78Ca47IDAHD3RgFqemd8L71DAiSVlJSHNZ_XgDArP0orEmAKWjNqMlc9-OgUq_o0eJuwgSaDG1a-IbCyB8ZrZOURWNM_Wb9hOkA6utbS9M_1PM9SR-8Z369UT8D3l0zAfC3oJ4KUmMYryVcvXwn_WGsE4YR9oEEwCDKGoB3ZBzhPoPRonE6yAtxEEFdNOiAI5zwJ0gr-NjRBwp0N_JVrdQHGzX3YBE0xOOMuMEYnyXiXL0pOC-lTiHf2AdqNPkiNQJMgoEm_8H6KAR_Jmvt8SgPjB8YPC8-yhruwUefwkYQ6D0ts2WX8NHfziwFo7FK_MigGq1X-6lmmulK1ZSsy3W0bXtXbpmybbOpaPXJVVntRiZHvSlXXhS7afctlvZdjM2Sm4wXfFW1Rb4uirZp8JyvRFlXLt0q3kjdsV-irMDa39n5NlyMziFF326KpqjqzYtAW5zvG-fKlcs746fOtPIzBO9JOpUDVZ6FLSJshXpDtCmuQ8IlNhux8Y5fkqodTWsA1IoEy4uI86tnTiBr8CN92-P-uGO9-02nMYrA__ggMTXHIpb8yfk7K1sfmFvxfWhLj59kCZPy8unDv-H8BAAD__wTIX4k">