"unsupported inline asm: input with type "
"%diff{$ matching output with type $|}0,1">;
def err_asm_unknown_register_name : Error<"unknown register name '%0' in asm">;
+ def err_asm_empty : Error<"__asm used with no assembly instructions">;
def warn_asm_label_on_auto_decl : Warning<
"ignored asm label '%0' on automatic variable">;
def err_invalid_asm_cast_lvalue : Error<
}
// Build the individual assembly instruction(s) and place them in the AsmStrings
-// vector. These strings are fed to the AsmParser.
-static void buildMSAsmStrings(Sema &SemaRef, ArrayRef<Token> AsmToks,
+// vector. These strings are fed to the AsmParser. Returns true on error.
+static bool buildMSAsmStrings(Sema &SemaRef,
+ SourceLocation AsmLoc,
+ ArrayRef<Token> AsmToks,
std::vector<std::string> &AsmStrings,
std::vector<std::pair<unsigned,unsigned> > &AsmTokRanges) {
assert (!AsmToks.empty() && "Didn't expect an empty AsmToks!");
}
if (AsmToks[i].is(tok::kw_asm)) {
i++; // Skip __asm
- assert(i != e && "Expected another token");
+ if (i == e) {
+ SemaRef.Diag(AsmLoc, diag::err_asm_empty);
+ return true;
+ }
}
}
}
AsmStrings.push_back(Asm.str());
AsmTokRanges.push_back(std::make_pair(startTok, AsmToks.size()-1));
+
+ return false;
}
#define DEF_SIMPLE_MSASM(STR) \
std::vector<std::string> AsmStrings;
std::vector<std::pair<unsigned,unsigned> > AsmTokRanges;
- buildMSAsmStrings(*this, AsmToks, AsmStrings, AsmTokRanges);
+ if (buildMSAsmStrings(*this, AsmLoc, AsmToks, AsmStrings, AsmTokRanges))
+ return StmtError();
std::vector<std::vector<StringRef> > Pieces(AsmStrings.size());
buildMSAsmPieces(AsmStrings, Pieces);