Raise error when declaring reserved names.
authorRobert Bradshaw <robertwb@math.washington.edu>
Fri, 17 Aug 2007 08:47:56 +0000 (01:47 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Fri, 17 Aug 2007 08:47:56 +0000 (01:47 -0700)
Cython/Compiler/Symtab.py

index 22122abf23c4324ffdec1742d040117b7976b3c7..9c437f19232492c19930755f52266b2574559085 100644 (file)
@@ -198,6 +198,9 @@ class Scope:
         # Create new entry, and add to dictionary if
         # name is not None. Reports a warning if already 
         # declared.
+        if not self.in_cinclude and re.match("^_[_A-Z]+$", cname):
+            # See http://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html#Reserved-Names 
+            error(pos, "'%s' is a reserved name in C." % cname)
         dict = self.entries
         if name and dict.has_key(name):
             warning(pos, "'%s' redeclared " % name, 0)