[PATCH] D44948: Add diagnostic -Waggregate-ctors, "aggregate type has user-declared constructors"

2018-04-16 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone abandoned this revision.
Quuxplusone added a comment.

This patch's new home is 
https://github.com/Quuxplusone/clang/commits/aggregate-ctors — which is where I 
should have put it to begin with.


Repository:
  rC Clang

https://reviews.llvm.org/D44948



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


[PATCH] D44948: Add diagnostic -Waggregate-ctors, "aggregate type has user-declared constructors"

2018-03-28 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

> If no real code triggers this diagnostic, ...

Boost triggers this diagnostic:

  include/boost/core/noncopyable.hpp:23:9: error: aggregate type has 
user-declared constructors [-Werror,-Waggregate-ctors]
class noncopyable
  ^
  include/boost/iterator/iterator_facade.hpp:496:9: error: aggregate type has 
user-declared constructors [-Werror,-Waggregate-ctors]
class iterator_core_access
  ^
  include/boost/process/detail/posix/environment.hpp:101:7: error: aggregate 
type has user-declared constructors [-Werror,-Waggregate-ctors]
  class native_environment_impl
^
  include/boost/variant/static_visitor.hpp:43:7: error: aggregate type has 
user-declared constructors [-Werror,-Waggregate-ctors]
  class static_visitor
^


Repository:
  rC Clang

https://reviews.llvm.org/D44948



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


[PATCH] D44948: Add diagnostic -Waggregate-ctors, "aggregate type has user-declared constructors"

2018-03-27 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone planned changes to this revision.
Quuxplusone added a comment.

This is related to an upcoming C++ paper, definitely not ready for prime time 
(e.g. no tests), and quite possibly never will be ready (although if people 
thought it would be useful, I'd be happy to clean it up and add tests).
I'll mark it "Plan Changes" for now and perhaps just abandon it in a few 
days/weeks. Sorry I didn't mark it as such to begin with.


Repository:
  rC Clang

https://reviews.llvm.org/D44948



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


[PATCH] D44948: Add diagnostic -Waggregate-ctors, "aggregate type has user-declared constructors"

2018-03-27 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please mention new diagnostics in documentation and Release Notes.


Repository:
  rC Clang

https://reviews.llvm.org/D44948



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


[PATCH] D44948: Add diagnostic -Waggregate-ctors, "aggregate type has user-declared constructors"

2018-03-27 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone created this revision.
Herald added a subscriber: cfe-commits.

This new warning diagnoses any aggregate class/struct/union type which has 
user-declared constructors, in order to test the hypothesis that real code does 
not (intentionally) contain such animals.

  

If no real code triggers this diagnostic, then it would be plausible to change 
the definition of "aggregate type" in C++2a so that types triggering this 
diagnostic would no longer be considered aggregate types at all.


Repository:
  rC Clang

https://reviews.llvm.org/D44948

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDeclCXX.cpp


Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -5907,6 +5907,10 @@
diag::warn_non_virtual_dtor) << Context.getRecordType(Record);
   }
 
+  if (Record->isAggregate() && Record->hasUserDeclaredConstructor()) {
+Diag(Record->getLocation(), 
diag::warn_aggregate_with_user_declared_constructor);
+  }
+
   if (Record->isAbstract()) {
 if (FinalAttr *FA = Record->getAttr()) {
   Diag(Record->getLocation(), diag::warn_abstract_final_class)
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -6466,6 +6466,9 @@
 def warn_jump_out_of_seh_finally : Warning<
   "jump out of __finally block has undefined behavior">,
   InGroup>;
+def warn_aggregate_with_user_declared_constructor : Warning<
+  "aggregate type has user-declared constructors">,
+  InGroup;
 def warn_non_virtual_dtor : Warning<
   "%0 has virtual functions but non-virtual destructor">,
   InGroup, DefaultIgnore;
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -99,6 +99,7 @@
 def DeleteIncomplete : DiagGroup<"delete-incomplete">;
 def DeleteNonVirtualDtor : DiagGroup<"delete-non-virtual-dtor">;
 def AbstractFinalClass : DiagGroup<"abstract-final-class">;
+def AggregateCtors : DiagGroup<"aggregate-ctors">;
 
 def CXX11CompatDeprecatedWritableStr :
   DiagGroup<"c++11-compat-deprecated-writable-strings">;


Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -5907,6 +5907,10 @@
diag::warn_non_virtual_dtor) << Context.getRecordType(Record);
   }
 
+  if (Record->isAggregate() && Record->hasUserDeclaredConstructor()) {
+Diag(Record->getLocation(), diag::warn_aggregate_with_user_declared_constructor);
+  }
+
   if (Record->isAbstract()) {
 if (FinalAttr *FA = Record->getAttr()) {
   Diag(Record->getLocation(), diag::warn_abstract_final_class)
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -6466,6 +6466,9 @@
 def warn_jump_out_of_seh_finally : Warning<
   "jump out of __finally block has undefined behavior">,
   InGroup>;
+def warn_aggregate_with_user_declared_constructor : Warning<
+  "aggregate type has user-declared constructors">,
+  InGroup;
 def warn_non_virtual_dtor : Warning<
   "%0 has virtual functions but non-virtual destructor">,
   InGroup, DefaultIgnore;
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -99,6 +99,7 @@
 def DeleteIncomplete : DiagGroup<"delete-incomplete">;
 def DeleteNonVirtualDtor : DiagGroup<"delete-non-virtual-dtor">;
 def AbstractFinalClass : DiagGroup<"abstract-final-class">;
+def AggregateCtors : DiagGroup<"aggregate-ctors">;
 
 def CXX11CompatDeprecatedWritableStr :
   DiagGroup<"c++11-compat-deprecated-writable-strings">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits