Updated to Clang 3.5a.
Change-Id: I8127eb568f674c2e72635b639a3295381fe8af82
diff --git a/test/Sema/2007-10-01-BuildArrayRef.c b/test/Sema/2007-10-01-BuildArrayRef.c
index 4692731..2552934 100644
--- a/test/Sema/2007-10-01-BuildArrayRef.c
+++ b/test/Sema/2007-10-01-BuildArrayRef.c
@@ -1,9 +1,9 @@
-// RUN: not %clang_cc1_only -c %s -o - > /dev/null
+// RUN: %clang_cc1 -fsyntax-only -verify %s
// PR 1603
void func()
{
const int *arr;
- arr[0] = 1; // expected-error {{assignment of read-only location}}
+ arr[0] = 1; // expected-error {{read-only variable is not assignable}}
}
struct foo {
@@ -15,6 +15,6 @@
{
const struct foo *fp;
fp = &sfoo;
- fp[0].bar = 1; // expected-error {{ assignment of read-only member}}
+ fp[0].bar = 1; // expected-error {{read-only variable is not assignable}}
return sfoo.bar;
}
diff --git a/test/Sema/2009-03-09-WeakDeclarations-1.c b/test/Sema/2009-03-09-WeakDeclarations-1.c
index f219de6..c0035a4 100644
--- a/test/Sema/2009-03-09-WeakDeclarations-1.c
+++ b/test/Sema/2009-03-09-WeakDeclarations-1.c
@@ -1,12 +1,12 @@
-// RUN: %clang_cc1 %s -triple i686-apple-darwin
+// RUN: %clang_cc1 -verify %s -triple i686-apple-darwin
// Insist upon warnings for inappropriate weak attributes.
// O.K.
extern int ext_weak_import __attribute__ ((__weak_import__));
// These are inappropriate, and should generate warnings:
-int decl_weak_import __attribute__ ((__weak_import__)); // expected-warning {'weak_import' attribute cannot be specified on a definition}
-int decl_initialized_weak_import __attribute__ ((__weak_import__)) = 13; // expected-warning {'weak_import' attribute cannot be specified on a definition}
+int decl_weak_import __attribute__ ((__weak_import__)); // expected-warning {{'weak_import' attribute cannot be specified on a definition}}
+int decl_initialized_weak_import __attribute__ ((__weak_import__)) = 13; // expected-warning {{'weak_import' attribute cannot be specified on a definition}}
// O.K.
extern int ext_f(void) __attribute__ ((__weak_import__));
diff --git a/test/Sema/2009-04-22-UnknownSize.c b/test/Sema/2009-04-22-UnknownSize.c
index 9f71740..60bd8d2 100644
--- a/test/Sema/2009-04-22-UnknownSize.c
+++ b/test/Sema/2009-04-22-UnknownSize.c
@@ -1,4 +1,4 @@
-// RUN: not %clang_cc1 %s -emit-llvm -o -
+// RUN: not %clang_cc1 -fsyntax-only -verify %s
// PR2958
static struct foo s; // expected-error { tentative definition has type 'struct foo' that is never completed }
struct foo *p = &s;
diff --git a/test/Sema/2009-07-17-VoidParameter.c b/test/Sema/2009-07-17-VoidParameter.c
index 68d1b1e..b838b02 100644
--- a/test/Sema/2009-07-17-VoidParameter.c
+++ b/test/Sema/2009-07-17-VoidParameter.c
@@ -1,4 +1,4 @@
-// RUN: not %clang_cc1 -emit-llvm %s -o -
+// RUN: %clang_cc1 -verify -fsyntax-only %s
// PR4214
typedef void vt;
-void (*func_ptr)(vt my_vt); // expected-error {argument may not have 'void' type}
+void (*func_ptr)(vt my_vt); // expected-error {{argument may not have 'void' type}}
diff --git a/test/Sema/Inputs/ms-keyword-system-header.h b/test/Sema/Inputs/ms-keyword-system-header.h
index 43a3db7..dda4c2a 100644
--- a/test/Sema/Inputs/ms-keyword-system-header.h
+++ b/test/Sema/Inputs/ms-keyword-system-header.h
@@ -3,7 +3,7 @@
typedef union {
union w *__uptr;
#if defined(MS) && defined(NOT_SYSTEM)
- // expected-warning@-2 {{keyword '__uptr' will be treated as an identifier here}}
+ // expected-warning@-2 {{keyword '__uptr' will be made available as an identifier here}}
#endif
int *__iptr;
} WS __attribute__((__transparent_union__));
diff --git a/test/Sema/Inputs/warn-unreachable.h b/test/Sema/Inputs/warn-unreachable.h
new file mode 100644
index 0000000..394242f
--- /dev/null
+++ b/test/Sema/Inputs/warn-unreachable.h
@@ -0,0 +1,7 @@
+// Test that this unreachable code warning is
+// not reported because it is in a header.
+
+void foo_unreachable_header() {
+ return;
+ foo_unreachable_header(); // no-warning
+}
\ No newline at end of file
diff --git a/test/Sema/MicrosoftCompatibility.c b/test/Sema/MicrosoftCompatibility.c
index 6330c15..a193b26 100644
--- a/test/Sema/MicrosoftCompatibility.c
+++ b/test/Sema/MicrosoftCompatibility.c
@@ -16,6 +16,8 @@
}
__declspec(align(32768)) struct S1 { int a; } s; /* expected-error {{requested alignment must be 8192 bytes or smaller}} */
-struct __declspec(aligned) S2 {}; /* expected-warning {{unknown __declspec attribute 'aligned' ignored}} */
+struct __declspec(aligned) S2 {}; /* expected-warning {{__declspec attribute 'aligned' is not supported}} */
struct __declspec(appdomain) S3 {}; /* expected-warning {{__declspec attribute 'appdomain' is not supported}} */
+
+__declspec(__noreturn__) void f7(void); /* expected-warning {{__declspec attribute '__noreturn__' is not supported}} */
diff --git a/test/Sema/MicrosoftExtensions.c b/test/Sema/MicrosoftExtensions.c
index a6caf7a..b199644 100644
--- a/test/Sema/MicrosoftExtensions.c
+++ b/test/Sema/MicrosoftExtensions.c
@@ -20,10 +20,7 @@
int D[];
};
-
-
-
-
+struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) IUnknown {}; /* expected-error {{'uuid' attribute is not supported in C}} */
typedef struct notnested {
long bad1;
@@ -90,11 +87,11 @@
AA; // expected-warning {{anonymous structs are a Microsoft extension}}
} BB;
-__declspec(deprecated("This is deprecated")) enum DE1 { one, two } e1; // expected-note {{'e1' declared here}}
-struct __declspec(deprecated) DS1 { int i; float f; }; // expected-note {{declared here}}
+__declspec(deprecated("This is deprecated")) enum DE1 { one, two } e1; // expected-note {{'e1' has been explicitly marked deprecated here}}
+struct __declspec(deprecated) DS1 { int i; float f; }; // expected-note {{'DS1' has been explicitly marked deprecated here}}
#define MY_TEXT "This is also deprecated"
-__declspec(deprecated(MY_TEXT)) void Dfunc1( void ) {} // expected-note {{'Dfunc1' declared here}}
+__declspec(deprecated(MY_TEXT)) void Dfunc1( void ) {} // expected-note {{'Dfunc1' has been explicitly marked deprecated here}}
struct __declspec(deprecated(123)) DS2 {}; // expected-error {{'deprecated' attribute requires a string}}
@@ -134,3 +131,17 @@
typedef int *T;
T __ptr32 wrong10; // expected-error {{'__ptr32' attribute only applies to pointer arguments}}
+
+typedef char *my_va_list;
+void __va_start(my_va_list *ap, ...); // expected-note {{passing argument to parameter 'ap' here}}
+void vmyprintf(const char *f, my_va_list ap);
+void myprintf(const char *f, ...) {
+ my_va_list ap;
+ if (1) {
+ __va_start(&ap, f);
+ vmyprintf(f, ap);
+ ap = 0;
+ } else {
+ __va_start(ap, f); // expected-warning {{incompatible pointer types passing 'my_va_list'}}
+ }
+}
diff --git a/test/Sema/aarch64-neon-ranges.c b/test/Sema/aarch64-neon-ranges.c
new file mode 100644
index 0000000..bcc9c50
--- /dev/null
+++ b/test/Sema/aarch64-neon-ranges.c
@@ -0,0 +1,217 @@
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +neon -ffreestanding -fsyntax-only -verify %s
+
+#include <arm_neon.h>
+
+void test_vext_8bit(int8x8_t small, int8x16_t big) {
+ vext_s8(small, small, 7);
+ vext_u8(small, small, 7);
+ vext_p8(small, small, 7);
+ vextq_s8(big, big, 15);
+ 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}}
+}
+
+void test_mul_lane_f64(float64x1_t small, float64x2_t big, float64x2_t rhs) {
+ vmul_lane_f64(small, small, 0);
+ vmul_laneq_f64(small, big, 1);
+ vmulq_lane_f64(big, small, 0);
+ vmulq_laneq_f64(big, big, 1);
+ vfma_lane_f64(small, small, small, 0);
+ vfma_laneq_f64(small, small, big, 1);
+ 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}}
+}
+
+void test_ld1st1(int8x8_t small, int8x16_t big, void *addr) {
+ vld1_lane_s8(addr, small, 7);
+ vld1_lane_s16(addr, small, 3);
+ vld1_lane_s32(addr, small, 1);
+ vld1_lane_s64(addr, small, 0);
+
+ vld1q_lane_s8(addr, big, 15);
+ vld1q_lane_s16(addr, big, 7);
+ 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}}
+
+ 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}}
+
+ vst1_lane_s8(addr, small, 7);
+ vst1_lane_s16(addr, small, 3);
+ vst1_lane_s32(addr, small, 1);
+ vst1_lane_s64(addr, small, 0);
+
+ vst1q_lane_s8(addr, big, 15);
+ vst1q_lane_s16(addr, big, 7);
+ 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}}
+
+ 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}}
+}
+
+void test_ld2st2(int8x8x2_t small8, int8x16x2_t big8,
+ int16x4x2_t small16, int16x8x2_t big16,
+ int32x2x2_t small32, int32x4x2_t big32,
+ int64x1x2_t small64, int64x2x2_t big64,
+ void *addr) {
+ vld2_lane_s8(addr, small8, 7);
+ vld2_lane_s16(addr, small16, 3);
+ vld2_lane_s32(addr, small32, 1);
+ vld2_lane_s64(addr, small64, 0);
+
+ vld2q_lane_s8(addr, big8, 15);
+ vld2q_lane_s16(addr, big16, 7);
+ 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}}
+
+ 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}}
+
+ vst2_lane_s8(addr, small8, 7);
+ vst2_lane_s16(addr, small16, 3);
+ vst2_lane_s32(addr, small32, 1);
+ vst2_lane_s64(addr, small64, 0);
+
+ vst2q_lane_s8(addr, big8, 15);
+ vst2q_lane_s16(addr, big16, 7);
+ 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}}
+
+ 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}}
+}
+
+void test_ld3st3(int8x8x3_t small8, int8x16x3_t big8,
+ int16x4x3_t small16, int16x8x3_t big16,
+ int32x2x3_t small32, int32x4x3_t big32,
+ int64x1x3_t small64, int64x2x3_t big64,
+ void *addr) {
+ vld3_lane_s8(addr, small8, 7);
+ vld3_lane_s16(addr, small16, 3);
+ vld3_lane_s32(addr, small32, 1);
+ vld3_lane_s64(addr, small64, 0);
+
+ vld3q_lane_s8(addr, big8, 15);
+ vld3q_lane_s16(addr, big16, 7);
+ 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}}
+
+ 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}}
+
+ vst3_lane_s8(addr, small8, 7);
+ vst3_lane_s16(addr, small16, 3);
+ vst3_lane_s32(addr, small32, 1);
+ vst3_lane_s64(addr, small64, 0);
+
+ vst3q_lane_s8(addr, big8, 15);
+ vst3q_lane_s16(addr, big16, 7);
+ 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}}
+
+ 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}}
+}
+
+void test_ld4st4(int8x8x4_t small8, int8x16x4_t big8,
+ int16x4x4_t small16, int16x8x4_t big16,
+ int32x2x4_t small32, int32x4x4_t big32,
+ int64x1x4_t small64, int64x2x4_t big64,
+ void *addr) {
+ vld4_lane_s8(addr, small8, 7);
+ vld4_lane_s16(addr, small16, 3);
+ vld4_lane_s32(addr, small32, 1);
+ vld4_lane_s64(addr, small64, 0);
+
+ vld4q_lane_s8(addr, big8, 15);
+ vld4q_lane_s16(addr, big16, 7);
+ 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}}
+
+ 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}}
+
+ vst4_lane_s8(addr, small8, 7);
+ vst4_lane_s16(addr, small16, 3);
+ vst4_lane_s32(addr, small32, 1);
+ vst4_lane_s64(addr, small64, 0);
+
+ vst4q_lane_s8(addr, big8, 15);
+ vst4q_lane_s16(addr, big16, 7);
+ 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}}
+
+ 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}}
+}
+
diff --git a/test/Sema/aarch64-neon-vector-types.c b/test/Sema/aarch64-neon-vector-types.c
index 894cf6d..b733e3c 100644
--- a/test/Sema/aarch64-neon-vector-types.c
+++ b/test/Sema/aarch64-neon-vector-types.c
@@ -1,19 +1,34 @@
// RUN: %clang_cc1 %s -triple aarch64-none-linux-gnu -target-feature +neon -fsyntax-only -verify
+// RUN: %clang_cc1 %s -triple aarch64-none-linux-gnu -target-feature +neon -DUSE_LONG -fsyntax-only -verify
typedef float float32_t;
typedef unsigned char poly8_t;
typedef unsigned short poly16_t;
+
+// Both "long" and "long long" should work for 64-bit arch like aarch64.
+// stdint.h in gnu libc is using "long" for 64-bit arch.
+#if USE_LONG
+typedef long int64_t;
+typedef unsigned long uint64_t;
+#else
+typedef long long int64_t;
typedef unsigned long long uint64_t;
+#endif
+typedef uint64_t poly64_t;
// Define some valid Neon types.
typedef __attribute__((neon_vector_type(2))) int int32x2_t;
typedef __attribute__((neon_vector_type(4))) int int32x4_t;
+typedef __attribute__((neon_vector_type(1))) int64_t int64x1_t;
+typedef __attribute__((neon_vector_type(2))) int64_t int64x2_t;
typedef __attribute__((neon_vector_type(1))) uint64_t uint64x1_t;
typedef __attribute__((neon_vector_type(2))) uint64_t uint64x2_t;
typedef __attribute__((neon_vector_type(2))) float32_t float32x2_t;
typedef __attribute__((neon_vector_type(4))) float32_t float32x4_t;
typedef __attribute__((neon_polyvector_type(16))) poly8_t poly8x16_t;
typedef __attribute__((neon_polyvector_type(8))) poly16_t poly16x8_t;
+typedef __attribute__((neon_polyvector_type(1))) poly64_t poly64x1_t;
+typedef __attribute__((neon_polyvector_type(2))) poly64_t poly64x2_t;
// The attributes must have a single argument.
typedef __attribute__((neon_vector_type(2, 4))) int only_one_arg; // expected-error{{attribute takes one argument}}
diff --git a/test/Sema/alloc_size.c b/test/Sema/alloc_size.c
deleted file mode 100644
index 053323a..0000000
--- a/test/Sema/alloc_size.c
+++ /dev/null
@@ -1,27 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-
-void* my_malloc(unsigned char) __attribute__((alloc_size(1)));
-void* my_calloc(unsigned char, short) __attribute__((alloc_size(1,2)));
-void* my_realloc(void*, unsigned) __attribute__((alloc_size(2)));
-
-
-void* fn1(int) __attribute__((alloc_size("xpto"))); // expected-error{{'alloc_size' attribute requires parameter 1 to be an integer constant}}
-
-void* fn2(void*) __attribute__((alloc_size(1))); // expected-error{{'alloc_size' attribute requires an integer constant}}
-
-void* fn3(unsigned) __attribute__((alloc_size(0))); // expected-error{{attribute parameter 1 is out of bounds}}
-void* fn4(unsigned) __attribute__((alloc_size(2))); // expected-error{{attribute parameter 1 is out of bounds}}
-
-void fn5(unsigned) __attribute__((alloc_size(1))); // expected-warning{{only applies to functions that return a pointer}}
-char fn6(unsigned) __attribute__((alloc_size(1))); // expected-warning{{only applies to functions that return a pointer}}
-
-void* fn7(unsigned) __attribute__((alloc_size)); // expected-error {{attribute takes at least 1 argument}}
-
-void *fn8(int, int) __attribute__((alloc_size(1, 1))); // OK
-
-void* fn9(unsigned) __attribute__((alloc_size(12345678901234567890123))); // expected-error {{integer constant is larger than the largest unsigned integer type}} // expected-error {{attribute parameter 1 is out of bounds}}
-
-void* fn10(size_t, size_t) __attribute__((alloc_size(1,2))); // expected-error{{redefinition of parameter}} \
- // expected-error{{a parameter list without types is only allowed in a function definition}} \
- // expected-error{{attribute parameter 1 is out of bounds}}
-void* fn11() __attribute__((alloc_size(1))); // expected-error{{attribute parameter 1 is out of bounds}}
diff --git a/test/Sema/arm-interrupt-attr.c b/test/Sema/arm-interrupt-attr.c
index b2cedc2..e8f21ad 100644
--- a/test/Sema/arm-interrupt-attr.c
+++ b/test/Sema/arm-interrupt-attr.c
@@ -1,9 +1,9 @@
// RUN: %clang_cc1 %s -triple arm-apple-darwin -verify -fsyntax-only
-__attribute__((interrupt(IRQ))) void foo() {} // expected-error {{'interrupt' attribute requires a string}}
+__attribute__((interrupt(IRQ))) void foo() {} // expected-error {{'interrupt' attribute requires a string}}
__attribute__((interrupt("irq"))) void foo1() {} // expected-warning {{'interrupt' attribute argument not supported: irq}}
-__attribute__((interrupt("IRQ", 1))) void foo2() {} // expected-error {{attribute takes no more than 1 argument}}
+__attribute__((interrupt("IRQ", 1))) void foo2() {} // expected-error {{'interrupt' attribute takes no more than 1 argument}}
__attribute__((interrupt("IRQ"))) void foo3() {}
__attribute__((interrupt("FIQ"))) void foo4() {}
diff --git a/test/Sema/arm64-inline-asm.c b/test/Sema/arm64-inline-asm.c
new file mode 100644
index 0000000..2d93621
--- /dev/null
+++ b/test/Sema/arm64-inline-asm.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios7.1 -fsyntax-only -verify %s
+void foo() {
+ asm volatile("USE(%0)" :: "z"(0LL));
+ asm volatile("USE(%x0)" :: "z"(0LL));
+ asm volatile("USE(%w0)" :: "z"(0));
+
+ asm volatile("USE(%0)" :: "z"(0)); // expected-warning {{value size does not match register size specified by the constraint and modifier}}
+}
diff --git a/test/Sema/arm64-neon-args.c b/test/Sema/arm64-neon-args.c
new file mode 100644
index 0000000..5ee653d
--- /dev/null
+++ b/test/Sema/arm64-neon-args.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple arm64-apple-darwin -fsyntax-only -ffreestanding -verify %s
+
+#include <arm_neon.h>
+
+// rdar://13527900
+void vcopy_reject(float32x4_t vOut0, float32x4_t vAlpha, int t) {
+ vcopyq_laneq_f32(vOut0, 1, vAlpha, t); // expected-error {{argument to '__builtin_neon_vgetq_lane_f32' must be a constant integer}} expected-error {{initializing 'float32_t' (aka 'float') with an expression of incompatible type 'void'}}
+}
+
+// rdar://problem/15256199
+float32x4_t test_vmlsq_lane(float32x4_t accum, float32x4_t lhs, float32x2_t rhs) {
+ return vmlsq_lane_f32(accum, lhs, rhs, 1);
+}
diff --git a/test/Sema/asm.c b/test/Sema/asm.c
index c81f16a..1559b22 100644
--- a/test/Sema/asm.c
+++ b/test/Sema/asm.c
@@ -13,6 +13,9 @@
asm ("foo\n" : "=a" (i) : "[" (i)); // expected-error {{invalid input constraint '[' in asm}}
asm ("foo\n" : "=a" (i) : "[foo" (i)); // expected-error {{invalid input constraint '[foo' in asm}}
asm ("foo\n" : "=a" (i) : "[symbolic_name]" (i)); // expected-error {{invalid input constraint '[symbolic_name]' in asm}}
+
+ asm ("foo\n" : : "" (i)); // expected-error {{invalid input constraint '' in asm}}
+ asm ("foo\n" : "=a" (i) : "" (i)); // expected-error {{invalid input constraint '' in asm}}
}
void clobbers() {
diff --git a/test/Sema/atomic-ops.c b/test/Sema/atomic-ops.c
index c2d38e7..6f9f568 100644
--- a/test/Sema/atomic-ops.c
+++ b/test/Sema/atomic-ops.c
@@ -182,3 +182,225 @@
flag flagvar = { 0 };
PR16931(&flagvar); // expected-warning {{incompatible pointer types}}
}
+
+void memory_checks(_Atomic(int) *Ap, int *p, int val) {
+ (void)__c11_atomic_load(Ap, memory_order_relaxed);
+ (void)__c11_atomic_load(Ap, memory_order_acquire);
+ (void)__c11_atomic_load(Ap, memory_order_consume);
+ (void)__c11_atomic_load(Ap, memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
+ (void)__c11_atomic_load(Ap, memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
+ (void)__c11_atomic_load(Ap, memory_order_seq_cst);
+ (void)__c11_atomic_load(Ap, val);
+ (void)__c11_atomic_load(Ap, -1); // expected-warning {{memory order argument to atomic operation is invalid}}
+ (void)__c11_atomic_load(Ap, 42); // expected-warning {{memory order argument to atomic operation is invalid}}
+
+ (void)__c11_atomic_store(Ap, val, memory_order_relaxed);
+ (void)__c11_atomic_store(Ap, val, memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}}
+ (void)__c11_atomic_store(Ap, val, memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}}
+ (void)__c11_atomic_store(Ap, val, memory_order_release);
+ (void)__c11_atomic_store(Ap, val, memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
+ (void)__c11_atomic_store(Ap, val, memory_order_seq_cst);
+
+ (void)__c11_atomic_fetch_add(Ap, 1, memory_order_relaxed);
+ (void)__c11_atomic_fetch_add(Ap, 1, memory_order_acquire);
+ (void)__c11_atomic_fetch_add(Ap, 1, memory_order_consume);
+ (void)__c11_atomic_fetch_add(Ap, 1, memory_order_release);
+ (void)__c11_atomic_fetch_add(Ap, 1, memory_order_acq_rel);
+ (void)__c11_atomic_fetch_add(Ap, 1, memory_order_seq_cst);
+
+ (void)__c11_atomic_init(Ap, val);
+ (void)__c11_atomic_init(Ap, val);
+ (void)__c11_atomic_init(Ap, val);
+ (void)__c11_atomic_init(Ap, val);
+ (void)__c11_atomic_init(Ap, val);
+ (void)__c11_atomic_init(Ap, val);
+
+ (void)__c11_atomic_fetch_sub(Ap, val, memory_order_relaxed);
+ (void)__c11_atomic_fetch_sub(Ap, val, memory_order_acquire);
+ (void)__c11_atomic_fetch_sub(Ap, val, memory_order_consume);
+ (void)__c11_atomic_fetch_sub(Ap, val, memory_order_release);
+ (void)__c11_atomic_fetch_sub(Ap, val, memory_order_acq_rel);
+ (void)__c11_atomic_fetch_sub(Ap, val, memory_order_seq_cst);
+
+ (void)__c11_atomic_fetch_and(Ap, val, memory_order_relaxed);
+ (void)__c11_atomic_fetch_and(Ap, val, memory_order_acquire);
+ (void)__c11_atomic_fetch_and(Ap, val, memory_order_consume);
+ (void)__c11_atomic_fetch_and(Ap, val, memory_order_release);
+ (void)__c11_atomic_fetch_and(Ap, val, memory_order_acq_rel);
+ (void)__c11_atomic_fetch_and(Ap, val, memory_order_seq_cst);
+
+ (void)__c11_atomic_fetch_or(Ap, val, memory_order_relaxed);
+ (void)__c11_atomic_fetch_or(Ap, val, memory_order_acquire);
+ (void)__c11_atomic_fetch_or(Ap, val, memory_order_consume);
+ (void)__c11_atomic_fetch_or(Ap, val, memory_order_release);
+ (void)__c11_atomic_fetch_or(Ap, val, memory_order_acq_rel);
+ (void)__c11_atomic_fetch_or(Ap, val, memory_order_seq_cst);
+
+ (void)__c11_atomic_fetch_xor(Ap, val, memory_order_relaxed);
+ (void)__c11_atomic_fetch_xor(Ap, val, memory_order_acquire);
+ (void)__c11_atomic_fetch_xor(Ap, val, memory_order_consume);
+ (void)__c11_atomic_fetch_xor(Ap, val, memory_order_release);
+ (void)__c11_atomic_fetch_xor(Ap, val, memory_order_acq_rel);
+ (void)__c11_atomic_fetch_xor(Ap, val, memory_order_seq_cst);
+
+ (void)__c11_atomic_exchange(Ap, val, memory_order_relaxed);
+ (void)__c11_atomic_exchange(Ap, val, memory_order_acquire);
+ (void)__c11_atomic_exchange(Ap, val, memory_order_consume);
+ (void)__c11_atomic_exchange(Ap, val, memory_order_release);
+ (void)__c11_atomic_exchange(Ap, val, memory_order_acq_rel);
+ (void)__c11_atomic_exchange(Ap, val, memory_order_seq_cst);
+
+ (void)__c11_atomic_compare_exchange_strong(Ap, p, val, memory_order_relaxed, memory_order_relaxed);
+ (void)__c11_atomic_compare_exchange_strong(Ap, p, val, memory_order_acquire, memory_order_relaxed);
+ (void)__c11_atomic_compare_exchange_strong(Ap, p, val, memory_order_consume, memory_order_relaxed);
+ (void)__c11_atomic_compare_exchange_strong(Ap, p, val, memory_order_release, memory_order_relaxed);
+ (void)__c11_atomic_compare_exchange_strong(Ap, p, val, memory_order_acq_rel, memory_order_relaxed);
+ (void)__c11_atomic_compare_exchange_strong(Ap, p, val, memory_order_seq_cst, memory_order_relaxed);
+
+ (void)__c11_atomic_compare_exchange_weak(Ap, p, val, memory_order_relaxed, memory_order_relaxed);
+ (void)__c11_atomic_compare_exchange_weak(Ap, p, val, memory_order_acquire, memory_order_relaxed);
+ (void)__c11_atomic_compare_exchange_weak(Ap, p, val, memory_order_consume, memory_order_relaxed);
+ (void)__c11_atomic_compare_exchange_weak(Ap, p, val, memory_order_release, memory_order_relaxed);
+ (void)__c11_atomic_compare_exchange_weak(Ap, p, val, memory_order_acq_rel, memory_order_relaxed);
+ (void)__c11_atomic_compare_exchange_weak(Ap, p, val, memory_order_seq_cst, memory_order_relaxed);
+
+ (void)__atomic_load_n(p, memory_order_relaxed);
+ (void)__atomic_load_n(p, memory_order_acquire);
+ (void)__atomic_load_n(p, memory_order_consume);
+ (void)__atomic_load_n(p, memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
+ (void)__atomic_load_n(p, memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
+ (void)__atomic_load_n(p, memory_order_seq_cst);
+
+ (void)__atomic_load(p, p, memory_order_relaxed);
+ (void)__atomic_load(p, p, memory_order_acquire);
+ (void)__atomic_load(p, p, memory_order_consume);
+ (void)__atomic_load(p, p, memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
+ (void)__atomic_load(p, p, memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
+ (void)__atomic_load(p, p, memory_order_seq_cst);
+
+ (void)__atomic_store(p, p, memory_order_relaxed);
+ (void)__atomic_store(p, p, memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}}
+ (void)__atomic_store(p, p, memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}}
+ (void)__atomic_store(p, p, memory_order_release);
+ (void)__atomic_store(p, p, memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
+ (void)__atomic_store(p, p, memory_order_seq_cst);
+
+ (void)__atomic_store_n(p, val, memory_order_relaxed);
+ (void)__atomic_store_n(p, val, memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}}
+ (void)__atomic_store_n(p, val, memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}}
+ (void)__atomic_store_n(p, val, memory_order_release);
+ (void)__atomic_store_n(p, val, memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
+ (void)__atomic_store_n(p, val, memory_order_seq_cst);
+
+ (void)__atomic_fetch_add(p, val, memory_order_relaxed);
+ (void)__atomic_fetch_add(p, val, memory_order_acquire);
+ (void)__atomic_fetch_add(p, val, memory_order_consume);
+ (void)__atomic_fetch_add(p, val, memory_order_release);
+ (void)__atomic_fetch_add(p, val, memory_order_acq_rel);
+ (void)__atomic_fetch_add(p, val, memory_order_seq_cst);
+
+ (void)__atomic_fetch_sub(p, val, memory_order_relaxed);
+ (void)__atomic_fetch_sub(p, val, memory_order_acquire);
+ (void)__atomic_fetch_sub(p, val, memory_order_consume);
+ (void)__atomic_fetch_sub(p, val, memory_order_release);
+ (void)__atomic_fetch_sub(p, val, memory_order_acq_rel);
+ (void)__atomic_fetch_sub(p, val, memory_order_seq_cst);
+
+ (void)__atomic_add_fetch(p, val, memory_order_relaxed);
+ (void)__atomic_add_fetch(p, val, memory_order_acquire);
+ (void)__atomic_add_fetch(p, val, memory_order_consume);
+ (void)__atomic_add_fetch(p, val, memory_order_release);
+ (void)__atomic_add_fetch(p, val, memory_order_acq_rel);
+ (void)__atomic_add_fetch(p, val, memory_order_seq_cst);
+
+ (void)__atomic_sub_fetch(p, val, memory_order_relaxed);
+ (void)__atomic_sub_fetch(p, val, memory_order_acquire);
+ (void)__atomic_sub_fetch(p, val, memory_order_consume);
+ (void)__atomic_sub_fetch(p, val, memory_order_release);
+ (void)__atomic_sub_fetch(p, val, memory_order_acq_rel);
+ (void)__atomic_sub_fetch(p, val, memory_order_seq_cst);
+
+ (void)__atomic_fetch_and(p, val, memory_order_relaxed);
+ (void)__atomic_fetch_and(p, val, memory_order_acquire);
+ (void)__atomic_fetch_and(p, val, memory_order_consume);
+ (void)__atomic_fetch_and(p, val, memory_order_release);
+ (void)__atomic_fetch_and(p, val, memory_order_acq_rel);
+ (void)__atomic_fetch_and(p, val, memory_order_seq_cst);
+
+ (void)__atomic_fetch_or(p, val, memory_order_relaxed);
+ (void)__atomic_fetch_or(p, val, memory_order_acquire);
+ (void)__atomic_fetch_or(p, val, memory_order_consume);
+ (void)__atomic_fetch_or(p, val, memory_order_release);
+ (void)__atomic_fetch_or(p, val, memory_order_acq_rel);
+ (void)__atomic_fetch_or(p, val, memory_order_seq_cst);
+
+ (void)__atomic_fetch_xor(p, val, memory_order_relaxed);
+ (void)__atomic_fetch_xor(p, val, memory_order_acquire);
+ (void)__atomic_fetch_xor(p, val, memory_order_consume);
+ (void)__atomic_fetch_xor(p, val, memory_order_release);
+ (void)__atomic_fetch_xor(p, val, memory_order_acq_rel);
+ (void)__atomic_fetch_xor(p, val, memory_order_seq_cst);
+
+ (void)__atomic_fetch_nand(p, val, memory_order_relaxed);
+ (void)__atomic_fetch_nand(p, val, memory_order_acquire);
+ (void)__atomic_fetch_nand(p, val, memory_order_consume);
+ (void)__atomic_fetch_nand(p, val, memory_order_release);
+ (void)__atomic_fetch_nand(p, val, memory_order_acq_rel);
+ (void)__atomic_fetch_nand(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);
+ (void)__atomic_and_fetch(p, val, memory_order_release);
+ (void)__atomic_and_fetch(p, val, memory_order_acq_rel);
+ (void)__atomic_and_fetch(p, val, memory_order_seq_cst);
+
+ (void)__atomic_or_fetch(p, val, memory_order_relaxed);
+ (void)__atomic_or_fetch(p, val, memory_order_acquire);
+ (void)__atomic_or_fetch(p, val, memory_order_consume);
+ (void)__atomic_or_fetch(p, val, memory_order_release);
+ (void)__atomic_or_fetch(p, val, memory_order_acq_rel);
+ (void)__atomic_or_fetch(p, val, memory_order_seq_cst);
+
+ (void)__atomic_xor_fetch(p, val, memory_order_relaxed);
+ (void)__atomic_xor_fetch(p, val, memory_order_acquire);
+ (void)__atomic_xor_fetch(p, val, memory_order_consume);
+ (void)__atomic_xor_fetch(p, val, memory_order_release);
+ (void)__atomic_xor_fetch(p, val, memory_order_acq_rel);
+ (void)__atomic_xor_fetch(p, val, memory_order_seq_cst);
+
+ (void)__atomic_nand_fetch(p, val, memory_order_relaxed);
+ (void)__atomic_nand_fetch(p, val, memory_order_acquire);
+ (void)__atomic_nand_fetch(p, val, memory_order_consume);
+ (void)__atomic_nand_fetch(p, val, memory_order_release);
+ (void)__atomic_nand_fetch(p, val, memory_order_acq_rel);
+ (void)__atomic_nand_fetch(p, val, memory_order_seq_cst);
+
+ (void)__atomic_exchange_n(p, val, memory_order_relaxed);
+ (void)__atomic_exchange_n(p, val, memory_order_acquire);
+ (void)__atomic_exchange_n(p, val, memory_order_consume);
+ (void)__atomic_exchange_n(p, val, memory_order_release);
+ (void)__atomic_exchange_n(p, val, memory_order_acq_rel);
+ (void)__atomic_exchange_n(p, val, memory_order_seq_cst);
+
+ (void)__atomic_exchange(p, p, p, memory_order_relaxed);
+ (void)__atomic_exchange(p, p, p, memory_order_acquire);
+ (void)__atomic_exchange(p, p, p, memory_order_consume);
+ (void)__atomic_exchange(p, p, p, memory_order_release);
+ (void)__atomic_exchange(p, p, p, memory_order_acq_rel);
+ (void)__atomic_exchange(p, p, p, memory_order_seq_cst);
+
+ (void)__atomic_compare_exchange(p, p, p, 0, memory_order_relaxed, memory_order_relaxed);
+ (void)__atomic_compare_exchange(p, p, p, 0, memory_order_acquire, memory_order_relaxed);
+ (void)__atomic_compare_exchange(p, p, p, 0, memory_order_consume, memory_order_relaxed);
+ (void)__atomic_compare_exchange(p, p, p, 0, memory_order_release, memory_order_relaxed);
+ (void)__atomic_compare_exchange(p, p, p, 0, memory_order_acq_rel, memory_order_relaxed);
+ (void)__atomic_compare_exchange(p, p, p, 0, memory_order_seq_cst, memory_order_relaxed);
+
+ (void)__atomic_compare_exchange_n(p, p, val, 0, memory_order_relaxed, memory_order_relaxed);
+ (void)__atomic_compare_exchange_n(p, p, val, 0, memory_order_acquire, memory_order_relaxed);
+ (void)__atomic_compare_exchange_n(p, p, val, 0, memory_order_consume, memory_order_relaxed);
+ (void)__atomic_compare_exchange_n(p, p, val, 0, memory_order_release, memory_order_relaxed);
+ (void)__atomic_compare_exchange_n(p, p, val, 0, memory_order_acq_rel, memory_order_relaxed);
+ (void)__atomic_compare_exchange_n(p, p, val, 0, memory_order_seq_cst, memory_order_relaxed);
+}
diff --git a/test/Sema/attr-alias-elf.c b/test/Sema/attr-alias-elf.c
index 88bd7b7..01bc187 100644
--- a/test/Sema/attr-alias-elf.c
+++ b/test/Sema/attr-alias-elf.c
@@ -52,3 +52,7 @@
extern int a4 __attribute__((alias("b4"))); // expected-error {{alias must point to a defined variable or function}}
typedef int b4;
+
+void test2_bar() {}
+void test2_foo() __attribute__((weak, alias("test2_bar")));
+void test2_zed() __attribute__((alias("test2_foo"))); // expected-warning {{alias will always resolve to test2_bar even if weak definition of alias test2_foo is overridden}}
diff --git a/test/Sema/attr-aligned.c b/test/Sema/attr-aligned.c
index 92f2742..ad59357 100644
--- a/test/Sema/attr-aligned.c
+++ b/test/Sema/attr-aligned.c
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
int x __attribute__((aligned(3))); // expected-error {{requested alignment is not a power of 2}}
+int y __attribute__((aligned(1 << 29))); // expected-error {{requested alignment must be 268435456 bytes or smaller}}
// PR3254
short g0[3] __attribute__((aligned));
@@ -20,6 +21,12 @@
char a2[__alignof__(a) == 1? : -1] = { 0 };
char a3[sizeof(a) == 1? : -1] = { 0 };
+typedef long long __attribute__((aligned(1))) underaligned_longlong;
+char a4[__alignof__(underaligned_longlong) == 1 ?: -1] = {0};
+
+typedef long long __attribute__((aligned(1))) underaligned_complex_longlong;
+char a5[__alignof__(underaligned_complex_longlong) == 1 ?: -1] = {0};
+
// rdar://problem/8335865
int b __attribute__((aligned(2)));
char b1[__alignof__(b) == 2 ?: -1] = {0};
@@ -32,7 +39,7 @@
char d1[__alignof__(d) == 2 ?: -1] = {0};
char d2[__alignof__(d.member) == 2 ?: -1] = {0};
-struct E { int member __attribute__((align(2))); } __attribute__((packed));
+struct E { int member __attribute__((aligned(2))); } __attribute__((packed));
struct E e;
char e1[__alignof__(e) == 2 ?: -1] = {0};
char e2[__alignof__(e.member) == 2 ?: -1] = {0};
diff --git a/test/Sema/attr-availability-ios.c b/test/Sema/attr-availability-ios.c
index 329068c..6462d58 100644
--- a/test/Sema/attr-availability-ios.c
+++ b/test/Sema/attr-availability-ios.c
@@ -1,14 +1,14 @@
// RUN: %clang_cc1 "-triple" "x86_64-apple-ios3.0" -fsyntax-only -verify %s
-void f0(int) __attribute__((availability(ios,introduced=2.0,deprecated=2.1))); // expected-note {{'f0' declared here}}
+void f0(int) __attribute__((availability(ios,introduced=2.0,deprecated=2.1))); // expected-note {{'f0' has been explicitly marked deprecated here}}
void f1(int) __attribute__((availability(ios,introduced=2.1)));
-void f2(int) __attribute__((availability(ios,introduced=2.0,deprecated=3.0))); // expected-note {{'f2' declared here}}
+void f2(int) __attribute__((availability(ios,introduced=2.0,deprecated=3.0))); // expected-note {{'f2' has been explicitly marked deprecated here}}
void f3(int) __attribute__((availability(ios,introduced=3.0)));
void f4(int) __attribute__((availability(macosx,introduced=10.1,deprecated=10.3,obsoleted=10.5), availability(ios,introduced=2.0,deprecated=2.1,obsoleted=3.0))); // expected-note{{explicitly marked unavailable}}
-void f5(int) __attribute__((availability(ios,introduced=2.0))) __attribute__((availability(ios,deprecated=3.0))); // expected-note {{'f5' declared here}}
+void f5(int) __attribute__((availability(ios,introduced=2.0))) __attribute__((availability(ios,deprecated=3.0))); // expected-note {{'f5' has been explicitly marked deprecated here}}
void f6(int) __attribute__((availability(ios,deprecated=3.0)));
-void f6(int) __attribute__((availability(ios,introduced=2.0))); // expected-note {{'f6' declared here}}
+void f6(int) __attribute__((availability(ios,introduced=2.0))); // expected-note {{'f6' has been explicitly marked deprecated here}}
void test() {
f0(0); // expected-warning{{'f0' is deprecated: first deprecated in iOS 2.1}}
diff --git a/test/Sema/attr-availability-macosx.c b/test/Sema/attr-availability-macosx.c
index 468e930..38f149b 100644
--- a/test/Sema/attr-availability-macosx.c
+++ b/test/Sema/attr-availability-macosx.c
@@ -2,10 +2,10 @@
void f0(int) __attribute__((availability(macosx,introduced=10.4,deprecated=10.6)));
void f1(int) __attribute__((availability(macosx,introduced=10.5)));
-void f2(int) __attribute__((availability(macosx,introduced=10.4,deprecated=10.5))); // expected-note {{'f2' declared here}}
+void f2(int) __attribute__((availability(macosx,introduced=10.4,deprecated=10.5))); // expected-note {{'f2' has been explicitly marked deprecated here}}
void f3(int) __attribute__((availability(macosx,introduced=10.6)));
void f4(int) __attribute__((availability(macosx,introduced=10.1,deprecated=10.3,obsoleted=10.5), availability(ios,introduced=2.0,deprecated=3.0))); // expected-note{{explicitly marked unavailable}}
-void f5(int) __attribute__((availability(ios,introduced=3.2), availability(macosx,unavailable))); // expected-note{{function has been explicitly marked unavailable here}}
+void f5(int) __attribute__((availability(ios,introduced=3.2), availability(macosx,unavailable))); // expected-note{{'f5' has been explicitly marked unavailable here}}
void test() {
f0(0);
diff --git a/test/Sema/attr-availability.c b/test/Sema/attr-availability.c
index ac6a187..b7a8e6e 100644
--- a/test/Sema/attr-availability.c
+++ b/test/Sema/attr-availability.c
@@ -8,10 +8,10 @@
// rdar://10095131
extern void
-ATSFontGetName(const char *oName) __attribute__((availability(macosx,introduced=8.0,deprecated=9.0, message="use CTFontCopyFullName"))); // expected-note {{'ATSFontGetName' declared here}}
+ATSFontGetName(const char *oName) __attribute__((availability(macosx,introduced=8.0,deprecated=9.0, message="use CTFontCopyFullName"))); // expected-note {{'ATSFontGetName' has been explicitly marked deprecated here}}
extern void
-ATSFontGetPostScriptName(int flags) __attribute__((availability(macosx,introduced=8.0,obsoleted=9.0, message="use ATSFontGetFullPostScriptName"))); // expected-note {{function has been explicitly marked unavailable here}}
+ATSFontGetPostScriptName(int flags) __attribute__((availability(macosx,introduced=8.0,obsoleted=9.0, message="use ATSFontGetFullPostScriptName"))); // expected-note {{'ATSFontGetPostScriptName' has been explicitly marked unavailable here}}
void test_10095131() {
ATSFontGetName("Hello"); // expected-warning {{'ATSFontGetName' is deprecated: first deprecated in OS X 9.0 - use CTFontCopyFullName}}
diff --git a/test/Sema/attr-capabilities.c b/test/Sema/attr-capabilities.c
new file mode 100644
index 0000000..e6f123f
--- /dev/null
+++ b/test/Sema/attr-capabilities.c
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -fsyntax-only -Wthread-safety -verify %s
+
+typedef int __attribute__((capability("role"))) ThreadRole;
+struct __attribute__((shared_capability("mutex"))) Mutex {};
+struct NotACapability {};
+
+// Test an invalid capability name
+struct __attribute__((capability("wrong"))) IncorrectName {}; // expected-warning {{invalid capability name 'wrong'; capability name must be 'mutex' or 'role'}}
+
+int Test1 __attribute__((capability("test1"))); // expected-error {{'capability' attribute only applies to structs or typedefs}}
+int Test2 __attribute__((shared_capability("test2"))); // expected-error {{'shared_capability' attribute only applies to structs or typedefs}}
+int Test3 __attribute__((acquire_capability("test3"))); // expected-warning {{'acquire_capability' attribute only applies to functions}}
+int Test4 __attribute__((try_acquire_capability("test4"))); // expected-error {{'try_acquire_capability' attribute only applies to functions}}
+int Test5 __attribute__((release_capability("test5"))); // expected-warning {{'release_capability' attribute only applies to functions}}
+
+struct __attribute__((capability(12))) Test3 {}; // expected-error {{'capability' attribute requires a string}}
+struct __attribute__((shared_capability(Test2))) Test4 {}; // expected-error {{'shared_capability' attribute requires a string}}
+
+struct __attribute__((capability)) Test5 {}; // expected-error {{'capability' attribute takes one argument}}
+struct __attribute__((shared_capability("test1", 12))) Test6 {}; // expected-error {{'shared_capability' attribute takes one argument}}
+
+struct NotACapability BadCapability;
+ThreadRole GUI, Worker;
+void Func1(void) __attribute__((requires_capability(GUI))) {}
+void Func2(void) __attribute__((requires_shared_capability(Worker))) {}
+
+void Func3(void) __attribute__((requires_capability)) {} // expected-error {{'requires_capability' attribute takes at least 1 argument}}
+void Func4(void) __attribute__((requires_shared_capability)) {} // expected-error {{'requires_shared_capability' attribute takes at least 1 argument}}
+
+void Func5(void) __attribute__((requires_capability(1))) {} // expected-warning {{'requires_capability' attribute requires arguments whose type is annotated with 'capability' attribute; type here is 'int'}}
+void Func6(void) __attribute__((requires_shared_capability(BadCapability))) {} // expected-warning {{'requires_shared_capability' attribute requires arguments whose type is annotated with 'capability' attribute; type here is 'struct NotACapability'}}
+
+void Func7(void) __attribute__((assert_capability(GUI))) {}
+void Func8(void) __attribute__((assert_shared_capability(GUI))) {}
+
+void Func9(void) __attribute__((assert_capability())) {} // expected-error {{'assert_capability' attribute takes one argument}}
+void Func10(void) __attribute__((assert_shared_capability())) {} // expected-error {{'assert_shared_capability' attribute takes one argument}}
+
+void Func11(void) __attribute__((acquire_capability(GUI))) {}
+void Func12(void) __attribute__((acquire_shared_capability(GUI))) {}
+
+void Func15(void) __attribute__((release_capability(GUI))) {}
+void Func16(void) __attribute__((release_shared_capability(GUI))) {}
+void Func17(void) __attribute__((release_generic_capability(GUI))) {}
+
+void Func21(void) __attribute__((try_acquire_capability(1))) {}
+void Func22(void) __attribute__((try_acquire_shared_capability(1))) {}
+
+void Func23(void) __attribute__((try_acquire_capability(1, GUI))) {}
+void Func24(void) __attribute__((try_acquire_shared_capability(1, GUI))) {}
+
+void Func25(void) __attribute__((try_acquire_capability())) {} // expected-error {{'try_acquire_capability' attribute takes at least 1 argument}}
+void Func26(void) __attribute__((try_acquire_shared_capability())) {} // expected-error {{'try_acquire_shared_capability' attribute takes at least 1 argument}}
\ No newline at end of file
diff --git a/test/Sema/attr-cleanup.c b/test/Sema/attr-cleanup.c
index f5cbc38..26f283a 100644
--- a/test/Sema/attr-cleanup.c
+++ b/test/Sema/attr-cleanup.c
@@ -38,7 +38,7 @@
__attribute((cleanup(c4))) void* g;
}
-void c5(void*) __attribute__((deprecated)); // expected-note{{'c5' declared here}}
+void c5(void*) __attribute__((deprecated)); // expected-note{{'c5' has been explicitly marked deprecated here}}
void t5() {
int i __attribute__((cleanup(c5))); // expected-warning {{'c5' is deprecated}}
}
diff --git a/test/Sema/attr-coldhot.c b/test/Sema/attr-coldhot.c
index 253b189..abadf88 100644
--- a/test/Sema/attr-coldhot.c
+++ b/test/Sema/attr-coldhot.c
@@ -6,5 +6,5 @@
int var1 __attribute__((__cold__)); // expected-warning{{'__cold__' attribute only applies to functions}}
int var2 __attribute__((__hot__)); // expected-warning{{'__hot__' attribute only applies to functions}}
-int qux() __attribute__((__hot__)) __attribute__((__cold__)); // expected-error{{'__hot__' and cold attributes are not compatible}}
-int baz() __attribute__((__cold__)) __attribute__((__hot__)); // expected-error{{'__cold__' and hot attributes are not compatible}}
+int qux() __attribute__((__hot__)) __attribute__((__cold__)); // expected-error{{'__hot__' and 'cold' attributes are not compatible}}
+int baz() __attribute__((__cold__)) __attribute__((__hot__)); // expected-error{{'__cold__' and 'hot' attributes are not compatible}}
diff --git a/test/Sema/attr-deprecated-message.c b/test/Sema/attr-deprecated-message.c
index f48d13e..c683061 100644
--- a/test/Sema/attr-deprecated-message.c
+++ b/test/Sema/attr-deprecated-message.c
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 %s -verify -fsyntax-only
// rdar: // 6734520
-typedef int INT1 __attribute__((deprecated("Please avoid INT1"))); // expected-note 3 {{'INT1' declared here}}
+typedef int INT1 __attribute__((deprecated("Please avoid INT1"))); // expected-note 3 {{'INT1' has been explicitly marked deprecated here}}
typedef INT1 INT2 __attribute__ ((__deprecated__("Please avoid INT2")));
@@ -12,16 +12,16 @@
INT1 should_be_unavailable; // expected-warning {{'INT1' is deprecated: Please avoid INT1}}
INT1a should_not_be_deprecated;
-INT1 f1(void) __attribute__ ((deprecated("Please avoid f1"))); // expected-note {{'f1' declared here}}
+INT1 f1(void) __attribute__ ((deprecated("Please avoid f1"))); // expected-note {{'f1' has been explicitly marked deprecated here}}
INT1 f2(void); // expected-warning {{'INT1' is deprecated: Please avoid INT1}}
-typedef enum {red, green, blue} Color __attribute__((deprecated("Please avoid Color"))); // expected-note {{'Color' declared here}}
+typedef enum {red, green, blue} Color __attribute__((deprecated("Please avoid Color"))); // expected-note {{'Color' has been explicitly marked deprecated here}}
Color c1; // expected-warning {{'Color' is deprecated: Please avoid Color}}
int g1;
-int g2 __attribute__ ((deprecated("Please avoid g2"))); // expected-note {{'g2' declared here}}
+int g2 __attribute__ ((deprecated("Please avoid g2"))); // expected-note {{'g2' has been explicitly marked deprecated here}}
int func1()
{
diff --git a/test/Sema/attr-deprecated.c b/test/Sema/attr-deprecated.c
index 8124ab0..c9e3dd5 100644
--- a/test/Sema/attr-deprecated.c
+++ b/test/Sema/attr-deprecated.c
@@ -1,10 +1,10 @@
// RUN: %clang_cc1 %s -verify -fsyntax-only
-int f() __attribute__((deprecated)); // expected-note 2 {{declared here}}
+int f() __attribute__((deprecated)); // expected-note 2 {{'f' has been explicitly marked deprecated here}}
void g() __attribute__((deprecated));
-void g(); // expected-note {{declared here}}
+void g(); // expected-note {{'g' has been explicitly marked deprecated here}}
-extern int var __attribute__((deprecated)); // expected-note {{declared here}}
+extern int var __attribute__((deprecated)); // expected-note {{'var' has been explicitly marked deprecated here}}
int a() {
int (*ptr)() = f; // expected-warning {{'f' is deprecated}}
@@ -17,13 +17,13 @@
}
// test if attributes propagate to variables
-extern int var; // expected-note {{declared here}}
+extern int var; // expected-note {{'var' has been explicitly marked deprecated here}}
int w() {
return var; // expected-warning {{'var' is deprecated}}
}
int old_fn() __attribute__ ((deprecated));
-int old_fn(); // expected-note {{declared here}}
+int old_fn(); // expected-note {{'old_fn' has been explicitly marked deprecated here}}
int (*fn_ptr)() = old_fn; // expected-warning {{'old_fn' is deprecated}}
int old_fn() {
@@ -32,7 +32,7 @@
struct foo {
- int x __attribute__((deprecated)); // expected-note 3 {{declared here}}
+ int x __attribute__((deprecated)); // expected-note 3 {{'x' has been explicitly marked deprecated here}}
};
void test1(struct foo *F) {
@@ -41,11 +41,11 @@
struct foo f2 = { 17 }; // expected-warning {{'x' is deprecated}}
}
-typedef struct foo foo_dep __attribute__((deprecated)); // expected-note 12 {{declared here}}
+typedef struct foo foo_dep __attribute__((deprecated)); // expected-note 12 {{'foo_dep' has been explicitly marked deprecated here}}
foo_dep *test2; // expected-warning {{'foo_dep' is deprecated}}
struct __attribute__((deprecated,
- invalid_attribute)) bar_dep ; // expected-warning {{unknown attribute 'invalid_attribute' ignored}} expected-note 2 {{declared here}}
+ invalid_attribute)) bar_dep ; // expected-warning {{unknown attribute 'invalid_attribute' ignored}} expected-note 2 {{'bar_dep' has been explicitly marked deprecated here}}
struct bar_dep *test3; // expected-warning {{'bar_dep' is deprecated}}
@@ -102,9 +102,9 @@
test19;
// rdar://problem/8518751
-enum __attribute__((deprecated)) Test20 { // expected-note {{declared here}}
- test20_a __attribute__((deprecated)), // expected-note {{declared here}}
- test20_b // expected-note {{declared here}}
+enum __attribute__((deprecated)) Test20 { // expected-note {{'Test20' has been explicitly marked deprecated here}}
+ test20_a __attribute__((deprecated)), // expected-note {{'test20_a' has been explicitly marked deprecated here}}
+ test20_b // expected-note {{'test20_b' has been explicitly marked deprecated here}}
};
void test20() {
enum Test20 f; // expected-warning {{'Test20' is deprecated}}
@@ -122,5 +122,5 @@
};
typedef int test23_ty __attribute((deprecated)); // expected-note {{previous definition is here}}
-typedef int test23_ty; // expected-note {{'test23_ty' declared here}} expected-warning {{redefinition of typedef 'test23_ty' is a C11 feature}}
+typedef int test23_ty; // expected-note {{'test23_ty' has been explicitly marked deprecated here}} expected-warning {{redefinition of typedef 'test23_ty' is a C11 feature}}
test23_ty test23_v; // expected-warning {{'test23_ty' is deprecated}}
diff --git a/test/Sema/attr-malloc.c b/test/Sema/attr-malloc.c
index 2cec84d..c78d15c 100644
--- a/test/Sema/attr-malloc.c
+++ b/test/Sema/attr-malloc.c
@@ -1,5 +1,5 @@
-// RUN: %clang -Xclang -verify -fsyntax-only %s
-// RUN: %clang -emit-llvm -S -o %t %s
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+// RUN: %clang_cc1 -emit-llvm -o %t %s
#include <stddef.h>
diff --git a/test/Sema/attr-msp430.c b/test/Sema/attr-msp430.c
new file mode 100644
index 0000000..d08cd8e
--- /dev/null
+++ b/test/Sema/attr-msp430.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple msp430-unknown-unknown -fsyntax-only -verify %s
+
+int i;
+void f(void) __attribute__((interrupt(i))); /* expected-error {{'interrupt' attribute requires an integer constant}} */
+
+void f2(void) __attribute__((interrupt(12)));
diff --git a/test/Sema/attr-noduplicate.c b/test/Sema/attr-noduplicate.c
new file mode 100644
index 0000000..2a77de5
--- /dev/null
+++ b/test/Sema/attr-noduplicate.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+int a __attribute__((noduplicate)); // expected-warning {{'noduplicate' attribute only applies to functions}}
+
+void t1() __attribute__((noduplicate));
+
+void t2() __attribute__((noduplicate(2))); // expected-error {{'noduplicate' attribute takes no arguments}}
+
diff --git a/test/Sema/attr-ownership.c b/test/Sema/attr-ownership.c
index e31b429..2aa9f9f 100644
--- a/test/Sema/attr-ownership.c
+++ b/test/Sema/attr-ownership.c
@@ -1,12 +1,12 @@
// RUN: %clang_cc1 %s -verify
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 {{attribute takes no more than 1 argument}}
+void *f2(void) __attribute__((ownership_returns(foo, 1, 2))); // expected-error {{'ownership_returns' attribute takes no more than 1 argument}}
void f3(void) __attribute__((ownership_holds(foo, 1))); // expected-error {{'ownership_holds' attribute parameter 1 is out of bounds}}
void *f4(void) __attribute__((ownership_returns(foo)));
-void f5(void) __attribute__((ownership_holds(foo))); // expected-error {{attribute takes at least 2 arguments}}
+void f5(void) __attribute__((ownership_holds(foo))); // expected-error {{'ownership_holds' attribute takes at least 2 arguments}}
void f6(void) __attribute__((ownership_holds(foo, 1, 2, 3))); // expected-error {{'ownership_holds' attribute parameter 1 is out of bounds}}
-void f7(void) __attribute__((ownership_takes(foo))); // expected-error {{attribute takes at least 2 arguments}}
+void f7(void) __attribute__((ownership_takes(foo))); // expected-error {{'ownership_takes' attribute takes at least 2 arguments}}
void f8(int *i, int *j, int k) __attribute__((ownership_holds(foo, 1, 2, 4))); // expected-error {{'ownership_holds' attribute parameter 3 is out of bounds}}
int f9 __attribute__((ownership_takes(foo, 1))); // expected-warning {{'ownership_takes' attribute only applies to functions}}
diff --git a/test/Sema/attr-section.c b/test/Sema/attr-section.c
index 396892a..812de06 100644
--- a/test/Sema/attr-section.c
+++ b/test/Sema/attr-section.c
@@ -10,10 +10,12 @@
// PR6007
void test() {
- __attribute__((section("NEAR,x"))) int n1; // expected-error {{'section' attribute is not valid on local variables}}
+ __attribute__((section("NEAR,x"))) int n1; // expected-error {{'section' attribute only applies to functions and global variables}}
__attribute__((section("NEAR,x"))) static int n2; // ok.
}
// pr9356
void __attribute__((section("foo,zed"))) test2(void); // expected-note {{previous attribute is here}}
void __attribute__((section("bar,zed"))) test2(void) {} // expected-warning {{section does not match previous declaration}}
+
+enum __attribute__((section("NEAR,x"))) e { one }; // expected-error {{'section' attribute only applies to functions and global variables}}
diff --git a/test/Sema/attr-unavailable-message.c b/test/Sema/attr-unavailable-message.c
index ebdf945..400a2c6 100644
--- a/test/Sema/attr-unavailable-message.c
+++ b/test/Sema/attr-unavailable-message.c
@@ -1,8 +1,8 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// rdar: //6734520
-int foo(int) __attribute__((__unavailable__("USE IFOO INSTEAD"))); // expected-note {{function has been explicitly marked unavailable here}}
-double dfoo(double) __attribute__((__unavailable__("NO LONGER"))); // expected-note 2 {{function has been explicitly marked unavailable here}}
+int foo(int) __attribute__((__unavailable__("USE IFOO INSTEAD"))); // expected-note {{'foo' has been explicitly marked unavailable here}}
+double dfoo(double) __attribute__((__unavailable__("NO LONGER"))); // expected-note 2 {{'dfoo' has been explicitly marked unavailable here}}
void bar() __attribute__((__unavailable__)); // expected-note {{explicitly marked unavailable}}
@@ -34,13 +34,13 @@
// rdar://10201690
enum foo {
- a = 1, // expected-note {{declared here}}
- b __attribute__((deprecated())) = 2, // expected-note {{declared here}}
+ a = 1, // expected-note {{'a' has been explicitly marked deprecated here}}
+ b __attribute__((deprecated())) = 2, // expected-note {{'b' has been explicitly marked deprecated here}}
c = 3
}__attribute__((deprecated()));
-enum fee { // expected-note {{declaration has been explicitly marked unavailable here}}
- r = 1, // expected-note {{declaration has been explicitly marked unavailable here}}
+enum fee { // expected-note {{'fee' has been explicitly marked unavailable here}}
+ r = 1, // expected-note {{'r' has been explicitly marked unavailable here}}
s = 2,
t = 3
}__attribute__((unavailable()));
diff --git a/test/Sema/attr-used.c b/test/Sema/attr-used.c
index accc7b6..4e3bda7 100644
--- a/test/Sema/attr-used.c
+++ b/test/Sema/attr-used.c
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -verify -fsyntax-only -Wno-private-extern %s
-extern int l0 __attribute__((used)); // expected-warning {{used attribute ignored}}
-__private_extern__ int l1 __attribute__((used)); // expected-warning {{used attribute ignored}}
+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}}
int x;
@@ -13,8 +13,8 @@
}
void f1() {
- static int a __attribute__((used));
- int b __attribute__((used)); // expected-warning {{used attribute ignored}}
+ static int a __attribute__((used));
+ int b __attribute__((used)); // expected-warning {{'used' attribute ignored}}
}
static void __attribute__((used)) f0(void);
diff --git a/test/Sema/bitfield-layout.c b/test/Sema/bitfield-layout.c
index d226391..2abd139 100644
--- a/test/Sema/bitfield-layout.c
+++ b/test/Sema/bitfield-layout.c
@@ -9,6 +9,21 @@
CHECK_SIZE(struct, a, 5)
CHECK_ALIGN(struct, a, 1)
+// Zero-width bit-fields with packed
+struct __attribute__((packed)) a2 { short x : 9; char : 0; int y : 17; };
+CHECK_SIZE(struct, a2, 5)
+CHECK_ALIGN(struct, a2, 1)
+
+// Zero-width bit-fields at the end of packed struct
+struct __attribute__((packed)) a3 { short x : 9; int : 0; };
+CHECK_SIZE(struct, a3, 4)
+CHECK_ALIGN(struct, a3, 1)
+
+// For comparison, non-zero-width bit-fields at the end of packed struct
+struct __attribute__((packed)) a4 { short x : 9; int : 1; };
+CHECK_SIZE(struct, a4, 2)
+CHECK_ALIGN(struct, a4, 1)
+
union b {char x; int : 0; char y;};
CHECK_SIZE(union, b, 1)
CHECK_ALIGN(union, b, 1)
diff --git a/test/Sema/block-misc.c b/test/Sema/block-misc.c
index 2260458..b4732b5 100644
--- a/test/Sema/block-misc.c
+++ b/test/Sema/block-misc.c
@@ -131,7 +131,7 @@
static void *P = ^{ // expected-error {{initializer element is not a compile-time constant}}
void *Q = ^{
- // References test14's "X": outer block is non constant.
+ // References test14's "X": outer block is non-constant.
return X+4;
};
};
diff --git a/test/Sema/builtins-arm64-exclusive.c b/test/Sema/builtins-arm64-exclusive.c
new file mode 100644
index 0000000..0be9c17
--- /dev/null
+++ b/test/Sema/builtins-arm64-exclusive.c
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios7.0 -fsyntax-only -verify %s
+
+struct Simple {
+ char a, b;
+};
+
+int test_ldrex(char *addr) {
+ int sum = 0;
+ sum += __builtin_arm_ldrex(addr);
+ sum += __builtin_arm_ldrex((short *)addr);
+ sum += __builtin_arm_ldrex((int *)addr);
+ sum += __builtin_arm_ldrex((long long *)addr);
+ sum += __builtin_arm_ldrex((__int128 *)addr);
+ sum += __builtin_arm_ldrex((float *)addr);
+ sum += __builtin_arm_ldrex((double *)addr);
+ sum += *__builtin_arm_ldrex((int **)addr);
+ sum += __builtin_arm_ldrex((struct Simple **)addr)->a;
+ sum += __builtin_arm_ldrex((volatile char *)addr);
+ sum += __builtin_arm_ldrex((const volatile char *)addr);
+
+ // In principle this might be valid, but stick to ints and floats for scalar
+ // types at the moment.
+ sum += __builtin_arm_ldrex((struct Simple *)addr).a; // expected-error {{address argument to atomic builtin must be a pointer to}}
+
+ __builtin_arm_ldrex(); // expected-error {{too few arguments to function call}}
+ __builtin_arm_ldrex(1, 2); // expected-error {{too many arguments to function call}}
+ return sum;
+}
+
+int test_strex(char *addr) {
+ int res = 0;
+ struct Simple var = {0};
+ res |= __builtin_arm_strex(4, addr);
+ res |= __builtin_arm_strex(42, (short *)addr);
+ res |= __builtin_arm_strex(42, (int *)addr);
+ res |= __builtin_arm_strex(42, (long long *)addr);
+ res |= __builtin_arm_strex(42, (__int128 *)addr);
+ res |= __builtin_arm_strex(2.71828f, (float *)addr);
+ res |= __builtin_arm_strex(3.14159, (double *)addr);
+ res |= __builtin_arm_strex(&var, (struct Simple **)addr);
+
+ res |= __builtin_arm_strex(42, (volatile char *)addr);
+ res |= __builtin_arm_strex(42, (char *const)addr);
+ res |= __builtin_arm_strex(42, (const char *)addr); // expected-warning {{passing 'const char *' to parameter of type 'volatile char *' discards qualifiers}}
+
+
+ res |= __builtin_arm_strex(var, (struct Simple *)addr); // expected-error {{address argument to atomic builtin must be a pointer to}}
+ res |= __builtin_arm_strex(var, (struct Simple **)addr); // expected-error {{passing 'struct Simple' to parameter of incompatible type 'struct Simple *'}}
+ res |= __builtin_arm_strex(&var, (struct Simple **)addr).a; // expected-error {{is not a structure or union}}
+
+ __builtin_arm_strex(1); // expected-error {{too few arguments to function call}}
+ __builtin_arm_strex(1, 2, 3); // expected-error {{too many arguments to function call}}
+ return res;
+}
+
+void test_clrex() {
+ __builtin_arm_clrex();
+ __builtin_arm_clrex(1); // expected-error {{too many arguments to function call}}
+}
diff --git a/test/Sema/builtins-arm64.c b/test/Sema/builtins-arm64.c
new file mode 100644
index 0000000..f2bdc9d
--- /dev/null
+++ b/test/Sema/builtins-arm64.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple arm64-apple-ios -DTEST1 -fsyntax-only -verify %s
+
+#ifdef TEST1
+void __clear_cache(void *start, void *end);
+#endif
+
+void test_clear_cache_chars(char *start, char *end) {
+ __clear_cache(start, end);
+}
+
+void test_clear_cache_voids(void *start, void *end) {
+ __clear_cache(start, end);
+}
+
+void test_clear_cache_no_args() {
+ __clear_cache(); // expected-error {{too few arguments to function call}}
+}
diff --git a/test/Sema/callingconv.c b/test/Sema/callingconv.c
index 500c0fb..f9fa9fe 100644
--- a/test/Sema/callingconv.c
+++ b/test/Sema/callingconv.c
@@ -66,3 +66,5 @@
typedef void typedef_fun_t(int);
typedef_fun_t typedef_fun; // expected-note {{previous declaration is here}}
void __attribute__((stdcall)) typedef_fun(int x) { } // expected-error {{function declared 'stdcall' here was previously declared without calling convention}}
+
+struct type_test {} __attribute__((stdcall)); // expected-warning {{'stdcall' attribute only applies to functions and methods}}
diff --git a/test/Sema/carbon.c b/test/Sema/carbon.c
deleted file mode 100644
index 0498116..0000000
--- a/test/Sema/carbon.c
+++ /dev/null
@@ -1,4 +0,0 @@
-// RUN: %clang -fsyntax-only %s
-#ifdef __APPLE__
-#include <Carbon/Carbon.h>
-#endif
diff --git a/test/Sema/const-eval.c b/test/Sema/const-eval.c
index 16d028e..883cced 100644
--- a/test/Sema/const-eval.c
+++ b/test/Sema/const-eval.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-linux %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-linux %s -Wno-tautological-pointer-compare
#define EVAL_EXPR(testno, expr) int test##testno = sizeof(struct{char qq[expr];});
int x;
diff --git a/test/Sema/constructor-attribute.c b/test/Sema/constructor-attribute.c
index 3825916..1bb69fc 100644
--- a/test/Sema/constructor-attribute.c
+++ b/test/Sema/constructor-attribute.c
@@ -3,13 +3,13 @@
int x __attribute__((constructor)); // expected-warning {{'constructor' attribute only applies to functions}}
int f() __attribute__((constructor));
int f() __attribute__((constructor(1)));
-int f() __attribute__((constructor(1,2))); // expected-error {{attribute takes no more than 1 argument}}
-int f() __attribute__((constructor(1.0))); // expected-error {{'constructor' attribute requires parameter 1 to be an integer constant}}
+int f() __attribute__((constructor(1,2))); // expected-error {{'constructor' attribute takes no more than 1 argument}}
+int f() __attribute__((constructor(1.0))); // expected-error {{'constructor' attribute requires an integer constant}}
int x __attribute__((destructor)); // expected-warning {{'destructor' attribute only applies to functions}}
int f() __attribute__((destructor));
int f() __attribute__((destructor(1)));
-int f() __attribute__((destructor(1,2))); // expected-error {{attribute takes no more than 1 argument}}
-int f() __attribute__((destructor(1.0))); // expected-error {{'destructor' attribute requires parameter 1 to be an integer constant}}
+int f() __attribute__((destructor(1,2))); // expected-error {{'destructor' attribute takes no more than 1 argument}}
+int f() __attribute__((destructor(1.0))); // expected-error {{'destructor' attribute requires an integer constant}}
diff --git a/test/Sema/crash-invalid-array.c b/test/Sema/crash-invalid-array.c
index eeac391..029413b 100644
--- a/test/Sema/crash-invalid-array.c
+++ b/test/Sema/crash-invalid-array.c
@@ -1,18 +1,16 @@
-// RUN: not %clang_cc1 -O1 %s -emit-llvm
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin -fsyntax-only -verify %s
// PR6913
-#include <stdio.h>
-
int main()
{
int x[10][10];
- int (*p)[] = x; // expected-error {{invalid use of array with unspecified bounds}
+ int (*p)[] = x;
int i;
for(i = 0; i < 10; ++i)
{
- p[i][i] = i;
+ p[i][i] = i; // expected-error {{subscript of pointer to incomplete type 'int []'}}
}
}
diff --git a/test/Sema/decl-in-prototype.c b/test/Sema/decl-in-prototype.c
index 05b8e0a..9cb7fab 100644
--- a/test/Sema/decl-in-prototype.c
+++ b/test/Sema/decl-in-prototype.c
@@ -1,12 +1,12 @@
-// RUN: %clang_cc1_only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
const int AA = 5;
-int f1(enum {AA,BB} E) {
+int f1(enum {AA,BB} E) { // expected-warning {{will not be visible outside of this function}}
return BB;
}
-int f2(enum {AA=7,BB} E) {
+int f2(enum {AA=7,BB} E) { // expected-warning {{will not be visible outside of this function}}
return AA;
}
diff --git a/test/Sema/dllexport.c b/test/Sema/dllexport.c
new file mode 100644
index 0000000..8a71e5d
--- /dev/null
+++ b/test/Sema/dllexport.c
@@ -0,0 +1,135 @@
+// RUN: %clang_cc1 -triple i686-win32 -fsyntax-only -verify -std=c99 %s
+// RUN: %clang_cc1 -triple x86_64-win32 -fsyntax-only -verify -std=c11 %s
+// RUN: %clang_cc1 -triple i686-mingw32 -fsyntax-only -verify -std=c11 %s
+// RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -verify -std=c99 %s
+
+// Invalid usage.
+__declspec(dllexport) typedef int typedef1; // expected-warning{{'dllexport' attribute only applies to variables and functions}}
+typedef __declspec(dllexport) int typedef2; // expected-warning{{'dllexport' attribute only applies to variables and functions}}
+typedef int __declspec(dllexport) typedef3; // expected-warning{{'dllexport' attribute only applies to variables and functions}}
+typedef __declspec(dllexport) void (*FunTy)(); // expected-warning{{'dllexport' attribute only applies to variables and functions}}
+enum __declspec(dllexport) Enum { EnumVal }; // expected-warning{{'dllexport' attribute only applies to variables and functions}}
+struct __declspec(dllexport) Record {}; // expected-warning{{'dllexport' attribute only applies to variables and functions}}
+
+
+
+//===----------------------------------------------------------------------===//
+// Globals
+//===----------------------------------------------------------------------===//
+
+// Export declaration.
+__declspec(dllexport) extern int ExternGlobalDecl;
+
+// dllexport implies a definition.
+__declspec(dllexport) int GlobalDef;
+
+// Export definition.
+__declspec(dllexport) int GlobalInit1 = 1;
+int __declspec(dllexport) GlobalInit2 = 1;
+
+// Declare, then export definition.
+__declspec(dllexport) extern int GlobalDeclInit;
+int GlobalDeclInit = 1;
+
+// Redeclarations
+__declspec(dllexport) extern int GlobalRedecl1;
+__declspec(dllexport) int GlobalRedecl1;
+
+__declspec(dllexport) extern int GlobalRedecl2;
+ int GlobalRedecl2;
+
+ extern int GlobalRedecl3; // expected-note{{previous declaration is here}}
+__declspec(dllexport) extern int GlobalRedecl3; // expected-error{{redeclaration of 'GlobalRedecl3' cannot add 'dllexport' attribute}}
+
+// External linkage is required.
+__declspec(dllexport) static int StaticGlobal; // expected-error{{'StaticGlobal' must have external linkage when declared 'dllexport'}}
+
+// Export in local scope.
+void functionScope() {
+ __declspec(dllexport) int LocalVarDecl; // expected-error{{'LocalVarDecl' must have external linkage when declared 'dllexport'}}
+ __declspec(dllexport) int LocalVarDef = 1; // expected-error{{'LocalVarDef' must have external linkage when declared 'dllexport'}}
+ __declspec(dllexport) extern int ExternLocalVarDecl;
+ __declspec(dllexport) static int StaticLocalVar; // expected-error{{'StaticLocalVar' must have external linkage when declared 'dllexport'}}
+}
+
+
+
+//===----------------------------------------------------------------------===//
+// Functions
+//===----------------------------------------------------------------------===//
+
+// Export function declaration. Check different placements.
+__attribute__((dllexport)) void decl1A(); // Sanity check with __attribute__
+__declspec(dllexport) void decl1B();
+
+void __attribute__((dllexport)) decl2A();
+void __declspec(dllexport) decl2B();
+
+// Export function definition.
+__declspec(dllexport) void def() {}
+
+// Export inline function.
+__declspec(dllexport) inline void inlineFunc1() {} // expected-warning{{'dllexport' attribute ignored}}
+extern void inlineFunc1();
+
+inline void __attribute__((dllexport)) inlineFunc2() {} // expected-warning{{'dllexport' attribute ignored}}
+extern void inlineFunc2();
+
+// Redeclarations
+__declspec(dllexport) void redecl1();
+__declspec(dllexport) void redecl1();
+
+__declspec(dllexport) void redecl2();
+ void redecl2();
+
+__declspec(dllexport) void redecl3();
+ void redecl3() {}
+
+ void redecl4(); // expected-note{{previous declaration is here}}
+__declspec(dllexport) void redecl4(); // expected-error{{redeclaration of 'redecl4' cannot add 'dllexport' attribute}}
+
+// External linkage is required.
+__declspec(dllexport) static int staticFunc(); // expected-error{{'staticFunc' must have external linkage when declared 'dllexport'}}
+
+
+
+//===----------------------------------------------------------------------===//
+// Precedence
+//===----------------------------------------------------------------------===//
+
+// dllexport takes precedence over dllimport if both are specified.
+__attribute__((dllimport, dllexport)) extern int PrecedenceExternGlobal1A; // expected-warning{{'dllimport' attribute ignored}}
+__declspec(dllimport) __declspec(dllexport) extern int PrecedenceExternGlobal1B; // expected-warning{{'dllimport' attribute ignored}}
+
+__attribute__((dllexport, dllimport)) extern int PrecedenceExternGlobal2A; // expected-warning{{'dllimport' attribute ignored}}
+__declspec(dllexport) __declspec(dllimport) extern int PrecedenceExternGlobal2B; // expected-warning{{'dllimport' attribute ignored}}
+
+__attribute__((dllimport, dllexport)) int PrecedenceGlobal1A; // expected-warning{{'dllimport' attribute ignored}}
+__declspec(dllimport) __declspec(dllexport) int PrecedenceGlobal1B; // expected-warning{{'dllimport' attribute ignored}}
+
+__attribute__((dllexport, dllimport)) int PrecedenceGlobal2A; // expected-warning{{'dllimport' attribute ignored}}
+__declspec(dllexport) __declspec(dllimport) int PrecedenceGlobal2B; // expected-warning{{'dllimport' attribute ignored}}
+
+__declspec(dllexport) extern int PrecedenceExternGlobalRedecl1;
+__declspec(dllimport) extern int PrecedenceExternGlobalRedecl1; // expected-warning{{'dllimport' attribute ignored}}
+
+__declspec(dllimport) extern int PrecedenceExternGlobalRedecl2; // expected-warning{{'dllimport' attribute ignored}}
+__declspec(dllexport) extern int PrecedenceExternGlobalRedecl2;
+
+__declspec(dllexport) extern int PrecedenceGlobalRedecl1;
+__declspec(dllimport) int PrecedenceGlobalRedecl1; // expected-warning{{'dllimport' attribute ignored}}
+
+__declspec(dllimport) extern int PrecedenceGlobalRedecl2; // expected-warning{{'dllimport' attribute ignored}}
+__declspec(dllexport) int PrecedenceGlobalRedecl2;
+
+void __attribute__((dllimport, dllexport)) precedence1A() {} // expected-warning{{'dllimport' attribute ignored}}
+void __declspec(dllimport) __declspec(dllexport) precedence1B() {} // expected-warning{{'dllimport' attribute ignored}}
+
+void __attribute__((dllexport, dllimport)) precedence2A() {} // expected-warning{{'dllimport' attribute ignored}}
+void __declspec(dllexport) __declspec(dllimport) precedence2B() {} // expected-warning{{'dllimport' attribute ignored}}
+
+void __declspec(dllimport) precedenceRedecl1(); // expected-warning{{'dllimport' attribute ignored}}
+void __declspec(dllexport) precedenceRedecl1() {}
+
+void __declspec(dllexport) precedenceRedecl2();
+void __declspec(dllimport) precedenceRedecl2() {} // expected-warning{{'dllimport' attribute ignored}}
diff --git a/test/Sema/dllimport-dllexport.c b/test/Sema/dllimport-dllexport.c
deleted file mode 100644
index 80810d6..0000000
--- a/test/Sema/dllimport-dllexport.c
+++ /dev/null
@@ -1,48 +0,0 @@
-// RUN: %clang_cc1 -triple i386-mingw32 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -verify %s
-
-inline void __attribute__((dllexport)) foo1(){} // expected-warning{{dllexport attribute ignored}}
-inline void __attribute__((dllimport)) foo2(){} // expected-warning{{dllimport attribute ignored}}
-
-void __attribute__((dllimport)) foo3(){} // expected-error{{dllimport attribute can be applied only to symbol declaration}}
-
-void __attribute__((dllimport, dllexport)) foo4(); // expected-warning{{dllimport attribute ignored}}
-
-void __attribute__((dllexport)) foo5();
-void __attribute__((dllimport)) foo5(); // expected-warning{{dllimport attribute ignored}}
-
-typedef int __attribute__((dllexport)) type6; // expected-warning{{'dllexport' attribute only applies to variables and functions}}
-
-typedef int __attribute__((dllimport)) type7; // expected-warning{{'dllimport' attribute only applies to variables and functions}}
-
-void __attribute__((dllimport)) foo6();
-void foo6(){} // expected-warning {{'foo6' redeclared without dllimport attribute: previous dllimport ignored}}
-
-// PR6269
-inline void __declspec(dllexport) foo7(){} // expected-warning{{dllexport attribute ignored}}
-inline void __declspec(dllimport) foo8(){} // expected-warning{{dllimport attribute ignored}}
-
-void __declspec(dllimport) foo9(){} // expected-error{{dllimport attribute can be applied only to symbol declaration}}
-
-void __declspec(dllimport) __declspec(dllexport) foo10(); // expected-warning{{dllimport attribute ignored}}
-
-void __declspec(dllexport) foo11();
-void __declspec(dllimport) foo11(); // expected-warning{{dllimport attribute ignored}}
-
-typedef int __declspec(dllexport) type1; // expected-warning{{'dllexport' attribute only applies to variables and functions}}
-
-typedef int __declspec(dllimport) type2; // expected-warning{{'dllimport' attribute only applies to variables and functions}}
-
-void __declspec(dllimport) foo12();
-void foo12(){} // expected-warning {{'foo12' redeclared without dllimport attribute: previous dllimport ignored}}
-
-void __attribute__((dllimport)) foo13(); // expected-warning{{dllimport attribute ignored}}
-void __attribute__((dllexport)) foo13();
-
-extern int foo14 __attribute__((dllexport));
-extern int foo14 __attribute__((dllimport)); // expected-warning{{dllimport attribute ignored}}
-
-__declspec(dllimport) int foo15 = 54; // expected-warning{{'dllimport' attribute cannot be specified on a definition}}
-
-extern __declspec(dllimport) int foo17;
-int foo17 = 54; // expected-warning{{'dllimport' attribute cannot be specified on a definition}}
diff --git a/test/Sema/dllimport.c b/test/Sema/dllimport.c
new file mode 100644
index 0000000..a498294
--- /dev/null
+++ b/test/Sema/dllimport.c
@@ -0,0 +1,122 @@
+// RUN: %clang_cc1 -triple i686-win32 -fsyntax-only -verify -std=c99 %s
+// RUN: %clang_cc1 -triple x86_64-win32 -fsyntax-only -verify -std=c11 %s
+// RUN: %clang_cc1 -triple i686-mingw32 -fsyntax-only -verify -std=c11 %s
+// RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -verify -std=c99 %s
+
+// Invalid usage.
+__declspec(dllimport) typedef int typedef1; // expected-warning{{'dllimport' attribute only applies to variables and functions}}
+typedef __declspec(dllimport) int typedef2; // expected-warning{{'dllimport' attribute only applies to variables and functions}}
+typedef int __declspec(dllimport) typedef3; // expected-warning{{'dllimport' attribute only applies to variables and functions}}
+typedef __declspec(dllimport) void (*FunTy)(); // expected-warning{{'dllimport' attribute only applies to variables and functions}}
+enum __declspec(dllimport) Enum { EnumVal }; // expected-warning{{'dllimport' attribute only applies to variables and functions}}
+struct __declspec(dllimport) Record {}; // expected-warning{{'dllimport' attribute only applies to variables and functions}}
+
+
+
+//===----------------------------------------------------------------------===//
+// Globals
+//===----------------------------------------------------------------------===//
+
+// Import declaration.
+__declspec(dllimport) extern int ExternGlobalDecl;
+
+// dllimport implies a declaration.
+__declspec(dllimport) int GlobalDecl;
+int **__attribute__((dllimport))* GlobalDeclChunkAttr;
+int GlobalDeclAttr __attribute__((dllimport));
+
+// Not allowed on definitions.
+__declspec(dllimport) extern int ExternGlobalInit = 1; // expected-error{{definition of dllimport data}}
+__declspec(dllimport) int GlobalInit1 = 1; // expected-error{{definition of dllimport data}}
+int __declspec(dllimport) GlobalInit2 = 1; // expected-error{{definition of dllimport data}}
+
+// Declare, then reject definition.
+__declspec(dllimport) extern int ExternGlobalDeclInit; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
+int ExternGlobalDeclInit = 1; // expected-warning{{'ExternGlobalDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
+
+__declspec(dllimport) int GlobalDeclInit; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
+int GlobalDeclInit = 1; // expected-warning{{'GlobalDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
+
+int *__attribute__((dllimport)) GlobalDeclChunkAttrInit; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
+int *GlobalDeclChunkAttrInit = 0; // expected-warning{{'GlobalDeclChunkAttrInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
+
+int GlobalDeclAttrInit __attribute__((dllimport)); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
+int GlobalDeclAttrInit = 1; // expected-warning{{'GlobalDeclAttrInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
+
+// Redeclarations
+__declspec(dllimport) extern int GlobalRedecl1;
+__declspec(dllimport) extern int GlobalRedecl1;
+
+__declspec(dllimport) int GlobalRedecl2a;
+__declspec(dllimport) int GlobalRedecl2a;
+
+int *__attribute__((dllimport)) GlobalRedecl2b;
+int *__attribute__((dllimport)) GlobalRedecl2b;
+
+int GlobalRedecl2c __attribute__((dllimport));
+int GlobalRedecl2c __attribute__((dllimport));
+
+// NB: MSVC issues a warning and makes GlobalRedecl3 dllexport. We follow GCC
+// and drop the dllimport with a warning.
+__declspec(dllimport) extern int GlobalRedecl3; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
+ extern int GlobalRedecl3; // expected-warning{{'GlobalRedecl3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
+
+ extern int GlobalRedecl4; // expected-note{{previous declaration is here}}
+__declspec(dllimport) extern int GlobalRedecl4; // expected-error{{redeclaration of 'GlobalRedecl4' cannot add 'dllimport' attribute}}
+
+// External linkage is required.
+__declspec(dllimport) static int StaticGlobal; // expected-error{{'StaticGlobal' must have external linkage when declared 'dllimport'}}
+
+// Import in local scope.
+__declspec(dllimport) float LocalRedecl1; // expected-note{{previous definition is here}}
+__declspec(dllimport) float LocalRedecl2; // expected-note{{previous definition is here}}
+__declspec(dllimport) float LocalRedecl3; // expected-note{{previous definition is here}}
+void functionScope() {
+ __declspec(dllimport) int LocalRedecl1; // expected-error{{redefinition of 'LocalRedecl1' with a different type: 'int' vs 'float'}}
+ int *__attribute__((dllimport)) LocalRedecl2; // expected-error{{redefinition of 'LocalRedecl2' with a different type: 'int *' vs 'float'}}
+ int LocalRedecl3 __attribute__((dllimport)); // expected-error{{redefinition of 'LocalRedecl3' with a different type: 'int' vs 'float'}}
+
+ __declspec(dllimport) int LocalVarDecl;
+ __declspec(dllimport) int LocalVarDef = 1; // expected-error{{definition of dllimport data}}
+ __declspec(dllimport) extern int ExternLocalVarDecl;
+ __declspec(dllimport) extern int ExternLocalVarDef = 1; // expected-error{{definition of dllimport data}}
+ __declspec(dllimport) static int StaticLocalVar; // expected-error{{'StaticLocalVar' must have external linkage when declared 'dllimport'}}
+}
+
+
+
+//===----------------------------------------------------------------------===//
+// Functions
+//===----------------------------------------------------------------------===//
+
+// Import function declaration. Check different placements.
+__attribute__((dllimport)) void decl1A(); // Sanity check with __attribute__
+__declspec(dllimport) void decl1B();
+
+void __attribute__((dllimport)) decl2A();
+void __declspec(dllimport) decl2B();
+
+// Not allowed on function definitions.
+__declspec(dllimport) void def() {} // expected-error{{'dllimport' attribute can be applied only to symbol declaration}}
+
+// Import inline function.
+__declspec(dllimport) inline void inlineFunc1() {} // expected-warning{{'dllimport' attribute ignored}}
+inline void __attribute__((dllimport)) inlineFunc2() {} // expected-warning{{'dllimport' attribute ignored}}
+
+// Redeclarations
+__declspec(dllimport) void redecl1();
+__declspec(dllimport) void redecl1();
+
+// NB: MSVC issues a warning and makes redecl2/redecl3 dllexport. We follow GCC
+// and drop the dllimport with a warning.
+__declspec(dllimport) void redecl2(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
+ void redecl2(); // expected-warning{{'redecl2' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
+
+__declspec(dllimport) void redecl3(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
+ void redecl3() {} // expected-warning{{'redecl3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
+
+ void redecl4(); // expected-note{{previous declaration is here}}
+__declspec(dllimport) void redecl4(); // expected-error{{redeclaration of 'redecl4' cannot add 'dllimport' attribute}}
+
+// External linkage is required.
+__declspec(dllimport) static int staticFunc(); // expected-error{{'staticFunc' must have external linkage when declared 'dllimport'}}
diff --git a/test/Sema/empty1.c b/test/Sema/empty1.c
index de922f7..9a2fb67 100644
--- a/test/Sema/empty1.c
+++ b/test/Sema/empty1.c
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -Wc++-compat
+// RUN: %clang_cc1 %s -triple %itanium_abi_triple -fsyntax-only -verify -Wc++-compat
+
+// Note: Empty C structs are 4 bytes in the Microsoft ABI.
struct emp_1 { // expected-warning {{empty struct has size 0 in C, size 1 in C++}}
};
diff --git a/test/Sema/enable_if.c b/test/Sema/enable_if.c
new file mode 100644
index 0000000..a3c4323
--- /dev/null
+++ b/test/Sema/enable_if.c
@@ -0,0 +1,97 @@
+// RUN: %clang_cc1 %s -verify
+// RUN: %clang_cc1 %s -DCODEGEN -emit-llvm -o - | FileCheck %s
+
+#define O_CREAT 0x100
+typedef int mode_t;
+typedef unsigned long size_t;
+
+int open(const char *pathname, int flags) __attribute__((enable_if(!(flags & O_CREAT), "must specify mode when using O_CREAT"))) __attribute__((overloadable)); // expected-note{{candidate disabled: must specify mode when using O_CREAT}}
+int open(const char *pathname, int flags, mode_t mode) __attribute__((overloadable)); // expected-note{{candidate function not viable: requires 3 arguments, but 2 were provided}}
+
+void test1() {
+#ifndef CODEGEN
+ open("path", O_CREAT); // expected-error{{no matching function for call to 'open'}}
+#endif
+ open("path", O_CREAT, 0660);
+ open("path", 0);
+ open("path", 0, 0);
+}
+
+size_t __strnlen_chk(const char *s, size_t requested_amount, size_t s_len);
+
+size_t strnlen(const char *s, size_t maxlen) // expected-note{{candidate function}}
+ __attribute__((overloadable))
+ __asm__("strnlen_real1");
+
+__attribute__((always_inline))
+inline size_t strnlen(const char *s, size_t maxlen) // expected-note{{candidate function}}
+ __attribute__((overloadable))
+ __attribute__((enable_if(__builtin_object_size(s, 0) != -1,
+ "chosen when target buffer size is known")))
+{
+ return __strnlen_chk(s, maxlen, __builtin_object_size(s, 0));
+}
+
+size_t strnlen(const char *s, size_t maxlen) // expected-note{{candidate disabled: chosen when 'maxlen' is known to be less than or equal to the buffer size}}
+ __attribute__((overloadable))
+ __attribute__((enable_if(__builtin_object_size(s, 0) != -1,
+ "chosen when target buffer size is known")))
+ __attribute__((enable_if(maxlen <= __builtin_object_size(s, 0),
+ "chosen when 'maxlen' is known to be less than or equal to the buffer size")))
+ __asm__("strnlen_real2");
+
+size_t strnlen(const char *s, size_t maxlen) // expected-note{{candidate function has been explicitly made unavailable}}
+ __attribute__((overloadable))
+ __attribute__((enable_if(__builtin_object_size(s, 0) != -1,
+ "chosen when target buffer size is known")))
+ __attribute__((enable_if(maxlen > __builtin_object_size(s, 0),
+ "chosen when 'maxlen' is larger than the buffer size")))
+ __attribute__((unavailable("'maxlen' is larger than the buffer size")));
+
+void test2(const char *s, int i) {
+// CHECK: define void @test2
+ const char c[123];
+ strnlen(s, i);
+// CHECK: call {{.*}}strnlen_real1
+ strnlen(s, 999);
+// CHECK: call {{.*}}strnlen_real1
+ strnlen(c, 1);
+// CHECK: call {{.*}}strnlen_real2
+ strnlen(c, i);
+// CHECK: call {{.*}}strnlen_chk
+#ifndef CODEGEN
+ strnlen(c, 999); // expected-error{{call to unavailable function 'strnlen': 'maxlen' is larger than the buffer size}}
+#endif
+}
+
+int isdigit(int c) __attribute__((overloadable)); // expected-note{{candidate function}}
+int isdigit(int c) __attribute__((overloadable)) // expected-note{{candidate function has been explicitly made unavailable}}
+ __attribute__((enable_if(c <= -1 || c > 255, "'c' must have the value of an unsigned char or EOF")))
+ __attribute__((unavailable("'c' must have the value of an unsigned char or EOF")));
+
+void test3(int c) {
+ isdigit(c);
+ isdigit(10);
+#ifndef CODEGEN
+ isdigit(-10); // expected-error{{call to unavailable function 'isdigit': 'c' must have the value of an unsigned char or EOF}}
+#endif
+}
+
+#ifndef CODEGEN
+__attribute__((enable_if(n == 0, "chosen when 'n' is zero"))) void f1(int n); // expected-error{{use of undeclared identifier 'n'}}
+
+int n __attribute__((enable_if(1, "always chosen"))); // expected-warning{{'enable_if' attribute only applies to functions}}
+
+void f(int n) __attribute__((enable_if("chosen when 'n' is zero", n == 0))); // expected-error{{'enable_if' attribute requires a string}}
+
+void f(int n) __attribute__((enable_if())); // expected-error{{'enable_if' attribute requires exactly 2 arguments}}
+
+void f(int n) __attribute__((enable_if(unresolvedid, "chosen when 'unresolvedid' is non-zero"))); // expected-error{{use of undeclared identifier 'unresolvedid'}}
+
+int global;
+void f(int n) __attribute__((enable_if(global == 0, "chosen when 'global' is zero"))); // expected-error{{'enable_if' attribute expression never produces a constant expression}} // expected-note{{subexpression not valid in a constant expression}}
+
+const int cst = 7;
+void return_cst(void) __attribute__((overloadable)) __attribute__((enable_if(cst == 7, "chosen when 'cst' is 7")));
+void test_return_cst() { return_cst(); }
+#endif
diff --git a/test/Sema/ext_vector_casts.c b/test/Sema/ext_vector_casts.c
index 66004b0..d60bc3c 100644
--- a/test/Sema/ext_vector_casts.c
+++ b/test/Sema/ext_vector_casts.c
@@ -1,6 +1,7 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fsyntax-only -verify -fno-lax-vector-conversions %s
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fsyntax-only -verify -fno-lax-vector-conversions -Wconversion %s
typedef __attribute__(( ext_vector_type(2) )) float float2;
+typedef __attribute__(( ext_vector_type(3) )) float float3;
typedef __attribute__(( ext_vector_type(4) )) int int4;
typedef __attribute__(( ext_vector_type(8) )) short short8;
typedef __attribute__(( ext_vector_type(4) )) float float4;
@@ -11,12 +12,16 @@
static void test() {
float2 vec2;
+ float3 vec3;
float4 vec4, vec4_2;
int4 ivec4;
short8 ish8;
t3 vec4_3;
int *ptr;
int i;
+
+ vec3 += vec2; // expected-error {{can't convert between vector values of different size}}
+ vec4 += vec3; // expected-error {{can't convert between vector values of different size}}
vec4 = 5.0f;
vec4 = (float4)5.0f;
@@ -33,9 +38,8 @@
ivec4 = (int4)ptr; // expected-error {{invalid conversion between vector type 'int4' and scalar type 'int *'}}
vec4 = (float4)vec2; // expected-error {{invalid conversion between ext-vector type 'float4' and 'float2'}}
-
- ish8 += 5; // expected-error {{can't convert between vector values of different size ('short8' and 'int')}}
- ish8 += (short)5;
+
+ ish8 += 5;
ivec4 *= 5;
vec4 /= 5.2f;
vec4 %= 4; // expected-error {{invalid operands to binary expression ('float4' and 'int')}}
@@ -44,7 +48,7 @@
ivec4 += (int4)vec4;
ivec4 -= ivec4;
ivec4 |= ivec4;
- ivec4 += ptr; // expected-error {{can't convert between vector values of different size ('int4' and 'int *')}}
+ ivec4 += ptr; // expected-error {{can't convert between vector and non-scalar values ('int4' and 'int *')}}
}
typedef __attribute__(( ext_vector_type(2) )) float2 vecfloat2; // expected-error{{invalid vector element type 'float2'}}
@@ -74,3 +78,47 @@
return stride;
}
+// rdar://16196902
+typedef __attribute__((ext_vector_type(4))) float float32x4_t;
+
+typedef float C3DVector3 __attribute__((ext_vector_type(3)));
+
+extern float32x4_t vabsq_f32(float32x4_t __a);
+
+C3DVector3 Func(const C3DVector3 a) {
+ return (C3DVector3)vabsq_f32((float32x4_t)a); // expected-error {{invalid conversion between ext-vector type 'float32x4_t' and 'C3DVector3'}}
+}
+
+// rdar://16350802
+typedef double double2 __attribute__ ((ext_vector_type(2)));
+
+static void splats(int i, long l, __uint128_t t, float f, double d) {
+ short8 vs = 0;
+ int4 vi = i;
+ ulong2 vl = (unsigned long)l;
+ float2 vf = f;
+ double2 vd = d;
+
+ vs = 65536 + vs; // expected-warning {{implicit conversion from 'int' to 'short8' changes value from 65536 to 0}}
+ vs = vs + i; // expected-warning {{implicit conversion loses integer precision}}
+ vs = vs + 1;
+ vs = vs + 1.f; // expected-error {{can't convert between vector values of different size}}
+
+ vi = l + vi; // expected-warning {{implicit conversion loses integer precision}}
+ vi = 1 + vi;
+ vi = vi + 2.0; // expected-error {{can't convert between vector values of different size}}
+ vi = vi + 0xffffffff; // expected-warning {{implicit conversion changes signedness}}
+
+ vl = l + vl; // expected-warning {{implicit conversion changes signedness}}
+ vl = vl + t; // expected-warning {{implicit conversion loses integer precision}}
+
+ vf = 1 + vf;
+ vf = l + vf;
+ vf = 2.0 + vf;
+ vf = d + vf; // expected-warning {{implicit conversion loses floating-point precision}}
+ vf = vf + 0xffffffff;
+ vf = vf + 2.1; // expected-warning {{implicit conversion loses floating-point precision}}
+
+ vd = l + vd;
+ vd = vd + t;
+}
diff --git a/test/Sema/fn-ptr-as-fn-prototype.c b/test/Sema/fn-ptr-as-fn-prototype.c
index cf95c97..4b01b13 100644
--- a/test/Sema/fn-ptr-as-fn-prototype.c
+++ b/test/Sema/fn-ptr-as-fn-prototype.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1_only -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -ast-print %s | FileCheck %s
// This testcase checks the functionality of
// Sema::ActOn{Start,End}FunctionDeclarator, specifically checking that
diff --git a/test/Sema/format-strings-fixit.c b/test/Sema/format-strings-fixit.c
index 3127418..b982eb4 100644
--- a/test/Sema/format-strings-fixit.c
+++ b/test/Sema/format-strings-fixit.c
@@ -14,6 +14,7 @@
typedef __INTMAX_TYPE__ intmax_t;
typedef __UINTMAX_TYPE__ uintmax_t;
typedef __PTRDIFF_TYPE__ ptrdiff_t;
+typedef __WCHAR_TYPE__ wchar_t;
void test() {
// Basic types
@@ -97,11 +98,13 @@
int scanf(char const *, ...);
-void test2() {
+void test2(int intSAParm[static 2]) {
char str[100];
+ char *vstr = "abc";
short shortVar;
unsigned short uShortVar;
int intVar;
+ int intAVar[2];
unsigned uIntVar;
float floatVar;
double doubleVar;
@@ -114,11 +117,20 @@
intmax_t intmaxVar;
uintmax_t uIntmaxVar;
ptrdiff_t ptrdiffVar;
+ enum {A, B, C} enumVar;
+ // Some string types.
scanf("%lf", str);
+ scanf("%lf", vstr);
+ scanf("%ls", str);
+ scanf("%ls", str);
+
+ // Some integer types.
scanf("%f", &shortVar);
scanf("%f", &uShortVar);
scanf("%p", &intVar);
+ scanf("%f", intAVar);
+ scanf("%f", intSAParm);
scanf("%Lf", &uIntVar);
scanf("%ld", &floatVar);
scanf("%f", &doubleVar);
@@ -127,6 +139,7 @@
scanf("%f", &uLongVar);
scanf("%f", &longLongVar);
scanf("%f", &uLongLongVar);
+ scanf("%d", &enumVar); // FIXME: We ought to fix specifiers for enums.
// Some named ints.
scanf("%f", &sizeVar);
@@ -206,10 +219,15 @@
// CHECK: printf("%La", (long double) 42);
// CHECK: printf("%LA", (long double) 42);
-// CHECK: scanf("%s", str);
+// CHECK: scanf("%99s", str);
+// CHECK: scanf("%s", vstr);
+// CHECK: scanf("%99s", str);
+// CHECK: scanf("%99s", str);
// CHECK: scanf("%hd", &shortVar);
// CHECK: scanf("%hu", &uShortVar);
// CHECK: scanf("%d", &intVar);
+// CHECK: scanf("%d", intAVar);
+// CHECK: scanf("%d", intSAParm);
// CHECK: scanf("%u", &uIntVar);
// CHECK: scanf("%f", &floatVar);
// CHECK: scanf("%lf", &doubleVar);
@@ -218,6 +236,7 @@
// CHECK: scanf("%lu", &uLongVar);
// CHECK: scanf("%lld", &longLongVar);
// CHECK: scanf("%llu", &uLongLongVar);
+// CHECK: scanf("%d", &enumVar);
// CHECK: scanf("%zu", &sizeVar);
// CHECK: scanf("%jd", &intmaxVar);
// CHECK: scanf("%ju", &uIntmaxVar);
diff --git a/test/Sema/format-strings-scanf.c b/test/Sema/format-strings-scanf.c
index d66bed5..381447c 100644
--- a/test/Sema/format-strings-scanf.c
+++ b/test/Sema/format-strings-scanf.c
@@ -107,9 +107,9 @@
// Test argument type check for the 'm' length modifier.
scanf("%ms", fp); // expected-warning{{format specifies type 'char **' but the argument has type 'float *'}}
- scanf("%mS", fp); // expected-warning-re{{format specifies type 'wchar_t \*\*' \(aka '[^']+'\) but the argument has type 'float \*'}}
+ scanf("%mS", fp); // expected-warning-re{{format specifies type 'wchar_t **' (aka '{{[^']+}}') but the argument has type 'float *'}}
scanf("%mc", fp); // expected-warning{{format specifies type 'char **' but the argument has type 'float *'}}
- scanf("%mC", fp); // expected-warning-re{{format specifies type 'wchar_t \*\*' \(aka '[^']+'\) but the argument has type 'float \*'}}
+ scanf("%mC", fp); // expected-warning-re{{format specifies type 'wchar_t **' (aka '{{[^']+}}') but the argument has type 'float *'}}
scanf("%m[abc]", fp); // expected-warning{{format specifies type 'char **' but the argument has type 'float *'}}
}
diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c
index 6da027e..ad7b37c 100644
--- a/test/Sema/format-strings.c
+++ b/test/Sema/format-strings.c
@@ -535,6 +535,21 @@
0.0); // expected-warning{{format specifies}}
}
+void pr18905() {
+ const char s1[] = "s\0%s"; // expected-note{{format string is defined here}}
+ const char s2[1] = "s"; // expected-note{{format string is defined here}}
+ const char s3[2] = "s\0%s"; // expected-warning{{initializer-string for char array is too long}}
+ const char s4[10] = "s";
+ const char s5[0] = "%s"; // expected-warning{{initializer-string for char array is too long}}
+ // expected-note@-1{{format string is defined here}}
+
+ printf(s1); // expected-warning{{format string contains '\0' within the string body}}
+ printf(s2); // expected-warning{{format string is not null-terminated}}
+ printf(s3); // no-warning
+ printf(s4); // no-warning
+ printf(s5); // expected-warning{{format string is not null-terminated}}
+}
+
void __attribute__((format(strfmon,1,2))) monformat(const char *fmt, ...);
void __attribute__((format(strftime,1,0))) dateformat(const char *fmt);
@@ -544,7 +559,7 @@
monformat("", 1); // expected-warning{{format string is empty}}
monformat(str); // expected-warning{{format string is not a string literal (potentially insecure)}}
dateformat(""); // expected-warning{{format string is empty}}
- dateformat(str); // no-warning (using strftime non literal is not unsafe)
+ dateformat(str); // no-warning (using strftime non-literal is not unsafe)
}
// Do not warn about unused arguments coming from system headers.
diff --git a/test/Sema/i-c-e.c b/test/Sema/i-c-e.c
index 7749b6c..c6025f9 100644
--- a/test/Sema/i-c-e.c
+++ b/test/Sema/i-c-e.c
@@ -1,4 +1,4 @@
-// RUN: %clang %s -ffreestanding -Wno-int-to-pointer-cast -fsyntax-only -Xclang -verify -pedantic -fpascal-strings -std=c99
+// RUN: %clang_cc1 %s -ffreestanding -Wno-int-to-pointer-cast -fsyntax-only -verify -pedantic -fpascal-strings -std=c99
#include <stdint.h>
#include <limits.h>
diff --git a/test/Sema/implicit-builtin-decl.c b/test/Sema/implicit-builtin-decl.c
index d7ec169..bfc1907 100644
--- a/test/Sema/implicit-builtin-decl.c
+++ b/test/Sema/implicit-builtin-decl.c
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: not %clang_cc1 -fsyntax-only -ast-dump %s | FileCheck %s
+
void f() {
int *ptr = malloc(sizeof(int) * 10); // expected-warning{{implicitly declaring library function 'malloc' with type}} \
// expected-note{{please include the header <stdlib.h> or explicitly provide a declaration for 'malloc'}} \
@@ -57,3 +59,10 @@
void longjmp(); // expected-warning{{declaration of built-in function 'longjmp' requires inclusion of the header <setjmp.h>}}
extern float fmaxf(float, float);
+
+struct __jmp_buf_tag {};
+void sigsetjmp(struct __jmp_buf_tag[1], int); // expected-warning{{declaration of built-in function 'sigsetjmp' requires inclusion of the header <setjmp.h>}}
+
+// CHECK: FunctionDecl {{.*}} <line:[[@LINE-2]]:1, col:44> col:6 sigsetjmp '
+// CHECK-NOT: FunctionDecl
+// CHECK: ReturnsTwiceAttr {{.*}} <{{.*}}> Implicit
diff --git a/test/Sema/implicit-cast-dump.c b/test/Sema/implicit-cast-dump.c
index 87f15d0..4cd855f 100644
--- a/test/Sema/implicit-cast-dump.c
+++ b/test/Sema/implicit-cast-dump.c
@@ -5,7 +5,7 @@
void bar() {
- // CHECK: FunctionDecl {{.*}} <line:{{.*}}, line:{{.*}}> bar 'void ()'
+ // CHECK: FunctionDecl {{.*}} <line:{{.*}}, line:{{.*}}> line:{{.*}} bar 'void ()'
foo1(0);
// CHECK: ImplicitCastExpr {{.*}} <col:{{.*}}> 'void *' <NullToPointer>
diff --git a/test/Sema/inline-asm-validate.c b/test/Sema/inline-asm-validate.c
new file mode 100644
index 0000000..cfe4972
--- /dev/null
+++ b/test/Sema/inline-asm-validate.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple arm64-apple-macosx10.8.0 -fsyntax-only -verify %s
+
+unsigned t, r, *p;
+
+int foo (void) {
+ __asm__ __volatile__( "stxr %w[_t], %[_r], [%[_p]]" : [_t] "=&r" (t) : [_p] "p" (p), [_r] "r" (r) : "memory"); // expected-warning {{value size does not match register size specified by the constraint and modifier}}
+ return 1;
+}
diff --git a/test/Sema/lit.local.cfg b/test/Sema/lit.local.cfg
new file mode 100644
index 0000000..f4ef5d2
--- /dev/null
+++ b/test/Sema/lit.local.cfg
@@ -0,0 +1,4 @@
+config.substitutions = list(config.substitutions)
+config.substitutions.insert(0,
+ (r'%clang\b',
+ """*** Do not use the driver in Sema tests. ***""") )
diff --git a/test/Sema/loop-control.c b/test/Sema/loop-control.c
new file mode 100644
index 0000000..6c33e84
--- /dev/null
+++ b/test/Sema/loop-control.c
@@ -0,0 +1,121 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -x c++ -Werror %s
+
+int pr8880_1() {
+ int first = 1;
+ for ( ; ({ if (first) { first = 0; continue; } 0; }); )
+ return 0;
+ return 1;
+}
+
+void pr8880_2(int first) {
+ for ( ; ({ if (first) { first = 0; break; } 0; }); ) {}
+}
+
+void pr8880_3(int first) {
+ for ( ; ; (void)({ if (first) { first = 0; continue; } 0; })) {}
+}
+
+void pr8880_4(int first) {
+ for ( ; ; (void)({ if (first) { first = 0; break; } 0; })) {}
+}
+
+void pr8880_5 (int first) {
+ while(({ if (first) { first = 0; continue; } 0; })) {}
+}
+
+void pr8880_6 (int first) {
+ while(({ if (first) { first = 0; break; } 0; })) {}
+}
+
+void pr8880_7 (int first) {
+ do {} while(({ if (first) { first = 0; continue; } 0; }));
+}
+
+void pr8880_8 (int first) {
+ do {} while(({ if (first) { first = 0; break; } 0; }));
+}
+
+void pr8880_10(int i) {
+ for ( ; i != 10 ; i++ )
+ for ( ; ; (void)({ ++i; continue; i;})) {} // expected-warning{{'continue' is bound to current loop, GCC binds it to the enclosing loop}}
+}
+
+void pr8880_11(int i) {
+ for ( ; i != 10 ; i++ )
+ for ( ; ; (void)({ ++i; break; i;})) {} // expected-warning{{'break' is bound to current loop, GCC binds it to the enclosing loop}}
+}
+
+void pr8880_12(int i, int j) {
+ for ( ; i != 10 ; i++ )
+ for ( ; ({if (i) continue; i;}); j++) {} // expected-warning {{'continue' is bound to current loop, GCC binds it to the enclosing loop}}
+}
+
+void pr8880_13(int i, int j) {
+ for ( ; i != 10 ; i++ )
+ for ( ; ({if (i) break; i;}); j++) {} // expected-warning{{'break' is bound to current loop, GCC binds it to the enclosing loop}}
+}
+
+void pr8880_14(int i) {
+ for ( ; i != 10 ; i++ )
+ while(({if (i) break; i;})) {} // expected-warning {{'break' is bound to current loop, GCC binds it to the enclosing loop}}
+}
+
+void pr8880_15(int i) {
+ while (--i)
+ while(({if (i) continue; i;})) {} // expected-warning {{'continue' is bound to current loop, GCC binds it to the enclosing loop}}
+}
+
+void pr8880_16(int i) {
+ for ( ; i != 10 ; i++ )
+ do {} while(({if (i) break; i;})); // expected-warning {{'break' is bound to current loop, GCC binds it to the enclosing loop}}
+}
+
+void pr8880_17(int i) {
+ for ( ; i != 10 ; i++ )
+ do {} while(({if (i) continue; i;})); // expected-warning {{'continue' is bound to current loop, GCC binds it to the enclosing loop}}
+}
+
+void pr8880_18(int x, int y) {
+ while(x > 0)
+ switch(({if(y) break; y;})) {
+ case 2: x = 0;
+ }
+}
+
+void pr8880_19(int x, int y) {
+ switch(x) {
+ case 1:
+ switch(({if(y) break; y;})) {
+ case 2: x = 0;
+ }
+ }
+}
+
+void pr8880_20(int x, int y) {
+ switch(x) {
+ case 1:
+ while(({if (y) break; y;})) {} //expected-warning {{'break' is bound to loop, GCC binds it to switch}}
+ }
+}
+
+void pr8880_21(int x, int y) {
+ switch(x) {
+ case 1:
+ do {} while(({if (y) break; y;})); //expected-warning {{'break' is bound to loop, GCC binds it to switch}}
+ }
+}
+
+void pr8880_22(int x, int y) {
+ switch(x) {
+ case 1:
+ for ( ; ; (void)({ ++y; break; y;})) {} // expected-warning{{'break' is bound to loop, GCC binds it to switc}}
+ }
+}
+
+void pr8880_23(int x, int y) {
+ switch(x) {
+ case 1:
+ for ( ; ({ ++y; break; y;}); ++y) {} // expected-warning{{'break' is bound to loop, GCC binds it to switch}}
+ }
+}
diff --git a/test/Sema/ms-inline-asm.c b/test/Sema/ms-inline-asm.c
index 69f234e..deca650 100644
--- a/test/Sema/ms-inline-asm.c
+++ b/test/Sema/ms-inline-asm.c
@@ -1,4 +1,4 @@
-// REQUIRES: x86-64-registered-target
+// REQUIRES: x86-registered-target
// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fasm-blocks -Wno-microsoft -verify -fsyntax-only
void t1(void) {
@@ -32,3 +32,72 @@
mov eax, TYPE bar // expected-error {{unable to lookup expression}}
}
}
+
+void rdar15318432(void) {
+ // We used to crash on this. When LLVM called back to Clang to parse a name
+ // and do name lookup, if parsing failed, we did not restore the lexer state
+ // properly.
+
+ // expected-error@+2 {{expected identifier}}
+ __asm {
+ and ecx, ~15
+ }
+
+ int x = 0;
+ // expected-error@+3 {{expected identifier}}
+ __asm {
+ and ecx, x
+ and ecx, ~15
+ }
+}
+
+static int global;
+
+int t2(int *arr, int i) {
+ __asm {
+ mov eax, arr;
+ mov eax, arr[0];
+ mov eax, arr[1 + 2];
+ mov eax, arr[1 + (2 * 5) - 3 + 1<<1];
+ }
+
+ // expected-error@+1 {{cannot use base register with variable reference}}
+ __asm mov eax, arr[ebp + 1 + (2 * 5) - 3 + 1<<1]
+ // expected-error@+1 {{cannot use index register with variable reference}}
+ __asm mov eax, arr[esi * 4]
+ // expected-error@+1 {{cannot use more than one symbol in memory operand}}
+ __asm mov eax, arr[i]
+ // expected-error@+1 {{cannot use more than one symbol in memory operand}}
+ __asm mov eax, global[i]
+
+ // FIXME: Why don't we diagnose this?
+ // expected-Xerror@+1 {{cannot reference multiple local variables in assembly operand}}
+ //__asm mov eax, [arr + i];
+ return 0;
+}
+
+typedef struct {
+ int a;
+ int b;
+} A;
+
+void t3() {
+ __asm mov eax, [eax] UndeclaredId // expected-error {{unknown token in expression}}
+
+ // FIXME: Only emit one diagnostic here.
+ // expected-error@+2 {{unexpected type name 'A': expected expression}}
+ // expected-error@+1 {{unknown token in expression}}
+ __asm mov eax, [eax] A
+}
+
+void t4() {
+ // The dot in the "intel dot operator" is optional in MSVC. MSVC also does
+ // global field lookup, but we don't.
+ __asm mov eax, [0] A.a
+ __asm mov eax, [0].A.a
+ __asm mov eax, [0].a // expected-error {{Unable to lookup field reference!}}
+ __asm mov eax, fs:[0] A.a
+ __asm mov eax, fs:[0].A.a
+ __asm mov eax, fs:[0].a // expected-error {{Unable to lookup field reference!}}
+ __asm mov eax, fs:[0]. A.a // expected-error {{Unexpected token type!}}
+}
diff --git a/test/Sema/ms-wchar.c b/test/Sema/ms-wchar.c
index febaf28..ead3d97 100644
--- a/test/Sema/ms-wchar.c
+++ b/test/Sema/ms-wchar.c
@@ -12,7 +12,7 @@
unsigned short g; // expected-error {{redefinition of 'g' with a different type: 'unsigned short' vs '__wchar_t'}}
// The type of a wide string literal is actually not __wchar_t.
-__wchar_t s[] = L"Hello world!"; // expected-error-re {{array initializer must be an initializer list$}}
+__wchar_t s[] = L"Hello world!"; // expected-error-re {{array initializer must be an initializer list{{$}}}}
// Do not suggest initializing with a string here, because it would not work.
-__wchar_t t[] = 1; // expected-error-re {{array initializer must be an initializer list$}}
+__wchar_t t[] = 1; // expected-error-re {{array initializer must be an initializer list{{$}}}}
diff --git a/test/Sema/ms_bitfield_layout.c b/test/Sema/ms_bitfield_layout.c
index 4a2076c..f2010c1 100644
--- a/test/Sema/ms_bitfield_layout.c
+++ b/test/Sema/ms_bitfield_layout.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple i686-pc-win32 -cxx-abi microsoft -fdump-record-layouts %s 2>/dev/null \
+// RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple i686-pc-win32 -fdump-record-layouts %s 2>/dev/null \
// RUN: | FileCheck %s
-// RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple x86_64-pc-win32 -cxx-abi microsoft -fdump-record-layouts %s 2>/dev/null \
+// RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple x86_64-pc-win32 -fdump-record-layouts %s 2>/dev/null \
// RUN: | FileCheck %s
typedef struct A {
diff --git a/test/Sema/ms_class_layout.cpp b/test/Sema/ms_class_layout.cpp
index bb8052e..896d3ed 100644
--- a/test/Sema/ms_class_layout.cpp
+++ b/test/Sema/ms_class_layout.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm-only -triple i686-pc-win32 -fdump-record-layouts -cxx-abi microsoft %s 2>&1 \
+// RUN: %clang_cc1 -emit-llvm-only -triple i686-pc-win32 -fdump-record-layouts %s 2>/dev/null \
// RUN: | FileCheck %s
#pragma pack(push, 8)
@@ -289,7 +289,7 @@
// CHECK-NEXT: 8 | (D vftable pointer)
// CHECK-NEXT: 16 | double a
// CHECK-NEXT: sizeof=24, align=8
-// CHECK-NEXT: nvsize=8, nvalign=4
+// CHECK-NEXT: nvsize=8, nvalign=8
// CHECK: %struct.H = type { %struct.G, i32*, %class.D }
@@ -354,7 +354,7 @@
// CHECK-NEXT: | [sizeof=40, align=8
// CHECK-NEXT: | nvsize=24, nvalign=8]
-// CHECK: struct.O = type { i32 (...)**, [4 x i8], %struct.H.base, %struct.G, [4 x i8], %class.D }
+// CHECK: struct.O = type { i32 (...)**, [4 x i8], %struct.H.base, %struct.G, %class.D }
// CHECK: struct.O.base = type { i32 (...)**, [4 x i8], %struct.H.base, %struct.G, [4 x i8] }
@@ -428,10 +428,10 @@
// CHECK-NEXT: nvsize=12, nvalign=4
// CHECK: %struct.f = type { i32 (...)** }
-// CHECK: %struct.s = type { i32 (...)**, i32*, i32, [4 x i8], %struct.f }
+// CHECK: %struct.s = type { i32 (...)**, i32*, i32, i32, %struct.f }
// CHECK: %class.IA = type { i32 (...)** }
-// CHECK: %class.ICh = type { i32 (...)**, i32*, [4 x i8], %class.IA }
-// CHECK: %struct.sd = type { i32*, i32, i8, [7 x i8], %struct.f, %struct.s.base, [4 x i8], %class.IA, %class.ICh.base }
+// CHECK: %class.ICh = type { i32 (...)**, i32*, i32, %class.IA }
+// CHECK: %struct.sd = type { i32*, i32, i8, i32, %struct.f, %struct.s.base, i32, %class.IA, %class.ICh.base }
// CHECK: 0 | struct AV
// CHECK-NEXT: 0 | (AV vftable pointer)
@@ -457,7 +457,7 @@
// CHECK: %struct.AV = type { i32 (...)** }
// CHECK: %struct.BV = type { %struct.AV }
-// CHECK: %struct.CV = type { i32*, [4 x i8], %struct.BV }
+// CHECK: %struct.CV = type { i32*, i32, %struct.BV }
// CHECK: %struct.CV.base = type { i32* }
// CHECK: 0 | struct DV
@@ -470,12 +470,12 @@
// CHECK: %struct.DV = type { %struct.BV }
// CHECK: 0 | struct EV
-// CHECK-NEXT: 4 | struct CV (base)
-// CHECK-NEXT: 4 | (CV vbtable pointer)
// CHECK-NEXT: 0 | struct DV (primary base)
// CHECK-NEXT: 0 | struct BV (primary base)
// CHECK-NEXT: 0 | struct AV (primary base)
// CHECK-NEXT: 0 | (AV vftable pointer)
+// CHECK-NEXT: 4 | struct CV (base)
+// CHECK-NEXT: 4 | (CV vbtable pointer)
// CHECK-NEXT: 8 | (vtordisp for vbase BV)
// CHECK-NEXT: 12 | struct BV (virtual base)
// CHECK-NEXT: 12 | struct AV (primary base)
@@ -483,7 +483,7 @@
// CHECK-NEXT: sizeof=16, align=4
// CHECK-NEXT: nvsize=8, nvalign=4
-// CHECK: %struct.EV = type { %struct.DV, %struct.CV.base, [4 x i8], %struct.BV }
+// CHECK: %struct.EV = type { %struct.DV, %struct.CV.base, i32, %struct.BV }
// CHECK: %struct.EV.base = type { %struct.DV, %struct.CV.base }
// Overriding a method means that all the vbases containing that
diff --git a/test/Sema/neon-vector-types.c b/test/Sema/neon-vector-types.c
index d8dd412..03f669e 100644
--- a/test/Sema/neon-vector-types.c
+++ b/test/Sema/neon-vector-types.c
@@ -4,7 +4,7 @@
typedef float float32_t;
typedef signed char poly8_t;
typedef short poly16_t;
-typedef unsigned long long uint64_t;
+typedef unsigned __INT64_TYPE__ uint64_t;
// Define some valid Neon types.
typedef __attribute__((neon_vector_type(2))) int int32x2_t;
@@ -23,7 +23,6 @@
typedef __attribute__((neon_vector_type(2.0))) int non_int_width; // expected-error{{'neon_vector_type' attribute requires an integer constant}}
// Only certain element types are allowed.
-typedef __attribute__((neon_vector_type(2))) double double_elt; // expected-error{{invalid vector element type}}
typedef __attribute__((neon_vector_type(4))) void* ptr_elt; // expected-error{{invalid vector element type}}
typedef __attribute__((neon_polyvector_type(4))) float32_t bad_poly_elt; // expected-error{{invalid vector element type}}
struct aggr { signed char c; };
diff --git a/test/Sema/nonnull.c b/test/Sema/nonnull.c
index 4e61711..0e92654 100644
--- a/test/Sema/nonnull.c
+++ b/test/Sema/nonnull.c
@@ -20,3 +20,36 @@
}
void foo(const char *str) __attribute__((nonnull("foo"))); // expected-error{{'nonnull' attribute requires parameter 1 to be an integer constant}}
+void bar(int i) __attribute__((nonnull(1))); // expected-warning {{'nonnull' attribute only applies to pointer arguments}} expected-warning {{'nonnull' attribute applied to function with no pointer arguments}}
+
+void baz(__attribute__((nonnull)) const char *str);
+void baz2(__attribute__((nonnull(1))) const char *str); // expected-warning {{'nonnull' attribute when used on parameters takes no arguments}}
+void baz3(__attribute__((nonnull)) int x); // expected-warning {{'nonnull' attribute only applies to pointer arguments}}
+
+void test_baz() {
+ baz(0); // expected-warning {{null passed to a callee which requires a non-null argument}}
+ baz2(0); // no-warning
+ baz3(0); // no-warning
+}
+
+void test_void_returns_nonnull(void) __attribute__((returns_nonnull)); // expected-warning {{'returns_nonnull' attribute only applies to return values that are pointers}}
+int test_int_returns_nonnull(void) __attribute__((returns_nonnull)); // expected-warning {{'returns_nonnull' attribute only applies to return values that are pointers}}
+void *test_ptr_returns_nonnull(void) __attribute__((returns_nonnull)); // no-warning
+
+int i __attribute__((nonnull)); // expected-warning {{'nonnull' attribute only applies to functions, methods, and parameters}}
+int j __attribute__((returns_nonnull)); // expected-warning {{'returns_nonnull' attribute only applies to functions and methods}}
+void *test_no_fn_proto() __attribute__((returns_nonnull)); // expected-warning {{'returns_nonnull' attribute only applies to functions and methods}}
+
+__attribute__((returns_nonnull))
+void *test_bad_returns_null(void) {
+ return 0; // expected-warning {{null returned from function that requires a non-null return value}}
+}
+
+void PR18795(int (*g)(const char *h, ...) __attribute__((nonnull(1))) __attribute__((nonnull))) {
+ g(0); // expected-warning{{null passed to a callee which requires a non-null argument}}
+}
+void PR18795_helper() {
+ PR18795(0); // expected-warning{{null passed to a callee which requires a non-null argument}}
+}
+
+
diff --git a/test/Sema/overloadable.c b/test/Sema/overloadable.c
index b93c39f..bdd4714 100644
--- a/test/Sema/overloadable.c
+++ b/test/Sema/overloadable.c
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-int var __attribute__((overloadable)); // expected-error{{'overloadable' attribute can only be applied to a function}}
+int var __attribute__((overloadable)); // expected-error{{'overloadable' attribute only applies to functions}}
void params(void) __attribute__((overloadable(12))); // expected-error {{'overloadable' attribute takes no arguments}}
int *f(int) __attribute__((overloadable)); // expected-note 2{{previous overload of function is here}}
diff --git a/test/Sema/pragma-ms_struct.c b/test/Sema/pragma-ms_struct.c
index 6533320..e2c5ff1 100644
--- a/test/Sema/pragma-ms_struct.c
+++ b/test/Sema/pragma-ms_struct.c
@@ -25,7 +25,7 @@
} __attribute__((__ms_struct__)) t1;
struct S {
- double __attribute__((ms_struct)) d; // expected-warning {{'ms_struct' attribute ignored}}
+ double __attribute__((ms_struct)) d; // expected-warning {{'ms_struct' attribute only applies to struct or union}}
unsigned long bf_1 : 12;
unsigned long : 0;
unsigned long bf_2 : 12;
@@ -36,7 +36,7 @@
A = 0,
B,
C
-} __attribute__((ms_struct)) e1; // expected-warning {{'ms_struct' attribute ignored}}
+} __attribute__((ms_struct)) e1; // expected-warning {{'ms_struct' attribute only applies to struct or union}}
// rdar://10513599
#pragma ms_struct on
@@ -52,10 +52,12 @@
void *pv1;
Foo foo;
unsigned short fInited : 1;
-void *pv2;
-} PackOddity;
+void *pv2;
+} PackOddity;
#pragma ms_struct off
static int arr[sizeof(PackOddity) == 40 ? 1 : -1];
+struct __declspec(ms_struct) bad { // expected-warning {{__declspec attribute 'ms_struct' is not supported}}
+};
diff --git a/test/Sema/pragma-pack-apple.c b/test/Sema/pragma-pack-apple.c
index 5b33c03..426d984 100644
--- a/test/Sema/pragma-pack-apple.c
+++ b/test/Sema/pragma-pack-apple.c
@@ -1,5 +1,5 @@
-// RUN: %clang -fsyntax-only %s 2>&1 | FileCheck %s
-// RUN: %clang -fsyntax-only -fapple-pragma-pack %s 2>&1 | FileCheck -check-prefix=CHECK-APPLE %s
+// RUN: %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -fsyntax-only -fapple-pragma-pack %s 2>&1 | FileCheck -check-prefix=CHECK-APPLE %s
#pragma pack(push,1)
#pragma pack(2)
diff --git a/test/Sema/return.c b/test/Sema/return.c
index 7e7c8b7..2a58a6e 100644
--- a/test/Sema/return.c
+++ b/test/Sema/return.c
@@ -1,4 +1,4 @@
-// RUN: %clang %s -fsyntax-only -Wignored-qualifiers -Wno-error=return-type -Xclang -verify -fblocks -Wno-unreachable-code -Wno-unused-value
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -fsyntax-only -Wignored-qualifiers -Wno-error=return-type -verify -fblocks -Wno-unreachable-code -Wno-unused-value
// clang emits the following warning by default.
// With GCC, -pedantic, -Wreturn-type or -Wall are required to produce the
@@ -275,3 +275,44 @@
return 5;
}
}
+
+// PR18999
+int test35() {
+lbl:
+ if (1)
+ goto lbl;
+}
+
+// PR19074.
+void abort(void) __attribute__((noreturn));
+#define av_assert0(cond) do {\
+ if (!(cond)) {\
+ abort();\
+ }\
+ } while (0)
+
+int PR19074(int x) {
+ switch(x) {
+ case 0:
+ return 0;
+ default:
+ av_assert0(0);
+ } // no-warning
+}
+
+int PR19074_positive(int x) {
+ switch(x) {
+ case 0:
+ return 0;
+ default:
+ break;
+ }
+} // expected-warning {{control may reach end of non-void function}}
+
+// sizeof(long) test.
+int sizeof_long() {
+ if (sizeof(long) == 4)
+ return 1;
+ if (sizeof(long) == 8)
+ return 2;
+} // no-warning
diff --git a/test/Sema/sentinel-attribute.c b/test/Sema/sentinel-attribute.c
index e5cbf6e..46f1350 100644
--- a/test/Sema/sentinel-attribute.c
+++ b/test/Sema/sentinel-attribute.c
@@ -5,7 +5,7 @@
void f2(int a, ...) __attribute__ ((sentinel(1)));
void f3(int a, ...) __attribute__ ((sentinel("hello"))); //expected-error{{'sentinel' attribute requires parameter 1 to be an integer constant}}
-void f4(int a, ...) __attribute__ ((sentinel(1, 2, 3))); //expected-error{{attribute takes no more than 2 arguments}}
+void f4(int a, ...) __attribute__ ((sentinel(1, 2, 3))); //expected-error{{'sentinel' attribute takes no more than 2 arguments}}
void f4(int a, ...) __attribute__ ((sentinel(-1))); //expected-error{{parameter 1 less than zero}}
void f4(int a, ...) __attribute__ ((sentinel(0, 2))); // expected-error{{parameter 2 not 0 or 1}}
diff --git a/test/Sema/shift.c b/test/Sema/shift.c
index 142d83c..d355544 100644
--- a/test/Sema/shift.c
+++ b/test/Sema/shift.c
@@ -1,4 +1,4 @@
-// RUN: %clang -Wall -Wshift-sign-overflow -ffreestanding -fsyntax-only -Xclang -verify %s
+// RUN: %clang_cc1 -Wall -Wshift-sign-overflow -ffreestanding -fsyntax-only -verify %s
#include <limits.h>
diff --git a/test/Sema/statements.c b/test/Sema/statements.c
index f01ee40..057492a 100644
--- a/test/Sema/statements.c
+++ b/test/Sema/statements.c
@@ -90,9 +90,6 @@
}
}
-// PR 8880
-// FIXME: Clang should reject this, since GCC does. Previously this
-// was causing a crash in the CFG builder.
int test_pr8880() {
int first = 1;
for ( ; ({ if (first) { first = 0; continue; } 0; }); )
diff --git a/test/Sema/static-init.c b/test/Sema/static-init.c
index bbf9038..a2ed551 100644
--- a/test/Sema/static-init.c
+++ b/test/Sema/static-init.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-bool-conversion %s
typedef __typeof((int*) 0 - (int*) 0) intptr_t;
diff --git a/test/Sema/switch.c b/test/Sema/switch.c
index e37d5da..092378d 100644
--- a/test/Sema/switch.c
+++ b/test/Sema/switch.c
@@ -109,14 +109,14 @@
switch(a) {
case A:
case B:
- case 3: // expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ case 3: // expected-warning{{case value not in enumerated type 'enum (anonymous enum}}
break;
}
switch(a) {
case A:
case B:
- case 3 ... //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
- 4: //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ case 3 ... //expected-warning{{case value not in enumerated type 'enum (anonymous enum}}
+ 4: //expected-warning{{case value not in enumerated type 'enum (anonymous enum}}
break;
}
switch(a) {
@@ -124,16 +124,16 @@
break;
}
switch(a) {
- case 0 ... 2: //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ case 0 ... 2: //expected-warning{{case value not in enumerated type 'enum (anonymous enum}}
break;
}
switch(a) {
- case 1 ... 3: //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ case 1 ... 3: //expected-warning{{case value not in enumerated type 'enum (anonymous enum}}
break;
}
switch(a) {
- case 0 ... //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
- 3: //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ case 0 ... //expected-warning{{case value not in enumerated type 'enum (anonymous enum}}
+ 3: //expected-warning{{case value not in enumerated type 'enum (anonymous enum}}
break;
}
@@ -167,11 +167,11 @@
C = 1
} a;
switch(a) {
- case 0: //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ case 0: //expected-warning{{case value not in enumerated type 'enum (anonymous enum}}
case 1:
- case 2: //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ case 2: //expected-warning{{case value not in enumerated type 'enum (anonymous enum}}
case 3:
- case 4: //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ case 4: //expected-warning{{case value not in enumerated type 'enum (anonymous enum}}
break;
}
}
@@ -184,14 +184,14 @@
D = 12
} a;
switch(a) {
- case 0 ... //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
- 1: //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ case 0 ... //expected-warning{{case value not in enumerated type 'enum (anonymous enum}}
+ 1: //expected-warning{{case value not in enumerated type 'enum (anonymous enum}}
case 2 ... 4:
- case 5 ... //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
- 9: //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ case 5 ... //expected-warning{{case value not in enumerated type 'enum (anonymous enum}}
+ 9: //expected-warning{{case value not in enumerated type 'enum (anonymous enum}}
case 10 ... 12:
- case 13 ... //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
- 16: //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ case 13 ... //expected-warning{{case value not in enumerated type 'enum (anonymous enum}}
+ 16: //expected-warning{{case value not in enumerated type 'enum (anonymous enum}}
break;
}
}
@@ -349,3 +349,29 @@
break;
}
}
+
+// Allow the warning 'case value not in enumerated type' to be silenced with
+// the following pattern.
+//
+// If 'case' expression refers to a static const variable of the correct enum
+// type, then we count this as a sufficient declaration of intent by the user,
+// so we silence the warning.
+enum ExtendedEnum1 {
+ EE1_a,
+ EE1_b
+};
+
+enum ExtendedEnum1_unrelated { EE1_misc };
+
+static const enum ExtendedEnum1 EE1_c = 100;
+static const enum ExtendedEnum1_unrelated EE1_d = 101;
+
+void switch_on_ExtendedEnum1(enum ExtendedEnum1 e) {
+ switch(e) {
+ case EE1_a: break;
+ case EE1_b: break;
+ case EE1_c: break; // no-warning
+ case EE1_d: break; // expected-warning {{case value not in enumerated type 'enum ExtendedEnum1'}}
+ }
+}
+
diff --git a/test/Sema/thread-specifier.c b/test/Sema/thread-specifier.c
index bf1ce9e..39243d1 100644
--- a/test/Sema/thread-specifier.c
+++ b/test/Sema/thread-specifier.c
@@ -21,7 +21,7 @@
__thread __private_extern__ int t4;
struct t5 { __thread int x; };
#ifdef __cplusplus
-// expected-error-re@-2 {{'(__thread|_Thread_local|thread_local)' is only allowed on variable declarations}}
+// expected-error-re@-2 {{'{{__thread|_Thread_local|thread_local}}' is only allowed on variable declarations}}
#else
// FIXME: The 'is only allowed on variable declarations' diagnostic is better here.
// expected-error@-5 {{type name does not allow storage class to be specified}}
@@ -47,17 +47,17 @@
static __thread int t10;
__thread __private_extern__ int t11;
#if __cplusplus < 201103L
- __thread auto int t12a; // expected-error-re {{cannot combine with previous '(__thread|_Thread_local)' declaration specifier}}
+ __thread auto int t12a; // expected-error-re {{cannot combine with previous '{{__thread|_Thread_local}}' declaration specifier}}
auto __thread int t12b; // expected-error {{cannot combine with previous 'auto' declaration specifier}}
#elif !defined(CXX11)
- __thread auto t12a = 0; // expected-error-re {{'_Thread_local' variables must have global storage}}
- auto __thread t12b = 0; // expected-error-re {{'_Thread_local' variables must have global storage}}
+ __thread auto t12a = 0; // expected-error {{'_Thread_local' variables must have global storage}}
+ auto __thread t12b = 0; // expected-error {{'_Thread_local' variables must have global storage}}
#endif
- __thread register int t13a; // expected-error-re {{cannot combine with previous '(__thread|_Thread_local|thread_local)' declaration specifier}}
+ __thread register int t13a; // expected-error-re {{cannot combine with previous '{{__thread|_Thread_local|thread_local}}' declaration specifier}}
register __thread int t13b; // expected-error {{cannot combine with previous 'register' declaration specifier}}
}
-__thread typedef int t14; // expected-error-re {{cannot combine with previous '(__thread|_Thread_local|thread_local)' declaration specifier}}
+__thread typedef int t14; // expected-error-re {{cannot combine with previous '{{__thread|_Thread_local|thread_local}}' declaration specifier}}
__thread int t15; // expected-note {{previous declaration is here}}
extern int t15; // expected-error {{non-thread-local declaration of 't15' follows thread-local declaration}}
extern int t16; // expected-note {{previous declaration is here}}
diff --git a/test/Sema/transparent-union.c b/test/Sema/transparent-union.c
index ab1ba18..eff7df6 100644
--- a/test/Sema/transparent-union.c
+++ b/test/Sema/transparent-union.c
@@ -1,4 +1,4 @@
-// RUN: %clang -fsyntax-only -Xclang -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
typedef union {
int *ip;
float *fp;
@@ -70,4 +70,22 @@
int4 vec; // expected-warning{{first field of a transparent union cannot have vector type 'int4'; transparent_union attribute ignored}}
} TU5 __attribute__((transparent_union));
-
+union pr15134 {
+ unsigned int u;
+ struct {
+ unsigned int expo:2;
+ unsigned int mant:30;
+ } __attribute__((packed));
+ // The packed attribute is acceptable because it defines a less strict
+ // alignment than required by the first field of the transparent union.
+} __attribute__((transparent_union));
+
+union pr15134v2 {
+ struct { // expected-note {{alignment of first field is 32 bits}}
+ unsigned int u1;
+ unsigned int u2;
+ };
+ struct { // expected-warning {{alignment of field '' (64 bits) does not match the alignment of the first field in transparent union; transparent_union attribute ignored}}
+ unsigned int u3;
+ } __attribute__((aligned(8)));
+} __attribute__((transparent_union));
diff --git a/test/Sema/typeof-use-deprecated.c b/test/Sema/typeof-use-deprecated.c
index 1518c83..ba72b12 100644
--- a/test/Sema/typeof-use-deprecated.c
+++ b/test/Sema/typeof-use-deprecated.c
@@ -1,25 +1,25 @@
// RUN: %clang_cc1 %s -verify -fsyntax-only
-struct s { int a; } __attribute__((deprecated)) x; // expected-warning {{'s' is deprecated}} expected-note 2 {{'s' declared here}}
+struct s { int a; } __attribute__((deprecated)) x; // expected-warning {{'s' is deprecated}} expected-note 2 {{'s' has been explicitly marked deprecated here}}
typeof(x) y; // expected-warning {{'s' is deprecated}}
-union un{ int a; } __attribute__((deprecated)) u; // expected-warning {{'un' is deprecated}} expected-note 2 {{'un' declared here}}
+union un{ int a; } __attribute__((deprecated)) u; // expected-warning {{'un' is deprecated}} expected-note 2 {{'un' has been explicitly marked deprecated here}}
typeof( u) z; // expected-warning {{'un' is deprecated}}
-enum E{ one} __attribute__((deprecated)) e; // expected-warning {{'E' is deprecated}} expected-note 2 {{'E' declared here}}
+enum E{ one} __attribute__((deprecated)) e; // expected-warning {{'E' is deprecated}} expected-note 2 {{'E' has been explicitly marked deprecated here}}
typeof( e) w; // expected-warning {{'E' is deprecated}}
-struct foo { int x; } __attribute__((deprecated)); // expected-note {{'foo' declared here}}
-typedef struct foo bar __attribute__((deprecated)); // expected-note {{'bar' declared here}}
+struct foo { int x; } __attribute__((deprecated)); // expected-note {{'foo' has been explicitly marked deprecated here}}
+typedef struct foo bar __attribute__((deprecated)); // expected-note {{'bar' has been explicitly marked deprecated here}}
bar x1; // expected-warning {{'bar' is deprecated}}
int main() { typeof(x1) y; } // expected-warning {{'foo' is deprecated}}
struct gorf { int x; };
-typedef struct gorf T __attribute__((deprecated)); // expected-note {{'T' declared here}}
+typedef struct gorf T __attribute__((deprecated)); // expected-note {{'T' has been explicitly marked deprecated here}}
T t; // expected-warning {{'T' is deprecated}}
void wee() { typeof(t) y; }
diff --git a/test/Sema/types.c b/test/Sema/types.c
index dac0bfe..339788e 100644
--- a/test/Sema/types.c
+++ b/test/Sema/types.c
@@ -53,7 +53,7 @@
int __attribute__ ((vector_size (8), vector_size (8))) v; // expected-error {{invalid vector element type}}
void test(int i) {
- char c = (char __attribute__((align(8)))) i; // expected-warning {{'align' attribute ignored when parsing type}}
+ char c = (char __attribute__((aligned(8)))) i; // expected-warning {{'aligned' attribute ignored when parsing type}}
}
// http://llvm.org/PR11082
@@ -72,3 +72,4 @@
// no support for vector enum type
enum { e_2 } x3 __attribute__((vector_size(64))); // expected-error {{invalid vector element type}}
+int x4 __attribute__((ext_vector_type(64))); // expected-error {{'ext_vector_type' attribute only applies to types}}
diff --git a/test/Sema/unused-expr.c b/test/Sema/unused-expr.c
index ea08631..43d8150 100644
--- a/test/Sema/unused-expr.c
+++ b/test/Sema/unused-expr.c
@@ -7,11 +7,11 @@
void bar(volatile int *VP, int *P, int A,
_Complex double C, volatile _Complex double VC) {
- VP < P; // expected-warning {{expression result unused}}
+ VP < P; // expected-warning {{relational comparison result unused}}
(void)A;
(void)foo(1,2); // no warning.
- A < foo(1, 2); // expected-warning {{expression result unused}}
+ A < foo(1, 2); // expected-warning {{relational comparison result unused}}
foo(1,2)+foo(4,3); // expected-warning {{expression result unused}}
@@ -54,23 +54,23 @@
int b = 0;
if (a)
- b < 1; // expected-warning{{expression result unused}}
+ b < 1; // expected-warning{{relational comparison result unused}}
else
- b < 2; // expected-warning{{expression result unused}}
+ b < 2; // expected-warning{{relational comparison result unused}}
while (1)
- b < 3; // expected-warning{{expression result unused}}
+ b < 3; // expected-warning{{relational comparison result unused}}
do
- b < 4; // expected-warning{{expression result unused}}
+ b < 4; // expected-warning{{relational comparison result unused}}
while (1);
for (;;)
- b < 5; // expected-warning{{expression result unused}}
+ b < 5; // expected-warning{{relational comparison result unused}}
- for (b < 1;;) {} // expected-warning{{expression result unused}}
+ for (b < 1;;) {} // expected-warning{{relational comparison result unused}}
for (;b < 1;) {}
- for (;;b < 1) {} // expected-warning{{expression result unused}}
+ for (;;b < 1) {} // expected-warning{{relational comparison result unused}}
}
// rdar://7186119
@@ -91,7 +91,7 @@
fn1(); // expected-warning {{ignoring return value of function declared with warn_unused_result attribute}}
fn2(92, 21); // expected-warning {{ignoring return value of function declared with pure attribute}}
fn3(42); // expected-warning {{ignoring return value of function declared with const attribute}}
- __builtin_fabsf(0); // expected-warning {{ignoring return value of function declared with const attribute}}
+ __builtin_abs(0); // expected-warning {{ignoring return value of function declared with const attribute}}
(void)0, fn1(); // expected-warning {{ignoring return value of function declared with warn_unused_result attribute}}
return 0;
}
diff --git a/test/Sema/variadic-promotion.c b/test/Sema/variadic-promotion.c
index b248774..01d8e93 100644
--- a/test/Sema/variadic-promotion.c
+++ b/test/Sema/variadic-promotion.c
@@ -6,7 +6,7 @@
variadic(3, *f16, f32, f64);
// CHECK: ImplicitCastExpr {{.*}} 'double' <FloatingCast>
-// CHECK-NEXT: 'half'
+// CHECK-NEXT: '__fp16'
// CHECK: ImplicitCastExpr {{.*}} 'double' <FloatingCast>
// CHECK-NEXT: 'float'
diff --git a/test/Sema/vector-cast.c b/test/Sema/vector-cast.c
index 7fa6e86..bfc731e 100644
--- a/test/Sema/vector-cast.c
+++ b/test/Sema/vector-cast.c
@@ -36,3 +36,21 @@
f2(Y); // expected-warning {{incompatible vector types passing 't3' to parameter of type 't2'}}
}
+typedef float float2 __attribute__ ((vector_size (8)));
+
+void f4() {
+ float2 f2;
+ double d;
+ f2 += d;
+ d += f2;
+}
+
+// rdar://15931426
+// Don't permit a lax conversion to and from a pointer type.
+typedef short short_sizeof_pointer __attribute__((vector_size(sizeof(void*))));
+void f5() {
+ short_sizeof_pointer v;
+ void *ptr;
+ v = ptr; // expected-error {{assigning to 'short_sizeof_pointer' from incompatible type 'void *'}}
+ ptr = v; // expected-error {{assigning to 'void *' from incompatible type 'short_sizeof_pointer'}}
+}
diff --git a/test/Sema/vla.c b/test/Sema/vla.c
index 4fd6361..e03dda8 100644
--- a/test/Sema/vla.c
+++ b/test/Sema/vla.c
@@ -19,7 +19,7 @@
// PR2352
void f2(unsigned int m)
{
- extern int e1[2][m]; // expected-error {{variable length array declaration can not have 'extern' linkage}}
+ extern int e1[2][m]; // expected-error {{variable length array declaration cannot have 'extern' linkage}}
e1[0][0] = 0;
@@ -34,10 +34,10 @@
void f3()
{
- static int a[i]; // expected-error {{variable length array declaration can not have 'static' storage duration}}
- extern int b[i]; // expected-error {{variable length array declaration can not have 'extern' linkage}}
+ static int a[i]; // expected-error {{variable length array declaration cannot have 'static' storage duration}}
+ extern int b[i]; // expected-error {{variable length array declaration cannot have 'extern' linkage}}
- extern int (*c1)[i]; // expected-error {{variably modified type declaration can not have 'extern' linkage}}
+ extern int (*c1)[i]; // expected-error {{variably modified type declaration cannot have 'extern' linkage}}
static int (*d)[i];
}
diff --git a/test/Sema/warn-absolute-value-header.c b/test/Sema/warn-absolute-value-header.c
new file mode 100644
index 0000000..e3bf9ee
--- /dev/null
+++ b/test/Sema/warn-absolute-value-header.c
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -verify %s -Wabsolute-value
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only %s -Wabsolute-value -fdiagnostics-parseable-fixits 2>&1 | FileCheck %s
+
+int abs(int);
+
+// Wrong signature
+int fabsf(int);
+// expected-warning@-1{{incompatible redeclaration of library function 'fabsf'}}
+// expected-note@-2{{'fabsf' is a builtin with type 'float (float)'}}
+
+void test_int(int i, unsigned u, long long ll, float f, double d) {
+ (void)abs(i);
+
+ // Remove abs call
+ (void)abs(u);
+ // expected-warning@-1{{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note@-2{{remove the call to 'abs' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:""
+
+ int llabs;
+ (void)llabs;
+ // Conflict in names, no notes
+ (void)abs(ll);
+ // expected-warning@-1{{absolute value function 'abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value}}
+
+ // Conflict in names, no notes
+ (void)abs(f);
+ // expected-warning@-1{{using integer absolute value function 'abs' when argument is of floating point type}}
+
+ // Suggest header.
+ (void)abs(d);
+ // expected-warning@-1{{using integer absolute value function 'abs' when argument is of floating point type}}
+ // expected-note@-2{{use function 'fabs' instead}}
+ // expected-note@-3{{please include the header <math.h> or explicitly provide a declaration for 'fabs'}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:9-[[@LINE-4]]:12}:"fabs"
+}
diff --git a/test/Sema/warn-absolute-value.c b/test/Sema/warn-absolute-value.c
new file mode 100644
index 0000000..70601db
--- /dev/null
+++ b/test/Sema/warn-absolute-value.c
@@ -0,0 +1,782 @@
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -verify %s -Wabsolute-value
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only %s -Wabsolute-value -fdiagnostics-parseable-fixits 2>&1 | FileCheck %s
+
+int abs(int);
+long int labs(long int);
+long long int llabs(long long int);
+
+float fabsf(float);
+double fabs(double);
+long double fabsl(long double);
+
+float cabsf(float _Complex);
+double cabs(double _Complex);
+long double cabsl(long double _Complex);
+
+void test_int(int x) {
+ (void)abs(x);
+ (void)labs(x);
+ (void)llabs(x);
+
+ (void)fabsf(x);
+ // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of integer type}}
+ // expected-note@-2 {{use function 'abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"abs"
+ (void)fabs(x);
+ // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of integer type}}
+ // expected-note@-2 {{use function 'abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"abs"
+ (void)fabsl(x);
+ // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of integer type}}
+ // expected-note@-2 {{use function 'abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"abs"
+
+ (void)cabsf(x);
+ // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of integer type}}
+ // expected-note@-2 {{use function 'abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"abs"
+ (void)cabs(x);
+ // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of integer type}}
+ // expected-note@-2 {{use function 'abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"abs"
+ (void)cabsl(x);
+ // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of integer type}}
+ // expected-note@-2 {{use function 'abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"abs"
+
+ (void)__builtin_abs(x);
+ (void)__builtin_labs(x);
+ (void)__builtin_llabs(x);
+
+ (void)__builtin_fabsf(x);
+ // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of integer type}}
+ // expected-note@-2 {{use function '__builtin_abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_abs"
+ (void)__builtin_fabs(x);
+ // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of integer type}}
+ // expected-note@-2 {{use function '__builtin_abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_abs"
+ (void)__builtin_fabsl(x);
+ // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of integer type}}
+ // expected-note@-2 {{use function '__builtin_abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_abs"
+
+ (void)__builtin_cabsf(x);
+ // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of integer type}}
+ // expected-note@-2 {{use function '__builtin_abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_abs"
+ (void)__builtin_cabs(x);
+ // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of integer type}}
+ // expected-note@-2 {{use function '__builtin_abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_abs"
+ (void)__builtin_cabsl(x);
+ // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of integer type}}
+ // expected-note@-2 {{use function '__builtin_abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_abs"
+}
+
+void test_long(long x) {
+ (void)abs(x); // no warning - int and long are same length for this target
+ (void)labs(x);
+ (void)llabs(x);
+
+ (void)fabsf(x);
+ // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of integer type}}
+ // expected-note@-2 {{use function 'labs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"labs"
+ (void)fabs(x);
+ // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of integer type}}
+ // expected-note@-2 {{use function 'labs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"labs"
+ (void)fabsl(x);
+ // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of integer type}}
+ // expected-note@-2 {{use function 'labs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"labs"
+
+ (void)cabsf(x);
+ // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of integer type}}
+ // expected-note@-2 {{use function 'labs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"labs"
+ (void)cabs(x);
+ // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of integer type}}
+ // expected-note@-2 {{use function 'labs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"labs"
+ (void)cabsl(x);
+ // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of integer type}}
+ // expected-note@-2 {{use function 'labs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"labs"
+
+ (void)__builtin_abs(x); // no warning - int and long are same length for
+ // this target
+ (void)__builtin_labs(x);
+ (void)__builtin_llabs(x);
+
+ (void)__builtin_fabsf(x);
+ // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of integer type}}
+ // expected-note@-2 {{use function '__builtin_labs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_labs"
+ (void)__builtin_fabs(x);
+ // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of integer type}}
+ // expected-note@-2 {{use function '__builtin_labs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_labs"
+ (void)__builtin_fabsl(x);
+ // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of integer type}}
+ // expected-note@-2 {{use function '__builtin_labs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_labs"
+
+ (void)__builtin_cabsf(x);
+ // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of integer type}}
+ // expected-note@-2 {{use function '__builtin_labs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_labs"
+ (void)__builtin_cabs(x);
+ // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of integer type}}
+ // expected-note@-2 {{use function '__builtin_labs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_labs"
+ (void)__builtin_cabsl(x);
+ // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of integer type}}
+ // expected-note@-2 {{use function '__builtin_labs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_labs"
+}
+
+void test_long_long(long long x) {
+ (void)abs(x);
+ // expected-warning@-1{{absolute value function 'abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value}}
+ // expected-note@-2{{use function 'llabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"llabs"
+ (void)labs(x);
+ // expected-warning@-1{{absolute value function 'labs' given an argument of type 'long long' but has parameter of type 'long' which may cause truncation of value}}
+ // expected-note@-2{{use function 'llabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"llabs"
+ (void)llabs(x);
+
+ (void)fabsf(x);
+ // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of integer type}}
+ // expected-note@-2 {{use function 'llabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"llabs"
+ (void)fabs(x);
+ // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of integer type}}
+ // expected-note@-2 {{use function 'llabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"llabs"
+ (void)fabsl(x);
+ // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of integer type}}
+ // expected-note@-2 {{use function 'llabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"llabs"
+
+ (void)cabsf(x);
+ // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of integer type}}
+ // expected-note@-2 {{use function 'llabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"llabs"
+ (void)cabs(x);
+ // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of integer type}}
+ // expected-note@-2 {{use function 'llabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"llabs"
+ (void)cabsl(x);
+ // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of integer type}}
+ // expected-note@-2 {{use function 'llabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"llabs"
+
+ (void)__builtin_abs(x);
+ // expected-warning@-1{{absolute value function '__builtin_abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value}}
+ // expected-note@-2{{use function '__builtin_llabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_llabs"
+ (void)__builtin_labs(x);
+ // expected-warning@-1{{absolute value function '__builtin_labs' given an argument of type 'long long' but has parameter of type 'long' which may cause truncation of value}}
+ // expected-note@-2{{use function '__builtin_llabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_llabs"
+ (void)__builtin_llabs(x);
+
+ (void)__builtin_fabsf(x);
+ // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of integer type}}
+ // expected-note@-2 {{use function '__builtin_llabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_llabs"
+ (void)__builtin_fabs(x);
+ // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of integer type}}
+ // expected-note@-2 {{use function '__builtin_llabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_llabs"
+ (void)__builtin_fabsl(x);
+ // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of integer type}}
+ // expected-note@-2 {{use function '__builtin_llabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_llabs"
+
+ (void)__builtin_cabsf(x);
+ // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of integer type}}
+ // expected-note@-2 {{use function '__builtin_llabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_llabs"
+ (void)__builtin_cabs(x);
+ // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of integer type}}
+ // expected-note@-2 {{use function '__builtin_llabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_llabs"
+ (void)__builtin_cabsl(x);
+ // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of integer type}}
+ // expected-note@-2 {{use function '__builtin_llabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_llabs"
+}
+
+void test_float(float x) {
+ (void)abs(x);
+ // expected-warning@-1 {{using integer absolute value function 'abs' when argument is of floating point type}}
+ // expected-note@-2 {{use function 'fabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"fabsf"
+ (void)labs(x);
+ // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of floating point type}}
+ // expected-note@-2 {{use function 'fabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"fabsf"
+ (void)llabs(x);
+ // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of floating point type}}
+ // expected-note@-2 {{use function 'fabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabsf"
+
+ (void)fabsf(x);
+ (void)fabs(x);
+ (void)fabsl(x);
+
+ (void)cabsf(x);
+ // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of floating point type}}
+ // expected-note@-2 {{use function 'fabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabsf"
+ (void)cabs(x);
+ // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of floating point type}}
+ // expected-note@-2 {{use function 'fabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"fabsf"
+ (void)cabsl(x);
+ // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of floating point type}}
+ // expected-note@-2 {{use function 'fabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabsf"
+
+ (void)__builtin_abs(x);
+ // expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of floating point type}}
+ // expected-note@-2 {{use function '__builtin_fabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_fabsf"
+ (void)__builtin_labs(x);
+ // expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of floating point type}}
+ // expected-note@-2 {{use function '__builtin_fabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_fabsf"
+ (void)__builtin_llabs(x);
+ // expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of floating point type}}
+ // expected-note@-2 {{use function '__builtin_fabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabsf"
+
+ (void)__builtin_fabsf(x);
+ (void)__builtin_fabs(x);
+ (void)__builtin_fabsl(x);
+
+ (void)__builtin_cabsf(x);
+ // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of floating point type}}
+ // expected-note@-2 {{use function '__builtin_fabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabsf"
+ (void)__builtin_cabs(x);
+ // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of floating point type}}
+ // expected-note@-2 {{use function '__builtin_fabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_fabsf"
+ (void)__builtin_cabsl(x);
+ // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of floating point type}}
+ // expected-note@-2 {{use function '__builtin_fabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabsf"
+}
+
+void test_double(double x) {
+ (void)abs(x);
+ // expected-warning@-1 {{using integer absolute value function 'abs' when argument is of floating point type}}
+ // expected-note@-2 {{use function 'fabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"fabs"
+ (void)labs(x);
+ // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of floating point type}}
+ // expected-note@-2 {{use function 'fabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"fabs"
+ (void)llabs(x);
+ // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of floating point type}}
+ // expected-note@-2 {{use function 'fabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabs"
+
+ (void)fabsf(x);
+ // expected-warning@-1{{absolute value function 'fabsf' given an argument of type 'double' but has parameter of type 'float' which may cause truncation of value}}
+ // expected-note@-2{{use function 'fabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabs"
+ (void)fabs(x);
+ (void)fabsl(x);
+
+ (void)cabsf(x);
+ // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of floating point type}}
+ // expected-note@-2 {{use function 'fabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabs"
+ (void)cabs(x);
+ // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of floating point type}}
+ // expected-note@-2 {{use function 'fabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"fabs"
+ (void)cabsl(x);
+ // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of floating point type}}
+ // expected-note@-2 {{use function 'fabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabs"
+
+ (void)__builtin_abs(x);
+ // expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of floating point type}}
+ // expected-note@-2 {{use function '__builtin_fabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_fabs"
+ (void)__builtin_labs(x);
+ // expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of floating point type}}
+ // expected-note@-2 {{use function '__builtin_fabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_fabs"
+ (void)__builtin_llabs(x);
+ // expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of floating point type}}
+ // expected-note@-2 {{use function '__builtin_fabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabs"
+
+ (void)__builtin_fabsf(x);
+ // expected-warning@-1{{absolute value function '__builtin_fabsf' given an argument of type 'double' but has parameter of type 'float' which may cause truncation of value}}
+ // expected-note@-2{{use function '__builtin_fabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabs"
+ (void)__builtin_fabs(x);
+ (void)__builtin_fabsl(x);
+
+ (void)__builtin_cabsf(x);
+ // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of floating point type}}
+ // expected-note@-2 {{use function '__builtin_fabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabs"
+ (void)__builtin_cabs(x);
+ // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of floating point type}}
+ // expected-note@-2 {{use function '__builtin_fabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_fabs"
+ (void)__builtin_cabsl(x);
+ // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of floating point type}}
+ // expected-note@-2 {{use function '__builtin_fabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabs"
+}
+
+void test_long_double(long double x) {
+ (void)abs(x);
+ // expected-warning@-1 {{using integer absolute value function 'abs' when argument is of floating point type}}
+ // expected-note@-2 {{use function 'fabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"fabsl"
+ (void)labs(x);
+ // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of floating point type}}
+ // expected-note@-2 {{use function 'fabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"fabsl"
+ (void)llabs(x);
+ // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of floating point type}}
+ // expected-note@-2 {{use function 'fabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabsl"
+
+ (void)fabsf(x);
+ // expected-warning@-1{{absolute value function 'fabsf' given an argument of type 'long double' but has parameter of type 'float' which may cause truncation of value}}
+ // expected-note@-2{{use function 'fabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabsl"
+ (void)fabs(x);
+ // expected-warning@-1{{absolute value function 'fabs' given an argument of type 'long double' but has parameter of type 'double' which may cause truncation of value}}
+ // expected-note@-2{{use function 'fabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"fabsl"
+ (void)fabsl(x);
+
+ (void)cabsf(x);
+ // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of floating point type}}
+ // expected-note@-2 {{use function 'fabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabsl"
+ (void)cabs(x);
+ // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of floating point type}}
+ // expected-note@-2 {{use function 'fabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"fabsl"
+ (void)cabsl(x);
+ // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of floating point type}}
+ // expected-note@-2 {{use function 'fabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabsl"
+
+ (void)__builtin_abs(x);
+ // expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of floating point type}}
+ // expected-note@-2 {{use function '__builtin_fabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_fabsl"
+ (void)__builtin_labs(x);
+ // expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of floating point type}}
+ // expected-note@-2 {{use function '__builtin_fabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_fabsl"
+ (void)__builtin_llabs(x);
+ // expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of floating point type}}
+ // expected-note@-2 {{use function '__builtin_fabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabsl"
+
+ (void)__builtin_fabsf(x);
+ // expected-warning@-1{{absolute value function '__builtin_fabsf' given an argument of type 'long double' but has parameter of type 'float' which may cause truncation of value}}
+ // expected-note@-2{{use function '__builtin_fabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabsl"
+ (void)__builtin_fabs(x);
+ // expected-warning@-1{{absolute value function '__builtin_fabs' given an argument of type 'long double' but has parameter of type 'double' which may cause truncation of value}}
+ // expected-note@-2{{use function '__builtin_fabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_fabsl"
+ (void)__builtin_fabsl(x);
+
+ (void)__builtin_cabsf(x);
+ // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of floating point type}}
+ // expected-note@-2 {{use function '__builtin_fabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabsl"
+ (void)__builtin_cabs(x);
+ // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of floating point type}}
+ // expected-note@-2 {{use function '__builtin_fabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_fabsl"
+ (void)__builtin_cabsl(x);
+ // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of floating point type}}
+ // expected-note@-2 {{use function '__builtin_fabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabsl"
+}
+
+void test_complex_float(_Complex float x) {
+ (void)abs(x);
+ // expected-warning@-1 {{using integer absolute value function 'abs' when argument is of complex type}}
+ // expected-note@-2 {{use function 'cabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"cabsf"
+ (void)labs(x);
+ // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of complex type}}
+ // expected-note@-2 {{use function 'cabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsf"
+ (void)llabs(x);
+ // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of complex type}}
+ // expected-note@-2 {{use function 'cabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsf"
+
+ (void)fabsf(x);
+ // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of complex type}}
+ // expected-note@-2 {{use function 'cabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsf"
+ (void)fabs(x);
+ // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of complex type}}
+ // expected-note@-2 {{use function 'cabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsf"
+ (void)fabsl(x);
+ // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of complex type}}
+ // expected-note@-2 {{use function 'cabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsf"
+
+ (void)cabsf(x);
+ (void)cabs(x);
+ (void)cabsl(x);
+
+ (void)__builtin_abs(x);
+ // expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of complex type}}
+ // expected-note@-2 {{use function '__builtin_cabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_cabsf"
+ (void)__builtin_labs(x);
+ // expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of complex type}}
+ // expected-note@-2 {{use function '__builtin_cabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsf"
+ (void)__builtin_llabs(x);
+ // expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of complex type}}
+ // expected-note@-2 {{use function '__builtin_cabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsf"
+
+ (void)__builtin_fabsf(x);
+ // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of complex type}}
+ // expected-note@-2 {{use function '__builtin_cabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsf"
+ (void)__builtin_fabs(x);
+ // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of complex type}}
+ // expected-note@-2 {{use function '__builtin_cabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsf"
+ (void)__builtin_fabsl(x);
+ // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of complex type}}
+ // expected-note@-2 {{use function '__builtin_cabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsf"
+
+ (void)__builtin_cabsf(x);
+ (void)__builtin_cabs(x);
+ (void)__builtin_cabsl(x);
+}
+
+void test_complex_double(_Complex double x) {
+ (void)abs(x);
+ // expected-warning@-1 {{using integer absolute value function 'abs' when argument is of complex type}}
+ // expected-note@-2 {{use function 'cabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"cabs"
+ (void)labs(x);
+ // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of complex type}}
+ // expected-note@-2 {{use function 'cabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabs"
+ (void)llabs(x);
+ // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of complex type}}
+ // expected-note@-2 {{use function 'cabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabs"
+
+ (void)fabsf(x);
+ // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of complex type}}
+ // expected-note@-2 {{use function 'cabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabs"
+ (void)fabs(x);
+ // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of complex type}}
+ // expected-note@-2 {{use function 'cabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabs"
+ (void)fabsl(x);
+ // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of complex type}}
+ // expected-note@-2 {{use function 'cabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabs"
+
+ (void)cabsf(x);
+ // expected-warning@-1 {{absolute value function 'cabsf' given an argument of type '_Complex double' but has parameter of type '_Complex float' which may cause truncation of value}}
+ // expected-note@-2 {{use function 'cabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabs"
+ (void)cabs(x);
+ (void)cabsl(x);
+
+ (void)__builtin_abs(x);
+ // expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of complex type}}
+ // expected-note@-2 {{use function '__builtin_cabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_cabs"
+ (void)__builtin_labs(x);
+ // expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of complex type}}
+ // expected-note@-2 {{use function '__builtin_cabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabs"
+ (void)__builtin_llabs(x);
+ // expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of complex type}}
+ // expected-note@-2 {{use function '__builtin_cabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabs"
+
+ (void)__builtin_fabsf(x);
+ // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of complex type}}
+ // expected-note@-2 {{use function '__builtin_cabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabs"
+ (void)__builtin_fabs(x);
+ // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of complex type}}
+ // expected-note@-2 {{use function '__builtin_cabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabs"
+ (void)__builtin_fabsl(x);
+ // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of complex type}}
+ // expected-note@-2 {{use function '__builtin_cabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabs"
+
+ (void)__builtin_cabsf(x);
+ // expected-warning@-1 {{absolute value function '__builtin_cabsf' given an argument of type '_Complex double' but has parameter of type '_Complex float' which may cause truncation of value}}
+ // expected-note@-2 {{use function '__builtin_cabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabs"
+ (void)__builtin_cabs(x);
+ (void)__builtin_cabsl(x);
+}
+
+void test_complex_long_double(_Complex long double x) {
+ (void)abs(x);
+ // expected-warning@-1 {{using integer absolute value function 'abs' when argument is of complex type}}
+ // expected-note@-2 {{use function 'cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"cabsl"
+ (void)labs(x);
+ // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of complex type}}
+ // expected-note@-2 {{use function 'cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsl"
+ (void)llabs(x);
+ // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of complex type}}
+ // expected-note@-2 {{use function 'cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl"
+
+ (void)fabsf(x);
+ // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of complex type}}
+ // expected-note@-2 {{use function 'cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl"
+ (void)fabs(x);
+ // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of complex type}}
+ // expected-note@-2 {{use function 'cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsl"
+ (void)fabsl(x);
+ // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of complex type}}
+ // expected-note@-2 {{use function 'cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl"
+
+ (void)cabsf(x);
+ // expected-warning@-1 {{absolute value function 'cabsf' given an argument of type '_Complex long double' but has parameter of type '_Complex float' which may cause truncation of value}}
+ // expected-note@-2 {{use function 'cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl"
+ (void)cabs(x);
+ // expected-warning@-1 {{absolute value function 'cabs' given an argument of type '_Complex long double' but has parameter of type '_Complex double' which may cause truncation of value}}
+ // expected-note@-2 {{use function 'cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsl"
+ (void)cabsl(x);
+
+ (void)__builtin_abs(x);
+ // expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of complex type}}
+ // expected-note@-2 {{use function '__builtin_cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_cabsl"
+ (void)__builtin_labs(x);
+ // expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of complex type}}
+ // expected-note@-2 {{use function '__builtin_cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsl"
+ (void)__builtin_llabs(x);
+ // expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of complex type}}
+ // expected-note@-2 {{use function '__builtin_cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl"
+
+ (void)__builtin_fabsf(x);
+ // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of complex type}}
+ // expected-note@-2 {{use function '__builtin_cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl"
+ (void)__builtin_fabs(x);
+ // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of complex type}}
+ // expected-note@-2 {{use function '__builtin_cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsl"
+ (void)__builtin_fabsl(x);
+ // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of complex type}}
+ // expected-note@-2 {{use function '__builtin_cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl"
+
+ (void)__builtin_cabsf(x);
+ // expected-warning@-1 {{absolute value function '__builtin_cabsf' given an argument of type '_Complex long double' but has parameter of type '_Complex float' which may cause truncation of value}}
+ // expected-note@-2 {{use function '__builtin_cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl"
+ (void)__builtin_cabs(x);
+ // expected-warning@-1 {{absolute value function '__builtin_cabs' given an argument of type '_Complex long double' but has parameter of type '_Complex double' which may cause truncation of value}}
+ // expected-note@-2 {{use function '__builtin_cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsl"
+ (void)__builtin_cabsl(x);
+}
+
+void test_unsigned_int(unsigned int x) {
+ (void)abs(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note@-2 {{remove the call to 'abs' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:""
+ (void)labs(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note@-2 {{remove the call to 'labs' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:""
+ (void)llabs(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note@-2 {{remove the call to 'llabs' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
+
+ (void)fabsf(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note@-2 {{remove the call to 'fabsf' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
+ (void)fabs(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note@-2 {{remove the call to 'fabs' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:""
+ (void)fabsl(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note@-2 {{remove the call to 'fabsl' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
+
+ (void)cabsf(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note@-2 {{remove the call to 'cabsf' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
+ (void)cabs(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note@-2 {{remove the call to 'cabs' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:""
+ (void)cabsl(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note@-2 {{remove the call to 'cabsl' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
+
+ (void)__builtin_abs(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note@-2 {{remove the call to '__builtin_abs' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:""
+ (void)__builtin_labs(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note@-2 {{remove the call to '__builtin_labs' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:""
+ (void)__builtin_llabs(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note@-2 {{remove the call to '__builtin_llabs' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
+
+ (void)__builtin_fabsf(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note@-2 {{remove the call to '__builtin_fabsf' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
+ (void)__builtin_fabs(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note@-2 {{remove the call to '__builtin_fabs' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:""
+ (void)__builtin_fabsl(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note@-2 {{remove the call to '__builtin_fabsl' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
+
+ (void)__builtin_cabsf(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note@-2 {{remove the call to '__builtin_cabsf' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
+ (void)__builtin_cabs(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note@-2 {{remove the call to '__builtin_cabs' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:""
+ (void)__builtin_cabsl(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note@-2 {{remove the call to '__builtin_cabsl' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
+}
+
+void test_unsigned_long(unsigned long x) {
+ (void)abs(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note@-2 {{remove the call to 'abs' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:""
+ (void)labs(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note@-2 {{remove the call to 'labs' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:""
+ (void)llabs(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note@-2 {{remove the call to 'llabs' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
+
+ (void)fabsf(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note@-2 {{remove the call to 'fabsf' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
+ (void)fabs(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note@-2 {{remove the call to 'fabs' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:""
+ (void)fabsl(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note@-2 {{remove the call to 'fabsl' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
+
+ (void)cabsf(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note@-2 {{remove the call to 'cabsf' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
+ (void)cabs(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note@-2 {{remove the call to 'cabs' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:""
+ (void)cabsl(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note@-2 {{remove the call to 'cabsl' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
+
+ (void)__builtin_abs(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note@-2 {{remove the call to '__builtin_abs' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:""
+ (void)__builtin_labs(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note@-2 {{remove the call to '__builtin_labs' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:""
+ (void)__builtin_llabs(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note@-2 {{remove the call to '__builtin_llabs' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
+
+ (void)__builtin_fabsf(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note@-2 {{remove the call to '__builtin_fabsf' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
+ (void)__builtin_fabs(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note@-2 {{remove the call to '__builtin_fabs' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:""
+ (void)__builtin_fabsl(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note@-2 {{remove the call to '__builtin_fabsl' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
+
+ (void)__builtin_cabsf(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note@-2 {{remove the call to '__builtin_cabsf' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
+ (void)__builtin_cabs(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note@-2 {{remove the call to '__builtin_cabs' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:""
+ (void)__builtin_cabsl(x);
+ // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note@-2 {{remove the call to '__builtin_cabsl' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
+}
+
diff --git a/test/Sema/warn-documentation.cpp b/test/Sema/warn-documentation.cpp
index 7166a49..ed25d94 100644
--- a/test/Sema/warn-documentation.cpp
+++ b/test/Sema/warn-documentation.cpp
@@ -167,7 +167,13 @@
// expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
/// \param a Blah blah.
-int test_param1;
+int test_param1_backslash;
+
+// rdar://13066276
+// Check that the diagnostic uses the same command marker as the comment.
+// expected-warning@+1 {{'@param' command used in a comment that is not attached to a function declaration}}
+/// @param a Blah blah.
+int test_param1_at;
// expected-warning@+1 {{empty paragraph passed to '\param' command}}
/// \param
@@ -269,41 +275,85 @@
/// \param x2 Ccc.
int test_param22(int x1, int x2, int x3);
-// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
-/// \param aaa Meow.
-/// \param bbb Bbb.
-/// \returns aaa.
-typedef int test_param23(int aaa, int ccc);
+//===---
+// Test that we treat typedefs to some non-function types as functions for the
+// purposes of documentation comment parsing.
+//===---
+
+namespace foo {
+ inline namespace bar {
+ template<typename>
+ struct function_wrapper {};
+
+ template<unsigned>
+ struct not_a_function_wrapper {};
+ }
+};
// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
/// \param aaa Meow.
/// \param bbb Bbb.
/// \returns aaa.
-typedef int (*test_param24)(int aaa, int ccc);
+typedef int test_function_like_typedef1(int aaa, int ccc);
// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
/// \param aaa Meow.
/// \param bbb Bbb.
/// \returns aaa.
-typedef int (* const test_param25)(int aaa, int ccc);
+typedef int (*test_function_like_typedef2)(int aaa, int ccc);
// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
/// \param aaa Meow.
/// \param bbb Bbb.
/// \returns aaa.
-typedef int (C::*test_param26)(int aaa, int ccc);
+typedef int (* const test_function_like_typedef3)(int aaa, int ccc);
-typedef int (*test_param27)(int aaa);
+// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
+/// \param aaa Meow.
+/// \param bbb Bbb.
+/// \returns aaa.
+typedef int (C::*test_function_like_typedef4)(int aaa, int ccc);
+
+// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
+/// \param aaa Meow.
+/// \param bbb Bbb.
+/// \returns aaa.
+typedef foo::function_wrapper<int (int aaa, int ccc)> test_function_like_typedef5;
+
+// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
+/// \param aaa Meow.
+/// \param bbb Bbb.
+/// \returns aaa.
+typedef foo::function_wrapper<int (int aaa, int ccc)> *test_function_like_typedef6;
+
+// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
+/// \param aaa Meow.
+/// \param bbb Bbb.
+/// \returns aaa.
+typedef foo::function_wrapper<int (int aaa, int ccc)> &test_function_like_typedef7;
+
+// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
+/// \param aaa Meow.
+/// \param bbb Bbb.
+/// \returns aaa.
+typedef foo::function_wrapper<int (int aaa, int ccc)> &&test_function_like_typedef8;
+
+
+typedef int (*test_not_function_like_typedef1)(int aaa);
// expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
/// \param aaa Meow.
-typedef test_param27 test_param28;
+typedef test_not_function_like_typedef1 test_not_function_like_typedef2;
// rdar://13066276
+// Check that the diagnostic uses the same command marker as the comment.
// expected-warning@+1 {{'@param' command used in a comment that is not attached to a function declaration}}
/// @param aaa Meow.
-typedef unsigned int test_param29;
+typedef unsigned int test_not_function_like_typedef3;
+// expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
+/// \param aaa Meow.
+typedef foo::not_a_function_wrapper<1> test_not_function_like_typedef4;
/// \param aaa Aaa
/// \param ... Vararg
@@ -321,6 +371,26 @@
int test_vararg_param4();
+/// \param aaa Aaa
+/// \param ... Vararg
+template<typename T>
+int test_template_vararg_param1(int aaa, ...);
+
+/// \param ... Vararg
+template<typename T>
+int test_template_vararg_param2(...);
+
+// expected-warning@+1 {{parameter '...' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
+/// \param ... Vararg
+template<typename T>
+int test_template_vararg_param3(int aaa);
+
+// expected-warning@+1 {{parameter '...' not found in the function declaration}}
+/// \param ... Vararg
+template<typename T>
+int test_template_vararg_param4();
+
+
// expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}}
/// \tparam T Aaa
int test_tparam1;
@@ -503,7 +573,13 @@
// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
/// \returns Aaa
-int test_returns_wrong_decl_1;
+int test_returns_wrong_decl_1_backslash;
+
+// rdar://13066276
+// Check that the diagnostic uses the same command marker as the comment.
+// expected-warning@+1 {{'@returns' command used in a comment that is not attached to a function or method declaration}}
+/// @returns Aaa
+int test_returns_wrong_decl_1_at;
// expected-warning@+1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
/// \return Aaa
@@ -555,11 +631,6 @@
/// \returns Aaa
namespace test_returns_wrong_decl_10 { };
-// rdar://13066276
-// expected-warning@+1 {{'@returns' command used in a comment that is not attached to a function or method declaration}}
-/// @returns Aaa
-typedef unsigned int test_returns_wrong_decl_11;
-
// rdar://13094352
// expected-warning@+1 {{'@function' command should be used in a comment attached to a function declaration}}
/*! @function test_function
diff --git a/test/Sema/warn-missing-variable-declarations.c b/test/Sema/warn-missing-variable-declarations.c
index 631d3d2..e5ce97d 100644
--- a/test/Sema/warn-missing-variable-declarations.c
+++ b/test/Sema/warn-missing-variable-declarations.c
@@ -1,4 +1,4 @@
-// RUN: %clang -Wmissing-variable-declarations -fsyntax-only -Xclang -verify %s
+// RUN: %clang_cc1 -Wmissing-variable-declarations -fsyntax-only -verify %s
int vbad1; // expected-warning{{no previous extern declaration for non-static variable 'vbad1'}}
diff --git a/test/Sema/warn-null.c b/test/Sema/warn-null.c
index 28fb6a5..3bf2aed 100644
--- a/test/Sema/warn-null.c
+++ b/test/Sema/warn-null.c
@@ -1,5 +1,7 @@
// RUN: %clang_cc1 %s -verify
+#define SOME_ADDR (unsigned long long)0
+
// PR10837: Warn if a non-pointer-typed expression is folded to a null pointer
int *p = 0;
int *q = '\0'; // expected-warning{{expression which evaluates to zero treated as a null pointer constant}}
@@ -8,4 +10,5 @@
p = 0;
q = '\0'; // expected-warning{{expression which evaluates to zero treated as a null pointer constant}}
r = 1 - 1; // expected-warning{{expression which evaluates to zero treated as a null pointer constant}}
+ p = SOME_ADDR; // expected-warning{{expression which evaluates to zero treated as a null pointer constant}}
}
diff --git a/test/Sema/warn-outof-range-assign-enum.c b/test/Sema/warn-outof-range-assign-enum.c
index 43eea0c..edd4e37 100644
--- a/test/Sema/warn-outof-range-assign-enum.c
+++ b/test/Sema/warn-outof-range-assign-enum.c
@@ -11,6 +11,24 @@
CCTestEnum test = 50; // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}}
CCTestEnum test1 = -50; // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}}
+// Explicit cast should silence the warning.
+static const CCTestEnum SilenceWithCast1 = 51; // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}}
+static const CCTestEnum SilenceWithCast2 = (CCTestEnum) 51; // no-warning
+static const CCTestEnum SilenceWithCast3 = (const CCTestEnum) 51; // no-warning
+static const CCTestEnum SilenceWithCast4 = (const volatile CCTestEnum) 51; // no-warning
+
+void SilenceWithCastLocalVar() {
+ CCTestEnum SilenceWithCast1 = 51; // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}}
+ CCTestEnum SilenceWithCast2 = (CCTestEnum) 51; // no-warning
+ CCTestEnum SilenceWithCast3 = (const CCTestEnum) 51; // no-warning
+ CCTestEnum SilenceWithCast4 = (const volatile CCTestEnum) 51; // no-warning
+
+ const CCTestEnum SilenceWithCast1c = 51; // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}}
+ const CCTestEnum SilenceWithCast2c = (CCTestEnum) 51; // no-warning
+ const CCTestEnum SilenceWithCast3c = (const CCTestEnum) 51; // no-warning
+ const CCTestEnum SilenceWithCast4c = (const volatile CCTestEnum) 51; // no-warning
+}
+
CCTestEnum foo(CCTestEnum r) {
return 20; // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}}
}
diff --git a/test/Sema/warn-thread-safety-analysis.c b/test/Sema/warn-thread-safety-analysis.c
index 1918ace..6d41e40 100644
--- a/test/Sema/warn-thread-safety-analysis.c
+++ b/test/Sema/warn-thread-safety-analysis.c
@@ -1,4 +1,4 @@
-// RUN: %clang -fsyntax-only -verify -Wthread-safety -Wthread-safety-beta -fcxx-exceptions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -Wthread-safety-beta %s
#define LOCKABLE __attribute__ ((lockable))
#define SCOPED_LOCKABLE __attribute__ ((scoped_lockable))
@@ -31,15 +31,12 @@
struct Mutex *mu_;
};
-// Define mutex lock/unlock functions.
-void mutex_exclusive_lock(struct Mutex *mu) EXCLUSIVE_LOCK_FUNCTION(mu) {
-}
-
-void mutex_shared_lock(struct Mutex *mu) SHARED_LOCK_FUNCTION(mu) {
-}
-
-void mutex_unlock(struct Mutex *mu) UNLOCK_FUNCTION(mu) {
-}
+// Declare mutex lock/unlock functions.
+void mutex_exclusive_lock(struct Mutex *mu) EXCLUSIVE_LOCK_FUNCTION(mu);
+void mutex_shared_lock(struct Mutex *mu) SHARED_LOCK_FUNCTION(mu);
+void mutex_unlock(struct Mutex *mu) UNLOCK_FUNCTION(mu);
+void mutex_shared_unlock(struct Mutex *mu) __attribute__((release_shared_capability(mu)));
+void mutex_exclusive_unlock(struct Mutex *mu) __attribute__((release_capability(mu)));
// Define global variables.
struct Mutex mu1;
@@ -77,14 +74,14 @@
int main() {
- Foo_fun1(1); // expected-warning{{calling function 'Foo_fun1' requires shared lock on 'mu2'}} \
- expected-warning{{calling function 'Foo_fun1' requires exclusive lock on 'mu1'}}
+ Foo_fun1(1); // expected-warning{{calling function 'Foo_fun1' requires holding mutex 'mu2'}} \
+ expected-warning{{calling function 'Foo_fun1' requires holding mutex 'mu1' exclusively}}
mutex_exclusive_lock(&mu1);
mutex_shared_lock(&mu2);
Foo_fun1(1);
- mutex_shared_lock(&mu1); // expected-warning{{locking 'mu1' that is already locked}}
+ mutex_shared_lock(&mu1); // expected-warning{{acquiring mutex 'mu1' that is already held}}
mutex_unlock(&mu1);
mutex_unlock(&mu2);
mutex_shared_lock(&mu1);
@@ -98,13 +95,13 @@
mutex_unlock(&mu1);
mutex_exclusive_lock(&mu1);
- Foo_func3(4); // expected-warning{{cannot call function 'Foo_func3' while mutex 'mu1' is locked}}
+ Foo_func3(4); // expected-warning{{cannot call function 'Foo_func3' while mutex 'mu1' is held}}
mutex_unlock(&mu1);
Foo_func3(5);
- set_value(&a_, 0); // expected-warning{{calling function 'setA' requires exclusive lock on 'foo_.mu_'}}
- get_value(b_); // expected-warning{{calling function 'getB' requires shared lock on 'foo_.mu_'}}
+ set_value(&a_, 0); // expected-warning{{calling function 'set_value' requires holding mutex 'foo_.mu_' exclusively}}
+ get_value(b_); // expected-warning{{calling function 'get_value' requires holding mutex 'foo_.mu_'}}
mutex_exclusive_lock(foo_.mu_);
set_value(&a_, 1);
mutex_unlock(foo_.mu_);
@@ -112,12 +109,20 @@
(void)(get_value(b_) == 1);
mutex_unlock(foo_.mu_);
- c_ = 0; // expected-warning{{writing variable 'c_' requires locking any mutex exclusively}}
- (void)(*d_ == 0); // expected-warning{{reading the value pointed to by 'd_' requires locking any mutex}}
+ c_ = 0; // expected-warning{{writing variable 'c_' requires holding any mutex exclusively}}
+ (void)(*d_ == 0); // expected-warning{{reading the value pointed to by 'd_' requires holding any mutex}}
mutex_exclusive_lock(foo_.mu_);
c_ = 1;
(void)(*d_ == 1);
mutex_unlock(foo_.mu_);
+ mutex_exclusive_lock(&mu1);
+ mutex_shared_unlock(&mu1); // expected-warning {{releasing mutex 'mu1' using shared access, expected exclusive access}}
+ mutex_exclusive_unlock(&mu1);
+
+ mutex_shared_lock(&mu1);
+ mutex_exclusive_unlock(&mu1); // expected-warning {{releasing mutex 'mu1' using exclusive access, expected shared access}}
+ mutex_shared_unlock(&mu1);
+
return 0;
}
diff --git a/test/Sema/warn-type-safety.c b/test/Sema/warn-type-safety.c
index dfab8f8..0431386 100644
--- a/test/Sema/warn-type-safety.c
+++ b/test/Sema/warn-type-safety.c
@@ -57,6 +57,8 @@
__attribute__(( type_tag_for_datatype(mpi,int,layout_compatible,not_a_flag) )); // expected-error {{invalid comparison flag 'not_a_flag'}}
+void datatype_wrong7(void) __attribute__((type_tag_for_datatype(datatype_wrong7, int))); // expected-error {{'type_tag_for_datatype' attribute only applies to variables}}
+
// Using a tag with kind A in a place where the function requires kind B should
// warn.
@@ -156,5 +158,3 @@
F_func(float_ptr, 0xFFFFFFFFFFFFFFFFULL); // expected-warning {{argument type 'float *' doesn't match specified 'f' type tag that requires 'int *'}}
F_func(float_ptr, 0xFFFFFFFFULL);
}
-
-
diff --git a/test/Sema/warn-unreachable.c b/test/Sema/warn-unreachable.c
index fd74b5c..0d22965 100644
--- a/test/Sema/warn-unreachable.c
+++ b/test/Sema/warn-unreachable.c
@@ -1,4 +1,6 @@
-// RUN: %clang %s -fsyntax-only -Xclang -verify -fblocks -Wunreachable-code -Wno-unused-value -Wno-covered-switch-default
+// RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks -Wunreachable-code-aggressive -Wno-unused-value -Wno-covered-switch-default -I %S/Inputs
+
+#include "warn-unreachable.h"
int halt() __attribute__((noreturn));
int live();
@@ -107,7 +109,7 @@
case C3:
return 1;
default: {
- int i = 0; // expected-warning{{will never be executed}}
+ int i = 0; // no-warning
++i;
return i;
}
@@ -134,10 +136,263 @@
// Test case for <rdar://problem/11005770>. We should treat code guarded
// by 'x & 0' and 'x * 0' as unreachable.
-void calledFun();
+int calledFun();
void test_mul_and_zero(int x) {
if (x & 0) calledFun(); // expected-warning {{will never be executed}}
if (0 & x) calledFun(); // expected-warning {{will never be executed}}
if (x * 0) calledFun(); // expected-warning {{will never be executed}}
if (0 * x) calledFun(); // expected-warning {{will never be executed}}
}
+
+void raze() __attribute__((noreturn));
+void warn_here();
+
+int test_break_preceded_by_noreturn(int i) {
+ switch (i) {
+ case 1:
+ raze();
+ break; // expected-warning {{'break' will never be executed}}
+ case 2:
+ raze();
+ break; // expected-warning {{'break' will never be executed}}
+ warn_here(); // expected-warning {{will never be executed}}
+ case 3:
+ return 1;
+ break; // expected-warning {{will never be executed}}
+ default:
+ break;
+ break; // expected-warning {{will never be executed}}
+ }
+ return i;
+}
+
+// Don't warn about unreachable 'default' cases, as that is covered
+// by -Wcovered-switch-default.
+typedef enum { Value1 = 1 } MyEnum;
+void unreachable_default(MyEnum e) {
+ switch (e) {
+ case Value1:
+ calledFun();
+ break;
+ case 2: // expected-warning {{case value not in enumerated type 'MyEnum'}}
+ calledFun();
+ break;
+ default:
+ calledFun(); // no-warning
+ break;
+ }
+}
+void unreachable_in_default(MyEnum e) {
+ switch (e) {
+ default:
+ raze();
+ calledFun(); // expected-warning {{will never be executed}}
+ break;
+ }
+}
+
+// Don't warn about trivial dead returns.
+int trivial_dead_return() {
+ raze();
+ return ((0)); // expected-warning {{'return' will never be executed}}
+}
+
+void trivial_dead_return_void() {
+ raze();
+ return; // expected-warning {{'return' will never be executed}}
+}
+
+MyEnum trival_dead_return_enum() {
+ raze();
+ return Value1; // expected-warning {{'return' will never be executed}}
+}
+
+MyEnum trivial_dead_return_enum_2(int x) {
+ switch (x) {
+ case 1: return 1;
+ case 2: return 2;
+ case 3: return 3;
+ default: return 4;
+ }
+
+ return 2; // expected-warning {{will never be executed}}
+}
+
+const char *trivial_dead_return_cstr() {
+ raze();
+ return ""; // expected-warning {{return' will never be executed}}
+}
+
+char trivial_dead_return_char() {
+ raze();
+ return ' '; // expected-warning {{return' will never be executed}}
+}
+
+MyEnum nontrivial_dead_return_enum_2(int x) {
+ switch (x) {
+ case 1: return 1;
+ case 2: return 2;
+ case 3: return 3;
+ default: return 4;
+ }
+
+ return calledFun(); // expected-warning {{will never be executed}}
+}
+
+enum X { A, B, C };
+
+int covered_switch(enum X x) {
+ switch (x) {
+ case A: return 1;
+ case B: return 2;
+ case C: return 3;
+ }
+ return 4; // no-warning
+}
+
+// Test unreachable code depending on configuration values
+#define CONFIG_CONSTANT 1
+int test_config_constant(int x) {
+ if (!CONFIG_CONSTANT) {
+ calledFun(); // no-warning
+ return 1;
+ }
+ if (!1) { // expected-note {{silence by adding parentheses to mark code as explicitly dead}}
+ calledFun(); // expected-warning {{will never be executed}}
+ return 1;
+ }
+ if (sizeof(int) > sizeof(char)) {
+ calledFun(); // no-warning
+ return 1;
+ }
+ if (x > 10)
+ return CONFIG_CONSTANT ? calledFun() : calledFun(); // no-warning
+ else
+ return 1 ? // expected-note {{silence by adding parentheses to mark code as explicitly dead}}
+ calledFun() :
+ calledFun(); // expected-warning {{will never be executed}}
+}
+
+int sizeof_int(int x, int y) {
+ if (sizeof(long) == sizeof(int))
+ return 1; // no-warning
+ if (sizeof(long) != sizeof(int))
+ return 0; // no-warning
+ if (x && y && sizeof(long) < sizeof(char))
+ return 0; // no-warning
+ return 2; // no-warning
+}
+
+enum MyEnum2 {
+ ME_A = CONFIG_CONSTANT,
+ ME_B = 1
+};
+
+int test_MyEnum() {
+ if (!ME_A)
+ return 1; // no-warning
+ if (ME_A)
+ return 2; // no-warning
+ if (ME_B)
+ return 3;
+ if (!ME_B) // expected-warning {{will never be executed}}
+ return 4; // expected-warning {{will never be executed}}
+ return 5;
+}
+
+// Test for idiomatic do..while.
+int test_do_while(int x) {
+ do {
+ if (x == calledFun())
+ break;
+ ++x;
+ break;
+ }
+ while (0); // no-warning
+ return x;
+}
+
+int test_do_while_nontrivial_cond(int x) {
+ do {
+ if (x == calledFun())
+ break;
+ ++x;
+ break;
+ }
+ while (calledFun()); // expected-warning {{will never be executed}}
+ return x;
+}
+
+// Diagnostic control: -Wunreachable-code-return.
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunreachable-code-return"
+
+void trivial_dead_return_void_SUPPRESSED() {
+ raze();
+ return; // no-warning
+}
+
+MyEnum trival_dead_return_enum_SUPPRESSED() {
+ raze();
+ return Value1; // no-warning
+}
+
+#pragma clang diagnostic pop
+
+// Diagnostic control: -Wunreachable-code-break.
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunreachable-code-break"
+
+int test_break_preceded_by_noreturn_SUPPRESSED(int i) {
+ switch (i) {
+ case 1:
+ raze();
+ break; // no-warning
+ case 2:
+ raze();
+ break; // no-warning
+ warn_here(); // expected-warning {{will never be executed}}
+ case 3:
+ return 1;
+ break; // no-warning
+ default:
+ break;
+ break; // no-warning
+ }
+ return i;
+}
+
+#pragma clang diagnostic pop
+
+// Test "silencing" with parentheses.
+void test_with_paren_silencing(int x) {
+ if (0) calledFun(); // expected-warning {{will never be executed}} expected-note {{silence by adding parentheses to mark code as explicitly dead}}
+ if ((0)) calledFun(); // no-warning
+
+ if (1) // expected-note {{silence by adding parentheses to mark code as explicitly dead}}
+ calledFun();
+ else
+ calledFun(); // expected-warning {{will never be executed}}
+
+ if ((1))
+ calledFun();
+ else
+ calledFun(); // no-warning
+
+ if (!1) // expected-note {{silence by adding parentheses to mark code as explicitly dead}}
+ calledFun(); // expected-warning {{code will never be executed}}
+ else
+ calledFun();
+
+ if ((!1))
+ calledFun(); // no-warning
+ else
+ calledFun();
+
+ if (!(1))
+ calledFun(); // no-warning
+ else
+ calledFun();
+}
diff --git a/test/Sema/wchar.c b/test/Sema/wchar.c
index 13c2f58..74e482a 100644
--- a/test/Sema/wchar.c
+++ b/test/Sema/wchar.c
@@ -1,5 +1,5 @@
-// RUN: %clang %s -fsyntax-only -Xclang -verify
-// RUN: %clang %s -fsyntax-only -fshort-wchar -Xclang -verify -DSHORT_WCHAR
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+// RUN: %clang_cc1 %s -fsyntax-only -fshort-wchar -verify -DSHORT_WCHAR
typedef __WCHAR_TYPE__ wchar_t;