[PATCH] D49599: Prevent Scoped Enums from being Integral constant expressions:
Erich Keane via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 20 10:47:19 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL337585: Prevent Scoped Enums from being Integral constant expressions: (authored by erichkeane, committed by ).
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D49599?vs=156487&id=156540#toc
Repository:
rL LLVM
https://reviews.llvm.org/D49599
Files:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/SemaCXX/PR38235.cpp
Index: cfe/trunk/lib/AST/ExprConstant.cpp
===================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp
+++ cfe/trunk/lib/AST/ExprConstant.cpp
@@ -11142,7 +11142,7 @@
const Expr *E,
llvm::APSInt *Value,
SourceLocation *Loc) {
- if (!E->getType()->isIntegralOrEnumerationType()) {
+ if (!E->getType()->isIntegralOrUnscopedEnumerationType()) {
if (Loc) *Loc = E->getExprLoc();
return false;
}
Index: cfe/trunk/test/SemaCXX/PR38235.cpp
===================================================================
--- cfe/trunk/test/SemaCXX/PR38235.cpp
+++ cfe/trunk/test/SemaCXX/PR38235.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+enum class E { Foo, Bar = 97119 };
+
+void f() __attribute__((constructor(E::Foo))); // expected-error{{'constructor' attribute requires an integer constant}}
+void f2() __attribute__((constructor(E::Bar)));// expected-error{{'constructor' attribute requires an integer constant}}
+
+void switch_me(E e) {
+ switch (e) {
+ case E::Foo:
+ case E::Bar:
+ break;
+ }
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49599.156540.patch
Type: text/x-patch
Size: 1243 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180720/7514af95/attachment.bin>
More information about the llvm-commits
mailing list