llvm.org GIT mirror llvm / 2604a97
Let the integrated assembler understand .warning, PR20428. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213873 91177308-0d34-0410-b5e6-96231b3b80d8 Nico Weber 6 years ago
2 changed file(s) with 59 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
356356 DK_CFI_REGISTER, DK_CFI_WINDOW_SAVE,
357357 DK_MACROS_ON, DK_MACROS_OFF, DK_MACRO, DK_ENDM, DK_ENDMACRO, DK_PURGEM,
358358 DK_SLEB128, DK_ULEB128,
359 DK_ERR, DK_ERROR,
359 DK_ERR, DK_ERROR, DK_WARNING,
360360 DK_END
361361 };
362362
472472
473473 // ".err" or ".error"
474474 bool parseDirectiveError(SMLoc DirectiveLoc, bool WithMessage);
475
476 // ".warning"
477 bool parseDirectiveWarning(SMLoc DirectiveLoc);
475478
476479 void initializeDirectiveKindMap();
477480 };
15521555 return parseDirectiveError(IDLoc, false);
15531556 case DK_ERROR:
15541557 return parseDirectiveError(IDLoc, true);
1558 case DK_WARNING:
1559 return parseDirectiveWarning(IDLoc);
15551560 }
15561561
15571562 return Error(IDLoc, "unknown directive");
40704075
40714076 Error(L, Message);
40724077 return true;
4078 }
4079
4080 /// parseDirectiveWarning
4081 /// ::= .warning [string]
4082 bool AsmParser::parseDirectiveWarning(SMLoc L) {
4083 if (!TheCondStack.empty()) {
4084 if (TheCondStack.back().Ignore) {
4085 eatToEndOfStatement();
4086 return false;
4087 }
4088 }
4089
4090 StringRef Message = ".warning directive invoked in source file";
4091 if (Lexer.isNot(AsmToken::EndOfStatement)) {
4092 if (Lexer.isNot(AsmToken::String)) {
4093 TokError(".warning argument must be a string");
4094 eatToEndOfStatement();
4095 return true;
4096 }
4097
4098 Message = getTok().getStringContents();
4099 Lex();
4100 }
4101
4102 Warning(L, Message);
4103 return false;
40734104 }
40744105
40754106 /// parseDirectiveEndIf
42044235 DirectiveKindMap[".purgem"] = DK_PURGEM;
42054236 DirectiveKindMap[".err"] = DK_ERR;
42064237 DirectiveKindMap[".error"] = DK_ERROR;
4238 DirectiveKindMap[".warning"] = DK_WARNING;
42074239 }
42084240
42094241 MCAsmMacro *AsmParser::parseMacroLikeBody(SMLoc DirectiveLoc) {
0 // RUN: llvm-mc -triple i386 %s 2>&1 | FileCheck %s
1
2 .warning
3 // CHECK: warning: .warning directive invoked in source file
4 // CHECK-NEXT: .warning
5 // CHECK-NEXT: ^
6
7 .ifc a,a
8 .warning
9 .endif
10 // CHECK: warning: .warning directive invoked in source file
11 // CHECK-NEXT: .warning
12 // CHECK-NEXT: ^
13
14 .ifnc a,a
15 .warning
16 .endif
17 // CHECK-NOT: warning: .warning directive invoked in source file
18
19 .warning "here be dragons"
20 // CHECK: warning: here be dragons
21
22 .ifc one, two
23 .warning "dragons, i say"
24 .endif
25 // CHECK-NOT: warning: dragons, i say