Files
RedBear-OS/local/recipes/dev/libclc/source/clang/test/CodeGen/complex-math-mixed.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

147 lines
4.3 KiB
C

// RUN: %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-unknown -o - | FileCheck %s --check-prefix=X86
// RUN: %clang_cc1 %s -O0 -triple x86_64-unknown-unknown -ast-dump | FileCheck %s --check-prefix=AST
// Check that for 'F _Complex + int' (F = real floating-point type), we emit an
// implicit cast from 'int' to 'F', but NOT to 'F _Complex' (i.e. that we do
// 'F _Complex + F', NOT 'F _Complex + F _Complex'), and likewise for -/*.
// AST-NOT: FloatingRealToComplex
float _Complex add_float_ci(float _Complex a, int b) {
// X86-LABEL: @add_float_ci
// X86: [[I:%.*]] = sitofp i32 {{%.*}} to float
// X86: fadd float {{.*}}, [[I]]
// X86-NOT: fadd
return a + b;
}
float _Complex add_float_ic(int a, float _Complex b) {
// X86-LABEL: @add_float_ic
// X86: [[I:%.*]] = sitofp i32 {{%.*}} to float
// X86: fadd float [[I]]
// X86-NOT: fadd
return a + b;
}
float _Complex sub_float_ci(float _Complex a, int b) {
// X86-LABEL: @sub_float_ci
// X86: [[I:%.*]] = sitofp i32 {{%.*}} to float
// X86: fsub float {{.*}}, [[I]]
// X86-NOT: fsub
return a - b;
}
float _Complex sub_float_ic(int a, float _Complex b) {
// X86-LABEL: @sub_float_ic
// X86: [[I:%.*]] = sitofp i32 {{%.*}} to float
// X86: fsub float [[I]]
// X86: fneg
// X86-NOT: fsub
return a - b;
}
float _Complex mul_float_ci(float _Complex a, int b) {
// X86-LABEL: @mul_float_ci
// X86: [[I:%.*]] = sitofp i32 {{%.*}} to float
// X86: fmul float {{.*}}, [[I]]
// X86: fmul float {{.*}}, [[I]]
// X86-NOT: fmul
return a * b;
}
float _Complex mul_float_ic(int a, float _Complex b) {
// X86-LABEL: @mul_float_ic
// X86: [[I:%.*]] = sitofp i32 {{%.*}} to float
// X86: fmul float [[I]]
// X86: fmul float [[I]]
// X86-NOT: fmul
return a * b;
}
float _Complex div_float_ci(float _Complex a, int b) {
// X86-LABEL: @div_float_ci
// X86: [[I:%.*]] = sitofp i32 {{%.*}} to float
// X86: fdiv float {{.*}}, [[I]]
// X86: fdiv float {{.*}}, [[I]]
// X86-NOT: @__divsc3
return a / b;
}
// There is no good way of doing this w/o converting the 'int' to a complex
// number, so we expect complex division here.
float _Complex div_float_ic(int a, float _Complex b) {
// X86-LABEL: @div_float_ic
// X86: [[I:%.*]] = sitofp i32 {{%.*}} to float
// X86: call {{.*}} @__divsc3(float {{.*}} [[I]], float noundef 0.{{0+}}e+00, float {{.*}}, float {{.*}})
return a / b;
}
double _Complex add_double_ci(double _Complex a, int b) {
// X86-LABEL: @add_double_ci
// X86: [[I:%.*]] = sitofp i32 {{%.*}} to double
// X86: fadd double {{.*}}, [[I]]
// X86-NOT: fadd
return a + b;
}
double _Complex add_double_ic(int a, double _Complex b) {
// X86-LABEL: @add_double_ic
// X86: [[I:%.*]] = sitofp i32 {{%.*}} to double
// X86: fadd double [[I]]
// X86-NOT: fadd
return a + b;
}
double _Complex sub_double_ci(double _Complex a, int b) {
// X86-LABEL: @sub_double_ci
// X86: [[I:%.*]] = sitofp i32 {{%.*}} to double
// X86: fsub double {{.*}}, [[I]]
// X86-NOT: fsub
return a - b;
}
double _Complex sub_double_ic(int a, double _Complex b) {
// X86-LABEL: @sub_double_ic
// X86: [[I:%.*]] = sitofp i32 {{%.*}} to double
// X86: fsub double [[I]]
// X86: fneg
// X86-NOT: fsub
return a - b;
}
double _Complex mul_double_ci(double _Complex a, int b) {
// X86-LABEL: @mul_double_ci
// X86: [[I:%.*]] = sitofp i32 {{%.*}} to double
// X86: fmul double {{.*}}, [[I]]
// X86: fmul double {{.*}}, [[I]]
// X86-NOT: fmul
return a * b;
}
double _Complex mul_double_ic(int a, double _Complex b) {
// X86-LABEL: @mul_double_ic
// X86: [[I:%.*]] = sitofp i32 {{%.*}} to double
// X86: fmul double [[I]]
// X86: fmul double [[I]]
// X86-NOT: fmul
return a * b;
}
double _Complex div_double_ci(double _Complex a, int b) {
// X86-LABEL: @div_double_ci
// X86: [[I:%.*]] = sitofp i32 {{%.*}} to double
// X86: fdiv double {{.*}}, [[I]]
// X86: fdiv double {{.*}}, [[I]]
// X86-NOT: @__divdc3
return a / b;
}
// There is no good way of doing this w/o converting the 'int' to a complex
// number, so we expect complex division here.
double _Complex div_double_ic(int a, double _Complex b) {
// X86-LABEL: @div_double_ic
// X86: [[I:%.*]] = sitofp i32 {{%.*}} to double
// X86: call {{.*}} @__divdc3(double {{.*}} [[I]], double noundef 0.{{0+}}e+00, double {{.*}}, double {{.*}})
return a / b;
}