Skip to content

Commit 7509894

Browse files
committed
Merge commit 'd20604e5b6792bd010dd4dfd36f3e836ae0fe7b2' into tti/remove-concept-model
# Conflicts: # llvm/include/llvm/Analysis/TargetTransformInfo.h # llvm/include/llvm/Analysis/TargetTransformInfoImpl.h # llvm/include/llvm/CodeGen/BasicTTIImpl.h # llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
2 parents ead188b + d20604e commit 7509894

File tree

119 files changed

+3533
-1139
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+3533
-1139
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,10 @@ Improvements to Clang's diagnostics
408408
they're only triggered if the authors are already making the choice to use
409409
``preferred_type`` attribute.
410410

411+
- ``-Winitializer-overrides`` and ``-Wreorder-init-list`` are now grouped under
412+
the ``-Wc99-designator`` diagnostic group, as they also are about the
413+
behavior of the C99 feature as it was introduced into C++20. Fixes #GH47037
414+
411415
Improvements to Clang's time-trace
412416
----------------------------------
413417

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,13 @@ def AbstractFinalClass : DiagGroup<"abstract-final-class">;
184184
def FinalDtorNonFinalClass : DiagGroup<"final-dtor-non-final-class">;
185185
def GNUOffsetofExtensions : DiagGroup<"gnu-offsetof-extensions">;
186186

187+
def InitializerOverrides : DiagGroup<"initializer-overrides">;
188+
// For compatibility with GCC; -Woverride-init = -Winitializer-overrides
189+
def : DiagGroup<"override-init", [InitializerOverrides]>;
190+
def ReorderCtor : DiagGroup<"reorder-ctor">;
191+
def ReorderInitList : DiagGroup<"reorder-init-list">;
192+
def Reorder : DiagGroup<"reorder", [ReorderCtor, ReorderInitList]>;
193+
187194
def CXX11CompatDeprecatedWritableStr :
188195
DiagGroup<"c++11-compat-deprecated-writable-strings">;
189196

