Files
clang-p2996/llvm/test/MC/CSKY/invalid-attribute.s
Sergei Barannikov af20c1c129 [MC] Add three-state parseDirective as a replacement for ParseDirective
Conventionally, parsing methods return false on success and true on
error. However, directive parsing methods need a third state: the
directive is not target specific. AsmParser::parseStatement detected
this case by using a fragile heuristic: if the target parser did not
consume any tokens, the directive is assumed to be not target-specific.

Some targets fail to follow the convention: they return success after
emitting an error or do not consume the entire line and return failure
on successful parsing. This was partially worked around by checking for
pending errors in parseStatement.

This patch tries to improve the situation by introducing parseDirective
method that returns ParseStatus -- three-state class. The new method
should eventually replace the old one returning bool.

ParseStatus is intentionally implicitly constructible from bool to allow
uses like `return Error(Loc, "message")`. It also has a potential to
replace OperandMatchResulTy as it is more convenient to use due to the
implicit construction from bool and more type safe.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D154101
2023-07-01 04:33:28 +03:00

55 lines
1.7 KiB
ArmAsm

## Negative tests:
## - Feed integer value to string type attribute.
## - Feed string value to integer type attribute.
## - Invalid arch string.
# RUN: not llvm-mc %s -triple=csky -filetype=asm 2>&1 | FileCheck %s
.csky_attribute CSKY_UNKNOWN
# CHECK: [[@LINE-1]]:17: error: attribute name not recognised: CSKY_UNKNOWN
.csky_attribute CSKY_ARCH_NAME
# CHECK: [[@LINE-1]]:31: error: expected comma
.csky_attribute CSKY_ISA_FLAGS
# CHECK: [[@LINE-1]]:31: error: expected comma
.csky_attribute CSKY_ARCH_NAME, "foo",
# CHECK: [[@LINE-1]]:38: error: expected newline
.csky_attribute CSKY_ISA_FLAGS, 42,
# CHECK: [[@LINE-1]]:35: error: expected newline
.csky_attribute CSKY_ARCH_NAME, "foo"
# CHECK: [[@LINE-1]]:33: error: unknown arch name
.csky_attribute CSKY_CPU_NAME, "foo"
# CHECK: [[@LINE-1]]:32: error: unknown cpu name
.csky_attribute CSKY_DSP_VERSION, "1"
# CHECK: [[@LINE-1]]:35: error: expected numeric constant
.csky_attribute CSKY_VDSP_VERSION, "1"
# CHECK: [[@LINE-1]]:36: error: expected numeric constant
.csky_attribute CSKY_FPU_VERSION, "1"
# CHECK: [[@LINE-1]]:35: error: expected numeric constant
.csky_attribute CSKY_FPU_ABI, "1"
# CHECK: [[@LINE-1]]:31: error: expected numeric constant
.csky_attribute CSKY_FPU_ROUNDING, "1"
# CHECK: [[@LINE-1]]:36: error: expected numeric constant
.csky_attribute CSKY_FPU_DENORMAL, "1"
# CHECK: [[@LINE-1]]:36: error: expected numeric constant
.csky_attribute CSKY_FPU_EXCEPTION, "1"
# CHECK: [[@LINE-1]]:37: error: expected numeric constant
.csky_attribute CSKY_FPU_NUMBER_MODULE, 4
# CHECK: [[@LINE-1]]:41: error: expected string constant
.csky_attribute CSKY_FPU_HARDFP, "1"
# CHECK: [[@LINE-1]]:34: error: expected numeric constant