aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaStmt.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-06-29 17:12:35 +0000
committerDouglas Gregor <dgregor@apple.com>2010-06-29 17:12:35 +0000
commit6623584c0ec508110d75572eef092bf98fedf3f4 (patch)
tree8a747f7d0a07ba8d5170cc4f321657327626b5dc /lib/Sema/SemaStmt.cpp
parent9fde9c424f734e1ef45177999e3a04faad127414 (diff)
With packed enums, an enumerator's value may be stored in more bits
than the enumeration type itself takes. Fixes PR7477. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107163 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaStmt.cpp')
-rw-r--r--lib/Sema/SemaStmt.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index 738fc55823..8e163ef245 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -836,6 +836,8 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, StmtArg Switch,
llvm::APSInt Val = (*EDI)->getInitVal();
if(Val.getBitWidth() < CondWidth)
Val.extend(CondWidth);
+ else if (Val.getBitWidth() > CondWidth)
+ Val.trunc(CondWidth);
Val.setIsSigned(CondIsSigned);
EnumVals.push_back(std::make_pair(Val, (*EDI)));
}