diff options
| author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-02-03 18:01:15 +0000 |
|---|---|---|
| committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-02-03 18:01:15 +0000 |
| commit | 7272d9cf36cdcbc13f35ce8f37f92263ee91fe98 (patch) | |
| tree | c16d4e5089323458ec61a7bfff5b4c24837e0de2 /clang/test/SemaCXX/warn-overloaded-virtual.cpp | |
| parent | 25c98707da7ccb1c976f6eab03d1cfd024258114 (diff) | |
| download | bcm5719-llvm-7272d9cf36cdcbc13f35ce8f37f92263ee91fe98.tar.gz bcm5719-llvm-7272d9cf36cdcbc13f35ce8f37f92263ee91fe98.zip | |
Implement -Woverloaded-virtual.
The difference with gcc is that it warns if you overload virtual methods only if
the method doesn't also override any method. This is to cut down on the number of warnings
and make it more useful like reported here: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20423.
If we want to warn that not all overloads are overriden we can have an additional
warning like -Wpartial-override.
-Woverloaded-virtual, unlike gcc, is added to -Wmost. Addresses rdar://8757630.
llvm-svn: 124805
Diffstat (limited to 'clang/test/SemaCXX/warn-overloaded-virtual.cpp')
| -rw-r--r-- | clang/test/SemaCXX/warn-overloaded-virtual.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/warn-overloaded-virtual.cpp b/clang/test/SemaCXX/warn-overloaded-virtual.cpp new file mode 100644 index 00000000000..7636722e181 --- /dev/null +++ b/clang/test/SemaCXX/warn-overloaded-virtual.cpp @@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -fsyntax-only -Woverloaded-virtual -verify %s + +struct B1 { + virtual void foo(int); // expected-note {{declared here}} + virtual void foo(); // expected-note {{declared here}} +}; + +struct S1 : public B1 { + void foo(float); // expected-warning {{hides overloaded virtual functions}} +}; + +struct S2 : public B1 { + void foo(); // expected-note {{declared here}} +}; + +struct B2 { + virtual void foo(void*); // expected-note {{declared here}} +}; + +struct MS1 : public S2, public B2 { + virtual void foo(int); // expected-warning {{hides overloaded virtual functions}} +}; + +struct B3 { + virtual void foo(int); + virtual void foo(); +}; + +struct S3 : public B3 { + using B3::foo; + void foo(float); +}; + +struct B4 { + virtual void foo(); +}; + +struct S4 : public B4 { + void foo(float); + void foo(); +}; |

