From: Gabor Ballabas Date: Wed, 1 Jul 2015 08:58:49 +0000 (+0000) Subject: Fix PR23872: Integrated assembler error message when using .type directive with ... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=9f9bf86ed5d39dff7c3641ef30f03b8d9050a27b;p=oota-llvm.git 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 '@' is a valid replacement when assembling for AArch32 target. Differential Revision: http://reviews.llvm.org/D10651 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241149 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/MC/MCParser/ELFAsmParser.cpp b/lib/MC/MCParser/ELFAsmParser.cpp index e3585bd2763..5f8a6039afd 100644 --- a/lib/MC/MCParser/ELFAsmParser.cpp +++ b/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_, '#', '@', " - "'%' or \"\""); + getLexer().isNot(AsmToken::Hash) && + getLexer().isNot(AsmToken::Percent) && + getLexer().isNot(AsmToken::String)) { + if (!getLexer().getAllowAtInIdentifier()) + return TokError("expected STT_, '#', " + "'%' or \"\""); + else if (getLexer().isNot(AsmToken::At)) + return TokError("expected STT_, '#', '@', " + "'%' or \"\""); + } if (getLexer().isNot(AsmToken::String) && getLexer().isNot(AsmToken::Identifier)) diff --git a/test/MC/ELF/gnu-type-diagnostics.s b/test/MC/ELF/gnu-type-diagnostics.s index df87d6df082..11dac3594f5 100644 --- a/test/MC/ELF/gnu-type-diagnostics.s +++ b/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_, '#', '%' or "" +// CHECK-INVALID-AT-IN-TYPE-DIRECTIVE: .type symbol 32 +// CHECK-INVALID-AT-IN-TYPE-DIRECTIVE: ^