// 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();
};
namespace rdar8367341 {
- float foo(); // expected-note 2{{here}}
+ float foo(); // expected-note {{here}}
struct A {
static const float x = 5.0f; // expected-warning {{requires 'constexpr'}}
- static const float y = foo(); // expected-warning {{requires 'constexpr'}} expected-error {{constexpr variable 'y' must be initialized by a constant expression}} expected-note {{non-constexpr function 'foo'}}
+ static const float y = foo(); // expected-warning {{requires 'constexpr'}}
static constexpr float x2 = 5.0f;
static constexpr float y2 = foo(); // expected-error {{must be initialized by a constant expression}} expected-note {{non-constexpr function 'foo'}}
};