summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2018-05-27 14:00:44 +0200
committerAndreas Rumpf <rumpf_a@web.de>2018-05-27 14:00:44 +0200
commitdd8a6ef3a2aa1f0200d6ddff0f1f38532e84647b (patch)
tree1c3e3051f65dadb36190e0e20ac3c6ea96873c0c /compiler
parent98498087202203e343c782ce24e294bd0b82becf (diff)
downloadNim-dd8a6ef3a2aa1f0200d6ddff0f1f38532e84647b.tar.gz
implements --hint[globalvar]:on switch for quickly finding global variables
Diffstat (limited to 'compiler')
-rw-r--r--compiler/lineinfos.nim8
-rw-r--r--compiler/semstmts.nim2
2 files changed, 7 insertions, 3 deletions
diff --git a/compiler/lineinfos.nim b/compiler/lineinfos.nim
index 0ff6a5ccd..31fbe5197 100644
--- a/compiler/lineinfos.nim
+++ b/compiler/lineinfos.nim
@@ -44,6 +44,7 @@ type
     hintConditionAlwaysTrue, hintName, hintPattern,
     hintExecuting, hintLinking, hintDependency,
     hintSource, hintPerformance, hintStackTrace, hintGCStats,
+    hintGlobalVar,
     hintUser, hintUserRaw
 
 const
@@ -113,6 +114,7 @@ const
     hintPerformance: "$1",
     hintStackTrace: "$1",
     hintGCStats: "$1",
+    hintGlobalVar: "global variable declared here",
     hintUser: "$1",
     hintUserRaw: "$1"]
 
@@ -134,7 +136,7 @@ const
     "XDeclaredButNotUsed", "ConvToBaseNotNeeded", "ConvFromXtoItselfNotNeeded",
     "ExprAlwaysX", "QuitCalled", "Processing", "CodeBegin", "CodeEnd", "Conf",
     "Path", "CondTrue", "Name", "Pattern", "Exec", "Link", "Dependency",
-    "Source", "Performance", "StackTrace", "GCStats",
+    "Source", "Performance", "StackTrace", "GCStats", "GlobalVar",
     "User", "UserRaw"]
 
 const
@@ -166,7 +168,7 @@ const
                                          hintExecuting, hintLinking,
                                          hintCodeBegin, hintCodeEnd,
                                          hintSource, hintStackTrace,
-                                         hintGCStats},
+                                         hintGlobalVar, hintGCStats},
     {low(TNoteKind)..high(TNoteKind)} - {warnShadowIdent, warnUninit,
                                          warnProveField, warnProveIndex,
                                          warnGcUnsafe,
@@ -174,7 +176,7 @@ const
                                          hintDependency,
                                          hintCodeBegin, hintCodeEnd,
                                          hintSource, hintStackTrace,
-                                         hintGCStats},
+                                         hintGlobalVar, hintGCStats},
     {low(TNoteKind)..high(TNoteKind)} - {hintStackTrace, warnUninit},
     {low(TNoteKind)..high(TNoteKind)}]
 
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index eb3376ff5..aa4d85789 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -569,6 +569,8 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
         b.sons[j] = newSymNode(v)
       checkNilable(c, v)
       if sfCompileTime in v.flags: hasCompileTime = true
+      if v.flags * {sfGlobal, sfThread} == {sfGlobal}:
+        message(c.config, v.info, hintGlobalVar)
   if hasCompileTime:
     vm.setupCompileTimeVar(c.module, c.cache, c.graph, result)