Author: epilk Date: Mon Jul 9 19:15:07 2018 New Revision: 336634 URL: http://llvm.org/viewvc/llvm-project?rev=336634&view=rev Log: [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 Added: cfe/trunk/test/SemaCXX/typo-correction-cxx17.cpp Modified: cfe/trunk/lib/Sema/SemaLookup.cpp Modified: cfe/trunk/lib/Sema/SemaLookup.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=336634&r1=336633&r2=336634&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaLookup.cpp (original) +++ cfe/trunk/lib/Sema/SemaLookup.cpp Mon Jul 9 19:15:07 2018 @@ -4990,6 +4990,8 @@ bool FunctionCallFilterCCC::ValidateCand // 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>()) Added: cfe/trunk/test/SemaCXX/typo-correction-cxx17.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/typo-correction-cxx17.cpp?rev=336634&view=auto ============================================================================== --- cfe/trunk/test/SemaCXX/typo-correction-cxx17.cpp (added) +++ cfe/trunk/test/SemaCXX/typo-correction-cxx17.cpp Mon Jul 9 19:15:07 2018 @@ -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'}} +} +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits