We should not capture the type if the function return type is undeduced.
Reviewed By: adamcz
Differential Revision: https://reviews.llvm.org/D87350
for (const auto &C : CS)
ConsiderCandidate(C);
- return Result.getValueOr(QualType());
+ if (!Result)
+ return QualType();
+ auto Value = Result.getValue();
+ if (Value.isNull() || Value->isUndeducedType())
+ return QualType();
+ return Value;
}
/// FinishOverloadedCallExpr - given an OverloadCandidateSet, builds and returns
// CHECK-NEXT:| `-UnresolvedLookupExpr {{.*}} 'invalid'
struct alignas(invalid()) Aligned {};
+auto f();
+int f(double);
+// CHECK: VarDecl {{.*}} unknown_type_call 'int'
+// CHECK-NEXT: `-RecoveryExpr {{.*}} '<dependent type>'
+int unknown_type_call = f(0, 0);
+
void InvalidInitalizer(int x) {
struct Bar { Bar(); };
// CHECK: `-VarDecl {{.*}} a1 'Bar'
int v = arr(); // expected-error {{array types cannot be value-initialized}} \
expected-error {{cannot initialize a variable of type 'int' with an rvalue of type 'test8::arr'}}
}
+
+namespace test9 {
+auto f(); // expected-note {{candidate function not viable}}
+// verify no crash on evaluating the size of undeduced auto type.
+static_assert(sizeof(f(1)), ""); // expected-error {{no matching function for call to 'f'}}
+}