llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> This should never happen I believe, but if it does, the "non-literal type '<dependent type>'" diagnostic is weird. That dependent type should never reach this stage I believe. If we actually try to generate code for this, we hit an assertion in codegen: https://godbolt.org/z/b19P9eqf9 --- Full diff: https://github.com/llvm/llvm-project/pull/108598.diff 2 Files Affected: - (modified) clang/lib/AST/ExprConstant.cpp (+2) - (modified) clang/test/SemaCXX/cxx2a-template-lambdas.cpp (+1-3) ``````````diff diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 6387e375dda79c..b98904ea3a2bbd 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -16009,6 +16009,8 @@ static bool Evaluate(APValue &Result, EvalInfo &Info, const Expr *E) { if (!EvaluateAtomic(E, nullptr, Result, Info)) return false; } + } else if (T->isDependentType()) { + return false; } else if (Info.getLangOpts().CPlusPlus11) { Info.FFDiag(E, diag::note_constexpr_nonliteral) << E->getType(); return false; diff --git a/clang/test/SemaCXX/cxx2a-template-lambdas.cpp b/clang/test/SemaCXX/cxx2a-template-lambdas.cpp index 00ba291fbd1981..8a7191f76c3e1d 100644 --- a/clang/test/SemaCXX/cxx2a-template-lambdas.cpp +++ b/clang/test/SemaCXX/cxx2a-template-lambdas.cpp @@ -43,13 +43,11 @@ struct ShadowMe { #if __cplusplus >= 201102L template<typename T> constexpr T outer() { - // FIXME: The C++11 error seems wrong return []<T x>() { return x; }.template operator()<123>(); // expected-error {{no matching member function}} \ expected-note {{candidate template ignored}} \ - cxx11-note {{non-literal type '<dependent type>' cannot be used in a constant expression}} \ cxx14-note {{non-literal type}} } -static_assert(outer<int>() == 123); // cxx11-cxx14-error {{not an integral constant expression}} cxx11-cxx14-note {{in call}} +static_assert(outer<int>() == 123); // cxx11-cxx14-error {{not an integral constant expression}} cxx14-note {{in call}} template int *outer<int *>(); // expected-note {{in instantiation}} #endif `````````` </details> https://github.com/llvm/llvm-project/pull/108598 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits