Skip to content

[clang][ExprConst] Explicitly reject dependent types without diagnostic #108598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang/lib/AST/ExprConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions clang/test/SemaCXX/cxx2a-template-lambdas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading