enabling short-circuiting coroutines use cases. This fixes
(`#56532 <https://github.com/llvm/llvm-project/issues/56532>`_) in
antecipation of `CWG2563 <https://cplusplus.github.io/CWG/issues/2563.html>_`.
+- Fix highlighting issue with ``_Complex`` and initialization list with more than
+ 2 items. (`#61518 <https://github.com/llvm/llvm-project/issues/61518>`_)
Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// 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);
--- /dev/null
+// RUN: not %clang_cc1 -std=c++11 -fsyntax-only -fcaret-diagnostics-max-lines 5 %s 2>&1 | FileCheck %s -strict-whitespace
+
+
+//CHECK: {{.*}}: error: excess elements in scalar initializer
+//CHECK-NEXT: {{^}}_Complex double gz1 = {1, 2, 3};
+//CHECK-NEXT: {{^}} ^{{$}}
+_Complex double gz1 = {1, 2, 3};
+
+//CHECK: {{.*}}: error: excess elements in scalar initializer
+//CHECK-NEXT: {{^}}_Complex double dd = {1.0, 2.0, 3.0};
+//CHECK-NEXT: {{^}} ^~~{{$}}
+_Complex double dd = {1.0, 2.0, 3.0};
+
+//CHECK: {{.*}}: error: excess elements in scalar initializer
+//CHECK-NEXT: {{^}}_Complex float fd = {1.0, 2.0, 3.0, 4.0, 5.0};
+//CHECK-NEXT: {{^}} ^~~{{$}}
+_Complex float fd = {1.0, 2.0, 3.0, 4.0, 5.0};
+
+//CHECK: {{.*}}: error: no viable conversion from 'foo' to 'double'
+//CHECK-NEXT: {{^}}_Complex double ds = {f, 1.0, b};
+//CHECK-NEXT: {{^}} ^{{$}}
+struct foo{};
+struct bar{};
+
+foo f;
+bar b;
+_Complex double ds = {f, 1.0, b};
+
+//CHECK: {{.*}}: error: no viable conversion from 'foo' to 'double'
+//CHECK-NEXT: {{^}}_Complex double fg = {1.0, f};
+//CHECK-NEXT: {{^}} ^{{$}}
+_Complex double fg = {1.0, f};
+
+
+//CHECK: {{.*}}: error: excess elements in scalar initializer
+//CHECK-NEXT: {{^}}_Complex double gg = {1.0, 2.0, f};
+//CHECK-NEXT: {{^}} ^{{$}}
+//CHECK-NEXT: {{^}}6 errors generated.
+_Complex double gg = {1.0, 2.0, f};
// Random other valid stuff
-_Complex int valid2 = { 1, 2 }; // expected-warning {{complex integer}} expected-warning {{specifying real and imaginary components is an extension}}
+_Complex int valid2 = { 1, 2 }; // expected-warning {{complex integer}} \
+ // expected-warning {{specifying real and imaginary components is an extension}}
struct teststruct valid3 = { { 1.0f, 2.0f} }; // expected-warning {{specifying real and imaginary components is an extension}}
_Complex float valid4[2] = { {1.0f, 1.0f}, {1.0f, 1.0f} }; // expected-warning 2 {{specifying real and imaginary components is an extension}}
// FIXME: We need some sort of warning for valid5
-_Complex float valid5 = {1.0f, 1.0fi}; // expected-warning {{imaginary constants}} expected-warning {{specifying real and imaginary components is an extension}}
+_Complex float valid5 = {1.0f, 1.0fi}; // expected-warning {{imaginary constants}} \
+ // expected-warning {{specifying real and imaginary components is an extension}}
// Random invalid stuff
struct teststruct invalid1 = { 1, 2 }; // expected-warning {{excess elements}}
-_Complex float invalid2 = { 1, 2, 3 }; // expected-warning {{excess elements}}
-_Complex float invalid3 = {}; // expected-error {{scalar initializer cannot be empty}} expected-warning {{GNU empty initializer}}
+_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}}
// Check incomplete array sizing
// 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}}