[PATCH] D113837: Sema: Let InitListExpr have dependent type instead of 'void'

Aaron Puchert via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 14 08:46:54 PST 2021


aaronpuchert added a subscriber: JonasToth.
aaronpuchert added a comment.

We could also introduce a separate (placeholder) type for initializer lists and perhaps also `ParenListExpr` if the dependent type seems misleading to you.

CC @JonasToth for the changes to `clang-tidy/checkers/cppcoreguidelines-owning-memory.cpp`.



================
Comment at: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-owning-memory.cpp:306
   }
   HeapArray(int size, T val, int *problematic) : _data{problematic}, size(size) {} // Bad
+  // CHECK-NOTES: [[@LINE-1]]:50: warning: expected initialization of owner member variable with value of type 'gsl::owner<>'; got '<dependent type>'
----------------
If the warning is looking at this in the original template, we're initializing a `gsl::owner<T *>` which is type-dependent. So we can't carry out the initialization yet.

[Got the impression earlier](https://github.com/mgehre/llvm-project/issues/80#issuecomment-567210626) that the lifetime checks want to “understand” templates which can of course not work because templates can be specialized, overload resolution is only performed on  the instantiation, and so on.


================
Comment at: clang/test/SemaOpenCLCXX/address-space-references.clcpp:25
   c.gen({1, 2});
-  c.glob({1, 2}); //expected-error{{binding reference of type 'const __global short2' (vector of 2 'short' values) to value of type 'void' changes address space}}
+  c.glob({1, 2}); //expected-error{{binding reference of type 'const __global short2' (vector of 2 'short' values) to value of type '<dependent type>' changes address space}}
   c.nested_list({{1, 2}, {3, 4}});
----------------
Somehow we seem to fail matching the initializer list, but not report that, only on type mismatch later. I think we should either go through with the initialization, then have a `short __attribute__((ext_vector_type(2)))` and complain that we can't bind the reference to that, or complain when processing the initializer list.

But that's unrelated to this change, `void` was also not correct.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113837



More information about the cfe-commits mailing list