diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -1536,7 +1536,7 @@ // the element type of the complex type. The first element initializes // the real part, and the second element intitializes the imaginary part. - if (IList->getNumInits() != 2) + if (IList->getNumInits() < 2) return CheckScalarType(Entity, IList, DeclType, Index, StructuredList, StructuredIndex); diff --git a/clang/test/Sema/complex-init-list.c b/clang/test/Sema/complex-init-list.c --- a/clang/test/Sema/complex-init-list.c +++ b/clang/test/Sema/complex-init-list.c @@ -34,7 +34,7 @@ // Random invalid stuff struct teststruct invalid1 = { 1, 2 }; // expected-warning {{excess elements}} -_Complex float invalid2 = { 1, 2, 3 }; // expected-warning {{excess elements}} +_Complex float invalid2 = { 1, 2, 3 }; // expected-warning {{specifying real and imaginary components is an extension}} expected-warning {{excess elements in scalar initializer}} _Complex float invalid3 = {}; // expected-error {{scalar initializer cannot be empty}} expected-warning {{GNU empty initializer}} @@ -46,3 +46,7 @@ // Constant-folding with init list. _Complex float x = 2 + (_Complex float) { 1, 2 }; // expected-warning {{specifying real and imaginary components is an extension}} + +// initialization list +_Complex double cd = {1.0, 2.0, 3.0}; // expected-warning {{specifying real and imaginary components is an extension}} expected-warning {{excess elements in scalar initializer}} +_Complex float cf = {1.1f, 2.2f, 3.3f, 4.4f}; // expected-warning {{specifying real and imaginary components is an extension}} expected-warning {{excess elements in scalar initializer}}