diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2008-11-06 15:59:35 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2008-11-06 15:59:35 +0000 |
commit | d93f0ddba0965ded252e228134b30ce30e863fb0 (patch) | |
tree | 94241b20ebda32370cae324a5fdb17a2cb34a584 /test | |
parent | 85bb3dad385e9c2a57cf5aa2d2116d8381953a5a (diff) |
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
Diffstat (limited to 'test')
-rw-r--r-- | test/SemaCXX/aggregate-initialization.cpp | 4 | ||||
-rw-r--r-- | test/SemaCXX/class.cpp | 8 | ||||
-rw-r--r-- | test/SemaCXX/dynamic-cast.cpp | 21 |
3 files changed, 29 insertions, 4 deletions
diff --git a/test/SemaCXX/aggregate-initialization.cpp b/test/SemaCXX/aggregate-initialization.cpp index 855bc27616..75b872feb0 100644 --- a/test/SemaCXX/aggregate-initialization.cpp +++ b/test/SemaCXX/aggregate-initialization.cpp @@ -17,10 +17,12 @@ class NonAggr3 { 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 c3886f3922..7eeecdc577 100644 --- a/test/SemaCXX/class.cpp +++ b/test/SemaCXX/class.cpp @@ -47,12 +47,16 @@ public: } 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 0a4dbc2ae9..5e47b9a0b5 100644 --- a/test/SemaCXX/dynamic-cast.cpp +++ b/test/SemaCXX/dynamic-cast.cpp @@ -10,6 +10,15 @@ struct F : B, E {}; struct Incomplete; +struct Poly +{ + virtual void f(); +}; + +struct PolyDerived : Poly +{ +}; + void basic_bad() { // ptr -> nonptr @@ -52,4 +61,14 @@ void up() (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}} +} |