Skip to content

Commit 6524f66

Browse files
committed
[clang][ExprConst] Explicitly reject dependent types without diagnostic
This should never happen I believe, but if it does, the "non-literal type '<dependent type>'" diagnostic is weird.
1 parent cd774c8 commit 6524f66

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

clang/lib/AST/ExprConstant.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16009,6 +16009,8 @@ static bool Evaluate(APValue &Result, EvalInfo &Info, const Expr *E) {
1600916009
if (!EvaluateAtomic(E, nullptr, Result, Info))
1601016010
return false;
1601116011
}
16012+
} else if (T->isDependentType()) {
16013+
return false;
1601216014
} else if (Info.getLangOpts().CPlusPlus11) {
1601316015
Info.FFDiag(E, diag::note_constexpr_nonliteral) << E->getType();
1601416016
return false;

clang/test/SemaCXX/cxx2a-template-lambdas.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,11 @@ struct ShadowMe {
4343
#if __cplusplus >= 201102L
4444
template<typename T>
4545
constexpr T outer() {
46-
// FIXME: The C++11 error seems wrong
4746
return []<T x>() { return x; }.template operator()<123>(); // expected-error {{no matching member function}} \
4847
expected-note {{candidate template ignored}} \
49-
cxx11-note {{non-literal type '<dependent type>' cannot be used in a constant expression}} \
5048
cxx14-note {{non-literal type}}
5149
}
52-
static_assert(outer<int>() == 123); // cxx11-cxx14-error {{not an integral constant expression}} cxx11-cxx14-note {{in call}}
50+
static_assert(outer<int>() == 123); // cxx11-cxx14-error {{not an integral constant expression}} cxx14-note {{in call}}
5351
template int *outer<int *>(); // expected-note {{in instantiation}}
5452
#endif
5553

0 commit comments

Comments
 (0)