aboutsummaryrefslogtreecommitdiff
path: root/lib/AsmParser/LLParser.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-25 06:36:36 +0000
committerChris Lattner <sabre@nondot.org>2009-03-25 06:36:36 +0000
commitad9ad7c827b585c018288c89d611d8c97d8d2e7d (patch)
tree7f0dc1b1b1007c1e30b9634f8a90a4e9feb9e767 /lib/AsmParser/LLParser.cpp
parent0c8f7dc67cebcb1eef5984baaa4802cb46f72797 (diff)
Fix a bug in our autoupgrade support: in an argument list to a function
call, we should treat "i64 zext" as the start of a constant expr, but "i64 0 zext" as an argument with an obsolete attribute on it (this form is already tested by test/Assembler/2007-07-30-AutoUpgradeZextSext.ll). Make the autoupgrade logic more discerning to avoid treating "i64 zext" as an old-style attribute, causing us to reject a valid constant expr. This fixes PR3876. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67682 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AsmParser/LLParser.cpp')
-rw-r--r--lib/AsmParser/LLParser.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp
index 9d0f24cda9..7800b8f721 100644
--- a/lib/AsmParser/LLParser.cpp
+++ b/lib/AsmParser/LLParser.cpp
@@ -678,6 +678,7 @@ bool LLParser::ParseOptionalAddrSpace(unsigned &AddrSpace) {
/// ParseOptionalAttrs - Parse a potentially empty attribute list. AttrKind
/// indicates what kind of attribute list this is: 0: function arg, 1: result,
/// 2: function attr.
+/// 3: function arg after value: FIXME: REMOVE IN LLVM 3.0
bool LLParser::ParseOptionalAttrs(unsigned &Attrs, unsigned AttrKind) {
Attrs = Attribute::None;
LocTy AttrLoc = Lex.getLoc();
@@ -686,9 +687,12 @@ bool LLParser::ParseOptionalAttrs(unsigned &Attrs, unsigned AttrKind) {
switch (Lex.getKind()) {
case lltok::kw_sext:
case lltok::kw_zext:
- // Treat these as signext/zeroext unless they are function attrs.
+ // Treat these as signext/zeroext if they occur in the argument list after
+ // the value, as in "call i8 @foo(i8 10 sext)". If they occur before the
+ // value, as in "call i8 @foo(i8 sext (" then it is part of a constant
+ // expr.
// FIXME: REMOVE THIS IN LLVM 3.0
- if (AttrKind != 2) {
+ if (AttrKind == 3) {
if (Lex.getKind() == lltok::kw_sext)
Attrs |= Attribute::SExt;
else
@@ -700,7 +704,7 @@ bool LLParser::ParseOptionalAttrs(unsigned &Attrs, unsigned AttrKind) {
if (AttrKind != 2 && (Attrs & Attribute::FunctionOnly))
return Error(AttrLoc, "invalid use of function-only attribute");
- if (AttrKind != 0 && (Attrs & Attribute::ParameterOnly))
+ if (AttrKind != 0 && AttrKind != 3 && (Attrs & Attribute::ParameterOnly))
return Error(AttrLoc, "invalid use of parameter-only attribute");
return false;
@@ -1085,7 +1089,7 @@ bool LLParser::ParseParameterList(SmallVectorImpl<ParamInfo> &ArgList,
ParseValue(ArgTy, V, PFS) ||
// FIXME: Should not allow attributes after the argument, remove this in
// LLVM 3.0.
- ParseOptionalAttrs(ArgAttrs2, 0))
+ ParseOptionalAttrs(ArgAttrs2, 3))
return true;
ArgList.push_back(ParamInfo(ArgLoc, V, ArgAttrs1|ArgAttrs2));
}