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.
5 #include "base_refcounted.h"
11 // Unsafe; should error.
12 class AnonymousDerivedProtectedToPublicInImpl
13 : public ProtectedRefCountedVirtualDtorInHeader
{
15 AnonymousDerivedProtectedToPublicInImpl() {}
16 ~AnonymousDerivedProtectedToPublicInImpl() override
{}
19 // Unsafe; but we should only warn on the base class.
20 class AnonymousDerivedProtectedOnDerived
21 : public ProtectedRefCountedDtorInHeader
{
23 ~AnonymousDerivedProtectedOnDerived() {}
28 // Unsafe; should error.
29 class PublicRefCountedDtorInImpl
30 : public base::RefCounted
<PublicRefCountedDtorInImpl
> {
32 PublicRefCountedDtorInImpl() {}
33 ~PublicRefCountedDtorInImpl() {}
36 friend class base::RefCounted
<PublicRefCountedDtorInImpl
>;
43 virtual ~BarInterface() {}
46 typedef base::RefCounted
<BarInterface
> RefCountedBar
;
47 typedef RefCountedBar AnotherTypedef
;
52 typedef typename
Foo::AnotherTypedef MyLocalTypedef
;
55 // Unsafe; should error.
56 class UnsafeTypedefChainInImpl
: public Baz::MyLocalTypedef
{
58 UnsafeTypedefChainInImpl() {}
59 ~UnsafeTypedefChainInImpl() {}
63 PublicRefCountedDtorInHeader bad
;
64 PublicRefCountedDtorInImpl also_bad
;
66 ProtectedRefCountedDtorInHeader
* even_badder
= NULL
;
67 PrivateRefCountedDtorInHeader
* private_ok
= NULL
;
69 DerivedProtectedToPublicInHeader still_bad
;
70 PublicRefCountedThreadSafeDtorInHeader another_bad_variation
;
71 AnonymousDerivedProtectedToPublicInImpl and_this_is_bad_too
;
72 ImplicitDerivedProtectedToPublicInHeader bad_yet_again
;
73 UnsafeTypedefChainInImpl and_again_this_is_bad
;
75 WebKitPublicDtorInHeader ignored
;
76 WebKitDerivedPublicDtorInHeader still_ignored
;