mirror of
https://github.com/intel/llvm.git
synced 2026-01-30 14:07:28 +08:00
LHS type and the computation result type; this encodes information into the AST which is otherwise non-obvious. Fix Sema to always come up with the right answer for both of these types. Fix IRGen and the analyzer to account for these changes. This fixes PR2601. The approach is inspired by PR2601 comment 2. Note that this changes real *= complex in CodeGen from a silent miscompilation to an explicit error. I'm not really sure that the analyzer changes are correct, or how to test them... someone more familiar with the analyzer should check those changes. llvm-svn: 67889
62 lines
778 B
C
62 lines
778 B
C
// RUN: clang-cc -emit-llvm < %s
|
|
|
|
int main(void)
|
|
{
|
|
double _Complex a = 5;
|
|
double _Complex b = 42;
|
|
|
|
return a * b != b * a;
|
|
}
|
|
|
|
_Complex double bar(int);
|
|
void test(_Complex double*);
|
|
void takecomplex(_Complex double);
|
|
|
|
void test2(int c) {
|
|
_Complex double X;
|
|
X = bar(1);
|
|
test(&X);
|
|
takecomplex(X);
|
|
}
|
|
|
|
_Complex double g1, g2;
|
|
_Complex float cf;
|
|
double D;
|
|
|
|
void test3() {
|
|
g1 = g1 + g2;
|
|
g1 = g1 - g2;
|
|
g1 = g1 * g2;
|
|
g1 = +-~g1;
|
|
|
|
double Gr = __real g1;
|
|
|
|
cf += D;
|
|
// FIXME: Currently unsupported!
|
|
//D += cf;
|
|
cf /= g1;
|
|
g1 = g1 + D;
|
|
g1 = D + g1;
|
|
}
|
|
|
|
void t1() {
|
|
(__real__ cf) = 4.0;
|
|
}
|
|
|
|
void t2() {
|
|
(__imag__ cf) = 4.0;
|
|
}
|
|
|
|
// PR1960
|
|
void t3() {
|
|
__complex__ long long v = 2;
|
|
}
|
|
|
|
// PR3131
|
|
float _Complex t4();
|
|
|
|
void t5() {
|
|
float _Complex x = t4();
|
|
}
|
|
|