This is an archive of the discontinued LLVM Phabricator instance.

Add diagnostic -Waggregate-ctors, "aggregate type has user-declared constructors"
AbandonedPublic

Authored by Quuxplusone on Mar 27 2018, 12:38 PM.

Details

Summary

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.

Diff Detail

Repository
rC Clang

Event Timeline

Eugene.Zelenko added a project: Restricted Project.
Eugene.Zelenko added a subscriber: Eugene.Zelenko.

Please mention new diagnostics in documentation and Release Notes.

Quuxplusone planned changes to this revision.Mar 27 2018, 4:49 PM

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.

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<char>
      ^
include/boost/variant/static_visitor.hpp:43:7: error: aggregate type has user-declared constructors [-Werror,-Waggregate-ctors]
class static_visitor
      ^
Quuxplusone abandoned this revision.Apr 16 2018, 12:05 AM

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.