aboutsummaryrefslogtreecommitdiff
path: root/test/SemaCXX/static-cast.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/SemaCXX/static-cast.cpp')
-rw-r--r--test/SemaCXX/static-cast.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/test/SemaCXX/static-cast.cpp b/test/SemaCXX/static-cast.cpp
index 06fd8636e5d6..b3fe49a88c6b 100644
--- a/test/SemaCXX/static-cast.cpp
+++ b/test/SemaCXX/static-cast.cpp
@@ -9,8 +9,8 @@ struct F : public C1 {}; // Single path to B with virtual.
struct G1 : public B {};
struct G2 : public B {};
struct H : public G1, public G2 {}; // Ambiguous path to B.
-struct I; // Incomplete.
-struct J; // Incomplete.
+struct I; // Incomplete. expected-note {{'I' is incomplete}}
+struct J; // Incomplete. expected-note {{'J' is incomplete}}
enum Enum { En1, En2 };
enum Onom { On1, On2 };
@@ -92,9 +92,13 @@ void t_529_5_8()
(void)static_cast<E&>(*((A*)0)); // expected-error {{cannot cast private base class 'A' to 'E'}}
(void)static_cast<H*>((A*)0); // expected-error {{ambiguous cast from base 'A' to derived 'H':\n struct A -> struct B -> struct G1 -> struct H\n struct A -> struct B -> struct G2 -> struct H}}
(void)static_cast<H&>(*((A*)0)); // expected-error {{ambiguous cast from base 'A' to derived 'H':\n struct A -> struct B -> struct G1 -> struct H\n struct A -> struct B -> struct G2 -> struct H}}
- (void)static_cast<E*>((B*)0); // expected-error {{static_cast from 'B *' to 'E *' is not allowed}}
+ (void)static_cast<E*>((B*)0); // expected-error {{static_cast from 'B *' to 'E *', which are not related by inheritance, is not allowed}}
(void)static_cast<E&>(*((B*)0)); // expected-error {{non-const lvalue reference to type 'E' cannot bind to a value of unrelated type 'B'}}
+
+ (void)static_cast<E*>((J*)0); // expected-error {{static_cast from 'J *' to 'E *', which are not related by inheritance, is not allowed}}
+ (void)static_cast<I*>((B*)0); // expected-error {{static_cast from 'B *' to 'I *', which are not related by inheritance, is not allowed}}
+
// TODO: Test inaccessible base in context where it's accessible, i.e.
// member function and friend.