From 1c5ae9bc1f557fb27471c20de9fb3697de7f365e Mon Sep 17 00:00:00 2001 From: Erik Pilkington Date: Tue, 10 Jul 2018 02:15:07 +0000 Subject: [PATCH] [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 --- clang/lib/Sema/SemaLookup.cpp | 2 ++ clang/test/SemaCXX/typo-correction-cxx17.cpp | 7 +++++++ 2 files changed, 9 insertions(+) create mode 100644 clang/test/SemaCXX/typo-correction-cxx17.cpp diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 984247bacc6e..4545bf9d855f 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/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/clang/test/SemaCXX/typo-correction-cxx17.cpp b/clang/test/SemaCXX/typo-correction-cxx17.cpp new file mode 100644 index 000000000000..f13749975342 --- /dev/null +++ b/clang/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'}} +} +}