diff options
| author | Stefan Behnel <stefan_ml@behnel.de> | 2018-03-11 09:25:15 +0100 |
|---|---|---|
| committer | Stefan Behnel <stefan_ml@behnel.de> | 2018-03-11 09:25:15 +0100 |
| commit | 139143ee181fb6d4ef151defca10f5882ebce977 (patch) | |
| tree | b3285b15f81b93d43d0cd73c130fee35aa75e991 /Cython/Compiler/Symtab.py | |
| parent | 084af98bf092404b83aaeb6d48ada5f6f9dc28a0 (diff) | |
| download | cython-139143ee181fb6d4ef151defca10f5882ebce977.tar.gz | |
Do not issue "redefined" warnings on C++ function overrides with different signatures (previously only applied to methods).
Closes #2013.
Diffstat (limited to 'Cython/Compiler/Symtab.py')
| -rw-r--r-- | Cython/Compiler/Symtab.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/Cython/Compiler/Symtab.py b/Cython/Compiler/Symtab.py index 3d4954764..9e49acd0d 100644 --- a/Cython/Compiler/Symtab.py +++ b/Cython/Compiler/Symtab.py @@ -446,9 +446,22 @@ class Scope(object): warning(pos, "'%s' is a reserved name in C." % cname, -1) entries = self.entries if name and name in entries and not shadow: - old_type = entries[name].type - if self.is_cpp_class_scope and type.is_cfunction and old_type.is_cfunction and type != old_type: - # C++ method overrides are ok + old_entry = entries[name] + + # Reject redeclared C++ functions only if they have the same type signature. + cpp_override_allowed = False + if type.is_cfunction and old_entry.type.is_cfunction and self.is_cpp(): + for alt_entry in old_entry.all_alternatives(): + if type == alt_entry.type: + if name == '<init>' and not type.args: + # Cython pre-declares the no-args constructor - allow later user definitions. + cpp_override_allowed = True + break + else: + cpp_override_allowed = True + + if cpp_override_allowed: + # C++ function/method overrides with different signatures are ok. pass elif self.is_cpp_class_scope and entries[name].is_inherited: # Likewise ignore inherited classes. |
