[PATCH] D76096: [clang] allow const structs to be constant expressions for C
Nick Desaulniers via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 20 13:37:23 PDT 2023
nickdesaulniers planned changes to this revision.
nickdesaulniers added inline comments.
================
Comment at: clang/test/Sema/builtins.c:181-186
+ ASSERT(!OPT(test17_c));
+ ASSERT(!OPT(&test17_c[0]));
+ ASSERT(!OPT((char*)test17_c));
ASSERT(!OPT(test17_d)); // expected-warning {{folding}}
ASSERT(!OPT(&test17_d[0])); // expected-warning {{folding}}
ASSERT(!OPT((char*)test17_d)); // expected-warning {{folding}}
----------------
efriedma wrote:
> nickdesaulniers wrote:
> > `test17_c` and `test17_d` are both declared as `const char [4];` not sure why this case would differ
> `strlen(test17_c)` is 3; `strlen(test17_d)` is undefined behavior. I assume the difference is because the latter doesn't fold.
Ah right, test17_d is not a NUL-terminated C style string. I'll add a comment (or update the existing one) to the test about that.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D76096/new/
https://reviews.llvm.org/D76096
More information about the cfe-commits
mailing list