Index: lld/trunk/ELF/ScriptLexer.cpp =================================================================== --- lld/trunk/ELF/ScriptLexer.cpp +++ lld/trunk/ELF/ScriptLexer.cpp @@ -78,15 +78,11 @@ if (ErrorCount) return; - if (!Pos) { - error(getCurrentLocation() + ": " + Msg); - return; - } - - std::string S = getCurrentLocation() + ": "; - error(S + Msg); - error(S + getLine()); - error(S + std::string(getColumnNumber(), ' ') + "^"); + std::string S = (getCurrentLocation() + ": " + Msg).str(); + if (Pos) + S += "\n>>> " + getLine().str() + "\n>>> " + + std::string(getColumnNumber(), ' ') + "^"; + error(S); } // Split S into linker script tokens. Index: lld/trunk/test/ELF/linkerscript/diagnostic.s =================================================================== --- lld/trunk/test/ELF/linkerscript/diagnostic.s +++ lld/trunk/test/ELF/linkerscript/diagnostic.s @@ -50,9 +50,9 @@ # RUN: echo ".temp : { *(.temp) } }" >> %t.script # RUN: not ld.lld -shared %t -o %t1 --script %t.script 2>&1 | \ # RUN: FileCheck -check-prefix=ERR6 -strict-whitespace %s -# ERR6: error: {{.*}}.script:1: -# ERR6-NEXT: error: {{.*}}.script:1: UNKNOWN_TAG { -# ERR6-NEXT: error: {{.*}}.script:1: ^ +# ERR6: error: {{.*}}.script:1: unknown directive: UNKNOWN_TAG +# ERR6-NEXT: >>> UNKNOWN_TAG { +# ERR6-NEXT: >>> ^ ## One more check that text of lines and pointer to 'bad' token are working ok. # RUN: echo "SECTIONS {" > %t.script @@ -62,8 +62,8 @@ # RUN: not ld.lld -shared %t -o %t1 --script %t.script 2>&1 | \ # RUN: FileCheck -check-prefix=ERR7 -strict-whitespace %s # ERR7: error: {{.*}}.script:4: malformed number: .temp -# ERR7-NEXT: error: {{.*}}.script:4: boom .temp : { *(.temp) } } -# ERR7-NEXT: error: {{.*}}.script:4: ^ +# ERR7-NEXT: >>> boom .temp : { *(.temp) } } +# ERR7-NEXT: >>> ^ ## Check tokenize() error # RUN: echo "SECTIONS {}" > %t.script @@ -89,8 +89,8 @@ # RUN: not ld.lld -shared %t -o %t1 --script %t.script 2>&1 | \ # RUN: FileCheck -check-prefix=ERR10 -strict-whitespace %s # ERR10: error: {{.*}}.script.inc:4: malformed number: .temp -# ERR10-NEXT: error: {{.*}}.script.inc:4: boom .temp : { *(.temp) } } -# ERR10-NEXT: error: {{.*}}.script.inc:4: ^ +# ERR10-NEXT: >>> boom .temp : { *(.temp) } } +# ERR10-NEXT: >>> ^ ## Check error reporting in script with INCLUDE directive. # RUN: echo "SECTIONS {" > %t.script.inc Index: lld/trunk/test/ELF/linkerscript/linkerscript.s =================================================================== --- lld/trunk/test/ELF/linkerscript/linkerscript.s +++ lld/trunk/test/ELF/linkerscript/linkerscript.s @@ -38,7 +38,7 @@ # RUN: not ld.lld %t.script > %t.log 2>&1 # RUN: FileCheck -check-prefix=INCLUDE_ERR %s < %t.log # INCLUDE_ERR: error: {{.+}}.script:1: cannot open foo.script -# INCLUDE_ERR-NEXT: error: {{.+}}.script:1: INCLUDE "foo.script" +# INCLUDE_ERR-NEXT: INCLUDE "foo.script" # RUN: ld.lld -L %T %t.script %t # RUN: echo "FOO(BAR)" > %t.script