Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions clang/lib/Sema/SemaChecking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5551,16 +5551,6 @@ bool Sema::BuiltinComplex(CallExpr *TheCall) {
<< Real->getSourceRange() << Imag->getSourceRange();
}

// We don't allow _Complex _Float16 nor _Complex __fp16 as type specifiers;
// don't allow this builtin to form those types either.
// FIXME: Should we allow these types?
if (Real->getType()->isFloat16Type())
return Diag(TheCall->getBeginLoc(), diag::err_invalid_complex_spec)
<< "_Float16";
if (Real->getType()->isHalfType())
return Diag(TheCall->getBeginLoc(), diag::err_invalid_complex_spec)
<< "half";

TheCall->setType(Context.getComplexType(Real->getType()));
return false;
}
Expand Down
22 changes: 22 additions & 0 deletions clang/test/CodeGen/complex_Float16.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5
// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s

// CHECK-LABEL: define dso_local <2 x half> @builtin_complex(
// CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
// CHECK-NEXT: [[ENTRY:.*:]]
// CHECK-NEXT: [[RETVAL:%.*]] = alloca { half, half }, align 2
// CHECK-NEXT: [[A:%.*]] = alloca half, align 2
// CHECK-NEXT: store half 0xH0000, ptr [[A]], align 2
// CHECK-NEXT: [[TMP0:%.*]] = load half, ptr [[A]], align 2
// CHECK-NEXT: [[TMP1:%.*]] = load half, ptr [[A]], align 2
// CHECK-NEXT: [[RETVAL_REALP:%.*]] = getelementptr inbounds nuw { half, half }, ptr [[RETVAL]], i32 0, i32 0
// CHECK-NEXT: [[RETVAL_IMAGP:%.*]] = getelementptr inbounds nuw { half, half }, ptr [[RETVAL]], i32 0, i32 1
// CHECK-NEXT: store half [[TMP0]], ptr [[RETVAL_REALP]], align 2
// CHECK-NEXT: store half [[TMP1]], ptr [[RETVAL_IMAGP]], align 2
// CHECK-NEXT: [[TMP2:%.*]] = load <2 x half>, ptr [[RETVAL]], align 2
// CHECK-NEXT: ret <2 x half> [[TMP2]]
//
_Complex _Float16 builtin_complex(void) {
_Float16 a = 0;
return __builtin_complex(a, a);
}
3 changes: 2 additions & 1 deletion clang/test/Sema/Float16.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
_Float16 f;

#ifdef HAVE
// expected-no-diagnostics
_Complex _Float16 a;
void builtin_complex(void) {
_Float16 a = 0;
(void)__builtin_complex(a, a); // expected-error {{'_Complex _Float16' is invalid}}
(void)__builtin_complex(a, a);
}
#endif
7 changes: 0 additions & 7 deletions clang/test/Sema/fp16-sema.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,3 @@ extern __fp16 *(*gf1) (void);

typedef __fp16 (*tf1) (void); // expected-error {{function return value cannot have __fp16 type; did you forget * ?}}
typedef __fp16 *(*tg1) (void);

void testComplex() {
// FIXME: Should these be valid?
_Complex __fp16 a; // expected-error {{'_Complex half' is invalid}}
__fp16 b;
a = __builtin_complex(b, b); // expected-error {{'_Complex half' is invalid}}
}
7 changes: 0 additions & 7 deletions clang/test/Sema/riscv-fp16.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,3 @@ extern __fp16 *(*gf1) (void);

typedef __fp16 (*tf1) (void); // expected-error {{function return value cannot have __fp16 type; did you forget * ?}}
typedef __fp16 *(*tg1) (void);

void testComplex() {
// FIXME: Should these be valid?
_Complex __fp16 a; // expected-error {{'_Complex half' is invalid}}
__fp16 b;
a = __builtin_complex(b, b); // expected-error {{'_Complex half' is invalid}}
}
Loading