Files
RedBear-OS/local/recipes/dev/libclc/source/clang/test/Parser/brackets.c
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

80 lines
2.7 KiB
C

// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: cp %s %t
// RUN: not %clang_cc1 -fixit %t -x c -DFIXIT
// RUN: %clang_cc1 -fsyntax-only %t -x c -DFIXIT
// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -fno-diagnostics-show-line-numbers %s 2>&1 | FileCheck %s -strict-whitespace
void test1(void) {
int a[] = {0,1,1,2,3};
int []b = {0,1,4,9,16};
// expected-error@-1{{brackets are not allowed here; to declare an array, place the brackets after the identifier}}
// CHECK: {{^}} int []b = {0,1,4,9,16};
// CHECK: {{^}} ~~ ^
// CHECK: {{^}} []
// CHECK: fix-it:{{.*}}:{[[@LINE-5]]:7-[[@LINE-5]]:9}:""
// CHECK: fix-it:{{.*}}:{[[@LINE-6]]:10-[[@LINE-6]]:10}:"[]"
int c = a[0];
int d = b[0]; // No undeclared identifier error here.
int *e = a;
int *f = b; // No undeclared identifier error here.
}
struct S {
int [1][1]x;
// expected-error@-1{{brackets are not allowed here; to declare an array, place the brackets after the identifier}}
// CHECK: {{^}} int [1][1]x;
// CHECK: {{^}} ~~~~~~ ^
// CHECK: {{^}} [1][1]
// CHECK: fix-it:{{.*}}:{[[@LINE-5]]:7-[[@LINE-5]]:13}:""
// CHECK: fix-it:{{.*}}:{[[@LINE-6]]:14-[[@LINE-6]]:14}:"[1][1]"
} s;
#ifndef FIXIT
void test2(void) {
int [][][];
// expected-error@-1{{expected identifier or '('}}
// CHECK: {{^}} int [][][];
// CHECK: {{^}} ^
// CHECK-NOT: fix-it
struct T {
int [];
// expected-error@-1{{expected member name or ';' after declaration specifiers}}
// CHECK: {{^}} int [];
// CHECK: {{^}} ~~~ ^
// CHECK-NOT: fix-it
};
}
void test3(void) {
int [5] *;
// expected-error@-1{{expected identifier or '('}}
// CHECK: {{^}} int [5] *;
// CHECK: {{^}} ^
// CHECK-NOT: fix-it
// expected-error@-5{{brackets are not allowed here; to declare an array, place the brackets after the identifier}}
// CHECK: {{^}} int [5] *;
// CHECK: {{^}} ~~~ ^
// CHECK: {{^}} ()[5]
// CHECK: fix-it:{{.*}}:{[[@LINE-9]]:7-[[@LINE-9]]:11}:""
// CHECK: fix-it:{{.*}}:{[[@LINE-10]]:11-[[@LINE-10]]:11}:"("
// CHECK: fix-it:{{.*}}:{[[@LINE-11]]:12-[[@LINE-11]]:12}:")[5]"
int [5] * a;
// expected-error@-1{{brackets are not allowed here; to declare an array, place the brackets after the identifier}}
// CHECK: {{^}} int [5] * a;
// CHECK: {{^}} ~~~ ^
// CHECK: {{^}} ( )[5]
// CHECK: fix-it:{{.*}}:{[[@LINE-5]]:7-[[@LINE-5]]:11}:""
// CHECK: fix-it:{{.*}}:{[[@LINE-6]]:11-[[@LINE-6]]:11}:"("
// CHECK: fix-it:{{.*}}:{[[@LINE-7]]:14-[[@LINE-7]]:14}:")[5]"
int *b[5] = a; // expected-error{{}} a should not be corrected to type b
int (*c)[5] = a; // a should be the same type as c
}
#endif
// CHECK: 8 errors generated.