aboutsummaryrefslogtreecommitdiff
path: root/test/Headers
diff options
context:
space:
mode:
Diffstat (limited to 'test/Headers')
-rw-r--r--test/Headers/Inputs/include/cmath5
-rw-r--r--test/Headers/Inputs/include/limits10
-rw-r--r--test/Headers/Inputs/include/math.h4
-rw-r--r--test/Headers/float.c13
-rw-r--r--test/Headers/float16.c12
-rw-r--r--test/Headers/max_align.c12
-rw-r--r--test/Headers/ms-arm64-intrin.cpp6
-rw-r--r--test/Headers/ms-intrin.cpp2
-rw-r--r--test/Headers/nvptx_device_cmath_functions.c21
-rw-r--r--test/Headers/nvptx_device_cmath_functions.cpp21
-rw-r--r--test/Headers/nvptx_device_math_functions.c21
-rw-r--r--test/Headers/nvptx_device_math_functions.cpp21
-rw-r--r--test/Headers/opencl-c-header.cl20
-rw-r--r--test/Headers/ppc-intrinsics.c13
-rw-r--r--test/Headers/x86-intrinsics-headers-clean.cpp10
15 files changed, 161 insertions, 30 deletions
diff --git a/test/Headers/Inputs/include/cmath b/test/Headers/Inputs/include/cmath
new file mode 100644
index 0000000000..4ba1795137
--- /dev/null
+++ b/test/Headers/Inputs/include/cmath
@@ -0,0 +1,5 @@
+#pragma once
+
+double sqrt(double);
+double pow(double, double);
+double modf(double, double*);
diff --git a/test/Headers/Inputs/include/limits b/test/Headers/Inputs/include/limits
new file mode 100644
index 0000000000..fbee11ef11
--- /dev/null
+++ b/test/Headers/Inputs/include/limits
@@ -0,0 +1,10 @@
+#pragma once
+
+namespace std
+{
+struct __numeric_limits_base
+ {};
+template<typename _Tp>
+ struct numeric_limits : public __numeric_limits_base
+ {};
+}
diff --git a/test/Headers/Inputs/include/math.h b/test/Headers/Inputs/include/math.h
index 6f70f09bee..4ba1795137 100644
--- a/test/Headers/Inputs/include/math.h
+++ b/test/Headers/Inputs/include/math.h
@@ -1 +1,5 @@
#pragma once
+
+double sqrt(double);
+double pow(double, double);
+double modf(double, double*);
diff --git a/test/Headers/float.c b/test/Headers/float.c
index 74ebb8437f..70c11b0537 100644
--- a/test/Headers/float.c
+++ b/test/Headers/float.c
@@ -1,6 +1,9 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c89 -ffreestanding %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c99 -ffreestanding %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -ffreestanding %s
+// RUN: %clang_cc1 -fsyntax-only -verify -xc++ -std=c++11 -ffreestanding %s
+// RUN: %clang_cc1 -fsyntax-only -verify -xc++ -std=c++14 -ffreestanding %s
+// RUN: %clang_cc1 -fsyntax-only -verify -xc++ -std=c++17 -ffreestanding %s
// expected-no-diagnostics
/* Basic floating point conformance checks against:
@@ -11,7 +14,7 @@
/*
C11, 5.2.4.2.2p11, pp. 30
C99, 5.2.4.2.2p9, pp. 25
- C89, 2.2.4.2
+ C89, 2.2.4.2
*/
#include <float.h>
@@ -42,7 +45,7 @@
#endif
-#if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__)
+#if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) || __cplusplus >= 201703L
#ifndef FLT_DECIMAL_DIG
#error "Mandatory macro FLT_DECIMAL_DIG is missing."
#elif FLT_DECIMAL_DIG < 6
@@ -98,7 +101,7 @@
#endif
-#if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__)
+#if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) || __cplusplus >= 201103L
#ifndef DECIMAL_DIG
#error "Mandatory macro DECIMAL_DIG is missing."
#elif DECIMAL_DIG < 10
@@ -212,13 +215,13 @@ _Static_assert(FLT_MANT_DIG == __FLT_MANT_DIG__, "");
_Static_assert(DBL_MANT_DIG == __DBL_MANT_DIG__, "");
_Static_assert(LDBL_MANT_DIG == __LDBL_MANT_DIG__, "");
-#if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__)
+#if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) || __cplusplus >= 201703L
_Static_assert(FLT_DECIMAL_DIG == __FLT_DECIMAL_DIG__, "");
_Static_assert(DBL_DECIMAL_DIG == __DBL_DECIMAL_DIG__, "");
_Static_assert(LDBL_DECIMAL_DIG == __LDBL_DECIMAL_DIG__, "");
#endif
-#if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__)
+#if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) || __cplusplus >= 201103L
_Static_assert(DECIMAL_DIG == __DECIMAL_DIG__, "");
#endif
diff --git a/test/Headers/float16.c b/test/Headers/float16.c
index 3b905adb33..90ba053b28 100644
--- a/test/Headers/float16.c
+++ b/test/Headers/float16.c
@@ -1,7 +1,11 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c89 -ffreestanding %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c99 -ffreestanding %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -ffreestanding %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -x c++ -ffreestanding %s
+// RUN: %clang_cc1 -triple=aarch64-none-none -fsyntax-only -verify -std=c89 \
+// RUN: -ffreestanding %s
+// RUN: %clang_cc1 -triple=aarch64-none-none -fsyntax-only -verify \
+// RUN: -std=c99 -ffreestanding %s
+// RUN: %clang_cc1 -triple=aarch64-none-none -fsyntax-only -verify -std=c11 \
+// RUN: -ffreestanding %s
+// RUN: %clang_cc1 -triple=aarch64-none-none -fsyntax-only -verify \
+// RUN: -std=c++11 -x c++ -ffreestanding %s
// expected-no-diagnostics
#define __STDC_WANT_IEC_60559_TYPES_EXT__
diff --git a/test/Headers/max_align.c b/test/Headers/max_align.c
new file mode 100644
index 0000000000..283a7a8770
--- /dev/null
+++ b/test/Headers/max_align.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c11 -verify %s
+// expected-no-diagnostics
+
+// XFAIL: windows-
+
+#ifndef __BIGGEST_ALIGNMENT__
+#error __BIGGEST_ALIGNMENT__ not defined
+#endif
+
+#include <stddef.h>
+
+_Static_assert(__BIGGEST_ALIGNMENT__ == _Alignof(max_align_t), "");
diff --git a/test/Headers/ms-arm64-intrin.cpp b/test/Headers/ms-arm64-intrin.cpp
index 729ca5e7f2..2e052b33bf 100644
--- a/test/Headers/ms-arm64-intrin.cpp
+++ b/test/Headers/ms-arm64-intrin.cpp
@@ -14,16 +14,16 @@ void check_nop() {
}
unsigned short check_byteswap_ushort(unsigned short val) {
-// CHECK: call i16 @llvm.bswap.i16(i16 %val)
+// CHECK: call i16 @_byteswap_ushort(i16 %val)
return _byteswap_ushort(val);
}
unsigned long check_byteswap_ulong(unsigned long val) {
-// CHECK: call i32 @llvm.bswap.i32(i32 %val)
+// CHECK: call i32 @_byteswap_ulong(i32 %val)
return _byteswap_ulong(val);
}
unsigned __int64 check_byteswap_uint64(unsigned __int64 val) {
-// CHECK: call i64 @llvm.bswap.i64(i64 %val)
+// CHECK: call i64 @_byteswap_uint64(i64 %val)
return _byteswap_uint64(val);
}
diff --git a/test/Headers/ms-intrin.cpp b/test/Headers/ms-intrin.cpp
index b0fef9cc06..18bb798203 100644
--- a/test/Headers/ms-intrin.cpp
+++ b/test/Headers/ms-intrin.cpp
@@ -49,7 +49,9 @@ void f() {
int info[4];
__cpuid(info, 0);
__cpuidex(info, 0, 0);
+#if defined(_M_X64) || defined(_M_IX86)
_xgetbv(0);
+#endif
__halt();
__nop();
__readmsr(0);
diff --git a/test/Headers/nvptx_device_cmath_functions.c b/test/Headers/nvptx_device_cmath_functions.c
new file mode 100644
index 0000000000..aa55c1eb65
--- /dev/null
+++ b/test/Headers/nvptx_device_cmath_functions.c
@@ -0,0 +1,21 @@
+// Test calling of device math functions.
+///==========================================================================///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include cmath -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include cmath -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
+
+#include <cmath>
+
+void test_sqrt(double a1) {
+ #pragma omp target
+ {
+ // CHECK-YES: call double @__nv_sqrt(double
+ double l1 = sqrt(a1);
+ // CHECK-YES: call double @__nv_pow(double
+ double l2 = pow(a1, a1);
+ // CHECK-YES: call double @__nv_modf(double
+ double l3 = modf(a1 + 3.5, &a1);
+ }
+}
diff --git a/test/Headers/nvptx_device_cmath_functions.cpp b/test/Headers/nvptx_device_cmath_functions.cpp
new file mode 100644
index 0000000000..a5b4377413
--- /dev/null
+++ b/test/Headers/nvptx_device_cmath_functions.cpp
@@ -0,0 +1,21 @@
+// Test calling of device math functions.
+///==========================================================================///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include cmath -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include cmath -internal-isystem %S/Inputs/include -include stdlib.h -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
+
+#include <cmath>
+
+void test_sqrt(double a1) {
+ #pragma omp target
+ {
+ // CHECK-YES: call double @__nv_sqrt(double
+ double l1 = sqrt(a1);
+ // CHECK-YES: call double @__nv_pow(double
+ double l2 = pow(a1, a1);
+ // CHECK-YES: call double @__nv_modf(double
+ double l3 = modf(a1 + 3.5, &a1);
+ }
+}
diff --git a/test/Headers/nvptx_device_math_functions.c b/test/Headers/nvptx_device_math_functions.c
new file mode 100644
index 0000000000..733ad52bd1
--- /dev/null
+++ b/test/Headers/nvptx_device_math_functions.c
@@ -0,0 +1,21 @@
+// Test calling of device math functions.
+///==========================================================================///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include math.h -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
+
+#include <math.h>
+
+void test_sqrt(double a1) {
+ #pragma omp target
+ {
+ // CHECK-YES: call double @__nv_sqrt(double
+ double l1 = sqrt(a1);
+ // CHECK-YES: call double @__nv_pow(double
+ double l2 = pow(a1, a1);
+ // CHECK-YES: call double @__nv_modf(double
+ double l3 = modf(a1 + 3.5, &a1);
+ }
+}
diff --git a/test/Headers/nvptx_device_math_functions.cpp b/test/Headers/nvptx_device_math_functions.cpp
new file mode 100644
index 0000000000..9753011243
--- /dev/null
+++ b/test/Headers/nvptx_device_math_functions.cpp
@@ -0,0 +1,21 @@
+// Test calling of device math functions.
+///==========================================================================///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include math.h -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -internal-isystem %S/Inputs/include -include stdlib.h -include limits -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
+
+#include <math.h>
+
+void test_sqrt(double a1) {
+ #pragma omp target
+ {
+ // CHECK-YES: call double @__nv_sqrt(double
+ double l1 = sqrt(a1);
+ // CHECK-YES: call double @__nv_pow(double
+ double l2 = pow(a1, a1);
+ // CHECK-YES: call double @__nv_modf(double
+ double l3 = modf(a1 + 3.5, &a1);
+ }
+}
diff --git a/test/Headers/opencl-c-header.cl b/test/Headers/opencl-c-header.cl
index b26e61bf1a..14c2e78444 100644
--- a/test/Headers/opencl-c-header.cl
+++ b/test/Headers/opencl-c-header.cl
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify | FileCheck %s
-// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL1.1| FileCheck %s
-// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL1.2| FileCheck %s
+// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL1.1 | FileCheck %s
+// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL1.2 | FileCheck %s
+// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=c++ | FileCheck %s --check-prefix=CHECK20
// Test including the default header as a module.
// The module should be compiled only once and loaded from cache afterwards.
@@ -52,22 +53,21 @@
// CHECK: _Z16convert_char_rtec
// CHECK-NOT: _Z3ctzc
// CHECK20: _Z3ctzc
-// CHECK20-NOT: _Z16convert_char_rtec
+// CHECK20: _Z16convert_char_rtec
char f(char x) {
-#if __OPENCL_C_VERSION__ != CL_VERSION_2_0
- return convert_char_rte(x);
-
-#else //__OPENCL_C_VERSION__
+// Check functionality from OpenCL 2.0 onwards
+#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0)
ndrange_t t;
- return ctz(x);
+ x = ctz(x);
#endif //__OPENCL_C_VERSION__
+ return convert_char_rte(x);
}
// Verify that a builtin using a write_only image3d_t type is available
// from OpenCL 2.0 onwards.
// CHECK20: _Z12write_imagef14ocl_image3d_wo
-#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
+#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
void test_image3dwo(write_only image3d_t img) {
write_imagef(img, (0), (0.0f));
}
@@ -75,7 +75,7 @@ void test_image3dwo(write_only image3d_t img) {
// Verify that non-builtin cl_intel_planar_yuv extension is defined from
// OpenCL 1.2 onwards.
-#if (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
+#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
// expected-no-diagnostics
#ifndef cl_intel_planar_yuv
#error "Missing cl_intel_planar_yuv define"
diff --git a/test/Headers/ppc-intrinsics.c b/test/Headers/ppc-intrinsics.c
new file mode 100644
index 0000000000..622ce90c76
--- /dev/null
+++ b/test/Headers/ppc-intrinsics.c
@@ -0,0 +1,13 @@
+// REQUIRES: powerpc-registered-target
+
+// RUN: %clang -S -emit-llvm -DNO_WARN_X86_INTRINSICS -target powerpc64-gnu-linux %s -Xclang -verify -o - | FileCheck %s
+// RUN: %clang -S -emit-llvm -DNO_WARN_X86_INTRINSICS -target powerpc64-gnu-linux %s -Xclang -verify -x c++ -o - | FileCheck %s
+// expected-no-diagnostics
+
+// RUN: not %clang -S -emit-llvm -target powerpc64-gnu-linux %s -o /dev/null 2>&1 | FileCheck %s -check-prefix=CHECK-ERROR
+
+#include <mmintrin.h>
+// CHECK-ERROR: mmintrin.h:{{[0-9]+}}:{{[0-9]+}}: error: "Please read comment above. Use -DNO_WARN_X86_INTRINSICS to disable this error."
+
+// CHECK: target triple = "powerpc64-
+// CHECK: !llvm.module.flags =
diff --git a/test/Headers/x86-intrinsics-headers-clean.cpp b/test/Headers/x86-intrinsics-headers-clean.cpp
index c75f0910f5..0a0679064c 100644
--- a/test/Headers/x86-intrinsics-headers-clean.cpp
+++ b/test/Headers/x86-intrinsics-headers-clean.cpp
@@ -1,14 +1,8 @@
// Make sure the intrinsic headers compile cleanly with no warnings or errors.
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wsystem-headers \
-// RUN: -fsyntax-only -x c++ -Wno-ignored-attributes -verify %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wsystem-headers \
-// RUN: -fsyntax-only -x c++ -Wno-ignored-attributes -target-feature +f16c \
-// RUN: -verify %s
+// RUN: %clang_cc1 -ffreestanding -triple x86_64-unknown-unknown -Wsystem-headers \
+// RUN: -fsyntax-only -fno-lax-vector-conversions -x c++ -verify %s
// expected-no-diagnostics
-// Dont' include mm_malloc.h. It's system specific.
-#define __MM_MALLOC_H
-
#include <x86intrin.h>