[PATCH] D108451: [Sema] Avoid crash in CheckEnumConstant with contains-error expressions

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 2 07:11:06 PDT 2021


sammccall added a comment.

Thanks, and sorry for sitting on this so long.

Addressed comments. I think the failing windows bots were implicit `-fms-extensions` or so that sometimes makes diagnosis more lazy. Moving the test to recovery-expr-type.cpp should take care of this as that test case specifies `-triple`. But waiting for the windows bot to finish before landing.



================
Comment at: clang/test/Sema/enum.cpp:8-9
+// When initializers contain errors, enumerators are non-type-dependent zeros.
+static_assert(Circular_A != 0, ""); // expected-error {{static_assert failed}}
+static_assert(Circular_B != 0, ""); // expected-error {{static_assert failed}}
----------------
aaron.ballman wrote:
> Should we be static asserting this? It seems like emergent behavior more than something we intentionally want anyone to rely on.
Yeah, the thing we're testing is that we can const-evaluate these, and it neither crashes nor propagates dependence further. The static_assert checks the latter.

Replaced with a static assert that isn't sensitive tot he actual value.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108451



More information about the cfe-commits mailing list