diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -5981,6 +5981,9 @@ static bool EvaluateCallArg(const ParmVarDecl *PVD, const Expr *Arg, CallRef Call, EvalInfo &Info, bool NonNull = false) { + if (Arg->isValueDependent()) + return false; + LValue LV; // Create the parameter slot and register its destruction. For a vararg // argument, create a temporary. diff --git a/clang/test/SemaCXX/constexpr-value-dependent.cpp b/clang/test/SemaCXX/constexpr-value-dependent.cpp new file mode 100644 --- /dev/null +++ b/clang/test/SemaCXX/constexpr-value-dependent.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify + +template constexpr int f(int y) { + return x * y; +} + +// The error makes the CallExpr become potentially value-dependent. This used to +// cause a crash. +constexpr int test(int x) { + return f<1>(f(1)); // expected-error {{no matching function for call to 'f'}} expected-note@-7{{candidate template ignored}} +}