Diag(DS.getConstexprSpecLoc(), diag::err_invalid_constexpr_member);
SourceLocation ConstexprLoc = DS.getConstexprSpecLoc();
if (InitStyle == ICIS_NoInit) {
- B << 0 << 0 << FixItHint::CreateReplacement(ConstexprLoc, "const");
- D.getMutableDeclSpec().ClearConstexprSpec();
- const char *PrevSpec;
- unsigned DiagID;
- bool Failed = D.getMutableDeclSpec().SetTypeQual(DeclSpec::TQ_const, ConstexprLoc,
- PrevSpec, DiagID, getLangOpts());
- (void)Failed;
- assert(!Failed && "Making a constexpr member const shouldn't fail");
+ B << 0 << 0;
+ if (D.getDeclSpec().getTypeQualifiers() & DeclSpec::TQ_const)
+ B << FixItHint::CreateRemoval(ConstexprLoc);
+ else {
+ B << FixItHint::CreateReplacement(ConstexprLoc, "const");
+ D.getMutableDeclSpec().ClearConstexprSpec();
+ const char *PrevSpec;
+ unsigned DiagID;
+ bool Failed = D.getMutableDeclSpec().SetTypeQual(
+ DeclSpec::TQ_const, ConstexprLoc, PrevSpec, DiagID, getLangOpts());
+ (void)Failed;
+ assert(!Failed && "Making a constexpr member const shouldn't fail");
+ }
} else {
B << 1;
const char *PrevSpec;
struct foo {
constexpr int i; // expected-error {{non-static data member cannot be constexpr; did you intend to make it const?}}
constexpr int j = 7; // expected-error {{non-static data member cannot be constexpr; did you intend to make it static?}}
- foo() : i(3) {
+ constexpr const int k; // expected-error {{non-static data member cannot be constexpr; did you intend to make it const?}}
+ foo() : i(3), k(4) {
}
static int get_j() {
return j;