@@ -250,7 +257,9 @@ def Deprecated : DiagGroup<"deprecated", [DeprecatedAnonEnumEnumConversion,
250257
def CXX20Designator : DiagGroup<"c++20-designator">;
251258
// Allow -Wno-c99-designator to be used to turn off all warnings on valid C99
252259
// designators (including the warning controlled by -Wc++20-designator).
253-
def C99Designator : DiagGroup<"c99-designator", [CXX20Designator]>;
260+
def C99Designator : DiagGroup<"c99-designator", [CXX20Designator,
261+
InitializerOverrides,
262+
ReorderInitList]>;
254263
def GNUDesignator : DiagGroup<"gnu-designator">;
255264
def DtorName : DiagGroup<"dtor-name">;
256265

@@ -595,9 +604,6 @@ def NullabilityCompleteness : DiagGroup<"nullability-completeness",
595604
def NullArithmetic : DiagGroup<"null-arithmetic">;
596605
def NullCharacter : DiagGroup<"null-character">;
597606
def NullDereference : DiagGroup<"null-dereference">;
598-
def InitializerOverrides : DiagGroup<"initializer-overrides">;
599-
// For compatibility with GCC; -Woverride-init = -Winitializer-overrides
600-
def : DiagGroup<"override-init", [InitializerOverrides]>;
601607
def NonNull : DiagGroup<"nonnull">;
602608
def NonPODVarargs : DiagGroup<"non-pod-varargs">;
603609
def ClassVarargs : DiagGroup<"class-varargs", [NonPODVarargs]>;
@@ -919,9 +925,6 @@ def UsedButMarkedUnused : DiagGroup<"used-but-marked-unused">;
919925
def UsedSearchPath : DiagGroup<"search-path-usage">;
920926
def UserDefinedLiterals : DiagGroup<"user-defined-literals">;
921927
def UserDefinedWarnings : DiagGroup<"user-defined-warnings">;
922-
def ReorderCtor : DiagGroup<"reorder-ctor">;
923-
def ReorderInitList : DiagGroup<"reorder-init-list">;
924-
def Reorder : DiagGroup<"reorder", [ReorderCtor, ReorderInitList]>;
925928
def UndeclaredSelector : DiagGroup<"undeclared-selector">;
926929
def ImplicitAtomic : DiagGroup<"implicit-atomic-properties">;
927930
def AtomicAlignment : DiagGroup<"atomic-alignment">;

clang/include/clang/Driver/Distro.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class Distro {
8181
UbuntuNoble,
8282
UbuntuOracular,
8383
UbuntuPlucky,
84+
UbuntuQuesting,
8485
UnknownDistro
8586
};
8687

@@ -132,7 +133,7 @@ class Distro {
132133
}
133134

134135
bool IsUbuntu() const {
135-
return DistroVal >= UbuntuHardy && DistroVal <= UbuntuPlucky;
136+
return DistroVal >= UbuntuHardy && DistroVal <= UbuntuQuesting;
136137
}
137138

138139
bool IsAlpineLinux() const { return DistroVal == AlpineLinux; }

clang/lib/CIR/CodeGen/CIRGenStmtOpenACC.cpp

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,17 @@ class OpenACCClauseCIREmitter final
9797

9898
// Handle a clause affected by the 'device-type' to the point that they need
9999
// to have the attributes added in the correct/corresponding order, such as
100-
// 'num_workers' or 'vector_length' on a compute construct.
101-
mlir::ArrayAttr
102-
handleDeviceTypeAffectedClause(mlir::ArrayAttr existingDeviceTypes,
103-
mlir::Value argument,
104-
mlir::MutableOperandRange &argCollection) {
100+
// 'num_workers' or 'vector_length' on a compute construct. For cases where we
101+
// don't have an expression 'argument' that needs to be added to an operand
102+
// and only care about the 'device-type' list, we can use this with 'argument'
103+
// as 'std::nullopt'. If 'argument' is NOT 'std::nullopt' (that is, has a
104+
// value), argCollection must also be non-null. For cases where we don't have
105+
// an argument that needs to be added to an additional one (such as asyncOnly)
106+
// we can use this with 'argument' as std::nullopt.
107+
mlir::ArrayAttr handleDeviceTypeAffectedClause(
108+
mlir::ArrayAttr existingDeviceTypes,
109+
std::optional<mlir::Value> argument = std::nullopt,
110+
mlir::MutableOperandRange *argCollection = nullptr) {
105111
llvm::SmallVector<mlir::Attribute> deviceTypes;
106112

107113
// Collect the 'existing' device-type attributes so we can re-create them
@@ -120,13 +126,19 @@ class OpenACCClauseCIREmitter final
120126
lastDeviceTypeClause->getArchitectures()) {
121127
deviceTypes.push_back(mlir::acc::DeviceTypeAttr::get(
122128
builder.getContext(), decodeDeviceType(arch.getIdentifierInfo())));
123-
argCollection.append(argument);
129+
if (argument) {
130+
assert(argCollection);
131+
argCollection->append(*argument);
132+
}
124133
}
125134
} else {
126135
// Else, we just add a single for 'none'.
127136
deviceTypes.push_back(mlir::acc::DeviceTypeAttr::get(
128137
builder.getContext(), mlir::acc::DeviceType::None));
129-
argCollection.append(argument);
138+
if (argument) {
139+
assert(argCollection);
140+
argCollection->append(*argument);
141+
}
130142
}
131143

132144
return mlir::ArrayAttr::get(builder.getContext(), deviceTypes);
@@ -205,7 +217,7 @@ class OpenACCClauseCIREmitter final
205217
mlir::MutableOperandRange range = operation.getNumWorkersMutable();
206218
operation.setNumWorkersDeviceTypeAttr(handleDeviceTypeAffectedClause(
207219
operation.getNumWorkersDeviceTypeAttr(),
208-
createIntExpr(clause.getIntExpr()), range));
220+
createIntExpr(clause.getIntExpr()), &range));
209221
} else if constexpr (isOneOfTypes<OpTy, SerialOp>) {
210222
llvm_unreachable("num_workers not valid on serial");
211223
} else {
@@ -218,14 +230,30 @@ class OpenACCClauseCIREmitter final
218230
mlir::MutableOperandRange range = operation.getVectorLengthMutable();
219231
operation.setVectorLengthDeviceTypeAttr(handleDeviceTypeAffectedClause(
220232
operation.getVectorLengthDeviceTypeAttr(),
221-
createIntExpr(clause.getIntExpr()), range));
233+
createIntExpr(clause.getIntExpr()), &range));
222234
} else if constexpr (isOneOfTypes<OpTy, SerialOp>) {
223235
llvm_unreachable("vector_length not valid on serial");
224236
} else {
225237
return clauseNotImplemented(clause);
226238
}
227239
}
228240

