| 1 |
struct Base { |
| 2 |
int t; |
| 3 |
}; |
| 4 |
struct Foo : public Base { |
| 5 |
int x; |
| 6 |
Base b; |
| 7 |
void foo(); |
| 8 |
}; |
| 9 |
|
| 10 |
void 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 %s |
| 13 |
// 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 %s |
| 14 |
// CHECK-CC1: COMPLETION: b : [#Base#]b |
| 15 |
// CHECK-CC1-NEXT: COMPLETION: x : [#int#]x |
| 16 |
// CHECK-CC1-NOT: foo |
| 17 |
// CHECK-CC1-NOT: t |
| 18 |
|
| 19 |
// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-8):20 %s -o - | FileCheck -check-prefix=CHECK-NESTED %s |
| 20 |
// CHECK-NESTED: COMPLETION: t : [#int#]t |
| 21 |
|
| 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 %s |
| 28 |
// 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 %s |
| 29 |
// 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 %s |
| 30 |
// 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 %s |
| 31 |
// CHECK-CC2: COMPLETION: t : [#int#]t |
| 32 |
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 %s |
| 35 |
// CHECK-REF: COMPLETION: t : [#int#]t |
| 36 |
|
| 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 %s |
| 41 |
// 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 %s |
| 42 |
// 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 %s |
| 43 |
// CHECK-NESTED-2: COMPLETION: t : [#int#]t |
| 44 |
} |
| 45 |
|
| 46 |
// Handle templates |
| 47 |
template <typename T> |
| 48 |
struct Test { T x; }; |
| 49 |
template <> |
| 50 |
struct Test<int> { |
| 51 |
int x; |
| 52 |
char y; |
| 53 |
}; |
| 54 |
void 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 %s |
| 57 |
// CHECK-CC3: COMPLETION: x : [#T#]x |
| 58 |
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 %s |
| 60 |
// CHECK-CC4: COMPLETION: x : [#int#]x |
| 61 |
// CHECK-CC4-NEXT: COMPLETION: y : [#char#]y |
| 62 |
} |
| 63 |
|
| 64 |
template <typename T> |
| 65 |
void 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 %s |
| 68 |
} |
| 69 |
|
| 70 |
namespace signature_regression { |
| 71 |
// Verify that an old bug is gone: passing an init-list as a constructor arg |
| 72 |
// 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 %s |
| 79 |
// CHECK-SIGNATURE-REGRESSION-NOT: OVERLOAD: [#int#]wrongFunction |
| 80 |
// CHECK-SIGNATURE-REGRESSION: OVERLOAD: [#int#]rightFunction |
| 81 |
// CHECK-SIGNATURE-REGRESSION-NOT: OVERLOAD: [#int#]wrongFunction |
| 82 |
} |
| 83 |
|
| 84 |
struct WithAnon { |
| 85 |
int outer; |
| 86 |
struct { int inner; }; |
| 87 |
}; |
| 88 |
auto 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 %s |
| 90 |
// CHECK-CC5: COMPLETION: inner : [#int#]inner |
| 91 |
// CHECK-CC5: COMPLETION: outer : [#int#]outer |