This patch would cause clang emit more diagnostics, but it is much better than https://reviews.llvm.org/D76831
cpp struct A { A(int); ~A() = delete; }; void k() { A a; }
before the patch:
/tmp/t3.cpp:24:5: error: no matching constructor for initialization of 'A' A a; ^ /tmp/t3.cpp:20:3: note: candidate constructor not viable: requires 1 argument, but 0 were provided A(int); ^ /tmp/t3.cpp:19:8: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided struct A {
After the patch:
/tmp/t3.cpp:24:5: error: no matching constructor for initialization of 'A' A a; ^ /tmp/t3.cpp:20:3: note: candidate constructor not viable: requires 1 argument, but 0 were provided A(int); ^ /tmp/t3.cpp:19:8: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided struct A { ^ /tmp/t3.cpp:24:5: error: attempt to use a deleted function A a; ^ /tmp/t3.cpp:21:3: note: '~A' has been explicitly marked deleted here ~A() = delete;
Tempting as it is, I'm not sure we should leave a big comment around describing code that isn't here.
Maybe just a minimal If default-init fails, leave var uninitialized but valid, for recovery.