241+
void VisitAsyncClause(const OpenACCAsyncClause &clause) {
242+
if constexpr (isOneOfTypes<OpTy, ParallelOp, SerialOp, KernelsOp>) {
243+
if (!clause.hasIntExpr()) {
244+
operation.setAsyncOnlyAttr(
245+
handleDeviceTypeAffectedClause(operation.getAsyncOnlyAttr()));
246+
} else {
247+
mlir::MutableOperandRange range = operation.getAsyncOperandsMutable();
248+
operation.setAsyncOperandsDeviceTypeAttr(handleDeviceTypeAffectedClause(
249+
operation.getAsyncOperandsDeviceTypeAttr(),
250+
createIntExpr(clause.getIntExpr()), &range));
251+
}
252+
} else {
253+
return clauseNotImplemented(clause);
254+
}
255+
}
256+
229257
void VisitSelfClause(const OpenACCSelfClause &clause) {
230258
if constexpr (isOneOfTypes<OpTy, ParallelOp, SerialOp, KernelsOp>) {
231259
if (clause.isEmptySelfClause()) {

clang/lib/Driver/Distro.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ static Distro::DistroType DetectLsbRelease(llvm::vfs::FileSystem &VFS) {
9696
.Case("noble", Distro::UbuntuNoble)
9797
.Case("oracular", Distro::UbuntuOracular)
9898
.Case("plucky", Distro::UbuntuPlucky)
99+
.Case("questing", Distro::UbuntuQuesting)
99100
.Default(Distro::UnknownDistro);
100101
return Version;
101102
}

clang/lib/Sema/SemaOpenACCClause.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ class SemaOpenACCClauseVisitor {
334334
}
335335

336336
// For 'tile' and 'collapse', only allow 1 per 'device_type'.
337-
// Also applies to num_worker, num_gangs, and vector_length.
337+
// Also applies to num_worker, num_gangs, vector_length, and async.
338338
template <typename TheClauseTy>
339339
bool DisallowSinceLastDeviceType(SemaOpenACC::OpenACCParsedClause &Clause) {
340340
auto LastDeviceTypeItr =
@@ -639,6 +639,9 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitVectorLengthClause(
639639

640640
OpenACCClause *SemaOpenACCClauseVisitor::VisitAsyncClause(
641641
SemaOpenACC::OpenACCParsedClause &Clause) {
642+
if (DisallowSinceLastDeviceType<OpenACCAsyncClause>(Clause))
643+
return nullptr;
644+
642645
assert(Clause.getNumIntExprs() < 2 &&
643646
"Invalid number of expressions for Async");
644647
return OpenACCAsyncClause::Create(

clang/test/CIR/CodeGenOpenACC/kernels.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,5 +210,51 @@ void acc_kernels(int cond) {
210210
// CHECK-NEXT: acc.terminator
211211
// CHECK-NEXT: } loc
212212

213+
#pragma acc kernels async
214+
{}
215+
// CHECK-NEXT: acc.kernels {
216+
// CHECK-NEXT: acc.terminator
217+
// CHECK-NEXT: } attributes {asyncOnly = [#acc.device_type<none>]}
218+
219+
#pragma acc kernels async(cond)
220+
{}
221+
// CHECK-NEXT: %[[COND_LOAD:.*]] = cir.load %[[COND]] : !cir.ptr<!s32i>, !s32i
222+
// CHECK-NEXT: %[[CONV_CAST:.*]] = builtin.unrealized_conversion_cast %[[COND_LOAD]] : !s32i to si32
223+
// CHECK-NEXT: acc.kernels async(%[[CONV_CAST]] : si32) {
224+
// CHECK-NEXT: acc.terminator
225+
// CHECK-NEXT: } loc
226+
227+
#pragma acc kernels async device_type(nvidia, radeon) async
228+
{}
229+
// CHECK-NEXT: acc.kernels {
230+
// CHECK-NEXT: acc.terminator
231+
// CHECK-NEXT: } attributes {asyncOnly = [#acc.device_type<none>, #acc.device_type<nvidia>, #acc.device_type<radeon>]}
232+
233+
#pragma acc kernels async(3) device_type(nvidia, radeon) async(cond)
234+
{}
235+
// CHECK-NEXT: %[[THREE_LITERAL:.*]] = cir.const #cir.int<3> : !s32i
236+
// CHECK-NEXT: %[[THREE_CAST:.*]] = builtin.unrealized_conversion_cast %[[THREE_LITERAL]] : !s32i to si32
237+
// CHECK-NEXT: %[[COND_LOAD:.*]] = cir.load %[[COND]] : !cir.ptr<!s32i>, !s32i
238+
// CHECK-NEXT: %[[CONV_CAST:.*]] = builtin.unrealized_conversion_cast %[[COND_LOAD]] : !s32i to si32
239+
// CHECK-NEXT: acc.kernels async(%[[THREE_CAST]] : si32, %[[CONV_CAST]] : si32 [#acc.device_type<nvidia>], %[[CONV_CAST]] : si32 [#acc.device_type<radeon>]) {
240+
// CHECK-NEXT: acc.terminator
241+
// CHECK-NEXT: } loc
242+
243+
#pragma acc kernels async device_type(nvidia, radeon) async(cond)
244+
{}
245+
// CHECK-NEXT: %[[COND_LOAD:.*]] = cir.load %[[COND]] : !cir.ptr<!s32i>, !s32i
246+
// CHECK-NEXT: %[[CONV_CAST:.*]] = builtin.unrealized_conversion_cast %[[COND_LOAD]] : !s32i to si32
247+
// CHECK-NEXT: acc.kernels async(%[[CONV_CAST]] : si32 [#acc.device_type<nvidia>], %[[CONV_CAST]] : si32 [#acc.device_type<radeon>]) {
248+
// CHECK-NEXT: acc.terminator
249+
// CHECK-NEXT: } attributes {asyncOnly = [#acc.device_type<none>]}
250+
251+
#pragma acc kernels async(3) device_type(nvidia, radeon) async
252+
{}
253+
// CHECK-NEXT: %[[THREE_LITERAL:.*]] = cir.const #cir.int<3> : !s32i
254+
// CHECK-NEXT: %[[THREE_CAST:.*]] = builtin.unrealized_conversion_cast %[[THREE_LITERAL]] : !s32i to si32
255+
// CHECK-NEXT: acc.kernels async(%[[THREE_CAST]] : si32) {
256+
// CHECK-NEXT: acc.terminator
257+
// CHECK-NEXT: } attributes {asyncOnly = [#acc.device_type<nvidia>, #acc.device_type<radeon>]}
258+
213259
// CHECK-NEXT: cir.return
214260
}

clang/test/CIR/CodeGenOpenACC/parallel.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,5 +209,51 @@ void acc_parallel(int cond) {
209209
// CHECK-NEXT: acc.yield
210210
// CHECK-NEXT: } loc
211211

212+
#pragma acc parallel async
213+
{}
214+
// CHECK-NEXT: acc.parallel {
215+
// CHECK-NEXT: acc.yield
216+
// CHECK-NEXT: } attributes {asyncOnly = [#acc.device_type<none>]}
217+
218+
#pragma acc parallel async(cond)
219+
{}
220+
// CHECK-NEXT: %[[COND_LOAD:.*]] = cir.load %[[COND]] : !cir.ptr<!s32i>, !s32i
221+
// CHECK-NEXT: %[[CONV_CAST:.*]] = builtin.unrealized_conversion_cast %[[COND_LOAD]] : !s32i to si32
222+
// CHECK-NEXT: acc.parallel async(%[[CONV_CAST]] : si32) {
223+
// CHECK-NEXT: acc.yield
224+
// CHECK-NEXT: } loc
225+
226+
#pragma acc parallel async device_type(nvidia, radeon) async
227+
{}
228+
// CHECK-NEXT: acc.parallel {
229+
// CHECK-NEXT: acc.yield
230+
// CHECK-NEXT: } attributes {asyncOnly = [#acc.device_type<none>, #acc.device_type<nvidia>, #acc.device_type<radeon>]}
231+
232+
#pragma acc parallel async(3) device_type(nvidia, radeon) async(cond)
233+
{}
234+
// CHECK-NEXT: %[[THREE_LITERAL:.*]] = cir.const #cir.int<3> : !s32i
235+
// CHECK-NEXT: %[[THREE_CAST:.*]] = builtin.unrealized_conversion_cast %[[THREE_LITERAL]] : !s32i to si32
236+
// CHECK-NEXT: %[[COND_LOAD:.*]] = cir.load %[[COND]] : !cir.ptr<!s32i>, !s32i
237+
// CHECK-NEXT: %[[CONV_CAST:.*]] = builtin.unrealized_conversion_cast %[[COND_LOAD]] : !s32i to si32
238+
// CHECK-NEXT: acc.parallel async(%[[THREE_CAST]] : si32, %[[CONV_CAST]] : si32 [#acc.device_type<nvidia>], %[[CONV_CAST]] : si32 [#acc.device_type<radeon>]) {
239+
// CHECK-NEXT: acc.yield
240+
// CHECK-NEXT: } loc
241+
242+
#pragma acc parallel async device_type(nvidia, radeon) async(cond)
243+
{}
244+
// CHECK-NEXT: %[[COND_LOAD:.*]] = cir.load %[[COND]] : !cir.ptr<!s32i>, !s32i
245+
// CHECK-NEXT: %[[CONV_CAST:.*]] = builtin.unrealized_conversion_cast %[[COND_LOAD]] : !s32i to si32
246+
// CHECK-NEXT: acc.parallel async(%[[CONV_CAST]] : si32 [#acc.device_type<nvidia>], %[[CONV_CAST]] : si32 [#acc.device_type<radeon>]) {
247+
// CHECK-NEXT: acc.yield
248+
// CHECK-NEXT: } attributes {asyncOnly = [#acc.device_type<none>]}
249+
250+
#pragma acc parallel async(3) device_type(nvidia, radeon) async
251+
{}
252+
// CHECK-NEXT: %[[THREE_LITERAL:.*]] = cir.const #cir.int<3> : !s32i
253+
// CHECK-NEXT: %[[THREE_CAST:.*]] = builtin.unrealized_conversion_cast %[[THREE_LITERAL]] : !s32i to si32
254+
// CHECK-NEXT: acc.parallel async(%[[THREE_CAST]] : si32) {
255+
// CHECK-NEXT: acc.yield
256+
// CHECK-NEXT: } attributes {asyncOnly = [#acc.device_type<nvidia>, #acc.device_type<radeon>]}
257+
212258
// CHECK-NEXT: cir.return
213259
}

clang/test/CIR/CodeGenOpenACC/serial.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,51 @@ void acc_serial(int cond) {
106106
// CHECK-NEXT: acc.yield
107107
// CHECK-NEXT: } loc
108108

109+
#pragma acc serial async
110+
{}
111+
// CHECK-NEXT: acc.serial {
112+
// CHECK-NEXT: acc.yield
113+
// CHECK-NEXT: } attributes {asyncOnly = [#acc.device_type<none>]}
114+
115+
#pragma acc serial async(cond)
116+
{}
117+
// CHECK-NEXT: %[[COND_LOAD:.*]] = cir.load %[[COND]] : !cir.ptr<!s32i>, !s32i
118+
// CHECK-NEXT: %[[CONV_CAST:.*]] = builtin.unrealized_conversion_cast %[[COND_LOAD]] : !s32i to si32
119+
// CHECK-NEXT: acc.serial async(%[[CONV_CAST]] : si32) {
120+
// CHECK-NEXT: acc.yield
121+
// CHECK-NEXT: } loc
122+
123+
#pragma acc serial async device_type(nvidia, radeon) async
124+
{}
125+
// CHECK-NEXT: acc.serial {
126+
// CHECK-NEXT: acc.yield
127+
// CHECK-NEXT: } attributes {asyncOnly = [#acc.device_type<none>, #acc.device_type<nvidia>, #acc.device_type<radeon>]}
128+
129+
#pragma acc serial async(3) device_type(nvidia, radeon) async(cond)
130+
{}
131+
// CHECK-NEXT: %[[THREE_LITERAL:.*]] = cir.const #cir.int<3> : !s32i
132+
// CHECK-NEXT: %[[THREE_CAST:.*]] = builtin.unrealized_conversion_cast %[[THREE_LITERAL]] : !s32i to si32
133+
// CHECK-NEXT: %[[COND_LOAD:.*]] = cir.load %[[COND]] : !cir.ptr<!s32i>, !s32i
134+
// CHECK-NEXT: %[[CONV_CAST:.*]] = builtin.unrealized_conversion_cast %[[COND_LOAD]] : !s32i to si32
135+
// CHECK-NEXT: acc.serial async(%[[THREE_CAST]] : si32, %[[CONV_CAST]] : si32 [#acc.device_type<nvidia>], %[[CONV_CAST]] : si32 [#acc.device_type<radeon>]) {
136+
// CHECK-NEXT: acc.yield
137+
// CHECK-NEXT: } loc
138+
139+
#pragma acc serial async device_type(nvidia, radeon) async(cond)
140+
{}
141+
// CHECK-NEXT: %[[COND_LOAD:.*]] = cir.load %[[COND]] : !cir.ptr<!s32i>, !s32i
142+
// CHECK-NEXT: %[[CONV_CAST:.*]] = builtin.unrealized_conversion_cast %[[COND_LOAD]] : !s32i to si32
143+
// CHECK-NEXT: acc.serial async(%[[CONV_CAST]] : si32 [#acc.device_type<nvidia>], %[[CONV_CAST]] : si32 [#acc.device_type<radeon>]) {
144+
// CHECK-NEXT: acc.yield
145+
// CHECK-NEXT: } attributes {asyncOnly = [#acc.device_type<none>]}
146+
147+
#pragma acc serial async(3) device_type(nvidia, radeon) async
148+
{}
149+
// CHECK-NEXT: %[[THREE_LITERAL:.*]] = cir.const #cir.int<3> : !s32i
150+
// CHECK-NEXT: %[[THREE_CAST:.*]] = builtin.unrealized_conversion_cast %[[THREE_LITERAL]] : !s32i to si32
151+
// CHECK-NEXT: acc.serial async(%[[THREE_CAST]] : si32) {
152+
// CHECK-NEXT: acc.yield
153+
// CHECK-NEXT: } attributes {asyncOnly = [#acc.device_type<nvidia>, #acc.device_type<radeon>]}
154+
109155
// CHECK-NEXT: cir.return
110156
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=override,reorder -Werror=c99-designator %s
2+
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=override -Wno-reorder-init-list -Werror=initializer-overrides %s
3+
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=reorder -Wno-initializer-overrides -Werror=reorder-init-list %s
4+
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=good -Wno-c99-designator %s
5+
// good-no-diagnostics
6+
7+
// Ensure that -Wc99-designator controls both -Winitializer-overrides and
8+
// -Wreorder-init-list.
9+
10+
struct X {
11+
int a;
12+
int b;
13+
};
14+
15+
void test() {
16+
X x{.a = 0, // override-note {{previous initialization is here}}
17+
.a = 1}; // override-error {{initializer overrides prior initialization of this subobject}}
18+
X y{.b = 0, // reorder-note {{previous initialization for field 'b' is here}}
19+
.a = 1}; // reorder-error {{ISO C++ requires field designators to be specified in declaration order; field 'b' will be initialized after field 'a'}}
20+
}
21+

0 commit comments

Comments
 (0)