[PATCH] D146503: Fix highlighting issue with _complex and initialization list with more than 2 items

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 22 05:56:15 PDT 2023


aaron.ballman added a comment.

Thanks for this!

One thing that's missing is test coverage for the highlight itself, as that was what the original issue was about. You should add a test that uses `-fcaret-diagnostics-max-lines` and `FileCheck` so that you can test that the caret shows up where expected (along the lines of https://github.com/llvm/llvm-project/blob/main/clang/test/Misc/caret-diags-multiline.cpp).

You should also add a release note about the fix to `clang/docs/ReleaseNotes.rst`



================
Comment at: clang/test/Sema/complex-init-list.c:37
 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}}
----------------
This makes it a bit easier to see that there are two diagnostics being fired (even though we're not consistently doing that in this test file).


================
Comment at: clang/test/Sema/complex-init-list.c:51-52
+// 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}}
----------------



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146503/new/

https://reviews.llvm.org/D146503



More information about the cfe-commits mailing list