OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base_refcounted.h" |
| 6 |
| 7 #include <cstddef> |
| 8 |
| 9 namespace { |
| 10 |
| 11 // Unsafe; should error. |
| 12 class AnonymousDerivedProtectedToPublicInImpl |
| 13 : public ProtectedRefCountedDtorInHeader { |
| 14 public: |
| 15 AnonymousDerivedProtectedToPublicInImpl() {} |
| 16 ~AnonymousDerivedProtectedToPublicInImpl() {} |
| 17 }; |
| 18 |
| 19 } // namespace |
| 20 |
| 21 // Unsafe; should error. |
| 22 class PublicRefCountedDtorInImpl |
| 23 : public base::RefCounted<PublicRefCountedDtorInImpl> { |
| 24 public: |
| 25 PublicRefCountedDtorInImpl() {} |
| 26 ~PublicRefCountedDtorInImpl() {} |
| 27 |
| 28 private: |
| 29 friend class base::RefCounted<PublicRefCountedDtorInImpl>; |
| 30 }; |
| 31 |
| 32 class Foo { |
| 33 public: |
| 34 class BarInterface { |
| 35 protected: |
| 36 virtual ~BarInterface() {} |
| 37 }; |
| 38 |
| 39 typedef base::RefCounted<BarInterface> RefCountedBar; |
| 40 typedef RefCountedBar AnotherTypedef; |
| 41 }; |
| 42 |
| 43 class Baz { |
| 44 public: |
| 45 typedef typename Foo::AnotherTypedef MyLocalTypedef; |
| 46 }; |
| 47 |
| 48 // Unsafe; should error. |
| 49 class UnsafeTypedefChainInImpl : public Baz::MyLocalTypedef { |
| 50 public: |
| 51 UnsafeTypedefChainInImpl() {} |
| 52 ~UnsafeTypedefChainInImpl() {} |
| 53 }; |
| 54 |
| 55 int main() { |
| 56 PublicRefCountedDtorInHeader bad; |
| 57 PublicRefCountedDtorInImpl also_bad; |
| 58 |
| 59 ProtectedRefCountedDtorInHeader* protected_ok = NULL; |
| 60 PrivateRefCountedDtorInHeader* private_ok = NULL; |
| 61 |
| 62 DerivedProtectedToPublicInHeader still_bad; |
| 63 PublicRefCountedThreadSafeDtorInHeader another_bad_variation; |
| 64 AnonymousDerivedProtectedToPublicInImpl and_this_is_bad_too; |
| 65 ImplicitDerivedProtectedToPublicInHeader bad_yet_again; |
| 66 UnsafeTypedefChainInImpl and_again_this_is_bad; |
| 67 |
| 68 WebKitPublicDtorInHeader ignored; |
| 69 WebKitDerivedPublicDtorInHeader still_ignored; |
| 70 |
| 71 return 0; |
| 72 } |
OLD | NEW |