Index: llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp =================================================================== --- llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp +++ llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp @@ -25,7 +25,7 @@ COMMDirectiveAlignmentIsInBytes = false; LCOMMDirectiveAlignmentType = LCOMM::ByteAlignment; HasDotTypeDotSizeDirective = false; - HasSingleParameterDotFile = false; + HasSingleParameterDotFile = true; WeakRefDirective = "\t.weak\t"; HasLinkOnceDirective = true; Index: llvm/trunk/lib/MC/MCParser/AsmParser.cpp =================================================================== --- llvm/trunk/lib/MC/MCParser/AsmParser.cpp +++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp @@ -3360,9 +3360,12 @@ } } - if (FileNumber == -1) + if (FileNumber == -1) { + if (!getContext().getAsmInfo()->hasSingleParameterDotFile()) + return Error(DirectiveLoc, + "target does not support '.file' without a number"); getStreamer().EmitFileDirective(Filename); - else { + } else { // In case there is a -g option as well as debug info from directive .file, // we turn off the -g option, directly use the existing debug info instead. // Also reset any implicit ".file 0" for the assembler source. Index: llvm/trunk/test/MC/COFF/file.s =================================================================== --- llvm/trunk/test/MC/COFF/file.s +++ llvm/trunk/test/MC/COFF/file.s @@ -1,6 +1,11 @@ // RUN: llvm-mc -triple i686-windows -filetype obj %s -o - | llvm-objdump -t - \ // RUN: | FileCheck %s +// Round trip through .s output to exercise MCAsmStreamer. +// RUN: llvm-mc -triple i686-windows %s -o - \ +// RUN: | llvm-mc -triple i686-windows - -filetype=obj -o - | llvm-objdump -t - \ +// RUN: | FileCheck %s + // RUN: llvm-mc -triple i686-windows -filetype obj %s -o - \ // RUN: | llvm-readobj -symbols | FileCheck %s -check-prefix CHECK-SCN Index: llvm/trunk/test/MC/MachO/file-single.s =================================================================== --- llvm/trunk/test/MC/MachO/file-single.s +++ llvm/trunk/test/MC/MachO/file-single.s @@ -0,0 +1,8 @@ +// RUN: not llvm-mc -triple i386-apple-darwin9 %s -o /dev/null 2>&1 | FileCheck %s + +// Previously this crashed MC. + +// CHECK: error: target does not support '.file' without a number + + .file "dir/foo" + nop