summaryrefslogtreecommitdiff
path: root/test/Sema
diff options
context:
space:
mode:
Diffstat (limited to 'test/Sema')
-rw-r--r--test/Sema/Inputs/pragma-align-no-header-change-warning.h5
-rw-r--r--test/Sema/_Float128.c22
-rw-r--r--test/Sema/aarch64-neon-fp16-ranges.c64
-rw-r--r--test/Sema/aarch64-neon-ranges.c150
-rw-r--r--test/Sema/address_spaces.c1
-rw-r--r--test/Sema/alloc-size.c12
-rw-r--r--test/Sema/annotate.c6
-rw-r--r--test/Sema/arm-asm.c7
-rw-r--r--test/Sema/arm-neon-types.c2
-rw-r--r--test/Sema/arm-no-fp16.c76
-rw-r--r--test/Sema/arm64-inline-asm.c6
-rw-r--r--test/Sema/artificial.c4
-rw-r--r--test/Sema/assign.c8
-rw-r--r--test/Sema/ast-print.c44
-rw-r--r--test/Sema/atomic-ops.c164
-rw-r--r--test/Sema/attr-availability-square-brackets.c25
-rw-r--r--test/Sema/attr-availability-tvos.c2
-rw-r--r--test/Sema/attr-availability-watchos.c2
-rw-r--r--test/Sema/attr-cpuspecific.c96
-rw-r--r--test/Sema/attr-cx2.c26
-rw-r--r--test/Sema/attr-external-source-symbol.c14
-rw-r--r--test/Sema/attr-format_arg.c17
-rw-r--r--test/Sema/attr-ifunc.c2
-rw-r--r--test/Sema/attr-min-vector-width.c16
-rw-r--r--test/Sema/attr-nocf_check.c23
-rw-r--r--test/Sema/attr-nocf_check.cpp23
-rw-r--r--test/Sema/attr-objc-bridge-related.m7
-rw-r--r--test/Sema/attr-ownership.c2
-rw-r--r--test/Sema/attr-ownership.cpp7
-rw-r--r--test/Sema/attr-print.c3
-rw-r--r--test/Sema/attr-target-ast.c5
-rw-r--r--test/Sema/attr-target-mv-bad-target.c10
-rw-r--r--test/Sema/attr-target-mv.c103
-rw-r--r--test/Sema/attr-target-unsupported.c12
-rw-r--r--test/Sema/attr-target.c25
-rw-r--r--test/Sema/attr-type-safety.c45
-rw-r--r--test/Sema/attr-used.c4
-rw-r--r--test/Sema/attr-weak.c3
-rw-r--r--test/Sema/availability-guard-format.mm15
-rw-r--r--test/Sema/bitfield.c4
-rw-r--r--test/Sema/bittest-intrinsics.c84
-rw-r--r--test/Sema/builtin-classify-type.c19
-rw-r--r--test/Sema/builtin-dump-struct.c42
-rw-r--r--test/Sema/builtin-object-size.c6
-rw-r--r--test/Sema/builtin-prefetch.c6
-rw-r--r--test/Sema/builtin-redecl.cpp18
-rw-r--r--test/Sema/builtins-arm.c39
-rw-r--r--test/Sema/builtins-arm64.c14
-rw-r--r--test/Sema/builtins-hexagon-v55.c17
-rw-r--r--test/Sema/builtins-hexagon-v60.c16
-rw-r--r--test/Sema/builtins-hexagon-v62.c15
-rw-r--r--test/Sema/builtins-hexagon-v65.c15
-rw-r--r--test/Sema/builtins-hvx-none.c26
-rw-r--r--test/Sema/builtins-hvx-v60.c25
-rw-r--r--test/Sema/builtins-hvx-v62.c24
-rw-r--r--test/Sema/builtins-hvx-v65.c23
-rw-r--r--test/Sema/builtins-ppc.c34
-rw-r--r--test/Sema/builtins-x86.c119
-rw-r--r--test/Sema/builtins-x86.cpp24
-rw-r--r--test/Sema/builtins.c28
-rw-r--r--test/Sema/compare.c15
-rw-r--r--test/Sema/complex-int.c4
-rw-r--r--test/Sema/constant-builtins-2.c25
-rw-r--r--test/Sema/conversion.c19
-rw-r--r--test/Sema/cxx-as-c.c9
-rw-r--r--test/Sema/darwin-tls.c6
-rw-r--r--test/Sema/diagnose_if.c10
-rw-r--r--test/Sema/error-type-safety.cpp39
-rw-r--r--test/Sema/ext_vector_comparisons.c12
-rw-r--r--test/Sema/float128-ld-incompatibility.cpp5
-rw-r--r--test/Sema/inline-asm-validate-amdgpu.cl5
-rw-r--r--test/Sema/integer-overflow.c15
-rw-r--r--test/Sema/internal_linkage.c8
-rw-r--r--test/Sema/mms-bitfields.c15
-rw-r--r--test/Sema/ms_wide_predefined_expr.cpp2
-rw-r--r--test/Sema/multistep-explicit-cast.c70
-rw-r--r--test/Sema/no_stack_protector.c5
-rw-r--r--test/Sema/nocf_check_attr_not_allowed.c5
-rw-r--r--test/Sema/nonnull.c4
-rw-r--r--test/Sema/pr30372.c2
-rw-r--r--test/Sema/pragma-align-no-header-change-warning.c5
-rw-r--r--test/Sema/preserve-call-conv.c1
-rw-r--r--test/Sema/redefine_extname.c1
-rw-r--r--test/Sema/return.c12
-rw-r--r--test/Sema/riscv-interrupt-attr.c62
-rw-r--r--test/Sema/riscv-interrupt-attr.cpp16
-rw-r--r--test/Sema/self-comparison.c7
-rw-r--r--test/Sema/sign-compare-enum.c79
-rw-r--r--test/Sema/switch.c2
-rw-r--r--test/Sema/tautological-constant-compare.c44
-rw-r--r--test/Sema/tautological-constant-enum-compare.c4
-rw-r--r--test/Sema/tautological-unsigned-enum-zero-compare.c3
-rw-r--r--test/Sema/tautological-unsigned-enum-zero-compare.cpp3
-rw-r--r--test/Sema/tautological-unsigned-zero-compare.c43
-rw-r--r--test/Sema/tls.c4
-rw-r--r--test/Sema/transparent-union.c29
-rw-r--r--test/Sema/transpose-memset.c61
-rw-r--r--test/Sema/typedef-retain.c4
-rw-r--r--test/Sema/typo-correction.c13
-rw-r--r--test/Sema/uninit-variables.c2
-rw-r--r--test/Sema/varargs.c9
-rw-r--r--test/Sema/vector-gcc-compat.c2
-rw-r--r--test/Sema/vector-gcc-compat.cpp2
-rw-r--r--test/Sema/vla.c21
-rw-r--r--test/Sema/warn-cast-qual.c10
-rw-r--r--test/Sema/warn-documentation.m4
-rw-r--r--test/Sema/warn-duplicate-enum.c20
-rw-r--r--test/Sema/warn-strict-prototypes.c6
-rw-r--r--test/Sema/warn-string-conversion.c2
-rw-r--r--test/Sema/warn-type-safety.c8
-rw-r--r--test/Sema/warn-unreachable.c4
-rw-r--r--test/Sema/x86-builtin-palignr.c4
112 files changed, 2116 insertions, 302 deletions
diff --git a/test/Sema/Inputs/pragma-align-no-header-change-warning.h b/test/Sema/Inputs/pragma-align-no-header-change-warning.h
new file mode 100644
index 0000000000000..6cd4e7d7ed1ba
--- /dev/null
+++ b/test/Sema/Inputs/pragma-align-no-header-change-warning.h
@@ -0,0 +1,5 @@
+#pragma options align=mac68k
+
+struct S { int x; };
+
+#pragma options align=reset
diff --git a/test/Sema/_Float128.c b/test/Sema/_Float128.c
deleted file mode 100644
index f0c3c6d555efe..0000000000000
--- a/test/Sema/_Float128.c
+++ /dev/null
@@ -1,22 +0,0 @@
-// RUN: %clang_cc1 -verify %s
-// RUN: %clang_cc1 -triple powerpc64-linux -verify %s
-// RUN: %clang_cc1 -triple i686-windows-gnu -verify %s
-// RUN: %clang_cc1 -triple x86_64-windows-gnu -verify %s
-// RUN: %clang_cc1 -triple x86_64-windows-msvc -verify %s
-
-#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
-_Float128 f;
-_Float128 tiny = __FLT128_EPSILON__;
-int g(int x, _Float128 *y) {
- return x + *y;
-}
-
-// expected-no-diagnostics
-#else
-_Float128 f; // expected-error {{__float128 is not supported on this target}}
-float tiny = __FLT128_EPSILON__; // expected-error{{use of undeclared identifier}}
-int g(int x, _Float128 *y) { // expected-error {{__float128 is not supported on this target}}
- return x + *y;
-}
-
-#endif // defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
diff --git a/test/Sema/aarch64-neon-fp16-ranges.c b/test/Sema/aarch64-neon-fp16-ranges.c
new file mode 100644
index 0000000000000..60190525e042a
--- /dev/null
+++ b/test/Sema/aarch64-neon-fp16-ranges.c
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -triple arm64-linux-gnu -fallow-half-arguments-and-returns -target-feature +neon -target-feature +fullfp16 -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -fallow-half-arguments-and-returns -target-feature +fullfp16 -target-feature +neon -ffreestanding -fsyntax-only -verify %s
+
+#include <arm_neon.h>
+#include <arm_fp16.h>
+
+void test_vcvt_f16_16(int16_t a){
+ vcvth_n_f16_s16(a, 1);
+ vcvth_n_f16_s16(a, 16);
+ vcvth_n_f16_s16(a, 0); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vcvth_n_f16_s16(a, 17); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+
+ vcvth_n_f16_u16(a, 1);
+ vcvth_n_f16_u16(a, 16);
+ vcvth_n_f16_u16(a, 0); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vcvth_n_f16_u16(a, 17); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+}
+
+void test_vcvt_f16_32(int32_t a){
+ vcvth_n_f16_u32(a, 1);
+ vcvth_n_f16_u32(a, 16);
+ vcvth_n_f16_u32(a, 0); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vcvth_n_f16_u32(a, 17); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+
+ vcvth_n_f16_s32(a, 1);
+ vcvth_n_f16_s32(a, 16);
+ vcvth_n_f16_s32(a, 0); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vcvth_n_f16_s32(a, 17); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+}
+
+void test_vcvt_f16_64(int64_t a){
+ vcvth_n_f16_s64(a, 1);
+ vcvth_n_f16_s64(a, 16);
+ vcvth_n_f16_s64(a, 0); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vcvth_n_f16_s64(a, 17); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+}
+
+
+void test_vcvt_su_f(float16_t a){
+ vcvth_n_s16_f16(a, 1);
+ vcvth_n_s16_f16(a, 16);
+ vcvth_n_s16_f16(a, 0); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vcvth_n_s16_f16(a, 17); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+
+ vcvth_n_s32_f16(a, 1);
+ vcvth_n_s32_f16(a, 16);
+ vcvth_n_s32_f16(a, 0); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vcvth_n_s32_f16(a, 17); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+
+ vcvth_n_s64_f16(a, 1);
+ vcvth_n_s64_f16(a, 16);
+ vcvth_n_s64_f16(a, 0); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vcvth_n_s64_f16(a, 17); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+
+ vcvth_n_u16_f16(a, 1);
+ vcvth_n_u16_f16(a, 16);
+ vcvth_n_u16_f16(a, 0); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vcvth_n_u16_f16(a, 17); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+
+ vcvth_n_u32_f16(a, 1);
+ vcvth_n_u32_f16(a, 16);
+ vcvth_n_u32_f16(a, 0); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vcvth_n_u32_f16(a, 17); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+}
diff --git a/test/Sema/aarch64-neon-ranges.c b/test/Sema/aarch64-neon-ranges.c
index 3a170b8f4cb98..f9b652fc9bf5b 100644
--- a/test/Sema/aarch64-neon-ranges.c
+++ b/test/Sema/aarch64-neon-ranges.c
@@ -11,12 +11,12 @@ void test_vext_8bit(int8x8_t small, int8x16_t big) {
vextq_u8(big, big, 15);
vextq_p8(big, big, 15);
- vext_s8(small, small, 8); // expected-error {{argument should be a value from 0 to 7}}
- vext_u8(small, small, 8); // expected-error {{argument should be a value from 0 to 7}}
- vext_p8(small, small, 8); // expected-error {{argument should be a value from 0 to 7}}
- vextq_s8(big, big, 16); // expected-error {{argument should be a value from 0 to 15}}
- vextq_u8(big, big, 16); // expected-error {{argument should be a value from 0 to 15}}
- vextq_p8(big, big, 16); // expected-error {{argument should be a value from 0 to 15}}
+ vext_s8(small, small, 8); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vext_u8(small, small, 8); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vext_p8(small, small, 8); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vextq_s8(big, big, 16); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vextq_u8(big, big, 16); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vextq_p8(big, big, 16); // expected-error-re {{argument value {{.*}} is outside the valid range}}
}
void test_mul_lane_f64(float64x1_t small, float64x2_t big, float64x2_t rhs) {
@@ -29,11 +29,11 @@ void test_mul_lane_f64(float64x1_t small, float64x2_t big, float64x2_t rhs) {
vfmaq_lane_f64(big, big, small, 0);
vfmaq_laneq_f64(big, big, big, 1);
- vmul_lane_f64(small, small, 1); // expected-error {{argument should be a value from 0 to 0}}
- vmul_laneq_f64(small, big, 2); // expected-error {{argument should be a value from 0 to 1}}
- vfma_lane_f64(small, small, small, 1); // expected-error {{argument should be a value from 0 to 0}}
- vfma_laneq_f64(small, small, big, 2); // expected-error {{argument should be a value from 0 to 1}}
- vfmaq_laneq_f64(big, big, big, 2); // expected-error {{argument should be a value from 0 to 1}}
+ vmul_lane_f64(small, small, 1); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vmul_laneq_f64(small, big, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vfma_lane_f64(small, small, small, 1); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vfma_laneq_f64(small, small, big, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vfmaq_laneq_f64(big, big, big, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}
}
void test_ld1st1(int8x8_t small, int8x16_t big, void *addr) {
@@ -47,15 +47,15 @@ void test_ld1st1(int8x8_t small, int8x16_t big, void *addr) {
vld1q_lane_s32(addr, big, 3);
vld1q_lane_s64(addr, big, 1);
- vld1_lane_s8(addr, small, 8); // expected-error {{argument should be a value from 0 to 7}}
- vld1_lane_s16(addr, small, 4); // expected-error {{argument should be a value from 0 to 3}}
- vld1_lane_s32(addr, small, 2); // expected-error {{argument should be a value from 0 to 1}}
- vld1_lane_s64(addr, small, 1); // expected-error {{argument should be a value from 0 to 0}}
+ vld1_lane_s8(addr, small, 8); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vld1_lane_s16(addr, small, 4); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vld1_lane_s32(addr, small, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vld1_lane_s64(addr, small, 1); // expected-error-re {{argument value {{.*}} is outside the valid range}}
- vld1q_lane_s8(addr, big, 16); // expected-error {{argument should be a value from 0 to 15}}
- vld1q_lane_s16(addr, big, 8); // expected-error {{argument should be a value from 0 to 7}}
- vld1q_lane_s32(addr, big, 4); // expected-error {{argument should be a value from 0 to 3}}
- vld1q_lane_s64(addr, big, 2); // expected-error {{argument should be a value from 0 to 1}}
+ vld1q_lane_s8(addr, big, 16); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vld1q_lane_s16(addr, big, 8); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vld1q_lane_s32(addr, big, 4); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vld1q_lane_s64(addr, big, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}
vst1_lane_s8(addr, small, 7);
vst1_lane_s16(addr, small, 3);
@@ -67,15 +67,15 @@ void test_ld1st1(int8x8_t small, int8x16_t big, void *addr) {
vst1q_lane_s32(addr, big, 3);
vst1q_lane_s64(addr, big, 1);
- vst1_lane_s8(addr, small, 8); // expected-error {{argument should be a value from 0 to 7}}
- vst1_lane_s16(addr, small, 4); // expected-error {{argument should be a value from 0 to 3}}
- vst1_lane_s32(addr, small, 2); // expected-error {{argument should be a value from 0 to 1}}
- vst1_lane_s64(addr, small, 1); // expected-error {{argument should be a value from 0 to 0}}
+ vst1_lane_s8(addr, small, 8); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vst1_lane_s16(addr, small, 4); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vst1_lane_s32(addr, small, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vst1_lane_s64(addr, small, 1); // expected-error-re {{argument value {{.*}} is outside the valid range}}
- vst1q_lane_s8(addr, big, 16); // expected-error {{argument should be a value from 0 to 15}}
- vst1q_lane_s16(addr, big, 8); // expected-error {{argument should be a value from 0 to 7}}
- vst1q_lane_s32(addr, big, 4); // expected-error {{argument should be a value from 0 to 3}}
- vst1q_lane_s64(addr, big, 2); // expected-error {{argument should be a value from 0 to 1}}
+ vst1q_lane_s8(addr, big, 16); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vst1q_lane_s16(addr, big, 8); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vst1q_lane_s32(addr, big, 4); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vst1q_lane_s64(addr, big, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}
}
void test_ld2st2(int8x8x2_t small8, int8x16x2_t big8,
@@ -93,15 +93,15 @@ void test_ld2st2(int8x8x2_t small8, int8x16x2_t big8,
vld2q_lane_s32(addr, big32, 3);
vld2q_lane_s64(addr, big64, 1);
- vld2_lane_s8(addr, small8, 8); // expected-error {{argument should be a value from 0 to 7}}
- vld2_lane_s16(addr, small16, 4); // expected-error {{argument should be a value from 0 to 3}}
- vld2_lane_s32(addr, small32, 2); // expected-error {{argument should be a value from 0 to 1}}
- vld2_lane_s64(addr, small64, 1); // expected-error {{argument should be a value from 0 to 0}}
+ vld2_lane_s8(addr, small8, 8); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vld2_lane_s16(addr, small16, 4); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vld2_lane_s32(addr, small32, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vld2_lane_s64(addr, small64, 1); // expected-error-re {{argument value {{.*}} is outside the valid range}}
- vld2q_lane_s8(addr, big8, 16); // expected-error {{argument should be a value from 0 to 15}}
- vld2q_lane_s16(addr, big16, 8); // expected-error {{argument should be a value from 0 to 7}}
- vld2q_lane_s32(addr, big32, 4); // expected-error {{argument should be a value from 0 to 3}}
- vld2q_lane_s64(addr, big64, 2); // expected-error {{argument should be a value from 0 to 1}}
+ vld2q_lane_s8(addr, big8, 16); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vld2q_lane_s16(addr, big16, 8); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vld2q_lane_s32(addr, big32, 4); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vld2q_lane_s64(addr, big64, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}
vst2_lane_s8(addr, small8, 7);
vst2_lane_s16(addr, small16, 3);
@@ -113,15 +113,15 @@ void test_ld2st2(int8x8x2_t small8, int8x16x2_t big8,
vst2q_lane_s32(addr, big32, 3);
vst2q_lane_s64(addr, big64, 1);
- vst2_lane_s8(addr, small8, 8); // expected-error {{argument should be a value from 0 to 7}}
- vst2_lane_s16(addr, small16, 4); // expected-error {{argument should be a value from 0 to 3}}
- vst2_lane_s32(addr, small32, 2); // expected-error {{argument should be a value from 0 to 1}}
- vst2_lane_s64(addr, small64, 1); // expected-error {{argument should be a value from 0 to 0}}
+ vst2_lane_s8(addr, small8, 8); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vst2_lane_s16(addr, small16, 4); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vst2_lane_s32(addr, small32, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vst2_lane_s64(addr, small64, 1); // expected-error-re {{argument value {{.*}} is outside the valid range}}
- vst2q_lane_s8(addr, big8, 16); // expected-error {{argument should be a value from 0 to 15}}
- vst2q_lane_s16(addr, big16, 8); // expected-error {{argument should be a value from 0 to 7}}
- vst2q_lane_s32(addr, big32, 4); // expected-error {{argument should be a value from 0 to 3}}
- vst2q_lane_s64(addr, big64, 2); // expected-error {{argument should be a value from 0 to 1}}
+ vst2q_lane_s8(addr, big8, 16); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vst2q_lane_s16(addr, big16, 8); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vst2q_lane_s32(addr, big32, 4); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vst2q_lane_s64(addr, big64, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}
}
void test_ld3st3(int8x8x3_t small8, int8x16x3_t big8,
@@ -139,15 +139,15 @@ void test_ld3st3(int8x8x3_t small8, int8x16x3_t big8,
vld3q_lane_s32(addr, big32, 3);
vld3q_lane_s64(addr, big64, 1);
- vld3_lane_s8(addr, small8, 8); // expected-error {{argument should be a value from 0 to 7}}
- vld3_lane_s16(addr, small16, 4); // expected-error {{argument should be a value from 0 to 3}}
- vld3_lane_s32(addr, small32, 2); // expected-error {{argument should be a value from 0 to 1}}
- vld3_lane_s64(addr, small64, 1); // expected-error {{argument should be a value from 0 to 0}}
+ vld3_lane_s8(addr, small8, 8); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vld3_lane_s16(addr, small16, 4); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vld3_lane_s32(addr, small32, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vld3_lane_s64(addr, small64, 1); // expected-error-re {{argument value {{.*}} is outside the valid range}}
- vld3q_lane_s8(addr, big8, 16); // expected-error {{argument should be a value from 0 to 15}}
- vld3q_lane_s16(addr, big16, 8); // expected-error {{argument should be a value from 0 to 7}}
- vld3q_lane_s32(addr, big32, 4); // expected-error {{argument should be a value from 0 to 3}}
- vld3q_lane_s64(addr, big64, 2); // expected-error {{argument should be a value from 0 to 1}}
+ vld3q_lane_s8(addr, big8, 16); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vld3q_lane_s16(addr, big16, 8); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vld3q_lane_s32(addr, big32, 4); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vld3q_lane_s64(addr, big64, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}
vst3_lane_s8(addr, small8, 7);
vst3_lane_s16(addr, small16, 3);
@@ -159,15 +159,15 @@ void test_ld3st3(int8x8x3_t small8, int8x16x3_t big8,
vst3q_lane_s32(addr, big32, 3);
vst3q_lane_s64(addr, big64, 1);
- vst3_lane_s8(addr, small8, 8); // expected-error {{argument should be a value from 0 to 7}}
- vst3_lane_s16(addr, small16, 4); // expected-error {{argument should be a value from 0 to 3}}
- vst3_lane_s32(addr, small32, 2); // expected-error {{argument should be a value from 0 to 1}}
- vst3_lane_s64(addr, small64, 1); // expected-error {{argument should be a value from 0 to 0}}
+ vst3_lane_s8(addr, small8, 8); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vst3_lane_s16(addr, small16, 4); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vst3_lane_s32(addr, small32, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vst3_lane_s64(addr, small64, 1); // expected-error-re {{argument value {{.*}} is outside the valid range}}
- vst3q_lane_s8(addr, big8, 16); // expected-error {{argument should be a value from 0 to 15}}
- vst3q_lane_s16(addr, big16, 8); // expected-error {{argument should be a value from 0 to 7}}
- vst3q_lane_s32(addr, big32, 4); // expected-error {{argument should be a value from 0 to 3}}
- vst3q_lane_s64(addr, big64, 2); // expected-error {{argument should be a value from 0 to 1}}
+ vst3q_lane_s8(addr, big8, 16); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vst3q_lane_s16(addr, big16, 8); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vst3q_lane_s32(addr, big32, 4); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vst3q_lane_s64(addr, big64, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}
}
void test_ld4st4(int8x8x4_t small8, int8x16x4_t big8,
@@ -185,15 +185,15 @@ void test_ld4st4(int8x8x4_t small8, int8x16x4_t big8,
vld4q_lane_s32(addr, big32, 3);
vld4q_lane_s64(addr, big64, 1);
- vld4_lane_s8(addr, small8, 8); // expected-error {{argument should be a value from 0 to 7}}
- vld4_lane_s16(addr, small16, 4); // expected-error {{argument should be a value from 0 to 3}}
- vld4_lane_s32(addr, small32, 2); // expected-error {{argument should be a value from 0 to 1}}
- vld4_lane_s64(addr, small64, 1); // expected-error {{argument should be a value from 0 to 0}}
+ vld4_lane_s8(addr, small8, 8); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vld4_lane_s16(addr, small16, 4); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vld4_lane_s32(addr, small32, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vld4_lane_s64(addr, small64, 1); // expected-error-re {{argument value {{.*}} is outside the valid range}}
- vld4q_lane_s8(addr, big8, 16); // expected-error {{argument should be a value from 0 to 15}}
- vld4q_lane_s16(addr, big16, 8); // expected-error {{argument should be a value from 0 to 7}}
- vld4q_lane_s32(addr, big32, 4); // expected-error {{argument should be a value from 0 to 3}}
- vld4q_lane_s64(addr, big64, 2); // expected-error {{argument should be a value from 0 to 1}}
+ vld4q_lane_s8(addr, big8, 16); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vld4q_lane_s16(addr, big16, 8); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vld4q_lane_s32(addr, big32, 4); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vld4q_lane_s64(addr, big64, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}
vst4_lane_s8(addr, small8, 7);
vst4_lane_s16(addr, small16, 3);
@@ -205,14 +205,14 @@ void test_ld4st4(int8x8x4_t small8, int8x16x4_t big8,
vst4q_lane_s32(addr, big32, 3);
vst4q_lane_s64(addr, big64, 1);
- vst4_lane_s8(addr, small8, 8); // expected-error {{argument should be a value from 0 to 7}}
- vst4_lane_s16(addr, small16, 4); // expected-error {{argument should be a value from 0 to 3}}
- vst4_lane_s32(addr, small32, 2); // expected-error {{argument should be a value from 0 to 1}}
- vst4_lane_s64(addr, small64, 1); // expected-error {{argument should be a value from 0 to 0}}
+ vst4_lane_s8(addr, small8, 8); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vst4_lane_s16(addr, small16, 4); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vst4_lane_s32(addr, small32, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vst4_lane_s64(addr, small64, 1); // expected-error-re {{argument value {{.*}} is outside the valid range}}
- vst4q_lane_s8(addr, big8, 16); // expected-error {{argument should be a value from 0 to 15}}
- vst4q_lane_s16(addr, big16, 8); // expected-error {{argument should be a value from 0 to 7}}
- vst4q_lane_s32(addr, big32, 4); // expected-error {{argument should be a value from 0 to 3}}
- vst4q_lane_s64(addr, big64, 2); // expected-error {{argument should be a value from 0 to 1}}
+ vst4q_lane_s8(addr, big8, 16); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vst4q_lane_s16(addr, big16, 8); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vst4q_lane_s32(addr, big32, 4); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vst4q_lane_s64(addr, big64, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}
}
diff --git a/test/Sema/address_spaces.c b/test/Sema/address_spaces.c
index 018a8521bfc50..87707d7deb0de 100644
--- a/test/Sema/address_spaces.c
+++ b/test/Sema/address_spaces.c
@@ -14,6 +14,7 @@ void foo(_AS3 float *a,
int _AS1 _AS2 *Y; // expected-error {{multiple address spaces specified for type}}
int *_AS1 _AS2 *Z; // expected-error {{multiple address spaces specified for type}}
+ int *_AS1 _AS1 *M; // expected-warning {{multiple identical address spaces specified for type}}
_AS1 int local; // expected-error {{automatic variable qualified with an address space}}
_AS1 int array[5]; // expected-error {{automatic variable qualified with an address space}}
diff --git a/test/Sema/alloc-size.c b/test/Sema/alloc-size.c
index 7004a5a7d7f6f..56181511a1948 100644
--- a/test/Sema/alloc-size.c
+++ b/test/Sema/alloc-size.c
@@ -3,14 +3,14 @@
void *fail1(int a) __attribute__((alloc_size)); //expected-error{{'alloc_size' attribute takes at least 1 argument}}
void *fail2(int a) __attribute__((alloc_size())); //expected-error{{'alloc_size' attribute takes at least 1 argument}}
-void *fail3(int a) __attribute__((alloc_size(0))); //expected-error{{'alloc_size' attribute parameter 0 is out of bounds}}
-void *fail4(int a) __attribute__((alloc_size(2))); //expected-error{{'alloc_size' attribute parameter 2 is out of bounds}}
+void *fail3(int a) __attribute__((alloc_size(0))); //expected-error{{'alloc_size' attribute parameter 1 is out of bounds}}
+void *fail4(int a) __attribute__((alloc_size(2))); //expected-error{{'alloc_size' attribute parameter 1 is out of bounds}}
-void *fail5(int a, int b) __attribute__((alloc_size(0, 1))); //expected-error{{'alloc_size' attribute parameter 0 is out of bounds}}
-void *fail6(int a, int b) __attribute__((alloc_size(3, 1))); //expected-error{{'alloc_size' attribute parameter 3 is out of bounds}}
+void *fail5(int a, int b) __attribute__((alloc_size(0, 1))); //expected-error{{'alloc_size' attribute parameter 1 is out of bounds}}
+void *fail6(int a, int b) __attribute__((alloc_size(3, 1))); //expected-error{{'alloc_size' attribute parameter 1 is out of bounds}}
-void *fail7(int a, int b) __attribute__((alloc_size(1, 0))); //expected-error{{'alloc_size' attribute parameter 0 is out of bounds}}
-void *fail8(int a, int b) __attribute__((alloc_size(1, 3))); //expected-error{{'alloc_size' attribute parameter 3 is out of bounds}}
+void *fail7(int a, int b) __attribute__((alloc_size(1, 0))); //expected-error{{'alloc_size' attribute parameter 2 is out of bounds}}
+void *fail8(int a, int b) __attribute__((alloc_size(1, 3))); //expected-error{{'alloc_size' attribute parameter 2 is out of bounds}}
int fail9(int a) __attribute__((alloc_size(1))); //expected-warning{{'alloc_size' attribute only applies to return values that are pointers}}
diff --git a/test/Sema/annotate.c b/test/Sema/annotate.c
index 4a786d0a0163c..0d1a1c29a3109 100644
--- a/test/Sema/annotate.c
+++ b/test/Sema/annotate.c
@@ -1,9 +1,13 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify
+// RUN: %clang_cc1 %s -fsyntax-only -fdouble-square-bracket-attributes -verify
void __attribute__((annotate("foo"))) foo(float *a) {
__attribute__((annotate("bar"))) int x;
+ [[clang::annotate("bar")]] int x2;
__attribute__((annotate(1))) int y; // expected-error {{'annotate' attribute requires a string}}
+ [[clang::annotate(1)]] int y2; // expected-error {{'annotate' attribute requires a string}}
__attribute__((annotate("bar", 1))) int z; // expected-error {{'annotate' attribute takes one argument}}
+ [[clang::annotate("bar", 1)]] int z2; // expected-error {{'annotate' attribute takes one argument}}
+
int u = __builtin_annotation(z, (char*) 0); // expected-error {{second argument to __builtin_annotation must be a non-wide string constant}}
int v = __builtin_annotation(z, (char*) L"bar"); // expected-error {{second argument to __builtin_annotation must be a non-wide string constant}}
int w = __builtin_annotation(z, "foo");
diff --git a/test/Sema/arm-asm.c b/test/Sema/arm-asm.c
index e48718b0a2aca..24fb5a7ecd82a 100644
--- a/test/Sema/arm-asm.c
+++ b/test/Sema/arm-asm.c
@@ -10,3 +10,10 @@ void test_64bit_r(void) {
long long foo = 0, bar = 0;
asm volatile("INST %0, %1" : "=r"(foo) : "r"(bar));
}
+
+void test_clobber_conflict(void) {
+ register int x asm("r1");
+ asm volatile("nop" :: "r"(x) : "%r1"); // expected-error {{conflicts with asm clobber list}}
+ asm volatile("nop" :: "l"(x) : "%r1"); // expected-error {{conflicts with asm clobber list}}
+ asm volatile("nop" : "=r"(x) :: "%r1"); // expected-error {{conflicts with asm clobber list}}
+}
diff --git a/test/Sema/arm-neon-types.c b/test/Sema/arm-neon-types.c
index a5ee708b50344..989f20ab20ec5 100644
--- a/test/Sema/arm-neon-types.c
+++ b/test/Sema/arm-neon-types.c
@@ -17,7 +17,7 @@ float32x2_t test2(uint32x2_t x) {
float32x2_t test3(uint32x2_t x) {
// FIXME: The "incompatible result type" error is due to pr10112 and should be
// removed when that is fixed.
- return vcvt_n_f32_u32(x, 0); // expected-error {{argument should be a value from 1 to 32}}
+ return vcvt_n_f32_u32(x, 0); // expected-error-re {{argument value {{.*}} is outside the valid range}}
}
typedef signed int vSInt32 __attribute__((__vector_size__(16)));
diff --git a/test/Sema/arm-no-fp16.c b/test/Sema/arm-no-fp16.c
index 6443d83198ce8..2a23270e92d86 100644
--- a/test/Sema/arm-no-fp16.c
+++ b/test/Sema/arm-no-fp16.c
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -triple thumbv7-none-eabi %s -target-feature +neon -target-feature -fp16 -fsyntax-only -verify
+// RUN: %clang_cc1 -triple thumbv7-none-eabi %s -target-feature +neon \
+// RUN: -fallow-half-arguments-and-returns -target-feature -fp16 \
+// RUN: -fsyntax-only -verify
#include <arm_neon.h>
@@ -9,3 +11,75 @@ float16x4_t test_vcvt_f16_f32(float32x4_t a) {
float32x4_t test_vcvt_f32_f16(float16x4_t a) {
return vcvt_f32_f16(a); // expected-warning{{implicit declaration of function 'vcvt_f32_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float32x4_t'}}
}
+
+float16x4_t test_vrnda_f16(float16x4_t a) {
+ return vrnda_f16(a); // expected-warning{{implicit declaration of function 'vrnda_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x4_t'}}
+}
+
+float16x8_t test_vrndaq_f16(float16x8_t a) {
+ return vrndaq_f16(a); // expected-warning{{implicit declaration of function 'vrndaq_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x8_t'}}
+}
+
+float16x4_t test_vrnd_f16(float16x4_t a) {
+ return vrnd_f16(a); // expected-warning{{implicit declaration of function 'vrnd_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x4_t'}}
+}
+
+float16x8_t test_vrndq_f16(float16x8_t a) {
+ return vrndq_f16(a); // expected-warning{{implicit declaration of function 'vrndq_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x8_t'}}
+}
+
+float16x4_t test_vrndi_f16(float16x4_t a) {
+ return vrndi_f16(a); // expected-warning{{implicit declaration of function 'vrndi_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x4_t'}}
+}
+
+float16x8_t test_vrndiq_f16(float16x8_t a) {
+ return vrndiq_f16(a); // expected-warning{{implicit declaration of function 'vrndiq_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x8_t'}}
+}
+
+float16x4_t test_vrndm_f16(float16x4_t a) {
+ return vrndm_f16(a); // expected-warning{{implicit declaration of function 'vrndm_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x4_t'}}
+}
+
+float16x8_t test_vrndmq_f16(float16x8_t a) {
+ return vrndmq_f16(a); // expected-warning{{implicit declaration of function 'vrndmq_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x8_t'}}
+}
+
+float16x4_t test_vrndn_f16(float16x4_t a) {
+ return vrndn_f16(a); // expected-warning{{implicit declaration of function 'vrndn_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x4_t'}}
+}
+
+float16x8_t test_vrndnq_f16(float16x8_t a) {
+ return vrndnq_f16(a); // expected-warning{{implicit declaration of function 'vrndnq_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x8_t'}}
+}
+
+float16x4_t test_vrndp_f16(float16x4_t a) {
+ return vrndp_f16(a); // expected-warning{{implicit declaration of function 'vrndp_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x4_t'}}
+}
+
+float16x8_t test_vrndpq_f16(float16x8_t a) {
+ return vrndpq_f16(a); // expected-warning{{implicit declaration of function 'vrndpq_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x8_t'}}
+}
+
+float16x4_t test_vrndx_f16(float16x4_t a) {
+ return vrndx_f16(a); // expected-warning{{implicit declaration of function 'vrndx_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x4_t'}}
+}
+
+float16x8_t test_vrndxq_f16(float16x8_t a) {
+ return vrndxq_f16(a); // expected-warning{{implicit declaration of function 'vrndxq_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x8_t'}}
+}
+
+float16x4_t test_vmaxnm_f16(float16x4_t a, float16x4_t b) {
+ return vmaxnm_f16(a, b); // expected-warning{{implicit declaration of function 'vmaxnm_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x4_t'}}
+}
+
+float16x8_t test_vmaxnmq_f16(float16x8_t a, float16x8_t b) {
+ return vmaxnmq_f16(a, b); // expected-warning{{implicit declaration of function 'vmaxnmq_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x8_t'}}
+}
+
+float16x4_t test_vminnm_f16(float16x4_t a, float16x4_t b) {
+ return vminnm_f16(a, b); // expected-warning{{implicit declaration of function 'vminnm_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x4_t'}}
+}
+
+float16x8_t test_vminnmq_f16(float16x8_t a, float16x8_t b) {
+ return vminnmq_f16(a, b); // expected-warning{{implicit declaration of function 'vminnmq_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x8_t'}}
+}
diff --git a/test/Sema/arm64-inline-asm.c b/test/Sema/arm64-inline-asm.c
index d8e16a6872cc2..541c190e6116d 100644
--- a/test/Sema/arm64-inline-asm.c
+++ b/test/Sema/arm64-inline-asm.c
@@ -7,3 +7,9 @@ void foo() {
asm volatile("USE(%0)" :: "z"(0)); // expected-warning {{value size does not match register size specified by the constraint and modifier}} expected-note {{use constraint modifier "w"}}
}
+
+void test_clobber_conflict(void) {
+ register long x asm("x1");
+ asm volatile("nop" :: "r"(x) : "%x1"); // expected-error {{conflicts with asm clobber list}}
+ asm volatile("nop" : "=r"(x) :: "%x1"); // expected-error {{conflicts with asm clobber list}}
+}
diff --git a/test/Sema/artificial.c b/test/Sema/artificial.c
new file mode 100644
index 0000000000000..076a61ca0fef4
--- /dev/null
+++ b/test/Sema/artificial.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+inline void __attribute__((artificial)) foo() {}
+void __attribute__((artificial)) bar() {} // expected-warning {{'artificial' attribute only applies to inline functions}}
diff --git a/test/Sema/assign.c b/test/Sema/assign.c
index 5bdfa9a3a5df9..28d7b9f3bbdfc 100644
--- a/test/Sema/assign.c
+++ b/test/Sema/assign.c
@@ -11,10 +11,10 @@ void test2 (const struct {int a;} *x) {
typedef int arr[10];
void test3() {
- const arr b;
- const int b2[10];
- b[4] = 1; // expected-error {{read-only variable is not assignable}}
- b2[4] = 1; // expected-error {{read-only variable is not assignable}}
+ const arr b; // expected-note {{variable 'b' declared const here}}
+ const int b2[10]; // expected-note {{variable 'b2' declared const here}}
+ b[4] = 1; // expected-error {{cannot assign to variable 'b' with const-qualified type 'const arr' (aka 'int const[10]')}}
+ b2[4] = 1; // expected-error {{cannot assign to variable 'b2' with const-qualified type 'const int [10]'}}
}
typedef struct I {
diff --git a/test/Sema/ast-print.c b/test/Sema/ast-print.c
index f701b12209537..7f675206e58b3 100644
--- a/test/Sema/ast-print.c
+++ b/test/Sema/ast-print.c
@@ -1,5 +1,14 @@
-// RUN: %clang_cc1 %s -ast-print | FileCheck %s
-// RUN: %clang_cc1 %s -ast-print | %clang_cc1 -fsyntax-only -
+// RUN: %clang_cc1 %s -ast-print -verify > %t.c
+// RUN: FileCheck %s --input-file %t.c
+//
+// RUN: echo >> %t.c "// expected""-warning@* {{use of GNU old-style field designator extension}}"
+// RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes' is deprecated}}"
+// RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes' has been explicitly marked deprecated here}}"
+// RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes2' is deprecated}}"
+// RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes2' has been explicitly marked deprecated here}}"
+// RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes3' is deprecated}}"
+// RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes3' has been explicitly marked deprecated here}}"
+// RUN: %clang_cc1 -fsyntax-only %t.c -verify
typedef void func_typedef();
func_typedef xxx;
@@ -15,6 +24,10 @@ struct blah {
};
};
+// This used to crash clang.
+struct {
+}(s1);
+
int foo(const struct blah *b) {
// CHECK: return b->b;
return b->b;
@@ -54,7 +67,7 @@ struct pair_t {
};
// CHECK: struct pair_t p = {a: 3, .b = 4};
-struct pair_t p = {a: 3, .b = 4};
+struct pair_t p = {a: 3, .b = 4}; // expected-warning {{use of GNU old-style field designator extension}}
void initializers() {
// CHECK: int *x = ((void *)0), *y = ((void *)0);
@@ -66,11 +79,28 @@ void initializers() {
} z = {(struct Z){}};
}
-// CHECK-LABEL: enum EnumWithAttributes {
-enum EnumWithAttributes {
+// CHECK-LABEL: enum __attribute__((deprecated(""))) EnumWithAttributes {
+enum EnumWithAttributes { // expected-warning {{'EnumWithAttributes' is deprecated}}
// CHECK-NEXT: EnumWithAttributesFoo __attribute__((deprecated(""))),
EnumWithAttributesFoo __attribute__((deprecated)),
// CHECK-NEXT: EnumWithAttributesBar __attribute__((unavailable(""))) = 50
EnumWithAttributesBar __attribute__((unavailable)) = 50
- // CHECK-NEXT: } __attribute__((deprecated("")))
-} __attribute__((deprecated));
+ // CHECK-NEXT: } *EnumWithAttributesPtr;
+} __attribute__((deprecated)) *EnumWithAttributesPtr; // expected-note {{'EnumWithAttributes' has been explicitly marked deprecated here}}
+
+// CHECK-LABEL: enum __attribute__((deprecated(""))) EnumWithAttributes2 *EnumWithAttributes2Ptr;
+// expected-warning@+2 {{'EnumWithAttributes2' is deprecated}}
+// expected-note@+1 {{'EnumWithAttributes2' has been explicitly marked deprecated here}}
+enum __attribute__((deprecated)) EnumWithAttributes2 *EnumWithAttributes2Ptr;
+
+// CHECK-LABEL: EnumWithAttributes3Fn
+void EnumWithAttributes3Fn() {
+ // CHECK-NEXT: enum __attribute__((deprecated(""))) EnumWithAttributes3 *EnumWithAttributes3Ptr;
+ // expected-warning@+2 {{'EnumWithAttributes3' is deprecated}}
+ // expected-note@+1 {{'EnumWithAttributes3' has been explicitly marked deprecated here}}
+ enum __attribute__((deprecated)) EnumWithAttributes3 *EnumWithAttributes3Ptr;
+ // Printing must not put the attribute after the tag where it would apply to
+ // the variable instead of the type, and then our deprecation warning would
+ // move to this use of the variable.
+ void *p = EnumWithAttributes3Ptr;
+}
diff --git a/test/Sema/atomic-ops.c b/test/Sema/atomic-ops.c
index eee1cda8635ea..49310bf45b68f 100644
--- a/test/Sema/atomic-ops.c
+++ b/test/Sema/atomic-ops.c
@@ -173,6 +173,9 @@ void f(_Atomic(int) *i, const _Atomic(int) *ci,
__atomic_fetch_sub(P, 3, memory_order_seq_cst);
__atomic_fetch_sub(D, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer or pointer}}
__atomic_fetch_sub(s1, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer or pointer}}
+ __atomic_fetch_min(D, 3, memory_order_seq_cst); // expected-error {{must be a pointer to signed or unsigned 32-bit integer}}
+ __atomic_fetch_max(P, 3, memory_order_seq_cst); // expected-error {{must be a pointer to signed or unsigned 32-bit integer}}
+ __atomic_fetch_max(p, 3); // expected-error {{too few arguments to function call, expected 3, have 2}}
__c11_atomic_fetch_and(i, 1, memory_order_seq_cst);
__c11_atomic_fetch_and(p, 1, memory_order_seq_cst); // expected-error {{must be a pointer to atomic integer}}
@@ -456,6 +459,20 @@ void memory_checks(_Atomic(int) *Ap, int *p, int val) {
(void)__atomic_fetch_nand(p, val, memory_order_acq_rel);
(void)__atomic_fetch_nand(p, val, memory_order_seq_cst);
+ (void)__atomic_fetch_min(p, val, memory_order_relaxed);
+ (void)__atomic_fetch_min(p, val, memory_order_acquire);
+ (void)__atomic_fetch_min(p, val, memory_order_consume);
+ (void)__atomic_fetch_min(p, val, memory_order_release);
+ (void)__atomic_fetch_min(p, val, memory_order_acq_rel);
+ (void)__atomic_fetch_min(p, val, memory_order_seq_cst);
+
+ (void)__atomic_fetch_max(p, val, memory_order_relaxed);
+ (void)__atomic_fetch_max(p, val, memory_order_acquire);
+ (void)__atomic_fetch_max(p, val, memory_order_consume);
+ (void)__atomic_fetch_max(p, val, memory_order_release);
+ (void)__atomic_fetch_max(p, val, memory_order_acq_rel);
+ (void)__atomic_fetch_max(p, val, memory_order_seq_cst);
+
(void)__atomic_and_fetch(p, val, memory_order_relaxed);
(void)__atomic_and_fetch(p, val, memory_order_acquire);
(void)__atomic_and_fetch(p, val, memory_order_consume);
@@ -513,9 +530,146 @@ void memory_checks(_Atomic(int) *Ap, int *p, int val) {
(void)__atomic_compare_exchange_n(p, p, val, 0, memory_order_seq_cst, memory_order_relaxed);
}
-void nullPointerWarning(_Atomic(int) *Ap, int *p, int val) {
- // The 'expected' pointer shouldn't be NULL.
- (void)__c11_atomic_compare_exchange_strong(Ap, NULL, val, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
- (void)atomic_compare_exchange_weak(Ap, ((void*)0), val); // expected-warning {{null passed to a callee that requires a non-null argument}}
- (void)__atomic_compare_exchange_n(p, NULL, val, 0, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+void nullPointerWarning() {
+ volatile _Atomic(int) vai;
+ _Atomic(int) ai;
+ volatile int vi = 42;
+ int i = 42;
+ volatile _Atomic(int*) vap;
+ _Atomic(int*) ap;
+ volatile int* vp = NULL;
+ int* p = NULL;
+
+ __c11_atomic_init((volatile _Atomic(int)*)0, 42); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ __c11_atomic_init((_Atomic(int)*)0, 42); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ __c11_atomic_store((volatile _Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ __c11_atomic_store((_Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__c11_atomic_load((volatile _Atomic(int)*)0, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__c11_atomic_load((_Atomic(int)*)0, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__c11_atomic_exchange((volatile _Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__c11_atomic_exchange((_Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__c11_atomic_compare_exchange_weak((volatile _Atomic(int)*)0, &i, 42, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__c11_atomic_compare_exchange_weak((_Atomic(int)*)0, &i, 42, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__c11_atomic_compare_exchange_weak(&vai, (int*)0, 42, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__c11_atomic_compare_exchange_weak(&ai, (int*)0, 42, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__c11_atomic_compare_exchange_strong((volatile _Atomic(int)*)0, &i, 42, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__c11_atomic_compare_exchange_strong((_Atomic(int)*)0, &i, 42, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__c11_atomic_compare_exchange_strong(&vai, (int*)0, 42, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__c11_atomic_compare_exchange_strong(&ai, (int*)0, 42, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__c11_atomic_fetch_add((volatile _Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__c11_atomic_fetch_add((_Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__c11_atomic_fetch_sub((volatile _Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__c11_atomic_fetch_sub((_Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__c11_atomic_fetch_and((volatile _Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__c11_atomic_fetch_and((_Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__c11_atomic_fetch_or((volatile _Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__c11_atomic_fetch_or((_Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__c11_atomic_fetch_xor((volatile _Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__c11_atomic_fetch_xor((_Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+
+ __atomic_store_n((volatile int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ __atomic_store_n((int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ __atomic_store((volatile int*)0, &i, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ __atomic_store((int*)0, &i, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ __atomic_store(&vi, (int*)0, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ __atomic_store(&i, (int*)0, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__atomic_load_n((volatile int*)0, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__atomic_load_n((int*)0, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ __atomic_load((volatile int*)0, &i, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ __atomic_load((int*)0, &i, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ __atomic_load(&vi, (int*)0, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ __atomic_load(&i, (int*)0, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__atomic_exchange_n((volatile int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__atomic_exchange_n((int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ __atomic_exchange((volatile int*)0, &i, &i, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ __atomic_exchange((int*)0, &i, &i, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ __atomic_exchange(&vi, (int*)0, &i, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ __atomic_exchange(&i, (int*)0, &i, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ __atomic_exchange(&vi, &i, (int*)0, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ __atomic_exchange(&i, &i, (int*)0, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__atomic_compare_exchange_n((volatile int*)0, &i, 42, /*weak=*/0, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__atomic_compare_exchange_n((int*)0, &i, 42, /*weak=*/0, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__atomic_compare_exchange_n(&vi, (int*)0, 42, /*weak=*/0, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__atomic_compare_exchange_n(&i, (int*)0, 42, /*weak=*/0, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__atomic_compare_exchange((volatile int*)0, &i, &i, /*weak=*/0, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__atomic_compare_exchange((int*)0, &i, &i, /*weak=*/0, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__atomic_compare_exchange(&vi, (int*)0, &i, /*weak=*/0, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__atomic_compare_exchange(&i, (int*)0, &i, /*weak=*/0, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__atomic_compare_exchange(&vi, &i, (int*)0, /*weak=*/0, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__atomic_compare_exchange(&i, &i, (int*)0, /*weak=*/0, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__atomic_fetch_add((volatile int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__atomic_fetch_add((int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__atomic_fetch_sub((volatile int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__atomic_fetch_sub((int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__atomic_fetch_and((volatile int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__atomic_fetch_and((int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__atomic_fetch_or((volatile int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__atomic_fetch_or((int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__atomic_fetch_xor((volatile int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__atomic_fetch_xor((int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__atomic_fetch_min((volatile int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__atomic_fetch_min((int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__atomic_fetch_max((volatile int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)__atomic_fetch_max((int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+
+ // These don't warn: the "desired" parameter is passed by value. Even for
+ // atomic pointers the "desired" result can be NULL.
+ __c11_atomic_init(&vai, 0);
+ __c11_atomic_init(&ai, 0);
+ __c11_atomic_init(&vap, NULL);
+ __c11_atomic_init(&ap, NULL);
+ __c11_atomic_store(&vai, 0, memory_order_relaxed);
+ __c11_atomic_store(&ai, 0, memory_order_relaxed);
+ __c11_atomic_store(&vap, NULL, memory_order_relaxed);
+ __c11_atomic_store(&ap, NULL, memory_order_relaxed);
+ (void)__c11_atomic_exchange(&vai, 0, memory_order_relaxed);
+ (void)__c11_atomic_exchange(&ai, 0, memory_order_relaxed);
+ (void)__c11_atomic_exchange(&vap, NULL, memory_order_relaxed);
+ (void)__c11_atomic_exchange(&ap, NULL, memory_order_relaxed);
+ (void)__c11_atomic_compare_exchange_weak(&vai, &i, 0, memory_order_relaxed, memory_order_relaxed);
+ (void)__c11_atomic_compare_exchange_weak(&ai, &i, 0, memory_order_relaxed, memory_order_relaxed);
+ (void)__c11_atomic_compare_exchange_weak(&vap, &p, NULL, memory_order_relaxed, memory_order_relaxed);
+ (void)__c11_atomic_compare_exchange_weak(&ap, &p, NULL, memory_order_relaxed, memory_order_relaxed);
+ (void)__c11_atomic_compare_exchange_strong(&vai, &i, 0, memory_order_relaxed, memory_order_relaxed);
+ (void)__c11_atomic_compare_exchange_strong(&ai, &i, 0, memory_order_relaxed, memory_order_relaxed);
+ (void)__c11_atomic_compare_exchange_strong(&vap, &p, NULL, memory_order_relaxed, memory_order_relaxed);
+ (void)__c11_atomic_compare_exchange_strong(&ap, &p, NULL, memory_order_relaxed, memory_order_relaxed);
+ (void)__c11_atomic_fetch_add(&vai, 0, memory_order_relaxed);
+ (void)__c11_atomic_fetch_add(&ai, 0, memory_order_relaxed);
+ (void)__c11_atomic_fetch_sub(&vai, 0, memory_order_relaxed);
+ (void)__c11_atomic_fetch_sub(&ai, 0, memory_order_relaxed);
+ (void)__c11_atomic_fetch_and(&vai, 0, memory_order_relaxed);
+ (void)__c11_atomic_fetch_and(&ai, 0, memory_order_relaxed);
+ (void)__c11_atomic_fetch_or(&vai, 0, memory_order_relaxed);
+ (void)__c11_atomic_fetch_or(&ai, 0, memory_order_relaxed);
+ (void)__c11_atomic_fetch_xor(&vai, 0, memory_order_relaxed);
+ (void)__c11_atomic_fetch_xor(&ai, 0, memory_order_relaxed);
+
+ // Ditto.
+ __atomic_store_n(&vi, 0, memory_order_relaxed);
+ __atomic_store_n(&i, 0, memory_order_relaxed);
+ __atomic_store_n(&vp, NULL, memory_order_relaxed);
+ __atomic_store_n(&p, NULL, memory_order_relaxed);
+ (void)__atomic_exchange_n(&vi, 0, memory_order_relaxed);
+ (void)__atomic_exchange_n(&i, 0, memory_order_relaxed);
+ (void)__atomic_exchange_n(&vp, NULL, memory_order_relaxed);
+ (void)__atomic_exchange_n(&p, NULL, memory_order_relaxed);
+ (void)__atomic_compare_exchange_n(&vi, &i, 0, /*weak=*/0, memory_order_relaxed, memory_order_relaxed);
+ (void)__atomic_compare_exchange_n(&i, &i, 0, /*weak=*/0, memory_order_relaxed, memory_order_relaxed);
+ (void)__atomic_compare_exchange_n(&vp, &vp, NULL, /*weak=*/0, memory_order_relaxed, memory_order_relaxed);
+ (void)__atomic_compare_exchange_n(&p, &p, NULL, /*weak=*/0, memory_order_relaxed, memory_order_relaxed);
+ (void)__atomic_fetch_add(&vi, 0, memory_order_relaxed);
+ (void)__atomic_fetch_add(&i, 0, memory_order_relaxed);
+ (void)__atomic_fetch_sub(&vi, 0, memory_order_relaxed);
+ (void)__atomic_fetch_sub(&i, 0, memory_order_relaxed);
+ (void)__atomic_fetch_and(&vi, 0, memory_order_relaxed);
+ (void)__atomic_fetch_and(&i, 0, memory_order_relaxed);
+ (void)__atomic_fetch_or(&vi, 0, memory_order_relaxed);
+ (void)__atomic_fetch_or(&i, 0, memory_order_relaxed);
+ (void)__atomic_fetch_xor(&vi, 0, memory_order_relaxed);
+ (void)__atomic_fetch_xor(&i, 0, memory_order_relaxed);
+ (void)__atomic_fetch_min(&vi, 0, memory_order_relaxed);
+ (void)__atomic_fetch_min(&i, 0, memory_order_relaxed);
+ (void)__atomic_fetch_max(&vi, 0, memory_order_relaxed);
+ (void)__atomic_fetch_max(&i, 0, memory_order_relaxed);
}
diff --git a/test/Sema/attr-availability-square-brackets.c b/test/Sema/attr-availability-square-brackets.c
new file mode 100644
index 0000000000000..13dbf0abb17f5
--- /dev/null
+++ b/test/Sema/attr-availability-square-brackets.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fsyntax-only -fdouble-square-bracket-attributes -verify %s
+
+void f0() [[clang::availability(macosx,introduced=10.4,deprecated=10.2)]]; // expected-warning{{feature cannot be deprecated in macOS version 10.2 before it was introduced in version 10.4; attribute ignored}}
+void f1() [[clang::availability(ios,obsoleted=2.1,deprecated=3.0)]]; // expected-warning{{feature cannot be obsoleted in iOS version 2.1 before it was deprecated in version 3.0; attribute ignored}}
+void f2() [[clang::availability(ios,introduced=2.1,deprecated=2.1)]];
+
+extern void
+ATSFontGetName(const char *oName) [[clang::availability(macosx,introduced=8.0,deprecated=9.0, message="use CTFontCopyFullName")]]; // expected-note {{'ATSFontGetName' has been explicitly marked deprecated here}}
+
+void test_10095131() {
+ ATSFontGetName("Hello"); // expected-warning {{'ATSFontGetName' is deprecated: first deprecated in macOS 9.0 - use CTFontCopyFullName}}
+}
+
+enum
+[[clang::availability(macos, unavailable)]]
+{
+ NSDataWritingFileProtectionWriteOnly = 0x30000000,
+ NSDataWritingFileProtectionCompleteUntilUserAuthentication = 0x40000000,
+};
+
+extern int x [[clang::availability(macosx,introduced=10.5)]];
+extern int x;
+
+int i [[clang::availability(this, should = 1.0)]]; // expected-error {{'should' is not an availability stage; use 'introduced', 'deprecated', or 'obsoleted'}} \
+ // expected-warning {{unknown platform 'this' in availability macro}}
diff --git a/test/Sema/attr-availability-tvos.c b/test/Sema/attr-availability-tvos.c
index d53d6ac8edc46..68337e49ce447 100644
--- a/test/Sema/attr-availability-tvos.c
+++ b/test/Sema/attr-availability-tvos.c
@@ -53,7 +53,7 @@ void test_tvos() {
f3_tvos(0);
f4_tvos(0); // expected-error{{'f4_tvos' is unavailable: obsoleted in tvOS 3.0}}
// We get no warning here because any explicit 'tvos' availability causes
- // the ios availablity to not implicitly become 'tvos' availability. Otherwise we'd get
+ // the ios availability to not implicitly become 'tvos' availability. Otherwise we'd get
// a deprecated warning.
f5_tvos(0); // no-warning
f5_attr_reversed_tvos(0); // no-warning
diff --git a/test/Sema/attr-availability-watchos.c b/test/Sema/attr-availability-watchos.c
index ec7f3a7d3afd6..59233986ee460 100644
--- a/test/Sema/attr-availability-watchos.c
+++ b/test/Sema/attr-availability-watchos.c
@@ -42,7 +42,7 @@ void test_watchos() {
f3_watchos(0);
f4_watchos(0); // expected-error{{'f4_watchos' is unavailable: obsoleted in watchOS 3.0}}
// We get no warning here because any explicit 'watchos' availability causes
- // the ios availablity to not implicitly become 'watchos' availability. Otherwise we'd get
+ // the ios availability to not implicitly become 'watchos' availability. Otherwise we'd get
// a deprecated warning.
f5_watchos(0); // no-warning
f5_attr_reversed_watchos(0); // no-warning
diff --git a/test/Sema/attr-cpuspecific.c b/test/Sema/attr-cpuspecific.c
new file mode 100644
index 0000000000000..91063c1c5b8aa
--- /dev/null
+++ b/test/Sema/attr-cpuspecific.c
@@ -0,0 +1,96 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify %s
+
+void __attribute__((cpu_specific(ivybridge))) no_default(void);
+void __attribute__((cpu_specific(sandybridge))) no_default(void);
+
+void use1(void){
+ // Should be OK, default not a problem.
+ no_default();
+}
+
+int __attribute__((cpu_specific(atom))) addr_of(void);
+int __attribute__((cpu_specific(ivybridge))) addr_of(void);
+int __attribute__((cpu_specific(ivybridge))) addr_of2(void);
+
+void use2(void){
+ addr_of();
+ addr_of2();
+ // expected-error@+1{{reference to multiversioned function could not be resolved; did you mean to call it with no arguments?}}
+ (void)+addr_of;
+ // expected-error@+1{{reference to multiversioned function could not be resolved; did you mean to call it with no arguments?}}
+ (void)+addr_of2;
+ // expected-error@+1{{reference to multiversioned function could not be resolved; did you mean to call it with no arguments?}}
+ (void)&addr_of;
+ // expected-error@+1{{reference to multiversioned function could not be resolved; did you mean to call it with no arguments?}}
+ (void)&addr_of2;
+}
+
+// expected-error@+1 {{multiversioned function must have a prototype}}
+int __attribute__((cpu_specific(atom))) no_proto();
+
+int __attribute__((cpu_specific(atom))) redecl1(void);
+int __attribute__((cpu_specific(atom))) redecl1(void) { return 1; }
+
+int __attribute__((cpu_dispatch(atom))) redecl2(void);
+int __attribute__((cpu_dispatch(atom))) redecl2(void) { }
+// expected-error@+2 {{redefinition of 'redecl2'}}
+// expected-note@-2 {{previous definition is here}}
+int __attribute__((cpu_dispatch(atom))) redecl2(void) { }
+
+int redecl3(void);
+// expected-error@-1 {{function declaration is missing 'cpu_specific' or 'cpu_dispatch' attribute in a multiversioned function}}
+// expected-note@+1 {{function multiversioning caused by this declaration}}
+int __attribute__((cpu_dispatch(atom))) redecl3(void) {}
+
+int __attribute__((cpu_specific(atom))) redecl4(void);
+// expected-error@+1 {{function declaration is missing 'cpu_specific' or 'cpu_dispatch' attribute in a multiversioned function}}
+int redecl4(void);
+
+// expected-warning@+1 {{CPU list contains duplicate entries; attribute ignored}}
+int __attribute__((cpu_specific(atom, atom))) dup_procs(void);
+
+int __attribute__((cpu_specific(ivybridge, atom))) dup_procs2(void);
+// expected-error@+2 {{multiple 'cpu_specific' functions cannot specify the same CPU: 'atom'}}
+// expected-note@-2 {{previous declaration is here}}
+int __attribute__((cpu_specific(atom))) dup_procs2(void);
+
+int __attribute__((cpu_specific(ivybridge, atom))) dup_procs3(void);
+// expected-error@+2 {{multiple 'cpu_specific' functions cannot specify the same CPU: 'ivybridge'}}
+// expected-note@-2 {{previous declaration is here}}
+int __attribute__((cpu_specific(atom, ivybridge))) dup_procs3(void);
+
+int __attribute__((cpu_specific(atom))) redef(void) { return 1; }
+// expected-error@+2 {{redefinition of 'redef'}}
+// expected-note@-2 {{previous definition is here}}
+int __attribute__((cpu_specific(atom))) redef(void) { return 2; }
+
+int __attribute((cpu_dispatch(atom))) mult_dispatch(void) {}
+// expected-error@+2 {{'cpu_dispatch' function redeclared with different CPUs}}
+// expected-note@-2 {{previous declaration is here}}
+int __attribute((cpu_dispatch(ivybridge))) mult_dispatch(void) {}
+
+// expected-error@+1 {{'cpu_dispatch' attribute takes at least 1 argument}}
+int __attribute((cpu_dispatch())) no_dispatch(void) {}
+// expected-error@+1 {{'cpu_specific' attribute takes at least 1 argument}}
+int __attribute((cpu_specific())) no_specific(void) {}
+
+//expected-error@+1 {{attribute 'cpu_specific' multiversioning cannot be combined}}
+void __attribute__((used,cpu_specific(sandybridge))) addtl_attrs(void);
+
+void __attribute__((target("default"))) addtl_attrs2(void);
+// expected-error@+2 {{multiversioning attributes cannot be combined}}
+// expected-note@-2 {{previous declaration is here}}
+void __attribute__((cpu_specific(sandybridge))) addtl_attrs2(void);
+
+// expected-error@+2 {{multiversioning attributes cannot be combined}}
+void __attribute((cpu_specific(sandybridge), cpu_dispatch(atom, sandybridge)))
+combine_attrs(void);
+
+int __attribute__((cpu_dispatch(ivybridge))) diff_cc(void){}
+// expected-error@+1 {{multiversioned function declaration has a different calling convention}}
+__vectorcall int __attribute__((cpu_specific(sandybridge))) diff_cc(void);
+
+// expected-warning@+2 {{body of cpu_dispatch function will be ignored}}
+int __attribute__((cpu_dispatch(atom))) disp_with_body(void) {
+ return 5;
+}
diff --git a/test/Sema/attr-cx2.c b/test/Sema/attr-cx2.c
new file mode 100644
index 0000000000000..5b537625c1298
--- /dev/null
+++ b/test/Sema/attr-cx2.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -fdouble-square-bracket-attributes %s
+
+struct S {};
+struct S * [[clang::address_space(1)]] Foo;
+
+enum [[clang::enum_extensibility(open)]] EnumOpen {
+ C0 = 1, C1 = 10
+};
+
+enum [[clang::flag_enum]] EnumFlag {
+ D0 = 1, D1 = 8
+};
+
+void foo(void *c) [[clang::overloadable]];
+void foo(char *c) [[clang::overloadable]];
+
+void context_okay(void *context [[clang::swift_context]]) [[clang::swiftcall]];
+void context_okay2(void *context [[clang::swift_context]], void *selfType, char **selfWitnessTable) [[clang::swiftcall]];
+
+void *f1(void) [[clang::ownership_returns(foo)]];
+void *f2() [[clang::ownership_returns(foo)]]; // expected-warning {{'ownership_returns' attribute only applies to non-K&R-style functions}}
+
+void foo2(void) [[clang::unavailable("not available - replaced")]]; // expected-note {{'foo2' has been explicitly marked unavailable here}}
+void bar(void) {
+ foo2(); // expected-error {{'foo2' is unavailable: not available - replaced}}
+}
diff --git a/test/Sema/attr-external-source-symbol.c b/test/Sema/attr-external-source-symbol.c
index af6e6bc79e7b6..dfed609c8e87e 100644
--- a/test/Sema/attr-external-source-symbol.c
+++ b/test/Sema/attr-external-source-symbol.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fblocks -verify -fdouble-square-bracket-attributes %s
void threeClauses() __attribute__((external_source_symbol(language="Swift", defined_in="module", generated_declaration)));
@@ -17,3 +17,15 @@ void namedDeclsOnly() {
return 1;
};
}
+
+void threeClauses2() [[clang::external_source_symbol(language="Swift", defined_in="module", generated_declaration)]];
+
+void twoClauses2() [[clang::external_source_symbol(language="Swift", defined_in="module")]];
+
+void fourClauses2()
+[[clang::external_source_symbol(language="Swift", defined_in="module", generated_declaration, generated_declaration)]]; // expected-error {{duplicate 'generated_declaration' clause in an 'external_source_symbol' attribute}}
+
+void oneClause2() [[clang::external_source_symbol(generated_declaration)]];
+
+void noArguments2()
+[[clang::external_source_symbol]]; // expected-error {{'external_source_symbol' attribute takes at least 1 argument}}
diff --git a/test/Sema/attr-format_arg.c b/test/Sema/attr-format_arg.c
index 64a23878317c6..e041c5acbffa5 100644
--- a/test/Sema/attr-format_arg.c
+++ b/test/Sema/attr-format_arg.c
@@ -4,10 +4,27 @@ int printf(const char *, ...);
const char* f(const char *s) __attribute__((format_arg(1)));
+const char *h(const char *msg1, const char *msg2)
+ __attribute__((__format_arg__(1))) __attribute__((__format_arg__(2)));
+
void g(const char *s) {
printf("%d", 123);
printf("%d %d", 123); // expected-warning{{more '%' conversions than data arguments}}
printf(f("%d"), 123);
printf(f("%d %d"), 123); // expected-warning{{more '%' conversions than data arguments}}
+
+ printf(h(
+ "", // expected-warning {{format string is empty}}
+ "" // expected-warning {{format string is empty}}
+ ), 123);
+ printf(h(
+ "%d",
+ "" // expected-warning {{format string is empty}}
+ ), 123);
+ printf(h(
+ "", // expected-warning {{format string is empty}}
+ "%d"
+ ), 123);
+ printf(h("%d", "%d"), 123);
}
diff --git a/test/Sema/attr-ifunc.c b/test/Sema/attr-ifunc.c
index 16fd0dfc98206..af7a7e33da096 100644
--- a/test/Sema/attr-ifunc.c
+++ b/test/Sema/attr-ifunc.c
@@ -36,7 +36,7 @@ void f1a() __asm("f1");
void f1a() {}
//expected-note@-1 {{previous definition is here}}
void f1() __attribute__((ifunc("f1_ifunc")));
-//expected-error@-1 {{definition with same mangled name as another definition}}
+//expected-error@-1 {{definition with same mangled name 'f1' as another definition}}
void* f1_ifunc() { return 0; }
void* f6_ifunc(int i);
diff --git a/test/Sema/attr-min-vector-width.c b/test/Sema/attr-min-vector-width.c
new file mode 100644
index 0000000000000..0e6f84a672f23
--- /dev/null
+++ b/test/Sema/attr-min-vector-width.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
+
+int i;
+void f(void) __attribute__((__min_vector_width__(i))); /* expected-error {{'__min_vector_width__' attribute requires an integer constant}} */
+
+void f2(void) __attribute__((__min_vector_width__(128)));
+
+void f3(void) __attribute__((__min_vector_width__(128), __min_vector_width__(256))); /* expected-warning {{attribute '__min_vector_width__' is already applied with different parameters}} */
+
+void f4(void) __attribute__((__min_vector_width__())); /* expected-error {{'__min_vector_width__' attribute takes one argument}} */
+
+void f5(void) __attribute__((__min_vector_width__(128, 256))); /* expected-error {{'__min_vector_width__' attribute takes one argument}} */
+
+void f6(void) {
+ int x __attribute__((__min_vector_width__(128))) = 0; /* expected-error {{'__min_vector_width__' attribute only applies to functions}} */
+}
diff --git a/test/Sema/attr-nocf_check.c b/test/Sema/attr-nocf_check.c
new file mode 100644
index 0000000000000..9ca1bb173439e
--- /dev/null
+++ b/test/Sema/attr-nocf_check.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -verify -fcf-protection=branch -fsyntax-only %s
+
+// Function pointer definition.
+typedef void (*FuncPointerWithNoCfCheck)(void) __attribute__((nocf_check)); // no-warning
+typedef void (*FuncPointer)(void);
+
+// Dont allow function declaration and definition mismatch.
+void __attribute__((nocf_check)) testNoCfCheck(); // expected-note {{previous declaration is here}}
+void testNoCfCheck(){}; // expected-error {{conflicting types for 'testNoCfCheck'}}
+
+// No variable or parameter declaration
+__attribute__((nocf_check)) int i; // expected-warning {{'nocf_check' attribute only applies to function}}
+void testNoCfCheckImpl(double __attribute__((nocf_check)) i) {} // expected-warning {{'nocf_check' attribute only applies to function}}
+
+// Allow attributed function pointers as well as casting between attributed
+// and non-attributed function pointers.
+void testNoCfCheckMismatch(FuncPointer f) {
+ FuncPointerWithNoCfCheck fNoCfCheck = f; // expected-warning {{incompatible function pointer types}}
+ (*fNoCfCheck)(); // no-warning
+}
+
+// 'nocf_check' Attribute has no parameters.
+int testNoCfCheckParams() __attribute__((nocf_check(1))); // expected-error {{'nocf_check' attribute takes no arguments}}
diff --git a/test/Sema/attr-nocf_check.cpp b/test/Sema/attr-nocf_check.cpp
new file mode 100644
index 0000000000000..e306c8ef79cd5
--- /dev/null
+++ b/test/Sema/attr-nocf_check.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple=i386-unknown-unknown -verify -fcf-protection=branch -std=c++11 -fsyntax-only %s
+
+// Function pointer definition.
+[[gnu::nocf_check]] typedef void (*FuncPointerWithNoCfCheck)(void); // no-warning
+typedef void (*FuncPointer)(void);
+
+// Dont allow function declaration and definition mismatch.
+[[gnu::nocf_check]] void testNoCfCheck(); // expected-note {{previous declaration is here}}
+void testNoCfCheck(){}; // expected-error {{conflicting types for 'testNoCfCheck'}}
+
+// No variable or parameter declaration
+int [[gnu::nocf_check]] i; // expected-error {{'nocf_check' attribute cannot be applied to types}}
+void testNoCfCheckImpl(double i [[gnu::nocf_check]]) {} // expected-warning {{'nocf_check' attribute only applies to functions and function pointers}}
+
+// Allow attributed function pointers as well as casting between attributed
+// and non-attributed function pointers.
+void testNoCfCheckMismatch(FuncPointer f) {
+ FuncPointerWithNoCfCheck fNoCfCheck = f; // expected-error {{cannot initialize a variable of type}}
+ (*fNoCfCheck)(); // no-warning
+}
+
+// 'nocf_check' Attribute has no parameters.
+[[gnu::nocf_check(1)]] int testNoCfCheckParams(); // expected-error {{'nocf_check' attribute takes no arguments}}
diff --git a/test/Sema/attr-objc-bridge-related.m b/test/Sema/attr-objc-bridge-related.m
new file mode 100644
index 0000000000000..bf059ba018607
--- /dev/null
+++ b/test/Sema/attr-objc-bridge-related.m
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -fdouble-square-bracket-attributes %s
+
+struct [[clang::objc_bridge_related(NSParagraphStyle,,)]] TestBridgedRef;
+
+struct [[clang::objc_bridge_related(NSColor,colorWithCGColor:,CGColor)]] CGColorRefOk;
+struct [[clang::objc_bridge_related(,colorWithCGColor:,CGColor)]] CGColorRef1NotOk; // expected-error {{expected a related ObjectiveC class name, e.g., 'NSColor'}}
+struct [[clang::objc_bridge_related(NSColor,colorWithCGColor::,CGColor)]] CGColorRef3NotOk; // expected-error {{expected a class method selector with single argument, e.g., 'colorWithCGColor:'}}
diff --git a/test/Sema/attr-ownership.c b/test/Sema/attr-ownership.c
index fa21b0319b428..ff6c7197df8d4 100644
--- a/test/Sema/attr-ownership.c
+++ b/test/Sema/attr-ownership.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify
+// RUN: %clang_cc1 %s -verify -fsyntax-only
void f1(void) __attribute__((ownership_takes("foo"))); // expected-error {{'ownership_takes' attribute requires parameter 1 to be an identifier}}
void *f2(void) __attribute__((ownership_returns(foo, 1, 2))); // expected-error {{'ownership_returns' attribute takes no more than 1 argument}}
diff --git a/test/Sema/attr-ownership.cpp b/test/Sema/attr-ownership.cpp
new file mode 100644
index 0000000000000..cde195ff0aa89
--- /dev/null
+++ b/test/Sema/attr-ownership.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+class C {
+ void f(int, int)
+ __attribute__((ownership_returns(foo, 2))) // expected-note {{declared with index 2 here}}
+ __attribute__((ownership_returns(foo, 3))); // expected-error {{'ownership_returns' attribute index does not match; here it is 3}}
+};
diff --git a/test/Sema/attr-print.c b/test/Sema/attr-print.c
index 7ffbbb800d51c..16b440d5d73a4 100644
--- a/test/Sema/attr-print.c
+++ b/test/Sema/attr-print.c
@@ -7,6 +7,9 @@ int x __attribute__((aligned(4)));
// CHECK: int y __declspec(align(4));
__declspec(align(4)) int y;
+// CHECK: short arr[3] __attribute__((aligned));
+short arr[3] __attribute__((aligned));
+
// CHECK: void foo() __attribute__((const));
void foo() __attribute__((const));
diff --git a/test/Sema/attr-target-ast.c b/test/Sema/attr-target-ast.c
new file mode 100644
index 0000000000000..6e8497ea9c8d0
--- /dev/null
+++ b/test/Sema/attr-target-ast.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -ast-dump %s | FileCheck %s
+
+int __attribute__((target("arch=hiss,arch=woof"))) pine_tree() { return 4; }
+// CHECK-NOT: arch=hiss
+// CHECK-NOT: arch=woof
diff --git a/test/Sema/attr-target-mv-bad-target.c b/test/Sema/attr-target-mv-bad-target.c
new file mode 100644
index 0000000000000..9cf3c5e10a6b2
--- /dev/null
+++ b/test/Sema/attr-target-mv-bad-target.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-windows-pc -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple arm-none-eabi -fsyntax-only -verify %s
+
+int __attribute__((target("sse4.2"))) redecl1(void) { return 1; }
+//expected-error@+2 {{function multiversioning is not supported on the current target}}
+//expected-note@-2 {{previous declaration is here}}
+int __attribute__((target("avx"))) redecl1(void) { return 2; }
+
+//expected-error@+1 {{function multiversioning is not supported on the current target}}
+int __attribute__((target("default"))) with_def(void) { return 1;}
diff --git a/test/Sema/attr-target-mv.c b/test/Sema/attr-target-mv.c
new file mode 100644
index 0000000000000..671adff5b0427
--- /dev/null
+++ b/test/Sema/attr-target-mv.c
@@ -0,0 +1,103 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify %s
+
+void __attribute__((target("sse4.2"))) no_default(void);
+void __attribute__((target("arch=sandybridge"))) no_default(void);
+
+void use1(void){
+ // expected-error@+1 {{no matching function for call to 'no_default'}}
+ no_default();
+}
+
+void __attribute__((target("sse4.2"))) has_def(void);
+void __attribute__((target("default"))) has_def(void);
+
+void use2(void){
+ // expected-error@+2 {{reference to overloaded function could not be resolved; did you mean to call it?}}
+ // expected-note@-4 {{possible target for call}}
+ +has_def;
+}
+
+int __attribute__((target("sse4.2"))) no_proto();
+// expected-error@-1 {{multiversioned function must have a prototype}}
+// expected-note@+1 {{function multiversioning caused by this declaration}}
+int __attribute__((target("arch=sandybridge"))) no_proto();
+
+// The following should all be legal, since they are just redeclarations.
+int __attribute__((target("sse4.2"))) redecl1(void);
+int __attribute__((target("sse4.2"))) redecl1(void) { return 1; }
+int __attribute__((target("arch=sandybridge"))) redecl1(void) { return 2; }
+
+int __attribute__((target("sse4.2"))) redecl2(void) { return 1; }
+int __attribute__((target("sse4.2"))) redecl2(void);
+int __attribute__((target("arch=sandybridge"))) redecl2(void) { return 2; }
+
+int __attribute__((target("sse4.2"))) redecl3(void) { return 0; }
+int __attribute__((target("arch=ivybridge"))) redecl3(void) { return 1; }
+int __attribute__((target("arch=sandybridge"))) redecl3(void);
+int __attribute__((target("arch=sandybridge"))) redecl3(void) { return 2; }
+
+int __attribute__((target("sse4.2"))) redecl4(void) { return 1; }
+int __attribute__((target("arch=sandybridge"))) redecl4(void) { return 2; }
+int __attribute__((target("arch=sandybridge"))) redecl4(void);
+
+int __attribute__((target("sse4.2"))) redef(void) { return 1; }
+int __attribute__((target("arch=ivybridge"))) redef(void) { return 1; }
+int __attribute__((target("arch=sandybridge"))) redef(void) { return 2; }
+// expected-error@+2 {{redefinition of 'redef'}}
+// expected-note@-2 {{previous definition is here}}
+int __attribute__((target("arch=sandybridge"))) redef(void) { return 2; }
+
+int __attribute__((target("default"))) redef2(void) { return 1;}
+// expected-error@+2 {{redefinition of 'redef2'}}
+// expected-note@-2 {{previous definition is here}}
+int __attribute__((target("default"))) redef2(void) { return 1;}
+
+int __attribute__((target("sse4.2"))) mv_after_use(void) { return 1; }
+int use3(void) {
+ return mv_after_use();
+}
+
+// expected-error@+1 {{function declaration cannot become a multiversioned function after first usage}}
+int __attribute__((target("arch=sandybridge"))) mv_after_use(void) { return 2; }
+
+int __attribute__((target("sse4.2,arch=sandybridge"))) mangle(void) { return 1; }
+//expected-error@+2 {{multiversioned function redeclarations require identical target attributes}}
+//expected-note@-2 {{previous declaration is here}}
+int __attribute__((target("arch=sandybridge,sse4.2"))) mangle(void) { return 2; }
+
+int prev_no_target(void);
+int __attribute__((target("arch=sandybridge"))) prev_no_target(void) { return 2; }
+// expected-error@-2 {{function declaration is missing 'target' attribute in a multiversioned function}}
+// expected-note@+1 {{function multiversioning caused by this declaration}}
+int __attribute__((target("arch=ivybridge"))) prev_no_target(void) { return 2; }
+
+int __attribute__((target("arch=sandybridge"))) prev_no_target2(void);
+int prev_no_target2(void);
+// expected-error@-1 {{function declaration is missing 'target' attribute in a multiversioned function}}
+// expected-note@+1 {{function multiversioning caused by this declaration}}
+int __attribute__((target("arch=ivybridge"))) prev_no_target2(void);
+
+void __attribute__((target("sse4.2"))) addtl_attrs(void);
+//expected-error@+1 {{attribute 'target' multiversioning cannot be combined}}
+void __attribute__((used,target("arch=sandybridge"))) addtl_attrs(void);
+
+//expected-error@+1 {{attribute 'target' multiversioning cannot be combined}}
+void __attribute__((target("default"), used)) addtl_attrs2(void);
+
+//expected-error@+2 {{attribute 'target' multiversioning cannot be combined}}
+//expected-note@+2 {{function multiversioning caused by this declaration}}
+void __attribute__((used,target("sse4.2"))) addtl_attrs3(void);
+void __attribute__((target("arch=sandybridge"))) addtl_attrs3(void);
+
+void __attribute__((target("sse4.2"))) addtl_attrs4(void);
+void __attribute__((target("arch=sandybridge"))) addtl_attrs4(void);
+//expected-error@+1 {{attribute 'target' multiversioning cannot be combined}}
+void __attribute__((used,target("arch=ivybridge"))) addtl_attrs4(void);
+
+int __attribute__((target("sse4.2"))) diff_cc(void);
+// expected-error@+1 {{multiversioned function declaration has a different calling convention}}
+__vectorcall int __attribute__((target("arch=sandybridge"))) diff_cc(void);
+
+int __attribute__((target("sse4.2"))) diff_ret(void);
+// expected-error@+1 {{multiversioned function declaration has a different return type}}
+short __attribute__((target("arch=sandybridge"))) diff_ret(void);
diff --git a/test/Sema/attr-target-unsupported.c b/test/Sema/attr-target-unsupported.c
new file mode 100644
index 0000000000000..8e23fcc17ebd8
--- /dev/null
+++ b/test/Sema/attr-target-unsupported.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple mips-linux-gnu -fsyntax-only -verify %s
+
+void __attribute__((target("arch=mips1")))
+foo(void) {}
+// expected-error@+3 {{function multiversioning is not supported on the current target}}
+// expected-note@-2 {{previous declaration is here}}
+void __attribute__((target("arch=mips2")))
+foo(void) {}
+
+// expected-error@+2 {{function multiversioning is not supported on the current target}}
+void __attribute__((target("default")))
+bar(void){}
diff --git a/test/Sema/attr-target.c b/test/Sema/attr-target.c
index 058bfc421a190..644d7cb1604e0 100644
--- a/test/Sema/attr-target.c
+++ b/test/Sema/attr-target.c
@@ -1,14 +1,21 @@
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify %s
int __attribute__((target("avx,sse4.2,arch=ivybridge"))) foo() { return 4; }
-int __attribute__((target())) bar() { return 4; } //expected-error {{'target' attribute takes one argument}}
-int __attribute__((target("tune=sandybridge"))) baz() { return 4; } //expected-warning {{ignoring unsupported 'tune=' in the target attribute string}}
-int __attribute__((target("fpmath=387"))) walrus() { return 4; } //expected-warning {{ignoring unsupported 'fpmath=' in the target attribute string}}
-int __attribute__((target("avx,sse4.2,arch=hiss"))) meow() { return 4; }//expected-warning {{ignoring unsupported architecture 'hiss' in the target attribute string}}
-int __attribute__((target("woof"))) bark() { return 4; }//expected-warning {{ignoring unsupported 'woof' in the target attribute string}}
-int __attribute__((target("arch="))) turtle() { return 4; } // no warning, same as saying 'nothing'.
-int __attribute__((target("arch=hiss,arch=woof"))) pine_tree() { return 4; } //expected-warning {{ignoring unsupported architecture 'hiss' in the target attribute string}}
-int __attribute__((target("arch=ivybridge,arch=haswell"))) oak_tree() { return 4; } //expected-warning {{ignoring duplicate 'arch=' in the target attribute string}}
-
+//expected-error@+1 {{'target' attribute takes one argument}}
+int __attribute__((target())) bar() { return 4; }
+//expected-warning@+1 {{unsupported 'tune=' in the 'target' attribute string; 'target' attribute ignored}}
+int __attribute__((target("tune=sandybridge"))) baz() { return 4; }
+//expected-warning@+1 {{unsupported 'fpmath=' in the 'target' attribute string; 'target' attribute ignored}}
+int __attribute__((target("fpmath=387"))) walrus() { return 4; }
+//expected-warning@+1 {{unsupported architecture 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
+int __attribute__((target("avx,sse4.2,arch=hiss"))) meow() { return 4; }
+//expected-warning@+1 {{unsupported 'woof' in the 'target' attribute string; 'target' attribute ignored}}
+int __attribute__((target("woof"))) bark() { return 4; }
+// no warning, same as saying 'nothing'.
+int __attribute__((target("arch="))) turtle() { return 4; }
+//expected-warning@+1 {{unsupported architecture 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
+int __attribute__((target("arch=hiss,arch=woof"))) pine_tree() { return 4; }
+//expected-warning@+1 {{duplicate 'arch=' in the 'target' attribute string; 'target' attribute ignored}}
+int __attribute__((target("arch=ivybridge,arch=haswell"))) oak_tree() { return 4; }
diff --git a/test/Sema/attr-type-safety.c b/test/Sema/attr-type-safety.c
new file mode 100644
index 0000000000000..d7dab5d30760e
--- /dev/null
+++ b/test/Sema/attr-type-safety.c
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -fsyntax-only -fdouble-square-bracket-attributes -verify %s
+
+struct A {};
+
+typedef struct A *MPI_Datatype;
+
+extern struct A datatype_wrong1 [[clang::type_tag_for_datatype]]; // expected-error {{'type_tag_for_datatype' attribute requires parameter 1 to be an identifier}}
+
+extern struct A datatype_wrong2 [[clang::type_tag_for_datatype(mpi,1,2)]]; // expected-error {{expected a type}}
+
+extern struct A datatype_wrong3 [[clang::type_tag_for_datatype(mpi,not_a_type)]]; // expected-error {{unknown type name 'not_a_type'}}
+
+extern struct A datatype_wrong4 [[clang::type_tag_for_datatype(mpi,int,int)]]; // expected-error {{expected identifier}}
+
+extern struct A datatype_wrong5 [[clang::type_tag_for_datatype(mpi,int,not_a_flag)]]; // expected-error {{invalid comparison flag 'not_a_flag'}}
+
+extern struct A datatype_wrong6 [[clang::type_tag_for_datatype(mpi,int,layout_compatible,not_a_flag)]]; // expected-error {{invalid comparison flag 'not_a_flag'}}
+
+extern struct A A_tag [[clang::type_tag_for_datatype(a,int)]];
+extern struct A B_tag [[clang::type_tag_for_datatype(b,int)]];
+
+static const int C_tag [[clang::type_tag_for_datatype(c,int)]] = 10;
+static const int D_tag [[clang::type_tag_for_datatype(d,int)]] = 20;
+
+[[clang::pointer_with_type_tag]] // expected-error {{'pointer_with_type_tag' attribute requires exactly 3 arguments}}
+int wrong1(void *buf, MPI_Datatype datatype);
+
+[[clang::pointer_with_type_tag(mpi,0,7)]] // expected-error {{attribute parameter 2 is out of bounds}}
+int wrong2(void *buf, MPI_Datatype datatype);
+
+[[clang::pointer_with_type_tag(mpi,3,7)]] // expected-error {{attribute parameter 2 is out of bounds}}
+int wrong3(void *buf, MPI_Datatype datatype);
+
+[[clang::pointer_with_type_tag(mpi,1,0)]] // expected-error {{attribute parameter 3 is out of bounds}}
+int wrong4(void *buf, MPI_Datatype datatype);
+
+[[clang::pointer_with_type_tag(mpi,1,3)]] // expected-error {{attribute parameter 3 is out of bounds}}
+int wrong5(void *buf, MPI_Datatype datatype);
+
+[[clang::pointer_with_type_tag(mpi,0x8000000000000001ULL,1)]] // expected-error {{attribute parameter 2 is out of bounds}}
+int wrong6(void *buf, MPI_Datatype datatype);
+
+[[clang::pointer_with_type_tag(a,1,2)]] void A_func(void *ptr, void *tag);
+[[clang::pointer_with_type_tag(c,1,2)]] void C_func(void *ptr, int tag);
+
diff --git a/test/Sema/attr-used.c b/test/Sema/attr-used.c
index 4e3bda7609bb1..c13d57c95e614 100644
--- a/test/Sema/attr-used.c
+++ b/test/Sema/attr-used.c
@@ -3,7 +3,7 @@
extern int l0 __attribute__((used)); // expected-warning {{'used' attribute ignored}}
__private_extern__ int l1 __attribute__((used)); // expected-warning {{'used' attribute ignored}}
-struct __attribute__((used)) s { // expected-warning {{'used' attribute only applies to variables and functions}}
+struct __attribute__((used)) s { // expected-warning {{'used' attribute only applies to variables with non-local storage, functions, and Objective-C methods}}
int x;
};
@@ -14,7 +14,7 @@ static void __attribute__((used)) f0(void) {
void f1() {
static int a __attribute__((used));
- int b __attribute__((used)); // expected-warning {{'used' attribute ignored}}
+ int b __attribute__((used)); // expected-warning {{'used' attribute only applies to variables with non-local storage, functions, and Objective-C methods}}
}
static void __attribute__((used)) f0(void);
diff --git a/test/Sema/attr-weak.c b/test/Sema/attr-weak.c
index e3610caba5845..6f0c3d5523b3b 100644
--- a/test/Sema/attr-weak.c
+++ b/test/Sema/attr-weak.c
@@ -1,7 +1,9 @@
// RUN: %clang_cc1 -verify -fsyntax-only %s
+extern int f0() __attribute__((weak));
extern int g0 __attribute__((weak));
extern int g1 __attribute__((weak_import));
+int f2() __attribute__((weak));
int g2 __attribute__((weak));
int g3 __attribute__((weak_import)); // expected-warning {{'weak_import' attribute cannot be specified on a definition}}
int __attribute__((weak_import)) g4(void);
@@ -11,6 +13,7 @@ void __attribute__((weak_import)) g5(void) {
struct __attribute__((weak)) s0 {}; // expected-warning {{'weak' attribute only applies to variables, functions, and classes}}
struct __attribute__((weak_import)) s1 {}; // expected-warning {{'weak_import' attribute only applies to variables and functions}}
+static int f() __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}}
static int x __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}}
// rdar://9538608
diff --git a/test/Sema/availability-guard-format.mm b/test/Sema/availability-guard-format.mm
new file mode 100644
index 0000000000000..910de49ffc815
--- /dev/null
+++ b/test/Sema/availability-guard-format.mm
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx-10.11 -Wunguarded-availability -fdiagnostics-parseable-fixits -fsyntax-only -verify %s
+
+// Testing that even for source code using '_' as a delimiter in availability version tuple '.' is actually used in diagnostic output as a delimiter.
+
+@interface foo
+- (void) method_bar __attribute__((availability(macosx, introduced = 10_12))); // expected-note {{'method_bar' has been explicitly marked partial here}}
+@end
+
+int main() {
+ [foo method_bar]; // \
+ // expected-warning {{'method_bar' is only available on macOS 10.12 or newer}} \
+ // expected-note {{enclose 'method_bar' in an @available check to silence this warning}} \
+ // CHECK: "fix-it:.*if (@available(macOS 10.12, *))"
+ return 0;
+}
diff --git a/test/Sema/bitfield.c b/test/Sema/bitfield.c
index d625366e4e1f2..13e9480a378be 100644
--- a/test/Sema/bitfield.c
+++ b/test/Sema/bitfield.c
@@ -82,3 +82,7 @@ typedef __typeof__(+(t5.n--)) Unsigned; // also act like compound-assignment.
struct Test6 {
: 0.0; // expected-error{{type name requires a specifier or qualifier}}
};
+
+struct PR36157 {
+ int n : 1 ? 1 : implicitly_declare_function(); // expected-warning {{invalid in C99}}
+};
diff --git a/test/Sema/bittest-intrinsics.c b/test/Sema/bittest-intrinsics.c
new file mode 100644
index 0000000000000..536c1eb066c79
--- /dev/null
+++ b/test/Sema/bittest-intrinsics.c
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 -ffreestanding -fms-compatibility -fms-compatibility-version=19 -verify %s -triple i686-windows-msvc -fms-extensions -DTEST_X86
+// RUN: %clang_cc1 -ffreestanding -fms-compatibility -fms-compatibility-version=19 -verify %s -triple x86_64-windows-msvc -fms-extensions -DTEST_X64
+// RUN: %clang_cc1 -ffreestanding -fms-compatibility -fms-compatibility-version=19 -verify %s -triple arm-windows-msvc -fms-extensions -DTEST_ARM
+// RUN: %clang_cc1 -ffreestanding -fms-compatibility -fms-compatibility-version=19 -verify %s -triple thumbv7-windows-msvc -fms-extensions -DTEST_ARM
+// RUN: %clang_cc1 -ffreestanding -fms-compatibility -fms-compatibility-version=19 -verify %s -triple aarch64-windows-msvc -fms-extensions -DTEST_ARM
+
+#include <intrin.h>
+extern unsigned char sink;
+
+#ifdef TEST_X86
+void x86(long *bits, __int64 *bits64, long bitidx) {
+ sink = _bittest(bits, bitidx);
+ sink = _bittestandcomplement(bits, bitidx);
+ sink = _bittestandreset(bits, bitidx);
+ sink = _bittestandset(bits, bitidx);
+ sink = _interlockedbittestandreset(bits, bitidx);
+ sink = _interlockedbittestandset(bits, bitidx);
+
+ sink = _bittest64(bits64, bitidx); // expected-error {{builtin is not supported on this target}}
+ sink = _bittestandcomplement64(bits64, bitidx); // expected-error {{builtin is not supported on this target}}
+ sink = _bittestandreset64(bits64, bitidx); // expected-error {{builtin is not supported on this target}}
+ sink = _bittestandset64(bits64, bitidx); // expected-error {{builtin is not supported on this target}}
+ sink = _interlockedbittestandreset64(bits64, bitidx); // expected-error {{builtin is not supported on this target}}
+ sink = _interlockedbittestandset64(bits64, bitidx); // expected-error {{builtin is not supported on this target}}
+
+ sink = _interlockedbittestandreset_acq(bits, bitidx); // expected-error {{builtin is not supported on this target}}
+ sink = _interlockedbittestandreset_rel(bits, bitidx); // expected-error {{builtin is not supported on this target}}
+ sink = _interlockedbittestandreset_nf(bits, bitidx); // expected-error {{builtin is not supported on this target}}
+ sink = _interlockedbittestandset_acq(bits, bitidx); // expected-error {{builtin is not supported on this target}}
+ sink = _interlockedbittestandset_rel(bits, bitidx); // expected-error {{builtin is not supported on this target}}
+ sink = _interlockedbittestandset_nf(bits, bitidx); // expected-error {{builtin is not supported on this target}}
+}
+#endif
+
+#ifdef TEST_X64
+void x64(long *bits, __int64 *bits64, long bitidx) {
+ sink = _bittest(bits, bitidx);
+ sink = _bittestandcomplement(bits, bitidx);
+ sink = _bittestandreset(bits, bitidx);
+ sink = _bittestandset(bits, bitidx);
+ sink = _interlockedbittestandreset(bits, bitidx);
+ sink = _interlockedbittestandset(bits, bitidx);
+
+ sink = _bittest64(bits64, bitidx);
+ sink = _bittestandcomplement64(bits64, bitidx);
+ sink = _bittestandreset64(bits64, bitidx);
+ sink = _bittestandset64(bits64, bitidx);
+ sink = _interlockedbittestandreset64(bits64, bitidx);
+ sink = _interlockedbittestandset64(bits64, bitidx);
+
+ sink = _interlockedbittestandreset_acq(bits, bitidx); // expected-error {{builtin is not supported on this target}}
+ sink = _interlockedbittestandreset_rel(bits, bitidx); // expected-error {{builtin is not supported on this target}}
+ sink = _interlockedbittestandreset_nf(bits, bitidx); // expected-error {{builtin is not supported on this target}}
+ sink = _interlockedbittestandset_acq(bits, bitidx); // expected-error {{builtin is not supported on this target}}
+ sink = _interlockedbittestandset_rel(bits, bitidx); // expected-error {{builtin is not supported on this target}}
+ sink = _interlockedbittestandset_nf(bits, bitidx); // expected-error {{builtin is not supported on this target}}
+}
+#endif
+
+#ifdef TEST_ARM
+// expected-no-diagnostics
+void arm(long *bits, __int64 *bits64, long bitidx) {
+ sink = _bittest(bits, bitidx);
+ sink = _bittestandcomplement(bits, bitidx);
+ sink = _bittestandreset(bits, bitidx);
+ sink = _bittestandset(bits, bitidx);
+ sink = _interlockedbittestandreset(bits, bitidx);
+ sink = _interlockedbittestandset(bits, bitidx);
+
+ sink = _bittest64(bits64, bitidx);
+ sink = _bittestandcomplement64(bits64, bitidx);
+ sink = _bittestandreset64(bits64, bitidx);
+ sink = _bittestandset64(bits64, bitidx);
+ sink = _interlockedbittestandreset64(bits64, bitidx);
+ sink = _interlockedbittestandset64(bits64, bitidx);
+
+ sink = _interlockedbittestandreset_acq(bits, bitidx);
+ sink = _interlockedbittestandreset_rel(bits, bitidx);
+ sink = _interlockedbittestandreset_nf(bits, bitidx);
+ sink = _interlockedbittestandset_acq(bits, bitidx);
+ sink = _interlockedbittestandset_rel(bits, bitidx);
+ sink = _interlockedbittestandset_nf(bits, bitidx);
+}
+#endif
diff --git a/test/Sema/builtin-classify-type.c b/test/Sema/builtin-classify-type.c
index 376e73d1118c9..814c1aeec6277 100644
--- a/test/Sema/builtin-classify-type.c
+++ b/test/Sema/builtin-classify-type.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s -fblocks
// expected-no-diagnostics
@@ -25,6 +25,14 @@ void foo() {
struct { int a; float b; } s_obj;
union { int a; float b; } u_obj;
int arr[10];
+ int (^block)();
+ __attribute__((vector_size(16))) int vec;
+ typedef __attribute__((ext_vector_type(4))) int evec_t;
+ evec_t evec;
+ _Atomic int atomic_i;
+ _Atomic double atomic_d;
+ _Complex int complex_i;
+ _Complex double complex_d;
int a1[__builtin_classify_type(f()) == void_type_class ? 1 : -1];
int a2[__builtin_classify_type(i) == integer_type_class ? 1 : -1];
@@ -38,5 +46,14 @@ void foo() {
int a10[__builtin_classify_type(u_obj) == union_type_class ? 1 : -1];
int a11[__builtin_classify_type(arr) == pointer_type_class ? 1 : -1];
int a12[__builtin_classify_type("abc") == pointer_type_class ? 1 : -1];
+ int a13[__builtin_classify_type(block) == no_type_class ? 1 : -1];
+ int a14[__builtin_classify_type(vec) == no_type_class ? 1 : -1];
+ int a15[__builtin_classify_type(evec) == no_type_class ? 1 : -1];
+ int a16[__builtin_classify_type(atomic_i) == integer_type_class ? 1 : -1];
+ int a17[__builtin_classify_type(atomic_d) == real_type_class ? 1 : -1];
+ int a18[__builtin_classify_type(complex_i) == complex_type_class ? 1 : -1];
+ int a19[__builtin_classify_type(complex_d) == complex_type_class ? 1 : -1];
}
+extern int (^p)();
+int n = __builtin_classify_type(p);
diff --git a/test/Sema/builtin-dump-struct.c b/test/Sema/builtin-dump-struct.c
new file mode 100644
index 0000000000000..ec82ad15b644e
--- /dev/null
+++ b/test/Sema/builtin-dump-struct.c
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -fsyntax-only -fno-spell-checking -verify %s
+
+void invalid_uses() {
+ struct A {
+ };
+ struct A a;
+ void *b;
+ int (*goodfunc)(const char *, ...);
+ int (*badfunc1)(const char *);
+ int (*badfunc2)(int, ...);
+ void (*badfunc3)(const char *, ...);
+ int (*badfunc4)(char *, ...);
+ int (*badfunc5)(void);
+
+ __builtin_dump_struct(); // expected-error {{too few arguments to function call, expected 2, have 0}}
+ __builtin_dump_struct(1); // expected-error {{too few arguments to function call, expected 2, have 1}}
+ __builtin_dump_struct(1, 2); // expected-error {{passing 'int' to parameter of incompatible type structure pointer: type mismatch at 1st parameter ('int' vs structure pointer)}}
+ __builtin_dump_struct(&a, 2); // expected-error {{passing 'int' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int' vs 'int (*)(const char *, ...)')}}
+ __builtin_dump_struct(b, goodfunc); // expected-error {{passing 'void *' to parameter of incompatible type structure pointer: type mismatch at 1st parameter ('void *' vs structure pointer)}}
+ __builtin_dump_struct(&a, badfunc1); // expected-error {{passing 'int (*)(const char *)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int (*)(const char *)' vs 'int (*)(const char *, ...)')}}
+ __builtin_dump_struct(&a, badfunc2); // expected-error {{passing 'int (*)(int, ...)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int (*)(int, ...)' vs 'int (*)(const char *, ...)')}}
+ __builtin_dump_struct(&a, badfunc3); // expected-error {{passing 'void (*)(const char *, ...)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('void (*)(const char *, ...)' vs 'int (*)(const char *, ...)')}}
+ __builtin_dump_struct(&a, badfunc4); // expected-error {{passing 'int (*)(char *, ...)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int (*)(char *, ...)' vs 'int (*)(const char *, ...)')}}
+ __builtin_dump_struct(&a, badfunc5); // expected-error {{passing 'int (*)(void)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int (*)(void)' vs 'int (*)(const char *, ...)')}}
+ __builtin_dump_struct(a, goodfunc); // expected-error {{passing 'struct A' to parameter of incompatible type structure pointer: type mismatch at 1st parameter ('struct A' vs structure pointer)}}
+}
+
+void valid_uses() {
+ struct A {
+ };
+ union B {
+ };
+
+ int (*goodfunc)(const char *, ...);
+ int (*goodfunc2)();
+ struct A a;
+ union B b;
+
+ __builtin_dump_struct(&a, goodfunc);
+ __builtin_dump_struct(&b, goodfunc);
+ __builtin_dump_struct(&a, goodfunc2);
+}
diff --git a/test/Sema/builtin-object-size.c b/test/Sema/builtin-object-size.c
index 096882a088c08..436e99d9ab88c 100644
--- a/test/Sema/builtin-object-size.c
+++ b/test/Sema/builtin-object-size.c
@@ -13,10 +13,10 @@ int f1() {
__builtin_object_size(&a, 3));
}
int f2() {
- return __builtin_object_size(&a, -1); // expected-error {{argument should be a value from 0 to 3}}
+ return __builtin_object_size(&a, -1); // expected-error {{argument value -1 is outside the valid range [0, 3]}}
}
int f3() {
- return __builtin_object_size(&a, 4); // expected-error {{argument should be a value from 0 to 3}}
+ return __builtin_object_size(&a, 4); // expected-error {{argument value 4 is outside the valid range [0, 3]}}
}
@@ -41,7 +41,7 @@ void f5(void)
char buf[10];
memset((void *)0x100000000ULL, 0, 0x1000);
memcpy((char *)NULL + 0x10000, buf, 0x10);
- memcpy1((char *)NULL + 0x10000, buf, 0x10); // expected-error {{argument should be a value from 0 to 3}}
+ memcpy1((char *)NULL + 0x10000, buf, 0x10); // expected-error {{argument value 4 is outside the valid range [0, 3]}}
}
// rdar://18431336
diff --git a/test/Sema/builtin-prefetch.c b/test/Sema/builtin-prefetch.c
index c5fa792a56636..478c85b756878 100644
--- a/test/Sema/builtin-prefetch.c
+++ b/test/Sema/builtin-prefetch.c
@@ -8,7 +8,7 @@ void foo() {
__builtin_prefetch(&a, 1, 9, 3); // expected-error{{too many arguments to function}}
__builtin_prefetch(&a, "hello", 2); // expected-error{{argument to '__builtin_prefetch' must be a constant integer}}
__builtin_prefetch(&a, a, 2); // expected-error{{argument to '__builtin_prefetch' must be a constant integer}}
- __builtin_prefetch(&a, 2); // expected-error{{argument should be a value from 0 to 1}}
- __builtin_prefetch(&a, 0, 4); // expected-error{{argument should be a value from 0 to 3}}
- __builtin_prefetch(&a, -1, 4); // expected-error{{argument should be a value from 0 to 1}}
+ __builtin_prefetch(&a, 2); // expected-error{{argument value 2 is outside the valid range [0, 1]}}
+ __builtin_prefetch(&a, 0, 4); // expected-error{{argument value 4 is outside the valid range [0, 3]}}
+ __builtin_prefetch(&a, -1, 4); // expected-error{{argument value -1 is outside the valid range [0, 1]}}
}
diff --git a/test/Sema/builtin-redecl.cpp b/test/Sema/builtin-redecl.cpp
new file mode 100644
index 0000000000000..9d1a7fff02321
--- /dev/null
+++ b/test/Sema/builtin-redecl.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+// RUN: %clang_cc1 %s -fsyntax-only -verify -x c
+// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-compatibility
+
+// Redeclaring library builtins is OK.
+void exit(int);
+
+// expected-error@+2 {{cannot redeclare builtin function '__builtin_va_copy'}}
+// expected-note@+1 {{'__builtin_va_copy' is a builtin with type}}
+void __builtin_va_copy(double d);
+
+// expected-error@+2 {{cannot redeclare builtin function '__builtin_va_end'}}
+// expected-note@+1 {{'__builtin_va_end' is a builtin with type}}
+void __builtin_va_end(__builtin_va_list);
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+// RUN: %clang_cc1 %s -fsyntax-only -verify -x c
+
+void __va_start(__builtin_va_list*, ...);
diff --git a/test/Sema/builtins-arm.c b/test/Sema/builtins-arm.c
index 373bbae31e7f1..f34499123c406 100644
--- a/test/Sema/builtins-arm.c
+++ b/test/Sema/builtins-arm.c
@@ -35,18 +35,18 @@ void test2() {
#endif
void test3() {
- __builtin_arm_dsb(16); // expected-error {{argument should be a value from 0 to 15}}
- __builtin_arm_dmb(17); // expected-error {{argument should be a value from 0 to 15}}
- __builtin_arm_isb(18); // expected-error {{argument should be a value from 0 to 15}}
+ __builtin_arm_dsb(16); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ __builtin_arm_dmb(17); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ __builtin_arm_isb(18); // expected-error-re {{argument value {{.*}} is outside the valid range}}
}
void test4() {
- __builtin_arm_prefetch(0, 2, 0); // expected-error {{argument should be a value from 0 to 1}}
- __builtin_arm_prefetch(0, 0, 2); // expected-error {{argument should be a value from 0 to 1}}
+ __builtin_arm_prefetch(0, 2, 0); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ __builtin_arm_prefetch(0, 0, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}
}
void test5() {
- __builtin_arm_dbg(16); // expected-error {{argument should be a value from 0 to 15}}
+ __builtin_arm_dbg(16); // expected-error-re {{argument value {{.*}} is outside the valid range}}
}
void test6(int a, int b, int c) {
@@ -168,14 +168,14 @@ void test_9_4_1_width_specified_saturation(int a, int b) {
s = __builtin_arm_ssat(8, 2);
s = __builtin_arm_ssat(a, 1);
s = __builtin_arm_ssat(a, 32);
- s = __builtin_arm_ssat(a, 0); // expected-error {{argument should be a value from 1 to 32}}
- s = __builtin_arm_ssat(a, 33); // expected-error {{argument should be a value from 1 to 32}}
+ s = __builtin_arm_ssat(a, 0); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ s = __builtin_arm_ssat(a, 33); // expected-error-re {{argument value {{.*}} is outside the valid range}}
s = __builtin_arm_ssat(a, b); // expected-error {{argument to '__builtin_arm_ssat' must be a constant integer}}
u = __builtin_arm_usat(8, 2);
u = __builtin_arm_usat(a, 0);
u = __builtin_arm_usat(a, 31);
- u = __builtin_arm_usat(a, 32); // expected-error {{argument should be a value from 0 to 31}}
+ u = __builtin_arm_usat(a, 32); // expected-error-re {{argument value {{.*}} is outside the valid range}}
u = __builtin_arm_usat(a, b); // expected-error {{argument to '__builtin_arm_usat' must be a constant integer}}
}
@@ -215,12 +215,12 @@ void test_9_5_4_parallel_16bit_saturation(int16x2_t a) {
s = __builtin_arm_ssat16(a, 1);
s = __builtin_arm_ssat16(a, 16);
- s = __builtin_arm_ssat16(a, 0); // expected-error {{argument should be a value from 1 to 16}}
- s = __builtin_arm_ssat16(a, 17); // expected-error {{argument should be a value from 1 to 16}}
+ s = __builtin_arm_ssat16(a, 0); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ s = __builtin_arm_ssat16(a, 17); // expected-error-re {{argument value {{.*}} is outside the valid range}}
u = __builtin_arm_usat16(a, 0);
u = __builtin_arm_usat16(a, 15);
- u = __builtin_arm_usat16(a, 16); // expected-error {{argument should be a value from 0 to 15}}
+ u = __builtin_arm_usat16(a, 16); // expected-error-re {{argument value {{.*}} is outside the valid range}}
}
void test_9_5_5_packing_and_unpacking(int16x2_t a, int8x4_t b, uint16x2_t c, uint8x4_t d) {
@@ -320,3 +320,18 @@ void test_9_5_10_parallel_16bit_multiplication(int16x2_t a, int16x2_t b,
x = __builtin_arm_smusd(a, b);
x = __builtin_arm_smusdx(a, b);
}
+
+void test_VFP(float f, double d) {
+ float fr;
+ double dr;
+
+ fr = __builtin_arm_vcvtr_f(f, 0);
+ fr = __builtin_arm_vcvtr_f(f, 1);
+ fr = __builtin_arm_vcvtr_f(f, -1); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ fr = __builtin_arm_vcvtr_f(f, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+
+ dr = __builtin_arm_vcvtr_f(d, 0);
+ dr = __builtin_arm_vcvtr_f(d, 1);
+ dr = __builtin_arm_vcvtr_f(d, -1); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ dr = __builtin_arm_vcvtr_f(d, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+}
diff --git a/test/Sema/builtins-arm64.c b/test/Sema/builtins-arm64.c
index 2779984680f4b..27144a18cdeba 100644
--- a/test/Sema/builtins-arm64.c
+++ b/test/Sema/builtins-arm64.c
@@ -18,14 +18,14 @@ void test_clear_cache_no_args() {
}
void test_memory_barriers() {
- __builtin_arm_dmb(16); // expected-error {{argument should be a value from 0 to 15}}
- __builtin_arm_dsb(17); // expected-error {{argument should be a value from 0 to 15}}
- __builtin_arm_isb(18); // expected-error {{argument should be a value from 0 to 15}}
+ __builtin_arm_dmb(16); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ __builtin_arm_dsb(17); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ __builtin_arm_isb(18); // expected-error-re {{argument value {{.*}} is outside the valid range}}
}
void test_prefetch() {
- __builtin_arm_prefetch(0, 2, 0, 0, 0); // expected-error {{argument should be a value from 0 to 1}}
- __builtin_arm_prefetch(0, 0, 3, 0, 0); // expected-error {{argument should be a value from 0 to 2}}
- __builtin_arm_prefetch(0, 0, 0, 2, 0); // expected-error {{argument should be a value from 0 to 1}}
- __builtin_arm_prefetch(0, 0, 0, 0, 2); // expected-error {{argument should be a value from 0 to 1}}
+ __builtin_arm_prefetch(0, 2, 0, 0, 0); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ __builtin_arm_prefetch(0, 0, 3, 0, 0); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ __builtin_arm_prefetch(0, 0, 0, 2, 0); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ __builtin_arm_prefetch(0, 0, 0, 0, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}
}
diff --git a/test/Sema/builtins-hexagon-v55.c b/test/Sema/builtins-hexagon-v55.c
new file mode 100644
index 0000000000000..e5e233d1f1e86
--- /dev/null
+++ b/test/Sema/builtins-hexagon-v55.c
@@ -0,0 +1,17 @@
+// REQUIRES: hexagon-registered-target
+// RUN: %clang_cc1 %s -triple hexagon -fsyntax-only -verify -target-cpu hexagonv55
+
+unsigned builtin_needs_v60(unsigned Rs) {
+ // expected-error@+1 {{builtin is not supported on this CPU}}
+ return __builtin_HEXAGON_S6_rol_i_r(Rs, 3);
+}
+
+unsigned long long builtin_needs_v62(unsigned Rs) {
+ // expected-error@+1 {{builtin is not supported on this CPU}}
+ return __builtin_HEXAGON_S6_vsplatrbp(Rs);
+}
+
+unsigned builtin_needs_v65(unsigned long long Rss, unsigned long long Rtt) {
+ // expected-error@+1 {{builtin is not supported on this CPU}}
+ return __builtin_HEXAGON_A6_vcmpbeq_notany(Rss, Rtt);
+}
diff --git a/test/Sema/builtins-hexagon-v60.c b/test/Sema/builtins-hexagon-v60.c
new file mode 100644
index 0000000000000..d4f081bf66ae5
--- /dev/null
+++ b/test/Sema/builtins-hexagon-v60.c
@@ -0,0 +1,16 @@
+// REQUIRES: hexagon-registered-target
+// RUN: %clang_cc1 %s -triple hexagon -fsyntax-only -verify -target-cpu hexagonv60
+
+unsigned builtin_needs_v60(unsigned Rs) {
+ return __builtin_HEXAGON_S6_rol_i_r(Rs, 3);
+}
+
+unsigned long long builtin_needs_v62(unsigned Rs) {
+ // expected-error@+1 {{builtin is not supported on this CPU}}
+ return __builtin_HEXAGON_S6_vsplatrbp(Rs);
+}
+
+unsigned builtin_needs_v65(unsigned long long Rss, unsigned long long Rtt) {
+ // expected-error@+1 {{builtin is not supported on this CPU}}
+ return __builtin_HEXAGON_A6_vcmpbeq_notany(Rss, Rtt);
+}
diff --git a/test/Sema/builtins-hexagon-v62.c b/test/Sema/builtins-hexagon-v62.c
new file mode 100644
index 0000000000000..ed3907bc82715
--- /dev/null
+++ b/test/Sema/builtins-hexagon-v62.c
@@ -0,0 +1,15 @@
+// REQUIRES: hexagon-registered-target
+// RUN: %clang_cc1 %s -triple hexagon -fsyntax-only -verify -target-cpu hexagonv62
+
+unsigned builtin_needs_v60(unsigned Rs) {
+ return __builtin_HEXAGON_S6_rol_i_r(Rs, 3);
+}
+
+unsigned long long builtin_needs_v62(unsigned Rs) {
+ return __builtin_HEXAGON_S6_vsplatrbp(Rs);
+}
+
+unsigned builtin_needs_v65(unsigned long long Rss, unsigned long long Rtt) {
+ // expected-error@+1 {{builtin is not supported on this CPU}}
+ return __builtin_HEXAGON_A6_vcmpbeq_notany(Rss, Rtt);
+}
diff --git a/test/Sema/builtins-hexagon-v65.c b/test/Sema/builtins-hexagon-v65.c
new file mode 100644
index 0000000000000..bb8a1ce5e167c
--- /dev/null
+++ b/test/Sema/builtins-hexagon-v65.c
@@ -0,0 +1,15 @@
+// REQUIRES: hexagon-registered-target
+// RUN: %clang_cc1 %s -triple hexagon -fsyntax-only -verify -target-cpu hexagonv65
+
+// expected-no-diagnostics
+unsigned builtin_needs_v60(unsigned Rs) {
+ return __builtin_HEXAGON_S6_rol_i_r(Rs, 3);
+}
+
+unsigned long long builtin_needs_v62(unsigned Rs) {
+ return __builtin_HEXAGON_S6_vsplatrbp(Rs);
+}
+
+unsigned builtin_needs_v65(unsigned long long Rss, unsigned long long Rtt) {
+ return __builtin_HEXAGON_A6_vcmpbeq_notany(Rss, Rtt);
+}
diff --git a/test/Sema/builtins-hvx-none.c b/test/Sema/builtins-hvx-none.c
new file mode 100644
index 0000000000000..c43b34f1c57b7
--- /dev/null
+++ b/test/Sema/builtins-hvx-none.c
@@ -0,0 +1,26 @@
+// REQUIRES: hexagon-registered-target
+// RUN: %clang_cc1 -triple hexagon %s -fsyntax-only -verify
+
+typedef long Vect1024 __attribute__((__vector_size__(128)))
+ __attribute__((aligned(128)));
+typedef long Vect2048 __attribute__((__vector_size__(256)))
+ __attribute__((aligned(128)));
+
+typedef Vect1024 HVX_Vector;
+typedef Vect2048 HVX_VectorPair;
+
+
+HVX_Vector builtin_needs_v60(HVX_VectorPair a) {
+ // expected-error@+1 {{builtin requires HVX}}
+ return __builtin_HEXAGON_V6_hi_128B(a);
+}
+
+HVX_Vector builtin_needs_v62(char a) {
+ // expected-error@+1 {{builtin requires HVX}}
+ return __builtin_HEXAGON_V6_lvsplatb_128B(a);
+}
+
+HVX_VectorPair builtin_needs_v65() {
+ // expected-error@+1 {{builtin requires HVX}}
+ return __builtin_HEXAGON_V6_vdd0_128B();
+}
diff --git a/test/Sema/builtins-hvx-v60.c b/test/Sema/builtins-hvx-v60.c
new file mode 100644
index 0000000000000..7d298e989ea23
--- /dev/null
+++ b/test/Sema/builtins-hvx-v60.c
@@ -0,0 +1,25 @@
+// REQUIRES: hexagon-registered-target
+// RUN: %clang_cc1 -triple hexagon %s -target-feature +hvx-length128b -target-feature +hvxv60 -target-cpu hexagonv60 -fsyntax-only -verify
+
+typedef long Vect1024 __attribute__((__vector_size__(128)))
+ __attribute__((aligned(128)));
+typedef long Vect2048 __attribute__((__vector_size__(256)))
+ __attribute__((aligned(128)));
+
+typedef Vect1024 HVX_Vector;
+typedef Vect2048 HVX_VectorPair;
+
+
+HVX_Vector builtin_needs_v60(HVX_VectorPair a) {
+ return __builtin_HEXAGON_V6_hi_128B(a);
+}
+
+HVX_Vector builtin_needs_v62(char a) {
+ // expected-error@+1 {{builtin is not supported on this version of HVX}}
+ return __builtin_HEXAGON_V6_lvsplatb_128B(a);
+}
+
+HVX_VectorPair builtin_needs_v65() {
+ // expected-error@+1 {{builtin is not supported on this version of HVX}}
+ return __builtin_HEXAGON_V6_vdd0_128B();
+}
diff --git a/test/Sema/builtins-hvx-v62.c b/test/Sema/builtins-hvx-v62.c
new file mode 100644
index 0000000000000..b73af963766d7
--- /dev/null
+++ b/test/Sema/builtins-hvx-v62.c
@@ -0,0 +1,24 @@
+// REQUIRES: hexagon-registered-target
+// RUN: %clang_cc1 -triple hexagon %s -target-feature +hvx-length128b -target-feature +hvxv62 -target-cpu hexagonv62 -fsyntax-only -verify
+
+typedef long Vect1024 __attribute__((__vector_size__(128)))
+ __attribute__((aligned(128)));
+typedef long Vect2048 __attribute__((__vector_size__(256)))
+ __attribute__((aligned(128)));
+
+typedef Vect1024 HVX_Vector;
+typedef Vect2048 HVX_VectorPair;
+
+
+HVX_Vector builtin_needs_v60(HVX_VectorPair a) {
+ return __builtin_HEXAGON_V6_hi_128B(a);
+}
+
+HVX_Vector builtin_needs_v62(char a) {
+ return __builtin_HEXAGON_V6_lvsplatb_128B(a);
+}
+
+HVX_VectorPair builtin_needs_v65() {
+ // expected-error@+1 {{builtin is not supported on this version of HVX}}
+ return __builtin_HEXAGON_V6_vdd0_128B();
+}
diff --git a/test/Sema/builtins-hvx-v65.c b/test/Sema/builtins-hvx-v65.c
new file mode 100644
index 0000000000000..be6b7b0955d51
--- /dev/null
+++ b/test/Sema/builtins-hvx-v65.c
@@ -0,0 +1,23 @@
+// REQUIRES: hexagon-registered-target
+// RUN: %clang_cc1 -triple hexagon %s -target-feature +hvx-length128b -target-feature +hvxv65 -target-cpu hexagonv65 -fsyntax-only -verify
+
+typedef long Vect1024 __attribute__((__vector_size__(128)))
+ __attribute__((aligned(128)));
+typedef long Vect2048 __attribute__((__vector_size__(256)))
+ __attribute__((aligned(128)));
+
+typedef Vect1024 HVX_Vector;
+typedef Vect2048 HVX_VectorPair;
+
+// expected-no-diagnostics
+HVX_Vector builtin_needs_v60(HVX_VectorPair a) {
+ return __builtin_HEXAGON_V6_hi_128B(a);
+}
+
+HVX_Vector builtin_needs_v62(char a) {
+ return __builtin_HEXAGON_V6_lvsplatb_128B(a);
+}
+
+HVX_VectorPair builtin_needs_v65() {
+ return __builtin_HEXAGON_V6_vdd0_128B();
+}
diff --git a/test/Sema/builtins-ppc.c b/test/Sema/builtins-ppc.c
index 5c45d02b414cb..aa6e9843f6575 100644
--- a/test/Sema/builtins-ppc.c
+++ b/test/Sema/builtins-ppc.c
@@ -9,15 +9,15 @@
#ifdef TEST_HTM
void test_htm() {
- __builtin_tbegin(4); // expected-error {{argument should be a value from 0 to 1}}
- __builtin_tend(-1); // expected-error {{argument should be a value from 0 to 1}}
- __builtin_tsr(55); // expected-error {{argument should be a value from 0 to 7}}
- __builtin_tabortwc(-5, 2, 3); // expected-error {{argument should be a value from 0 to 31}}
- __builtin_tabortdc(55, 2, 3); // expected-error {{argument should be a value from 0 to 31}}
- __builtin_tabortwci(-5, 2, 5); // expected-error {{argument should be a value from 0 to 31}}
- __builtin_tabortwci(5, 2, 55); // expected-error {{argument should be a value from 0 to 31}}
- __builtin_tabortdci(-5, 2, 5); // expected-error {{argument should be a value from 0 to 31}}
- __builtin_tabortdci(5, 2, 55); // expected-error {{argument should be a value from 0 to 31}}
+ __builtin_tbegin(4); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ __builtin_tend(-1); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ __builtin_tsr(55); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ __builtin_tabortwc(-5, 2, 3); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ __builtin_tabortdc(55, 2, 3); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ __builtin_tabortwci(-5, 2, 5); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ __builtin_tabortwci(5, 2, 55); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ __builtin_tabortdci(-5, 2, 5); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ __builtin_tabortdci(5, 2, 55); // expected-error-re {{argument value {{.*}} is outside the valid range}}
}
#endif
@@ -30,20 +30,20 @@ void test_htm() {
vector unsigned int test_vshasigmaw_or(void)
{
vector unsigned int a = W_INIT
- vector unsigned int b = __builtin_crypto_vshasigmaw(a, 2, 15); // expected-error {{argument should be a value from 0 to 1}}
- vector unsigned int c = __builtin_crypto_vshasigmaw(a, -1, 15); // expected-error {{argument should be a value from 0 to 1}}
- vector unsigned int d = __builtin_crypto_vshasigmaw(a, 0, 85); // expected-error {{argument should be a value from 0 to 15}}
- vector unsigned int e = __builtin_crypto_vshasigmaw(a, 1, -15); // expected-error {{argument should be a value from 0 to 15}}
+ vector unsigned int b = __builtin_crypto_vshasigmaw(a, 2, 15); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vector unsigned int c = __builtin_crypto_vshasigmaw(a, -1, 15); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vector unsigned int d = __builtin_crypto_vshasigmaw(a, 0, 85); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vector unsigned int e = __builtin_crypto_vshasigmaw(a, 1, -15); // expected-error-re {{argument value {{.*}} is outside the valid range}}
return __builtin_crypto_vshasigmaw(a, 1, 15);
}
vector unsigned long long test_vshasigmad_or(void)
{
vector unsigned long long a = D_INIT
- vector unsigned long long b = __builtin_crypto_vshasigmad(a, 2, 15); // expected-error {{argument should be a value from 0 to 1}}
- vector unsigned long long c = __builtin_crypto_vshasigmad(a, -1, 15); // expected-error {{argument should be a value from 0 to 1}}
- vector unsigned long long d = __builtin_crypto_vshasigmad(a, 0, 85); // expected-error {{argument should be a value from 0 to 1}}
- vector unsigned long long e = __builtin_crypto_vshasigmad(a, 1, -15); // expected-error {{argument should be a value from 0 to 1}}
+ vector unsigned long long b = __builtin_crypto_vshasigmad(a, 2, 15); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vector unsigned long long c = __builtin_crypto_vshasigmad(a, -1, 15); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vector unsigned long long d = __builtin_crypto_vshasigmad(a, 0, 85); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+ vector unsigned long long e = __builtin_crypto_vshasigmad(a, 1, -15); // expected-error-re {{argument value {{.*}} is outside the valid range}}
return __builtin_crypto_vshasigmad(a, 0, 15);
}
diff --git a/test/Sema/builtins-x86.c b/test/Sema/builtins-x86.c
index 074efe16ade6b..9872a64f18740 100644
--- a/test/Sema/builtins-x86.c
+++ b/test/Sema/builtins-x86.c
@@ -4,82 +4,163 @@ typedef long long __m128i __attribute__((__vector_size__(16)));
typedef float __m128 __attribute__((__vector_size__(16)));
typedef double __m128d __attribute__((__vector_size__(16)));
+typedef long long __m256i __attribute__((__vector_size__(32)));
+typedef float __m256 __attribute__((__vector_size__(32)));
+typedef double __m256d __attribute__((__vector_size__(32)));
+
typedef long long __m512i __attribute__((__vector_size__(64)));
typedef float __m512 __attribute__((__vector_size__(64)));
typedef double __m512d __attribute__((__vector_size__(64)));
typedef unsigned char __mmask8;
typedef unsigned short __mmask16;
+typedef unsigned int __mmask32;
+
+void call_x86_32_builtins(void) {
+ (void)__builtin_ia32_readeflags_u32(); // expected-error{{this builtin is only available on 32-bit targets}}
+ (void)__builtin_ia32_writeeflags_u32(4); // expected-error{{this builtin is only available on 32-bit targets}}
+}
__m128 test__builtin_ia32_cmpps(__m128 __a, __m128 __b) {
- __builtin_ia32_cmpps(__a, __b, 32); // expected-error {{argument should be a value from 0 to 31}}
+ return __builtin_ia32_cmpps(__a, __b, 32); // expected-error {{argument value 32 is outside the valid range [0, 31]}}
}
__m128d test__builtin_ia32_cmppd(__m128d __a, __m128d __b) {
- __builtin_ia32_cmppd(__a, __b, 32); // expected-error {{argument should be a value from 0 to 31}}
+ return __builtin_ia32_cmppd(__a, __b, 32); // expected-error {{argument value 32 is outside the valid range [0, 31]}}
}
__m128 test__builtin_ia32_cmpss(__m128 __a, __m128 __b) {
- __builtin_ia32_cmpss(__a, __b, 32); // expected-error {{argument should be a value from 0 to 31}}
+ return __builtin_ia32_cmpss(__a, __b, 32); // expected-error {{argument value 32 is outside the valid range [0, 31]}}
}
__m128d test__builtin_ia32_cmpsd(__m128d __a, __m128d __b) {
- __builtin_ia32_cmpsd(__a, __b, 32); // expected-error {{argument should be a value from 0 to 31}}
+ return __builtin_ia32_cmpsd(__a, __b, 32); // expected-error {{argument value 32 is outside the valid range [0, 31]}}
}
__mmask16 test__builtin_ia32_cmpps512_mask(__m512d __a, __m512d __b) {
- __builtin_ia32_cmpps512_mask(__a, __b, 32, -1, 4); // expected-error {{argument should be a value from 0 to 31}}
+ return __builtin_ia32_cmpps512_mask(__a, __b, 32, -1, 4); // expected-error {{argument value 32 is outside the valid range [0, 31]}}
}
__mmask8 test__builtin_ia32_cmppd512_mask(__m512d __a, __m512d __b) {
- __builtin_ia32_cmppd512_mask(__a, __b, 32, -1, 4); // expected-error {{argument should be a value from 0 to 31}}
+ return __builtin_ia32_cmppd512_mask(__a, __b, 32, -1, 4); // expected-error {{argument value 32 is outside the valid range [0, 31]}}
}
__m128i test__builtin_ia32_vpcomub(__m128i __a, __m128i __b) {
- __builtin_ia32_vpcomub(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}}
+ return __builtin_ia32_vpcomub(__a, __b, 8); // expected-error {{argument value 8 is outside the valid range [0, 7]}}
}
__m128i test__builtin_ia32_vpcomuw(__m128i __a, __m128i __b) {
- __builtin_ia32_vpcomuw(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}}
+ return __builtin_ia32_vpcomuw(__a, __b, 8); // expected-error {{argument value 8 is outside the valid range [0, 7]}}
}
__m128i test__builtin_ia32_vpcomud(__m128i __a, __m128i __b) {
- __builtin_ia32_vpcomud(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}}
+ return __builtin_ia32_vpcomud(__a, __b, 8); // expected-error {{argument value 8 is outside the valid range [0, 7]}}
}
__m128i test__builtin_ia32_vpcomuq(__m128i __a, __m128i __b) {
- __builtin_ia32_vpcomuq(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}}
+ return __builtin_ia32_vpcomuq(__a, __b, 8); // expected-error {{argument value 8 is outside the valid range [0, 7]}}
}
__m128i test__builtin_ia32_vpcomb(__m128i __a, __m128i __b) {
- __builtin_ia32_vpcomub(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}}
+ return __builtin_ia32_vpcomub(__a, __b, 8); // expected-error {{argument value 8 is outside the valid range [0, 7]}}
}
__m128i test__builtin_ia32_vpcomw(__m128i __a, __m128i __b) {
- __builtin_ia32_vpcomuw(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}}
+ return __builtin_ia32_vpcomuw(__a, __b, 8); // expected-error {{argument value 8 is outside the valid range [0, 7]}}
}
__m128i test__builtin_ia32_vpcomd(__m128i __a, __m128i __b) {
- __builtin_ia32_vpcomud(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}}
+ return __builtin_ia32_vpcomud(__a, __b, 8); // expected-error {{argument value 8 is outside the valid range [0, 7]}}
}
__m128i test__builtin_ia32_vpcomq(__m128i __a, __m128i __b) {
- __builtin_ia32_vpcomuq(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}}
+ return __builtin_ia32_vpcomuq(__a, __b, 8); // expected-error {{argument value 8 is outside the valid range [0, 7]}}
}
__mmask16 test__builtin_ia32_cmpps512_mask_rounding(__m512 __a, __m512 __b, __mmask16 __u) {
- __builtin_ia32_cmpps512_mask(__a, __b, 0, __u, 0); // expected-error {{invalid rounding argument}}
+ return __builtin_ia32_cmpps512_mask(__a, __b, 0, __u, 0); // expected-error {{invalid rounding argument}}
}
__m128i test_mm_mask_i32gather_epi32(__m128i a, int const *b, __m128i c, __m128i mask) {
return __builtin_ia32_gatherd_d(a, b, c, mask, 5); // expected-error {{scale argument must be 1, 2, 4, or 8}}
}
-__m512i _mm512_mask_prefetch_i32gather_ps(__m512i index, __mmask16 mask, int const *addr) {
- return __builtin_ia32_gatherpfdps(mask, index, addr, 5, 1); // expected-error {{scale argument must be 1, 2, 4, or 8}}
+void _mm512_mask_prefetch_i32gather_ps(__m512i index, __mmask16 mask, int const *addr) {
+ __builtin_ia32_gatherpfdps(mask, index, addr, 5, 1); // expected-error {{scale argument must be 1, 2, 4, or 8}}
+}
+
+void _mm512_mask_prefetch_i32gather_ps_2(__m512i index, __mmask16 mask, int const *addr) {
+ __builtin_ia32_gatherpfdps(mask, index, addr, 1, 1); // expected-error {{argument value 1 is outside the valid range [2, 3]}}
+}
+
+__m512i test_mm512_shldi_epi64(__m512i __A, __m512i __B) {
+ return __builtin_ia32_vpshldq512(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
+}
+
+__m512i test_mm512_shldi_epi32(__m512i __A, __m512i __B) {
+ return __builtin_ia32_vpshldd512(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
+}
+
+__m512i test_mm512_shldi_epi16(__m512i __A, __m512i __B) {
+ return __builtin_ia32_vpshldw512(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
+}
+
+__m512i test_mm512_shrdi_epi64(__m512i __A, __m512i __B) {
+ return __builtin_ia32_vpshrdq512(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
+}
+
+__m512i test_mm512_shrdi_epi32(__m512i __A, __m512i __B) {
+ return __builtin_ia32_vpshrdd512(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
+}
+
+__m512i test_mm512_shrdi_epi16(__m512i __A, __m512i __B) {
+ return __builtin_ia32_vpshrdw512(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
+}
+
+__m256i test_mm256_shldi_epi64(__m256i __A, __m256i __B) {
+ return __builtin_ia32_vpshldq256(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
}
-__m512 _mm512_mask_prefetch_i32gather_ps_2(__m512i index, __mmask16 mask, int const *addr) {
- return __builtin_ia32_gatherpfdps(mask, index, addr, 1, 1); // expected-error {{argument should be a value from 2 to 3}}
+__m128i test_mm128_shldi_epi64( __m128i __A, __m128i __B) {
+ return __builtin_ia32_vpshldq128(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
}
+__m256i test_mm256_shldi_epi32(__m256i __A, __m256i __B) {
+ return __builtin_ia32_vpshldd256(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
+}
+
+__m128i test_mm128_shldi_epi32(__m128i __A, __m128i __B) {
+ return __builtin_ia32_vpshldd128(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
+}
+
+__m256i test_mm256_shldi_epi16( __m256i __A, __m256i __B) {
+ return __builtin_ia32_vpshldw256(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
+}
+
+__m128i test_mm128_shldi_epi16(__m128i __A, __m128i __B) {
+ return __builtin_ia32_vpshldw128(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
+}
+
+__m256i test_mm256_shrdi_epi64(__m256i __A, __m256i __B) {
+ return __builtin_ia32_vpshrdq256(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
+}
+
+__m128i test_mm128_shrdi_epi64(__m128i __A, __m128i __B) {
+ return __builtin_ia32_vpshrdq128(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
+}
+
+__m256i test_mm256_shrdi_epi32(__m256i __A, __m256i __B) {
+ return __builtin_ia32_vpshrdd256(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
+}
+
+__m128i test_mm128_shrdi_epi32(__m128i __A, __m128i __B) {
+ return __builtin_ia32_vpshrdd128(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
+}
+
+__m256i test_mm256_shrdi_epi16(__m256i __A, __m256i __B) {
+ return __builtin_ia32_vpshrdw256(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
+}
+
+__m128i test_mm128_shrdi_epi16(__m128i __A, __m128i __B) {
+ return __builtin_ia32_vpshrdw128(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
+}
diff --git a/test/Sema/builtins-x86.cpp b/test/Sema/builtins-x86.cpp
new file mode 100644
index 0000000000000..0f37f4a34649e
--- /dev/null
+++ b/test/Sema/builtins-x86.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin -fsyntax-only -verify %s
+//
+// Ensure that when we use builtins in C++ code with templates that compute the
+// valid immediate, the dead code with the invalid immediate doesn't error.
+// expected-no-diagnostics
+
+typedef short __v8hi __attribute__((__vector_size__(16)));
+
+template <int Imm>
+__v8hi test(__v8hi a) {
+ if (Imm < 4)
+ return __builtin_ia32_pshuflw(a, 0x55 * Imm);
+ else
+ return __builtin_ia32_pshuflw(a, 0x55 * (Imm - 4));
+}
+
+template __v8hi test<0>(__v8hi);
+template __v8hi test<1>(__v8hi);
+template __v8hi test<2>(__v8hi);
+template __v8hi test<3>(__v8hi);
+template __v8hi test<4>(__v8hi);
+template __v8hi test<5>(__v8hi);
+template __v8hi test<6>(__v8hi);
+template __v8hi test<7>(__v8hi);
diff --git a/test/Sema/builtins.c b/test/Sema/builtins.c
index 0e2925e0748da..a831d030ef116 100644
--- a/test/Sema/builtins.c
+++ b/test/Sema/builtins.c
@@ -248,3 +248,31 @@ char * Test20(char *p, const char *in, unsigned n)
return buf;
}
+
+void test21(const int *ptr) {
+ __sync_fetch_and_add(ptr, 1); // expected-error{{address argument to atomic builtin cannot be const-qualified ('const int *' invalid)}}
+ __atomic_fetch_add(ptr, 1, 0); // expected-error {{address argument to atomic operation must be a pointer to non-const type ('const int *' invalid)}}
+}
+
+void test22(void) {
+ (void)__builtin_signbit(); // expected-error{{too few arguments to function call, expected 1, have 0}}
+ (void)__builtin_signbit(1.0, 2.0, 3.0); // expected-error{{too many arguments to function call, expected 1, have 3}}
+ (void)__builtin_signbit(1); // expected-error {{floating point classification requires argument of floating point type (passed in 'int')}}
+ (void)__builtin_signbit(1.0);
+ (void)__builtin_signbit(1.0f);
+ (void)__builtin_signbit(1.0L);
+
+ (void)__builtin_signbitf(); // expected-error{{too few arguments to function call, expected 1, have 0}}
+ (void)__builtin_signbitf(1.0, 2.0, 3.0); // expected-error{{too many arguments to function call, expected 1, have 3}}
+ (void)__builtin_signbitf(1);
+ (void)__builtin_signbitf(1.0);
+ (void)__builtin_signbitf(1.0f);
+ (void)__builtin_signbitf(1.0L);
+
+ (void)__builtin_signbitl(); // expected-error{{too few arguments to function call, expected 1, have 0}}
+ (void)__builtin_signbitl(1.0, 2.0, 3.0); // expected-error{{too many arguments to function call, expected 1, have 3}}
+ (void)__builtin_signbitl(1);
+ (void)__builtin_signbitl(1.0);
+ (void)__builtin_signbitl(1.0f);
+ (void)__builtin_signbitl(1.0L);
+}
diff --git a/test/Sema/compare.c b/test/Sema/compare.c
index 97586a7cc05e3..b2b486f59f878 100644
--- a/test/Sema/compare.c
+++ b/test/Sema/compare.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -pedantic -verify -Wsign-compare %s -Wno-unreachable-code
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -pedantic -verify -Wsign-compare -Wtautological-constant-in-range-compare %s -Wno-unreachable-code
int test(char *C) { // nothing here should warn.
return C != ((void*)0);
@@ -391,3 +391,16 @@ typedef char two_chars[2];
void test12(unsigned a) {
if (0 && -1 > a) { }
}
+
+// PR36008
+
+enum PR36008EnumTest {
+ kPR36008Value = 0,
+};
+
+void pr36008(enum PR36008EnumTest lhs) {
+ __typeof__(lhs) x = lhs;
+ __typeof__(kPR36008Value) y = (kPR36008Value);
+ if (x == y) x = y; // no warning
+ if (y == x) y = x; // no warning
+}
diff --git a/test/Sema/complex-int.c b/test/Sema/complex-int.c
index 2b797e5a14ad6..52ea44dd77fb1 100644
--- a/test/Sema/complex-int.c
+++ b/test/Sema/complex-int.c
@@ -18,6 +18,10 @@ result = arr*brr;
result = xx*yy;
switch (arr) { // expected-error{{statement requires expression of integer type ('_Complex int' invalid)}}
+ case brr: ;
+ case xx: ;
+}
+switch (ii) {
case brr: ; // expected-error{{expression is not an integer constant expression}}
case xx: ; // expected-error{{expression is not an integer constant expression}}
}
diff --git a/test/Sema/constant-builtins-2.c b/test/Sema/constant-builtins-2.c
index a4baecb615587..40cfce1f4a003 100644
--- a/test/Sema/constant-builtins-2.c
+++ b/test/Sema/constant-builtins-2.c
@@ -5,24 +5,35 @@
double g0 = __builtin_huge_val();
float g1 = __builtin_huge_valf();
long double g2 = __builtin_huge_vall();
+#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
+__float128 g2_2 = __builtin_huge_valf128();
+#endif
double g3 = __builtin_inf();
float g4 = __builtin_inff();
long double g5 = __builtin_infl();
+#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
+__float128 g5_2 = __builtin_inff128();
+#endif
double g6 = __builtin_nan("");
float g7 = __builtin_nanf("");
long double g8 = __builtin_nanl("");
+#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
+__float128 g8_2 = __builtin_nanf128("");
+#endif
// GCC constant folds these too (via native strtol):
//double g6_1 = __builtin_nan("1");
//float g7_1 = __builtin_nanf("1");
//long double g8_1 = __builtin_nanl("1");
-// APFloat doesn't have signalling NaN functions.
-//double g9 = __builtin_nans("");
-//float g10 = __builtin_nansf("");
-//long double g11 = __builtin_nansl("");
+double g9 = __builtin_nans("");
+float g10 = __builtin_nansf("");
+long double g11 = __builtin_nansl("");
+#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
+__float128 g11_2 = __builtin_nansf128("");
+#endif
//int g12 = __builtin_abs(-12);
@@ -32,10 +43,16 @@ double g13_1 = __builtin_fabs(-__builtin_inf());
float g14 = __builtin_fabsf(-12.f);
// GCC doesn't eat this one.
//long double g15 = __builtin_fabsfl(-12.0L);
+#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
+__float128 g15_2 = __builtin_fabsf128(-12.q);
+#endif
float g16 = __builtin_copysign(1.0, -1.0);
double g17 = __builtin_copysignf(1.0f, -1.0f);
long double g18 = __builtin_copysignl(1.0L, -1.0L);
+#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
+__float128 g18_2 = __builtin_copysignf128(1.0q, -1.0q);
+#endif
char classify_nan [__builtin_fpclassify(+1, -1, -1, -1, -1, __builtin_nan(""))];
char classify_snan [__builtin_fpclassify(+1, -1, -1, -1, -1, __builtin_nans(""))];
diff --git a/test/Sema/conversion.c b/test/Sema/conversion.c
index 89c34c6a224cc..aa591c9fa60d1 100644
--- a/test/Sema/conversion.c
+++ b/test/Sema/conversion.c
@@ -429,3 +429,22 @@ void test27(ushort16 constants) {
ushort16 crCbScale = pairedConstants.s4; // expected-warning {{implicit conversion loses integer precision: 'uint32_t' (aka 'unsigned int') to 'ushort16'}}
ushort16 brBias = pairedConstants.s6; // expected-warning {{implicit conversion loses integer precision: 'uint32_t' (aka 'unsigned int') to 'ushort16'}}
}
+
+
+float double2float_test1(double a) {
+ return a; // expected-warning {{implicit conversion loses floating-point precision: 'double' to 'float'}}
+}
+
+void double2float_test2(double a, float *b) {
+ *b += a; // expected-warning {{implicit conversion when assigning computation result loses floating-point precision: 'double' to 'float'}}
+}
+
+float sinf (float x);
+double double2float_test3(double a) {
+ return sinf(a); // expected-warning {{implicit conversion loses floating-point precision: 'double' to 'float'}}
+}
+
+float double2float_test4(double a, float b) {
+ b -= a; // expected-warning {{implicit conversion when assigning computation result loses floating-point precision: 'double' to 'float'}}
+ return b;
+}
diff --git a/test/Sema/cxx-as-c.c b/test/Sema/cxx-as-c.c
new file mode 100644
index 0000000000000..41d7350d1f15e
--- /dev/null
+++ b/test/Sema/cxx-as-c.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -verify
+
+// PR36157
+struct Foo {
+ Foo(int n) : n_(n) {} // expected-error 1+{{}} expected-warning 1+{{}}
+private:
+ int n;
+};
+int main() { Foo f; } // expected-error 1+{{}}
diff --git a/test/Sema/darwin-tls.c b/test/Sema/darwin-tls.c
index 0fcf096d92baa..6279e0b7e4122 100644
--- a/test/Sema/darwin-tls.c
+++ b/test/Sema/darwin-tls.c
@@ -1,12 +1,18 @@
// RUN: not %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.6 %s 2>&1 | FileCheck %s --check-prefix NO-TLS
// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.7 %s 2>&1 | FileCheck %s --check-prefix TLS
+
// RUN: not %clang_cc1 -fsyntax-only -triple arm64-apple-ios7.1 %s 2>&1 | FileCheck %s --check-prefix NO-TLS
// RUN: %clang_cc1 -fsyntax-only -triple arm64-apple-ios8.0 %s 2>&1 | FileCheck %s --check-prefix TLS
// RUN: not %clang_cc1 -fsyntax-only -triple thumbv7s-apple-ios8.3 %s 2>&1 | FileCheck %s --check-prefix NO-TLS
// RUN: %clang_cc1 -fsyntax-only -triple thumbv7s-apple-ios9.0 %s 2>&1 | FileCheck %s --check-prefix TLS
// RUN: %clang_cc1 -fsyntax-only -triple armv7-apple-ios9.0 %s 2>&1 | FileCheck %s --check-prefix TLS
+// RUN: not %clang_cc1 -fsyntax-only -triple i386-apple-ios9.0-simulator %s 2>&1 | FileCheck %s --check-prefix NO-TLS
+// RUN: %clang_cc1 -fsyntax-only -triple i386-apple-ios10.0-simulator %s 2>&1 | FileCheck %s --check-prefix TLS
+
// RUN: not %clang_cc1 -fsyntax-only -triple thumbv7k-apple-watchos1.0 %s 2>&1 | FileCheck %s --check-prefix NO-TLS
// RUN: %clang_cc1 -fsyntax-only -triple thumbv7k-apple-watchos2.0 %s 2>&1 | FileCheck %s --check-prefix TLS
+// RUN: not %clang_cc1 -fsyntax-only -triple i386-apple-watchos2.0-simulator %s 2>&1 | FileCheck %s --check-prefix NO-TLS
+// RUN: %clang_cc1 -fsyntax-only -triple i386-apple-watchos3.0-simulator %s 2>&1 | FileCheck %s --check-prefix TLS
__thread int a;
diff --git a/test/Sema/diagnose_if.c b/test/Sema/diagnose_if.c
index 38a3307d924a5..00bb4770f053a 100644
--- a/test/Sema/diagnose_if.c
+++ b/test/Sema/diagnose_if.c
@@ -157,3 +157,13 @@ void runAlwaysWarnWithArg(int a) {
// Bug: we would complain about `a` being undeclared if this was spelled
// __diagnose_if__.
void underbarName(int a) __attribute__((__diagnose_if__(a, "", "warning")));
+
+// PR38095
+void constCharStar(const char *str) __attribute__((__diagnose_if__(!str[0], "empty string not allowed", "error"))); // expected-note {{from}}
+void charStar(char *str) __attribute__((__diagnose_if__(!str[0], "empty string not allowed", "error"))); // expected-note {{from}}
+void runConstCharStar() {
+ constCharStar("foo");
+ charStar("bar");
+ constCharStar(""); // expected-error {{empty string not allowed}}
+ charStar(""); // expected-error {{empty string not allowed}}
+}
diff --git a/test/Sema/error-type-safety.cpp b/test/Sema/error-type-safety.cpp
index 223645de0f713..c5aa48fd1e814 100644
--- a/test/Sema/error-type-safety.cpp
+++ b/test/Sema/error-type-safety.cpp
@@ -3,21 +3,50 @@
#define INT_TAG 42
static const int test_in
- __attribute__((type_tag_for_datatype(test, int))) = INT_TAG;
+ __attribute__((type_tag_for_datatype(test, int))) = INT_TAG;
// Argument index: 1, Type tag index: 2
void test_bounds_index(...)
- __attribute__((argument_with_type_tag(test, 1, 2)));
+ __attribute__((argument_with_type_tag(test, 1, 2)));
+
+// Argument index: 1, Type tag index: 2
+void test_bounds_index_ptr(void *, ...)
+ __attribute__((pointer_with_type_tag(test, 1, 2)));
// Argument index: 3, Type tag index: 1
void test_bounds_arg_index(...)
- __attribute__((argument_with_type_tag(test, 3, 1)));
+ __attribute__((argument_with_type_tag(test, 3, 1)));
+
+class C {
+public:
+ // Argument index: 2, Type tag index: 3
+ void test_bounds_index(...)
+ __attribute__((argument_with_type_tag(test, 2, 3)));
+
+ // Argument index: 2, Type tag index: 3
+ void test_bounds_index_ptr(void *, ...)
+ __attribute__((pointer_with_type_tag(test, 2, 3)));
+
+ // Argument index: 4, Type tag index: 2
+ void test_bounds_arg_index(...)
+ __attribute__((argument_with_type_tag(test, 4, 2)));
+};
void test_bounds()
{
+ C c;
+
// Test the boundary edges (ensure no off-by-one) with argument indexing.
test_bounds_index(1, INT_TAG);
+ c.test_bounds_index(1, INT_TAG);
+ test_bounds_index_ptr(0, INT_TAG);
+ c.test_bounds_index_ptr(0, INT_TAG);
+
+ test_bounds_index(1); // expected-error {{type tag index 2 is greater than the number of arguments specified}}
+ c.test_bounds_index(1); // expected-error {{type tag index 3 is greater than the number of arguments specified}}
+ test_bounds_index_ptr(0); // expected-error {{type tag index 2 is greater than the number of arguments specified}}
+ c.test_bounds_index_ptr(0); // expected-error {{type tag index 3 is greater than the number of arguments specified}}
- test_bounds_index(1); // expected-error {{type tag index 2 is greater than the number of arguments specified}}
- test_bounds_arg_index(INT_TAG, 1); // expected-error {{argument index 3 is greater than the number of arguments specified}}
+ test_bounds_arg_index(INT_TAG, 1); // expected-error {{argument index 3 is greater than the number of arguments specified}}
+ c.test_bounds_arg_index(INT_TAG, 1); // expected-error {{argument index 4 is greater than the number of arguments specified}}
}
diff --git a/test/Sema/ext_vector_comparisons.c b/test/Sema/ext_vector_comparisons.c
index 605ba6c55e333..4c632a412f44d 100644
--- a/test/Sema/ext_vector_comparisons.c
+++ b/test/Sema/ext_vector_comparisons.c
@@ -6,12 +6,12 @@ static int4 test1() {
int4 vec, rv;
// comparisons to self...
- return vec == vec; // expected-warning{{self-comparison always evaluates to a constant}}
- return vec != vec; // expected-warning{{self-comparison always evaluates to a constant}}
- return vec < vec; // expected-warning{{self-comparison always evaluates to a constant}}
- return vec <= vec; // expected-warning{{self-comparison always evaluates to a constant}}
- return vec > vec; // expected-warning{{self-comparison always evaluates to a constant}}
- return vec >= vec; // expected-warning{{self-comparison always evaluates to a constant}}
+ return vec == vec; // expected-warning{{self-comparison always evaluates to true}}
+ return vec != vec; // expected-warning{{self-comparison always evaluates to false}}
+ return vec < vec; // expected-warning{{self-comparison always evaluates to false}}
+ return vec <= vec; // expected-warning{{self-comparison always evaluates to true}}
+ return vec > vec; // expected-warning{{self-comparison always evaluates to false}}
+ return vec >= vec; // expected-warning{{self-comparison always evaluates to true}}
}
diff --git a/test/Sema/float128-ld-incompatibility.cpp b/test/Sema/float128-ld-incompatibility.cpp
index d993ed7b081c3..369b14a87e32a 100644
--- a/test/Sema/float128-ld-incompatibility.cpp
+++ b/test/Sema/float128-ld-incompatibility.cpp
@@ -1,10 +1,12 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 \
-// RUN: -triple powerpc64le-unknown-linux-gnu -target-cpu pwr8 \
+// RUN: -triple powerpc64le-unknown-linux-gnu -target-cpu pwr9 \
// RUN: -target-feature +float128 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -triple x86_64-unknown-linux-gnu -Wno-unused-value -Wno-parentheses %s
__float128 qf();
long double ldf();
+#ifdef __PPC__
// FIXME: once operations between long double and __float128 are implemented for
// targets where the types are different, these next two will change
long double ld{qf()}; // expected-error {{cannot initialize a variable of type 'long double' with an rvalue of type '__float128'}}
@@ -17,6 +19,7 @@ auto test1(__float128 q, long double ld) -> decltype(q + ld) { // expected-error
auto test2(long double a, __float128 b) -> decltype(a + b) { // expected-error {{invalid operands to binary expression ('long double' and '__float128')}}
return a + b; // expected-error {{invalid operands to binary expression ('long double' and '__float128')}}
}
+#endif
void test3(bool b) {
long double ld;
diff --git a/test/Sema/inline-asm-validate-amdgpu.cl b/test/Sema/inline-asm-validate-amdgpu.cl
index bc2580c5738bb..51009ecb3f1e0 100644
--- a/test/Sema/inline-asm-validate-amdgpu.cl
+++ b/test/Sema/inline-asm-validate-amdgpu.cl
@@ -74,3 +74,8 @@ test_double(const __global double *a, const __global double *b, __global double
c[i] = ci;
}
+
+void test_long(int arg0) {
+ long v15_16;
+ __asm volatile("v_lshlrev_b64 v[15:16], 0, %0" : "={v[15:16]}"(v15_16) : "v"(arg0));
+}
diff --git a/test/Sema/integer-overflow.c b/test/Sema/integer-overflow.c
index 44c2629ebf7bc..d66ce7ff16472 100644
--- a/test/Sema/integer-overflow.c
+++ b/test/Sema/integer-overflow.c
@@ -158,6 +158,21 @@ uint64_t check_integer_overflows(int i) {
return ((4608 * 1024 * 1024) + ((uint64_t)(4608 * 1024 * 1024)));
}
+void check_integer_overflows_in_function_calls() {
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+ (void)f0(4608 * 1024 * 1024);
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+ uint64_t x = f0(4608 * 1024 * 1024);
+
+// expected-warning@+2 {{overflow in expression; result is 536870912 with type 'int'}}
+ uint64_t (*f0_ptr)(uint64_t) = &f0;
+ (void)(*f0_ptr)(4608 * 1024 * 1024);
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+ (void)f2(0, f0(4608 * 1024 * 1024));
+}
+
struct s {
unsigned x;
unsigned y;
diff --git a/test/Sema/internal_linkage.c b/test/Sema/internal_linkage.c
index 37090a3333150..57315d826e242 100644
--- a/test/Sema/internal_linkage.c
+++ b/test/Sema/internal_linkage.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fdouble-square-bracket-attributes %s
int var __attribute__((internal_linkage));
int var2 __attribute__((internal_linkage,common)); // expected-error{{'internal_linkage' and 'common' attributes are not compatible}} \
@@ -19,3 +19,9 @@ struct __attribute__((internal_linkage)) S { // expected-warning{{'internal_link
};
__attribute__((internal_linkage("foo"))) int g() {} // expected-error{{'internal_linkage' attribute takes no arguments}}
+
+int var6 [[clang::internal_linkage]];
+int var7 [[clang::internal_linkage]] __attribute__((common)); // expected-error{{'internal_linkage' and 'common' attributes are not compatible}} \
+ // expected-note{{conflicting attribute is here}}
+__attribute__((common)) int var8 [[clang::internal_linkage]]; // expected-error{{'internal_linkage' and 'common' attributes are not compatible}} \
+ // expected-note{{conflicting attribute is here}}
diff --git a/test/Sema/mms-bitfields.c b/test/Sema/mms-bitfields.c
index d238a7a10d0d2..cee5b0669d252 100644
--- a/test/Sema/mms-bitfields.c
+++ b/test/Sema/mms-bitfields.c
@@ -11,3 +11,18 @@ struct
// MS pads out bitfields between different types.
static int arr[(sizeof(t) == 8) ? 1 : -1];
+
+#pragma pack (push,1)
+
+typedef unsigned int UINT32;
+
+struct Inner {
+ UINT32 A : 1;
+ UINT32 B : 1;
+ UINT32 C : 1;
+ UINT32 D : 30;
+} Inner;
+
+#pragma pack (pop)
+
+static int arr2[(sizeof(Inner) == 8) ? 1 : -1];
diff --git a/test/Sema/ms_wide_predefined_expr.cpp b/test/Sema/ms_wide_predefined_expr.cpp
index d56d1576cd0c7..eb6efa5cdbefc 100644
--- a/test/Sema/ms_wide_predefined_expr.cpp
+++ b/test/Sema/ms_wide_predefined_expr.cpp
@@ -7,6 +7,8 @@
void abcdefghi12(void) {
const wchar_t (*ss)[12] = &STR2WSTR(__FUNCTION__);
static int arr[sizeof(STR2WSTR(__FUNCTION__))==12*sizeof(wchar_t) ? 1 : -1];
+ const wchar_t (*ss2)[31] = &STR2WSTR(__FUNCSIG__);
+ static int arr2[sizeof(STR2WSTR(__FUNCSIG__))==31*sizeof(wchar_t) ? 1 : -1];
}
namespace PR13206 {
diff --git a/test/Sema/multistep-explicit-cast.c b/test/Sema/multistep-explicit-cast.c
new file mode 100644
index 0000000000000..aeb5919618126
--- /dev/null
+++ b/test/Sema/multistep-explicit-cast.c
@@ -0,0 +1,70 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -ast-dump %s | FileCheck %s
+
+// We are checking that implicit casts don't get marked with 'part_of_explicit_cast',
+// while in explicit casts, the implicitly-inserted implicit casts are marked with 'part_of_explicit_cast'
+
+unsigned char implicitcast_0(unsigned int x) {
+ // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} implicitcast_0 'unsigned char (unsigned int)'{{$}}
+ // CHECK: ImplicitCastExpr {{.*}} <col:{{.*}}> 'unsigned char' <IntegralCast>{{$}}
+ // CHECK-NEXT: ImplicitCastExpr {{.*}} <col:{{.*}}> 'unsigned int' <LValueToRValue>{{$}}
+ // CHECK-NEXT: DeclRefExpr {{.*}} <col:{{.*}}> 'unsigned int' lvalue ParmVar {{.*}} 'x' 'unsigned int'{{$}}
+ return x;
+}
+
+signed char implicitcast_1(unsigned int x) {
+ // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} implicitcast_1 'signed char (unsigned int)'{{$}}
+ // CHECK: ImplicitCastExpr {{.*}} <col:{{.*}}> 'signed char' <IntegralCast>{{$}}
+ // CHECK-NEXT: ImplicitCastExpr {{.*}} <col:{{.*}}> 'unsigned int' <LValueToRValue>{{$}}
+ // CHECK-NEXT: DeclRefExpr {{.*}} <col:{{.*}}> 'unsigned int' lvalue ParmVar {{.*}} 'x' 'unsigned int'{{$}}
+ return x;
+}
+
+unsigned char implicitcast_2(signed int x) {
+ // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} implicitcast_2 'unsigned char (int)'{{$}}
+ // CHECK: ImplicitCastExpr {{.*}} <col:{{.*}}> 'unsigned char' <IntegralCast>{{$}}
+ // CHECK-NEXT: ImplicitCastExpr {{.*}} <col:{{.*}}> 'int' <LValueToRValue>{{$}}
+ // CHECK-NEXT: DeclRefExpr {{.*}} <col:{{.*}}> 'int' lvalue ParmVar {{.*}} 'x' 'int'{{$}}
+ return x;
+}
+
+signed char implicitcast_3(signed int x) {
+ // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} implicitcast_3 'signed char (int)'{{$}}
+ // CHECK: ImplicitCastExpr {{.*}} <col:{{.*}}> 'signed char' <IntegralCast>{{$}}
+ // CHECK-NEXT: ImplicitCastExpr {{.*}} <col:{{.*}}> 'int' <LValueToRValue>{{$}}
+ // CHECK-NEXT: DeclRefExpr {{.*}} <col:{{.*}}> 'int' lvalue ParmVar {{.*}} 'x' 'int'{{$}}
+ return x;
+}
+
+//----------------------------------------------------------------------------//
+
+unsigned char cstylecast_0(unsigned int x) {
+ // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} cstylecast_0 'unsigned char (unsigned int)'{{$}}
+ // CHECK: CStyleCastExpr {{.*}} <col:{{.*}}> 'unsigned char' <IntegralCast>{{$}}
+ // CHECK-NEXT: ImplicitCastExpr {{.*}} <col:{{.*}}> 'unsigned int' <LValueToRValue> part_of_explicit_cast{{$}}
+ // CHECK-NEXT: DeclRefExpr {{.*}} <col:{{.*}}> 'unsigned int' lvalue ParmVar {{.*}} 'x' 'unsigned int'{{$}}
+ return (unsigned char)x;
+}
+
+signed char cstylecast_1(unsigned int x) {
+ // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} cstylecast_1 'signed char (unsigned int)'{{$}}
+ // CHECK: CStyleCastExpr {{.*}} <col:{{.*}}> 'signed char' <IntegralCast>{{$}}
+ // CHECK-NEXT: ImplicitCastExpr {{.*}} <col:{{.*}}> 'unsigned int' <LValueToRValue> part_of_explicit_cast{{$}}
+ // CHECK-NEXT: DeclRefExpr {{.*}} <col:{{.*}}> 'unsigned int' lvalue ParmVar {{.*}} 'x' 'unsigned int'{{$}}
+ return (signed char)x;
+}
+
+unsigned char cstylecast_2(signed int x) {
+ // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} cstylecast_2 'unsigned char (int)'{{$}}
+ // CHECK: CStyleCastExpr {{.*}} <col:{{.*}}> 'unsigned char' <IntegralCast>{{$}}
+ // CHECK-NEXT: ImplicitCastExpr {{.*}} <col:{{.*}}> 'int' <LValueToRValue> part_of_explicit_cast{{$}}
+ // CHECK-NEXT: DeclRefExpr {{.*}} <col:{{.*}}> 'int' lvalue ParmVar {{.*}} 'x' 'int'{{$}}
+ return (unsigned char)x;
+}
+
+signed char cstylecast_3(signed int x) {
+ // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} cstylecast_3 'signed char (int)'{{$}}
+ // CHECK: CStyleCastExpr {{.*}} <col:{{.*}}> 'signed char' <IntegralCast>{{$}}
+ // CHECK-NEXT: ImplicitCastExpr {{.*}} <col:{{.*}}> 'int' <LValueToRValue> part_of_explicit_cast{{$}}
+ // CHECK-NEXT: DeclRefExpr {{.*}} <col:{{.*}}> 'int' lvalue ParmVar {{.*}} 'x' 'int'{{$}}
+ return (signed char)x;
+}
diff --git a/test/Sema/no_stack_protector.c b/test/Sema/no_stack_protector.c
new file mode 100644
index 0000000000000..8e52f0982f52f
--- /dev/null
+++ b/test/Sema/no_stack_protector.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void __attribute__((no_stack_protector)) foo() {}
+int __attribute__((no_stack_protector)) var; // expected-warning {{'no_stack_protector' attribute only applies to functions}}
+void __attribute__((no_stack_protector(2))) bar() {} // expected-error {{'no_stack_protector' attribute takes no arguments}}
diff --git a/test/Sema/nocf_check_attr_not_allowed.c b/test/Sema/nocf_check_attr_not_allowed.c
new file mode 100644
index 0000000000000..2ba71d4aa4c74
--- /dev/null
+++ b/test/Sema/nocf_check_attr_not_allowed.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -triple powerpc-unknown-linux-gnu -fsyntax-only -verify -fcf-protection=branch %s
+// RUN: %clang_cc1 -triple arm-unknown-linux-gnu -fsyntax-only -verify -fcf-protection=branch %s
+// RUN: %clang_cc1 -triple arm-unknown-linux-gnu -fsyntax-only -verify %s
+
+void __attribute__((nocf_check)) foo(); // expected-warning-re{{{{((unknown attribute 'nocf_check' ignored)|('nocf_check' attribute ignored; use -fcf-protection to enable the attribute))}}}}
diff --git a/test/Sema/nonnull.c b/test/Sema/nonnull.c
index b589bb3d1ffda..3410d36ddfbc9 100644
--- a/test/Sema/nonnull.c
+++ b/test/Sema/nonnull.c
@@ -1,5 +1,9 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// rdar://9584012
+//
+// Verify All warnings are still issued with the option -fno-delete-null-pointer-checks
+// if nullptr is passed to function with nonnull attribute.
+// RUN: %clang_cc1 -fsyntax-only -fno-delete-null-pointer-checks -verify %s
typedef struct {
char *str;
diff --git a/test/Sema/pr30372.c b/test/Sema/pr30372.c
index e10fa2c841305..87c1c1bc9342c 100644
--- a/test/Sema/pr30372.c
+++ b/test/Sema/pr30372.c
@@ -1,7 +1,7 @@
// REQUIRES: x86-registered-target
// RUN: %clang_cc1 %s -triple i386-pc-windows-msvc18.0.0 -disable-free -fms-volatile -fms-extensions -fms-compatibility -fms-compatibility-version=18 -std=c++11 -x c++
-// Check that the parser catching an 'error' from forward declaration of "location" does not lexer out it's subsequent declation.
+// Check that the parser catching an 'error' from forward declaration of "location" does not lexer out it's subsequent declaration.
void foo() {
__asm {
diff --git a/test/Sema/pragma-align-no-header-change-warning.c b/test/Sema/pragma-align-no-header-change-warning.c
new file mode 100644
index 0000000000000..dcd61d0705677
--- /dev/null
+++ b/test/Sema/pragma-align-no-header-change-warning.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -triple i686-apple-darwin9 -fsyntax-only -Wpragma-pack -I %S/Inputs -verify %s
+// expected-no-diagnostics
+
+#include "pragma-align-no-header-change-warning.h"
+
diff --git a/test/Sema/preserve-call-conv.c b/test/Sema/preserve-call-conv.c
index 6bd049ffdca29..6add3095c667f 100644
--- a/test/Sema/preserve-call-conv.c
+++ b/test/Sema/preserve-call-conv.c
@@ -2,6 +2,7 @@
// RUN: %clang_cc1 %s -fsyntax-only -triple arm64-unknown-unknown -verify
// RUN: %clang_cc1 %s -fsyntax-only -triple x86_64-unknown-windows-msvc -verify
// RUN: %clang_cc1 %s -fsyntax-only -triple aarch64-unknown-windows-msvc -verify
+// RUN: %clang_cc1 %s -fsyntax-only -triple thumbv7-unknown-windows-msvc -verify
typedef void typedef_fun_t(int);
diff --git a/test/Sema/redefine_extname.c b/test/Sema/redefine_extname.c
index 8202176c9f7b5..b1e8dab9244f8 100644
--- a/test/Sema/redefine_extname.c
+++ b/test/Sema/redefine_extname.c
@@ -4,3 +4,4 @@
#pragma redefine_extname foo_static bar_static
static int foo_static() { return 1; } // expected-warning {{#pragma redefine_extname is applicable to external C declarations only; not applied to function 'foo_static'}}
+unsigned __int128_t; // expected-error {{redefinition of '__int128_t' as different kind of symbol}}
diff --git a/test/Sema/return.c b/test/Sema/return.c
index 2a58a6ef9e470..debf5ab55f5b5 100644
--- a/test/Sema/return.c
+++ b/test/Sema/return.c
@@ -283,6 +283,18 @@ lbl:
goto lbl;
}
+int test36a(int b) {
+ if (b)
+ return 43;
+ __builtin_unreachable();
+}
+
+int test36b(int b) {
+ if (b)
+ return 43;
+ __builtin_assume(0);
+}
+
// PR19074.
void abort(void) __attribute__((noreturn));
#define av_assert0(cond) do {\
diff --git a/test/Sema/riscv-interrupt-attr.c b/test/Sema/riscv-interrupt-attr.c
new file mode 100644
index 0000000000000..55f0863c1f533
--- /dev/null
+++ b/test/Sema/riscv-interrupt-attr.c
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -triple riscv32-unknown-elf -emit-llvm -DCHECK_IR < %s| FileCheck %s
+// RUN: %clang_cc1 -triple riscv64-unknown-elf -emit-llvm -DCHECK_IR < %s| FileCheck %s
+// RUN: %clang_cc1 %s -triple riscv32-unknown-elf -verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple riscv64-unknown-elf -verify -fsyntax-only
+
+#if defined(CHECK_IR)
+// CHECK-LABEL: @foo_user() #0
+// CHECK: ret void
+__attribute__((interrupt("user"))) void foo_user(void) {}
+// CHECK-LABEL: @foo_supervisor() #1
+// CHECK: ret void
+__attribute__((interrupt("supervisor"))) void foo_supervisor(void) {}
+// CHECK-LABEL: @foo_machine() #2
+// CHECK: ret void
+__attribute__((interrupt("machine"))) void foo_machine(void) {}
+// CHECK-LABEL: @foo_default() #2
+// CHECK: ret void
+__attribute__((interrupt())) void foo_default(void) {}
+// CHECK-LABEL: @foo_default2() #2
+// CHECK: ret void
+__attribute__((interrupt())) void foo_default2(void) {}
+// CHECK: attributes #0
+// CHECK: "interrupt"="user"
+// CHECK: attributes #1
+// CHECK: "interrupt"="supervisor"
+// CHECK: attributes #2
+// CHECK: "interrupt"="machine"
+#else
+struct a { int b; };
+
+struct a test __attribute__((interrupt)); // expected-warning {{'interrupt' attribute only applies to functions}}
+
+__attribute__((interrupt("USER"))) void foo1(void) {} // expected-warning {{'interrupt' attribute argument not supported: USER}}
+
+__attribute__((interrupt("user", 1))) void foo2(void) {} // expected-error {{'interrupt' attribute takes no more than 1 argument}}
+
+__attribute__((interrupt)) int foo3(void) {return 0;} // expected-warning {{RISC-V 'interrupt' attribute only applies to functions that have a 'void' return type}}
+
+__attribute__((interrupt())) void foo4();
+__attribute__((interrupt())) void foo4() {};
+
+__attribute__((interrupt())) void foo5(int a) {} // expected-warning {{RISC-V 'interrupt' attribute only applies to functions that have no parameters}}
+
+__attribute__((interrupt("user"), interrupt("supervisor"))) void foo6(void) {} // expected-warning {{repeated RISC-V 'interrupt' attribute}} \
+ // expected-note {{repeated RISC-V 'interrupt' attribute is here}}
+
+__attribute__((interrupt, interrupt)) void foo7(void) {} // expected-warning {{repeated RISC-V 'interrupt' attribute}} \
+ // expected-note {{repeated RISC-V 'interrupt' attribute is here}}
+
+__attribute__((interrupt(""))) void foo8(void) {} // expected-warning {{'interrupt' attribute argument not supported}}
+
+__attribute__((interrupt("user"))) void foo9(void);
+__attribute__((interrupt("supervisor"))) void foo9(void);
+__attribute__((interrupt("machine"))) void foo9(void);
+
+__attribute__((interrupt("user"))) void foo10(void) {}
+__attribute__((interrupt("supervisor"))) void foo11(void) {}
+__attribute__((interrupt("machine"))) void foo12(void) {}
+__attribute__((interrupt())) void foo13(void) {}
+__attribute__((interrupt)) void foo14(void) {}
+#endif
+
diff --git a/test/Sema/riscv-interrupt-attr.cpp b/test/Sema/riscv-interrupt-attr.cpp
new file mode 100644
index 0000000000000..a01999b3a1071
--- /dev/null
+++ b/test/Sema/riscv-interrupt-attr.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -x c++ -triple riscv32-unknown-elf -emit-llvm -DCHECK_IR < %s | FileCheck %s
+// RUN: %clang_cc1 -x c++ -triple riscv64-unknown-elf -emit-llvm -DCHECK_IR < %s | FileCheck %s
+// RUN: %clang_cc1 %s -triple riscv32-unknown-elf -verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple riscv64-unknown-elf -verify -fsyntax-only
+
+#if defined(CHECK_IR)
+// CHECK-LABEL: @_Z11foo_defaultv() #0
+// CHECK: ret void
+[[gnu::interrupt]] void foo_default() {}
+// CHECK: attributes #0
+// CHECK: "interrupt"="machine"
+#else
+[[gnu::interrupt]] [[gnu::interrupt]] void foo1() {} // expected-warning {{repeated RISC-V 'interrupt' attribute}} \
+ // expected-note {{repeated RISC-V 'interrupt' attribute is here}}
+[[gnu::interrupt]] void foo2() {}
+#endif
diff --git a/test/Sema/self-comparison.c b/test/Sema/self-comparison.c
index edb3a6a4c8a5f..4c848f030e133 100644
--- a/test/Sema/self-comparison.c
+++ b/test/Sema/self-comparison.c
@@ -60,7 +60,7 @@ int array_comparisons() {
return array1 >= array1; // expected-warning{{self-comparison always evaluates to true}}
//
- // compare differrent arrays
+ // compare different arrays
//
return array1 == array2; // expected-warning{{array comparison always evaluates to false}}
return array1 != array2; // expected-warning{{array comparison always evaluates to true}}
@@ -86,3 +86,8 @@ int R8435950(int i) {
return 1;
}
+__attribute__((weak)) int weak_1[3];
+__attribute__((weak)) int weak_2[3];
+_Bool compare_weak() {
+ return weak_1 == weak_2;
+}
diff --git a/test/Sema/sign-compare-enum.c b/test/Sema/sign-compare-enum.c
index 8661bd502fe5a..fb67e323f1d12 100644
--- a/test/Sema/sign-compare-enum.c
+++ b/test/Sema/sign-compare-enum.c
@@ -1,24 +1,77 @@
-// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -DUNSIGNED -verify -Wsign-compare %s
-// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -DSIGNED -verify -Wsign-compare %s
-// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -DUNSIGNED -DSILENCE -verify %s
-// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -DSIGNED -DSILENCE -verify %s
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -verify -Wsign-compare %s
+// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -verify -Wsign-compare %s
+// RUN: %clang_cc1 -x c++ -triple=x86_64-pc-linux-gnu -fsyntax-only -verify -Wsign-compare %s
+// RUN: %clang_cc1 -x c++ -triple=x86_64-pc-win32 -fsyntax-only -verify -Wsign-compare %s
-int main() {
- enum A { A_a = 0, A_b = 1 };
- static const int message[] = {0, 1};
- enum A a;
+// Check that -Wsign-compare is off by default.
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -verify -DSILENCE %s
+#ifdef SILENCE
+// expected-no-diagnostics
+#endif
+
+enum PosEnum {
+ A_a = 0,
+ A_b = 1,
+ A_c = 10
+};
+
+static const int message[] = {0, 1};
+
+int test_pos(enum PosEnum a) {
if (a < 2)
return 0;
-#if defined(SIGNED) && !defined(SILENCE)
- if (a < sizeof(message)/sizeof(message[0])) // expected-warning {{comparison of integers of different signs: 'enum A' and 'unsigned long long'}}
- return 0;
-#else
- // expected-no-diagnostics
+ // No warning, except in Windows C mode, where PosEnum is 'int' and it can
+ // take on any value according to the C standard.
+#if !defined(SILENCE) && defined(_WIN32) && !defined(__cplusplus)
+ // expected-warning@+2 {{comparison of integers of different signs}}
+#endif
if (a < 2U)
return 0;
+
+ unsigned uv = 2;
+#if !defined(SILENCE) && defined(_WIN32) && !defined(__cplusplus)
+ // expected-warning@+2 {{comparison of integers of different signs}}
+#endif
+ if (a < uv)
+ return 1;
+
+#if !defined(SILENCE) && defined(_WIN32) && !defined(__cplusplus)
+ // expected-warning@+2 {{comparison of integers of different signs}}
+#endif
if (a < sizeof(message)/sizeof(message[0]))
return 0;
+ return 4;
+}
+
+enum NegEnum {
+ NE_a = -1,
+ NE_b = 0,
+ NE_c = 10
+};
+
+int test_neg(enum NegEnum a) {
+ if (a < 2)
+ return 0;
+
+#ifndef SILENCE
+ // expected-warning@+2 {{comparison of integers of different signs}}
+#endif
+ if (a < 2U)
+ return 0;
+
+ unsigned uv = 2;
+#ifndef SILENCE
+ // expected-warning@+2 {{comparison of integers of different signs}}
+#endif
+ if (a < uv)
+ return 1;
+
+#ifndef SILENCE
+ // expected-warning@+2 {{comparison of integers of different signs}}
#endif
+ if (a < sizeof(message)/sizeof(message[0]))
+ return 0;
+ return 4;
}
diff --git a/test/Sema/switch.c b/test/Sema/switch.c
index a33300b41f540..638fd997679a4 100644
--- a/test/Sema/switch.c
+++ b/test/Sema/switch.c
@@ -372,7 +372,7 @@ void switch_on_ExtendedEnum1(enum ExtendedEnum1 e) {
case EE1_b: break;
case EE1_c: break; // no-warning
case EE1_d: break; // expected-warning {{case value not in enumerated type 'enum ExtendedEnum1'}}
- // expected-warning@-1 {{comparison of two values with different enumeration types in switch statement ('enum ExtendedEnum1' and 'const enum ExtendedEnum1_unrelated')}}
+ // expected-warning@-1 {{comparison of two values with different enumeration types in switch statement ('enum ExtendedEnum1' and 'enum ExtendedEnum1_unrelated')}}
}
}
diff --git a/test/Sema/tautological-constant-compare.c b/test/Sema/tautological-constant-compare.c
index c48aa99444538..b242f35dc6cf5 100644
--- a/test/Sema/tautological-constant-compare.c
+++ b/test/Sema/tautological-constant-compare.c
@@ -1,7 +1,13 @@
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -DTEST -verify %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wno-tautological-constant-compare -verify %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -DTEST -verify -x c++ %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wno-tautological-constant-compare -verify -x c++ %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wtautological-constant-in-range-compare -DTEST -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wtautological-constant-in-range-compare -DTEST -verify -x c++ %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wtautological-type-limit-compare -DTEST -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wtautological-type-limit-compare -DTEST -verify -x c++ %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra -Wno-sign-compare -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra -Wno-sign-compare -verify -x c++ %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wall -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wall -verify -x c++ %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify -x c++ %s
int value(void);
@@ -122,32 +128,6 @@ int main()
if (32767UL >= s)
return 0;
- if (s == 0UL)
- return 0;
- if (s != 0UL)
- return 0;
- if (s < 0UL) // expected-warning {{comparison of unsigned expression < 0 is always false}}
- return 0;
- if (s <= 0UL)
- return 0;
- if (s > 0UL)
- return 0;
- if (s >= 0UL) // expected-warning {{comparison of unsigned expression >= 0 is always true}}
- return 0;
-
- if (0UL == s)
- return 0;
- if (0UL != s)
- return 0;
- if (0UL < s)
- return 0;
- if (0UL <= s) // expected-warning {{comparison of 0 <= unsigned expression is always true}}
- return 0;
- if (0UL > s) // expected-warning {{comparison of 0 > unsigned expression is always false}}
- return 0;
- if (0UL >= s)
- return 0;
-
enum { ULONG_MAX = (2UL * (unsigned long)__LONG_MAX__ + 1UL) };
if (s == 2UL * (unsigned long)__LONG_MAX__ + 1UL)
return 0;
@@ -498,7 +478,7 @@ int main()
return 0;
#if __SIZEOF_INT128__
- __int128 i128;
+ __int128 i128 = value();
if (i128 == -1) // used to crash
return 0;
#endif
@@ -509,7 +489,7 @@ int main()
no,
maybe
};
- enum E e;
+ enum E e = (enum E)value();
if (e == yes)
return 0;
diff --git a/test/Sema/tautological-constant-enum-compare.c b/test/Sema/tautological-constant-enum-compare.c
index 539439b817dc5..99481c7adb33f 100644
--- a/test/Sema/tautological-constant-enum-compare.c
+++ b/test/Sema/tautological-constant-enum-compare.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -DUNSIGNED -verify %s
-// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -DSIGNED -verify %s
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -DUNSIGNED -Wtautological-constant-in-range-compare -verify %s
+// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -DSIGNED -Wtautological-constant-in-range-compare -verify %s
// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -DUNSIGNED -DSILENCE -Wno-tautological-constant-compare -verify %s
// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -DSIGNED -DSILENCE -Wno-tautological-constant-compare -verify %s
diff --git a/test/Sema/tautological-unsigned-enum-zero-compare.c b/test/Sema/tautological-unsigned-enum-zero-compare.c
index a32cfcd8329f2..87a56aa40bc33 100644
--- a/test/Sema/tautological-unsigned-enum-zero-compare.c
+++ b/test/Sema/tautological-unsigned-enum-zero-compare.c
@@ -1,9 +1,10 @@
// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only \
+// RUN: -Wtautological-unsigned-enum-zero-compare \
// RUN: -verify=unsigned,unsigned-signed %s
// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only \
+// RUN: -Wtautological-unsigned-enum-zero-compare \
// RUN: -verify=unsigned-signed %s
// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only \
-// RUN: -Wno-tautological-unsigned-enum-zero-compare \
// RUN: -verify=silence %s
// Okay, this is where it gets complicated.
diff --git a/test/Sema/tautological-unsigned-enum-zero-compare.cpp b/test/Sema/tautological-unsigned-enum-zero-compare.cpp
index a733b6edfc034..0b66c68197d9f 100644
--- a/test/Sema/tautological-unsigned-enum-zero-compare.cpp
+++ b/test/Sema/tautological-unsigned-enum-zero-compare.cpp
@@ -1,9 +1,10 @@
// RUN: %clang_cc1 -std=c++11 -triple=x86_64-pc-linux-gnu -fsyntax-only \
+// RUN: -Wtautological-unsigned-enum-zero-compare \
// RUN: -verify=unsigned,unsigned-signed %s
// RUN: %clang_cc1 -std=c++11 -triple=x86_64-pc-win32 -fsyntax-only \
+// RUN: -Wtautological-unsigned-enum-zero-compare \
// RUN: -verify=unsigned-signed %s
// RUN: %clang_cc1 -std=c++11 -triple=x86_64-pc-win32 -fsyntax-only \
-// RUN: -Wno-tautological-unsigned-enum-zero-compare \
// RUN: -verify=silence %s
// silence-no-diagnostics
diff --git a/test/Sema/tautological-unsigned-zero-compare.c b/test/Sema/tautological-unsigned-zero-compare.c
index b9ea02a731a3e..4c9394e213c4f 100644
--- a/test/Sema/tautological-unsigned-zero-compare.c
+++ b/test/Sema/tautological-unsigned-zero-compare.c
@@ -1,7 +1,13 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-zero-compare -verify=silence %s
-// RUN: %clang_cc1 -fsyntax-only -verify -x c++ %s
-// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-zero-compare -verify=silence -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only \
+// RUN: -Wtautological-unsigned-zero-compare \
+// RUN: -verify %s
+// RUN: %clang_cc1 -fsyntax-only \
+// RUN: -verify=silence %s
+// RUN: %clang_cc1 -fsyntax-only \
+// RUN: -Wtautological-unsigned-zero-compare \
+// RUN: -verify -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only \
+// RUN: -verify=silence -x c++ %s
unsigned uvalue(void);
signed int svalue(void);
@@ -32,10 +38,39 @@ int main()
TFunc<unsigned short>();
#endif
+ short s = svalue();
+
unsigned un = uvalue();
// silence-no-diagnostics
+ // Note: both sides are promoted to unsigned long prior to the comparison.
+ if (s == 0UL)
+ return 0;
+ if (s != 0UL)
+ return 0;
+ if (s < 0UL) // expected-warning {{comparison of unsigned expression < 0 is always false}}
+ return 0;
+ if (s <= 0UL)
+ return 0;
+ if (s > 0UL)
+ return 0;
+ if (s >= 0UL) // expected-warning {{comparison of unsigned expression >= 0 is always true}}
+ return 0;
+
+ if (0UL == s)
+ return 0;
+ if (0UL != s)
+ return 0;
+ if (0UL < s)
+ return 0;
+ if (0UL <= s) // expected-warning {{comparison of 0 <= unsigned expression is always true}}
+ return 0;
+ if (0UL > s) // expected-warning {{comparison of 0 > unsigned expression is always false}}
+ return 0;
+ if (0UL >= s)
+ return 0;
+
if (un == 0)
return 0;
if (un != 0)
diff --git a/test/Sema/tls.c b/test/Sema/tls.c
index 38bd3f2022461..e4d0656d1dd61 100644
--- a/test/Sema/tls.c
+++ b/test/Sema/tls.c
@@ -12,11 +12,11 @@
// RUN: %clang_cc1 -triple x86_64-pc-win32 -fsyntax-only %s
// RUN: %clang_cc1 -triple i386-pc-win32 -fsyntax-only %s
-// OpenBSD suppports TLS.
+// OpenBSD supports TLS.
// RUN: %clang_cc1 -triple x86_64-pc-openbsd -fsyntax-only %s
// RUN: %clang_cc1 -triple i386-pc-openbsd -fsyntax-only %s
-// Haiku does not suppport TLS.
+// Haiku does not support TLS.
// RUN: not %clang_cc1 -triple i586-pc-haiku -fsyntax-only %s
__thread int x;
diff --git a/test/Sema/transparent-union.c b/test/Sema/transparent-union.c
index 0481127674804..7967535db8c13 100644
--- a/test/Sema/transparent-union.c
+++ b/test/Sema/transparent-union.c
@@ -43,6 +43,35 @@ void fi(int i) {} // expected-error{{conflicting types}}
void fvpp(TU); // expected-note{{previous declaration is here}}
void fvpp(void **v) {} // expected-error{{conflicting types}}
+/* Test redeclaring a function taking a transparent_union arg more than twice.
+ Merging different declarations depends on their order, vary order too. */
+
+void f_triple0(TU tu) {}
+void f_triple0(int *); // expected-note{{previous declaration is here}}
+void f_triple0(float *f); // expected-error{{conflicting types}}
+
+void f_triple1(int *);
+void f_triple1(TU tu) {} // expected-note{{previous definition is here}}
+void f_triple1(float *f); // expected-error{{conflicting types}}
+
+void f_triple2(int *); // expected-note{{previous declaration is here}}
+void f_triple2(float *f); // expected-error{{conflicting types}}
+void f_triple2(TU tu) {}
+
+/* Test calling redeclared function taking a transparent_union arg. */
+
+void f_callee(TU);
+void f_callee(int *i) {} // expected-note{{passing argument to parameter 'i' here}}
+
+void caller(void) {
+ TU tu;
+ f_callee(tu); // expected-error{{passing 'TU' to parameter of incompatible type 'int *'}}
+
+ int *i;
+ f_callee(i);
+}
+
+
/* FIXME: we'd like to just use an "int" here and align it differently
from the normal "int", but if we do so we lose the alignment
information from the typedef within the compiler. */
diff --git a/test/Sema/transpose-memset.c b/test/Sema/transpose-memset.c
new file mode 100644
index 0000000000000..6112fde340662
--- /dev/null
+++ b/test/Sema/transpose-memset.c
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -Wmemset-transposed-args -verify %s
+// RUN: %clang_cc1 -xc++ -Wmemset-transposed-args -verify %s
+
+#define memset(...) __builtin_memset(__VA_ARGS__)
+#define bzero(x,y) __builtin_memset(x, 0, y)
+#define real_bzero(x,y) __builtin_bzero(x,y)
+
+int array[10];
+int *ptr;
+
+int main() {
+ memset(array, sizeof(array), 0); // expected-warning{{'size' argument to memset is '0'; did you mean to transpose the last two arguments?}} expected-note{{parenthesize the third argument to silence}}
+ memset(array, sizeof(array), 0xff); // expected-warning{{setting buffer to a 'sizeof' expression; did you mean to transpose the last two arguments?}} expected-note{{cast the second argument to 'int' to silence}}
+ memset(ptr, sizeof(ptr), 0); // expected-warning{{'size' argument to memset is '0'; did you mean to transpose the last two arguments?}} expected-note{{parenthesize the third argument to silence}}
+ memset(ptr, sizeof(*ptr) * 10, 1); // expected-warning{{setting buffer to a 'sizeof' expression; did you mean to transpose the last two arguments?}} expected-note{{cast the second argument to 'int' to silence}}
+ memset(ptr, 10 * sizeof(int *), 1); // expected-warning{{setting buffer to a 'sizeof' expression; did you mean to transpose the last two arguments?}} expected-note{{cast the second argument to 'int' to silence}}
+ memset(ptr, 10 * sizeof(int *) + 10, 0xff); // expected-warning{{setting buffer to a 'sizeof' expression; did you mean to transpose the last two arguments?}} expected-note{{cast the second argument to 'int' to silence}}
+ memset(ptr, sizeof(char) * sizeof(int *), 0xff); // expected-warning{{setting buffer to a 'sizeof' expression; did you mean to transpose the last two arguments?}} expected-note{{cast the second argument to 'int' to silence}}
+ memset(array, sizeof(array), sizeof(array)); // Uh... fine I guess.
+ memset(array, 0, sizeof(array));
+ memset(ptr, 0, sizeof(int *) * 10);
+ memset(array, (int)sizeof(array), (0)); // no warning
+ memset(array, (int)sizeof(array), 32); // no warning
+ memset(array, 32, (0)); // no warning
+ memset(array, 0, 0); // no warning
+
+ bzero(ptr, 0); // expected-warning{{'size' argument to bzero is '0'}} expected-note{{parenthesize the second argument to silence}}
+ real_bzero(ptr, 0); // expected-warning{{'size' argument to bzero is '0'}} expected-note{{parenthesize the second argument to silence}}
+}
+
+void macros() {
+#define ZERO 0
+ int array[10];
+ memset(array, 0xff, ZERO); // no warning
+ // Still emit a diagnostic for memsetting a sizeof expression:
+ memset(array, sizeof(array), ZERO); // expected-warning{{'sizeof'}} expected-note{{cast}}
+ bzero(array, ZERO); // no warning
+ real_bzero(array, ZERO); // no warning
+#define NESTED_DONT_DIAG \
+ memset(array, 0xff, ZERO); \
+ real_bzero(array, ZERO);
+
+ NESTED_DONT_DIAG;
+
+#define NESTED_DO_DIAG \
+ memset(array, 0xff, 0); \
+ real_bzero(array, 0)
+
+ NESTED_DO_DIAG; // expected-warning{{'size' argument to memset}} expected-warning{{'size' argument to bzero}} expected-note2{{parenthesize}}
+
+#define FN_MACRO(p) \
+ memset(array, 0xff, p)
+
+ FN_MACRO(ZERO);
+ FN_MACRO(0); // FIXME: should we diagnose this?
+
+ __builtin_memset(array, 0, ZERO); // no warning
+ __builtin_bzero(array, ZERO);
+ __builtin_memset(array, 1, 0); // expected-warning{{'size' argument to memset}} // expected-note{{parenthesize}}
+ __builtin_bzero(array, 0); // expected-warning{{'size' argument to bzero}} // expected-note{{parenthesize}}
+}
diff --git a/test/Sema/typedef-retain.c b/test/Sema/typedef-retain.c
index d216466360b7c..3d784ce60a75c 100644
--- a/test/Sema/typedef-retain.c
+++ b/test/Sema/typedef-retain.c
@@ -16,8 +16,8 @@ void test2(float4 a, int4p result, int i) {
typedef int a[5];
void test3() {
typedef const a b;
- b r;
- r[0]=10; // expected-error {{read-only variable is not assignable}}
+ b r; // expected-note {{variable 'r' declared const here}}
+ r[0] = 10; // expected-error {{cannot assign to variable 'r' with const-qualified type 'b' (aka 'int const[5]')}}
}
int test4(const a y) {
diff --git a/test/Sema/typo-correction.c b/test/Sema/typo-correction.c
index 78007015dcaed..e7992ac90bb3d 100644
--- a/test/Sema/typo-correction.c
+++ b/test/Sema/typo-correction.c
@@ -87,3 +87,16 @@ __attribute__((overloadable)) void func_overloadable(float);
void overloadable_callexpr(int arg) {
func_overloadable(ar); //expected-error{{use of undeclared identifier}}
}
+
+// rdar://problem/38642201
+struct rdar38642201 {
+ int fieldName;
+};
+
+void rdar38642201_callee(int x, int y);
+void rdar38642201_caller() {
+ struct rdar38642201 structVar;
+ rdar38642201_callee(
+ structVar1.fieldName1.member1, //expected-error{{use of undeclared identifier 'structVar1'}}
+ structVar2.fieldName2.member2); //expected-error{{use of undeclared identifier 'structVar2'}}
+}
diff --git a/test/Sema/uninit-variables.c b/test/Sema/uninit-variables.c
index 9e3dd9d2875be..89ea190cbc61c 100644
--- a/test/Sema/uninit-variables.c
+++ b/test/Sema/uninit-variables.c
@@ -111,7 +111,7 @@ void test15() {
int test15b() {
// Warn here with the self-init, since it does result in a use of
- // an unintialized variable and this is the root cause.
+ // an uninitialized variable and this is the root cause.
int x = x; // expected-warning {{variable 'x' is uninitialized when used within its own initialization}}
return x;
}
diff --git a/test/Sema/varargs.c b/test/Sema/varargs.c
index 0ade0cf0aaf9a..3fa429163ff5b 100644
--- a/test/Sema/varargs.c
+++ b/test/Sema/varargs.c
@@ -112,3 +112,12 @@ void f13(enum E1 e, ...) {
#endif
__builtin_va_end(va);
}
+
+void f14(int e, ...) {
+ // expected-warning@+3 {{implicitly declaring library function 'va_start'}}
+ // expected-note@+2 {{include the header <stdarg.h>}}
+ // expected-error@+1 {{too few arguments to function call}}
+ va_start();
+ __builtin_va_list va;
+ va_start(va, e);
+}
diff --git a/test/Sema/vector-gcc-compat.c b/test/Sema/vector-gcc-compat.c
index 9eb0569b25f01..73b56347f1b17 100644
--- a/test/Sema/vector-gcc-compat.c
+++ b/test/Sema/vector-gcc-compat.c
@@ -114,7 +114,7 @@ void logicTest(void) {
v2i64_a >>= 1;
}
-// For operations with floating point types, we check that interger constants
+// For operations with floating point types, we check that integer constants
// can be respresented, or failing that checking based on the integer types.
void floatTestConstant(void) {
// Test that constants added to floats must be expressible as floating point
diff --git a/test/Sema/vector-gcc-compat.cpp b/test/Sema/vector-gcc-compat.cpp
index 12da314c325ff..71497d95eb60a 100644
--- a/test/Sema/vector-gcc-compat.cpp
+++ b/test/Sema/vector-gcc-compat.cpp
@@ -112,7 +112,7 @@ void logicTest(void) {
v2i64_a >>= 1;
}
-// For operations with floating point types, we check that interger constants
+// For operations with floating point types, we check that integer constants
// can be respresented, or failing that checking based on the integer types.
void floatTestConstant(void) {
// Test that constants added to floats must be expressible as floating point
diff --git a/test/Sema/vla.c b/test/Sema/vla.c
index b9576bf8cfd61..8d83100b9d68e 100644
--- a/test/Sema/vla.c
+++ b/test/Sema/vla.c
@@ -68,3 +68,24 @@ void pr23151(int (*p1)[*]) // expected-error {{variable length array must be bou
int TransformBug(int a) {
return sizeof(*(int(*)[({ goto v; v: a;})]) 0); // expected-warning {{use of GNU statement expression extension}}
}
+
+// PR36157
+struct {
+ int a[ // expected-error {{variable length array in struct}}
+ implicitly_declared() // expected-warning {{implicit declaration}}
+ ];
+};
+int (*use_implicitly_declared)() = implicitly_declared; // ok, was implicitly declared at file scope
+
+void VLAPtrAssign(int size) {
+ int array[1][2][3][size][4][5];
+ // This is well formed
+ int (*p)[2][3][size][4][5] = array;
+ // Last array dimension too large
+ int (*p2)[2][3][size][4][6] = array; // expected-warning {{incompatible pointer types}}
+ // Second array dimension too large
+ int (*p3)[20][3][size][4][5] = array; // expected-warning {{incompatible pointer types}}
+
+ // Not illegal in C, program _might_ be well formed if size == 3.
+ int (*p4)[2][size][3][4][5] = array;
+}
diff --git a/test/Sema/warn-cast-qual.c b/test/Sema/warn-cast-qual.c
index a682cad75ed6a..789bde15b13c0 100644
--- a/test/Sema/warn-cast-qual.c
+++ b/test/Sema/warn-cast-qual.c
@@ -4,11 +4,15 @@
#include <stdint.h>
void foo() {
- const char * const ptr = 0;
- const char * const *ptrptr = 0;
+ const char *const ptr = 0;
+ const char *const *ptrptr = 0;
+ char *const *ptrcptr = 0;
+ char **ptrptr2 = 0;
char *y = (char *)ptr; // expected-warning {{cast from 'const char *' to 'char *' drops const qualifier}}
- char **y1 = (char **)ptrptr; // expected-warning {{cast from 'const char *const' to 'char *' drops const qualifier}}
+ char **y1 = (char **)ptrptr; // expected-warning {{cast from 'const char *const *' to 'char **' drops const qualifier}}
const char **y2 = (const char **)ptrptr; // expected-warning {{cast from 'const char *const *' to 'const char **' drops const qualifier}}
+ char *const *y3 = (char *const *)ptrptr; // expected-warning {{cast from 'const char *const' to 'char *const' drops const qualifier}}
+ const char **y4 = (const char **)ptrcptr; // expected-warning {{cast from 'char *const *' to 'const char **' drops const qualifier}}
char *z = (char *)(uintptr_t)(const void *)ptr; // no warning
char *z1 = (char *)(const void *)ptr; // expected-warning {{cast from 'const void *' to 'char *' drops const qualifier}}
diff --git a/test/Sema/warn-documentation.m b/test/Sema/warn-documentation.m
index 18ab5bd9e0968..0b75bcf80d5fe 100644
--- a/test/Sema/warn-documentation.m
+++ b/test/Sema/warn-documentation.m
@@ -218,13 +218,13 @@ int FooBar();
// rdar://14124644
@interface test_vararg1
-/// @param[in] arg somthing
+/// @param[in] arg something
/// @param[in] ... This is vararg
- (void) VarArgMeth : (id)arg, ...;
@end
@implementation test_vararg1
-/// @param[in] arg somthing
+/// @param[in] arg something
/// @param[in] ... This is vararg
- (void) VarArgMeth : (id)arg, ... {}
@end
diff --git a/test/Sema/warn-duplicate-enum.c b/test/Sema/warn-duplicate-enum.c
index f108b3aa6c328..84fdeb4f8fd4d 100644
--- a/test/Sema/warn-duplicate-enum.c
+++ b/test/Sema/warn-duplicate-enum.c
@@ -1,29 +1,29 @@
// RUN: %clang_cc1 %s -fsyntax-only -verify -Wduplicate-enum
// RUN: %clang_cc1 %s -x c++ -fsyntax-only -verify -Wduplicate-enum
enum A {
- A1 = 0, // expected-note {{element A1 also has value 0}}
+ A1 = 0, // expected-note {{element 'A1' also has value 0}}
A2 = -1,
- A3, // expected-warning {{element A3 has been implicitly assigned 0 which another element has been assigned}}
+ A3, // expected-warning {{element 'A3' has been implicitly assigned 0 which another element has been assigned}}
A4};
enum B {
- B1 = -1, // expected-note {{element B1 also has value -1}}
- B2, // expected-warning {{element B2 has been implicitly assigned 0 which another element has been assigned}}
+ B1 = -1, // expected-note {{element 'B1' also has value -1}}
+ B2, // expected-warning {{element 'B2' has been implicitly assigned 0 which another element has been assigned}}
B3,
B4 = -2,
- B5, // expected-warning {{element B5 has been implicitly assigned -1 which another element has been assigned}}
- B6 // expected-note {{element B6 also has value 0}}
+ B5, // expected-warning {{element 'B5' has been implicitly assigned -1 which another element has been assigned}}
+ B6 // expected-note {{element 'B6' also has value 0}}
};
-enum C { C1, C2 = -1, C3 }; // expected-warning{{element C1 has been implicitly assigned 0 which another element has been assigned}} \
- // expected-note {{element C3 also has value 0}}
+enum C { C1, C2 = -1, C3 }; // expected-warning{{element 'C1' has been implicitly assigned 0 which another element has been assigned}} \
+ // expected-note {{element 'C3' also has value 0}}
enum D {
D1,
D2,
- D3, // expected-warning{{element D3 has been implicitly assigned 2 which another element has been assigned}}
+ D3, // expected-warning{{element 'D3' has been implicitly assigned 2 which another element has been assigned}}
D4 = D2, // no warning
- D5 = 2 // expected-note {{element D5 also has value 2}}
+ D5 = 2 // expected-note {{element 'D5' also has value 2}}
};
enum E {
diff --git a/test/Sema/warn-strict-prototypes.c b/test/Sema/warn-strict-prototypes.c
index a28f57d48c84f..0c23b3b2c2453 100644
--- a/test/Sema/warn-strict-prototypes.c
+++ b/test/Sema/warn-strict-prototypes.c
@@ -65,3 +65,9 @@ void foo11(p, p2) int p; int p2; {}
void __attribute__((cdecl)) foo12(d) // expected-warning {{this old-style function definition is not preceded by a prototype}}
short d;
{}
+
+// No warnings for variadic functions. Overloadable attribute is required
+// to avoid err_ellipsis_first_param error.
+// rdar://problem/33251668
+void foo13(...) __attribute__((overloadable));
+void foo13(...) __attribute__((overloadable)) {}
diff --git a/test/Sema/warn-string-conversion.c b/test/Sema/warn-string-conversion.c
index 28dfc1b67dd5e..fbbc264f8f9ad 100644
--- a/test/Sema/warn-string-conversion.c
+++ b/test/Sema/warn-string-conversion.c
@@ -12,7 +12,7 @@ void assert_error();
#define assert2(expr) \
((expr) ? do_nothing() : assert_error())
-// Expection for common assert form.
+// Exception for common assert form.
void test1() {
assert1(0 && "foo");
assert1("foo" && 0);
diff --git a/test/Sema/warn-type-safety.c b/test/Sema/warn-type-safety.c
index 04313865a8b85..da914730d3aad 100644
--- a/test/Sema/warn-type-safety.c
+++ b/test/Sema/warn-type-safety.c
@@ -7,7 +7,7 @@ struct A {};
typedef struct A *MPI_Datatype;
int wrong1(void *buf, MPI_Datatype datatype)
- __attribute__(( pointer_with_type_tag )); // expected-error {{'pointer_with_type_tag' attribute requires parameter 1 to be an identifier}}
+ __attribute__(( pointer_with_type_tag )); // expected-error {{'pointer_with_type_tag' attribute requires exactly 3 arguments}}
int wrong2(void *buf, MPI_Datatype datatype)
__attribute__(( pointer_with_type_tag(mpi,0,7) )); // expected-error {{attribute parameter 2 is out of bounds}}
@@ -32,11 +32,15 @@ int wrong7(void *buf, MPI_Datatype datatype)
int wrong8(void *buf, MPI_Datatype datatype)
__attribute__(( pointer_with_type_tag(mpi,1,x) )); // expected-error {{attribute requires parameter 3 to be an integer constant}}
-int wrong9 __attribute__(( pointer_with_type_tag(mpi,1,2) )); // expected-error {{attribute only applies to functions and methods}}
+int wrong9 __attribute__(( pointer_with_type_tag(mpi,1,2) )); // expected-error {{'pointer_with_type_tag' attribute only applies to non-K&R-style functions}}
int wrong10(double buf, MPI_Datatype type)
__attribute__(( pointer_with_type_tag(mpi,1,2) )); // expected-error {{'pointer_with_type_tag' attribute only applies to pointer arguments}}
+int ok11(void *, ...)
+ __attribute__(( pointer_with_type_tag(mpi,1,2) ));
+int wrong11(void *, ...)
+ __attribute__(( pointer_with_type_tag(mpi,2,3) )); // expected-error {{'pointer_with_type_tag' attribute only applies to pointer arguments}}
extern struct A datatype_wrong1
__attribute__(( type_tag_for_datatype )); // expected-error {{'type_tag_for_datatype' attribute requires parameter 1 to be an identifier}}
diff --git a/test/Sema/warn-unreachable.c b/test/Sema/warn-unreachable.c
index 440aa0a5a174c..aec3b070213c7 100644
--- a/test/Sema/warn-unreachable.c
+++ b/test/Sema/warn-unreachable.c
@@ -468,6 +468,7 @@ int pr13910_foo(int x) {
else
return x;
__builtin_unreachable(); // expected no warning
+ __builtin_assume(0); // expected no warning
}
int pr13910_bar(int x) {
@@ -485,16 +486,19 @@ int pr13910_bar2(int x) {
return x;
pr13910_foo(x); // expected-warning {{code will never be executed}}
__builtin_unreachable(); // expected no warning
+ __builtin_assume(0); // expected no warning
pr13910_foo(x); // expected-warning {{code will never be executed}}
}
void pr13910_noreturn() {
raze();
__builtin_unreachable(); // expected no warning
+ __builtin_assume(0); // expected no warning
}
void pr13910_assert() {
myassert(0 && "unreachable");
return;
__builtin_unreachable(); // expected no warning
+ __builtin_assume(0); // expected no warning
}
diff --git a/test/Sema/x86-builtin-palignr.c b/test/Sema/x86-builtin-palignr.c
index f7e70b9c3c45b..e055cbb70e9e5 100644
--- a/test/Sema/x86-builtin-palignr.c
+++ b/test/Sema/x86-builtin-palignr.c
@@ -4,7 +4,5 @@
#include <tmmintrin.h>
__m64 test1(__m64 a, __m64 b, int c) {
- // FIXME: The "incompatible result type" error is due to pr10112 and should
- // be removed when that is fixed.
- return _mm_alignr_pi8(a, b, c); // expected-error {{argument to '__builtin_ia32_palignr' must be a constant integer}} expected-error {{incompatible result type}}
+ return _mm_alignr_pi8(a, b, c); // expected-error {{argument to '__builtin_ia32_palignr' must be a constant integer}}
}