File tree Expand file tree Collapse file tree 4 files changed +25
-2
lines changed Expand file tree Collapse file tree 4 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -121,8 +121,9 @@ void UseDesignatedInitializersCheck::registerMatchers(MatchFinder *Finder) {
121
121
hasAnyBase (hasType (cxxRecordDecl (has (fieldDecl ()))));
122
122
Finder->addMatcher (
123
123
initListExpr (
124
- hasType (cxxRecordDecl (RestrictToPODTypes ? isPOD () : isAggregate (),
125
- unless (HasBaseWithFields))
124
+ hasType (cxxRecordDecl (
125
+ RestrictToPODTypes ? isPOD () : isAggregate (),
126
+ unless (anyOf (HasBaseWithFields, hasName (" ::std::array" ))))
126
127
.bind (" type" )),
127
128
IgnoreSingleElementAggregates ? hasMoreThanOneElement () : anything (),
128
129
unless (isFullyDesignated ()))
Original file line number Diff line number Diff line change @@ -182,6 +182,10 @@ Changes in existing checks
182
182
``constexpr `` and ``static` `` values on member initialization and by detecting
183
183
explicit casting of built-in types within member list initialization.
184
184
185
+ - Improved :doc: `modernize-use-designated-initializers
186
+ <clang-tidy/checks/modernize/use-designated-initializers>` check by avoiding
187
+ diagnosing designated initializers for ``std::array `` initializations.
188
+
185
189
- Improved :doc: `modernize-use-ranges
186
190
<clang-tidy/checks/modernize/use-ranges>` check by updating suppress
187
191
warnings logic for ``nullptr `` in ``std::find ``.
Original file line number Diff line number Diff line change @@ -54,6 +54,9 @@ Options
54
54
55
55
The value `false ` specifies that even initializers for aggregate types with
56
56
only a single element should be checked. The default value is `true `.
57
+ ``std::array `` initializations are always excluded, as the type is a
58
+ standard library abstraction and not intended to be initialized with
59
+ designated initializers.
57
60
58
61
.. option :: RestrictToPODTypes
59
62
Original file line number Diff line number Diff line change @@ -209,3 +209,18 @@ struct S15{
209
209
S15 (S14& d):d{d}{}
210
210
S14& d;
211
211
};
212
+
213
+ // Issue #133715
214
+ namespace std {
215
+ template <typename T, unsigned int N>
216
+ struct array {
217
+ T __elems[N];
218
+ };
219
+ template <typename T, typename ... U>
220
+ array (T, U...) -> array<T, 1 + sizeof ...(U)>;
221
+ }
222
+
223
+ std::array a{1 ,2 ,3 };
224
+ std::array<int ,2 > b{10 , 11 };
225
+ using array = std::array<int , 2 >;
226
+ array c{10 , 11 };
You can’t perform that action at this time.
0 commit comments