adamcz updated this revision to Diff 305818. adamcz added a comment. Added [clang] in commit description
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D91162/new/ https://reviews.llvm.org/D91162 Files: clang/lib/AST/ExprConstant.cpp clang/test/SemaCXX/constexpr-value-dependent.cpp Index: clang/test/SemaCXX/constexpr-value-dependent.cpp =================================================================== --- /dev/null +++ clang/test/SemaCXX/constexpr-value-dependent.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify + +template<int x> 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<x>(1)); // expected-error {{no matching function for call to 'f'}} expected-note@-7{{candidate template ignored}} +} Index: clang/lib/AST/ExprConstant.cpp =================================================================== --- clang/lib/AST/ExprConstant.cpp +++ 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.
Index: clang/test/SemaCXX/constexpr-value-dependent.cpp =================================================================== --- /dev/null +++ clang/test/SemaCXX/constexpr-value-dependent.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify + +template<int x> 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<x>(1)); // expected-error {{no matching function for call to 'f'}} expected-note@-7{{candidate template ignored}} +} Index: clang/lib/AST/ExprConstant.cpp =================================================================== --- clang/lib/AST/ExprConstant.cpp +++ 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.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits