hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

Thanks!



================
Comment at: clang/lib/Sema/SemaDecl.cpp:17752
+    if (Enum->isDependentType() || Val->isTypeDependent() ||
+        Val->containsErrors())
       EltTy = Context.DependentTy;
----------------
What's happening during the crash:

- the EltTy is an enum type which points to an incomplete enum decl 
- the EnumDecl::getIntegerType() returns a null type
- ASTContext.getIntWidth crashes on a null type

As discussed, an alternative is to add a guard for incomplete-type EltTy (and 
assert that we only see this case for recovery-expr case), a disadvantage is 
that this might be narrow...

The current solution also seems fine to me.


================
Comment at: clang/test/Sema/enum.cpp:1
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
----------------
I'd put the test case in `clang/test/SemaCXX/recovery-expr-type.cpp`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108451

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

Reply via email to