New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Many "redeclared" warnings #2013

Closed
jdemeyer opened this Issue Nov 19, 2017 · 9 comments

Comments

Projects
None yet
5 participants
@jdemeyer
Contributor

jdemeyer commented Nov 19, 2017

Cython-0.28b1 is giving lots and lots of '...' redeclared warnings. Even when compiling Cython itself, I am getting

    warning: Cython/Compiler/Code.py:380:4: 'format_code' redeclared
    warning: Cython/Compiler/Code.py:442:4: 'none_or_sub' redeclared
    warning: Cython/Compiler/Code.py:693:4: 'new_label' redeclared
    warning: Cython/Compiler/Code.py:712:4: 'get_loop_labels' redeclared
    warning: Cython/Compiler/Code.py:717:4: 'set_loop_labels' redeclared
    warning: Cython/Compiler/Code.py:728:4: 'get_all_labels' redeclared
    warning: Cython/Compiler/Code.py:735:4: 'set_all_labels' redeclared
    warning: Cython/Compiler/Code.py:826:4: 'temps_in_use' redeclared
    warning: Cython/Compiler/Code.py:863:4: 'start_collecting_temps' redeclared
    warning: Cython/Compiler/Code.py:869:4: 'stop_collecting_temps' redeclared
    warning: Cython/Compiler/Code.py:930:4: 'get_py_string_const' redeclared
    warning: Cython/Compiler/FlowControl.py:74:4: 'empty' redeclared
    warning: Cython/Compiler/FlowControl.py:77:4: 'detach' redeclared
    warning: Cython/Compiler/FlowControl.py:86:4: 'add_child' redeclared
    warning: Cython/Compiler/FlowControl.py:94:4: 'empty' redeclared
    warning: Cython/Compiler/FlowControl.py:126:4: 'newblock' redeclared
    warning: Cython/Compiler/FlowControl.py:137:4: 'nextblock' redeclared
    warning: Cython/Compiler/FlowControl.py:151:4: 'is_tracked' redeclared
    warning: Cython/Compiler/FlowControl.py:158:4: 'is_statically_assigned' redeclared
    warning: Cython/Compiler/FlowControl.py:168:4: 'mark_position' redeclared
    warning: Cython/Compiler/FlowControl.py:173:4: 'mark_assignment' redeclared
    warning: Cython/Compiler/FlowControl.py:180:4: 'mark_argument' redeclared
    warning: Cython/Compiler/FlowControl.py:187:4: 'mark_deletion' redeclared
    warning: Cython/Compiler/FlowControl.py:194:4: 'mark_reference' redeclared
    warning: Cython/Compiler/FlowControl.py:204:4: 'normalize' redeclared
    warning: Cython/Compiler/FlowControl.py:227:4: 'initialize' redeclared
    warning: Cython/Compiler/FlowControl.py:263:4: 'map_one' redeclared
    warning: Cython/Compiler/FlowControl.py:763:4: 'mark_assignment' redeclared
    warning: Cython/Compiler/FlowControl.py:796:4: 'mark_position' redeclared
    warning: Cython/Compiler/Parsing.py:646:0: 'make_slice_node' redeclared
    warning: Cython/Compiler/Parsing.py:2422:0: 'p_c_base_type' redeclared
    warning: Cython/Compiler/Parsing.py:2751:0: 'p_c_declarator' redeclared
    warning: Cython/Compiler/Parsing.py:2943:0: 'p_c_arg_list' redeclared
    warning: Cython/Compiler/Parsing.py:3586:0: 'p_code' redeclared
    warning: Cython/Compiler/Parsing.py:3610:0: 'p_module' redeclared
    warning: Cython/Compiler/Parsing.py:3733:0: 'print_parse_tree' redeclared
    warning: Cython/Compiler/Pythran.py:21:0: 'is_pythran_supported_dtype' redeclared
    warning: Cython/Compiler/Pythran.py:121:0: 'to_pythran' redeclared
    warning: Cython/Compiler/Pythran.py:150:0: 'is_pythran_supported_type' redeclared
    warning: Cython/Compiler/Pythran.py:163:0: 'is_pythran_expr' redeclared
    warning: Cython/Compiler/Scanning.py:93:4: 'lookup' redeclared
    warning: Cython/Compiler/Scanning.py:400:4: 'indentation_action' redeclared
    warning: Cython/Compiler/Visitor.py:169:4: 'visit' redeclared
    warning: Cython/Compiler/Visitor.py:197:4: 'visitchildren' redeclared
    warning: Cython/Compiler/Visitor.py:247:4: 'visitchildren' redeclared
    warning: Cython/Compiler/Visitor.py:264:4: 'recurse_to_children' redeclared
    warning: Cython/Plex/Actions.py:13:4: 'same_as' redeclared
    warning: Cython/Plex/Actions.py:29:4: 'same_as' redeclared
    warning: Cython/Plex/Actions.py:50:4: 'same_as' redeclared
    warning: Cython/Plex/Actions.py:70:4: 'same_as' redeclared
    warning: Cython/Plex/Scanners.py:112:4: 'read' redeclared
    warning: Cython/StringIOTree.py:55:4: 'getvalue' redeclared
    warning: Cython/StringIOTree.py:60:4: 'copyto' redeclared
    warning: Cython/StringIOTree.py:69:4: 'commit' redeclared
    warning: Cython/StringIOTree.py:104:4: 'allmarkers' redeclared

