[PATCH] D120862: Sema: Allow scoped enums as source type for integral conversion.

Peter Collingbourne via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 2 18:33:15 PST 2022


pcc created this revision.
pcc added a reviewer: rsmith.
Herald added a project: All.
pcc requested review of this revision.
Herald added a project: clang.

Fixes pr54158.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120862

Files:
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCXX/cxx17-enum-scoped.cpp


Index: clang/test/SemaCXX/cxx17-enum-scoped.cpp
===================================================================
--- /dev/null
+++ clang/test/SemaCXX/cxx17-enum-scoped.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++17 -verify -triple x86_64-apple-darwin %s
+
+// expected-no-diagnostics
+
+namespace PR54158 {
+  enum class A : int;
+  enum class B : int;
+  B x{A{}};
+}
Index: clang/lib/Sema/SemaOverload.cpp
===================================================================
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -420,7 +420,7 @@
   //    value when converted back to the original type.
   case ICK_Integral_Conversion:
   IntegralConversion: {
-    assert(FromType->isIntegralOrUnscopedEnumerationType());
+    assert(FromType->isIntegralOrEnumerationType());
     assert(ToType->isIntegralOrUnscopedEnumerationType());
     const bool FromSigned = FromType->isSignedIntegerOrEnumerationType();
     const unsigned FromWidth = Ctx.getIntWidth(FromType);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120862.412587.patch
Type: text/x-patch
Size: 1024 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220303/a90825e9/attachment-0001.bin>


More information about the cfe-commits mailing list