Warn when trying to call a pure virtual member function in a class from the class constructor/destructor. Fixes PR7966.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130982 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaCXX/warn-pure-virtual-call-from-ctor-dtor.cpp b/test/SemaCXX/warn-pure-virtual-call-from-ctor-dtor.cpp
new file mode 100644
index 0000000..698eccd
--- /dev/null
+++ b/test/SemaCXX/warn-pure-virtual-call-from-ctor-dtor.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+struct A {
+  A() { f(); } // expected-warning {{call to pure virtual member function 'f'; overrides of 'f' in subclasses are not available in the constructor of 'A'}}
+  ~A() { f(); } // expected-warning {{call to pure virtual member function 'f'; overrides of 'f' in subclasses are not available in the destructor of 'A'}}
+
+  virtual void f() = 0; // expected-note 2 {{'f' declared here}}
+};