Index: clang/include/clang/Basic/DiagnosticParseKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticParseKinds.td +++ clang/include/clang/Basic/DiagnosticParseKinds.td @@ -709,7 +709,7 @@ def err_ms_property_expected_comma_or_rparen : Error< "expected ',' or ')' at end of property accessor list">; def err_ms_property_initializer : Error< - "property declaration cannot have an in-class initializer">; + "property declaration cannot have a default member initializer">; def warn_cxx20_compat_explicit_bool : Warning< "this expression will be parsed as explicit(bool) in C++20">, @@ -859,13 +859,13 @@ "%select{defaulted|deleted}0 function definitions are incompatible with C++98">, InGroup, DefaultIgnore; -// C++11 in-class member initialization +// C++11 default member initialization def ext_nonstatic_member_init : ExtWarn< - "in-class initialization of non-static data member is a C++11 extension">, - InGroup; + "default member initialization of non-static data member is a C++11 " + "extension">, InGroup; def warn_cxx98_compat_nonstatic_member_init : Warning< - "in-class initialization of non-static data members is incompatible with C++98">, - InGroup, DefaultIgnore; + "default member initialization of non-static data members is incompatible " + "with C++98">, InGroup, DefaultIgnore; def ext_bitfield_member_init: ExtWarn< "default member initializer for bit-field is a C++20 extension">, InGroup; @@ -873,7 +873,7 @@ "default member initializer for bit-field is incompatible with " "C++ standards before C++20">, InGroup, DefaultIgnore; def err_incomplete_array_member_init: Error< - "array bound cannot be deduced from an in-class initializer">; + "array bound cannot be deduced from a default member initializer">; // C++11 alias-declaration def ext_alias_declaration : ExtWarn< Index: clang/include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticSemaKinds.td +++ clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -1842,7 +1842,7 @@ def note_nontrivial_user_provided : Note< "because %select{base class of |field of |}0type %1 has a user-provided " "%sub{select_special_member_kind}2">; -def note_nontrivial_in_class_init : Note< +def note_nontrivial_default_member_init : Note< "because field %0 has an initializer">; def note_nontrivial_param_type : Note< "because its parameter is %diff{of type $, not $|of the wrong type}2,3">; @@ -8503,35 +8503,37 @@ def err_not_direct_base_or_virtual : Error< "type %0 is not a direct or virtual base of %1">; -def err_in_class_initializer_non_const : Error< +def err_default_member_initializer_non_const : Error< "non-const static data member must be initialized out of line">; -def err_in_class_initializer_volatile : Error< +def err_default_member_initializer_volatile : Error< "static const volatile data member must be initialized out of line">; -def err_in_class_initializer_bad_type : Error< +def err_default_member_initializer_bad_type : Error< "static data member of type %0 must be initialized out of line">; -def ext_in_class_initializer_float_type : ExtWarn< - "in-class initializer for static data member of type %0 is a GNU extension">, - InGroup; -def ext_in_class_initializer_float_type_cxx11 : ExtWarn< - "in-class initializer for static data member of type %0 requires " +def ext_default_member_initializer_float_type : ExtWarn< + "default member initializer for static data member of type %0 is a GNU " + "extension">, InGroup; +def ext_default_member_initializer_float_type_cxx11 : ExtWarn< + "default member initializer for static data member of type %0 requires " "'constexpr' specifier">, InGroup, DefaultError; -def note_in_class_initializer_float_type_cxx11 : Note<"add 'constexpr'">; -def err_in_class_initializer_literal_type : Error< - "in-class initializer for static data member of type %0 requires " +def note_default_member_initializer_float_type_cxx11 : Note<"add 'constexpr'">; +def err_default_member_initializer_literal_type : Error< + "default member initializer for static data member of type %0 requires " "'constexpr' specifier">; -def err_in_class_initializer_non_constant : Error< - "in-class initializer for static data member is not a constant expression">; -def err_in_class_initializer_not_yet_parsed : Error< +def err_default_member_initializer_non_constant : Error< + "default member initializer for static data member is not a constant " + "expression">; +def err_default_member_initializer_not_yet_parsed : Error< "default member initializer for %1 needed within definition of enclosing " "class %0 outside of member functions">; -def note_in_class_initializer_not_yet_parsed : Note< +def note_default_member_initializer_not_yet_parsed : Note< "default member initializer declared here">; -def err_in_class_initializer_cycle +def err_default_member_initializer_cycle : Error<"default member initializer for %0 uses itself">; -def ext_in_class_initializer_non_constant : Extension< - "in-class initializer for static data member is not a constant expression; " - "folding it to a constant is a GNU extension">, InGroup; +def ext_default_member_initializer_non_constant : Extension< + "default member initializer for static data member is not a constant " + "expression; folding it to a constant is a GNU extension">, + InGroup; def err_thread_dynamic_init : Error< "initializer for thread-local variable must be a constant expression">; Index: clang/lib/Sema/SemaDecl.cpp =================================================================== --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -12251,8 +12251,8 @@ // Require constness. } else if (!DclT.isConstQualified()) { - Diag(VDecl->getLocation(), diag::err_in_class_initializer_non_const) - << Init->getSourceRange(); + Diag(VDecl->getLocation(), diag::err_default_member_initializer_non_const) + << Init->getSourceRange(); VDecl->setInvalidDecl(); // We allow integer constant expressions in all cases. @@ -12262,7 +12262,8 @@ if (getLangOpts().CPlusPlus11 && DclT.isVolatileQualified()) // In C++11, a non-constexpr const static data member with an // in-class initializer cannot be volatile. - Diag(VDecl->getLocation(), diag::err_in_class_initializer_volatile); + Diag(VDecl->getLocation(), + diag::err_default_member_initializer_volatile); else if (Init->isValueDependent()) ; // Nothing to check. else if (Init->isIntegerConstantExpr(Context, &Loc)) @@ -12273,13 +12274,13 @@ else if (Init->isEvaluatable(Context)) { // If we can constant fold the initializer through heroics, accept it, // but report this as a use of an extension for -pedantic. - Diag(Loc, diag::ext_in_class_initializer_non_constant) - << Init->getSourceRange(); + Diag(Loc, diag::ext_default_member_initializer_non_constant) + << Init->getSourceRange(); } else { // Otherwise, this is some crazy unknown case. Report the issue at the // location provided by the isIntegerConstantExpr failed check. - Diag(Loc, diag::err_in_class_initializer_non_constant) - << Init->getSourceRange(); + Diag(Loc, diag::err_default_member_initializer_non_constant) + << Init->getSourceRange(); VDecl->setInvalidDecl(); } @@ -12289,32 +12290,35 @@ // it anyway and provide a fixit to add the 'constexpr'. if (getLangOpts().CPlusPlus11) { Diag(VDecl->getLocation(), - diag::ext_in_class_initializer_float_type_cxx11) + diag::ext_default_member_initializer_float_type_cxx11) << DclT << Init->getSourceRange(); Diag(VDecl->getBeginLoc(), - diag::note_in_class_initializer_float_type_cxx11) + diag::note_default_member_initializer_float_type_cxx11) << FixItHint::CreateInsertion(VDecl->getBeginLoc(), "constexpr "); } else { - Diag(VDecl->getLocation(), diag::ext_in_class_initializer_float_type) - << DclT << Init->getSourceRange(); + Diag(VDecl->getLocation(), + diag::ext_default_member_initializer_float_type) + << DclT << Init->getSourceRange(); if (!Init->isValueDependent() && !Init->isEvaluatable(Context)) { - Diag(Init->getExprLoc(), diag::err_in_class_initializer_non_constant) - << Init->getSourceRange(); + Diag(Init->getExprLoc(), + diag::err_default_member_initializer_non_constant) + << Init->getSourceRange(); VDecl->setInvalidDecl(); } } // Suggest adding 'constexpr' in C++11 for literal types. } else if (getLangOpts().CPlusPlus11 && DclT->isLiteralType(Context)) { - Diag(VDecl->getLocation(), diag::err_in_class_initializer_literal_type) + Diag(VDecl->getLocation(), + diag::err_default_member_initializer_literal_type) << DclT << Init->getSourceRange() << FixItHint::CreateInsertion(VDecl->getBeginLoc(), "constexpr "); VDecl->setConstexpr(true); } else { - Diag(VDecl->getLocation(), diag::err_in_class_initializer_bad_type) - << DclT << Init->getSourceRange(); + Diag(VDecl->getLocation(), diag::err_default_member_initializer_bad_type) + << DclT << Init->getSourceRange(); VDecl->setInvalidDecl(); } } else if (VDecl->isFileVarDecl()) { Index: clang/lib/Sema/SemaDeclCXX.cpp =================================================================== --- clang/lib/Sema/SemaDeclCXX.cpp +++ clang/lib/Sema/SemaDeclCXX.cpp @@ -9403,7 +9403,8 @@ // brace-or-equal-initializer if (CSM == Sema::CXXDefaultConstructor && FI->hasInClassInitializer()) { if (Diagnose) - S.Diag(FI->getLocation(), diag::note_nontrivial_in_class_init) << FI; + S.Diag(FI->getLocation(), diag::note_nontrivial_default_member_init) + << FI; return false; } @@ -15080,9 +15081,10 @@ // constructor before the initializer is lexically complete will ultimately // come here at which point we can diagnose it. RecordDecl *OutermostClass = ParentRD->getOuterLexicalRecordContext(); - Diag(Loc, diag::err_in_class_initializer_not_yet_parsed) + Diag(Loc, diag::err_default_member_initializer_not_yet_parsed) << OutermostClass << Field; - Diag(Field->getEndLoc(), diag::note_in_class_initializer_not_yet_parsed); + Diag(Field->getEndLoc(), + diag::note_default_member_initializer_not_yet_parsed); // Recover by marking the field invalid, unless we're in a SFINAE context. if (!isSFINAEContext()) Field->setInvalidDecl(); Index: clang/lib/Sema/SemaTemplateInstantiate.cpp =================================================================== --- clang/lib/Sema/SemaTemplateInstantiate.cpp +++ clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -2972,9 +2972,10 @@ RecordDecl *PatternRD = Pattern->getParent(); RecordDecl *OutermostClass = PatternRD->getOuterLexicalRecordContext(); Diag(PointOfInstantiation, - diag::err_in_class_initializer_not_yet_parsed) + diag::err_default_member_initializer_not_yet_parsed) << OutermostClass << Pattern; - Diag(Pattern->getEndLoc(), diag::note_in_class_initializer_not_yet_parsed); + Diag(Pattern->getEndLoc(), + diag::note_default_member_initializer_not_yet_parsed); Instantiation->setInvalidDecl(); return true; } @@ -2984,7 +2985,7 @@ return true; if (Inst.isAlreadyInstantiating()) { // Error out if we hit an instantiation cycle for this initializer. - Diag(PointOfInstantiation, diag::err_in_class_initializer_cycle) + Diag(PointOfInstantiation, diag::err_default_member_initializer_cycle) << Instantiation; return true; } Index: clang/test/Parser/MicrosoftExtensions.cpp =================================================================== --- clang/test/Parser/MicrosoftExtensions.cpp +++ clang/test/Parser/MicrosoftExtensions.cpp @@ -349,7 +349,7 @@ __declspec(property(get=GetV,)) int V10; // expected-error {{expected 'get' or 'put' in property declaration}} __declspec(property(get=GetV,put=SetV)) int V11; // no-warning __declspec(property(get=GetV,put=SetV,get=GetV)) int V12; // expected-error {{property declaration specifies 'get' accessor twice}} - __declspec(property(get=GetV)) int V13 = 3; // expected-error {{property declaration cannot have an in-class initializer}} + __declspec(property(get=GetV)) int V13 = 3; // expected-error {{property declaration cannot have a default member initializer}} int GetV() { return 123; } void SetV(int v) {} Index: clang/test/Parser/cxx-class.cpp =================================================================== --- clang/test/Parser/cxx-class.cpp +++ clang/test/Parser/cxx-class.cpp @@ -59,14 +59,14 @@ } y; } bug3177; -// check that we don't consume the token after the access specifier +// check that we don't consume the token after the access specifier // when it's not a colon class D { public // expected-error{{expected ':'}} int i; }; -// consume the token after the access specifier if it's a semicolon +// consume the token after the access specifier if it's a semicolon // that was meant to be a colon class E { public; // expected-error{{expected ':'}} @@ -229,34 +229,34 @@ class PR20760_a { int a = ); // expected-error {{expected expression}} #if __cplusplus <= 199711L - // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}} + // expected-warning@-2 {{default member initialization of non-static data member is a C++11 extension}} #endif int b = }; // expected-error {{expected expression}} #if __cplusplus <= 199711L - // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}} + // expected-warning@-2 {{default member initialization of non-static data member is a C++11 extension}} #endif int c = ]; // expected-error {{expected expression}} #if __cplusplus <= 199711L - // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}} + // expected-warning@-2 {{default member initialization of non-static data member is a C++11 extension}} #endif }; class PR20760_b { int d = d); // expected-error {{expected ';'}} #if __cplusplus <= 199711L - // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}} + // expected-warning@-2 {{default member initialization of non-static data member is a C++11 extension}} #endif int e = d]; // expected-error {{expected ';'}} #if __cplusplus <= 199711L - // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}} + // expected-warning@-2 {{default member initialization of non-static data member is a C++11 extension}} #endif int f = d // expected-error {{expected ';'}} #if __cplusplus <= 199711L - // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}} + // expected-warning@-2 {{default member initialization of non-static data member is a C++11 extension}} #endif }; Index: clang/test/SemaCXX/PR9572.cpp =================================================================== --- clang/test/SemaCXX/PR9572.cpp +++ clang/test/SemaCXX/PR9572.cpp @@ -21,7 +21,7 @@ const int kBlah = 3; #if __cplusplus <= 199711L - // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}} + // expected-warning@-2 {{default member initialization of non-static data member is a C++11 extension}} #endif Foo(); Index: clang/test/SemaCXX/class.cpp =================================================================== --- clang/test/SemaCXX/class.cpp +++ clang/test/SemaCXX/class.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -Wc++11-compat %s +// RUN: %clang_cc1 -fsyntax-only -verify -Wc++11-compat %s // RUN: %clang_cc1 -fsyntax-only -verify -Wc++11-compat %s -std=c++98 class C { public: @@ -44,11 +44,11 @@ int i = 0; #if __cplusplus <= 199711L - // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}} + // expected-warning@-2 {{default member initialization of non-static data member is a C++11 extension}} #endif static int si = 0; // expected-error {{non-const static data member must be initialized out of line}} static const NestedC ci = 0; // expected-error {{static data member of type 'const C::NestedC' must be initialized out of line}} - static const int nci = vs; // expected-error {{in-class initializer for static data member is not a constant expression}} + static const int nci = vs; // expected-error {{default member initializer for static data member is not a constant expression}} static const int vi = 0; static const volatile int cvi = 0; // ok, illegal in C++11 #if __cplusplus >= 201103L @@ -155,7 +155,7 @@ public: struct A { } mutable *member; }; - + void f(const EnclosingClass &ec) { ec.member = 0; } @@ -187,8 +187,8 @@ struct A { #if __cplusplus <= 199711L - static const float x = 5.0f; // expected-warning {{in-class initializer for static data member of type 'const float' is a GNU extension}} - static const float y = foo(); // expected-warning {{in-class initializer for static data member of type 'const float' is a GNU extension}} expected-error {{in-class initializer for static data member is not a constant expression}} + static const float x = 5.0f; // expected-warning {{default member initializer for static data member of type 'const float' is a GNU extension}} + static const float y = foo(); // expected-warning {{default member initializer for static data member of type 'const float' is a GNU extension}} expected-error {{default member initializer for static data member is not a constant expression}} #else static constexpr float x = 5.0f; static constexpr float y = foo(); // expected-error {{constexpr variable 'y' must be initialized by a constant expression}} expected-note {{non-constexpr function 'foo' cannot be used in a constant expression}} @@ -208,6 +208,6 @@ } } -struct PR9989 { - static int const PR9989_Member = sizeof PR9989_Member; +struct PR9989 { + static int const PR9989_Member = sizeof PR9989_Member; }; Index: clang/test/SemaCXX/cxx0x-class.cpp =================================================================== --- clang/test/SemaCXX/cxx0x-class.cpp +++ clang/test/SemaCXX/cxx0x-class.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -Wno-uninitialized -fsyntax-only -verify -std=c++11 -Wno-error=static-float-init %s +// RUN: %clang_cc1 -Wno-uninitialized -fsyntax-only -verify -std=c++11 -Wno-error=static-float-init %s int vs = 0; @@ -11,7 +11,7 @@ int i = 0; static int si = 0; // expected-error {{non-const static data member must be initialized out of line}} static const NestedC ci = 0; // expected-error {{static data member of type 'const C::NestedC' must be initialized out of line}} - static const int nci = vs; // expected-error {{in-class initializer for static data member is not a constant expression}} + static const int nci = vs; // expected-error {{default member initializer for static data member is not a constant expression}} static const int vi = 0; static const volatile int cvi = 0; // expected-error {{static const volatile data member must be initialized out of line}} }; Index: clang/test/SemaCXX/cxx98-compat.cpp =================================================================== --- clang/test/SemaCXX/cxx98-compat.cpp +++ clang/test/SemaCXX/cxx98-compat.cpp @@ -104,7 +104,7 @@ auto f() -> int; // expected-warning {{trailing return types are incompatible with C++98}} #ifdef CXX14COMPAT -auto ff() { return 5; } // expected-warning {{'auto' type specifier is incompatible with C++98}} +auto ff() { return 5; } // expected-warning {{'auto' type specifier is incompatible with C++98}} // expected-warning@-1 {{return type deduction is incompatible with C++ standards before C++14}} #endif @@ -122,7 +122,7 @@ } struct InClassInit { - int n = 0; // expected-warning {{in-class initialization of non-static data members is incompatible with C++98}} + int n = 0; // expected-warning {{default member initialization of non-static data members is incompatible with C++98}} }; struct OverrideControlBase { Index: clang/test/SemaCXX/gnu-flags.cpp =================================================================== --- clang/test/SemaCXX/gnu-flags.cpp +++ clang/test/SemaCXX/gnu-flags.cpp @@ -2,9 +2,9 @@ // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -DNONE -Wno-gnu // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -DNONE -Wno-gnu -// RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wgnu -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -DALL -Wgnu -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -DALL -Wgnu +// RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wgnu +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -DALL -Wgnu +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -DALL -Wgnu // RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wno-gnu \ // RUN: -Wgnu-anonymous-struct -Wredeclared-class-member \ @@ -84,7 +84,7 @@ #if (ALL || FOLDINGCONSTANT) && (__cplusplus <= 199711L) // C++03 or earlier modes -// expected-warning@+4 {{in-class initializer for static data member is not a constant expression; folding it to a constant is a GNU extension}} +// expected-warning@+4 {{default member initializer for static data member is not a constant expression; folding it to a constant is a GNU extension}} #endif struct fic { Index: clang/test/SemaCXX/member-init.cpp =================================================================== --- clang/test/SemaCXX/member-init.cpp +++ clang/test/SemaCXX/member-init.cpp @@ -21,20 +21,20 @@ }; struct UnknownBound { - int as[] = { 1, 2, 3 }; // expected-error {{array bound cannot be deduced from an in-class initializer}} + int as[] = { 1, 2, 3 }; // expected-error {{array bound cannot be deduced from a default member initializer}} int bs[4] = { 4, 5, 6, 7 }; - int cs[] = { 8, 9, 10 }; // expected-error {{array bound cannot be deduced from an in-class initializer}} + int cs[] = { 8, 9, 10 }; // expected-error {{array bound cannot be deduced from a default member initializer}} }; template struct T { static const int B; }; template<> struct T<2> { template using B = int; }; const int C = 0, D = 0; struct S { - int as[] = { decltype(x)::B(0) }; // expected-error {{array bound cannot be deduced from an in-class initializer}} + int as[] = { decltype(x)::B(0) }; // expected-error {{array bound cannot be deduced from a default member initializer}} T x; // test that we handle invalid array bound deductions without crashing when the declarator name is itself invalid operator int[](){}; // expected-error {{'operator int' cannot be the name of a variable or data member}} \ - // expected-error {{array bound cannot be deduced from an in-class initializer}} + // expected-error {{array bound cannot be deduced from a default member initializer}} }; struct ThrowCtor { ThrowCtor(int) noexcept(false); }; @@ -62,7 +62,7 @@ // PR10578 / namespace PR10578 { template - struct X { + struct X { X() { T* x = 1; // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}} expected-warning {{unused variable}} } Index: clang/test/SemaCXX/warn-static-const-float.cpp =================================================================== --- clang/test/SemaCXX/warn-static-const-float.cpp +++ clang/test/SemaCXX/warn-static-const-float.cpp @@ -10,10 +10,10 @@ #if NONE // expected-no-diagnostics #elif ERR -// expected-error@20 {{in-class initializer for static data member of type 'const double' requires 'constexpr' specifier}} +// expected-error@20 {{default member initializer for static data member of type 'const double' requires 'constexpr' specifier}} // expected-note@20 {{add 'constexpr'}} #elif EXT -// expected-warning@20 {{in-class initializer for static data member of type 'const double' is a GNU extension}} +// expected-warning@20 {{default member initializer for static data member of type 'const double' is a GNU extension}} #endif struct X { Index: clang/test/SemaTemplate/instantiate-static-var.cpp =================================================================== --- clang/test/SemaTemplate/instantiate-static-var.cpp +++ clang/test/SemaTemplate/instantiate-static-var.cpp @@ -5,7 +5,7 @@ template class X { public: - static const T value = 10 / Divisor; // expected-error{{in-class initializer for static data member is not a constant expression}} + static const T value = 10 / Divisor; // expected-error{{default member initializer for static data member is not a constant expression}} }; int array1[X::value == 5? 1 : -1]; @@ -14,11 +14,11 @@ template class Y { - static const T value = 0; + static const T value = 0; #if __cplusplus <= 199711L -// expected-warning@-2 {{in-class initializer for static data member of type 'const float' is a GNU extension}} +// expected-warning@-2 {{default member initializer for static data member of type 'const float' is a GNU extension}} #else -// expected-error@-4 {{in-class initializer for static data member of type 'const float' requires 'constexpr' specifier}} +// expected-error@-4 {{default member initializer for static data member of type 'const float' requires 'constexpr' specifier}} // expected-note@-5 {{add 'constexpr'}} #endif }; @@ -38,7 +38,7 @@ struct DefCon {}; -struct NoDefCon { +struct NoDefCon { NoDefCon(const NoDefCon&); // expected-note{{candidate constructor}} }; @@ -103,7 +103,7 @@ } namespace PR6449 { - template + template struct X0 { static const bool var = false; }; @@ -116,7 +116,7 @@ static const bool var = false; }; - template + template const bool X1::var; template class X0;