This fixes PR34912 :)
Details
Diff Detail
Event Timeline
lib/Sema/SemaInit.cpp | ||
---|---|---|
7691–7695 | Same problem exists here, and probably in a lot of these diagnostics. For example: *int a; int &&b = {a}; says "cannot bind to lvalue of type 'void'")
Can you try to address this more generally? Perhaps: add an Expr *OnlyArg, which is null if Args.size() != 1, is the list element if Args.size() == 1 and is an InitListExpr with a single element, and is otherwise Args[0], and change all the diagnostics that are talking about a one-and-only argument to use OnlyArg? |
Addressed review comments :)
I added a test case for the crashing code.
Note: I didn't change Args[0] to OnlyArg in FK_AddressOfUnaddressableFunction, because I'm pretty sure that C++ doesn't have unaddressable functions and thus there is no need to decompose an initializer list. Is this correct?
C++ with Clang extensions has unaddressable functions. This example asserts at the moment:
void f() __attribute__((enable_if(false, ""))); int f(); void (&&p)() = {f};
... due, I think, to failing to unwrap the initializer list when diagnosing the initialization.
In any case, this looks good to me. It'll look even better with the FK_AddressOfUnaddressableFunction case fixed :)