summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/AST/ExprConstant.cpp2
-rw-r--r--clang/test/SemaCXX/PR38235.cpp14
2 files changed, 15 insertions, 1 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index bf21bc65e2b..e69914f25da 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -11142,7 +11142,7 @@ static bool EvaluateCPlusPlus11IntegralConstantExpr(const ASTContext &Ctx,
const Expr *E,
llvm::APSInt *Value,
SourceLocation *Loc) {
- if (!E->getType()->isIntegralOrEnumerationType()) {
+ if (!E->getType()->isIntegralOrUnscopedEnumerationType()) {
if (Loc) *Loc = E->getExprLoc();
return false;
}
diff --git a/clang/test/SemaCXX/PR38235.cpp b/clang/test/SemaCXX/PR38235.cpp
new file mode 100644
index 00000000000..11874c837bc
--- /dev/null
+++ b/clang/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;
+ }
+}
OpenPOWER on IntegriCloud