brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.4 KiB · 1ce9576 Raw
123 lines · cpp
1class X {2public:3 int pub;4protected:5 int prot;6private:7 int priv;8};9 10class Unrelated {11public:12  static int pub;13protected:14  static int prot;15private:16  static int priv;17};18 19class Y : public X {20  int test() {21    this->pub = 10;22    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):11 %s -o - \23    // RUN: | FileCheck -check-prefix=THIS %s24    // THIS: priv (InBase,Inaccessible)25    // THIS: prot (InBase)26    // THIS: pub (InBase)27    //28    // Also check implicit 'this->', i.e. complete at the start of the line.29    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-8):1 %s -o - \30    // RUN: | FileCheck -check-prefix=THIS %s31 32    X().pub + 10;33    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):9 %s -o - \34    // RUN: | FileCheck -check-prefix=X-OBJ %s35    // X-OBJ: priv (Inaccessible)36    // X-OBJ: prot (Inaccessible)37    // X-OBJ: pub : [#int#]pub38    39    Y().pub + 10;40    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):9 %s -o - \41    // RUN: | FileCheck -check-prefix=Y-OBJ %s42    // Y-OBJ: priv (InBase,Inaccessible)43    // Y-OBJ: prot (InBase)44    // Y-OBJ: pub (InBase)45 46    this->X::pub = 10;47    X::pub = 10;48    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-2):14 %s -o - \49    // RUN: | FileCheck -check-prefix=THIS-BASE %s50    //51    // THIS-BASE: priv (Inaccessible)52    // THIS-BASE: prot : [#int#]prot53    // THIS-BASE: pub : [#int#]pub54    //55    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-8):8 %s -o - \56    // RUN: | FileCheck -check-prefix=THIS-BASE %s57    58 59    this->Unrelated::pub = 10; // a check we don't crash in this cases.60    Y().Unrelated::pub = 10; // a check we don't crash in this cases.61    Unrelated::pub = 10;62    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-3):22 %s -o - \63    // RUN: | FileCheck -check-prefix=UNRELATED %s64    // UNRELATED: priv (Inaccessible)65    // UNRELATED: prot (Inaccessible)66    // UNRELATED: pub : [#int#]pub67    //68    // RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-8):20 %s -o - \69    // RUN: | FileCheck -check-prefix=UNRELATED %s70    // RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-9):16 %s -o - \71    // RUN: | FileCheck -check-prefix=UNRELATED %s72  }73};74 75class Outer {76 public:77  static int pub;78 protected:79  static int prot;80 private:81  static int priv;82 83  class Inner {84    int test() {85      Outer::pub = 10;86    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):14 %s -o - \87    // RUN: | FileCheck -check-prefix=OUTER %s88    // OUTER: priv : [#int#]priv89    // OUTER: prot : [#int#]prot90    // OUTER: pub : [#int#]pub91 92    // Also check the unqualified case.93    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-8):1 %s -o - \94    // RUN: | FileCheck -check-prefix=OUTER %s95    }96  };97};98 99class Base {100public:101  int pub;102};103 104class Accessible : public Base {105};106 107class Inaccessible : private Base {108};109 110class Test : public Accessible, public Inaccessible {111  int test() {112    this->Accessible::pub = 10;113    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):23 %s -o - \114    // RUN: | FileCheck -check-prefix=ACCESSIBLE %s115    // ACCESSIBLE: pub (InBase)116 117    this->Inaccessible::pub = 10;118    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):25 %s -o - \119    // RUN: | FileCheck -check-prefix=INACCESSIBLE %s120    // INACCESSIBLE: pub (InBase,Inaccessible)121  }122};123