Skip to content

Commit 10b5c5a

Browse files
committed
Improve testing
- Add user-defined overloaded operator test - Add /= test with different types - Add reversed mixed type test - Use -fsyntax-only to avoid unnecessary codegen
1 parent 0556094 commit 10b5c5a

File tree

2 files changed

+85
-58
lines changed

2 files changed

+85
-58
lines changed

clang/test/Sema/complex-div-warn-higher-precision.c

Lines changed: 0 additions & 58 deletions
This file was deleted.
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// RUN: %clang_cc1 %s -complex-range=promoted -fsyntax-only -triple x86_64-unknown-linux -verify=no-diag \
2+
// RUN: -DDIV_CC -DDIV_RC -DDIVASSIGN -DDIVMIXEDFD -DDIVMIXEDFD2 -DDIVMIXEDID -DDIVASSIGN_MIXEDFD
3+
4+
// RUN: %clang_cc1 %s -complex-range=promoted -fsyntax-only -triple x86_64-unknown-windows -verify=no-diag
5+
// RUN: %clang_cc1 %s -complex-range=promoted -fsyntax-only -triple x86_64-unknown-windows -verify -DDIV_CC
6+
// RUN: %clang_cc1 %s -complex-range=promoted -fsyntax-only -triple x86_64-unknown-windows -verify -DDIV_RC
7+
// RUN: %clang_cc1 %s -complex-range=promoted -fsyntax-only -triple x86_64-unknown-windows -verify -DDIVASSIGN
8+
// RUN: %clang_cc1 %s -complex-range=promoted -fsyntax-only -triple x86_64-unknown-windows -verify -DDIVMIXEDFD
9+
// RUN: %clang_cc1 %s -complex-range=promoted -fsyntax-only -triple x86_64-unknown-windows -verify -DDIVMIXEDFD2
10+
// RUN: %clang_cc1 %s -complex-range=promoted -fsyntax-only -triple x86_64-unknown-windows -verify -DDIVMIXEDID
11+
// RUN: %clang_cc1 %s -complex-range=promoted -fsyntax-only -triple x86_64-unknown-windows -verify -DDIVASSIGN_MIXEDFD
12+
13+
_Complex double div_ccf(_Complex float a, _Complex float b) {
14+
return a / b;
15+
}
16+
17+
_Complex double div_cr(_Complex double a, double b) {
18+
return a / b;
19+
}
20+
21+
_Complex double div_rr(double a, double b) {
22+
return a / b;
23+
}
24+
25+
_Complex int div_ii(_Complex int a, _Complex int b) {
26+
return a / b;
27+
}
28+
29+
struct UserT {
30+
friend UserT operator/(UserT, _Complex double);
31+
friend UserT operator/(_Complex double, UserT);
32+
};
33+
34+
UserT div_uc(UserT a, _Complex double b) {
35+
return a / b;
36+
}
37+
38+
UserT div_cu(_Complex double a, UserT b) {
39+
return a / b;
40+
}
41+
42+
#ifdef DIV_CC
43+
_Complex double div_cc(_Complex double a, const _Complex double b) {
44+
return a / b; // #1
45+
}
46+
#endif // DIV_CC
47+
48+
#ifdef DIV_RC
49+
_Complex double div_rc(double a, _Complex float b) {
50+
return a / b; // #1
51+
}
52+
#endif // DIV_RC
53+
54+
#ifdef DIVASSIGN
55+
_Complex double divassign(_Complex double a, _Complex double b) {
56+
return a /= b; // #1
57+
}
58+
#endif // DIVASSIGN
59+
60+
#ifdef DIVMIXEDFD
61+
_Complex double divmixedfd(_Complex float a, _Complex double b) {
62+
return a / b; // #1
63+
}
64+
#endif // DIVMIXEDFD
65+
66+
#ifdef DIVMIXEDFD2
67+
_Complex double divmixedfd2(_Complex double a, _Complex float b) {
68+
return a / b; // #1
69+
}
70+
#endif // DIVMIXEDFD2
71+
72+
#ifdef DIVMIXEDID
73+
_Complex double divmixedid(_Complex int a, _Complex double b) {
74+
return a / b; // #1
75+
}
76+
#endif // DIVMIXEDID
77+
78+
#ifdef DIVASSIGN_MIXEDFD
79+
_Complex double divassign_mixedfd(_Complex float a, _Complex double b) {
80+
return a /= b; // #1
81+
}
82+
#endif // DIVMIXEDFD
83+
84+
// no-diag-no-diagnostics
85+
// expected-warning@#1 {{excess precision is requested but the target does not support excess precision which may result in observable differences in complex division behavior}}

0 commit comments

Comments
 (0)