aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaInit.cpp
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2022-05-20 12:16:29 -0700
committerAkira Hatanaka <ahatanaka@apple.com>2022-06-02 17:25:11 -0700
commit66e08995b0b72d28acb5e87b90292e59fabfadae (patch)
tree2fa5aacc0ed58ecaf6fff1cafea177c1bb296ad4 /clang/lib/Sema/SemaInit.cpp
parentf8b692dd31d986bc5a83437fceecf80d4e90f745 (diff)
downloadllvm-66e08995b0b72d28acb5e87b90292e59fabfadae.zip
llvm-66e08995b0b72d28acb5e87b90292e59fabfadae.tar.gz
llvm-66e08995b0b72d28acb5e87b90292e59fabfadae.tar.bz2
[Sema] Reject list-initialization of enumeration types from a
brace-init-list containing a single element of a different scoped enumeration type It is rejected because it doesn't satisfy the condition that the element has to be implicitly convertible to the underlying type of the enumeration. http://eel.is/c++draft/dcl.init.list#3.8 Differential Revision: https://reviews.llvm.org/D126084
Diffstat (limited to 'clang/lib/Sema/SemaInit.cpp')
-rw-r--r--clang/lib/Sema/SemaInit.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 016ff5ded..c7e0680 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -4503,13 +4503,13 @@ static void TryListInitialization(Sema &S,
Kind.getKind() == InitializationKind::IK_DirectList &&
ET && ET->getDecl()->isFixed() &&
!S.Context.hasSameUnqualifiedType(E->getType(), DestType) &&
- (E->getType()->isIntegralOrEnumerationType() ||
+ (E->getType()->isIntegralOrUnscopedEnumerationType() ||
E->getType()->isFloatingType())) {
// There are two ways that T(v) can work when T is an enumeration type.
// If there is either an implicit conversion sequence from v to T or
// a conversion function that can convert from v to T, then we use that.
- // Otherwise, if v is of integral, enumeration, or floating-point type,
- // it is converted to the enumeration type via its underlying type.
+ // Otherwise, if v is of integral, unscoped enumeration, or floating-point
+ // type, it is converted to the enumeration type via its underlying type.
// There is no overlap possible between these two cases (except when the
// source value is already of the destination type), and the first
// case is handled by the general case for single-element lists below.