def ext_in_class_initializer_float_type : ExtWarn<
"in-class initializer for static data member of type %0 is a GNU extension">,
InGroup<GNU>;
+def note_in_class_initializer_float_type_constexpr : Note<
+ "use 'constexpr' specifier to silence this warning">;
def err_in_class_initializer_literal_type : Error<
"in-class initializer for static data member of type %0 requires "
"'constexpr' specifier">;
} else if (T->isFloatingType()) { // also permits complex, which is ok
Diag(VDecl->getLocation(), diag::ext_in_class_initializer_float_type)
<< T << Init->getSourceRange();
+ if (getLangOptions().CPlusPlus0x)
+ Diag(VDecl->getLocation(),
+ diag::note_in_class_initializer_float_type_constexpr)
+ << FixItHint::CreateInsertion(VDecl->getLocStart(), "constexpr ");
if (!Init->isValueDependent() &&
!Init->isConstantInitializer(Context, false)) {
static const int d;
static constexpr double e = 0.0; // ok
- static const double f = 0.0; // expected-warning {{extension}}
+ static const double f = 0.0; // expected-warning {{extension}} expected-note {{use 'constexpr' specifier}}
static char *const g = 0; // expected-error {{requires 'constexpr' specifier}}
static const NonLit h = NonLit(); // expected-error {{must be initialized out of line}}
};
float foo();
struct A {
- static const float x = 5.0f; // expected-warning {{GNU extension}}
- static const float y = foo(); // expected-warning {{GNU extension}} expected-error {{in-class initializer is not a constant expression}}
+ static const float x = 5.0f; // expected-warning {{GNU extension}} expected-note {{use 'constexpr' specifier to silence this warning}}
+ static const float y = foo(); // expected-warning {{GNU extension}} expected-note {{use 'constexpr' specifier to silence this warning}} expected-error {{in-class initializer is not a constant expression}}
static constexpr float x2 = 5.0f;
static constexpr float y2 = foo(); // expected-error {{must be initialized by a constant expression}}
};