diff --git a/lib/MC/MCParser/ELFAsmParser.cpp b/lib/MC/MCParser/ELFAsmParser.cpp index f94e9d3c478..3e2150a451e 100644 --- a/lib/MC/MCParser/ELFAsmParser.cpp +++ b/lib/MC/MCParser/ELFAsmParser.cpp @@ -427,13 +427,13 @@ bool ELFAsmParser::parseGroup(StringRef &GroupName) { GroupName = getTok().getString(); Lex(); } else if (getParser().parseIdentifier(GroupName)) { - return true; + return TokError("invalid group name"); } if (L.is(AsmToken::Comma)) { Lex(); StringRef Linkage; if (getParser().parseIdentifier(Linkage)) - return true; + return TokError("invalid linkage"); if (Linkage != "comdat") return TokError("Linkage must be 'comdat'"); } diff --git a/test/MC/ELF/comdat-declaration-errors.s b/test/MC/ELF/comdat-declaration-errors.s new file mode 100644 index 00000000000..fade8cfe41d --- /dev/null +++ b/test/MC/ELF/comdat-declaration-errors.s @@ -0,0 +1,14 @@ +// RUN: not llvm-mc -triple x86_64-pc-linux-gnu %s \ +// RUN: -filetype=obj -o %t.o 2>&1 | FileCheck %s + +// Check we error out on incorrect COMDATs declarations +// and not just silently ingnore them. + +// CHECK: error: invalid group name +// CHECK-NEXT: .section .foo,"G",@progbits,-abc,comdat + +// CHECK: error: invalid linkage +// CHECK-NEXT: .section .bar,"G",@progbits,abc,-comdat + +.section .foo,"G",@progbits,-abc,comdat +.section .bar,"G",@progbits,abc,-comdat