92 lines · cpp
1struct Base {2 int t;3};4struct Foo : public Base {5 int x;6 Base b;7 void foo();8};9 10void foo() {11 Foo F{.x = 2, .b.t = 0};12 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):10 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC1 %s13 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-2):18 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC1 %s14 // CHECK-CC1: COMPLETION: b : [#Base#]b15 // CHECK-CC1-NEXT: COMPLETION: x : [#int#]x16 // CHECK-CC1-NOT: foo17 // CHECK-CC1-NOT: t18 19 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-8):20 %s -o - | FileCheck -check-prefix=CHECK-NESTED %s20 // CHECK-NESTED: COMPLETION: t : [#int#]t21 22 Base B = {.t = 2};23 auto z = [](Base B) {};24 z({.t = 1});25 z(Base{.t = 2});26 z((Base){.t = 2});27 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-5):14 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC2 %s28 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-4):7 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC2 %s29 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-4):11 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC2 %s30 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-4):13 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC2 %s31 // CHECK-CC2: COMPLETION: t : [#int#]t32 auto zr = [](const Base &B) {};33 zr({.t = 1});34 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):8 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-REF %s35 // CHECK-REF: COMPLETION: t : [#int#]t36 37 Foo G1{.b = {.t = 0}};38 Foo G2{.b{.t = 0}};39 Foo G3{b: {.t = 0}};40 // RUN: %clang_cc1 -code-completion-at=%s:%(line-3):17 -fsyntax-only -code-completion-patterns %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-NESTED-2 %s41 // RUN: %clang_cc1 -code-completion-at=%s:%(line-3):14 -fsyntax-only -code-completion-patterns %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-NESTED-2 %s42 // RUN: %clang_cc1 -code-completion-at=%s:%(line-3):15 -fsyntax-only -code-completion-patterns %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-NESTED-2 %s43 // CHECK-NESTED-2: COMPLETION: t : [#int#]t44}45 46// Handle templates47template <typename T>48struct Test { T x; };49template <>50struct Test<int> {51 int x;52 char y;53};54void bar() {55 Test<char> T{.x = 2};56 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):17 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC3 %s57 // CHECK-CC3: COMPLETION: x : [#T#]x58 Test<int> X{.x = 2};59 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):16 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC4 %s60 // CHECK-CC4: COMPLETION: x : [#int#]x61 // CHECK-CC4-NEXT: COMPLETION: y : [#char#]y62}63 64template <typename T>65void aux() {66 Test<T> X{.x = T(2)};67 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):14 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC3 %s68}69 70namespace signature_regression {71 // Verify that an old bug is gone: passing an init-list as a constructor arg72 // would emit overloads as a side-effect.73 struct S{int x;};74 int wrongFunction(S);75 int rightFunction();76 int dummy = wrongFunction({1});77 int x = rightFunction();78 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):25 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-SIGNATURE-REGRESSION %s79 // CHECK-SIGNATURE-REGRESSION-NOT: OVERLOAD: [#int#]wrongFunction80 // CHECK-SIGNATURE-REGRESSION: OVERLOAD: [#int#]rightFunction81 // CHECK-SIGNATURE-REGRESSION-NOT: OVERLOAD: [#int#]wrongFunction82}83 84struct WithAnon {85 int outer;86 struct { int inner; };87};88auto TestWithAnon = WithAnon { .inner = 2 };89 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):33 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC5 %s90 // CHECK-CC5: COMPLETION: inner : [#int#]inner91 // CHECK-CC5: COMPLETION: outer : [#int#]outer92