[PATCH] D130210: [SemaCXX] Set promotion type for enum if its type is promotable to integer type even if it has no definition.
Zequan Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 21 11:23:35 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd870a575631d: [SemaCXX] Set promotion type for enum if its type is promotable to integer type… (authored by zequanwu).
Changed prior to commit:
https://reviews.llvm.org/D130210?vs=446551&id=446584#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D130210/new/
https://reviews.llvm.org/D130210
Files:
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaDecl.cpp
clang/test/CXX/conv/conv.prom/p4.cpp
Index: clang/test/CXX/conv/conv.prom/p4.cpp
===================================================================
--- clang/test/CXX/conv/conv.prom/p4.cpp
+++ clang/test/CXX/conv/conv.prom/p4.cpp
@@ -26,3 +26,10 @@
// FIXME: DR1407 will make this ill-formed
e = +false_ // desired-error {{conversion from 'int' to 'bool'}}
};
+
+namespace GH56560 {
+enum GH56560_1 : bool;
+bool GH56560_2(GH56560_1 a, GH56560_1 b) {
+ return a == b;
+}
+} // namespace GH56560
Index: clang/lib/Sema/SemaDecl.cpp
===================================================================
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -16209,7 +16209,10 @@
ED->setIntegerTypeSourceInfo(TI);
else
ED->setIntegerType(QualType(EnumUnderlying.get<const Type *>(), 0));
- ED->setPromotionType(ED->getIntegerType());
+ QualType EnumTy = ED->getIntegerType();
+ ED->setPromotionType(EnumTy->isPromotableIntegerType()
+ ? Context.getPromotedIntegerType(EnumTy)
+ : EnumTy);
}
} else { // struct/union
New = RecordDecl::Create(Context, Kind, SearchDC, KWLoc, Loc, Name,
@@ -16831,8 +16834,11 @@
if (TypeSourceInfo *TI = EnumUnderlying.dyn_cast<TypeSourceInfo*>())
ED->setIntegerTypeSourceInfo(TI);
else
- ED->setIntegerType(QualType(EnumUnderlying.get<const Type*>(), 0));
- ED->setPromotionType(ED->getIntegerType());
+ ED->setIntegerType(QualType(EnumUnderlying.get<const Type *>(), 0));
+ QualType EnumTy = ED->getIntegerType();
+ ED->setPromotionType(EnumTy->isPromotableIntegerType()
+ ? Context.getPromotedIntegerType(EnumTy)
+ : EnumTy);
assert(ED->isComplete() && "enum with type should be complete");
}
} else {
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -192,6 +192,8 @@
Fixes `Issue 56310 <https://github.com/llvm/llvm-project/issues/56310>`_.
- Clang will now look through type sugar when checking a member function is a
move assignment operator. Fixes `Issue 56456 <https://github.com/llvm/llvm-project/issues/56456>`_.
+- Fixed a crash when a variable with a bool enum type that has no definition
+ used in comparison operators. Fixes `Issue 56560 <https://github.com/llvm/llvm-project/issues/56560>`_.
Improvements to Clang's diagnostics
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130210.446584.patch
Type: text/x-patch
Size: 2585 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220721/e27288b0/attachment.bin>
More information about the cfe-commits
mailing list