Files
RedBear-OS/local/recipes/dev/libclc/source/clang/test/SemaOpenCLCXX/address-space-lambda.clcpp
T
vasilito cb424d7448 build: static patch-sanity linter (shift-left the malformed-patch class)
verify-patch-sanity.py validates every active recipe .patch has internally-
consistent hunk line counts — catching the 'malformed patch at line N' failure
at commit/CI/preflight time instead of hours into a cook. This cycle hit that
class three times (qtwaylandscanner, sddm, xwayland), each only discovered when
cookbook tried to apply the patch.

Running it across the repo found 29 latent malformed patches (validated against
GNU patch: e.g. relibc/P3-sysv-ipc reproduces 'malformed patch at line 22').
They were harmless only because they sit in vendored recipes (baked, not re-
applied) — but would fail on any version-bump re-derivation. --fix recounts the
hunk headers (body untouched) and repaired all 29.

Wired into build-preflight.sh (Phase 1.0D) and redbear-ci.yml, with a unit test
(test-patch-sanity.sh). Skips archived/legacy trees and unvalidatable formats
(empty placeholders, bare-@@ git hunks).
2026-08-01 05:13:02 +03:00

73 lines
4.2 KiB
Plaintext

//RUN: %clang_cc1 %s -pedantic -ast-dump -verify | FileCheck %s
//RUN: %clang_cc1 %s -pedantic -ast-dump -verify -triple i386-windows | FileCheck %s
//CHECK: CXXMethodDecl {{.*}} constexpr operator() 'int (__private int){{.*}} const __generic'
auto glambda = [](auto a) { return a; };
__kernel void test() {
int i;
//CHECK: CXXMethodDecl {{.*}} constexpr operator() 'void () {{.*}}const __generic'
auto llambda = [&]() {i++;};
llambda();
glambda(1);
// Test lambda with default parameters
//CHECK: CXXMethodDecl {{.*}} constexpr operator() 'void () {{.*}}const __generic'
[&] {i++;} ();
__constant auto err = [&]() {}; //expected-note{{candidate function not viable: 'this' object is in address space '__constant', but method expects object in address space '__generic'}}
err(); //expected-error-re{{no matching function for call to object of type '__constant (lambda at {{.*}})'}}
// FIXME: There is very limited addr space functionality
// we can test when taking lambda type from the object.
// The limitation is due to addr spaces being added to all
// objects in OpenCL. Once we add metaprogramming utility
// for removing address spaces from a type we can enhance
// testing here.
(*(__constant decltype(llambda) *)nullptr)(); //expected-error{{multiple address spaces specified for type}}
(*(decltype(llambda) *)nullptr)();
}
__kernel void test_qual() {
//CHECK: |-CXXMethodDecl {{.*}} constexpr operator() 'void () {{.*}}const __private'
auto priv1 = []() __private {};
priv1();
//CHECK: |-CXXMethodDecl {{.*}} constexpr operator() 'void () {{.*}}const __generic'
auto priv2 = []() __generic {};
priv2();
auto priv3 = []() __global {}; //expected-note{{candidate function not viable: 'this' object is in address space '__private', but method expects object in address space '__global'}}
#if defined(_WIN32) && !defined(_WIN64)
//expected-note@35{{conversion candidate of type 'void (*)() __attribute__((thiscall))'}}
#else
//expected-note@35{{conversion candidate of type 'void (*)()'}}
#endif
priv3(); //expected-error{{no matching function for call to object of type}}
__constant auto const1 = []() __private{}; //expected-note{{candidate function not viable: 'this' object is in address space '__constant', but method expects object in address space '__private'}}
#if defined(_WIN32) && !defined(_WIN64)
//expected-note@43{{conversion candidate of type 'void (*)() __attribute__((thiscall))'}}
#else
//expected-note@43{{conversion candidate of type 'void (*)()'}}
#endif
const1(); //expected-error{{no matching function for call to object of type '__constant (lambda at}}
__constant auto const2 = []() __generic{}; //expected-note{{candidate function not viable: 'this' object is in address space '__constant', but method expects object in address space '__generic'}}
#if defined(_WIN32) && !defined(_WIN64)
//expected-note@50{{conversion candidate of type 'void (*)() __attribute__((thiscall))'}}
#else
//expected-note@50{{conversion candidate of type 'void (*)()'}}
#endif
const2(); //expected-error{{no matching function for call to object of type '__constant (lambda at}}
//CHECK: |-CXXMethodDecl {{.*}} constexpr operator() 'void () {{.*}}const __constant'
__constant auto const3 = []() __constant{};
const3();
[&] () __global {} (); //expected-error{{no matching function for call to object of type '(lambda at}} expected-note{{candidate function not viable: 'this' object is in default address space, but method expects object in address space '__global'}}
[&] () __private {} (); //expected-error{{no matching function for call to object of type '(lambda at}} expected-note{{candidate function not viable: 'this' object is in default address space, but method expects object in address space '__private'}}
[&] __private {} (); // expected-error{{no matching function for call to object of type '(lambda at}} expected-note{{candidate function not viable: 'this' object is in default address space, but method expects object in address space '__private'}}
#if __cplusplus <= 202002L
// expected-warning@-2{{lambda without a parameter clause is a C++23 extension}}
#endif
[&] () mutable __private {} ();
[&] () __private mutable {} (); //expected-error{{expected body of lambda expression}}
}