From c711c46a03ebbd8c83261c7ea9694920869fe5ba Mon Sep 17 00:00:00 2001 From: Robert Bradshaw <robertwb@gmail.com> Date: Thu, 29 Mar 2012 01:55:16 -0700 Subject: [PATCH] Fix T767 - template specialization leaks into builtin types --- Cython/Compiler/Symtab.py | 13 ++++++++----- tests/compile/cpp_templates.pyx | 4 ++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Cython/Compiler/Symtab.py b/Cython/Compiler/Symtab.py index bf77edd70..7a14e1c68 100644 --- a/Cython/Compiler/Symtab.py +++ b/Cython/Compiler/Symtab.py @@ -412,7 +412,8 @@ class Scope(object): 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 @@ class Scope(object): 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 @@ class CppClassScope(Scope): 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), diff --git a/tests/compile/cpp_templates.pyx b/tests/compile/cpp_templates.pyx index 139338084..4d37294ca 100644 --- a/tests/compile/cpp_templates.pyx +++ b/tests/compile/cpp_templates.pyx @@ -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 -- 2.30.9