[PATCH] D126084: [Sema] Reject implicit conversions between different scoped enum types in list initialization

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 25 10:28:49 PDT 2022


aaron.ballman added a reviewer: clang-language-wg.
aaron.ballman added a comment.

Please add more details to the summary and remove the rdar link (nobody outside of Apple can access that anyway). Also, this should have a release note for the bug fix.



================
Comment at: clang/lib/Sema/SemaInit.cpp:4506
         !S.Context.hasSameUnqualifiedType(E->getType(), DestType) &&
-        (E->getType()->isIntegralOrEnumerationType() ||
+        (E->getType()->isIntegralOrUnscopedEnumerationType() ||
          E->getType()->isFloatingType())) {
----------------
This doesn't match the comments immediately above here and I don't think is the correct fix.

We're handling this case: http://eel.is/c++draft/dcl.init.list#3.8

A scoped enumeration has a fixed underlying type (https://eel.is/c++draft/dcl.enum#5.sentence-5). The initializer list has a single element and that element can be implicitly converted to the underlying type (`int` in all of the test cases changed in this patch). And this is a direct initialization case, so I think we should be performing the conversion here rather than skipping to the next bullet.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126084



More information about the cfe-commits mailing list