Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#2388 closed defect (fixed)

[PATCH] Clang warning [-Woverloaded-virtual] in ShaderProgramFFP.cpp

Reported by: Echelon9 Owned by: ben
Priority: Should Have Milestone: Alpha 16
Component: Core engine Keywords: patch
Cc: Patch:

Description

Modern Clang compilers warn on two cases of derived classes hiding overloaded virtual functions in ShaderProgramFFP.cpp

The attached patch silences both these warnings by indicating clearly that both forms of Uniform() are to be made available, as the context requires.

Version of Clang used is that which ships with Xcode 5, but also reproduced with tip of trunk Clang/LLVM.

$ clang --version
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
$ svn up
$ cd build/workspaces
$ ./clean-workspaces.sh
$ ./update-workspaces.sh
$ cd gcc
$ make clean
$ make -j3
...
../../../source/graphics/ShaderProgramFFP.cpp:474:15: warning: 'CShaderProgramFFP_GuiAdd::Uniform' hides overloaded
      virtual function [-Woverloaded-virtual]
        virtual void Uniform(Binding id, float v0, float v1, float v2, float v3)
                     ^
../../../source/graphics/ShaderProgramFFP.cpp:412:15: note: hidden overloaded virtual function
      'CShaderProgramFFP_Gui_Base::Uniform' declared here
        virtual void Uniform(Binding id, const CMatrix3D& v)
                     ^
../../../source/graphics/ShaderProgramFFP.cpp:645:15: warning: 'CShaderProgramFFP_GuiSolid::Uniform' hides overloaded
      virtual function [-Woverloaded-virtual]
        virtual void Uniform(Binding id, float v0, float v1, float v2, float v3)
                     ^
../../../source/graphics/ShaderProgramFFP.cpp:412:15: note: hidden overloaded virtual function
      'CShaderProgramFFP_Gui_Base::Uniform' declared here
        virtual void Uniform(Binding id, const CMatrix3D& v)
                     ^

Attachments (1)

2388-silence-overloaded-warnings.patch (647 bytes ) - added by Echelon9 10 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 by historic_bruno, 10 years ago

That warning has existed for quite some time, so I can only assume it's harmless, but when looking at possible solutions, I recall seeing some documentation that the using syntax may not be supported by all compilers, and also that maybe there is a better way of solving the problem. So that's at least a consideration, FWIW I don't believe that using syntax occurs anywhere in the code base yet.

comment:2 by Echelon9, 10 years ago

Would you be able to recall that documentation?

I spent some time looking through the usual CPPReference.com and Stackoverflow posts on the using-declaration while implementing this patch.

No mention was made of compiler non-support nor language deprecation. What is important to distinguish is the use of using to change access permissions (i.e. from private to public in a derived class). I can see why that has been deprecated. However, that is not the use case proposed here.

comment:3 by historic_bruno, 10 years ago

http://www.parashift.com/c++-faq-lite/hiding-rule.html At the bottom it mentions "If the using syntax isn't supported by your compiler...", though it doesn't mention any specifically, maybe it's only ancient or weird compilers we don't care about.

comment:4 by Echelon9, 10 years ago

I took some time looking at the language support for this in various modern compilers (Clang, GCC and Microsoft's msvc).

Whilst the "using" keyword is rather un-Googleable, it appears to be well supported across each of those modern compilers. Essentially it is met for those which support ISO C++ 1998 standard (including the defects addressed in the ISO C++ 2003 standard).

C++11 support is NOT required for this patch.

Last edited 10 years ago by Echelon9 (previous) (diff)

comment:5 by historic_bruno, 10 years ago

We'll probably be safe applying the patch, last time we did build warning fixes it didn't take long before compiler incompatibilities were discovered, and this is a small change to revert.

comment:6 by ben, 10 years ago

Owner: set to ben
Resolution: fixed
Status: newclosed

In 14674:

Fixes clang "hidden overloaded virtual function" warning, patch by Echelon9, fixes #2388

comment:7 by historic_bruno, 10 years ago

Keywords: review removed
Note: See TracTickets for help on using tickets.