sammccall added a comment.

In D107275#3182906 <https://reviews.llvm.org/D107275#3182906>, @kadircet wrote:

> I am more worried about creating "incorrect" nodes in some cases. I think it 
> isn't valid in C/C++ for both LHS && RHS to be pointers/arrays in a subscript 
> expression, but I've got no idea about when it's diagnosed in clang and what 
> is put into the AST.
>
> ... we'll have a bunch of expressions with erroneous `ResultType` info which 
> might trip over some things.

Yeah, I think this is a problem. To put it another way:

- if `X is Foo*` and y is dependent, `x[y]` has type `Foo` *or* it is invalid
- if we claim it has type `Foo` then either template-instantiation must check 
it's valid, or we may accept invalid code
- accepting invalid code can turn into miscompiles via SFINAE

Probably rebuilding during template instantiation does verify enough but I'm 
not 100% sure.

In the motivating case, the subscript is a known integer type and the LHS is an 
array or pointer. In this case we don't have the above concern, and we also 
don't have my #1 above. So I'll restrict the code to cover that case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107275

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to