summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorNeelesh Chandola <neelesh.chandola@outlook.com>2018-12-13 13:59:46 +0530
committerNeelesh Chandola <neelesh.chandola@outlook.com>2018-12-13 13:59:46 +0530
commitb2411db54119ea00296d12a47bd12a371bc0a4ba (patch)
tree79d537e3066eb5c9778df62faa3a53445a190892
parentabcf4d8b5dd4988c952a232d4a610d0491ff79ff (diff)
parenta3c4791e9cde49f44e7261044cc84fa863bc717c (diff)
downloadNim-b2411db54119ea00296d12a47bd12a371bc0a4ba.tar.gz
Merge remote-tracking branch 'upstream/devel' into record-case
-rw-r--r--compiler/cmdlinehelper.nim12
-rw-r--r--compiler/extccomp.nim2
-rw-r--r--compiler/semstmts.nim4
-rw-r--r--lib/deprecated/pure/sockets.nim4
-rw-r--r--lib/pure/unittest.nim1
-rw-r--r--tools/vccexe/vccexe.nim18
-rw-r--r--tools/vccexe/vcvarsall.nim4
7 files changed, 27 insertions, 18 deletions
diff --git a/compiler/cmdlinehelper.nim b/compiler/cmdlinehelper.nim
index 8bd073314..9fbf4a0b0 100644
--- a/compiler/cmdlinehelper.nim
+++ b/compiler/cmdlinehelper.nim
@@ -48,6 +48,15 @@ proc loadConfigsAndRunMainCommand*(self: NimProg, cache: IdentCache; conf: Confi
   if self.suggestMode:
     conf.command = "nimsuggest"
 
+  # These defines/options should not be enabled while processing nimscript
+  # bug #4446, #9420, #8991, #9589, #9153
+  undefSymbol(conf.symbols, "profiler")
+  undefSymbol(conf.symbols, "memProfiler")
+  undefSymbol(conf.symbols, "nodejs")
+
+  # bug #9120
+  conf.globalOptions.excl(optTaintMode)
+
   proc runNimScriptIfExists(path: AbsoluteFile)=
     if fileExists(path):
       runNimScript(cache, path, freshDefines = false, conf)
@@ -79,6 +88,9 @@ proc loadConfigsAndRunMainCommand*(self: NimProg, cache: IdentCache; conf: Confi
         # 'nimsuggest foo.nims' means to just auto-complete the NimScript file
         discard
 
+  # Reload configuration from .cfg file
+  loadConfigs(DefaultConfig, cache, conf)
+
   # now process command line arguments again, because some options in the
   # command line can overwite the config file's settings
   extccomp.initVars(conf)
diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim
index 4b9e1c6fe..23f723e29 100644
--- a/compiler/extccomp.nim
+++ b/compiler/extccomp.nim
@@ -780,7 +780,7 @@ proc linkViaResponseFile(conf: ConfigRef; cmd: string) =
   let linkerArgs = conf.projectName & "_" & "linkerArgs.txt"
   let args = cmd.substr(i)
   # GCC's response files don't support backslashes. Junk.
-  if conf.cCompiler == ccGcc:
+  if conf.cCompiler == ccGcc or conf.cCompiler == ccCLang:
     writeFile(linkerArgs, args.replace('\\', '/'))
   else:
     writeFile(linkerArgs, args)
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index d81410891..65df29913 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -800,11 +800,13 @@ proc semCase(c: PContext, n: PNode; flags: TExprFlags): PNode =
       typ = commonType(typ, x.sons[1])
       closeScope(c)
     of nkElse:
-      chckCovered = false
       checkSonsLen(x, 1, c.config)
       x.sons[0] = semExprBranchScope(c, x.sons[0])
       typ = commonType(typ, x.sons[0])
       hasElse = true
+      if chckCovered and covered == toCover(c, n.sons[0].typ):
+        localError(c.config, x.info, "invalid else, all cases are already covered")
+      chckCovered = false
     else:
       illFormedAst(x, c.config)
   if chckCovered:
diff --git a/lib/deprecated/pure/sockets.nim b/lib/deprecated/pure/sockets.nim
index f78df0b2b..cc1b6039b 100644
--- a/lib/deprecated/pure/sockets.nim
+++ b/lib/deprecated/pure/sockets.nim
@@ -219,7 +219,6 @@ when defined(Posix):
     of AF_UNIX:        result = posix.AF_UNIX
     of AF_INET:        result = posix.AF_INET
     of AF_INET6:       result = posix.AF_INET6
-    else: discard
 
   proc toInt(typ: SockType): cint =
     case typ
@@ -227,7 +226,6 @@ when defined(Posix):
     of SOCK_DGRAM:     result = posix.SOCK_DGRAM
     of SOCK_SEQPACKET: result = posix.SOCK_SEQPACKET
     of SOCK_RAW:       result = posix.SOCK_RAW
-    else: discard
 
   proc toInt(p: Protocol): cint =
     case p
@@ -237,7 +235,6 @@ when defined(Posix):
     of IPPROTO_IPV6:   result = posix.IPPROTO_IPV6
     of IPPROTO_RAW:    result = posix.IPPROTO_RAW
     of IPPROTO_ICMP:   result = posix.IPPROTO_ICMP
-    else: discard
 
 else:
   proc toInt(domain: Domain): cint =
@@ -853,7 +850,6 @@ proc connect*(socket: Socket, address: string, port = Port(0),
       of AF_UNIX: s.sin_family = posix.AF_UNIX
       of AF_INET: s.sin_family = posix.AF_INET
       of AF_INET6: s.sin_family = posix.AF_INET6
-      else: nil
     if connect(socket.fd, cast[ptr TSockAddr](addr(s)), sizeof(s).cint) < 0'i32:
       OSError()
 
diff --git a/lib/pure/unittest.nim b/lib/pure/unittest.nim
index 837072be2..135a24e9a 100644
--- a/lib/pure/unittest.nim
+++ b/lib/pure/unittest.nim
@@ -239,7 +239,6 @@ method testEnded*(formatter: ConsoleOutputFormatter, testResult: TestResult) =
                     of OK: fgGreen
                     of FAILED: fgRed
                     of SKIPPED: fgYellow
-                    else: fgWhite
         styledEcho styleBright, color, prefix, "[", $testResult.status, "] ", resetStyle, testResult.testName
       else:
         rawPrint()
diff --git a/tools/vccexe/vccexe.nim b/tools/vccexe/vccexe.nim
index 2dcff8ce4..e7c3a4d75 100644
--- a/tools/vccexe/vccexe.nim
+++ b/tools/vccexe/vccexe.nim
@@ -2,12 +2,12 @@ import strutils, strtabs, os, osproc, vcvarsall, vccenv
 
 type
   VccVersion* = enum ## VCC compiler backend versions
-    vccUndefined = (0, ""), ## VCC version undefined, resolves to the latest recognizable VCC version
-    vcc90  =  vs90, ## Visual Studio 2008 (Version 9.0)
-    vcc100 = vs100, ## Visual Studio 2010 (Version 10.0)
-    vcc110 = vs110, ## Visual Studio 2012 (Version 11.0)
-    vcc120 = vs120, ## Visual Studio 2013 (Version 12.0)
-    vcc140 = vs140  ## Visual Studio 2015 (Version 14.0)
+    vccUndefined = 0,   ## VCC version undefined, resolves to the latest recognizable VCC version
+    vcc90  = ord(vs90)  ## Visual Studio 2008 (Version 9.0)
+    vcc100 = ord(vs100) ## Visual Studio 2010 (Version 10.0)
+    vcc110 = ord(vs110) ## Visual Studio 2012 (Version 11.0)
+    vcc120 = ord(vs120) ## Visual Studio 2013 (Version 12.0)
+    vcc140 = ord(vs140) ## Visual Studio 2015 (Version 14.0)
 
 proc discoverVccVcVarsAllPath*(version: VccVersion = vccUndefined): string =
   ## Returns the path to the vcvarsall utility of the specified VCC compiler backend.
@@ -101,12 +101,12 @@ command was specified
 when isMainModule:
   var vccversionArg: seq[string] = @[]
   var printPathArg: bool = false
-  var vcvarsallArg: string = nil
-  var commandArg: string = nil
+  var vcvarsallArg: string
+  var commandArg: string
   var noCommandArg: bool = false
   var platformArg: VccArch
   var sdkTypeArg: VccPlatformType
-  var sdkVersionArg: string = nil
+  var sdkVersionArg: string
   var verboseArg: bool = false
 
   var clArgs: seq[TaintedString] = @[]
diff --git a/tools/vccexe/vcvarsall.nim b/tools/vccexe/vcvarsall.nim
index e7a55069c..defcf687f 100644
--- a/tools/vccexe/vcvarsall.nim
+++ b/tools/vccexe/vcvarsall.nim
@@ -34,7 +34,7 @@ type
     vccplatUWP = "uwp", ## Universal Windows Platform (UWP) Application
     vccplatOneCore = "onecore" # Undocumented platform type in the Windows SDK, probably XBox One SDK platform type.
 
-proc vccVarsAll*(path: string, arch: VccArch = vccarchUnspecified, platform_type: VccPlatformType = vccplatEmpty, sdk_version: string = nil, verbose: bool = false): StringTableRef =
+proc vccVarsAll*(path: string, arch: VccArch = vccarchUnspecified, platform_type: VccPlatformType = vccplatEmpty, sdk_version: string = "", verbose: bool = false): StringTableRef =
   ## Returns a string table containing the proper process environment to successfully execute VCC compile commands for the specified SDK version, CPU architecture and platform type.
   ##
   ## path
@@ -50,7 +50,7 @@ proc vccVarsAll*(path: string, arch: VccArch = vccarchUnspecified, platform_type
 
   var vccvarsallpath = path
   # Assume that default executable is in current directory or in PATH
-  if path == nil or path.len < 1:
+  if path == "":
     vccvarsallpath = vcvarsallDefaultPath
   
   var args: seq[string] = @[]