/// the current PC. Defaults to false.
bool DollarIsPC = false;
+ /// Allow '.' token, when not referencing an identifier or constant, to refer
+ /// to the current PC. Defaults to true.
+ bool DotIsPC = true;
+
/// This string, if specified, is used to separate instructions from each
/// other when on the same line. Defaults to ';'
const char *SeparatorString;
unsigned getMinInstAlignment() const { return MinInstAlignment; }
bool getDollarIsPC() const { return DollarIsPC; }
+ bool getDotIsPC() const { return DotIsPC; }
const char *getSeparatorString() const { return SeparatorString; }
/// This indicates the column (zero-based) at which asm comments should be
void setAllowHashAtStartOfIdentifier(bool Value) {
AllowHashAtStartOfIdentifier = Value;
}
+ void setAllowDotIsPC(bool Value) { DotIsPC = Value; }
};
// Setup a testing class that the GTest framework can call.
static void SetUpTestCase() {
LLVMInitializeSystemZTargetInfo();
LLVMInitializeSystemZTargetMC();
+ LLVMInitializeSystemZAsmParser();
}
std::unique_ptr<MCRegisterInfo> MRI;
std::unique_ptr<MCStreamer> Str;
std::unique_ptr<MCAsmParser> Parser;
std::unique_ptr<MCContext> Ctx;
+ std::unique_ptr<MCSubtargetInfo> STI;
+ std::unique_ptr<MCTargetAsmParser> TargetAsmParser;
SourceMgr SrcMgr;
std::string TripleName;
MRI.reset(TheTarget->createMCRegInfo(TripleName));
EXPECT_NE(MRI, nullptr);
+ MII.reset(TheTarget->createMCInstrInfo());
+ EXPECT_NE(MII, nullptr);
+
+ STI.reset(TheTarget->createMCSubtargetInfo(TripleName, "z10", ""));
+ EXPECT_NE(STI, nullptr);
+
std::unique_ptr<MCAsmInfo> MAI;
MAI.reset(TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions));
EXPECT_NE(MAI, nullptr);
Str.reset(TheTarget->createNullStreamer(*Ctx));
Parser.reset(createMCAsmParser(SrcMgr, *Ctx, *Str, *MUPMAI));
+
+ TargetAsmParser.reset(
+ TheTarget->createMCAsmParser(*STI, *Parser, *MII, MCOptions));
+ Parser->setTargetParser(*TargetAsmParser);
}
void lexAndCheckTokens(StringRef AsmStr,
{AsmToken::Identifier, AsmToken::EndOfStatement, AsmToken::Eof});
lexAndCheckTokens(AsmStr, ExpectedTokens);
}
+
+TEST_F(SystemZAsmLexerTest, CheckRejectDotAsCurrentPC) {
+ StringRef AsmStr = ".-4";
+
+ // Setup.
+ MUPMAI->setAllowDotIsPC(false);
+ setupCallToAsmParser(AsmStr);
+
+ // Lex initially to get the string.
+ Parser->getLexer().Lex();
+
+ const MCExpr *Expr;
+ bool ParsePrimaryExpr = Parser->parseExpression(Expr);
+ EXPECT_EQ(ParsePrimaryExpr, true);
+ EXPECT_EQ(Parser->hasPendingError(), true);
+}
} // end anonymous namespace