Home | History | Annotate | Download | only in tests
      1 // Copyright (c) 2011 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 #ifndef MISSING_CTOR_H_
      6 #define MISSING_CTOR_H_
      7 
      8 struct MyString {
      9   MyString();
     10   ~MyString();
     11   MyString(const MyString&);
     12   MyString(MyString&&);
     13 };
     14 
     15 template <class T>
     16 struct MyVector {
     17   MyVector();
     18   ~MyVector();
     19   MyVector(const MyVector&);
     20   MyVector(MyVector&&);
     21 };
     22 
     23 // Note: this should warn for an implicit copy constructor too, but currently
     24 // doesn't, due to a plugin bug.
     25 class MissingCtorsArentOKInHeader {
     26  public:
     27 
     28  private:
     29   MyVector<int> one_;
     30   MyVector<MyString> two_;
     31 };
     32 
     33 // Inline move ctors shouldn't be warned about. Similar to the previous test
     34 // case, this also incorrectly fails to warn for the implicit copy ctor.
     35 class InlineImplicitMoveCtorOK {
     36  public:
     37   InlineImplicitMoveCtorOK();
     38 
     39  private:
     40   // ctor weight = 12, dtor weight = 9.
     41   MyString one_;
     42   MyString two_;
     43   MyString three_;
     44   int four_;
     45   int five_;
     46   int six_;
     47 };
     48 
     49 class ExplicitlyDefaultedInlineAlsoWarns {
     50  public:
     51   ExplicitlyDefaultedInlineAlsoWarns() = default;
     52   ~ExplicitlyDefaultedInlineAlsoWarns() = default;
     53   ExplicitlyDefaultedInlineAlsoWarns(
     54       const ExplicitlyDefaultedInlineAlsoWarns&) = default;
     55 
     56  private:
     57   MyVector<int> one_;
     58   MyVector<MyString> two_;
     59 
     60 };
     61 
     62 union UnionDoesNotWarn {
     63  UnionDoesNotWarn() = default;
     64  UnionDoesNotWarn(const UnionDoesNotWarn& other) = default;
     65 
     66  int a;
     67  int b;
     68  int c;
     69  int d;
     70  int e;
     71  int f;
     72  int g;
     73  int h;
     74  int i;
     75  int j;
     76  int k;
     77  int l;
     78  int m;
     79  int n;
     80  int o;
     81  int p;
     82  int q;
     83  int r;
     84  int s;
     85  int t;
     86  int u;
     87  int v;
     88  int w;
     89  int x;
     90  int y;
     91  int z;
     92 };
     93 
     94 #endif  // MISSING_CTOR_H_
     95