This is a recent regression related to #1874

@fried

This comment has been minimized.

Show comment
Hide comment
@fried

fried Nov 22, 2017

I am seeing these also when working with C++ and std::move

    cdef extern from "<utility>" namespace "std" nogil:
        cdef shared_ptr[vector[int32_t]] move(unique_ptr[vector[int32_t]])
        cdef unique_ptr[vector[int32_t]] move_unique "std::move"(unique_ptr[vector[int32_t]])
        cdef shared_ptr[vector[int16_t]] move(unique_ptr[vector[int16_t]])
        cdef unique_ptr[vector[int16_t]] move_unique "std::move"(unique_ptr[vector[int16_t]])

Seems we shouldn't be warning on standard overload definitions in an extern

fried commented Nov 22, 2017

I am seeing these also when working with C++ and std::move

    cdef extern from "<utility>" namespace "std" nogil:
        cdef shared_ptr[vector[int32_t]] move(unique_ptr[vector[int32_t]])
        cdef unique_ptr[vector[int32_t]] move_unique "std::move"(unique_ptr[vector[int32_t]])
        cdef shared_ptr[vector[int16_t]] move(unique_ptr[vector[int16_t]])
        cdef unique_ptr[vector[int16_t]] move_unique "std::move"(unique_ptr[vector[int16_t]])

Seems we shouldn't be warning on standard overload definitions in an extern

@fried

This comment has been minimized.

Show comment
Hide comment
@fried

fried Nov 22, 2017

If it helps this warning is produced from line 452 of Symtab.py in the declare method

fried commented Nov 22, 2017

If it helps this warning is produced from line 452 of Symtab.py in the declare method

@scoder

This comment has been minimized.

Show comment
Hide comment
@scoder

scoder Nov 22, 2017

Contributor

These are two separate issues. The original problem is that cpdef methods (and functions?) lead to incorrect warnings.

Contributor

scoder commented Nov 22, 2017

These are two separate issues. The original problem is that cpdef methods (and functions?) lead to incorrect warnings.

@jamadden

This comment has been minimized.

Show comment
Hide comment
@jamadden

jamadden Mar 4, 2018

Contributor

I see this compiling gevent with cython 0.28b1. It doesn't seem to cause any problems.

A simple reproducer:

# foo.py
class Semaphore(object):
    def locked(self):
        return True
# foo.pxd
cdef class Semaphore:
    cpdef bint locked(self)
$ cython foo.py
warning: foo.py:3:1: 'locked' redeclared
Contributor

jamadden commented Mar 4, 2018

I see this compiling gevent with cython 0.28b1. It doesn't seem to cause any problems.

A simple reproducer:

# foo.py
class Semaphore(object):
    def locked(self):
        return True
# foo.pxd
cdef class Semaphore:
    cpdef bint locked(self)
$ cython foo.py
warning: foo.py:3:1: 'locked' redeclared
@lesteve

This comment has been minimized.

Show comment
Hide comment
@lesteve

lesteve Mar 8, 2018

Another (possibly simpler) way to reproduce is to use typed memoryview:

# memoryview.pyx
def my_func(double[:] x):
    pass
$ cython memoryview.pyx
warning: TestClass:20:10: 'cpdef_method' redeclared 
warning: TestClass:31:10: 'cpdef_cname_method' redeclared

lesteve commented Mar 8, 2018

Another (possibly simpler) way to reproduce is to use typed memoryview:

# memoryview.pyx
def my_func(double[:] x):
    pass
$ cython memoryview.pyx
warning: TestClass:20:10: 'cpdef_method' redeclared 
warning: TestClass:31:10: 'cpdef_cname_method' redeclared
@scoder

This comment has been minimized.

Show comment
Hide comment
@scoder

scoder Mar 9, 2018

Contributor

CC-ing @robertwb

Contributor

scoder commented Mar 9, 2018

CC-ing @robertwb

@jdemeyer

This comment has been minimized.

Show comment
Hide comment
@jdemeyer

jdemeyer Mar 10, 2018

Contributor

Cython master still gives warnings with overloaded C++ functions as mentioned in #2013 (comment)

Apart from that, the issue looks solved.

Contributor

jdemeyer commented Mar 10, 2018

Cython master still gives warnings with overloaded C++ functions as mentioned in #2013 (comment)

Apart from that, the issue looks solved.

scoder added a commit that referenced this issue Mar 11, 2018

Do not issue "redefined" warnings on C++ function overrides with diff…
…erent signatures (previously only applied to methods).

Closes #2013.
@scoder

This comment has been minimized.

Show comment
Hide comment
@scoder

scoder Mar 11, 2018

Contributor

I think I found a way to tighten the detection here, but in order to prevent it from breaking again in the future, I'd be happy to see a test case that does not require C++11.

Contributor

scoder commented Mar 11, 2018

I think I found a way to tighten the detection here, but in order to prevent it from breaking again in the future, I'd be happy to see a test case that does not require C++11.

@scoder scoder added this to the 0.28 milestone Mar 11, 2018

@jdemeyer

This comment has been minimized.

Show comment
Hide comment
@jdemeyer

jdemeyer Mar 11, 2018

Contributor

The simplest example is

# cython: language=c++

cdef extern from *:
    int foo()
    int foo(int)
Contributor

jdemeyer commented Mar 11, 2018

The simplest example is

# cython: language=c++

cdef extern from *:
    int foo()
    int foo(int)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment