lebedev.ri added inline comments.

================
Comment at: 
clang/test/Sema/implicit-widening-of-pointer-offset-in-array-subscript-expression.c:24
+void t1(char *base, int a, int b) {
+  // FIXME: test `[a * b]base` pattern?
+}
----------------
dblaikie wrote:
> lebedev.ri wrote:
> > dblaikie wrote:
> > > lebedev.ri wrote:
> > > > dblaikie wrote:
> > > > > Question is unclear - is there uncertainty about whether this should 
> > > > > be tested? Or is this a false negative case? In which case I'd 
> > > > > probably include the test showing no diagnostic and mention it could 
> > > > > be fixed/improved?
> > > > I may be misremembering things, but IIRC `a[b]` and `b[a]` is the same 
> > > > thing,
> > > > but i'm not sure how to exercise the second spelling.
> > > > I.e. i'm just not sure how to write a test for it.
> > > > I may be misremembering things, but IIRC a[b] and b[a] is the same 
> > > > thing,
> > > Yep, that's the case - `a[b]` where one of them is a pointer and teh 
> > > other is an integer, is equivalent to `*(a + b)`, so that means it's the 
> > > same as `b[a]`.
> > > 
> > > I guess you'd write it the same as t0, but with the expressions reversed? 
> > > `return *(a * b)[base];`
> > That's what i tried, and it does't work - https://godbolt.org/z/as4vP4
> Sorry, my mistake - the `*` was wrong. This works: 
> https://godbolt.org/z/j9jqx3
Aha, thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93822

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

Reply via email to