diff options
author | Keno Fischer <keno@alumni.harvard.edu> | 2017-06-01 18:54:16 +0000 |
---|---|---|
committer | Keno Fischer <keno@alumni.harvard.edu> | 2017-06-01 18:54:16 +0000 |
commit | 4792222fb527bcb491d4b43a992be9d75ff6230f (patch) | |
tree | 4d25f01dfcff7d9391a6fb25ccae78884a4504bf /clang/lib/Sema/SemaDecl.cpp | |
parent | 3a424a857f767d7b0b850c56bd51400440752e32 (diff) | |
download | bcm5719-llvm-4792222fb527bcb491d4b43a992be9d75ff6230f.tar.gz bcm5719-llvm-4792222fb527bcb491d4b43a992be9d75ff6230f.zip |
[SemaCXX] Add diagnostics to require_constant_initialization
Summary:
This hooks up the detailed diagnostics of why constant initialization was
not possible if require_constant_initialization reports an error.
I have updated the test to account for the new notes.
Reviewed By: EricWF
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D24371
llvm-svn: 304451
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index a9adbec4f84..ea1f7526a83 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -11116,6 +11116,17 @@ void Sema::CheckCompleteVariableDeclaration(VarDecl *var) { << Init->getSourceRange(); Diag(attr->getLocation(), diag::note_declared_required_constant_init_here) << attr->getRange(); + if (getLangOpts().CPlusPlus11) { + APValue Value; + SmallVector<PartialDiagnosticAt, 8> Notes; + Init->EvaluateAsInitializer(Value, getASTContext(), var, Notes); + for (auto &it : Notes) + Diag(it.first, it.second); + } else { + Diag(CacheCulprit->getExprLoc(), + diag::note_invalid_subexpr_in_const_expr) + << CacheCulprit->getSourceRange(); + } } } else if (!var->isConstexpr() && IsGlobal && |