diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -11592,6 +11592,9 @@ } if (const auto *FD = dyn_cast(PV->getDeclContext())) { + // Skip function template not specialized yet. + if (FD->getTemplatedKind() == FunctionDecl::TK_FunctionTemplate) + return; auto ParamIter = llvm::find(FD->parameters(), PV); assert(ParamIter != FD->param_end()); unsigned ParamNo = std::distance(FD->param_begin(), ParamIter); diff --git a/clang/test/SemaTemplate/decltype.cpp b/clang/test/SemaTemplate/decltype.cpp new file mode 100644 --- /dev/null +++ b/clang/test/SemaTemplate/decltype.cpp @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s +// no crash & no diag + +// expected-no-diagnostics +template +auto foo(T x) -> decltype((x == nullptr), *x) { + return *x; +} + +void bar() { + foo(new int); +}