From: Erik Pilkington Date: Tue, 10 Jul 2018 02:15:07 +0000 (+0000) Subject: [Sema] Fix a structured binding typo correction bug X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c5845b4c8c168b6a9c41029b51573b6e7019c9fe;p=clang [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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336634 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index 984247bacc..4545bf9d85 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -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(ND)->getType(); + if (ValType.isNull()) + continue; if (ValType->isAnyPointerType() || ValType->isReferenceType()) ValType = ValType->getPointeeType(); if (const FunctionProtoType *FPT = ValType->getAs()) diff --git a/test/SemaCXX/typo-correction-cxx17.cpp b/test/SemaCXX/typo-correction-cxx17.cpp new file mode 100644 index 0000000000..f137499753 --- /dev/null +++ b/test/SemaCXX/typo-correction-cxx17.cpp @@ -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'}} +} +}