[clang] [Sema] Check nullness of captured type before use (PR #72230)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 14 06:03:47 PST 2023


================
@@ -23,3 +23,9 @@ int pr43080(int i) { // expected-note {{declared here}}
       i; // expected-error {{variable 'i' cannot be implicitly captured in a lambda with no capture-default specified}}
   }();
 }
+
+void pr72198() {
+  int [_, b] = {0, 0}; // expected-error{{decomposition declaration cannot be declared with type 'int'; declared type must be 'auto' or reference to 'auto'}} \
+                          expected-error{{excess elements in scalar initializer}}
+  [b]{}; // expected-warning{{expression result unused}}
----------------
tbaederr wrote:

```suggestion
  int [_, b] = {0, 0}; // expected-error {{decomposition declaration cannot be declared with type 'int'; declared type must be 'auto' or reference to 'auto'}} \
                          expected-error {{excess elements in scalar initializer}}
  [b]{}; // expected-warning {{expression result unused}}
```

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


More information about the cfe-commits mailing list