diff options
author | Gabor Ballabas <gaborb@inf.u-szeged.hu> | 2015-07-01 08:58:49 +0000 |
---|---|---|
committer | Gabor Ballabas <gaborb@inf.u-szeged.hu> | 2015-07-01 08:58:49 +0000 |
commit | af06a883782c55f541bf80f3cb5a42c3a70b3ee4 (patch) | |
tree | 5a3bdb5ab377d245f05863f7419d8a59300ee402 | |
parent | 7655381aa1f27729966c16b16599fba802dacec1 (diff) | |
download | bcm5719-llvm-af06a883782c55f541bf80f3cb5a42c3a70b3ee4.tar.gz bcm5719-llvm-af06a883782c55f541bf80f3cb5a42c3a70b3ee4.zip |
Fix PR23872: Integrated assembler error message when using .type directive with @ in AArch32 assembly.
The AArch32 assembler parses the '@' as a comment symbol, so the error message shouldn't suggest
that '@<type>' is a valid replacement when assembling for AArch32 target.
Differential Revision: http://reviews.llvm.org/D10651
llvm-svn: 241149
-rw-r--r-- | llvm/lib/MC/MCParser/ELFAsmParser.cpp | 14 | ||||
-rw-r--r-- | llvm/test/MC/ELF/gnu-type-diagnostics.s | 28 |
2 files changed, 38 insertions, 4 deletions
diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp index e3585bd2763..5f8a6039afd 100644 --- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp +++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp @@ -593,10 +593,16 @@ bool ELFAsmParser::ParseDirectiveType(StringRef, SMLoc) { Lex(); if (getLexer().isNot(AsmToken::Identifier) && - getLexer().isNot(AsmToken::Hash) && getLexer().isNot(AsmToken::At) && - getLexer().isNot(AsmToken::Percent) && getLexer().isNot(AsmToken::String)) - return TokError("expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', '@<type>', " - "'%<type>' or \"<type>\""); + getLexer().isNot(AsmToken::Hash) && + getLexer().isNot(AsmToken::Percent) && + getLexer().isNot(AsmToken::String)) { + if (!getLexer().getAllowAtInIdentifier()) + return TokError("expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', " + "'%<type>' or \"<type>\""); + else if (getLexer().isNot(AsmToken::At)) + return TokError("expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', '@<type>', " + "'%<type>' or \"<type>\""); + } if (getLexer().isNot(AsmToken::String) && getLexer().isNot(AsmToken::Identifier)) diff --git a/llvm/test/MC/ELF/gnu-type-diagnostics.s b/llvm/test/MC/ELF/gnu-type-diagnostics.s index df87d6df082..11dac3594f5 100644 --- a/llvm/test/MC/ELF/gnu-type-diagnostics.s +++ b/llvm/test/MC/ELF/gnu-type-diagnostics.s @@ -1,4 +1,29 @@ // RUN: not llvm-mc -triple i686-elf -filetype asm -o /dev/null %s 2>&1 | FileCheck %s +// RUN: not llvm-mc -triple aarch64-elf -filetype asm -o /dev/null %s 2>&1 | FileCheck %s +// RUN: not llvm-mc -triple arm-elf -filetype asm -o /dev/null %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-INVALID-AT-IN-TYPE-DIRECTIVE %s +// RUN: not llvm-mc -triple armeb-elf -filetype asm -o /dev/null %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-INVALID-AT-IN-TYPE-DIRECTIVE %s +// RUN: not llvm-mc -triple thumb-elf -filetype asm -o /dev/null %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-INVALID-AT-IN-TYPE-DIRECTIVE %s +// RUN: not llvm-mc -triple thumbeb-elf -filetype asm -o /dev/null %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-INVALID-AT-IN-TYPE-DIRECTIVE %s +// RUN: not llvm-mc -triple arm-coff -filetype asm -o /dev/null %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-INVALID-AT-IN-TYPE-DIRECTIVE %s +// RUN: not llvm-mc -triple armeb-coff -filetype asm -o /dev/null %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-INVALID-AT-IN-TYPE-DIRECTIVE %s +// RUN: not llvm-mc -triple thumb-coff -filetype asm -o /dev/null %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-INVALID-AT-IN-TYPE-DIRECTIVE %s +// RUN: not llvm-mc -triple thumbeb-coff -filetype asm -o /dev/null %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-INVALID-AT-IN-TYPE-DIRECTIVE %s +// RUN: not llvm-mc -triple arm-apple -filetype asm -o /dev/null %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-INVALID-AT-IN-TYPE-DIRECTIVE %s +// RUN: not llvm-mc -triple armeb-apple -filetype asm -o /dev/null %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-INVALID-AT-IN-TYPE-DIRECTIVE %s +// RUN: not llvm-mc -triple thumb-apple -filetype asm -o /dev/null %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-INVALID-AT-IN-TYPE-DIRECTIVE %s +// RUN: not llvm-mc -triple thumbeb-apple -filetype asm -o /dev/null %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-INVALID-AT-IN-TYPE-DIRECTIVE %s .type TYPE FUNC // CHECK: error: unsupported attribute in '.type' directive @@ -15,4 +40,7 @@ // CHECK: .type symbol 32 // CHECK: ^ +// CHECK-INVALID-AT-IN-TYPE-DIRECTIVE: error: expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', '%<type>' or "<type>" +// CHECK-INVALID-AT-IN-TYPE-DIRECTIVE: .type symbol 32 +// CHECK-INVALID-AT-IN-TYPE-DIRECTIVE: ^ |