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 @@ -13773,7 +13773,7 @@ case CK_PointerToIntegral: { CCEDiag(E, diag::note_constexpr_invalid_cast) - << 2 << Info.Ctx.getLangOpts().CPlusPlus; + << 2 << Info.Ctx.getLangOpts().CPlusPlus << E->getSourceRange(); LValue LV; if (!EvaluatePointer(SubExpr, LV, Info)) diff --git a/clang/lib/AST/Interp/Interp.cpp b/clang/lib/AST/Interp/Interp.cpp --- a/clang/lib/AST/Interp/Interp.cpp +++ b/clang/lib/AST/Interp/Interp.cpp @@ -469,7 +469,7 @@ const SourceInfo &E = S.Current->getSource(OpPC); S.CCEDiag(E, diag::note_constexpr_invalid_cast) - << 2 << S.getLangOpts().CPlusPlus; + << 2 << S.getLangOpts().CPlusPlus << S.Current->getRange(OpPC); return false; } diff --git a/clang/test/Misc/constexpr-source-ranges.cpp b/clang/test/Misc/constexpr-source-ranges.cpp --- a/clang/test/Misc/constexpr-source-ranges.cpp +++ b/clang/test/Misc/constexpr-source-ranges.cpp @@ -7,3 +7,9 @@ } // CHECK: constexpr-source-ranges.cpp:5:3:{5:3-5:10} + + +constexpr int I = 12; +constexpr const int *P = &I; +constexpr long L = (long)P; +// CHECK: constexpr-source-ranges.cpp:14:20:{14:20-14:27}