diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2009-11-14 21:15:49 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2009-11-14 21:15:49 +0000 |
commit | 7c353685bcb7ffed368f524af687af70578672cd (patch) | |
tree | 3dcd378188398a193abb4c3c7dbe20aa1d269da7 /clang/test/SemaCXX/static-cast.cpp | |
parent | 0acee6e0d722ba41026bf01bdd7b5f7ebbfc32b0 (diff) | |
download | bcm5719-llvm-7c353685bcb7ffed368f524af687af70578672cd.tar.gz bcm5719-llvm-7c353685bcb7ffed368f524af687af70578672cd.zip |
- Have TryStaticImplicitCast set the cast kind to NoOp when binding a reference. CheckReferenceInit already inserts implicit casts to the necessary types. This fixes an assertion in CodeGen for some casts and brings a fix for PR5453 close, if I understand that bug correctly.
- Also, perform calculated implicit cast sequences if they're determined to work. This finally diagnoses static_cast to ambiguous or implicit bases and fixes two long-standing fixmes in the test case. For the C-style cast, this requires propagating the access check suppression pretty deep into other functions.
- Pass the expressions for TryStaticCast and TryStaticImplicitCast by reference. This should lead to a better AST being emitted for such casts, and also fixes a memory leak, because CheckReferenceInit and PerformImplicitConversion wrap the node passed to them. These wrappers were previously lost.
llvm-svn: 88809
Diffstat (limited to 'clang/test/SemaCXX/static-cast.cpp')
-rw-r--r-- | clang/test/SemaCXX/static-cast.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/clang/test/SemaCXX/static-cast.cpp b/clang/test/SemaCXX/static-cast.cpp index 5d4f1bfcdf0..68f1dff276b 100644 --- a/clang/test/SemaCXX/static-cast.cpp +++ b/clang/test/SemaCXX/static-cast.cpp @@ -5,7 +5,7 @@ struct B : public A {}; // Single public base. struct C1 : public virtual B {}; // Single virtual base. struct C2 : public virtual B {}; struct D : public C1, public C2 {}; // Diamond -struct E : private A {}; // Single private base. expected-note 2 {{'private' inheritance specifier here}} +struct E : private A {}; // Single private base. expected-note 3 {{'private' inheritance specifier here}} struct F : public C1 {}; // Single path to B with virtual. struct G1 : public B {}; struct G2 : public B {}; @@ -57,8 +57,8 @@ void t_529_2() // Bad code below (void)static_cast<void*>((const int*)0); // expected-error {{static_cast from 'int const *' to 'void *' is not allowed}} - //(void)static_cast<A*>((E*)0); // {{static_cast from 'struct E *' to 'struct A *' is not allowed}} - //(void)static_cast<A*>((H*)0); // {{static_cast from 'struct H *' to 'struct A *' is not allowed}} + (void)static_cast<A*>((E*)0); // expected-error {{inaccessible base class 'struct A'}} + (void)static_cast<A*>((H*)0); // expected-error {{ambiguous conversion}} (void)static_cast<int>((int*)0); // expected-error {{static_cast from 'int *' to 'int' is not allowed}} (void)static_cast<A**>((B**)0); // expected-error {{static_cast from 'struct B **' to 'struct A **' is not allowed}} (void)static_cast<char&>(i); // expected-error {{non-const lvalue reference to type 'char' cannot be initialized with a value of type 'int'}} |