Do not call warning() from ELFOptTable::parse().

warning() depends on Config->FatalWarnings, so we don't want to call
that function before we initialize that member.

llvm-svn: 274723
This commit is contained in:
Rui Ueyama 2016-07-07 01:58:04 +00:00
parent 730c82e6b8
commit 0f282a593f
3 changed files with 5 additions and 9 deletions

View File

@ -81,7 +81,7 @@ struct Configuration {
bool EhFrameHdr;
bool EnableNewDtags;
bool ExportDynamic;
bool FatalWarnings = false;
bool FatalWarnings;
bool GcSections;
bool GnuHash = false;
bool ICF;

View File

@ -87,11 +87,8 @@ opt::InputArgList ELFOptTable::parse(ArrayRef<const char *> Argv) {
"\", expected " + Twine(MissingCount) +
(MissingCount == 1 ? " argument.\n" : " arguments"));
iterator_range<opt::arg_iterator> Unknowns = Args.filtered(OPT_UNKNOWN);
for (auto *Arg : Unknowns)
warning("warning: unknown argument: " + Arg->getSpelling());
if (Unknowns.begin() != Unknowns.end())
error("unknown argument(s) found");
for (auto *Arg : Args.filtered(OPT_UNKNOWN))
error("unknown argument: " + Arg->getSpelling());
return Args;
}

View File

@ -3,9 +3,8 @@
# RUN: not ld.lld --unknown1 --unknown2 -m foo /no/such/file -lnosuchlib \
# RUN: 2>&1 | FileCheck -check-prefix=UNKNOWN %s
# UNKNOWN: warning: unknown argument: --unknown1
# UNKNOWN: warning: unknown argument: --unknown2
# UNKNOWN: unknown argument(s) found
# UNKNOWN: unknown argument: --unknown1
# UNKNOWN: unknown argument: --unknown2
# UNKNOWN: unknown emulation: foo
# UNKNOWN: cannot open /no/such/file
# UNKNOWN: unable to find library -lnosuchlib