File indexing completed on 2024-04-28 05:38:40

0001 
0002 
0003 struct ValueClass // OK
0004 {
0005     int m;
0006 };
0007 
0008 struct DerivedValueClass : public ValueClass // OK
0009 {
0010     int m;
0011 };
0012 
0013 struct PolymorphicClass1 // OK, not copyable
0014 {
0015     virtual void foo();
0016     PolymorphicClass1(const PolymorphicClass1 &) = delete;
0017     PolymorphicClass1& operator=(const PolymorphicClass1 &) = delete;
0018 };
0019 
0020 struct PolymorphicClass2 // OK, not copyable
0021 {
0022     virtual void foo();
0023 private:
0024     PolymorphicClass2(const PolymorphicClass2 &);
0025     PolymorphicClass2& operator=(const PolymorphicClass2 &);
0026 };
0027 
0028 struct PolymorphicClass3 // OK, not copyable
0029 {
0030     virtual void foo();
0031     PolymorphicClass3(const PolymorphicClass3 &) = delete;
0032 private:
0033     PolymorphicClass3& operator=(const PolymorphicClass3 &) = delete;
0034 };
0035 
0036 struct PolymorphicClass4 // Warning, copyable
0037 {
0038     virtual void foo();
0039     PolymorphicClass4(const PolymorphicClass4 &);
0040     PolymorphicClass4& operator=(const PolymorphicClass4 &);
0041 };
0042 
0043 struct PolymorphicClass5 // Warning, copyable
0044 {
0045     virtual void foo();
0046 };
0047 
0048 struct DerivedFromNotCopyable : public PolymorphicClass3 // OK, not copyable
0049 {
0050 };
0051 
0052 struct DerivedFromCopyable : public PolymorphicClass4 // Warning, copyable
0053 {
0054 };
0055 
0056 class ClassWithPrivateSection
0057 {
0058 public:
0059     virtual void foo();
0060 private:
0061     void bar();
0062     int i;
0063 };
0064 
0065 // Ok, copy-ctor is protected
0066 class BaseWithProtectedCopyCtor
0067 {
0068 protected:
0069     virtual ~BaseWithProtectedCopyCtor();
0070     BaseWithProtectedCopyCtor(const BaseWithProtectedCopyCtor &) {}
0071     BaseWithProtectedCopyCtor &operator=(const BaseWithProtectedCopyCtor &);
0072 };
0073 
0074 // Ok, copy-ctor is protected in base class and derived is final (#438027)
0075 class DerivedOfBaseWithProtectedCopyCtor final : public BaseWithProtectedCopyCtor
0076 {
0077 protected:
0078     virtual ~DerivedOfBaseWithProtectedCopyCtor();
0079 };
0080 
0081 // Warn
0082 class DerivedOfBaseWithPublicCopyCtor final : public PolymorphicClass4
0083 {
0084 protected:
0085     virtual ~DerivedOfBaseWithPublicCopyCtor();
0086 };