52 lines · plain
1.. title:: clang-tidy - readability-redundant-access-specifiers2 3readability-redundant-access-specifiers4=======================================5 6Finds classes, structs, and unions containing redundant member (field and7method) access specifiers.8 9Example10-------11 12.. code-block:: c++13 14 class Foo {15 public:16 int x;17 int y;18 public:19 int z;20 protected:21 int a;22 public:23 int c;24 }25 26In the example above, the second ``public`` declaration can be removed without27any changes of behavior.28 29Options30-------31 32.. option:: CheckFirstDeclaration33 34 If set to `true`, the check will also diagnose if the first access35 specifier declaration is redundant (e.g. ``private`` inside ``class``,36 or ``public`` inside ``struct`` or ``union``).37 Default is `false`.38 39Example40^^^^^^^41 42.. code-block:: c++43 44 struct Bar {45 public:46 int x;47 }48 49If `CheckFirstDeclaration` option is enabled, a warning about redundant50access specifier will be emitted, because ``public`` is the default member access51for structs.52