Sema-check virtual declarations. Complete dynamic_cast checking.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58804 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaCXX/aggregate-initialization.cpp b/test/SemaCXX/aggregate-initialization.cpp
index 855bc27..75b872f 100644
--- a/test/SemaCXX/aggregate-initialization.cpp
+++ b/test/SemaCXX/aggregate-initialization.cpp
@@ -17,10 +17,12 @@
   int m;
 };
 
-// FIXME: virtual functions
 struct NonAggr4 {
+  int m;
+  virtual void f();
 };
 
 NonAggr1 na1 = { 17 }; // expected-error{{initialization of non-aggregate type 'struct NonAggr1' with an initializer list}}
 NonAggr2 na2 = { 17 }; // expected-error{{initialization of non-aggregate type 'struct NonAggr2' with an initializer list}}
 NonAggr3 na3 = { 17 }; // expected-error{{initialization of non-aggregate type 'class NonAggr3' with an initializer list}}
+NonAggr4 na4 = { 17 }; // expected-error{{initialization of non-aggregate type 'struct NonAggr4' with an initializer list}}
diff --git a/test/SemaCXX/class.cpp b/test/SemaCXX/class.cpp
index c3886f3..7eeecdc 100644
--- a/test/SemaCXX/class.cpp
+++ b/test/SemaCXX/class.cpp
@@ -47,12 +47,16 @@
   }
 
   int f1(int p) {
-   A z = 6;
-   return p + x + this->y + z;
+    A z = 6;
+    return p + x + this->y + z;
   }
 
   typedef int A;
 
+  virtual int vi; // expected-error {{error: 'virtual' can only appear on non-static member functions}}
+  virtual static int vsif(); // expected-error {{error: 'virtual' can only appear on non-static member functions}}
+  virtual int vif();
+
 private:
   int x,y;
   static int sx;
diff --git a/test/SemaCXX/dynamic-cast.cpp b/test/SemaCXX/dynamic-cast.cpp
index 0a4dbc2..5e47b9a 100644
--- a/test/SemaCXX/dynamic-cast.cpp
+++ b/test/SemaCXX/dynamic-cast.cpp
@@ -10,6 +10,15 @@
 
 struct Incomplete;
 
+struct Poly
+{
+  virtual void f();
+};
+
+struct PolyDerived : Poly
+{
+};
+
 void basic_bad()
 {
   // ptr -> nonptr
@@ -52,4 +61,14 @@
   (void)dynamic_cast<A&>(*((F*)0)); // expected-error {{ambiguous conversion from derived class 'struct F' to base class 'struct A':\n    struct F -> struct B -> struct A\n    struct F -> struct E -> struct A}}
 }
 
-// FIXME: Other test cases require recognition of polymorphic classes.
+void poly()
+{
+  (void)dynamic_cast<A*>((Poly*)0);
+  (void)dynamic_cast<A&>(*((Poly*)0));
+  (void)dynamic_cast<A*>((PolyDerived*)0);
+  (void)dynamic_cast<A&>(*((PolyDerived*)0));
+
+  // Not polymorphic source
+  (void)dynamic_cast<Poly*>((A*)0); // expected-error {{'struct A' is not polymorphic}}
+  (void)dynamic_cast<PolyDerived&>(*((A*)0)); // expected-error {{'struct A' is not polymorphic}}
+}