PECOFF: Move error check for invalid command line combination to validateImpl.
authorRui Ueyama <ruiu@google.com>
Fri, 6 Feb 2015 23:09:13 +0000 (23:09 +0000)
committerRui Ueyama <ruiu@google.com>
Fri, 6 Feb 2015 23:09:13 +0000 (23:09 +0000)
llvm-svn: 228461

lld/lib/Driver/WinLinkDriver.cpp
lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
lld/test/pecoff/noentry.test

index 80524d3..e060c1e 100644 (file)
@@ -1377,12 +1377,6 @@ bool WinLinkDriver::parse(int argc, const char *argv[],
     }
   }
 
-  // Specify /noentry without /dll is an error.
-  if (!ctx.hasEntry() && !parsedArgs->getLastArg(OPT_dll)) {
-    diag << "/noentry must be specified with /dll\n";
-    return false;
-  }
-
   // If dead-stripping is enabled, we need to add the entry symbol and
   // symbols given by /include to the dead strip root set, so that it
   // won't be removed from the output.
index b968ab6..936eef1 100644 (file)
@@ -51,6 +51,12 @@ bool PECOFFLinkingContext::validateImpl(raw_ostream &diagnostics) {
     return false;
   }
 
+  // Specifing /noentry without /dll is an error.
+  if (!hasEntry() && !isDll()) {
+    diagnostics << "/noentry must be specified with /dll\n";
+    return false;
+  }
+
   // Check for duplicate export ordinals.
   std::set<int> exports;
   for (const PECOFFLinkingContext::ExportDesc &desc : getDllExports()) {
index ee5d0cb..55b326d 100644 (file)
@@ -3,3 +3,8 @@
 # RUN: llvm-readobj -file-headers %t.exe | FileCheck %s
 
 CHECK: AddressOfEntryPoint: 0x0
+
+# RUN: not lld -flavor link /out:%t.exe /noentry -- %t.obj >& %t.log
+# RUN: FileCheck --check-prefix=ERROR %s < %t.log
+
+ERROR: /noentry must be specified with /dll