[Mesa-dev] [PATCH 1/4] glsl: fix visit/visit_enter overloaded virtual function warnings

Rob Herring robh at kernel.org
Thu Jun 1 00:52:51 UTC 2017


On Wed, May 31, 2017 at 5:49 PM, Ian Romanick <idr at freedesktop.org> wrote:
> On 05/31/2017 06:09 AM, Emil Velikov wrote:
>> On 31 May 2017 at 01:55, Ian Romanick <idr at freedesktop.org> wrote:
>>> I don't understand these warnings, and I have even less understanding of
>>> how "using" fixes them.  For example...
>>>
>>> On 05/30/2017 01:47 PM, Rob Herring wrote:
>>>> clang gives warnings about overloaded virtual functions:
>>>>
>>>> src/compiler/glsl/linker.cpp:244:30: warning: '(anonymous namespace)::array_resize_visitor::visit' hides overloaded virtual function [-Woverloaded-virtual]
>>>>    virtual ir_visitor_status visit(ir_variable *var)
>>>>                              ^
>>>> src/compiler/glsl/linker.cpp:195:30: note: hidden overloaded virtual function '(anonymous namespace)::deref_type_updater::visit' declared here: type mismatch at 1st parameter ('ir_dereference_variable *' vs 'ir_variable *')
>>>>    virtual ir_visitor_status visit(ir_dereference_variable *ir)
>>>>                              ^
>>>
>>> This is weird and confusing.  ir_hierarchical_visitor has a virtual
>>> visit(class ir_dereference_variable *) method.  The complaint about the
>>> type seems... bizarre.
>>>
>> Since it took me a second to click here is my take on it:
>>
>> The "base" class deref_type_updater has
>>    virtual ir_visitor_status visit(ir_variable *var)
>>
>> ... while the derived one class array_resize_visitor
>>    virtual ir_visitor_status visit(ir_dereference_variable *ir)
>>
>> ... hence the type mismatch.
>
> Right... but deref_type_updater is derived from ir_hierarchical_visitor,
> and that has virtual ir_visitor_status visit(ir_dereference_variable
> *ir).  That is the function being overridden.

The problem AIUI is specific to overloaded functions. Here
deref_type_updater::visit overrides all the
ir_hierarchical_visitor::visit functions, so they are not available to
array_resize_visitor by default.

Rob


More information about the mesa-dev mailing list