1.. title:: clang-tidy - readability-redundant-access-specifiers 2 3readability-redundant-access-specifiers 4======================================= 5 6Finds classes, structs, and unions containing redundant member (field and 7method) access specifiers. 8 9Example 10------- 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 without 27any changes of behavior. 28 29Options 30------- 31 32.. option:: CheckFirstDeclaration 33 34 If set to non-zero, the check will also diagnose if the first access 35 specifier declaration is redundant (e.g. ``private`` inside ``class``, 36 or ``public`` inside ``struct`` or ``union``). 37 Default is `0`. 38 39Example 40^^^^^^^ 41 42.. code-block:: c++ 43 44 struct Bar { 45 public: 46 int x; 47 } 48 49If `CheckFirstDeclaration` option is enabled, a warning about redundant 50access specifier will be emitted, because ``public`` is the default member access 51for structs. 52