summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX/class.derived
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-08-06 03:25:17 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-08-06 03:25:17 +0000
commit18f07db183f563bd645f69adf9315f9b57accc62 (patch)
treeefb6c6dda0d91581dbcfc9bef8450d982d162e34 /clang/test/CXX/class.derived
parentf716bb859bbf05e3921ec3297013c52936adf662 (diff)
downloadbcm5719-llvm-18f07db183f563bd645f69adf9315f9b57accc62.tar.gz
bcm5719-llvm-18f07db183f563bd645f69adf9315f9b57accc62.zip
PR13499: Don't try to check whether 'override' has been validly applied until
we know whether the function is virtual. But check it as soon as we do know; in some cases we don't need to wait for an instantiation. llvm-svn: 161316
Diffstat (limited to 'clang/test/CXX/class.derived')
-rw-r--r--clang/test/CXX/class.derived/class.virtual/p3-0x.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/clang/test/CXX/class.derived/class.virtual/p3-0x.cpp b/clang/test/CXX/class.derived/class.virtual/p3-0x.cpp
index c4a401bb27c..16f98280ed8 100644
--- a/clang/test/CXX/class.derived/class.virtual/p3-0x.cpp
+++ b/clang/test/CXX/class.derived/class.virtual/p3-0x.cpp
@@ -20,9 +20,15 @@ struct A {
template<typename T>
struct B : A {
+ // FIXME: Diagnose this.
virtual void f(T) override;
};
+template<typename T>
+struct C : A {
+ virtual void f(int) override; // expected-error {{does not override}}
+};
+
}
namespace Test3 {
@@ -51,3 +57,46 @@ struct D : B {
};
}
+
+namespace PR13499 {
+ struct X {
+ virtual void f();
+ virtual void h();
+ };
+ template<typename T> struct A : X {
+ void f() override;
+ void h() final;
+ };
+ template<typename T> struct B : X {
+ void g() override; // expected-error {{only virtual member functions can be marked 'override'}}
+ void i() final; // expected-error {{only virtual member functions can be marked 'final'}}
+ };
+ B<int> b; // no-note
+ template<typename T> struct C : T {
+ void g() override;
+ void i() final;
+ };
+ template<typename T> struct D : X {
+ virtual void g() override; // expected-error {{does not override}}
+ virtual void i() final;
+ };
+ template<typename...T> struct E : X {
+ void f(T...) override;
+ void g(T...) override; // expected-error {{only virtual member functions can be marked 'override'}}
+ void h(T...) final;
+ void i(T...) final; // expected-error {{only virtual member functions can be marked 'final'}}
+ };
+ // FIXME: Diagnose these in the template definition, not in the instantiation.
+ E<> e; // expected-note {{in instantiation of}}
+
+ template<typename T> struct Y : T {
+ void f() override;
+ void h() final;
+ };
+ template<typename T> struct Z : T {
+ void g() override; // expected-error {{only virtual member functions can be marked 'override'}}
+ void i() final; // expected-error {{only virtual member functions can be marked 'final'}}
+ };
+ Y<X> y;
+ Z<X> z; // expected-note {{in instantiation of}}
+}
OpenPOWER on IntegriCloud