[PATCH] D88445: Use "default member initializer" instead of "in-class initializer" for diagnostics

2020-09-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Thank you for the review! I've commit in 
15fbae8ac303d8601ea95418d4818cb50d0765e1 



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88445/new/

https://reviews.llvm.org/D88445

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88445: Use "default member initializer" instead of "in-class initializer" for diagnostics

2020-09-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Thanks!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88445/new/

https://reviews.llvm.org/D88445

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88445: Use "default member initializer" instead of "in-class initializer" for diagnostics

2020-09-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 294951.
aaron.ballman added a comment.

Missed a test case.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88445/new/

https://reviews.llvm.org/D88445

Files:
  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

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); };
Index: clang/test/SemaCXX/cxx98-compat.cpp
===
--- clang/test/SemaCXX/cxx98-compat.cpp
+++ clang/test/SemaCXX/cxx98-compat.cpp
@@ -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 initializer for non-static data members is incompatible with C++98}}
 };
 
 struct OverrideControlBase {
Index: clang/test/SemaCXX/class.cpp
===
--- clang/test/SemaCXX/class.cpp
+++ clang/test/SemaCXX/class.cpp
@@ -44,7 +44,7 @@
 
   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 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}}
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 initializer for non-static data member is a C++11 extension}}
 #endif
 
   Foo();
Index: clang/test/Parser/cxx-class.cpp
===
--- clang/test/Parser/cxx-class.cpp
+++ clang/test/Parser/cxx-class.cpp
@@ -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 initializer for 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 initializer for 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 initializer for non-static data member is a C++11 extension}}
 #endif
 
 };

[PATCH] D88445: Use "default member initializer" instead of "in-class initializer" for diagnostics

2020-09-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 294947.
aaron.ballman added a comment.

Updating based on review feedback.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88445/new/

https://reviews.llvm.org/D88445

Files:
  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

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); };
Index: clang/test/SemaCXX/cxx98-compat.cpp
===
--- clang/test/SemaCXX/cxx98-compat.cpp
+++ clang/test/SemaCXX/cxx98-compat.cpp
@@ -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 initializer for non-static data members is incompatible with C++98}}
 };
 
 struct OverrideControlBase {
Index: clang/test/SemaCXX/class.cpp
===
--- clang/test/SemaCXX/class.cpp
+++ clang/test/SemaCXX/class.cpp
@@ -44,7 +44,7 @@
 
   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 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}}
@@ -188,7 +188,7 @@
   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 y = foo(); // expected-warning {{in-class 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}}
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 initializer for non-static data member is a C++11 extension}}
 #endif
 
   Foo();
Index: clang/test/Parser/cxx-class.cpp
===
--- clang/test/Parser/cxx-class.cpp
+++ clang/test/Parser

[PATCH] D88445: Use "default member initializer" instead of "in-class initializer" for diagnostics

2020-09-28 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Thanks!




Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:864-867
+  "default member initialization of non-static data member is a C++11 "
+  "extension">, InGroup;
 def warn_cxx98_compat_nonstatic_member_init : Warning<
+  "default member initialization of non-static data members is incompatible "

Consider "initialization of" -> "initializer for", so we use the standard term 
in full.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:8506-8524
+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_default_member_initializer_float_type : ExtWarn<

For a static member, it's just an initializer, not a default member 
initializer. I think "in-class initializer" is probably the best we can say 
here.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:8533-8536
+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;

Likewise, this case is an initializer for a static member, and is not a default 
member initializer.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88445/new/

https://reviews.llvm.org/D88445

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88445: Use "default member initializer" instead of "in-class initializer" for diagnostics

2020-09-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added a reviewer: rsmith.
aaron.ballman requested review of this revision.

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.


https://reviews.llvm.org/D88445

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  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/cxx0x-class.cpp
  clang/test/SemaCXX/cxx98-compat.cpp
  clang/test/SemaCXX/gnu-flags.cpp
  clang/test/SemaCXX/member-init.cpp
  clang/test/SemaCXX/warn-static-const-float.cpp
  clang/test/SemaTemplate/instantiate-static-var.cpp

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;
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/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}}
+