[Sema] Fix a structured binding typo correction bug

BindingDecls have null type until their initializer is processed, so we can't
assume that a correction candidate has non-null type.

rdar://41559582

llvm-svn: 336634
This commit is contained in:
Erik Pilkington 2018-07-10 02:15:07 +00:00
parent 25291f15e7
commit 1c5ae9bc1f
2 changed files with 9 additions and 0 deletions

View File

@ -4990,6 +4990,8 @@ bool FunctionCallFilterCCC::ValidateCandidate(const TypoCorrection &candidate) {
// determine if it is a pointer or reference to a function. If so,
// check against the number of arguments expected for the pointee.
QualType ValType = cast<ValueDecl>(ND)->getType();
if (ValType.isNull())
continue;
if (ValType->isAnyPointerType() || ValType->isReferenceType())
ValType = ValType->getPointeeType();
if (const FunctionProtoType *FPT = ValType->getAs<FunctionProtoType>())

View File

@ -0,0 +1,7 @@
// RUN: %clang_cc1 -std=c++1z -fsyntax-only -verify %s
namespace decomp_decl {
void f() {
auto [this_is_a_typo] = this_is_a_typp(); // expected-error{{use of undeclared identifier 'this_is_a_typp'}}
}
}