[llvm-commits] [llvm] r61725 - in /llvm/trunk/lib/AsmParser: LLParser.cpp LLParser.h

Chris Lattner sabre at nondot.org
Mon Jan 5 10:34:07 PST 2009


Author: lattner
Date: Mon Jan  5 12:34:07 2009
New Revision: 61725

URL: http://llvm.org/viewvc/llvm-project?rev=61725&view=rev
Log:
Reject PR3281:accepted03.ll with:

llvm-as: accepted03.ll:1:35: invalid unresolved type up reference
declare void @r({ \7, opaque, \10 } %su)
                                  ^


Modified:
    llvm/trunk/lib/AsmParser/LLParser.cpp
    llvm/trunk/lib/AsmParser/LLParser.h

Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=61725&r1=61724&r2=61725&view=diff

==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Mon Jan  5 12:34:07 2009
@@ -1075,15 +1075,17 @@
 
 
 
-/// ParseArgumentList
+/// ParseArgumentList - Parse the argument list for a function type or function
+/// prototype.  If 'inType' is true then we are parsing a FunctionType.
 ///   ::= '(' ArgTypeListI ')'
 /// ArgTypeListI
 ///   ::= /*empty*/
 ///   ::= '...'
 ///   ::= ArgTypeList ',' '...'
 ///   ::= ArgType (',' ArgType)*
+///
 bool LLParser::ParseArgumentList(std::vector<ArgInfo> &ArgList,
-                                 bool &isVarArg) {
+                                 bool &isVarArg, bool inType) {
   isVarArg = false;
   assert(Lex.getKind() == lltok::lparen);
   Lex.Lex(); // eat the (.
@@ -1099,7 +1101,10 @@
     unsigned Attrs;
     std::string Name;
     
-    if (ParseTypeRec(ArgTy) ||
+    // If we're parsing a type, use ParseTypeRec, because we allow recursive
+    // types (such as a function returning a pointer to itself).  If parsing a
+    // function prototype, we require fully resolved types.
+    if ((inType ? ParseTypeRec(ArgTy) : ParseType(ArgTy)) ||
         ParseOptionalAttrs(Attrs, 0)) return true;
     
     if (Lex.getKind() == lltok::LocalVar ||
@@ -1154,7 +1159,7 @@
   std::vector<ArgInfo> ArgList;
   bool isVarArg;
   unsigned Attrs;
-  if (ParseArgumentList(ArgList, isVarArg) ||
+  if (ParseArgumentList(ArgList, isVarArg, true) ||
       // FIXME: Allow, but ignore attributes on function types!
       // FIXME: Remove in LLVM 3.0
       ParseOptionalAttrs(Attrs, 2))
@@ -2087,7 +2092,7 @@
   unsigned Alignment;
   std::string GC;
 
-  if (ParseArgumentList(ArgList, isVarArg) ||
+  if (ParseArgumentList(ArgList, isVarArg, false) ||
       ParseOptionalAttrs(FuncAttrs, 2) ||
       (EatIfPresent(lltok::kw_section) &&
        ParseStringConstant(Section)) ||

Modified: llvm/trunk/lib/AsmParser/LLParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.h?rev=61725&r1=61724&r2=61725&view=diff

==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.h (original)
+++ llvm/trunk/lib/AsmParser/LLParser.h Mon Jan  5 12:34:07 2009
@@ -232,7 +232,7 @@
         : Loc(L), Type(Ty), Attrs(Attr), Name(N) {}
     };
     bool ParseArgumentList(std::vector<ArgInfo> &ArgList,
-                           bool &isVarArg);
+                           bool &isVarArg, bool inType);
     bool ParseFunctionHeader(Function *&Fn, bool isDefine);
     bool ParseFunctionBody(Function &Fn);
     bool ParseBasicBlock(PerFunctionState &PFS);





More information about the llvm-commits mailing list