[PATCH] D64678: [Sema] Fix -Wuninitialized for struct assignment from GNU C statement expression

Nick Desaulniers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 12 16:48:07 PDT 2019


nickdesaulniers added a comment.

Thanks for the patch. Minor nits looking for test cases that should have no warning (like the two examples provided in the bug).



================
Comment at: clang/test/Sema/warn-uninitialized-statement-expression.c:7
+  int i = ({
+    int z = i; // expected-warning{{variable 'i' is uninitialized when used within its own initialization}}
+    init(&i);
----------------
Can you please add a case like `foo` without `z` in it (so that no warnings are expected, as in pr42604)? (You can keep both test cases, just looking for 1 more, as the first case).


================
Comment at: clang/test/Sema/warn-uninitialized-statement-expression.c:20
+  struct widget my_widget = ({
+    struct widget z = my_widget; // expected-warning{{variable 'my_widget' is uninitialized when used within its own initialization}}
+    int x = my_widget.x;
----------------
Ditto about adding a clear case that should not warn.


================
Comment at: clang/test/Sema/warn-uninitialized-statement-expression.c:21
+    struct widget z = my_widget; // expected-warning{{variable 'my_widget' is uninitialized when used within its own initialization}}
+    int x = my_widget.x;
+    init2(&my_widget);
----------------
This needs a trailing comment like:
```
int x = my_widget.x; // fixme: we should probably warn about this case
```
and file a bug about it.  Doesn't need to be solved here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64678





More information about the cfe-commits mailing list