Author: modocache Date: Sun Jan 6 19:25:59 2019 New Revision: 350501 URL: http://llvm.org/viewvc/llvm-project?rev=350501&view=rev Log: [SemaCXX] Fix ICE for unexpanded parameter pack
Summary: The documentation for RecursiveASTVisitor::TraverseDecl states that the Decl being traversed may be null. In fact, this is the case when a CXXCatchStmt with no exception decl is traversed. Because the visitor for diagnosing unexpanded parameter packs does not check for null, it ends up crashing when it attempts to call the Decl::isParameterPack method on a null Decl pointer. Add a null check to prevent an ICE, and a test case that would crash otherwise. Also, because the test requires C++ exceptions and C++14, change the test parameters for the entire test file. (Alternatively, I thought about adding a new test file, but went with this approach for my own convenience.) Co-authored-by: Andreas Molzer <andreas.mol...@gmx.de> Co-authored-by: Mara Bos <m-ou...@m-ou.se> Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D56271 Modified: cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp cfe/trunk/test/SemaCXX/alias-template.cpp Modified: cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp?rev=350501&r1=350500&r2=350501&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp (original) +++ cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp Sun Jan 6 19:25:59 2019 @@ -164,7 +164,7 @@ namespace { // A function parameter pack is a pack expansion, so cannot contain // an unexpanded parameter pack. Likewise for a template parameter // pack that contains any references to other packs. - if (D->isParameterPack()) + if (D && D->isParameterPack()) return true; return inherited::TraverseDecl(D); Modified: cfe/trunk/test/SemaCXX/alias-template.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/alias-template.cpp?rev=350501&r1=350500&r2=350501&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/alias-template.cpp (original) +++ cfe/trunk/test/SemaCXX/alias-template.cpp Sun Jan 6 19:25:59 2019 @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -verify -std=c++11 %s +// RUN: %clang_cc1 -verify -std=c++14 -fcxx-exceptions %s namespace RedeclAliasTypedef { template<typename U> using T = int; @@ -189,3 +189,7 @@ int sfinae_me() { return 0; } // expecte int g = sfinae_me<int>(); // expected-error{{no matching function for call to 'sfinae_me'}} } + +namespace NullExceptionDecl { +template<int... I> auto get = []() { try { } catch(...) {}; return I; }; // expected-error{{initializer contains unexpanded parameter pack 'I'}} +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits