LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 9182 - spurious warning on overloaded-virtual
Summary: spurious warning on overloaded-virtual
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: C++ (show other bugs)
Version: trunk
Hardware: PC Linux
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-09 17:00 PST by Nick Lewycky
Modified: 2011-02-10 12:14 PST (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Lewycky 2011-02-09 17:00:37 PST
This code warns that the derived class hides a virtual function -- except that it doesn't:

  struct Base {
    virtual void foo(int);
  };
  
  void Base::foo(int) { }
  
  struct Derived : public Base {
    virtual void foo(int);   
    void foo(int, int);   
  };

note that if you move the out-of-line Base::foo def'n after struct Derived, then it doesn't warn any more. Here's the clang output:

  $ clang++ -c x.cc -Woverloaded-virtual 
  x.cc:9:8: warning: 'Derived::foo' hides overloaded virtual function
        [-Woverloaded-virtual]
    void foo(int, int);
         ^
  x.cc:5:12: note: hidden overloaded virtual function 'Base::foo' declared here
  void Base::foo(int) { }
             ^
  1 warning generated.
Comment 1 Argyrios Kyrtzidis 2011-02-09 17:07:59 PST
Cloned to <rdar://problem/8979966>.
Comment 2 Argyrios Kyrtzidis 2011-02-10 12:14:37 PST
Fixed at r125296. Thanks for the report!