Fix a few cases where enum constant handling was using
ASTContext::getTypeSize() rather than ASTContext::getIntWidth() for
the width of an integral type. The former includes padding for bools
(to the target's size) while the latter does not, so we woud end up
zero-extending bools to the target width when we shouldn't. Fixes a
crash-on-valid in the included test.
llvm-svn: 101372
diff --git a/clang/test/SemaCXX/constant-expression.cpp b/clang/test/SemaCXX/constant-expression.cpp
index 0d4d387..a17dd58 100644
--- a/clang/test/SemaCXX/constant-expression.cpp
+++ b/clang/test/SemaCXX/constant-expression.cpp
@@ -1,5 +1,4 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
-
// C++ [expr.const]p1:
// In several places, C++ requires expressions that evaluate to an integral
// or enumeration constant: as array bounds, as case expressions, as
@@ -79,5 +78,10 @@
};
template struct C<1, eval>;
-//template struct C<cval, ceval>;
-//template struct C<Struct::sval, Struct::seval>;
+template struct C<cval, ceval>;
+template struct C<Struct::sval, Struct::seval>;
+
+enum {
+ a = sizeof(int) == 8,
+ b = a? 8 : 4
+};