[PATCH] D154675: [Clang] Fix crash when emitting diagnostic for out of order designated initializers in C++

Shafik Yaghmour via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 10 14:10:28 PDT 2023


shafik added inline comments.


================
Comment at: clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp:66
   .y = 1, // override-note {{previous}}
-  .y = 1, // override-error {{overrides prior initialization}}
+  .y = 1, // override-error {{overrides prior initialization}} // reorder-note {{previous initialization for field 'y' is here}}
   .x = 1, // reorder-error {{declaration order}} override-error {{overrides prior initialization}} override-note {{previous}}
----------------
aaron.ballman wrote:
> A few questions: 1) what is this new note attached to? The only `reorder-*` diagnostic I see in the test is for the initialization of `x`. 2) is the note actually on the correct previous use? I would have expected this to be on the assignment to `y` one line above.
It is attached to :

```
.x = 1, // reorder-error {{declaration order}}
```

We were not issuing it before b/c it was broken, in this case it was just not crashing but it was still broken.

We could argue the note should go on the first `.y` although I could see both sides since the override is a warning and not an error I think using the second is defensible. 




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

https://reviews.llvm.org/D154675



More information about the cfe-commits mailing list