[clang] 15fbae8 - Use "default member initializer" instead of "in-class initializer" for diagnostics.
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 29 12:04:37 PDT 2020
Author: Aaron Ballman
Date: 2020-09-29T15:04:23-04:00
New Revision: 15fbae8ac303d8601ea95418d4818cb50d0765e1
URL: https://github.com/llvm/llvm-project/commit/15fbae8ac303d8601ea95418d4818cb50d0765e1
DIFF: https://github.com/llvm/llvm-project/commit/15fbae8ac303d8601ea95418d4818cb50d0765e1.diff
LOG: Use "default member initializer" instead of "in-class initializer" for diagnostics.
This changes some diagnostics to use terminology from the standard
rather than invented terminology, which improves consistency with other
diagnostics as well. There are no functional changes intended other
than wording and naming.
Added:
Modified:
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/test/Parser/MicrosoftExtensions.cpp
clang/test/Parser/cxx-class.cpp
clang/test/SemaCXX/PR9572.cpp
clang/test/SemaCXX/class.cpp
clang/test/SemaCXX/cxx98-compat.cpp
clang/test/SemaCXX/member-init.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 1ac1e9d10a7a..da4e1725269f 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -709,7 +709,7 @@ def err_ms_property_expected_accessor_name : Error<
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 @@ def warn_cxx98_compat_defaulted_deleted_function : Warning<
"%select{defaulted|deleted}0 function definitions are incompatible with C++98">,
InGroup<CXX98Compat>, 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<CXX11>;
+ "default member initializer for non-static data member is a C++11 "
+ "extension">, InGroup<CXX11>;
def warn_cxx98_compat_nonstatic_member_init : Warning<
- "in-class initialization of non-static data members is incompatible with C++98">,
- InGroup<CXX98Compat>, DefaultIgnore;
+ "default member initializer for non-static data members is incompatible with "
+ "C++98">, InGroup<CXX98Compat>, DefaultIgnore;
def ext_bitfield_member_init: ExtWarn<
"default member initializer for bit-field is a C++20 extension">,
InGroup<CXX20>;
@@ -873,7 +873,7 @@ def warn_cxx17_compat_bitfield_member_init: Warning<
"default member initializer for bit-field is incompatible with "
"C++ standards before C++20">, InGroup<CXXPre20Compat>, 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<
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 8f6c7b9400fa..ed11e0d1ce3c 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1842,7 +1842,7 @@ def note_nontrivial_no_copy : Note<
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">;
@@ -8521,12 +8521,12 @@ def err_in_class_initializer_literal_type : Error<
"'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_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<
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 6558a4f6d8b2..2d2b80573a69 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9403,7 +9403,8 @@ static bool checkTrivialClassMembers(Sema &S, CXXRecordDecl *RD,
// 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 @@ ExprResult Sema::BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field) {
// 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();
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 11e03c517d01..555d8e036a64 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2972,9 +2972,10 @@ bool Sema::InstantiateInClassInitializer(
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 @@ bool Sema::InstantiateInClassInitializer(
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;
}
diff --git a/clang/test/Parser/MicrosoftExtensions.cpp b/clang/test/Parser/MicrosoftExtensions.cpp
index ddbe5aaef779..52f40677a135 100644
--- a/clang/test/Parser/MicrosoftExtensions.cpp
+++ b/clang/test/Parser/MicrosoftExtensions.cpp
@@ -349,7 +349,7 @@ struct StructWithProperty {
__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) {}
diff --git a/clang/test/Parser/cxx-class.cpp b/clang/test/Parser/cxx-class.cpp
index 576c6d7e8b97..efd1a6dc03e7 100644
--- a/clang/test/Parser/cxx-class.cpp
+++ b/clang/test/Parser/cxx-class.cpp
@@ -229,34 +229,34 @@ namespace BadFriend {
class PR20760_a {
int a = ); // expected-error {{expected expression}}
#if __cplusplus <= 199711L
- // expected-warning at -2 {{in-class initialization of non-static data member is a C++11 extension}}
+ // expected-warning at -2 {{default member initializer for non-static data member is a C++11 extension}}
#endif
int b = }; // expected-error {{expected expression}}
#if __cplusplus <= 199711L
- // expected-warning at -2 {{in-class initialization of non-static data member is a C++11 extension}}
+ // expected-warning at -2 {{default member initializer for non-static data member is a C++11 extension}}
#endif
int c = ]; // expected-error {{expected expression}}
#if __cplusplus <= 199711L
- // expected-warning at -2 {{in-class initialization of non-static data member is a C++11 extension}}
+ // expected-warning at -2 {{default member initializer for non-static data member is a C++11 extension}}
#endif
};
class PR20760_b {
int d = d); // expected-error {{expected ';'}}
#if __cplusplus <= 199711L
- // expected-warning at -2 {{in-class initialization of non-static data member is a C++11 extension}}
+ // expected-warning at -2 {{default member initializer for non-static data member is a C++11 extension}}
#endif
int e = d]; // expected-error {{expected ';'}}
#if __cplusplus <= 199711L
- // expected-warning at -2 {{in-class initialization of non-static data member is a C++11 extension}}
+ // expected-warning at -2 {{default member initializer for non-static data member is a C++11 extension}}
#endif
int f = d // expected-error {{expected ';'}}
#if __cplusplus <= 199711L
- // expected-warning at -2 {{in-class initialization of non-static data member is a C++11 extension}}
+ // expected-warning at -2 {{default member initializer for non-static data member is a C++11 extension}}
#endif
};
diff --git a/clang/test/SemaCXX/PR9572.cpp b/clang/test/SemaCXX/PR9572.cpp
index cbfa6c76828d..d0ba32eb1ab1 100644
--- a/clang/test/SemaCXX/PR9572.cpp
+++ b/clang/test/SemaCXX/PR9572.cpp
@@ -21,7 +21,7 @@ struct Foo : public Base {
const int kBlah = 3;
#if __cplusplus <= 199711L
- // expected-warning at -2 {{in-class initialization of non-static data member is a C++11 extension}}
+ // expected-warning at -2 {{default member initializer for non-static data member is a C++11 extension}}
#endif
Foo();
diff --git a/clang/test/SemaCXX/class.cpp b/clang/test/SemaCXX/class.cpp
index 0ed6a77b9b12..84334f094381 100644
--- a/clang/test/SemaCXX/class.cpp
+++ b/clang/test/SemaCXX/class.cpp
@@ -44,7 +44,7 @@ class C {
int i = 0;
#if __cplusplus <= 199711L
- // expected-warning at -2 {{in-class initialization of non-static data member is a C++11 extension}}
+ // expected-warning at -2 {{default member initializer for 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}}
diff --git a/clang/test/SemaCXX/cxx98-compat.cpp b/clang/test/SemaCXX/cxx98-compat.cpp
index e221259859bc..581b620c7072 100644
--- a/clang/test/SemaCXX/cxx98-compat.cpp
+++ b/clang/test/SemaCXX/cxx98-compat.cpp
@@ -122,7 +122,7 @@ void RangeFor() {
}
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 initializer for non-static data members is incompatible with C++98}}
};
struct OverrideControlBase {
diff --git a/clang/test/SemaCXX/member-init.cpp b/clang/test/SemaCXX/member-init.cpp
index 33f16940bbf8..24291064296f 100644
--- a/clang/test/SemaCXX/member-init.cpp
+++ b/clang/test/SemaCXX/member-init.cpp
@@ -21,20 +21,20 @@ struct Recurse { // expected-error {{initializer for 'n' needed}}
};
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<int n> struct T { static const int B; };
template<> struct T<2> { template<int C, int D> using B = int; };
const int C = 0, D = 0;
struct S {
- int as[] = { decltype(x)::B<C, D>(0) }; // expected-error {{array bound cannot be deduced from an in-class initializer}}
+ int as[] = { decltype(x)::B<C, D>(0) }; // expected-error {{array bound cannot be deduced from a default member initializer}}
T<sizeof(as) / sizeof(int)> 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); };
More information about the cfe-commits
mailing list