[clang] [clang-tools-extra] [CLANGD] Do not crash on designator initialization of union (PR #83369)

Nathan Ridge via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 15 00:16:45 PDT 2024


================
@@ -72,6 +72,22 @@ TEST_F(ExtractVariableTest, Test) {
     )cpp";
   EXPECT_UNAVAILABLE(NoCrashCasesC);
 
+  ExtraArgs = {"-xc"};
+  const char *NoCrashDesignator = R"cpp(
+    struct A {
+      struct {
+        int x;
+      };
+    };
+    struct B {
+      int y;
+    };
+    void foo(struct B *b) {
+      struct A a = {.[[x]]=b->y};
----------------
HighCommander4 wrote:

This test case does not fail without the fix.

The reason is that the selection `[[x]]` does not trigger the crash.

The selection needs to be on the `[[->]]` to trigger the crash (and then, the result will be `AVAILABLE`).

Otherwise looks good, thanks!

https://github.com/llvm/llvm-project/pull/83369


More information about the cfe-commits mailing list