Change so that warning for multiple declarations are printed by default.
authorWilliam Stein <wstein@gmail.com>
Wed, 25 Oct 2006 06:21:53 +0000 (01:21 -0500)
committerWilliam Stein <wstein@gmail.com>
Wed, 25 Oct 2006 06:21:53 +0000 (01:21 -0500)
Cython/Compiler/Errors.py
Cython/Compiler/Symtab.py

index 070707d152635379d9b9404e8852252d081c4ec2..f56526880db7fc57e51ac0336f16652537733097 100644 (file)
@@ -88,7 +88,11 @@ def error(position, message):
     num_errors = num_errors + 1
     return err
 
-def warning(position, message):
+LEVEL=1 # warn about all errors level 1 or higher
+
+def warning(position, message, level):
+    if level < LEVEL:
+        return
     warn = CompileWarning(position, message)
     line = "warning: %s\n" % warn
     if listing_file:
index b84a91ae63b8377e5db0762bcecd9b8193605af5..7f5fc3ee7c8c3419919ddb65980940142058e0b8 100644 (file)
@@ -195,7 +195,7 @@ class Scope:
         # declared.
         dict = self.entries
         if name and dict.has_key(name):
-            warning(pos, "'%s' redeclared (ignoring second declaration)" % name)
+            warning(pos, "'%s' redeclared (ignoring second declaration)" % name, 0)
         entry = Entry(name, cname, type, pos = pos)
         entry.in_cinclude = self.in_cinclude
         if name:
@@ -243,9 +243,9 @@ class Scope:
             self.sue_entries.append(entry)
         else:
             if not (entry.is_type and entry.type.is_struct_or_union):
-                warning(pos, "'%s' redeclared  (ignoring second declaration)" % name)
+                warning(pos, "'%s' redeclared  (ignoring second declaration)" % name, 0)
             elif scope and entry.type.scope:
-                warning(pos, "'%s' already defined  (ignoring second definition)" % name)
+                warning(pos, "'%s' already defined  (ignoring second definition)" % name, 0)
             else:
                 self.check_previous_typedef_flag(entry, typedef_flag, pos)
                 if scope:
@@ -556,7 +556,7 @@ class ModuleScope(Scope):
         if entry not in self.entries:
             self.entries[name] = entry
         else:
-            warning(pos, "'%s' redeclared  (ignoring second declaration)" % name)
+            warning(pos, "'%s' redeclared  (ignoring second declaration)" % name, 0)
     
     def declare_module(self, name, scope, pos):
         # Declare a cimported module. This is represented as a
@@ -574,7 +574,7 @@ class ModuleScope(Scope):
                 # name to appear again, and indeed the generated
                 # code compiles fine. 
                 return entry
-                warning(pos, "'%s' redeclared  (ignoring second declaration)" % name)
+                warning(pos, "'%s' redeclared  (ignoring second declaration)" % name, 0)
                 return None
         else:
             entry = self.declare_var(name, py_object_type, pos)
@@ -822,7 +822,7 @@ class LocalScope(Scope):
     def declare_global(self, name, pos):
         # Pull entry from global scope into local scope.
         if self.lookup_here(name):
-            warning(pos, "'%s' redeclared  (ignoring second declaration)")
+            warning(pos, "'%s' redeclared  (ignoring second declaration)", 0)
         else:
             entry = self.global_scope().lookup_target(name)
             self.entries[name] = entry
@@ -996,7 +996,7 @@ class CClassScope(ClassScope):
         entry = self.lookup_here(name)
         if entry:
             if not entry.is_cfunction:
-                warning(pos, "'%s' redeclared  (ignoring second declaration)" % name)
+                warning(pos, "'%s' redeclared  (ignoring second declaration)" % name, 0)
             else:
                 if defining and entry.func_cname:
                     error(pos, "'%s' already defined" % name)