From c71adccb3e687952aacf4244fdf4610da3e40102 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Sat, 19 Feb 2011 14:24:57 -0800 Subject: [PATCH] Make cpp redeclaration an error (vs. a compiler crash). Fixes #523. --- Cython/Compiler/Nodes.py | 2 ++ Cython/Compiler/Symtab.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 375a4621..c41c6814 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -1057,6 +1057,8 @@ class CppClassNode(CStructOrUnionDefNode): self.entry = env.declare_cpp_class( self.name, scope, self.pos, self.cname, base_class_types, visibility = self.visibility, templates = template_types) + if self.entry is None: + return self.entry.is_cpp_class = 1 if self.attributes is not None: if self.in_pxd and not env.in_cinclude: diff --git a/Cython/Compiler/Symtab.py b/Cython/Compiler/Symtab.py index 74a80eb8..dcd21613 100644 --- a/Cython/Compiler/Symtab.py +++ b/Cython/Compiler/Symtab.py @@ -449,7 +449,8 @@ class Scope(object): visibility = visibility, defining = scope is not None) else: if not (entry.is_type and entry.type.is_cpp_class): - warning(pos, "'%s' redeclared " % name, 0) + error(pos, "'%s' redeclared " % name) + return None elif scope and entry.type.scope: warning(pos, "'%s' already defined (ignoring second definition)" % name, 0) else: -- 2.26.2