Permalink
Browse files

Fix T767 - template specialization leaks into builtin types

  • Loading branch information...
1 parent 058a5e8 commit c711c46a03ebbd8c83261c7ea9694920869fe5ba @robertwb robertwb committed Mar 29, 2012
Showing with 12 additions and 5 deletions.
  1. +8 −5 Cython/Compiler/Symtab.py
  2. +4 −0 tests/compile/cpp_templates.pyx
View
@@ -412,7 +412,8 @@ def declare_const(self, name, type, value, pos, cname = None, visibility = 'priv
return entry
def declare_type(self, name, type, pos,
- cname = None, visibility = 'private', api = 0, defining = 1, shadow = 0):
+ cname = None, visibility = 'private', api = 0, defining = 1,
+ shadow = 0, template = 0):
# Add an entry for a type definition.
if not cname:
cname = name
@@ -422,7 +423,8 @@ def declare_type(self, name, type, pos,
if defining:
self.type_entries.append(entry)
- type.entry = entry
+ if not template:
+ type.entry = entry
# here we would set as_variable to an object representing this type
return entry
@@ -2052,9 +2054,10 @@ def specialize(self, values):
for entry in self.entries.values():
if entry.is_type:
scope.declare_type(entry.name,
- entry.type.specialize(values),
- entry.pos,
- entry.cname)
+ entry.type.specialize(values),
+ entry.pos,
+ entry.cname,
+ template=1)
else:
# scope.declare_var(entry.name,
# entry.type.specialize(values),
@@ -1,5 +1,6 @@
# tag: cpp
# mode: compile
+# ticket: 767
cdef extern from "templates.h":
cdef cppclass TemplateTest1[T]:
@@ -35,3 +36,6 @@ del b, e
ctypedef TemplateTest1[int] TemplateTest1_int
cdef TemplateTest1_int aa
+# Verify that T767 is fixed.
+cdef public int func(int arg):
+ return arg

0 comments on commit c711c46

Please sign in to comment.