Don't fixit/recover from -Wstatic-float-init when it's not an error.
Fix to change r173414 that lead to Clang changing const to constexpr even under
-Wno-static-float-init.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173835 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 3350640..702d382 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -7203,11 +7203,15 @@
// In C++98, this is a GNU extension. In C++11, it is not, but we support
// it anyway and provide a fixit to add the 'constexpr'.
if (getLangOpts().CPlusPlus11) {
- Diag(VDecl->getLocation(),
- diag::ext_in_class_initializer_float_type_cxx11)
- << DclT << Init->getSourceRange()
- << FixItHint::CreateInsertion(VDecl->getLocStart(), "constexpr ");
- VDecl->setConstexpr(true);
+ SemaDiagnosticBuilder D = Diag(VDecl->getLocation(),
+ diag::ext_in_class_initializer_float_type_cxx11);
+ D << DclT << Init->getSourceRange();
+ if (Diags.getDiagnosticLevel(diag::warn_initializer_out_of_order,
+ VDecl->getLocation()) >=
+ DiagnosticsEngine::Error) {
+ D << FixItHint::CreateInsertion(VDecl->getLocStart(), "constexpr ");
+ VDecl->setConstexpr(true);
+ }
} else {
Diag(VDecl->getLocation(), diag::ext_in_class_initializer_float_type)
<< DclT << Init->getSourceRange();