Sirraide wrote:

> I wanted to make you aware of this new core issue 
> https://cplusplus.github.io/CWG/issues/2876.html (which i think we should 
> have tests for). Thanks

So, as of now, this
```c++
using T = void ();
using U = int;

T a = delete ("hello");
U b = delete ("hello"), c, d = delete ("hello");

struct C {
    T e = delete ("hello");
    U f = delete ("hello");
};
```
gives
```
test.cc:4:7: error: only functions can have deleted definitions
    4 | T a = delete ("hello");
      |       ^
test.cc:5:7: error: only functions can have deleted definitions
    5 | U b = delete ("hello"), c, d = delete ("hello");
      |       ^
test.cc:5:32: error: only functions can have deleted definitions
    5 | U b = delete ("hello"), c, d = delete ("hello");
      |                                ^
test.cc:8:8: error: '= delete' is a function definition and must occur in a 
standalone declaration
    8 |         T e = delete ("hello");
      |               ^
test.cc:9:8: error: cannot delete expression of type 'const char[6]'
    9 |         U f = delete ("hello");
      |               ^      ~~~~~~~~~
```
which seems reasonable to me—unless there’s something I’m missing here, but 
it’s ill-formed either way, so so long as we’re diagnosing it, we’re fine, from 
what I can tell at least.

One thing I did just now is made sure we discard the `("message")` if we 
encounter `= delete` in a place where it doesn’t belong so we don’t issue two 
errors instead of one (there was a ‘missing semicolon at end of declaration’ 
error that imo is just noise in this context).

https://github.com/llvm/llvm-project/pull/86526
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to