summaryrefslogtreecommitdiff
path: root/test/FixIt
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2014-10-02 23:13:51 +0000
committerFariborz Jahanian <fjahanian@apple.com>2014-10-02 23:13:51 +0000
commit6756af31efc2b57943f982b501a79377906de44f (patch)
treee9f627edcf978d244dbb453262d5f09dbb4543c6 /test/FixIt
parentbb17ae00530bdbfe91b62f95a2769faba44d0ca6 (diff)
downloadclang-6756af31efc2b57943f982b501a79377906de44f.tar.gz
Patch to warn if 'override' is missing
for an overriding method if class has at least one 'override' specified on one of its methods. Reviewed by Doug Gregor. rdar://18295240 (I have already checked in all llvm files with missing 'override' methods and Bob Wilson has fixed a TableGen of FastISel so no warnings are expected from build of llvm after this patch. I have already verified this). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218925 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/FixIt')
-rw-r--r--test/FixIt/cxx11-fixit-missing-override.cpp33
-rw-r--r--test/FixIt/fixit-cxx0x.cpp4
2 files changed, 35 insertions, 2 deletions
diff --git a/test/FixIt/cxx11-fixit-missing-override.cpp b/test/FixIt/cxx11-fixit-missing-override.cpp
new file mode 100644
index 0000000000..0a35491cd3
--- /dev/null
+++ b/test/FixIt/cxx11-fixit-missing-override.cpp
@@ -0,0 +1,33 @@
+// RUN: cp %s %t
+// RUN: %clang_cc1 -x c++ -std=c++11 -Winconsistent-missing-override -fixit %t
+// RUN: %clang_cc1 -x c++ -std=c++11 -Winconsistent-missing-override -Werror %t
+
+struct A
+{
+ virtual void foo();
+ virtual void bar(); // expected-note {{overridden virtual function is here}}
+ virtual void gorf() {}
+ virtual void g() = 0; // expected-note {{overridden virtual function is here}}
+};
+
+struct B : A
+{
+ void foo() override;
+ void bar(); // expected-warning {{'bar' overrides a member function but is not marked 'override'}}
+};
+
+struct C : B
+{
+ virtual void g() override = 0; // expected-warning {{'g' overrides a member function but is not marked 'override'}}
+ virtual void gorf() override {}
+ void foo() {}
+};
+
+struct D : C {
+ virtual void g()override ;
+ virtual void foo(){
+ }
+ void bar() override;
+};
+
+
diff --git a/test/FixIt/fixit-cxx0x.cpp b/test/FixIt/fixit-cxx0x.cpp
index 49a05ff8d1..7830071748 100644
--- a/test/FixIt/fixit-cxx0x.cpp
+++ b/test/FixIt/fixit-cxx0x.cpp
@@ -24,7 +24,7 @@ namespace SemiCommaTypo {
int o;
struct Base {
- virtual void f2(), f3();
+ virtual void f2(), f3(); // expected-note {{overridden virtual function is here}}
};
struct MemberDeclarator : Base {
int k : 4,
@@ -33,7 +33,7 @@ namespace SemiCommaTypo {
char c, // expected-error {{expected ';' at end of declaration}}
typedef void F(), // expected-error {{expected ';' at end of declaration}}
F f1,
- f2 final,
+ f2 final, // expected-warning {{'f2' overrides a member function but is not marked 'override'}}
f3 override, // expected-error {{expected ';' at end of declaration}}
};
}