Files
RedBear-OS/local/recipes/dev/libclc/source/clang/test/Modules/diag-pragma.cpp
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

48 lines
2.0 KiB
C++

// RUN: rm -rf %t
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -emit-module -fmodules-cache-path=%t -fmodule-name=diag_pragma -x c++ %S/Inputs/module.modulemap -std=c++20
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -std=c++20
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -emit-module -fmodule-name=diag_pragma -x c++ %S/Inputs/module.modulemap -std=c++20 -o %t/explicit.pcm -Werror=string-plus-int
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -std=c++20 -DEXPLICIT_FLAG -fmodule-file=%t/explicit.pcm
#include "diag_pragma.h"
int foo(int x) {
// Diagnostics from templates in the module follow the diagnostic state from
// when the module was built.
#ifdef EXPLICIT_FLAG
// expected-error@diag_pragma.h:7 {{adding 'int' to a string}}
#else
// expected-warning@diag_pragma.h:7 {{adding 'int' to a string}}
#endif
// expected-note@diag_pragma.h:7 {{use array indexing}}
f(0); // expected-note {{instantiation of}}
g(0); // ok, warning was ignored when building module
// Diagnostics from this source file ignore the diagnostic state from the
// module.
void("foo" + x); // expected-warning {{adding 'int' to a string}}
// expected-note@-1 {{use array indexing}}
#pragma clang diagnostic ignored "-Wstring-plus-int"
// Diagnostics from the module ignore diagnostic state changes from this
// source file.
#ifdef EXPLICIT_FLAG
// expected-error@diag_pragma.h:7 {{adding 'long' to a string}}
#else
// expected-warning@diag_pragma.h:7 {{adding 'long' to a string}}
#endif
// expected-note@diag_pragma.h:7 {{use array indexing}}
f(0L); // expected-note {{instantiation of}}
g(0L);
void("bar" + x);
if (x = DIAG_PRAGMA_MACRO) // expected-warning {{using the result of an assignment as a condition without parentheses}} \
// expected-note {{place parentheses}} expected-note {{use '=='}}
return 0;
return 1;
}