summaryrefslogtreecommitdiff
path: root/test/Sema
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2013-12-22 00:07:40 +0000
committerDimitry Andric <dim@FreeBSD.org>2013-12-22 00:07:40 +0000
commitbfef399519ca9b8a4b4c6b563253bad7e0eeffe0 (patch)
treedf8df0b0067b381eab470a3b8f28d14a552a6340 /test/Sema
parent6a0372513edbc473b538d2f724efac50405d6fef (diff)
downloadsrc-test2-bfef399519ca9b8a4b4c6b563253bad7e0eeffe0.tar.gz
src-test2-bfef399519ca9b8a4b4c6b563253bad7e0eeffe0.zip
Notes
Diffstat (limited to 'test/Sema')
-rw-r--r--test/Sema/128bitfloat.cc24
-rw-r--r--test/Sema/128bitint.c4
-rw-r--r--test/Sema/Inputs/ms-keyword-system-header.h9
-rw-r--r--test/Sema/MicrosoftCompatibility.cpp6
-rw-r--r--test/Sema/MicrosoftExtensions.c34
-rw-r--r--test/Sema/aarch64-neon-vector-types.c33
-rw-r--r--test/Sema/address_spaces.c2
-rw-r--r--test/Sema/alias-redefinition.c44
-rw-r--r--test/Sema/align-x86-64.c10
-rw-r--r--test/Sema/alloc_size.c6
-rw-r--r--test/Sema/annotate.c6
-rw-r--r--test/Sema/arm-asm.c5
-rw-r--r--test/Sema/arm-darwin-aapcs.cpp12
-rw-r--r--test/Sema/arm-interrupt-attr.c16
-rw-r--r--test/Sema/array-init.c3
-rw-r--r--test/Sema/array-size-64.c9
-rw-r--r--test/Sema/atomic-expr.c13
-rw-r--r--test/Sema/atomic-ops.c16
-rw-r--r--test/Sema/atomic-requires-library-error.c31
-rw-r--r--test/Sema/attr-alias-elf.c54
-rw-r--r--test/Sema/attr-args.c50
-rw-r--r--test/Sema/attr-bounded.c15
-rw-r--r--test/Sema/attr-cleanup.c22
-rw-r--r--test/Sema/attr-deprecated.c4
-rw-r--r--test/Sema/attr-endian.c3
-rw-r--r--test/Sema/attr-format.c2
-rw-r--r--test/Sema/attr-mode.c18
-rw-r--r--test/Sema/attr-naked.c4
-rw-r--r--test/Sema/attr-nodebug.c4
-rw-r--r--test/Sema/attr-noinline.c2
-rw-r--r--test/Sema/attr-noreturn.c6
-rw-r--r--test/Sema/attr-ownership.c19
-rw-r--r--test/Sema/attr-print.c19
-rw-r--r--test/Sema/attr-regparm.c4
-rw-r--r--test/Sema/attr-returns-twice.c2
-rw-r--r--test/Sema/attr-section.c2
-rw-r--r--test/Sema/attr-tls_model.c4
-rw-r--r--test/Sema/attr-unavailable-message.c9
-rw-r--r--test/Sema/attr-unused.c2
-rw-r--r--test/Sema/attr-visibility.c2
-rw-r--r--test/Sema/block-args.c11
-rw-r--r--test/Sema/builtin-clear_cache.c5
-rw-r--r--test/Sema/builtins-aarch64.c5
-rw-r--r--test/Sema/builtins-arm-exclusive.c61
-rw-r--r--test/Sema/builtins-arm-strex-rettype.c8
-rw-r--r--test/Sema/builtins-arm.c16
-rw-r--r--test/Sema/builtins-gnu-mode.c27
-rw-r--r--test/Sema/builtins.c8
-rw-r--r--test/Sema/c89.c11
-rw-r--r--test/Sema/callingconv-ms_abi.c9
-rw-r--r--test/Sema/callingconv-sysv_abi.c9
-rw-r--r--test/Sema/callingconv.c28
-rw-r--r--test/Sema/captured-statements.c12
-rw-r--r--test/Sema/carbon.c3
-rw-r--r--test/Sema/cast.c8
-rw-r--r--test/Sema/constant-builtins-2.c118
-rw-r--r--test/Sema/convertvector.c17
-rw-r--r--test/Sema/declspec.c13
-rw-r--r--test/Sema/designated-initializers.c66
-rw-r--r--test/Sema/dllimport-dllexport.c5
-rw-r--r--test/Sema/empty1.c85
-rw-r--r--test/Sema/empty2.c43
-rw-r--r--test/Sema/enum-increment.c13
-rw-r--r--test/Sema/ext_vector_casts.c26
-rw-r--r--test/Sema/extern-redecl.c24
-rw-r--r--test/Sema/format-strings-ms.c25
-rw-r--r--test/Sema/format-strings.c10
-rw-r--r--test/Sema/freemain.c2
-rw-r--r--test/Sema/function.c10
-rw-r--r--test/Sema/gnu-flags.c171
-rw-r--r--test/Sema/init.c3
-rw-r--r--test/Sema/inline.c13
-rw-r--r--test/Sema/member-reference.c5
-rw-r--r--test/Sema/mips16_attr_allowed.c20
-rw-r--r--test/Sema/mrtd.c38
-rw-r--r--test/Sema/ms-inline-asm.c12
-rw-r--r--test/Sema/ms-keyword-system-header.c17
-rw-r--r--test/Sema/ms-wchar.c18
-rw-r--r--test/Sema/ms_abi-sysv_abi.c14
-rw-r--r--test/Sema/ms_bitfield_layout.c243
-rw-r--r--test/Sema/ms_class_layout.cpp88
-rw-r--r--test/Sema/neon-vector-types-support.c4
-rw-r--r--test/Sema/neon-vector-types.c7
-rw-r--r--test/Sema/nonnull.c3
-rw-r--r--test/Sema/offsetof-64.c22
-rw-r--r--test/Sema/offsetof.c1
-rw-r--r--test/Sema/overloadable.c18
-rw-r--r--test/Sema/parentheses.c2
-rw-r--r--test/Sema/pragma-weak.c11
-rw-r--r--test/Sema/string-init.c51
-rw-r--r--test/Sema/string-plus-char.c15
-rw-r--r--test/Sema/struct-decl.c9
-rw-r--r--test/Sema/thread-specifier.c4
-rw-r--r--test/Sema/types.c8
-rw-r--r--test/Sema/varargs.c7
-rw-r--r--test/Sema/varargs.cpp7
-rw-r--r--test/Sema/vfprintf-valid-redecl.c11
-rw-r--r--test/Sema/warn-documentation-fixits.cpp26
-rw-r--r--test/Sema/warn-documentation.cpp91
-rw-r--r--test/Sema/warn-documentation.m57
-rw-r--r--test/Sema/warn-main-return-type.c4
-rw-r--r--test/Sema/warn-main.c12
-rw-r--r--test/Sema/warn-null.c11
-rw-r--r--test/Sema/warn-outof-range-assign-enum.c12
-rw-r--r--test/Sema/warn-shadow-intrinsics.c11
-rw-r--r--test/Sema/warn-thread-safety-analysis.c123
-rw-r--r--test/Sema/warn-type-safety.c4
-rw-r--r--test/Sema/warn-unsequenced.c88
-rw-r--r--test/Sema/warn-unused-function.c6
-rw-r--r--test/Sema/warn-unused-label.c4
-rw-r--r--test/Sema/warn-unused-parameters.c2
-rw-r--r--test/Sema/warn-variable-not-needed.c9
-rw-r--r--test/Sema/wchar.c4
113 files changed, 2268 insertions, 226 deletions
diff --git a/test/Sema/128bitfloat.cc b/test/Sema/128bitfloat.cc
new file mode 100644
index 000000000000..cb76dac96001
--- /dev/null
+++ b/test/Sema/128bitfloat.cc
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=gnu++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+#if !defined(__STRICT_ANSI__)
+__float128 f; // expected-error {{support for type '__float128' is not yet implemented}}
+// But this should work:
+template<typename> struct __is_floating_point_helper {};
+template<> struct __is_floating_point_helper<__float128> {};
+
+// FIXME: This could have a better diag.
+void g(int x, __float128 *y) {
+ x + *y; // expected-error {{invalid operands to binary expression ('int' and '__float128')}}
+}
+
+#else
+__float128 f; // expected-error {{unknown type name '__float128'}}
+template<typename> struct __is_floating_point_helper {};
+template<> struct __is_floating_point_helper<__float128> {}; // expected-error {{use of undeclared identifier '__float128'}}
+
+void g(int x, __float128 *y) { // expected-error {{unknown type name '__float128'}}
+ x + *y;
+}
+
+#endif
diff --git a/test/Sema/128bitint.c b/test/Sema/128bitint.c
index bb8e3d155e57..4272b2d1391e 100644
--- a/test/Sema/128bitint.c
+++ b/test/Sema/128bitint.c
@@ -16,10 +16,10 @@ __uint128_t b = (__uint128_t)-1;
__int128 i = (__int128)0;
unsigned __int128 u = (unsigned __int128)-1;
-long long SignedTooBig = 123456789012345678901234567890; // expected-warning {{integer constant is too large for its type}}
+long long SignedTooBig = 123456789012345678901234567890; // expected-error {{constant is larger than the largest unsigned integer type}}
__int128_t Signed128 = 123456789012345678901234567890i128;
long long Signed64 = 123456789012345678901234567890i128; // expected-warning {{implicit conversion from '__int128' to 'long long' changes value from 123456789012345678901234567890 to -4362896299872285998}}
-unsigned long long UnsignedTooBig = 123456789012345678901234567890; // expected-warning {{integer constant is too large for its type}}
+unsigned long long UnsignedTooBig = 123456789012345678901234567890; // expected-error {{constant is larger than the largest unsigned integer type}}
__uint128_t Unsigned128 = 123456789012345678901234567890Ui128;
unsigned long long Unsigned64 = 123456789012345678901234567890Ui128; // expected-warning {{implicit conversion from 'unsigned __int128' to 'unsigned long long' changes value from 123456789012345678901234567890 to 14083847773837265618}}
diff --git a/test/Sema/Inputs/ms-keyword-system-header.h b/test/Sema/Inputs/ms-keyword-system-header.h
new file mode 100644
index 000000000000..43a3db7a12ba
--- /dev/null
+++ b/test/Sema/Inputs/ms-keyword-system-header.h
@@ -0,0 +1,9 @@
+/* "System header" for testing GNU libc keyword conflict workarounds */
+
+typedef union {
+ union w *__uptr;
+#if defined(MS) && defined(NOT_SYSTEM)
+ // expected-warning@-2 {{keyword '__uptr' will be treated as an identifier here}}
+#endif
+ int *__iptr;
+} WS __attribute__((__transparent_union__));
diff --git a/test/Sema/MicrosoftCompatibility.cpp b/test/Sema/MicrosoftCompatibility.cpp
index 15c25586c47d..90a45dfaaf17 100644
--- a/test/Sema/MicrosoftCompatibility.cpp
+++ b/test/Sema/MicrosoftCompatibility.cpp
@@ -2,3 +2,9 @@
// PR15845
int foo(xxx); // expected-error{{unknown type name}}
+
+struct cls {
+ char *m;
+};
+
+char * cls::* __uptr wrong2 = &cls::m; // expected-error {{'__uptr' attribute cannot be used with pointers to members}}
diff --git a/test/Sema/MicrosoftExtensions.c b/test/Sema/MicrosoftExtensions.c
index 5d7330e3f700..a6caf7acb8a8 100644
--- a/test/Sema/MicrosoftExtensions.c
+++ b/test/Sema/MicrosoftExtensions.c
@@ -76,6 +76,9 @@ void pointer_to_integral_type_conv(char* ptr) {
short sh = (short)ptr;
ch = (char)ptr;
sh = (short)ptr;
+
+ // This is valid ISO C.
+ _Bool b = (_Bool)ptr;
}
@@ -93,7 +96,7 @@ struct __declspec(deprecated) DS1 { int i; float f; }; // expected-note {{declar
#define MY_TEXT "This is also deprecated"
__declspec(deprecated(MY_TEXT)) void Dfunc1( void ) {} // expected-note {{'Dfunc1' declared here}}
-struct __declspec(deprecated(123)) DS2 {}; // expected-error {{argument to deprecated attribute was not a string literal}}
+struct __declspec(deprecated(123)) DS2 {}; // expected-error {{'deprecated' attribute requires a string}}
void test( void ) {
e1 = one; // expected-warning {{'e1' is deprecated: This is deprecated}}
@@ -102,3 +105,32 @@ void test( void ) {
enum DE1 no; // no warning because E1 is not deprecated
}
+
+int __sptr wrong1; // expected-error {{'__sptr' attribute only applies to pointer arguments}}
+// The modifier must follow the asterisk
+int __sptr *wrong_psp; // expected-error {{'__sptr' attribute only applies to pointer arguments}}
+int * __sptr __uptr wrong2; // expected-error {{'__sptr' and '__uptr' attributes are not compatible}}
+int * __sptr __sptr wrong3; // expected-warning {{attribute '__sptr' is already applied}}
+
+// It is illegal to overload based on the type attribute.
+void ptr_func(int * __ptr32 i) {} // expected-note {{previous definition is here}}
+void ptr_func(int * __ptr64 i) {} // expected-error {{redefinition of 'ptr_func'}}
+
+// It is also illegal to overload based on the pointer type attribute.
+void ptr_func2(int * __sptr __ptr32 i) {} // expected-note {{previous definition is here}}
+void ptr_func2(int * __uptr __ptr32 i) {} // expected-error {{redefinition of 'ptr_func2'}}
+
+int * __sptr __ptr32 __sptr wrong4; // expected-warning {{attribute '__sptr' is already applied}}
+
+__ptr32 int *wrong5; // expected-error {{'__ptr32' attribute only applies to pointer arguments}}
+
+int *wrong6 __ptr32; // expected-error {{expected ';' after top level declarator}} expected-warning {{declaration does not declare anything}}
+
+int * __ptr32 __ptr64 wrong7; // expected-error {{'__ptr32' and '__ptr64' attributes are not compatible}}
+
+int * __ptr32 __ptr32 wrong8; // expected-warning {{attribute '__ptr32' is already applied}}
+
+int *(__ptr32 __sptr wrong9); // expected-error {{'__sptr' attribute only applies to pointer arguments}} // expected-error {{'__ptr32' attribute only applies to pointer arguments}}
+
+typedef int *T;
+T __ptr32 wrong10; // expected-error {{'__ptr32' attribute only applies to pointer arguments}}
diff --git a/test/Sema/aarch64-neon-vector-types.c b/test/Sema/aarch64-neon-vector-types.c
new file mode 100644
index 000000000000..894cf6de1b0c
--- /dev/null
+++ b/test/Sema/aarch64-neon-vector-types.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 %s -triple aarch64-none-linux-gnu -target-feature +neon -fsyntax-only -verify
+
+typedef float float32_t;
+typedef unsigned char poly8_t;
+typedef unsigned short poly16_t;
+typedef unsigned long long uint64_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))) 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;
+
+// The attributes must have a single argument.
+typedef __attribute__((neon_vector_type(2, 4))) int only_one_arg; // expected-error{{attribute takes one argument}}
+
+// The number of elements must be an ICE.
+typedef __attribute__((neon_vector_type(2.0))) int non_int_width; // expected-error{{attribute requires an integer constant}}
+
+// Only certain element types are allowed.
+typedef __attribute__((neon_vector_type(2))) double double_elt;
+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; };
+typedef __attribute__((neon_vector_type(8))) struct aggr aggregate_elt; // expected-error{{invalid vector element type}}
+
+// The total vector size must be 64 or 128 bits.
+typedef __attribute__((neon_vector_type(1))) int int32x1_t; // expected-error{{Neon vector size must be 64 or 128 bits}}
+typedef __attribute__((neon_vector_type(3))) int int32x3_t; // expected-error{{Neon vector size must be 64 or 128 bits}}
diff --git a/test/Sema/address_spaces.c b/test/Sema/address_spaces.c
index 0ae3230a6189..4756af9d9528 100644
--- a/test/Sema/address_spaces.c
+++ b/test/Sema/address_spaces.c
@@ -65,3 +65,5 @@ void access_as_field()
(void) bar.as_field;
}
+typedef int PR4997 __attribute__((address_space(Foobar))); // expected-error {{use of undeclared identifier 'Foobar'}}
+__attribute__((address_space("12"))) int *i; // expected-error {{'address_space' attribute requires an integer constant}}
diff --git a/test/Sema/alias-redefinition.c b/test/Sema/alias-redefinition.c
new file mode 100644
index 000000000000..6c6ebf80250b
--- /dev/null
+++ b/test/Sema/alias-redefinition.c
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -verify %s
+
+void f0() {}
+void fun0(void) __attribute((alias("f0")));
+
+void f1() {}
+void fun1() {} // expected-note {{previous definition}}
+void fun1(void) __attribute((alias("f1"))); // expected-error {{redefinition of 'fun1'}}
+
+void f2() {}
+void fun2(void) __attribute((alias("f2"))); // expected-note {{previous definition}}
+void fun2() {} // expected-error {{redefinition of 'fun2'}}
+
+void f3() {}
+void fun3(void) __attribute((alias("f3"))); // expected-note {{previous definition}}
+void fun3(void) __attribute((alias("f3"))); // expected-error {{redefinition of 'fun3'}}
+
+void f4() {}
+void fun4(void) __attribute((alias("f4")));
+void fun4(void);
+
+// FIXME: We should produce a special case error for this.
+void f5() {}
+void __attribute((alias("f5"))) fun5(void) {} // expected-error {{redefinition of 'fun5'}} // expected-note {{previous definition}}
+
+int v1;
+int var1 __attribute((alias("v1"))); // expected-note {{previous definition}}
+int var1 __attribute((alias("v1"))); // expected-error {{redefinition of 'var1'}}
+
+int v2;
+int var2 = 2; // expected-note {{previous definition}}
+int var2 __attribute((alias("v2"))); // expected-error {{redefinition of 'var2'}}
+
+int v3;
+int var3 __attribute((alias("v3"))); // expected-note {{previous definition}}
+int var3 = 2; // expected-error {{redefinition of 'var3'}}
+
+int v4;
+int var4; // expected-note {{previous definition}}
+int var4 __attribute((alias("v4"))); // expected-error {{alias definition of 'var4' after tentative definition}}
+
+int v5;
+int var5 __attribute((alias("v5"))); // expected-note {{previous definition}}
+int var5; // expected-error {{tentative definition of 'var5' after alias definition}}
diff --git a/test/Sema/align-x86-64.c b/test/Sema/align-x86-64.c
index 09bf63390f35..b34d85942d0e 100644
--- a/test/Sema/align-x86-64.c
+++ b/test/Sema/align-x86-64.c
@@ -1,16 +1,6 @@
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -verify %s
// expected-no-diagnostics
-// PR5599
-
-void frob(void *);
-
-void foo(void) {
- float x[4];
- char y[__alignof__(x) == 16 ? 1 : -1];
- frob(y);
-}
-
// PR5637
typedef __attribute__((aligned(16))) struct {
diff --git a/test/Sema/alloc_size.c b/test/Sema/alloc_size.c
index 84f393204659..053323a9f11b 100644
--- a/test/Sema/alloc_size.c
+++ b/test/Sema/alloc_size.c
@@ -5,9 +5,9 @@ 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{{attribute requires integer constant}}
+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{{attribute requires 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}}
@@ -19,7 +19,7 @@ void* fn7(unsigned) __attribute__((alloc_size)); // expected-error {{attribute t
void *fn8(int, int) __attribute__((alloc_size(1, 1))); // OK
-void* fn9(unsigned) __attribute__((alloc_size(12345678901234567890123))); // expected-warning {{integer constant is too large for its type}} // expected-error {{attribute parameter 1 is out of bounds}}
+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}} \
diff --git a/test/Sema/annotate.c b/test/Sema/annotate.c
index ef878d4c9824..4a786d0a0163 100644
--- a/test/Sema/annotate.c
+++ b/test/Sema/annotate.c
@@ -1,9 +1,9 @@
// RUN: %clang_cc1 %s -fsyntax-only -verify
-void __attribute__((annotate("foo"))) foo(float *a) {
+void __attribute__((annotate("foo"))) foo(float *a) {
__attribute__((annotate("bar"))) int x;
- __attribute__((annotate(1))) int y; // expected-error {{argument to annotate attribute was not a string literal}}
- __attribute__((annotate("bar", 1))) int z; // expected-error {{attribute takes one argument}}
+ __attribute__((annotate(1))) int y; // expected-error {{'annotate' attribute requires a string}}
+ __attribute__((annotate("bar", 1))) int z; // expected-error {{'annotate' attribute takes one argument}}
int u = __builtin_annotation(z, (char*) 0); // expected-error {{second argument to __builtin_annotation must be a non-wide string constant}}
int v = __builtin_annotation(z, (char*) L"bar"); // expected-error {{second argument to __builtin_annotation must be a non-wide string constant}}
int w = __builtin_annotation(z, "foo");
diff --git a/test/Sema/arm-asm.c b/test/Sema/arm-asm.c
index 3fc0eeb7543a..e48718b0a2ac 100644
--- a/test/Sema/arm-asm.c
+++ b/test/Sema/arm-asm.c
@@ -5,3 +5,8 @@ void f (void) {
asm volatile ("lw (r1), %0[val]": "=&b"(Val)); // expected-error {{invalid output constraint '=&b' in asm}}
return;
}
+
+void test_64bit_r(void) {
+ long long foo = 0, bar = 0;
+ asm volatile("INST %0, %1" : "=r"(foo) : "r"(bar));
+}
diff --git a/test/Sema/arm-darwin-aapcs.cpp b/test/Sema/arm-darwin-aapcs.cpp
new file mode 100644
index 000000000000..1359a1dc15aa
--- /dev/null
+++ b/test/Sema/arm-darwin-aapcs.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -triple thumbv7-apple-ios -target-abi aapcs -verify -fsyntax-only
+// expected-no-diagnostics
+
+// ARM's AAPCS normally has size_t defined as unsigned int, but on Darwin
+// some embedded targets use AAPCS with the iOS header files, which define
+// size_t as unsigned long. Make sure that works.
+typedef unsigned long size_t;
+void* malloc(size_t);
+void* operator new(size_t size)
+{
+ return (malloc(size));
+}
diff --git a/test/Sema/arm-interrupt-attr.c b/test/Sema/arm-interrupt-attr.c
new file mode 100644
index 000000000000..b2cedc2e4d20
--- /dev/null
+++ b/test/Sema/arm-interrupt-attr.c
@@ -0,0 +1,16 @@
+// 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 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"))) void foo3() {}
+__attribute__((interrupt("FIQ"))) void foo4() {}
+__attribute__((interrupt("SWI"))) void foo5() {}
+__attribute__((interrupt("ABORT"))) void foo6() {}
+__attribute__((interrupt("UNDEF"))) void foo7() {}
+
+__attribute__((interrupt)) void foo8() {}
+__attribute__((interrupt())) void foo9() {}
+__attribute__((interrupt(""))) void foo10() {}
diff --git a/test/Sema/array-init.c b/test/Sema/array-init.c
index f92852f341b6..ae2c7425662b 100644
--- a/test/Sema/array-init.c
+++ b/test/Sema/array-init.c
@@ -226,7 +226,8 @@ void emptyInit() {struct {} x[] = {6};} //expected-warning{{empty struct is a GN
// expected-error{{initializer for aggregate with no elements}}
void noNamedInit() {
- struct {int:5;} x[] = {6}; //expected-error{{initializer for aggregate with no elements}}
+ struct {int:5;} x[] = {6}; //expected-error{{initializer for aggregate with no elements}} \
+// expected-warning {{struct without named members is a GNU extension}}
}
struct {int a; int:5;} noNamedImplicit[] = {1,2,3};
int noNamedImplicitCheck[sizeof(noNamedImplicit) == 3 * sizeof(*noNamedImplicit) ? 1 : -1];
diff --git a/test/Sema/array-size-64.c b/test/Sema/array-size-64.c
index f22e8e77d215..0e094bfa6bd7 100644
--- a/test/Sema/array-size-64.c
+++ b/test/Sema/array-size-64.c
@@ -2,6 +2,11 @@
void f() {
int a[2147483647U][2147483647U]; // expected-error{{array is too large}}
- int b[1073741825U - 1U][2147483647U];
- int c[18446744073709551615U/sizeof(int)/2];
+ int b[1073741825U - 1U][2147483647U]; // expected-error{{array is too large}}
}
+
+void pr8256 () {
+ typedef char a[1LL<<61]; // expected-error {{array is too large}}
+ typedef char b[(long long)sizeof(a)-1];
+}
+
diff --git a/test/Sema/atomic-expr.c b/test/Sema/atomic-expr.c
index ecc04c4c68d6..5602d545cc7f 100644
--- a/test/Sema/atomic-expr.c
+++ b/test/Sema/atomic-expr.c
@@ -45,3 +45,16 @@ void func_09 (int* xp) {
void func_10 (int* xp) {
*xp <<= data2;
}
+
+int func_11 (int x) {
+ return data1 == x;
+}
+
+int func_12 () {
+ return data1 < data2;
+}
+
+int func_13 (int x, unsigned y) {
+ return x ? data1 : y;
+}
+
diff --git a/test/Sema/atomic-ops.c b/test/Sema/atomic-ops.c
index b3daa0704dc9..c2d38e714bf2 100644
--- a/test/Sema/atomic-ops.c
+++ b/test/Sema/atomic-ops.c
@@ -86,8 +86,8 @@ void f(_Atomic(int) *i, _Atomic(int*) *p, _Atomic(float) *d,
__c11_atomic_init(I, 5); // expected-error {{pointer to _Atomic}}
__c11_atomic_load(0); // expected-error {{too few arguments to function}}
__c11_atomic_load(0,0,0); // expected-error {{too many arguments to function}}
- __c11_atomic_store(0,0,0); // expected-error {{first argument to atomic builtin must be a pointer}}
- __c11_atomic_store((int*)0,0,0); // expected-error {{first argument to atomic operation must be a pointer to _Atomic}}
+ __c11_atomic_store(0,0,0); // expected-error {{address argument to atomic builtin must be a pointer}}
+ __c11_atomic_store((int*)0,0,0); // expected-error {{address argument to atomic operation must be a pointer to _Atomic}}
__c11_atomic_load(i, memory_order_seq_cst);
__c11_atomic_load(p, memory_order_seq_cst);
@@ -169,10 +169,16 @@ void f(_Atomic(int) *i, _Atomic(int*) *p, _Atomic(float) *d,
(int)__atomic_clear(&flag, memory_order_seq_cst); // expected-error {{operand of type 'void'}}
const _Atomic(int) const_atomic;
- __c11_atomic_init(&const_atomic, 0); // expected-error {{first argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}}
- __c11_atomic_store(&const_atomic, 0, memory_order_release); // expected-error {{first argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}}
- __c11_atomic_load(&const_atomic, memory_order_acquire); // expected-error {{first argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}}
+ __c11_atomic_init(&const_atomic, 0); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}}
+ __c11_atomic_store(&const_atomic, 0, memory_order_release); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}}
+ __c11_atomic_load(&const_atomic, memory_order_acquire); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}}
}
_Atomic(int*) PR12527_a;
void PR12527() { int *b = PR12527_a; }
+
+void PR16931(int* x) { // expected-note {{passing argument to parameter 'x' here}}
+ typedef struct { _Atomic(_Bool) flag; } flag;
+ flag flagvar = { 0 };
+ PR16931(&flagvar); // expected-warning {{incompatible pointer types}}
+}
diff --git a/test/Sema/atomic-requires-library-error.c b/test/Sema/atomic-requires-library-error.c
new file mode 100644
index 000000000000..b0aa2783544b
--- /dev/null
+++ b/test/Sema/atomic-requires-library-error.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 %s -triple=i686-apple-darwin9 -verify
+// rdar://13973577
+
+struct foo {
+ int big[128];
+};
+struct bar {
+ char c[3];
+};
+
+struct bar smallThing;
+struct foo bigThing;
+_Atomic(struct foo) bigAtomic;
+
+void structAtomicStore() {
+ struct foo f = {0};
+ __c11_atomic_store(&bigAtomic, f, 5); // expected-error {{atomic store requires runtime support that is not available for this target}}
+
+ struct bar b = {0};
+ __atomic_store(&smallThing, &b, 5);
+
+ __atomic_store(&bigThing, &f, 5);
+}
+
+void structAtomicLoad() {
+ struct foo f = __c11_atomic_load(&bigAtomic, 5); // expected-error {{atomic load requires runtime support that is not available for this target}}
+ struct bar b;
+ __atomic_load(&smallThing, &b, 5);
+
+ __atomic_load(&bigThing, &f, 5);
+}
diff --git a/test/Sema/attr-alias-elf.c b/test/Sema/attr-alias-elf.c
new file mode 100644
index 000000000000..88bd7b70958b
--- /dev/null
+++ b/test/Sema/attr-alias-elf.c
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux -fsyntax-only -verify -emit-llvm-only %s
+
+void f1(void) __attribute__((alias("g1")));
+void g1(void) {
+}
+
+void f2(void) __attribute__((alias("g2"))); // expected-error {{alias must point to a defined variable or function}}
+
+
+void f3(void) __attribute__((alias("g3"))); // expected-error {{alias must point to a defined variable or function}}
+void g3(void);
+
+
+void f4() __attribute__((alias("g4")));
+void g4() {}
+void h4() __attribute__((alias("f4")));
+
+void f5() __attribute__((alias("g5")));
+void h5() __attribute__((alias("f5")));
+void g5() {}
+
+void g6() {}
+void f6() __attribute__((alias("g6")));
+void h6() __attribute__((alias("f6")));
+
+void g7() {}
+void h7() __attribute__((alias("f7")));
+void f7() __attribute__((alias("g7")));
+
+void h8() __attribute__((alias("f8")));
+void g8() {}
+void f8() __attribute__((alias("g8")));
+
+void h9() __attribute__((alias("f9")));
+void f9() __attribute__((alias("g9")));
+void g9() {}
+
+void f10() __attribute__((alias("g10"))); // expected-error {{alias definition is part of a cycle}}
+void g10() __attribute__((alias("f10"))); // expected-error {{alias definition is part of a cycle}}
+
+// FIXME: This could be a bit better, h10 is not part of the cycle, it points
+// to it.
+void h10() __attribute__((alias("g10"))); // expected-error {{alias definition is part of a cycle}}
+
+extern int a1 __attribute__((alias("b1")));
+int b1 = 42;
+
+extern int a2 __attribute__((alias("b2"))); // expected-error {{alias must point to a defined variable or function}}
+
+extern int a3 __attribute__((alias("b3"))); // expected-error {{alias must point to a defined variable or function}}
+extern int b3;
+
+extern int a4 __attribute__((alias("b4"))); // expected-error {{alias must point to a defined variable or function}}
+typedef int b4;
diff --git a/test/Sema/attr-args.c b/test/Sema/attr-args.c
index 61358016fbe1..1981de522995 100644
--- a/test/Sema/attr-args.c
+++ b/test/Sema/attr-args.c
@@ -1,40 +1,14 @@
-// RUN: %clang_cc1 -DATTR=noreturn -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
-// RUN: %clang_cc1 -DATTR=always_inline -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
-// RUN: %clang_cc1 -DATTR=cdecl -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
-// RUN: %clang_cc1 -DATTR=const -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
-// RUN: %clang_cc1 -DATTR=fastcall -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
-// RUN: %clang_cc1 -DATTR=malloc -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
-// RUN: %clang_cc1 -DATTR=nothrow -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
-// RUN: %clang_cc1 -DATTR=stdcall -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
-// RUN: %clang_cc1 -DATTR=used -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
-// RUN: %clang_cc1 -DATTR=unused -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
-// RUN: %clang_cc1 -DATTR=weak -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
-
-#define ATTR_DECL(a) __attribute__((ATTR(a)))
-
-int a;
-
-inline ATTR_DECL(a) void* foo(); // expected-error{{attribute takes no arguments}}
-
-
-
-// RUN: %clang_cc1 -DATTR=noreturn -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
-// RUN: %clang_cc1 -DATTR=always_inline -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
-// RUN: %clang_cc1 -DATTR=cdecl -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
-// RUN: %clang_cc1 -DATTR=const -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
-// RUN: %clang_cc1 -DATTR=fastcall -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
-// RUN: %clang_cc1 -DATTR=malloc -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
-// RUN: %clang_cc1 -DATTR=nothrow -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
-// RUN: %clang_cc1 -DATTR=stdcall -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
-// RUN: %clang_cc1 -DATTR=used -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
-// RUN: %clang_cc1 -DATTR=unused -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
-// RUN: %clang_cc1 -DATTR=weak -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
-
-#define ATTR_DECL(a) __attribute__((ATTR(a)))
-
+// RUN: %clang_cc1 -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -fsyntax-only %s
int a;
-inline ATTR_DECL(a) void* foo(); // expected-error{{attribute takes no arguments}}
-
-
-
+inline __attribute__((noreturn(a))) void *f1(); // expected-error {{'noreturn' attribute takes no arguments}}
+inline __attribute__((always_inline(a))) void *f2(); // expected-error {{'always_inline' attribute takes no arguments}}
+inline __attribute__((cdecl(a))) void *f3(); // expected-error {{'cdecl' attribute takes no arguments}}
+inline __attribute__((const(a))) void *f4(); // expected-error {{'const' attribute takes no arguments}}
+inline __attribute__((fastcall(a))) void *f5(); // expected-error {{'fastcall' attribute takes no arguments}}
+inline __attribute__((malloc(a))) void *f5(); // expected-error {{'malloc' attribute takes no arguments}}
+inline __attribute__((nothrow(a))) void *f7(); // expected-error {{'nothrow' attribute takes no arguments}}
+inline __attribute__((stdcall(a))) void *f8(); // expected-error {{'stdcall' attribute takes no arguments}}
+inline __attribute__((used(a))) void *f9(); // expected-error {{'used' attribute takes no arguments}}
+inline __attribute__((unused(a))) void *f10(); // expected-error {{'unused' attribute takes no arguments}}
+inline __attribute__((weak(a))) void *f11(); // expected-error {{'weak' attribute takes no arguments}}
diff --git a/test/Sema/attr-bounded.c b/test/Sema/attr-bounded.c
new file mode 100644
index 000000000000..bf71fedf2d3f
--- /dev/null
+++ b/test/Sema/attr-bounded.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+// Make sure OpenBSD's bounded extension is accepted.
+
+typedef long ssize_t;
+typedef unsigned long size_t;
+typedef struct FILE FILE;
+
+ssize_t read(int, void *, size_t)
+ __attribute__((__bounded__(__buffer__,2,3)));
+int readlink(const char *, char *, size_t)
+ __attribute__((__bounded__(__string__,2,3)));
+size_t fread(void *, size_t, size_t, FILE *)
+ __attribute__((__bounded__(__size__,1,3,2)));
+char *getwd(char *)
+ __attribute__((__bounded__(__minbytes__,1,1024))); \ No newline at end of file
diff --git a/test/Sema/attr-cleanup.c b/test/Sema/attr-cleanup.c
index 991822e402e0..f5cbc385c689 100644
--- a/test/Sema/attr-cleanup.c
+++ b/test/Sema/attr-cleanup.c
@@ -2,18 +2,18 @@
void c1(int *a);
-extern int g1 __attribute((cleanup(c1))); // expected-warning {{cleanup attribute ignored}}
-int g2 __attribute((cleanup(c1))); // expected-warning {{cleanup attribute ignored}}
-static int g3 __attribute((cleanup(c1))); // expected-warning {{cleanup attribute ignored}}
+extern int g1 __attribute((cleanup(c1))); // expected-warning {{'cleanup' attribute ignored}}
+int g2 __attribute((cleanup(c1))); // expected-warning {{'cleanup' attribute ignored}}
+static int g3 __attribute((cleanup(c1))); // expected-warning {{'cleanup' attribute ignored}}
void t1()
{
- int v1 __attribute((cleanup)); // expected-error {{attribute takes one argument}}
- int v2 __attribute((cleanup(1, 2))); // expected-error {{attribute takes one argument}}
-
- static int v3 __attribute((cleanup(c1))); // expected-warning {{cleanup attribute ignored}}
-
- int v4 __attribute((cleanup(h))); // expected-error {{'cleanup' argument 'h' not found}}
+ int v1 __attribute((cleanup)); // expected-error {{'cleanup' attribute takes one argument}}
+ int v2 __attribute((cleanup(1, 2))); // expected-error {{'cleanup' attribute takes one argument}}
+
+ static int v3 __attribute((cleanup(c1))); // expected-warning {{'cleanup' attribute ignored}}
+
+ int v4 __attribute((cleanup(h))); // expected-error {{use of undeclared identifier 'h'}}
int v5 __attribute((cleanup(c1)));
int v6 __attribute((cleanup(v3))); // expected-error {{'cleanup' argument 'v3' is not a function}}
@@ -42,3 +42,7 @@ void c5(void*) __attribute__((deprecated)); // expected-note{{'c5' declared her
void t5() {
int i __attribute__((cleanup(c5))); // expected-warning {{'c5' is deprecated}}
}
+
+void t6(void) {
+ int i __attribute__((cleanup((void *)0))); // expected-error {{'cleanup' argument is not a function}}
+}
diff --git a/test/Sema/attr-deprecated.c b/test/Sema/attr-deprecated.c
index 565be7ff5997..8124ab0ddd02 100644
--- a/test/Sema/attr-deprecated.c
+++ b/test/Sema/attr-deprecated.c
@@ -120,3 +120,7 @@ struct test22 {
foo_dep c, d __attribute((deprecated)); // expected-warning {{'foo_dep' is deprecated}}
__attribute((deprecated)) foo_dep e, f;
};
+
+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}}
+test23_ty test23_v; // expected-warning {{'test23_ty' is deprecated}}
diff --git a/test/Sema/attr-endian.c b/test/Sema/attr-endian.c
new file mode 100644
index 000000000000..db24dafd4213
--- /dev/null
+++ b/test/Sema/attr-endian.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+int p1 __attribute__((endian(host))); // expected-warning {{unknown attribute 'endian' ignored}}
diff --git a/test/Sema/attr-format.c b/test/Sema/attr-format.c
index a223e08f5a48..21d9585a57e9 100644
--- a/test/Sema/attr-format.c
+++ b/test/Sema/attr-format.c
@@ -78,3 +78,5 @@ extern void gcc_cxxformat (const char *, ...)
__attribute__ ((__format__(__gcc_cxxdiag__, 1, 2)));
extern void gcc_tformat (const char *, ...)
__attribute__ ((__format__(__gcc_tdiag__, 1, 2)));
+
+const char *foo3(const char *format) __attribute__((format_arg("foo"))); // expected-error{{'format_arg' attribute requires parameter 1 to be an integer constant}}
diff --git a/test/Sema/attr-mode.c b/test/Sema/attr-mode.c
index a89c8397e0a0..49e41d210d03 100644
--- a/test/Sema/attr-mode.c
+++ b/test/Sema/attr-mode.c
@@ -2,6 +2,8 @@
// RUN: -verify %s
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -DTEST_64BIT_X86 -fsyntax-only \
// RUN: -verify %s
+// RUN: %clang_cc1 -triple powerpc64-pc-linux-gnu -DTEST_64BIT_PPC64 -fsyntax-only \
+// RUN: -verify %s
typedef int i16_1 __attribute((mode(HI)));
int i16_1_test[sizeof(i16_1) == 2 ? 1 : -1];
@@ -11,11 +13,12 @@ int i16_2_test[sizeof(i16_1) == 2 ? 1 : -1];
typedef float f64 __attribute((mode(DF)));
int f64_test[sizeof(f64) == 8 ? 1 : -1];
-typedef int invalid_1 __attribute((mode)); // expected-error{{attribute requires unquoted parameter}}
-typedef int invalid_2 __attribute((mode())); // expected-error{{attribute requires unquoted parameter}}
+typedef int invalid_1 __attribute((mode)); // expected-error{{'mode' attribute takes one argument}}
+typedef int invalid_2 __attribute((mode())); // expected-error{{'mode' attribute takes one argument}}
typedef int invalid_3 __attribute((mode(II))); // expected-error{{unknown machine mode}}
typedef struct {int i,j,k;} invalid_4 __attribute((mode(SI))); // expected-error{{mode attribute only supported for integer and floating-point types}}
typedef float invalid_5 __attribute((mode(SI))); // expected-error{{type of machine mode does not match type of base type}}
+typedef int invalid_6 __attribute__((mode(12))); // expected-error{{'mode' attribute requires an identifier}}
typedef unsigned unwind_word __attribute((mode(unwind_word)));
@@ -24,7 +27,10 @@ int **__attribute((mode(QI)))* i32; // expected-error{{mode attribute}}
typedef _Complex double c32 __attribute((mode(SC)));
int c32_test[sizeof(c32) == 8 ? 1 : -1];
typedef _Complex float c64 __attribute((mode(DC)));
+
+#ifndef TEST_64BIT_PPC64 // Note, 'XC' mode is illegal for PPC64 machines.
typedef _Complex float c80 __attribute((mode(XC)));
+#endif
// PR6108: Correctly select 'long' built in type on 64-bit platforms for 64 bit
// modes. Also test other mode-based conversions.
@@ -56,6 +62,14 @@ void test_long_to_ui64(unsigned long long* y) { f_ui64_arg(y); }
#elif TEST_64BIT_X86
void test_long_to_i64(long* y) { f_i64_arg(y); }
void test_long_to_ui64(unsigned long* y) { f_ui64_arg(y); }
+typedef float f128ibm __attribute__ ((mode (TF))); // expected-error{{unsupported machine mode 'TF'}}
+#elif TEST_64BIT_PPC64
+typedef float f128ibm __attribute__ ((mode (TF)));
+typedef _Complex float c128ibm __attribute__ ((mode (TC)));
+void f_ft128_arg(long double *x);
+void f_ft128_complex_arg(_Complex long double *x);
+void test_TFtype(f128ibm *a) { f_ft128_arg (a); }
+void test_TCtype(c128ibm *a) { f_ft128_complex_arg (a); }
#else
#error Unknown test architecture.
#endif
diff --git a/test/Sema/attr-naked.c b/test/Sema/attr-naked.c
index d9fa5423d9ef..55c6b326ef15 100644
--- a/test/Sema/attr-naked.c
+++ b/test/Sema/attr-naked.c
@@ -2,11 +2,11 @@
int a __attribute__((naked)); // expected-warning {{'naked' attribute only applies to functions}}
-__attribute__((naked)) int t0(void) {
+__attribute__((naked)) int t0(void) {
__asm__ volatile("mov r0, #0");
}
void t1() __attribute__((naked));
-void t2() __attribute__((naked(2))); // expected-error {{attribute takes no arguments}}
+void t2() __attribute__((naked(2))); // expected-error {{'naked' attribute takes no arguments}}
diff --git a/test/Sema/attr-nodebug.c b/test/Sema/attr-nodebug.c
index 3cc4088e4b3c..03ec49b850d6 100644
--- a/test/Sema/attr-nodebug.c
+++ b/test/Sema/attr-nodebug.c
@@ -4,8 +4,8 @@ int a __attribute__((nodebug));
void b() {
int b __attribute__((nodebug)); // expected-warning {{'nodebug' only applies to variables with static storage duration and functions}}
-}
+}
void t1() __attribute__((nodebug));
-void t2() __attribute__((nodebug(2))); // expected-error {{attribute takes no arguments}}
+void t2() __attribute__((nodebug(2))); // expected-error {{'nodebug' attribute takes no arguments}}
diff --git a/test/Sema/attr-noinline.c b/test/Sema/attr-noinline.c
index dfc88a8d8fcb..cadf9d6c186a 100644
--- a/test/Sema/attr-noinline.c
+++ b/test/Sema/attr-noinline.c
@@ -4,5 +4,5 @@ int a __attribute__((noinline)); // expected-warning {{'noinline' attribute only
void t1() __attribute__((noinline));
-void t2() __attribute__((noinline(2))); // expected-error {{attribute takes no arguments}}
+void t2() __attribute__((noinline(2))); // expected-error {{'noinline' attribute takes no arguments}}
diff --git a/test/Sema/attr-noreturn.c b/test/Sema/attr-noreturn.c
index 5c643fff718d..dab571064a22 100644
--- a/test/Sema/attr-noreturn.c
+++ b/test/Sema/attr-noreturn.c
@@ -13,7 +13,7 @@ int f1() __attribute__((noreturn));
int g0 __attribute__((noreturn)); // expected-warning {{'noreturn' only applies to function types; type here is 'int'}}
-int f2() __attribute__((noreturn(1, 2))); // expected-error {{attribute takes no arguments}}
+int f2() __attribute__((noreturn(1, 2))); // expected-error {{'noreturn' attribute takes no arguments}}
void f3() __attribute__((noreturn));
void f3() {
@@ -33,7 +33,7 @@ extern void f5 (unsigned long) __attribute__ ((__noreturn__));
void
f5 (unsigned long size)
{
-
+
}
// PR2461
@@ -41,4 +41,4 @@ __attribute__((noreturn)) void f(__attribute__((noreturn)) void (*x)(void)) {
x();
}
-typedef void (*Fun)(void) __attribute__ ((noreturn(2))); // expected-error {{attribute takes no arguments}}
+typedef void (*Fun)(void) __attribute__ ((noreturn(2))); // expected-error {{'noreturn' attribute takes no arguments}}
diff --git a/test/Sema/attr-ownership.c b/test/Sema/attr-ownership.c
new file mode 100644
index 000000000000..e31b429ef6ed
--- /dev/null
+++ b/test/Sema/attr-ownership.c
@@ -0,0 +1,19 @@
+// 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 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 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 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}}
+
+void f10(int i) __attribute__((ownership_holds(foo, 1))); // expected-error {{'ownership_holds' attribute only applies to pointer arguments}}
+void *f11(float i) __attribute__((ownership_returns(foo, 1))); // expected-error {{'ownership_returns' attribute only applies to integer arguments}}
+void *f12(float i, int k, int f, int *j) __attribute__((ownership_returns(foo, 4))); // expected-error {{'ownership_returns' attribute only applies to integer arguments}}
+
+void f13(int *i, int *j) __attribute__((ownership_holds(foo, 1))) __attribute__((ownership_takes(foo, 2)));
+void f14(int i, int j, int *k) __attribute__((ownership_holds(foo, 3))) __attribute__((ownership_takes(foo, 3))); // expected-error {{'ownership_holds' and 'ownership_takes' attributes are not compatible}}
diff --git a/test/Sema/attr-print.c b/test/Sema/attr-print.c
index 2659508e5625..b3bdfd72e645 100644
--- a/test/Sema/attr-print.c
+++ b/test/Sema/attr-print.c
@@ -13,9 +13,22 @@ void foo() __attribute__((const));
// CHECK: void bar() __attribute__((__const));
void bar() __attribute__((__const));
-// FIXME: Print these at a valid location for these attributes.
-// CHECK: int *p32 __ptr32;
+// CHECK: int * __ptr32 p32;
int * __ptr32 p32;
-// CHECK: int *p64 __ptr64;
+// CHECK: int * __ptr64 p64;
int * __ptr64 p64;
+
+// TODO: the Type Printer has no way to specify the order to print attributes
+// in, and so it currently always prints them in reverse order. Fix this.
+// CHECK: int * __ptr32 __uptr p32_2;
+int * __uptr __ptr32 p32_2;
+
+// CHECK: int * __ptr64 __sptr p64_2;
+int * __sptr __ptr64 p64_2;
+
+// CHECK: int * __ptr32 __uptr p32_3;
+int * __uptr __ptr32 p32_3;
+
+// CHECK: int * __sptr * __ptr32 ppsp32;
+int * __sptr * __ptr32 ppsp32;
diff --git a/test/Sema/attr-regparm.c b/test/Sema/attr-regparm.c
index ccd894e606d5..d50dd113f70f 100644
--- a/test/Sema/attr-regparm.c
+++ b/test/Sema/attr-regparm.c
@@ -1,10 +1,10 @@
// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
__attribute((regparm(2))) int x0(void);
-__attribute((regparm(1.0))) int x1(void); // expected-error{{'regparm' attribute requires integer constant}}
+__attribute((regparm(1.0))) int x1(void); // expected-error{{'regparm' attribute requires an integer constant}}
__attribute((regparm(-1))) int x2(void); // expected-error{{'regparm' parameter must be between 0 and 3 inclusive}}
__attribute((regparm(5))) int x3(void); // expected-error{{'regparm' parameter must be between 0 and 3 inclusive}}
-__attribute((regparm(5,3))) int x4(void); // expected-error{{attribute takes one argument}}
+__attribute((regparm(5,3))) int x4(void); // expected-error{{'regparm' attribute takes one argument}}
void __attribute__((regparm(3))) x5(int);
void x5(int); // expected-note{{previous declaration is here}}
diff --git a/test/Sema/attr-returns-twice.c b/test/Sema/attr-returns-twice.c
index 13f53e36de79..aa32b243b106 100644
--- a/test/Sema/attr-returns-twice.c
+++ b/test/Sema/attr-returns-twice.c
@@ -7,6 +7,6 @@ __attribute__((returns_twice)) void t0(void) {
void t1() __attribute__((returns_twice));
-void t2() __attribute__((returns_twice(2))); // expected-error {{attribute takes no arguments}}
+void t2() __attribute__((returns_twice(2))); // expected-error {{'returns_twice' attribute takes no arguments}}
typedef void (*t3)(void) __attribute__((returns_twice)); // expected-warning {{'returns_twice' attribute only applies to functions}}
diff --git a/test/Sema/attr-section.c b/test/Sema/attr-section.c
index 69ca732517af..396892a1c5e9 100644
--- a/test/Sema/attr-section.c
+++ b/test/Sema/attr-section.c
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -verify -fsyntax-only -triple x86_64-apple-darwin9 %s
int x __attribute__((section(
- 42))); // expected-error {{argument to section attribute was not a string literal}}
+ 42))); // expected-error {{'section' attribute requires a string}}
// rdar://4341926
diff --git a/test/Sema/attr-tls_model.c b/test/Sema/attr-tls_model.c
index e184ebc82af0..c4f92f1f80de 100644
--- a/test/Sema/attr-tls_model.c
+++ b/test/Sema/attr-tls_model.c
@@ -9,6 +9,6 @@ int f() __attribute((tls_model("global-dynamic"))); // expected-error {{'tls_mod
int x __attribute((tls_model("global-dynamic"))); // expected-error {{'tls_model' attribute only applies to thread-local variables}}
static __thread int y __attribute((tls_model("global-dynamic"))); // no-warning
-static __thread int y __attribute((tls_model("local", "dynamic"))); // expected-error {{attribute takes one argument}}
-static __thread int y __attribute((tls_model(123))); // expected-error {{argument to tls_model attribute was not a string literal}}
+static __thread int y __attribute((tls_model("local", "dynamic"))); // expected-error {{'tls_model' attribute takes one argument}}
+static __thread int y __attribute((tls_model(123))); // expected-error {{'tls_model' attribute requires a string}}
static __thread int y __attribute((tls_model("foobar"))); // expected-error {{tls_model must be "global-dynamic", "local-dynamic", "initial-exec" or "local-exec"}}
diff --git a/test/Sema/attr-unavailable-message.c b/test/Sema/attr-unavailable-message.c
index 97104960e5e4..ebdf945867fe 100644
--- a/test/Sema/attr-unavailable-message.c
+++ b/test/Sema/attr-unavailable-message.c
@@ -6,6 +6,11 @@ double dfoo(double) __attribute__((__unavailable__("NO LONGER"))); // expected-
void bar() __attribute__((__unavailable__)); // expected-note {{explicitly marked unavailable}}
+int quux(void) __attribute__((__unavailable__(12))); // expected-error {{'__unavailable__' attribute requires a string}}
+
+#define ACCEPTABLE "Use something else"
+int quux2(void) __attribute__((__unavailable__(ACCEPTABLE)));
+
void test_foo() {
int ir = foo(1); // expected-error {{'foo' is unavailable: USE IFOO INSTEAD}}
double dr = dfoo(1.0); // expected-error {{'dfoo' is unavailable: NO LONGER}}
@@ -32,13 +37,13 @@ enum foo {
a = 1, // expected-note {{declared here}}
b __attribute__((deprecated())) = 2, // expected-note {{declared here}}
c = 3
-}__attribute__((deprecated()));
+}__attribute__((deprecated()));
enum fee { // expected-note {{declaration has been explicitly marked unavailable here}}
r = 1, // expected-note {{declaration has been explicitly marked unavailable here}}
s = 2,
t = 3
-}__attribute__((unavailable()));
+}__attribute__((unavailable()));
enum fee f() { // expected-error {{'fee' is unavailable}}
int i = a; // expected-warning {{'a' is deprecated}}
diff --git a/test/Sema/attr-unused.c b/test/Sema/attr-unused.c
index 07c65cbd9aed..c0c7b9b97adb 100644
--- a/test/Sema/attr-unused.c
+++ b/test/Sema/attr-unused.c
@@ -9,7 +9,7 @@ int f1() __attribute__((unused));
int g0 __attribute__((unused));
-int f2() __attribute__((unused(1, 2))); // expected-error {{attribute takes no arguments}}
+int f2() __attribute__((unused(1, 2))); // expected-error {{'unused' attribute takes no arguments}}
struct Test0_unused {} __attribute__((unused));
struct Test0_not_unused {};
diff --git a/test/Sema/attr-visibility.c b/test/Sema/attr-visibility.c
index 7f7fd546f095..ed52ec2743f9 100644
--- a/test/Sema/attr-visibility.c
+++ b/test/Sema/attr-visibility.c
@@ -24,3 +24,5 @@ extern int test7 __attribute__((visibility("hidden"))); // expected-error {{visi
typedef int __attribute__((visibility("default"))) bar; // expected-warning {{'visibility' attribute ignored}}
int x __attribute__((type_visibility("default"))); // expected-error {{'type_visibility' attribute only applies to types and namespaces}}
+
+int PR17105 __attribute__((visibility(hidden))); // expected-error {{'visibility' attribute requires a string}}
diff --git a/test/Sema/block-args.c b/test/Sema/block-args.c
index 5ee383eebb02..c6beead3915b 100644
--- a/test/Sema/block-args.c
+++ b/test/Sema/block-args.c
@@ -45,3 +45,14 @@ void test5_helper(void (^)(int, int[*]));
void test5(void) {
test5_helper(^(int n, int array[n]) {});
}
+
+// Reduced from a problem on platforms where va_list is an array.
+struct tag {
+ int x;
+};
+typedef struct tag array_ty[1];
+void test6(void) {
+ void (^block)(array_ty) = ^(array_ty arr) { };
+ array_ty arr;
+ block(arr);
+}
diff --git a/test/Sema/builtin-clear_cache.c b/test/Sema/builtin-clear_cache.c
new file mode 100644
index 000000000000..e21aad79d12a
--- /dev/null
+++ b/test/Sema/builtin-clear_cache.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -triple armv7-none-linux-gnu -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+void __clear_cache(void *a, void *b) {}
diff --git a/test/Sema/builtins-aarch64.c b/test/Sema/builtins-aarch64.c
index 03e03343eb94..b0557532fab6 100644
--- a/test/Sema/builtins-aarch64.c
+++ b/test/Sema/builtins-aarch64.c
@@ -1,4 +1,9 @@
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -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);
diff --git a/test/Sema/builtins-arm-exclusive.c b/test/Sema/builtins-arm-exclusive.c
new file mode 100644
index 000000000000..8c784031142b
--- /dev/null
+++ b/test/Sema/builtins-arm-exclusive.c
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -triple armv7 -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((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}}
+
+ sum += __builtin_arm_ldrex((__int128 *)addr); // expected-error {{__int128 is not supported on this target}} expected-error {{address argument to load or store exclusive builtin must be a pointer to 1,2,4 or 8 byte type}}
+
+ __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(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}}
+
+ res |= __builtin_arm_strex(1, (__int128 *)addr); // expected-error {{__int128 is not supported on this target}} expected-error {{address argument to load or store exclusive builtin must be a pointer to 1,2,4 or 8 byte type}}
+
+ __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-arm-strex-rettype.c b/test/Sema/builtins-arm-strex-rettype.c
new file mode 100644
index 000000000000..4ee96ce3277e
--- /dev/null
+++ b/test/Sema/builtins-arm-strex-rettype.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple thumbv7m-apple-darwin-eabi -ast-dump %s | FileCheck %s
+
+// CHECK: CallExpr {{.*}} 'int'
+
+void foo(int a, int *b) {
+ do {
+ } while (__builtin_arm_strex(a, b));
+}
diff --git a/test/Sema/builtins-arm.c b/test/Sema/builtins-arm.c
index 7b48af155ee8..3ac1da0aa93d 100644
--- a/test/Sema/builtins-arm.c
+++ b/test/Sema/builtins-arm.c
@@ -1,15 +1,15 @@
-// RUN: %clang_cc1 -triple armv7 -fsyntax-only -verify -DTEST0 %s
-// RUN: %clang_cc1 -triple armv7 -fsyntax-only -verify -DTEST1 %s
+// RUN: %clang_cc1 -triple armv7 -fsyntax-only -verify %s
// RUN: %clang_cc1 -triple armv7 -target-abi apcs-gnu \
-// RUN: -fsyntax-only -verify -DTEST1 %s
+// RUN: -fsyntax-only -verify %s
-#ifdef TEST0
-void __clear_cache(char*, char*);
-#endif
+void f(void *a, void *b) {
+ __clear_cache(); // expected-error {{too few arguments to function call, expected 2, have 0}} // expected-note {{'__clear_cache' is a builtin with type 'void (void *, void *)}}
+ __clear_cache(a); // expected-error {{too few arguments to function call, expected 2, have 1}}
+ __clear_cache(a, b);
+}
-#ifdef TEST1
+void __clear_cache(char*, char*); // expected-error {{conflicting types for '__clear_cache'}}
void __clear_cache(void*, void*);
-#endif
#if defined(__ARM_PCS) || defined(__ARM_EABI__)
// va_list on ARM AAPCS is struct { void* __ap }.
diff --git a/test/Sema/builtins-gnu-mode.c b/test/Sema/builtins-gnu-mode.c
new file mode 100644
index 000000000000..718803eabe2a
--- /dev/null
+++ b/test/Sema/builtins-gnu-mode.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c99 %s
+// PR16138
+// expected-no-diagnostics
+
+int alloca;
+int stpcpy;
+int stpncpy;
+int strdup;
+int strndup;
+int index;
+int rindex;
+int bzero;
+int strcasecmp;
+int strncasecmp;
+int _exit;
+int vfork;
+int _setjmp;
+int __sigsetjmp;
+int sigsetjmp;
+int setjmp_syscall;
+int savectx;
+int qsetjmp;
+int getcontext;
+int _longjmp;
+int siglongjmp;
+int strlcpy;
+int strlcat;
diff --git a/test/Sema/builtins.c b/test/Sema/builtins.c
index d525ac012e11..8ca33c8e7527 100644
--- a/test/Sema/builtins.c
+++ b/test/Sema/builtins.c
@@ -2,7 +2,7 @@
// This test needs to set the target because it uses __builtin_ia32_vec_ext_v4si
int test1(float a, int b) {
- return __builtin_isless(a, b);
+ return __builtin_isless(a, b); // expected-note {{declared here}}
}
int test2(int a, int b) {
return __builtin_islessequal(a, b); // expected-error {{floating point type}}
@@ -191,3 +191,9 @@ void test18() {
ptr = __builtin___strlcpy_chk(dst, src, sizeof(src), sizeof(dst)); // expected-warning {{incompatible integer to pointer conversion}}
ptr = __builtin___strlcat_chk(dst, src, sizeof(src), sizeof(dst)); // expected-warning {{incompatible integer to pointer conversion}}
}
+
+void no_ms_builtins() {
+ __assume(1); // expected-warning {{implicit declaration}}
+ __noop(1); // expected-warning {{implicit declaration}}
+ __debugbreak(); // expected-warning {{implicit declaration}}
+}
diff --git a/test/Sema/c89.c b/test/Sema/c89.c
index a410a626edac..b746d383f306 100644
--- a/test/Sema/c89.c
+++ b/test/Sema/c89.c
@@ -90,7 +90,7 @@ void test16() {
printg("Hello, world!\n"); /* expected-warning {{implicit declaration of function 'printg'}} */
}
-struct x { int x,y[]; }; /* expected-warning {{Flexible array members are a C99-specific feature}} */
+struct x { int x,y[]; }; /* expected-warning {{flexible array members are a C99 feature}} */
/* Duplicated type-qualifiers aren't allowed by C90 */
const const int c_i; /* expected-warning {{duplicate 'const' declaration specifier}} */
@@ -116,3 +116,12 @@ long long ll1 = /* expected-warning {{'long long' is an extension when C99 mode
unsigned long long ull1 = /* expected-warning {{'long long' is an extension when C99 mode is not enabled}} */
42ULL; /* expected-warning {{'long long' is an extension when C99 mode is not enabled}} */
+struct Test17 { int a; };
+struct Test17 test17_aux(void);
+
+void test17(int v, int w) {
+ int a[2] = { v, w }; /* expected-warning {{initializer for aggregate is not a compile-time constant}} */
+ struct Test17 t0 = { v }; /* expected-warning {{initializer for aggregate is not a compile-time constant}} */
+ struct Test17 t1 = test17_aux(); /* this is allowed */
+}
+
diff --git a/test/Sema/callingconv-ms_abi.c b/test/Sema/callingconv-ms_abi.c
new file mode 100644
index 000000000000..64c5970adf1d
--- /dev/null
+++ b/test/Sema/callingconv-ms_abi.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-pc-win32 %s
+
+void __attribute__((ms_abi)) foo(void);
+void (*pfoo)(void) = foo;
+
+void __attribute__((sysv_abi)) bar(void);
+void (*pbar)(void) = bar; // expected-warning{{incompatible pointer types}}
+
+void (__attribute__((sysv_abi)) *pfoo2)(void) = foo; // expected-warning{{incompatible pointer types}}
diff --git a/test/Sema/callingconv-sysv_abi.c b/test/Sema/callingconv-sysv_abi.c
new file mode 100644
index 000000000000..015357d054f7
--- /dev/null
+++ b/test/Sema/callingconv-sysv_abi.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-pc-linux-gnu %s
+
+void __attribute__((ms_abi)) foo(void);
+void (*pfoo)(void) = foo; // expected-warning{{incompatible pointer types}}
+
+void __attribute__((sysv_abi)) bar(void);
+void (*pbar)(void) = bar;
+
+void (__attribute__((ms_abi)) *pbar2)(void) = bar; // expected-warning{{incompatible pointer types}}
diff --git a/test/Sema/callingconv.c b/test/Sema/callingconv.c
index e487020c4c53..500c0fbfb275 100644
--- a/test/Sema/callingconv.c
+++ b/test/Sema/callingconv.c
@@ -1,12 +1,13 @@
// RUN: %clang_cc1 %s -fsyntax-only -triple i386-unknown-unknown -verify
+// RUN: %clang_cc1 %s -fsyntax-only -triple i386-unknown-unknown -fms-compatibility -DWIN -verify
-void __attribute__((fastcall)) foo(float *a) {
+void __attribute__((fastcall)) foo(float *a) {
}
-void __attribute__((stdcall)) bar(float *a) {
+void __attribute__((stdcall)) bar(float *a) {
}
-void __attribute__((fastcall(1))) baz(float *a) { // expected-error {{attribute takes no arguments}}
+void __attribute__((fastcall(1))) baz(float *a) { // expected-error {{'fastcall' attribute takes no arguments}}
}
void __attribute__((fastcall)) test0() { // expected-error {{function with no prototype cannot use fastcall calling convention}}
@@ -15,12 +16,16 @@ void __attribute__((fastcall)) test0() { // expected-error {{function with no pr
void __attribute__((fastcall)) test1(void) {
}
-void __attribute__((fastcall)) test2(int a, ...) { // expected-error {{variadic function cannot use fastcall calling convention}}
+void __attribute__((fastcall)) test2(int a, ...) { // expected-warning {{fastcall calling convention ignored on variadic function}}
+}
+void __attribute__((stdcall)) test3(int a, ...) { // expected-warning {{stdcall calling convention ignored on variadic function}}
+}
+void __attribute__((thiscall)) test4(int a, ...) { // expected-error {{variadic function cannot use thiscall calling convention}}
}
void __attribute__((cdecl)) ctest0() {}
-void __attribute__((cdecl(1))) ctest1(float x) {} // expected-error {{attribute takes no arguments}}
+void __attribute__((cdecl(1))) ctest1(float x) {} // expected-error {{'cdecl' attribute takes no arguments}}
void (__attribute__((fastcall)) *pfoo)(float*) = foo;
@@ -36,10 +41,11 @@ void (__attribute__((cdecl)) *pctest2)() = ctest2;
typedef void (__attribute__((fastcall)) *Handler) (float *);
Handler H = foo;
-int __attribute__((pcs("aapcs", "aapcs"))) pcs1(void); // expected-error {{attribute takes one argument}}
-int __attribute__((pcs())) pcs2(void); // expected-error {{attribute takes one argument}}
-int __attribute__((pcs(pcs1))) pcs3(void); // expected-error {{attribute takes one argument}}
-int __attribute__((pcs(0))) pcs4(void); // expected-error {{'pcs' attribute requires parameter 1 to be a string}}
+int __attribute__((pcs("aapcs", "aapcs"))) pcs1(void); // expected-error {{'pcs' attribute takes one argument}}
+int __attribute__((pcs())) pcs2(void); // expected-error {{'pcs' attribute takes one argument}}
+int __attribute__((pcs(pcs1))) pcs3(void); // expected-error {{'pcs' attribute requires a string}} \
+ // expected-error {{invalid PCS type}}
+int __attribute__((pcs(0))) pcs4(void); // expected-error {{'pcs' attribute requires a string}}
/* These are ignored because the target is i386 and not ARM */
int __attribute__((pcs("aapcs"))) pcs5(void); // expected-warning {{calling convention 'pcs' ignored for this target}}
int __attribute__((pcs("aapcs-vfp"))) pcs6(void); // expected-warning {{calling convention 'pcs' ignored for this target}}
@@ -56,3 +62,7 @@ PROC __attribute__((cdecl)) ctest4(const char *x) {}
void __attribute__((pnaclcall)) pnaclfunc(float *a) {} // expected-warning {{calling convention 'pnaclcall' ignored for this target}}
void __attribute__((intel_ocl_bicc)) inteloclbifunc(float *a) {}
+
+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}}
diff --git a/test/Sema/captured-statements.c b/test/Sema/captured-statements.c
index 9285a7802d50..86e9273944bf 100644
--- a/test/Sema/captured-statements.c
+++ b/test/Sema/captured-statements.c
@@ -49,29 +49,29 @@ void test_nest() {
}
void test_nest_block() {
- __block int x;
+ __block int x; // expected-note {{'x' declared here}}
int y;
^{
int z;
#pragma clang __debug captured
{
- x = y; // OK
+ x = y; // expected-error{{__block variable 'x' cannot be captured in a captured statement}}
y = z; // expected-error{{variable is not assignable (missing __block type specifier)}}
z = y; // OK
}
}();
- __block int a;
+ __block int a; // expected-note 2 {{'a' declared here}}
int b;
#pragma clang __debug captured
{
__block int c;
int d;
^{
- a = b; // OK
- a = c; // OK
+ a = b; // expected-error{{__block variable 'a' cannot be captured in a captured statement}}
b = d; // OK - Consistent with block inside a lambda
- c = a; // OK
+ c = a; // expected-error{{__block variable 'a' cannot be captured in a captured statement}}
+ c = d; // OK
d = b; // expected-error{{variable is not assignable (missing __block type specifier)}}
}();
}
diff --git a/test/Sema/carbon.c b/test/Sema/carbon.c
index 045d72c86aed..0498116dd181 100644
--- a/test/Sema/carbon.c
+++ b/test/Sema/carbon.c
@@ -1,5 +1,4 @@
-// RUN: %clang -fsyntax-only %s -print-stats
+// RUN: %clang -fsyntax-only %s
#ifdef __APPLE__
#include <Carbon/Carbon.h>
#endif
-
diff --git a/test/Sema/cast.c b/test/Sema/cast.c
index 25ef1d03a4fe..7971163c12d0 100644
--- a/test/Sema/cast.c
+++ b/test/Sema/cast.c
@@ -54,6 +54,14 @@ void testInt(Int v) {
(void) (CDouble) v;
(void) (VoidPtr) v; // expected-warning{{cast to 'VoidPtr' (aka 'void *') from smaller integer type 'Int' (aka 'int')}}
(void) (CharPtr) v; // expected-warning{{cast to 'CharPtr' (aka 'char *') from smaller integer type 'Int' (aka 'int')}}
+
+ // Test that casts to void* can be controlled separately
+ // from other -Wint-to-pointer-cast warnings.
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wint-to-void-pointer-cast"
+ (void) (VoidPtr) v; // no-warning
+ (void) (CharPtr) v; // expected-warning{{cast to 'CharPtr' (aka 'char *') from smaller integer type 'Int' (aka 'int')}}
+#pragma clang diagnostic pop
}
void testLong(Long v) {
diff --git a/test/Sema/constant-builtins-2.c b/test/Sema/constant-builtins-2.c
index 13d81fe13cbf..d2d221c5e12b 100644
--- a/test/Sema/constant-builtins-2.c
+++ b/test/Sema/constant-builtins-2.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
// Math stuff
@@ -37,10 +37,126 @@ float g16 = __builtin_copysign(1.0, -1.0);
double g17 = __builtin_copysignf(1.0f, -1.0f);
long double g18 = __builtin_copysignl(1.0L, -1.0L);
+char classify_nan [__builtin_fpclassify(+1, -1, -1, -1, -1, __builtin_nan(""))];
+char classify_snan [__builtin_fpclassify(+1, -1, -1, -1, -1, __builtin_nans(""))];
+char classify_inf [__builtin_fpclassify(-1, +1, -1, -1, -1, __builtin_inf())];
+char classify_neg_inf [__builtin_fpclassify(-1, +1, -1, -1, -1, -__builtin_inf())];
+char classify_normal [__builtin_fpclassify(-1, -1, +1, -1, -1, 1.539)];
+char classify_normal2 [__builtin_fpclassify(-1, -1, +1, -1, -1, 1e-307)];
+char classify_denorm [__builtin_fpclassify(-1, -1, -1, +1, -1, 1e-308)];
+char classify_denorm2 [__builtin_fpclassify(-1, -1, -1, +1, -1, -1e-308)];
+char classify_zero [__builtin_fpclassify(-1, -1, -1, -1, +1, 0.0)];
+char classify_neg_zero[__builtin_fpclassify(-1, -1, -1, -1, +1, -0.0)];
+
+char isinf_sign_noninf1[__builtin_isinf_sign(-0.0) == 0 ? 1 : -1];
+char isinf_sign_noninf2[__builtin_isinf_sign(1e307) == 0 ? 1 : -1];
+char isinf_sign_noninf3[__builtin_isinf_sign(__builtin_nan("")) == 0 ? 1 : -1];
+char isinf_sign_noninf4[__builtin_isinf_sign(-436.) == 0 ? 1 : -1];
+char isinf_sign_inf [__builtin_isinf_sign(__builtin_inf()) == 1 ? 1 : -1];
+char isinf_sign_neg_inf[__builtin_isinf_sign(-__builtin_inf()) == -1 ? 1 : -1];
+
+char isinf_inf_pos[__builtin_isinf(__builtin_inf()) ? 1 : -1];
+char isinf_pos [!__builtin_isinf(1.0) ? 1 : -1];
+char isinf_normf [!__builtin_isinf(1e-37f) ? 1 : -1];
+char isinf_denormf[!__builtin_isinf(1e-38f) ? 1 : -1];
+char isinf_norm [!__builtin_isinf(1e-307) ? 1 : -1];
+char isinf_denorm [!__builtin_isinf(1e-308) ? 1 : -1];
+char isinf_zero [!__builtin_isinf(0.0) ? 1 : -1];
+char isinf_negzero[!__builtin_isinf(-0.0) ? 1 : -1];
+char isinf_neg [!__builtin_isinf(-1.0) ? 1 : -1];
+char isinf_inf_neg[__builtin_isinf(-__builtin_inf()) ? 1 : -1];
+char isinf_nan [!__builtin_isinf(__builtin_nan("")) ? 1 : -1];
+char isinf_snan [!__builtin_isinf(__builtin_nans("")) ? 1 : -1];
+
+char isfinite_inf_pos[!__builtin_isfinite(__builtin_inf()) ? 1 : -1];
+char isfinite_pos [__builtin_isfinite(1.0) ? 1 : -1];
+char isfinite_normf [__builtin_isfinite(1e-37f) ? 1 : -1];
+char isfinite_denormf[__builtin_isfinite(1e-38f) ? 1 : -1];
+char isfinite_norm [__builtin_isfinite(1e-307) ? 1 : -1];
+char isfinite_denorm [__builtin_isfinite(1e-308) ? 1 : -1];
+char isfinite_zero [__builtin_isfinite(0.0) ? 1 : -1];
+char isfinite_negzero[__builtin_isfinite(-0.0) ? 1 : -1];
+char isfinite_neg [__builtin_isfinite(-1.0) ? 1 : -1];
+char isfinite_inf_neg[!__builtin_isfinite(-__builtin_inf()) ? 1 : -1];
+char isfinite_nan [!__builtin_isfinite(__builtin_nan("")) ? 1 : -1];
+char isfinite_snan [!__builtin_isfinite(__builtin_nans("")) ? 1 : -1];
+
+char isnan_inf_pos[!__builtin_isnan(__builtin_inf()) ? 1 : -1];
+char isnan_pos [!__builtin_isnan(1.0) ? 1 : -1];
+char isnan_normf [!__builtin_isnan(1e-37f) ? 1 : -1];
+char isnan_denormf[!__builtin_isnan(1e-38f) ? 1 : -1];
+char isnan_norm [!__builtin_isnan(1e-307) ? 1 : -1];
+char isnan_denorm [!__builtin_isnan(1e-308) ? 1 : -1];
+char isnan_zero [!__builtin_isnan(0.0) ? 1 : -1];
+char isnan_negzero[!__builtin_isnan(-0.0) ? 1 : -1];
+char isnan_neg [!__builtin_isnan(-1.0) ? 1 : -1];
+char isnan_inf_neg[!__builtin_isnan(-__builtin_inf()) ? 1 : -1];
+char isnan_nan [__builtin_isnan(__builtin_nan("")) ? 1 : -1];
+char isnan_snan [__builtin_isnan(__builtin_nans("")) ? 1 : -1];
+
+char isnormal_inf_pos[!__builtin_isnormal(__builtin_inf()) ? 1 : -1];
+char isnormal_pos [__builtin_isnormal(1.0) ? 1 : -1];
+char isnormal_normf [__builtin_isnormal(1e-37f) ? 1 : -1];
+char isnormal_denormf[!__builtin_isnormal(1e-38f) ? 1 : -1];
+char isnormal_norm [__builtin_isnormal(1e-307) ? 1 : -1];
+char isnormal_denorm [!__builtin_isnormal(1e-308) ? 1 : -1];
+char isnormal_zero [!__builtin_isnormal(0.0) ? 1 : -1];
+char isnormal_negzero[!__builtin_isnormal(-0.0) ? 1 : -1];
+char isnormal_neg [__builtin_isnormal(-1.0) ? 1 : -1];
+char isnormal_inf_neg[!__builtin_isnormal(-__builtin_inf()) ? 1 : -1];
+char isnormal_nan [!__builtin_isnormal(__builtin_nan("")) ? 1 : -1];
+char isnormal_snan [!__builtin_isnormal(__builtin_nans("")) ? 1 : -1];
+
//double g19 = __builtin_powi(2.0, 4);
//float g20 = __builtin_powif(2.0f, 4);
//long double g21 = __builtin_powil(2.0L, 4);
+#define BITSIZE(x) (sizeof(x) * 8)
+char g22[__builtin_clz(1) == BITSIZE(int) - 1 ? 1 : -1];
+char g23[__builtin_clz(7) == BITSIZE(int) - 3 ? 1 : -1];
+char g24[__builtin_clz(1 << (BITSIZE(int) - 1)) == 0 ? 1 : -1];
+int g25 = __builtin_clz(0); // expected-error {{not a compile-time constant}}
+char g26[__builtin_clzl(0xFL) == BITSIZE(long) - 4 ? 1 : -1];
+char g27[__builtin_clzll(0xFFLL) == BITSIZE(long long) - 8 ? 1 : -1];
+
+char g28[__builtin_ctz(1) == 0 ? 1 : -1];
+char g29[__builtin_ctz(8) == 3 ? 1 : -1];
+char g30[__builtin_ctz(1 << (BITSIZE(int) - 1)) == BITSIZE(int) - 1 ? 1 : -1];
+int g31 = __builtin_ctz(0); // expected-error {{not a compile-time constant}}
+char g32[__builtin_ctzl(0x10L) == 4 ? 1 : -1];
+char g33[__builtin_ctzll(0x100LL) == 8 ? 1 : -1];
+
+char g34[__builtin_popcount(0) == 0 ? 1 : -1];
+char g35[__builtin_popcount(0xF0F0) == 8 ? 1 : -1];
+char g36[__builtin_popcount(~0) == BITSIZE(int) ? 1 : -1];
+char g37[__builtin_popcount(~0L) == BITSIZE(int) ? 1 : -1];
+char g38[__builtin_popcountl(0L) == 0 ? 1 : -1];
+char g39[__builtin_popcountl(0xF0F0L) == 8 ? 1 : -1];
+char g40[__builtin_popcountl(~0L) == BITSIZE(long) ? 1 : -1];
+char g41[__builtin_popcountll(0LL) == 0 ? 1 : -1];
+char g42[__builtin_popcountll(0xF0F0LL) == 8 ? 1 : -1];
+char g43[__builtin_popcountll(~0LL) == BITSIZE(long long) ? 1 : -1];
+
+char g44[__builtin_parity(0) == 0 ? 1 : -1];
+char g45[__builtin_parity(0xb821) == 0 ? 1 : -1];
+char g46[__builtin_parity(0xb822) == 0 ? 1 : -1];
+char g47[__builtin_parity(0xb823) == 1 ? 1 : -1];
+char g48[__builtin_parity(0xb824) == 0 ? 1 : -1];
+char g49[__builtin_parity(0xb825) == 1 ? 1 : -1];
+char g50[__builtin_parity(0xb826) == 1 ? 1 : -1];
+char g51[__builtin_parity(~0) == 0 ? 1 : -1];
+char g52[__builtin_parityl(1L << (BITSIZE(long) - 1)) == 1 ? 1 : -1];
+char g53[__builtin_parityll(1LL << (BITSIZE(long long) - 1)) == 1 ? 1 : -1];
+
+char g54[__builtin_ffs(0) == 0 ? 1 : -1];
+char g55[__builtin_ffs(1) == 1 ? 1 : -1];
+char g56[__builtin_ffs(0xfbe71) == 1 ? 1 : -1];
+char g57[__builtin_ffs(0xfbe70) == 5 ? 1 : -1];
+char g58[__builtin_ffs(1U << (BITSIZE(int) - 1)) == BITSIZE(int) ? 1 : -1];
+char g59[__builtin_ffsl(0x10L) == 5 ? 1 : -1];
+char g60[__builtin_ffsll(0x100LL) == 9 ? 1 : -1];
+#undef BITSIZE
+
// GCC misc stuff
extern int f();
diff --git a/test/Sema/convertvector.c b/test/Sema/convertvector.c
new file mode 100644
index 000000000000..ccdd87f9e40c
--- /dev/null
+++ b/test/Sema/convertvector.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef double vector4double __attribute__((__vector_size__(32)));
+typedef float vector8float __attribute__((__vector_size__(32)));
+
+vector8float foo1(vector4double x) {
+ return __builtin_convertvector(x, vector8float); // expected-error {{same number of elements}}
+}
+
+float foo2(vector4double x) {
+ return __builtin_convertvector(x, float); // expected-error {{must be a vector type}}
+}
+
+vector8float foo3(double x) {
+ return __builtin_convertvector(x, vector8float); // expected-error {{must be a vector}}
+}
+
diff --git a/test/Sema/declspec.c b/test/Sema/declspec.c
index 30c009201cef..d810632eeea5 100644
--- a/test/Sema/declspec.c
+++ b/test/Sema/declspec.c
@@ -36,3 +36,16 @@ void test2() {}
struct test3s {
} // expected-error {{expected ';' after struct}}
typedef int test3g;
+
+// PR8264
+const const int pr8264_1 = 0; // expected-warning {{duplicate 'const' declaration specifier}}
+volatile volatile int pr8264_2; // expected-warning {{duplicate 'volatile' declaration specifier}}
+char * restrict restrict pr8264_3; // expected-warning {{duplicate 'restrict' declaration specifier}}
+
+extern extern int pr8264_4; // expected-warning {{duplicate 'extern' declaration specifier}}
+void pr8264_5() {
+ register register int x; // expected-warning {{duplicate 'register' declaration specifier}}
+}
+
+inline inline void pr8264_6() {} // expected-warning {{duplicate 'inline' declaration specifier}}
+_Noreturn _Noreturn void pr8264_7(); // expected-warning {{duplicate '_Noreturn' declaration specifier}}
diff --git a/test/Sema/designated-initializers.c b/test/Sema/designated-initializers.c
index c9a8482e85db..6630da67c5bd 100644
--- a/test/Sema/designated-initializers.c
+++ b/test/Sema/designated-initializers.c
@@ -137,7 +137,6 @@ void test() {
};
}
-// FIXME: How do we test that this initializes the long properly?
union { char c; long l; } u1 = { .l = 0xFFFF };
extern float global_float;
@@ -223,6 +222,55 @@ struct Enigma enigma = {
};
+/// PR16644
+typedef union {
+ struct {
+ int zero;
+ int one;
+ int two;
+ int three;
+ } a;
+ int b[4];
+} union_16644_t;
+
+union_16644_t union_16644_instance_0 =
+{
+ .b[0] = 0, // expected-note{{previous}}
+ .a.one = 1, // expected-warning{{overrides}} expected-note{{previous}}
+ .b[2] = 2, // expected-warning{{overrides}} expected-note{{previous}}
+ .a.three = 3, // expected-warning{{overrides}}
+};
+
+union_16644_t union_16644_instance_1 =
+{
+ .a.three = 13, // expected-note{{previous}}
+ .b[2] = 12, // expected-warning{{overrides}} expected-note{{previous}}
+ .a.one = 11, // expected-warning{{overrides}} expected-note{{previous}}
+ .b[0] = 10, // expected-warning{{overrides}}
+};
+
+union_16644_t union_16644_instance_2 =
+{
+ .a.one = 21, // expected-note{{previous}}
+ .b[1] = 20, // expected-warning{{overrides}}
+};
+
+union_16644_t union_16644_instance_3 =
+{
+ .b[1] = 30, // expected-note{{previous}}
+ .a = { // expected-warning{{overrides}}
+ .one = 31
+ }
+};
+
+union_16644_t union_16644_instance_4[2] =
+{
+ [0].a.one = 2,
+ [1].a.zero = 3,// expected-note{{previous}}
+ [0].a.zero = 5,
+ [1].b[1] = 4 // expected-warning{{overrides}}
+};
+
/// PR4073
/// Should use evaluate to fold aggressively and emit a warning if not an ice.
extern int crazy_x;
@@ -277,3 +325,19 @@ struct ds ds2 = { { {
.a = 0,
.b = 1 // expected-error{{field designator 'b' does not refer to any field}}
} } };
+
+// Check initializer override warnings overriding a character in a string
+struct overwrite_string_struct {
+ char L[6];
+ int M;
+} overwrite_string[] = {
+ { { "foo" }, 1 }, // expected-note {{previous initialization is here}}
+ [0].L[2] = 'x' // expected-warning{{initializer overrides prior initialization of this subobject}}
+};
+struct overwrite_string_struct2 {
+ char L[6];
+ int M;
+} overwrite_string2[] = {
+ { { "foo" }, 1 },
+ [0].L[4] = 'x' // no-warning
+ };
diff --git a/test/Sema/dllimport-dllexport.c b/test/Sema/dllimport-dllexport.c
index 00c9df594b6f..80810d696e8c 100644
--- a/test/Sema/dllimport-dllexport.c
+++ b/test/Sema/dllimport-dllexport.c
@@ -41,3 +41,8 @@ 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/empty1.c b/test/Sema/empty1.c
new file mode 100644
index 000000000000..de922f775ef7
--- /dev/null
+++ b/test/Sema/empty1.c
@@ -0,0 +1,85 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -Wc++-compat
+
+struct emp_1 { // expected-warning {{empty struct has size 0 in C, size 1 in C++}}
+};
+
+union emp_2 { // expected-warning {{empty union has size 0 in C, size 1 in C++}}
+};
+
+struct emp_3 { // expected-warning {{struct has size 0 in C, size 1 in C++}}
+ int : 0;
+};
+
+union emp_4 { // expected-warning {{union has size 0 in C, size 1 in C++}}
+ int : 0;
+};
+
+struct emp_5 { // expected-warning {{struct has size 0 in C, size 1 in C++}}
+ int : 0;
+ int : 0;
+};
+
+union emp_6 { // expected-warning {{union has size 0 in C, size 1 in C++}}
+ int : 0;
+ int : 0;
+};
+
+struct emp_7 { // expected-warning {{struct has size 0 in C, size 1 in C++}}
+ struct emp_1 f1;
+};
+
+union emp_8 { // expected-warning {{union has size 0 in C, size 1 in C++}}
+ struct emp_1 f1;
+};
+
+struct emp_9 { // expected-warning {{struct has size 0 in C, non-zero size in C++}}
+ struct emp_1 f1;
+ union emp_2 f2;
+};
+
+// Checks for pointer subtraction (PR15683)
+struct emp_1 *func_1p(struct emp_1 *x) { return x - 5; }
+
+int func_1() {
+ struct emp_1 v[1];
+ return v - v; // expected-warning {{subtraction of pointers to type 'struct emp_1' of zero size has undefined behavior}}
+}
+
+int func_2(struct emp_1 *x) {
+ return 1 + x - x; // expected-warning {{subtraction of pointers to type 'struct emp_1' of zero size has undefined behavior}}
+}
+
+int func_3(struct emp_1 *x, struct emp_1 *y) {
+ return x - y; // expected-warning {{subtraction of pointers to type 'struct emp_1' of zero size has undefined behavior}}
+}
+
+int func_4(struct emp_1 *x, const struct emp_1 *y) {
+ return x - y; // expected-warning {{subtraction of pointers to type 'struct emp_1' of zero size has undefined behavior}}
+}
+
+int func_5(volatile struct emp_1 *x, const struct emp_1 *y) {
+ return x - y; // expected-warning {{subtraction of pointers to type 'struct emp_1' of zero size has undefined behavior}}
+}
+
+int func_6() {
+ union emp_2 v[1];
+ return v - v; // expected-warning {{subtraction of pointers to type 'union emp_2' of zero size has undefined behavior}}
+}
+
+struct A; // expected-note {{forward declaration of 'struct A'}}
+
+int func_7(struct A *x, struct A *y) {
+ return x - y; // expected-error {{arithmetic on a pointer to an incomplete type 'struct A'}}
+}
+
+int func_8(struct emp_1 (*x)[10], struct emp_1 (*y)[10]) {
+ return x - y; // expected-warning {{subtraction of pointers to type 'struct emp_1 [10]' of zero size has undefined behavior}}
+}
+
+int func_9(struct emp_1 (*x)[], struct emp_1 (*y)[]) {
+ return x - y; // expected-error {{arithmetic on a pointer to an incomplete type 'struct emp_1 []'}}
+}
+
+int func_10(int (*x)[0], int (*y)[0]) {
+ return x - y; // expected-warning {{subtraction of pointers to type 'int [0]' of zero size has undefined behavior}}
+}
diff --git a/test/Sema/empty2.c b/test/Sema/empty2.c
new file mode 100644
index 000000000000..68da5a8ee8ac
--- /dev/null
+++ b/test/Sema/empty2.c
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic
+
+struct emp_1 { // expected-warning {{empty struct is a GNU extension}}
+};
+
+union emp_2 { // expected-warning {{empty union is a GNU extension}}
+};
+
+struct emp_3 { // expected-warning {{struct without named members is a GNU extension}}
+ int : 0;
+};
+
+union emp_4 { // expected-warning {{union without named members is a GNU extension}}
+ int : 0;
+};
+
+struct emp_5 { // expected-warning {{struct without named members is a GNU extension}}
+ int : 0;
+ int : 0;
+};
+
+union emp_6 { // expected-warning {{union without named members is a GNU extension}}
+ int : 0;
+ int : 0;
+};
+
+struct nonamed_1 { // expected-warning {{struct without named members is a GNU extension}}
+ int : 4;
+};
+
+union nonamed_2 { // expected-warning {{union without named members is a GNU extension}}
+ int : 4;
+};
+
+struct nonamed_3 { // expected-warning {{struct without named members is a GNU extension}}
+ int : 4;
+ unsigned int : 4;
+};
+
+union nonamed_4 { // expected-warning {{union without named members is a GNU extension}}
+ int : 4;
+ unsigned int : 4;
+};
diff --git a/test/Sema/enum-increment.c b/test/Sema/enum-increment.c
new file mode 100644
index 000000000000..baaa3489b958
--- /dev/null
+++ b/test/Sema/enum-increment.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify
+// expected-no-diagnostics
+enum A { A1, A2, A3 };
+typedef enum A A;
+void test() {
+ A a;
+ a++;
+ a--;
+ ++a;
+ --a;
+ a = a + 1;
+ a = a - 1;
+}
diff --git a/test/Sema/ext_vector_casts.c b/test/Sema/ext_vector_casts.c
index 848ec1f106f6..66004b03ff8c 100644
--- a/test/Sema/ext_vector_casts.c
+++ b/test/Sema/ext_vector_casts.c
@@ -1,10 +1,13 @@
-// RUN: %clang_cc1 -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 %s
typedef __attribute__(( ext_vector_type(2) )) float float2;
typedef __attribute__(( ext_vector_type(4) )) int int4;
typedef __attribute__(( ext_vector_type(8) )) short short8;
typedef __attribute__(( ext_vector_type(4) )) float float4;
typedef float t3 __attribute__ ((vector_size (16)));
+typedef __typeof__(sizeof(int)) size_t;
+typedef unsigned long ulong2 __attribute__ ((ext_vector_type(2)));
+typedef size_t stride4 __attribute__((ext_vector_type(4)));
static void test() {
float2 vec2;
@@ -50,3 +53,24 @@ void inc(float2 f2) {
f2++; // expected-error{{cannot increment value of type 'float2'}}
__real f2; // expected-error{{invalid type 'float2' to __real operator}}
}
+
+typedef enum
+{
+ uchar_stride = 1,
+ uchar4_stride = 4,
+ ushort4_stride = 8,
+ short4_stride = 8,
+ uint4_stride = 16,
+ int4_stride = 16,
+ float4_stride = 16,
+} PixelByteStride;
+
+stride4 RDar15091442_get_stride4(int4 x, PixelByteStride pixelByteStride);
+stride4 RDar15091442_get_stride4(int4 x, PixelByteStride pixelByteStride)
+{
+ stride4 stride;
+ // This previously caused an assertion failure.
+ stride.lo = ((ulong2) x) * pixelByteStride; // no-warning
+ return stride;
+}
+
diff --git a/test/Sema/extern-redecl.c b/test/Sema/extern-redecl.c
index e9a4c571bd2d..6bdb66e07f55 100644
--- a/test/Sema/extern-redecl.c
+++ b/test/Sema/extern-redecl.c
@@ -62,3 +62,27 @@ void test5c() {
void *(*_malloc)() = &malloc;
float *(*_calloc)() = &calloc;
}
+
+void test6() {
+ extern int test6_array1[100];
+ extern int test6_array2[100];
+ void test6_fn1(int*);
+ void test6_fn2(int*);
+ {
+ // Types are only merged from visible declarations.
+ char test6_array2;
+ char test6_fn2;
+ {
+ extern int test6_array1[];
+ extern int test6_array2[];
+ (void)sizeof(test6_array1); // ok
+ (void)sizeof(test6_array2); // expected-error {{incomplete type}}
+
+ void test6_fn1();
+ void test6_fn2();
+ test6_fn1(1.2); // expected-error {{passing 'double' to parameter of incompatible type 'int *'}}
+ // FIXME: This is valid, but we should warn on it.
+ test6_fn2(1.2);
+ }
+ }
+}
diff --git a/test/Sema/format-strings-ms.c b/test/Sema/format-strings-ms.c
new file mode 100644
index 000000000000..b89ee421ced8
--- /dev/null
+++ b/test/Sema/format-strings-ms.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility -triple=i386-pc-win32 -pedantic %s
+
+int printf(const char *format, ...) __attribute__((format(printf, 1, 2)));
+
+void signed_test() {
+ short val = 30;
+ printf("val = %I64d\n", val); // expected-warning{{'I64' length modifier is not supported by ISO C}} \
+ // expected-warning{{format specifies type '__int64' (aka 'long long') but the argument has type 'short'}}
+ long long bigval = 30;
+ printf("val = %I32d\n", bigval); // expected-warning{{'I32' length modifier is not supported by ISO C}} \
+ // expected-warning{{format specifies type '__int32' (aka 'int') but the argument has type 'long long'}}
+ printf("val = %Id\n", bigval); // expected-warning{{'I' length modifier is not supported by ISO C}} \
+ // expected-warning{{format specifies type '__int32' (aka 'int') but the argument has type 'long long'}}
+}
+
+void unsigned_test() {
+ unsigned short val = 30;
+ printf("val = %I64u\n", val); // expected-warning{{'I64' length modifier is not supported by ISO C}} \
+ // expected-warning{{format specifies type 'unsigned __int64' (aka 'unsigned long long') but the argument has type 'unsigned short'}}
+ unsigned long long bigval = 30;
+ printf("val = %I32u\n", bigval); // expected-warning{{'I32' length modifier is not supported by ISO C}} \
+ // expected-warning{{format specifies type 'unsigned __int32' (aka 'unsigned int') but the argument has type 'unsigned long long'}}
+ printf("val = %Iu\n", bigval); // expected-warning{{'I' length modifier is not supported by ISO C}} \
+ // expected-warning{{format specifies type 'unsigned __int32' (aka 'unsigned int') but the argument has type 'unsigned long long'}}
+}
diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c
index ba1272148973..6da027e02c65 100644
--- a/test/Sema/format-strings.c
+++ b/test/Sema/format-strings.c
@@ -591,3 +591,13 @@ void test_qualifiers(volatile int *vip, const int *cip,
printf("%n", (ip_t)0); // No warning.
printf("%n", (cip_t)0); // expected-warning{{format specifies type 'int *' but the argument has type 'cip_t' (aka 'const int *')}}
}
+
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+#pragma GCC diagnostic warning "-Wformat-security"
+// <rdar://problem/14178260>
+extern void test_format_security_extra_args(const char*, int, ...)
+ __attribute__((__format__(__printf__, 1, 3)));
+void test_format_security_pos(char* string) {
+ test_format_security_extra_args(string, 5); // expected-warning {{format string is not a string literal (potentially insecure)}}
+}
+#pragma GCC diagnostic warning "-Wformat-nonliteral"
diff --git a/test/Sema/freemain.c b/test/Sema/freemain.c
index eed644d483ac..ff000c62cc70 100644
--- a/test/Sema/freemain.c
+++ b/test/Sema/freemain.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -ffreestanding %s
+// RUN: %clang_cc1 -triple i686-pc-openbsd -fsyntax-only -verify -ffreestanding %s
// Tests that -ffreestanding disables all special treatment of main().
diff --git a/test/Sema/function.c b/test/Sema/function.c
index bbf81a56cbb6..81d303c27f62 100644
--- a/test/Sema/function.c
+++ b/test/Sema/function.c
@@ -103,3 +103,13 @@ int func_e(int x) {
}
return x + 3;
}
+
+void decays(int a[3][3]); // expected-note {{passing argument to parameter 'a' here}}
+void no_decay(int (*a)[3]); // expected-note {{passing argument to parameter 'a' here}}
+
+void t22(int *ptr, int (*array)[3]) {
+ decays(ptr); // expected-warning {{incompatible pointer types passing 'int *' to parameter of type 'int (*)[3]'}}
+ no_decay(ptr); // expected-warning {{incompatible pointer types passing 'int *' to parameter of type 'int (*)[3]'}}
+ decays(array);
+ no_decay(array);
+}
diff --git a/test/Sema/gnu-flags.c b/test/Sema/gnu-flags.c
new file mode 100644
index 000000000000..e7588b7b371e
--- /dev/null
+++ b/test/Sema/gnu-flags.c
@@ -0,0 +1,171 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DNONE -Wno-gnu
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wgnu
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wno-gnu \
+// RUN: -Wgnu-alignof-expression -Wgnu-case-range -Wgnu-complex-integer -Wgnu-conditional-omitted-operand \
+// RUN: -Wgnu-empty-initializer -Wgnu-label-as-value -Wgnu-statement-expression \
+// RUN: -Wgnu-compound-literal-initializer -Wgnu-flexible-array-initializer \
+// RUN: -Wgnu-redeclared-enum -Wgnu-folding-constant -Wgnu-empty-struct \
+// RUN: -Wgnu-union-cast -Wgnu-variable-sized-type-not-at-end
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DNONE -Wgnu \
+// RUN: -Wno-gnu-alignof-expression -Wno-gnu-case-range -Wno-gnu-complex-integer -Wno-gnu-conditional-omitted-operand \
+// RUN: -Wno-gnu-empty-initializer -Wno-gnu-label-as-value -Wno-gnu-statement-expression \
+// RUN: -Wno-gnu-compound-literal-initializer -Wno-gnu-flexible-array-initializer \
+// RUN: -Wno-gnu-redeclared-enum -Wno-gnu-folding-constant -Wno-gnu-empty-struct \
+// RUN: -Wno-gnu-union-cast -Wno-gnu-variable-sized-type-not-at-end
+// Additional disabled tests:
+// %clang_cc1 -fsyntax-only -verify %s -DALIGNOF -Wno-gnu -Wgnu-alignof-expression
+// %clang_cc1 -fsyntax-only -verify %s -DCASERANGE -Wno-gnu -Wgnu-case-range
+// %clang_cc1 -fsyntax-only -verify %s -DCOMPLEXINT -Wno-gnu -Wgnu-complex-integer
+// %clang_cc1 -fsyntax-only -verify %s -DOMITTEDOPERAND -Wno-gnu -Wgnu-conditional-omitted-operand
+// %clang_cc1 -fsyntax-only -verify %s -DEMPTYINIT -Wno-gnu -Wgnu-empty-initializer
+// %clang_cc1 -fsyntax-only -verify %s -DLABELVALUE -Wno-gnu -Wgnu-label-as-value
+// %clang_cc1 -fsyntax-only -verify %s -DSTATEMENTEXP -Wno-gnu -Wgnu-statement-expression
+// %clang_cc1 -fsyntax-only -verify %s -DCOMPOUNDLITERALINITIALIZER -Wno-gnu -Wgnu-compound-literal-initializer
+// %clang_cc1 -fsyntax-only -verify %s -DFLEXIBLEARRAYINITIALIZER -Wno-gnu -Wgnu-flexible-array-initializer
+// %clang_cc1 -fsyntax-only -verify %s -DREDECLAREDENUM -Wno-gnu -Wgnu-redeclared-enum
+// %clang_cc1 -fsyntax-only -verify %s -DUNIONCAST -Wno-gnu -Wgnu-union-cast
+// %clang_cc1 -fsyntax-only -verify %s -DVARIABLESIZEDTYPENOTATEND -Wno-gnu -Wgnu-variable-sized-type-not-at-end
+// %clang_cc1 -fsyntax-only -verify %s -DFOLDINGCONSTANT -Wno-gnu -Wgnu-folding-constant
+// %clang_cc1 -fsyntax-only -verify %s -DEMPTYSTRUCT -Wno-gnu -Wgnu-empty-struct
+
+#if NONE
+// expected-no-diagnostics
+#endif
+
+
+#if ALL || ALIGNOF
+// expected-warning@+4 {{'_Alignof' applied to an expression is a GNU extension}}
+#endif
+
+char align;
+_Static_assert(_Alignof(align) > 0, "align's alignment is wrong");
+
+
+#if ALL || CASERANGE
+// expected-warning@+5 {{use of GNU case range extension}}
+#endif
+
+void caserange(int x) {
+ switch (x) {
+ case 42 ... 44: ;
+ }
+}
+
+
+#if ALL || COMPLEXINT
+// expected-warning@+3 {{complex integer types are a GNU extension}}
+#endif
+
+_Complex short int complexint;
+
+
+#if ALL || OMITTEDOPERAND
+// expected-warning@+3 {{use of GNU ?: conditional expression extension, omitting middle operand}}
+#endif
+
+static const char* omittedoperand = (const char*)0 ?: "Null";
+
+
+#if ALL || EMPTYINIT
+// expected-warning@+3 {{use of GNU empty initializer extension}}
+#endif
+
+struct { int x; } emptyinit = {};
+
+
+#if ALL || LABELVALUE
+// expected-warning@+6 {{use of GNU address-of-label extension}}
+// expected-warning@+7 {{use of GNU indirect-goto extension}}
+#endif
+
+void labelvalue() {
+ void *ptr;
+ ptr = &&foo;
+foo:
+ goto *ptr;
+}
+
+
+#if ALL || STATEMENTEXP
+// expected-warning@+5 {{use of GNU statement expression extension}}
+#endif
+
+void statementexp()
+{
+ int a = ({ 1; });
+}
+
+
+#if ALL || COMPOUNDLITERALINITIALIZER
+// expected-warning@+4 {{initialization of an array of type 'int [5]' from a compound literal of type 'int [5]' is a GNU extension}}
+#endif
+
+typedef int int5[5];
+int cli[5] = (int[]){1, 2, 3, 4, 5};
+
+
+#if ALL || FLEXIBLEARRAYINITIALIZER
+// expected-note@+6 {{initialized flexible array member 'y' is here}}
+// expected-warning@+6 {{flexible array initialization is a GNU extension}}
+#endif
+
+struct fai {
+ int x;
+ int y[];
+} fai = { 1, { 2, 3, 4 } };
+
+
+#if ALL || FOLDINGCONSTANT
+// expected-warning@+5 {{expression is not an integer constant expression; folding it to a constant is a GNU extension}}
+// expected-warning@+7 {{variable length array folded to constant array as an extension}}
+#endif
+
+enum {
+ fic = (int)(0.75 * 1000 * 1000)
+};
+static const int size = 100;
+void foo(void) { int data[size]; }
+
+#if ALL || REDECLAREDENUM
+// expected-note@+4 {{previous definition is here}}
+// expected-warning@+8 {{redeclaration of already-defined enum 'RE' is a GNU extension}}
+#endif
+
+enum RE {
+ Val1,
+ Val2
+};
+
+enum RE;
+
+
+#if ALL || UNIONCAST
+// expected-warning@+4 {{cast to union type is a GNU extension}}
+#endif
+
+union uc { int i; unsigned : 3; };
+union uc w = (union uc)2;
+
+
+#if ALL || VARIABLESIZEDTYPENOTATEND
+// expected-warning@+8 {{field 'hdr' with variable sized type 'struct vst' not at the end of a struct or class is a GNU extension}}
+#endif
+
+struct vst {
+ short tag_type;
+ char tag_data[];
+};
+struct vstnae {
+ struct vst hdr;
+ char data;
+};
+
+
+#if ALL || EMPTYSTRUCT
+// expected-warning@+4 {{empty struct is a GNU extension}}
+// expected-warning@+4 {{struct without named members is a GNU extension}}
+#endif
+
+const struct {} es;
+struct {int:5;} swnm;
+
diff --git a/test/Sema/init.c b/test/Sema/init.c
index 81a665dc6297..4a5fc558c51b 100644
--- a/test/Sema/init.c
+++ b/test/Sema/init.c
@@ -157,3 +157,6 @@ int PR4386_zed() __attribute((weak));
typedef char strty[10];
struct vortexstruct { strty s; };
struct vortexstruct vortexvar = { "asdf" };
+
+typedef struct { uintptr_t x : 2; } StructWithBitfield;
+StructWithBitfield bitfieldvar = { (uintptr_t)&bitfieldvar }; // expected-error {{initializer element is not a compile-time constant}}
diff --git a/test/Sema/inline.c b/test/Sema/inline.c
index 496e282ecacd..8a3835b71ada 100644
--- a/test/Sema/inline.c
+++ b/test/Sema/inline.c
@@ -83,6 +83,19 @@ extern inline void defineStaticVarInExtern() {
static int y = 0; // ok
}
+// Check behavior of line markers.
+# 1 "XXX.h" 1
+inline int useStaticMainFileInLineMarker() { // expected-note 2 {{use 'static' to give inline function 'useStaticMainFileInLineMarker' internal linkage}}
+ staticFunction(); // expected-warning{{static function 'staticFunction' is used in an inline function with external linkage}}
+ return staticVar; // expected-warning{{static variable 'staticVar' is used in an inline function with external linkage}}
+}
+# 100 "inline.c" 2
+
+inline int useStaticMainFileAfterLineMarker() {
+ staticFunction(); // no-warning
+ return staticVar; // no-warning
+}
+
#endif
diff --git a/test/Sema/member-reference.c b/test/Sema/member-reference.c
index edbbea59ac87..8939fd515709 100644
--- a/test/Sema/member-reference.c
+++ b/test/Sema/member-reference.c
@@ -1,5 +1,4 @@
// RUN: %clang_cc1 %s -verify -fsyntax-only
-// expected-no-diagnostics
struct simple { int i; };
@@ -19,3 +18,7 @@ void g(void) {
s->x = 1;
s->z = 2;
}
+
+int PR17762(struct simple c) {
+ return c->i; // expected-error {{member reference type 'struct simple' is not a pointer; maybe you meant to use '.'?}}
+}
diff --git a/test/Sema/mips16_attr_allowed.c b/test/Sema/mips16_attr_allowed.c
index 21a94e773f92..c712e902f5fb 100644
--- a/test/Sema/mips16_attr_allowed.c
+++ b/test/Sema/mips16_attr_allowed.c
@@ -2,22 +2,22 @@
void foo32();
void foo16();
-void __attribute__((nomips16)) foo32();
-void __attribute__((mips16)) foo16();
+void __attribute__((nomips16)) foo32();
+void __attribute__((mips16)) foo16();
-void __attribute__((nomips16)) foo32_();
-void __attribute__((mips16)) foo16_();
+void __attribute__((nomips16)) foo32_();
+void __attribute__((mips16)) foo16_();
void foo32_();
void foo16_();
-void foo32__() __attribute__((nomips16));
-void foo32__() __attribute__((mips16));
+void foo32__() __attribute__((nomips16));
+void foo32__() __attribute__((mips16));
-void foo32a() __attribute__((nomips16(xyz))) ; // expected-error {{attribute takes no arguments}}
-void __attribute__((mips16(xyz))) foo16a(); // expected-error {{attribute takes no arguments}}
+void foo32a() __attribute__((nomips16(0))) ; // expected-error {{'nomips16' attribute takes no arguments}}
+void __attribute__((mips16(1))) foo16a(); // expected-error {{'mips16' attribute takes no arguments}}
-void __attribute__((nomips16(1, 2))) foo32b(); // expected-error {{attribute takes no arguments}}
-void __attribute__((mips16(1, 2))) foo16b(); // expected-error {{attribute takes no arguments}}
+void __attribute__((nomips16(1, 2))) foo32b(); // expected-error {{'nomips16' attribute takes no arguments}}
+void __attribute__((mips16(1, 2))) foo16b(); // expected-error {{'mips16' attribute takes no arguments}}
__attribute((nomips16)) int a; // expected-error {{attribute only applies to functions}}
diff --git a/test/Sema/mrtd.c b/test/Sema/mrtd.c
new file mode 100644
index 000000000000..ba1720e8d7dc
--- /dev/null
+++ b/test/Sema/mrtd.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -DMRTD -mrtd -triple i386-unknown-unknown -verify %s
+// RUN: %clang_cc1 -triple i386-unknown-unknown -verify %s
+
+#ifndef MRTD
+// expected-note@+5 {{previous declaration is here}}
+// expected-error@+5 {{function declared 'stdcall' here was previously declared without calling convention}}
+// expected-note@+5 {{previous declaration is here}}
+// expected-error@+5 {{function declared 'stdcall' here was previously declared without calling convention}}
+#endif
+void nonvariadic1(int a, int b, int c);
+void __attribute__((stdcall)) nonvariadic1(int a, int b, int c);
+void nonvariadic2(int a, int b, int c);
+void __attribute__((stdcall)) nonvariadic2(int a, int b, int c) { }
+
+// expected-warning@+2 {{stdcall calling convention ignored on variadic function}}
+void variadic(int a, ...);
+void __attribute__((stdcall)) variadic(int a, ...);
+
+#ifdef MRTD
+// expected-note@+3 {{previous definition is here}}
+// expected-error@+3 {{redefinition of 'a' with a different type: 'void ((*))(int, int) __attribute__((cdecl))' vs 'void (*)(int, int) __attribute__((stdcall))'}}
+#endif
+extern void (*a)(int, int);
+__attribute__((cdecl)) extern void (*a)(int, int);
+
+extern void (*b)(int, ...);
+__attribute__((cdecl)) extern void (*b)(int, ...);
+
+#ifndef MRTD
+// expected-note@+3 {{previous definition is here}}
+// expected-error@+3 {{redefinition of 'c' with a different type: 'void ((*))(int, int) __attribute__((stdcall))' vs 'void (*)(int, int)'}}
+#endif
+extern void (*c)(int, int);
+__attribute__((stdcall)) extern void (*c)(int, int);
+
+// expected-warning@+2 {{stdcall calling convention ignored on variadic function}}
+extern void (*d)(int, ...);
+__attribute__((stdcall)) extern void (*d)(int, ...);
diff --git a/test/Sema/ms-inline-asm.c b/test/Sema/ms-inline-asm.c
index 1916d3463de5..69f234e5e9ae 100644
--- a/test/Sema/ms-inline-asm.c
+++ b/test/Sema/ms-inline-asm.c
@@ -1,4 +1,4 @@
-// REQUIRES: disabled
+// REQUIRES: x86-64-registered-target
// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fasm-blocks -Wno-microsoft -verify -fsyntax-only
void t1(void) {
@@ -13,22 +13,22 @@ void f() {
}
f();
__asm {
- mov eax, 1+=2 // expected-error 2 {{unknown token in expression}}
+ mov eax, 1+=2 // expected-error {{unknown token in expression}}
}
f();
__asm {
- mov eax, 1+++ // expected-error 2 {{unknown token in expression}}
+ mov eax, 1+++ // expected-error {{unknown token in expression}}
}
f();
__asm {
- mov eax, LENGTH bar // expected-error {{Unable to lookup expr!}}
+ mov eax, LENGTH bar // expected-error {{unable to lookup expression}}
}
f();
__asm {
- mov eax, SIZE bar // expected-error {{Unable to lookup expr!}}
+ mov eax, SIZE bar // expected-error {{unable to lookup expression}}
}
f();
__asm {
- mov eax, TYPE bar // expected-error {{Unable to lookup expr!}}
+ mov eax, TYPE bar // expected-error {{unable to lookup expression}}
}
}
diff --git a/test/Sema/ms-keyword-system-header.c b/test/Sema/ms-keyword-system-header.c
new file mode 100644
index 000000000000..b4ff5683cdfd
--- /dev/null
+++ b/test/Sema/ms-keyword-system-header.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fms-extensions -D MS -isystem %S/Inputs %s -fsyntax-only -verify
+// RUN: %clang_cc1 -fms-extensions -D MS -Wno-keyword-compat -I %S/Inputs %s -fsyntax-only -verify
+// RUN: %clang_cc1 -fms-extensions -D MS -D NOT_SYSTEM -I %S/Inputs %s -fsyntax-only -verify
+// RUN: %clang_cc1 -isystem %S/Inputs %s -fsyntax-only -verify
+
+// PR17824: GNU libc uses MS keyword __uptr as an identifier in C mode
+#include <ms-keyword-system-header.h>
+
+void fn() {
+ WS ws;
+ ws.__uptr = 0;
+#ifdef MS
+ // expected-error@-2 {{expected identifier}}
+#else
+ // expected-no-diagnostics
+#endif
+}
diff --git a/test/Sema/ms-wchar.c b/test/Sema/ms-wchar.c
new file mode 100644
index 000000000000..febaf283b338
--- /dev/null
+++ b/test/Sema/ms-wchar.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions -triple i386-pc-win32 %s
+
+// C++ mode with -fno-wchar works the same as C mode for wchar_t.
+// RUN: %clang_cc1 -x c++ -fno-wchar -fsyntax-only -verify -fms-extensions -triple i386-pc-win32 %s
+
+wchar_t f(); // expected-error{{unknown type name 'wchar_t'}}
+
+// __wchar_t is available as an MS extension.
+__wchar_t g = L'a'; // expected-note {{previous}}
+
+// __wchar_t is a distinct type, separate from the target's integer type for wide chars.
+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$}}
+
+// 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$}}
diff --git a/test/Sema/ms_abi-sysv_abi.c b/test/Sema/ms_abi-sysv_abi.c
new file mode 100644
index 000000000000..35a5fad9ceb3
--- /dev/null
+++ b/test/Sema/ms_abi-sysv_abi.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-pc-linux-gnu %s
+
+// CC qualifier can be applied only to functions
+int __attribute__((ms_abi)) var1; // expected-warning{{'ms_abi' only applies to function types; type here is 'int'}}
+int __attribute__((sysv_abi)) var2; // expected-warning{{'sysv_abi' only applies to function types; type here is 'int'}}
+
+// Different CC qualifiers are not compatible
+// FIXME: Should say 'sysv_abi' instead of 'cdecl'
+void __attribute__((ms_abi, sysv_abi)) foo3(void); // expected-error{{cdecl and ms_abi attributes are not compatible}}
+void __attribute__((ms_abi)) foo4(); // expected-note{{previous declaration is here}}
+void __attribute__((sysv_abi)) foo4(void); // expected-error{{function declared 'cdecl' here was previously declared 'ms_abi'}}
+
+void bar(int i, int j) __attribute__((ms_abi, cdecl)); // expected-error{{cdecl and ms_abi attributes are not compatible}}
+void bar2(int i, int j) __attribute__((sysv_abi, cdecl)); // no-error
diff --git a/test/Sema/ms_bitfield_layout.c b/test/Sema/ms_bitfield_layout.c
new file mode 100644
index 000000000000..4a2076c1dbac
--- /dev/null
+++ b/test/Sema/ms_bitfield_layout.c
@@ -0,0 +1,243 @@
+// RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple i686-pc-win32 -cxx-abi microsoft -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: | FileCheck %s
+
+typedef struct A {
+ char x;
+ int a : 22;
+ int : 0;
+ int c : 10;
+ char b : 3;
+ char d: 4;
+ short y;
+} A;
+
+// CHECK: Type: struct A
+// CHECK: Size:128
+// CHECK: Alignment:32
+// CHECK: FieldOffsets: [0, 32, 64, 64, 96, 99, 112]>
+
+typedef struct B {
+ char x;
+ int : 0;
+ short a : 4;
+ char y;
+} B;
+
+// CHECK: Type: struct B
+// CHECK: Size:48
+// CHECK: Alignment:16
+// CHECK: FieldOffsets: [0, 8, 16, 32]>
+
+typedef struct C {
+ char x;
+ short a : 4;
+ int : 0;
+ char y;
+} C;
+
+// CHECK: Type: struct C
+// CHECK: Size:64
+// CHECK: Alignment:32
+// CHECK: FieldOffsets: [0, 16, 32, 32]>
+
+typedef struct D {
+ char x;
+ short : 0;
+ int : 0;
+ char y;
+} D;
+
+// CHECK: Type: struct D
+// CHECK: Size:16
+// CHECK: Alignment:8
+// CHECK: FieldOffsets: [0, 8, 8, 8]>
+
+typedef union E {
+ char x;
+ long long a : 3;
+ int b : 3;
+ long long : 0;
+ short y;
+} E;
+
+// CHECK: Type: union E
+// CHECK: Size:64
+// CHECK: Alignment:16
+// CHECK: FieldOffsets: [0, 0, 0, 0, 0]>
+
+typedef struct F {
+ char x;
+ char a : 3;
+ char b : 3;
+ char c : 3;
+ short d : 6;
+ short e : 6;
+ short f : 6;
+ short g : 11;
+ short h : 11;
+ short i : 11;
+ short y;
+} F;
+
+// CHECK: Type: struct F
+// CHECK: Size:128
+// CHECK: Alignment:16
+// CHECK: FieldOffsets: [0, 8, 11, 16, 32, 38, 48, 64, 80, 96, 112]>
+
+typedef union G {
+ char x;
+ int a : 3;
+ int : 0;
+ long long : 0;
+ short y;
+} G;
+
+// CHECK: Type: union G
+// CHECK: Size:32
+// CHECK: Alignment:16
+// CHECK: FieldOffsets: [0, 0, 0, 0, 0]>
+
+typedef struct H {
+ unsigned short a : 1;
+ unsigned char : 0;
+ unsigned long : 0;
+ unsigned short c : 1;
+} H;
+
+// CHECK: Type: struct H
+// CHECK: Size:32
+// CHECK: Alignment:16
+// CHECK: FieldOffsets: [0, 16, 16, 16]>
+
+#pragma pack(push, 1)
+
+typedef struct A1 {
+ char x;
+ int a : 22;
+ int : 0;
+ int c : 10;
+ char b : 3;
+ char d: 4;
+ short y;
+} A1;
+
+// CHECK: Type: struct A1
+// CHECK: Size:96
+// CHECK: Alignment:8
+// CHECK: FieldOffsets: [0, 8, 40, 40, 72, 75, 80]>
+
+typedef struct B1 {
+ char x;
+ int : 0;
+ short a : 4;
+ char y;
+} B1;
+
+// CHECK: Type: struct B1
+// CHECK: Size:32
+// CHECK: Alignment:8
+// CHECK: FieldOffsets: [0, 8, 8, 24]>
+
+typedef struct C1 {
+ char x;
+ short a : 4;
+ int : 0;
+ char y;
+} C1;
+
+// CHECK: Type: struct C1
+// CHECK: Size:32
+// CHECK: Alignment:8
+// CHECK: FieldOffsets: [0, 8, 24, 24]>
+
+typedef struct D1 {
+ char x;
+ short : 0;
+ int : 0;
+ char y;
+} D1;
+
+// CHECK: Type: struct D1
+// CHECK: Size:16
+// CHECK: Alignment:8
+// CHECK: FieldOffsets: [0, 8, 8, 8]>
+
+typedef union E1 {
+ char x;
+ long long a : 3;
+ int b : 3;
+ long long : 0;
+ short y;
+} E1;
+
+// CHECK: Type: union E1
+// CHECK: Size:64
+// CHECK: Alignment:8
+// CHECK: FieldOffsets: [0, 0, 0, 0, 0]>
+
+typedef struct F1 {
+ char x;
+ char a : 3;
+ char b : 3;
+ char c : 3;
+ short d : 6;
+ short e : 6;
+ short f : 6;
+ short g : 11;
+ short h : 11;
+ short i : 11;
+ short y;
+} F1;
+
+// CHECK: Type: struct F1
+// CHECK: Size:120
+// CHECK: Alignment:8
+// CHECK: FieldOffsets: [0, 8, 11, 16, 24, 30, 40, 56, 72, 88, 104]>
+
+typedef union G1 {
+ char x;
+ int a : 3;
+ int : 0;
+ long long : 0;
+ short y;
+} G1;
+
+// CHECK: Type: union G1
+// CHECK: Size:32
+// CHECK: Alignment:8
+// CHECK: FieldOffsets: [0, 0, 0, 0, 0]>
+
+typedef struct H1 {
+ unsigned long a : 1;
+ unsigned char : 0;
+ unsigned long : 0;
+ unsigned long c : 1;
+} H1;
+
+// CHECK: Type: struct H1
+// CHECK: Size:64
+// CHECK: Alignment:8
+// CHECK: FieldOffsets: [0, 32, 32, 32]>
+
+#pragma pack(pop)
+
+int x[
+sizeof(A ) +
+sizeof(B ) +
+sizeof(C ) +
+sizeof(D ) +
+sizeof(E ) +
+sizeof(F ) +
+sizeof(G ) +
+sizeof(H ) +
+sizeof(A1) +
+sizeof(B1) +
+sizeof(C1) +
+sizeof(D1) +
+sizeof(E1) +
+sizeof(F1) +
+sizeof(G1) +
+sizeof(H1) +
+0];
diff --git a/test/Sema/ms_class_layout.cpp b/test/Sema/ms_class_layout.cpp
index f48494733184..bb8052e12ec3 100644
--- a/test/Sema/ms_class_layout.cpp
+++ b/test/Sema/ms_class_layout.cpp
@@ -164,7 +164,7 @@ int main() {
// CHECK-NEXT: 0 | (D vftable pointer)
// CHECK-NEXT: 8 | double a
-// CHECK-NEXT: sizeof=16, dsize=16, align=8
+// CHECK-NEXT: sizeof=16, align=8
// CHECK-NEXT: nvsize=16, nvalign=8
// CHECK: %class.D = type { i32 (...)**, double }
@@ -173,7 +173,7 @@ int main() {
// CHECK-NEXT: 0 | (B vftable pointer)
// CHECK-NEXT: 4 | int b_field
-// CHECK-NEXT: sizeof=8, dsize=8, align=4
+// CHECK-NEXT: sizeof=8, align=4
// CHECK-NEXT: nvsize=8, nvalign=4
// CHECK: %class.B = type { i32 (...)**, i32 }
@@ -185,7 +185,7 @@ int main() {
// CHECK-NEXT: 8 | int a_field
// CHECK-NEXT: 12 | char one
-// CHECK-NEXT: sizeof=16, dsize=16, align=4
+// CHECK-NEXT: sizeof=16, align=4
// CHECK-NEXT: nvsize=16, nvalign=4
// CHECK: 0 | class C
@@ -207,7 +207,7 @@ int main() {
// CHECK-NEXT: 72 | int a_field
// CHECK-NEXT: 76 | char one
-// CHECK-NEXT: sizeof=80, dsize=80, align=8
+// CHECK-NEXT: sizeof=80, align=8
// CHECK-NEXT: nvsize=64, nvalign=8
// CHECK: %class.A = type { %class.B, i32, i8 }
@@ -237,10 +237,10 @@ int main() {
// CHECK-NEXT: 88 | int a_field
// CHECK-NEXT: 92 | char one
-// CHECK-NEXT: sizeof=80, dsize=80, align=8
+// CHECK-NEXT: sizeof=80, align=8
// CHECK-NEXT: nvsize=64, nvalign=8
-// CHECK: sizeof=96, dsize=96, align=8
+// CHECK: sizeof=96, align=8
// CHECK-NEXT: nvsize=96, nvalign=8
// CHECK: %struct.BaseStruct = type { double, float, %class.C }
@@ -267,18 +267,18 @@ int main() {
// CHECK-NEXT: 84 | int b_field
// CHECK-NEXT: 88 | int a_field
// CHECK-NEXT: 92 | char one
-// CHECK-NEXT: sizeof=80, dsize=80, align=8
+// CHECK-NEXT: sizeof=80, align=8
// CHECK-NEXT: nvsize=64, nvalign=8
// CHECK: 96 | int x
-// CHECK-NEXT: sizeof=104, dsize=104, align=8
+// CHECK-NEXT: sizeof=104, align=8
// CHECK-NEXT: nvsize=104, nvalign=8
// CHECK: %struct.DerivedStruct = type { %struct.BaseStruct, i32 }
// CHECK: 0 | struct G
// CHECK-NEXT: 0 | int g_field
-// CHECK-NEXT: sizeof=4, dsize=4, align=4
+// CHECK-NEXT: sizeof=4, align=4
// CHECK-NEXT: nvsize=4, nvalign=4
// CHECK: 0 | struct H
@@ -288,7 +288,7 @@ int main() {
// CHECK-NEXT: 8 | class D (virtual base)
// CHECK-NEXT: 8 | (D vftable pointer)
// CHECK-NEXT: 16 | double a
-// CHECK-NEXT: sizeof=24, dsize=24, align=8
+// CHECK-NEXT: sizeof=24, align=8
// CHECK-NEXT: nvsize=8, nvalign=4
// CHECK: %struct.H = type { %struct.G, i32*, %class.D }
@@ -300,7 +300,7 @@ int main() {
// CHECK-NEXT: 24 | class D (virtual base)
// CHECK-NEXT: 24 | (D vftable pointer)
// CHECK-NEXT: 32 | double a
-// CHECK-NEXT: sizeof=40, dsize=40, align=8
+// CHECK-NEXT: sizeof=40, align=8
// CHECK-NEXT: nvsize=24, nvalign=8
// CHECK: %struct.I = type { i32 (...)**, [4 x i8], i32*, double, %class.D }
@@ -308,12 +308,12 @@ int main() {
// CHECK: 0 | struct L
// CHECK-NEXT: 0 | int l
-// CHECK-NEXT: sizeof=4, dsize=4, align=4
+// CHECK-NEXT: sizeof=4, align=4
// CHECK-NEXT: nvsize=4, nvalign=4
// CHECK: 0 | struct K
// CHECK-NEXT: 0 | int k
-// CHECK-NEXT: sizeof=4, dsize=4, align=4
+// CHECK-NEXT: sizeof=4, align=4
// CHECK-NEXT: nvsize=4, nvalign=4
// CHECK: 0 | struct M
@@ -321,42 +321,42 @@ int main() {
// CHECK-NEXT: 4 | int m
// CHECK-NEXT: 8 | struct K (virtual base)
// CHECK-NEXT: 8 | int k
-// CHECK-NEXT: sizeof=12, dsize=12, align=4
+// CHECK-NEXT: sizeof=12, align=4
//CHECK: %struct.M = type { i32*, i32, %struct.K }
//CHECK: %struct.M.base = type { i32*, i32 }
// CHECK: 0 | struct N
+// CHECK-NEXT: 0 | (N vftable pointer)
// CHECK-NEXT: 4 | struct L (base)
// CHECK-NEXT: 4 | int l
// CHECK-NEXT: 8 | struct M (base)
// CHECK-NEXT: 8 | (M vbtable pointer)
// CHECK-NEXT: 12 | int m
-// CHECK-NEXT: 0 | (N vftable pointer)
// CHECK-NEXT: 16 | struct K (virtual base)
// CHECK-NEXT: 16 | int k
-// CHECK-NEXT: sizeof=20, dsize=20, align=4
+// CHECK-NEXT: sizeof=20, align=4
// CHECK-NEXT: nvsize=16, nvalign=4
//CHECK: %struct.N = type { i32 (...)**, %struct.L, %struct.M.base, %struct.K }
-// FIXME: MSVC place struct H at offset 8.
// CHECK: 0 | struct O
-// CHECK-NEXT: 4 | struct H (base)
-// CHECK-NEXT: 4 | struct G (base)
-// CHECK-NEXT: 4 | int g_field
-// CHECK-NEXT: 8 | (H vbtable pointer)
-// CHECK-NEXT: 12 | struct G (base)
-// CHECK-NEXT: 12 | int g_field
// CHECK-NEXT: 0 | (O vftable pointer)
-// CHECK-NEXT: 16 | class D (virtual base)
-// CHECK-NEXT: 16 | (D vftable pointer)
-// CHECK-NEXT: 24 | double a
-// CHECK-NEXT: sizeof=32, dsize=32, align=8
-// CHECK-NEXT: nvsize=16, nvalign=4
+// CHECK-NEXT: 8 | struct H (base)
+// CHECK-NEXT: 8 | struct G (base)
+// CHECK-NEXT: 8 | int g_field
+// CHECK-NEXT: 12 | (H vbtable pointer)
+// CHECK-NEXT: 16 | struct G (base)
+// CHECK-NEXT: 16 | int g_field
+// CHECK-NEXT: 24 | class D (virtual base)
+// CHECK-NEXT: 24 | (D vftable pointer)
+// CHECK-NEXT: 32 | double a
+// 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.base = type { i32 (...)**, [4 x i8], %struct.H.base, %struct.G, [4 x i8] }
-//CHECK: %struct.O = type { i32 (...)**, %struct.H.base, %struct.G, %class.D }
-//CHECK: %struct.O.base = type { i32 (...)**, %struct.H.base, %struct.G }
// CHECK: 0 | struct P
// CHECK-NEXT: 0 | struct M (base)
@@ -367,20 +367,20 @@ int main() {
// CHECK-NEXT: 12 | int k
// CHECK-NEXT: 16 | struct L (virtual base)
// CHECK-NEXT: 16 | int l
-// CHECK-NEXT: sizeof=20, dsize=20, align=4
+// CHECK-NEXT: sizeof=20, align=4
// CHECK-NEXT: nvsize=12, nvalign=4
//CHECK: %struct.P = type { %struct.M.base, i32, %struct.K, %struct.L }
// CHECK: 0 | struct R (empty)
-// CHECK-NEXT: sizeof=1, dsize=0, align=1
+// CHECK-NEXT: sizeof=1, align=1
// CHECK-NEXT: nvsize=0, nvalign=1
//CHECK: %struct.R = type { i8 }
// CHECK: 0 | struct f
// CHECK-NEXT: 0 | (f vftable pointer)
-// CHECK-NEXT: sizeof=4, dsize=4, align=4
+// CHECK-NEXT: sizeof=4, align=4
// CHECK-NEXT: nvsize=4, nvalign=4
// CHECK: 0 | struct s
@@ -390,12 +390,12 @@ int main() {
// CHECK-NEXT: 12 | (vtordisp for vbase f)
// CHECK-NEXT: 16 | struct f (virtual base)
// CHECK-NEXT: 16 | (f vftable pointer)
-// CHECK-NEXT: sizeof=20, dsize=20, align=4
+// CHECK-NEXT: sizeof=20, align=4
// CHECK-NEXT: nvsize=12, nvalign=4
// CHECK: 0 | class IA
// CHECK-NEXT: 0 | (IA vftable pointer)
-// CHECK-NEXT: sizeof=4, dsize=4, align=4
+// CHECK-NEXT: sizeof=4, align=4
// CHECK-NEXT: nvsize=4, nvalign=4
// CHECK: 0 | class ICh
@@ -404,7 +404,7 @@ int main() {
// CHECK-NEXT: 8 | (vtordisp for vbase IA)
// CHECK-NEXT: 12 | class IA (virtual base)
// CHECK-NEXT: 12 | (IA vftable pointer)
-// CHECK-NEXT: sizeof=16, dsize=16, align=4
+// CHECK-NEXT: sizeof=16, align=4
// CHECK-NEXT: nvsize=8, nvalign=4
// CHECK: 0 | struct sd
@@ -424,7 +424,7 @@ int main() {
// CHECK-NEXT: 40 | class ICh (virtual base)
// CHECK-NEXT: 40 | (ICh vftable pointer)
// CHECK-NEXT: 44 | (ICh vbtable pointer)
-// CHECK-NEXT: sizeof=48, dsize=48, align=4
+// CHECK-NEXT: sizeof=48, align=4
// CHECK-NEXT: nvsize=12, nvalign=4
// CHECK: %struct.f = type { i32 (...)** }
@@ -435,14 +435,14 @@ int main() {
// CHECK: 0 | struct AV
// CHECK-NEXT: 0 | (AV vftable pointer)
-// CHECK-NEXT: sizeof=4, dsize=4, align=4
+// CHECK-NEXT: sizeof=4, align=4
// CHECK-NEXT: nvsize=4, nvalign=4
// CHECK: 0 | struct BV
// CHECK-NEXT: 0 | struct AV (primary base)
// CHECK-NEXT: 0 | (AV vftable pointer)
-// CHECK-NEXT: sizeof=4, dsize=4, align=4
+// CHECK-NEXT: sizeof=4, align=4
// CHECK-NEXT: nvsize=4, nvalign=4
@@ -452,7 +452,7 @@ int main() {
// CHECK-NEXT: 8 | struct BV (virtual base)
// CHECK-NEXT: 8 | struct AV (primary base)
// CHECK-NEXT: 8 | (AV vftable pointer)
-// CHECK-NEXT: sizeof=12, dsize=12, align=4
+// CHECK-NEXT: sizeof=12, align=4
// CHECK-NEXT: nvsize=4, nvalign=4
// CHECK: %struct.AV = type { i32 (...)** }
@@ -464,7 +464,7 @@ int main() {
// CHECK-NEXT: 0 | struct BV (primary base)
// CHECK-NEXT: 0 | struct AV (primary base)
// CHECK-NEXT: 0 | (AV vftable pointer)
-// CHECK-NEXT: sizeof=4, dsize=4, align=4
+// CHECK-NEXT: sizeof=4, align=4
// CHECK-NEXT: nvsize=4, nvalign=4
// CHECK: %struct.DV = type { %struct.BV }
@@ -480,14 +480,14 @@ int main() {
// CHECK-NEXT: 12 | struct BV (virtual base)
// CHECK-NEXT: 12 | struct AV (primary base)
// CHECK-NEXT: 12 | (AV vftable pointer)
-// CHECK-NEXT: sizeof=16, dsize=16, align=4
+// 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.base = type { %struct.DV, %struct.CV.base }
// Overriding a method means that all the vbases containing that
-// method need a vtordisp.
+// method need a vtordisp. Note: this code will cause an error in cl.exe.
namespace test1 {
struct A { virtual void foo(); };
struct B : A {};
@@ -503,6 +503,6 @@ namespace test1 {
// CHECK-NEXT: 16 | struct test1::B (virtual base)
// CHECK-NEXT: 16 | struct test1::A (primary base)
// CHECK-NEXT: 16 | (A vftable pointer)
-// CHECK-NEXT: sizeof=20, dsize=20, align=4
+// CHECK-NEXT: sizeof=20, align=4
// CHECK-NEXT: nvsize=4, nvalign=4
}
diff --git a/test/Sema/neon-vector-types-support.c b/test/Sema/neon-vector-types-support.c
new file mode 100644
index 000000000000..6bf8539e47bd
--- /dev/null
+++ b/test/Sema/neon-vector-types-support.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -triple armv7 -fsyntax-only -verify
+
+typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported for this target}}
+typedef __attribute__((neon_polyvector_type(16))) short poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported for this target}}
diff --git a/test/Sema/neon-vector-types.c b/test/Sema/neon-vector-types.c
index cbf013398a26..d8dd41225a32 100644
--- a/test/Sema/neon-vector-types.c
+++ b/test/Sema/neon-vector-types.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify
+// RUN: %clang_cc1 %s -triple armv7 -target-feature +neon -fsyntax-only -verify
+// RUN: %clang_cc1 %s -triple armv8 -target-feature +neon -fsyntax-only -verify
typedef float float32_t;
typedef signed char poly8_t;
@@ -16,10 +17,10 @@ typedef __attribute__((neon_polyvector_type(16))) poly8_t poly8x16_t;
typedef __attribute__((neon_polyvector_type(8))) poly16_t poly16x8_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}}
+typedef __attribute__((neon_vector_type(2, 4))) int only_one_arg; // expected-error{{'neon_vector_type' attribute takes one argument}}
// The number of elements must be an ICE.
-typedef __attribute__((neon_vector_type(2.0))) int non_int_width; // expected-error{{attribute requires integer constant}}
+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}}
diff --git a/test/Sema/nonnull.c b/test/Sema/nonnull.c
index cea8e3d0ddc4..4e6171160f64 100644
--- a/test/Sema/nonnull.c
+++ b/test/Sema/nonnull.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
// rdar://9584012
typedef struct {
@@ -19,3 +19,4 @@ int main(void) {
Class_init(obj, "Hello World");
}
+void foo(const char *str) __attribute__((nonnull("foo"))); // expected-error{{'nonnull' attribute requires parameter 1 to be an integer constant}}
diff --git a/test/Sema/offsetof-64.c b/test/Sema/offsetof-64.c
new file mode 100644
index 000000000000..4a80dee2fc2f
--- /dev/null
+++ b/test/Sema/offsetof-64.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-linux-gnu
+
+// PR15216
+// Don't crash when taking computing the offset of structs with large arrays.
+const unsigned long Size = (1l << 60);
+
+struct Chunk1 {
+ char padding[Size];
+ char more_padding[1][Size];
+ char data;
+};
+
+int test1 = __builtin_offsetof(struct Chunk1, data);
+
+struct Chunk2 {
+ char padding[Size][Size][Size]; // expected-error 2{{array is too large}}
+ char data;
+};
+
+// FIXME: Remove this error when the constant evaluator learns to
+// ignore bad types.
+int test2 = __builtin_offsetof(struct Chunk2, data); // expected-error{{initializer element is not a compile-time constant}}
diff --git a/test/Sema/offsetof.c b/test/Sema/offsetof.c
index 46fb515c7f2e..9e876ad5898e 100644
--- a/test/Sema/offsetof.c
+++ b/test/Sema/offsetof.c
@@ -69,3 +69,4 @@ int test4 = __builtin_offsetof(Array, array);
int test5() {
return __builtin_offsetof(Array, array[*(int*)0]); // expected-warning{{indirection of non-volatile null pointer}} expected-note{{__builtin_trap}}
}
+
diff --git a/test/Sema/overloadable.c b/test/Sema/overloadable.c
index 5d39f15ec81f..b93c39fc1a2d 100644
--- a/test/Sema/overloadable.c
+++ b/test/Sema/overloadable.c
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
int var __attribute__((overloadable)); // expected-error{{'overloadable' attribute can only be applied to a function}}
+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}}
float *f(float); // expected-error{{overloaded function 'f' must have the 'overloadable' attribute}}
@@ -65,7 +66,22 @@ extern int __attribute__((overloadable)) f0(); // expected-error{{'overloadable'
typedef int f1_type();
f1_type __attribute__((overloadable)) f1; // expected-error{{'overloadable' function 'f1' must have a prototype}}
-void test() {
+void test() {
f0();
f1();
}
+
+void before_local_1(int) __attribute__((overloadable)); // expected-note {{here}}
+void before_local_2(int); // expected-note {{here}}
+void before_local_3(int) __attribute__((overloadable));
+void local() {
+ void before_local_1(char); // expected-error {{must have the 'overloadable' attribute}}
+ void before_local_2(char) __attribute__((overloadable)); // expected-error {{conflicting types}}
+ void before_local_3(char) __attribute__((overloadable));
+ void after_local_1(char); // expected-note {{here}}
+ void after_local_2(char) __attribute__((overloadable)); // expected-note {{here}}
+ void after_local_3(char) __attribute__((overloadable));
+}
+void after_local_1(int) __attribute__((overloadable)); // expected-error {{conflicting types}}
+void after_local_2(int); // expected-error {{must have the 'overloadable' attribute}}
+void after_local_3(int) __attribute__((overloadable));
diff --git a/test/Sema/parentheses.c b/test/Sema/parentheses.c
index 300e58558867..b7f1b6e93aa5 100644
--- a/test/Sema/parentheses.c
+++ b/test/Sema/parentheses.c
@@ -118,5 +118,5 @@ void conditional_op(int x, int y, _Bool b) {
(void)(x % 2 ? 1 : 2); // no warning
}
-// RUN: %clang_cc1 -fsyntax-only -Wparentheses -Werror -fdiagnostics-show-option %s 2>&1 | FileCheck %s -check-prefix=CHECK-FLAG
+// RUN: not %clang_cc1 -fsyntax-only -Wparentheses -Werror -fdiagnostics-show-option %s 2>&1 | FileCheck %s -check-prefix=CHECK-FLAG
// CHECK-FLAG: error: using the result of an assignment as a condition without parentheses [-Werror,-Wparentheses]
diff --git a/test/Sema/pragma-weak.c b/test/Sema/pragma-weak.c
new file mode 100644
index 000000000000..c14125eac9f7
--- /dev/null
+++ b/test/Sema/pragma-weak.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -verify %s
+
+void __both3(void);
+#pragma weak both3 = __both3 // expected-note {{previous definition}}
+void both3(void) __attribute((alias("__both3"))); // expected-error {{redefinition of 'both3'}}
+void __both3(void) {}
+
+void __a3(void) __attribute((noinline));
+#pragma weak a3 = __a3 // expected-note {{previous definition}}
+void a3(void) __attribute((alias("__a3"))); // expected-error {{redefinition of 'a3'}}
+void __a3(void) {}
diff --git a/test/Sema/string-init.c b/test/Sema/string-init.c
new file mode 100644
index 000000000000..96ee360e4452
--- /dev/null
+++ b/test/Sema/string-init.c
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -std=c11 -fsyntax-only -triple x86_64-pc-linux -verify %s
+
+// Note: these match the types specified by the target above.
+typedef int wchar_t;
+typedef unsigned short char16_t;
+typedef unsigned int char32_t;
+
+void f() {
+ char a1[] = "a"; // No error.
+ char a2[] = u8"a"; // No error.
+ char a3[] = u"a"; // expected-error{{initializing char array with wide string literal}}
+ char a4[] = U"a"; // expected-error{{initializing char array with wide string literal}}
+ char a5[] = L"a"; // expected-error{{initializing char array with wide string literal}}
+
+ wchar_t b1[] = "a"; // expected-error{{initializing wide char array with non-wide string literal}}
+ wchar_t b2[] = u8"a"; // expected-error{{initializing wide char array with non-wide string literal}}
+ wchar_t b3[] = u"a"; // expected-error{{initializing wide char array with incompatible wide string literal}}
+ wchar_t b4[] = U"a"; // expected-error{{initializing wide char array with incompatible wide string literal}}
+ wchar_t b5[] = L"a"; // No error.
+
+ char16_t c1[] = "a"; // expected-error{{initializing wide char array with non-wide string literal}}
+ char16_t c2[] = u8"a"; // expected-error{{initializing wide char array with non-wide string literal}}
+ char16_t c3[] = u"a"; // No error.
+ char16_t c4[] = U"a"; // expected-error{{initializing wide char array with incompatible wide string literal}}
+ char16_t c5[] = L"a"; // expected-error{{initializing wide char array with incompatible wide string literal}}
+
+ char32_t d1[] = "a"; // expected-error{{initializing wide char array with non-wide string literal}}
+ char32_t d2[] = u8"a"; // expected-error{{initializing wide char array with non-wide string literal}}
+ char32_t d3[] = u"a"; // expected-error{{initializing wide char array with incompatible wide string literal}}
+ char32_t d4[] = U"a"; // No error.
+ char32_t d5[] = L"a"; // expected-error{{initializing wide char array with incompatible wide string literal}}
+
+ int e1[] = "a"; // expected-error{{initializing wide char array with non-wide string literal}}
+ int e2[] = u8"a"; // expected-error{{initializing wide char array with non-wide string literal}}
+ int e3[] = u"a"; // expected-error{{initializing wide char array with incompatible wide string literal}}
+ int e4[] = U"a"; // expected-error{{initializing wide char array with incompatible wide string literal}}
+ int e5[] = L"a"; // No error.
+
+ long f1[] = "a"; // expected-error{{array initializer must be an initializer list}}
+ long f2[] = u8"a"; // expected-error{{array initializer must be an initializer list}}}
+ long f3[] = u"a"; // expected-error{{array initializer must be an initializer list}}
+ long f4[] = U"a"; // expected-error{{array initializer must be an initializer list}}
+ long f5[] = L"a"; // expected-error{{array initializer must be an initializer list}}
+}
+
+void g() {
+ char a[] = 1; // expected-error{{array initializer must be an initializer list or string literal}}
+ wchar_t b[] = 1; // expected-error{{array initializer must be an initializer list or wide string literal}}
+ char16_t c[] = 1; // expected-error{{array initializer must be an initializer list or wide string literal}}
+ char32_t d[] = 1; // expected-error{{array initializer must be an initializer list or wide string literal}}
+}
diff --git a/test/Sema/string-plus-char.c b/test/Sema/string-plus-char.c
new file mode 100644
index 000000000000..322e8f5962be
--- /dev/null
+++ b/test/Sema/string-plus-char.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void f(const char *s) {
+ char *str = 0;
+ char *str2 = str + 'c'; // expected-warning {{adding 'char' to a string pointer does not append to the string}} expected-note {{use array indexing to silence this warning}}
+
+ const char *constStr = s + 'c'; // expected-warning {{adding 'char' to a string pointer does not append to the string}} expected-note {{use array indexing to silence this warning}}
+
+ str = 'c' + str;// expected-warning {{adding 'char' to a string pointer does not append to the string}} expected-note {{use array indexing to silence this warning}}
+
+ // no-warning
+ char c = 'c';
+ str = str + c;
+ str = c + str;
+}
diff --git a/test/Sema/struct-decl.c b/test/Sema/struct-decl.c
index 819e856ac8cb..8d3d74de7671 100644
--- a/test/Sema/struct-decl.c
+++ b/test/Sema/struct-decl.c
@@ -57,3 +57,12 @@ const struct test2 { // expected-warning {{'const' ignored on this declaration}}
inline struct test3 { // expected-error {{'inline' can only appear on functions}}
int x;
};
+
+struct hiding_1 {};
+struct hiding_2 {};
+void test_hiding() {
+ struct hiding_1 *hiding_1();
+ extern struct hiding_2 *hiding_2;
+ struct hiding_1 *p = hiding_1();
+ struct hiding_2 *q = hiding_2;
+}
diff --git a/test/Sema/thread-specifier.c b/test/Sema/thread-specifier.c
index 9d516e8f1413..bf1ce9e26e4a 100644
--- a/test/Sema/thread-specifier.c
+++ b/test/Sema/thread-specifier.c
@@ -2,8 +2,8 @@
// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic -x c++ %s -DGNU
// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic %s -DC11 -D__thread=_Thread_local
// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic -x c++ %s -DC11 -D__thread=_Thread_local
-// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic -x c++ %s -DCXX11 -D__thread=thread_local -std=c++11
-// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic -x c++ %s -DC11 -D__thread=_Thread_local -std=c++11
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic -x c++ %s -DCXX11 -D__thread=thread_local -std=c++11 -Wno-deprecated
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic -x c++ %s -DC11 -D__thread=_Thread_local -std=c++11 -Wno-deprecated
#ifdef __cplusplus
// In C++, we define __private_extern__ to extern.
diff --git a/test/Sema/types.c b/test/Sema/types.c
index d0637cca61a2..dac0bfe9fe82 100644
--- a/test/Sema/types.c
+++ b/test/Sema/types.c
@@ -64,3 +64,11 @@ void test(int i) {
void test2(int i) {
char c = (char __attribute__((may_alias))) i;
}
+
+// vector size too large
+int __attribute__ ((vector_size(8192))) x1; // expected-error {{vector size too large}}
+typedef int __attribute__ ((ext_vector_type(8192))) x2; // expected-error {{vector size too large}}
+
+// no support for vector enum type
+enum { e_2 } x3 __attribute__((vector_size(64))); // expected-error {{invalid vector element type}}
+
diff --git a/test/Sema/varargs.c b/test/Sema/varargs.c
index 663d3d594758..5329c2e61c98 100644
--- a/test/Sema/varargs.c
+++ b/test/Sema/varargs.c
@@ -76,3 +76,10 @@ void f9(__builtin_va_list args)
(void)__builtin_va_arg(args, short); // expected-warning {{second argument to 'va_arg' is of promotable type 'short'}}
(void)__builtin_va_arg(args, char); // expected-warning {{second argument to 'va_arg' is of promotable type 'char'}}
}
+
+void f10(int a, ...) {
+ int i;
+ __builtin_va_list ap;
+ i = __builtin_va_start(ap, a); // expected-error {{assigning to 'int' from incompatible type 'void'}}
+ __builtin_va_end(ap);
+}
diff --git a/test/Sema/varargs.cpp b/test/Sema/varargs.cpp
new file mode 100644
index 000000000000..48a7b2fdf103
--- /dev/null
+++ b/test/Sema/varargs.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+class string;
+void f(const string& s, ...) { // expected-note {{parameter of type 'const string &' is declared here}}
+ __builtin_va_list ap;
+ __builtin_va_start(ap, s); // expected-warning {{'va_start' has undefined behavior with reference types}}
+}
diff --git a/test/Sema/vfprintf-valid-redecl.c b/test/Sema/vfprintf-valid-redecl.c
index 5c5ce8d12b00..8ed18786ab7e 100644
--- a/test/Sema/vfprintf-valid-redecl.c
+++ b/test/Sema/vfprintf-valid-redecl.c
@@ -1,7 +1,16 @@
// RUN: %clang_cc1 %s -fsyntax-only -pedantic -verify
+// RUN: %clang_cc1 %s -fsyntax-only -pedantic -verify -DPREDECLARE
// expected-no-diagnostics
-// PR4290
+#ifdef PREDECLARE
+// PR16344
+// Clang has defined 'vfprint' in builtin list. If the following line occurs before any other
+// `vfprintf' in this file, and we getPreviousDecl()->getTypeSourceInfo() on it, then we will
+// get a null pointer since the one in builtin list doesn't has valid TypeSourceInfo.
+int vfprintf(void) { return 0; }
+#endif
+
+// PR4290
// The following declaration is compatible with vfprintf, so we shouldn't
// warn.
int vfprintf();
diff --git a/test/Sema/warn-documentation-fixits.cpp b/test/Sema/warn-documentation-fixits.cpp
index a47b77637506..675d86c366db 100644
--- a/test/Sema/warn-documentation-fixits.cpp
+++ b/test/Sema/warn-documentation-fixits.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -fcomment-block-commands=foobar -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -fcomment-block-commands=foobar -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
// expected-warning@+1 {{parameter 'ZZZZZZZZZZ' not found in the function declaration}} expected-note@+1 {{did you mean 'a'?}}
/// \param ZZZZZZZZZZ Blah blah.
@@ -57,6 +57,24 @@ struct test_deprecated_6 {
/// \deprecated
void test_deprecated_9(int a);
+// rdar://12381408
+// expected-warning@+2 {{unknown command tag name 'retur'; did you mean 'return'?}}
+/// \brief testing fixit
+/// \retur int in FooBar
+int FooBar();
+
+// expected-warning@+1 {{unknown command tag name 'fooba'; did you mean 'foobar'?}}
+/// \fooba bbb IS_DOXYGEN_END
+int gorf();
+
+/// \t bbb IS_DOXYGEN_END
+int Bar();
+
+// expected-warning@+2 {{unknown command tag name 'encode'; did you mean 'endcode'?}}
+// expected-warning@+1 {{'\endcode' command does not terminate a verbatim text block}}
+/// \encode PR18051
+int PR18051();
+
// CHECK: fix-it:"{{.*}}":{5:12-5:22}:"a"
// CHECK: fix-it:"{{.*}}":{9:12-9:15}:"aaa"
// CHECK: fix-it:"{{.*}}":{13:13-13:23}:"T"
@@ -68,4 +86,6 @@ void test_deprecated_9(int a);
// CHECK: fix-it:"{{.*}}":{46:27-46:27}:" __attribute__((deprecated))"
// CHECK: fix-it:"{{.*}}":{50:27-50:27}:" __attribute__((deprecated))"
// CHECK: fix-it:"{{.*}}":{58:30-58:30}:" MY_ATTR_DEPRECATED"
-
+// CHECK: fix-it:"{{.*}}":{63:6-63:11}:"return"
+// CHECK: fix-it:"{{.*}}":{67:6-67:11}:"foobar"
+// CHECK: fix-it:"{{.*}}":{75:6-75:12}:"endcode"
diff --git a/test/Sema/warn-documentation.cpp b/test/Sema/warn-documentation.cpp
index b3ab0199dcb4..7166a4990945 100644
--- a/test/Sema/warn-documentation.cpp
+++ b/test/Sema/warn-documentation.cpp
@@ -136,37 +136,33 @@ int test_duplicate_brief2(int);
int test_duplicate_brief3(int);
-// expected-warning@+5 {{duplicated command '\return'}} expected-note@+1 {{previous command '\return' here}}
/// \return Aaa
///
/// Bbb
///
/// \return Ccc
-int test_duplicate_returns1(int);
+int test_multiple_returns1(int);
-// expected-warning@+5 {{duplicated command '\returns'}} expected-note@+1 {{previous command '\returns' here}}
/// \returns Aaa
///
/// Bbb
///
/// \returns Ccc
-int test_duplicate_returns2(int);
+int test_multiple_returns2(int);
-// expected-warning@+5 {{duplicated command '\result'}} expected-note@+1 {{previous command '\result' here}}
/// \result Aaa
///
/// Bbb
///
/// \result Ccc
-int test_duplicate_returns3(int);
+int test_multiple_returns3(int);
-// expected-warning@+5 {{duplicated command '\return'}} expected-note@+1 {{previous command '\returns' (an alias of '\return') here}}
/// \returns Aaa
///
/// Bbb
///
/// \return Ccc
-int test_duplicate_returns4(int);
+int test_multiple_returns4(int);
// expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
@@ -309,6 +305,22 @@ typedef test_param27 test_param28;
typedef unsigned int test_param29;
+/// \param aaa Aaa
+/// \param ... Vararg
+int test_vararg_param1(int aaa, ...);
+
+/// \param ... Vararg
+int test_vararg_param2(...);
+
+// expected-warning@+1 {{parameter '...' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
+/// \param ... Vararg
+int test_vararg_param3(int aaa);
+
+// expected-warning@+1 {{parameter '...' not found in the function declaration}}
+/// \param ... Vararg
+int test_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;
@@ -592,6 +604,25 @@ int test4; ///< \brief
///< \author Aaa
+class TestRelates {};
+
+/// \relates TestRelates
+/// \brief Aaa
+void test_relates_1();
+
+/// \related TestRelates
+/// \brief Aaa
+void test_relates_2();
+
+/// \relatesalso TestRelates
+/// \brief Aaa
+void test_relates_3();
+
+/// \relatedalso TestRelates
+/// \brief Aaa
+void test_relates_4();
+
+
// Check that we attach the comment to the declaration during parsing in the
// following cases. The test is based on the fact that we don't parse
// documentation comments that are not attached to anything.
@@ -950,3 +981,47 @@ class C1;
@struct S3;
*/
class S3;
+
+// rdar://14124702
+//----------------------------------------------------------------------
+/// @class Predicate Predicate.h "lldb/Host/Predicate.h"
+/// @brief A C++ wrapper class for providing threaded access to a value
+/// of type T.
+///
+/// A templatized class.
+/// specified values.
+//----------------------------------------------------------------------
+template <class T, class T1>
+class Predicate
+{
+};
+
+//----------------------------------------------------------------------
+/// @class Predicate<int, char> Predicate.h "lldb/Host/Predicate.h"
+/// @brief A C++ wrapper class for providing threaded access to a value
+/// of type T.
+///
+/// A template specilization class.
+//----------------------------------------------------------------------
+template<> class Predicate<int, char>
+{
+};
+
+//----------------------------------------------------------------------
+/// @class Predicate<T, int> Predicate.h "lldb/Host/Predicate.h"
+/// @brief A C++ wrapper class for providing threaded access to a value
+/// of type T.
+///
+/// A partial specialization template class.
+//----------------------------------------------------------------------
+template<class T> class Predicate<T, int>
+{
+};
+
+/*! @function test_function
+*/
+template <class T> T test_function (T arg);
+
+/*! @function test_function<int>
+*/
+template <> int test_function<int> (int arg);
diff --git a/test/Sema/warn-documentation.m b/test/Sema/warn-documentation.m
index 0737a8dedd03..5e95e2a1e8a2 100644
--- a/test/Sema/warn-documentation.m
+++ b/test/Sema/warn-documentation.m
@@ -172,3 +172,60 @@ struct S;
@struct S1 THIS IS IT
*/
@interface S1 @end
+
+// expected-warning@+1 {{unknown command tag name}}
+/// \t bbb IS_DOXYGEN_END
+int FooBar();
+
+// rdar://13836387
+/** \brief Module handling the incoming notifications from the system.
+ *
+ * This includes:
+ * - Network Reachability
+ * - Power State
+ * - Low Disk
+ */
+@interface BRC : NSObject
+- (void)removeReach:(NSObject*)observer;
+@end
+
+@implementation BRC : NSObject
+- (void)removeReach:(NSObject*)observer // expected-note {{previous declaration is here}}
+{
+}
+- (void)removeReach:(NSObject*)observer // expected-error {{duplicate declaration of method 'removeReach:'}}
+{
+}
+@end
+
+// rdar://13927330
+/// @class Asset <- '@class' may be used in a comment attached to a an interface declaration
+@interface Asset : NSObject
+@end
+
+// rdar://14024851 Check that this does not enter an infinite loop
+@interface rdar14024851
+-(void)meth; // expected-note {{declared here}}
+@end
+
+@implementation rdar14024851 // expected-warning {{method definition for 'meth' not found}} expected-note {{previous definition}}
+@end
+
+@implementation rdar14024851 // expected-error {{reimplementation}}
+/// \brief comment
+-(void)meth {}
+@end
+
+// rdar://14124644
+@interface test_vararg1
+/// @param[in] arg somthing
+/// @param[in] ... This is vararg
+- (void) VarArgMeth : (id)arg, ...;
+@end
+
+@implementation test_vararg1
+/// @param[in] arg somthing
+/// @param[in] ... This is vararg
+- (void) VarArgMeth : (id)arg, ... {}
+@end
+
diff --git a/test/Sema/warn-main-return-type.c b/test/Sema/warn-main-return-type.c
index bd7c59f2d390..c6f3a0c1011a 100644
--- a/test/Sema/warn-main-return-type.c
+++ b/test/Sema/warn-main-return-type.c
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
-// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -x c++ %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -x c++ %s 2>&1 | FileCheck %s
// expected-note@+1 5{{previous definition is here}}
int main() {
diff --git a/test/Sema/warn-main.c b/test/Sema/warn-main.c
index 8a4eafc1325c..58a6dfde108d 100644
--- a/test/Sema/warn-main.c
+++ b/test/Sema/warn-main.c
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
-// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -x c++ %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -x c++ %s 2>&1 | FileCheck %s
// expected-note@+1 2{{previous definition is here}}
int main() {
@@ -14,16 +14,14 @@ static int main() {
return 0;
}
-// expected-error@+3 {{redefinition of 'main'}}
-// expected-error@+2 {{'main' is not allowed to be declared inline}}
-// expected-note@+1 {{previous definition is here}}
+// expected-error@+2 {{redefinition of 'main'}}
+// expected-error@+1 {{'main' is not allowed to be declared inline}}
inline int main() {
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:1-[[@LINE-1]]:8}:""
return 0;
}
-// expected-warning@+6 {{function 'main' declared 'noreturn' should not return}}
-// expected-error@+3 {{redefinition of 'main'}}
+// expected-warning@+5 {{function 'main' declared 'noreturn' should not return}}
// expected-warning@+2 {{'main' is not allowed to be declared _Noreturn}}
// expected-note@+1 {{remove '_Noreturn'}}
_Noreturn int main() {
diff --git a/test/Sema/warn-null.c b/test/Sema/warn-null.c
new file mode 100644
index 000000000000..28fb6a5f691c
--- /dev/null
+++ b/test/Sema/warn-null.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -verify
+
+// 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}}
+int *r = (1 - 1); // expected-warning{{expression which evaluates to zero treated as a null pointer constant}}
+void f() {
+ 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}}
+}
diff --git a/test/Sema/warn-outof-range-assign-enum.c b/test/Sema/warn-outof-range-assign-enum.c
index 2e79e66f49bd..43eea0cef41f 100644
--- a/test/Sema/warn-outof-range-assign-enum.c
+++ b/test/Sema/warn-outof-range-assign-enum.c
@@ -21,6 +21,18 @@ enum Test2 test2(enum Test2 *t) {
return 10; // expected-warning {{integer constant not in range of enumerated type 'enum Test2'}}
}
+// PR15069
+typedef enum
+{
+ a = 0
+} T;
+
+void f()
+{
+ T x = a;
+ x += 1; // expected-warning {{integer constant not in range of enumerated type}}
+}
+
int main() {
CCTestEnum test = 1; // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}}
test = 600; // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}}
diff --git a/test/Sema/warn-shadow-intrinsics.c b/test/Sema/warn-shadow-intrinsics.c
new file mode 100644
index 000000000000..b291426395c9
--- /dev/null
+++ b/test/Sema/warn-shadow-intrinsics.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -ffreestanding -triple x86_64-apple-macosx10.8.0 -fsyntax-only %s
+
+#include <emmintrin.h>
+
+// Test that using two macros from emmintrin do not cause a
+// useless -Wshadow warning.
+void rdar10679282() {
+ __m128i qf = _mm_setzero_si128();
+ qf = _mm_slli_si128(_mm_add_epi64(qf, _mm_srli_si128(qf, 8)), 8); // no-warning
+ (void) qf;
+}
diff --git a/test/Sema/warn-thread-safety-analysis.c b/test/Sema/warn-thread-safety-analysis.c
new file mode 100644
index 000000000000..1918aceee6da
--- /dev/null
+++ b/test/Sema/warn-thread-safety-analysis.c
@@ -0,0 +1,123 @@
+// RUN: %clang -fsyntax-only -verify -Wthread-safety -Wthread-safety-beta -fcxx-exceptions %s
+
+#define LOCKABLE __attribute__ ((lockable))
+#define SCOPED_LOCKABLE __attribute__ ((scoped_lockable))
+#define GUARDED_BY(x) __attribute__ ((guarded_by(x)))
+#define GUARDED_VAR __attribute__ ((guarded_var))
+#define PT_GUARDED_BY(x) __attribute__ ((pt_guarded_by(x)))
+#define PT_GUARDED_VAR __attribute__ ((pt_guarded_var))
+#define ACQUIRED_AFTER(...) __attribute__ ((acquired_after(__VA_ARGS__)))
+#define ACQUIRED_BEFORE(...) __attribute__ ((acquired_before(__VA_ARGS__)))
+#define EXCLUSIVE_LOCK_FUNCTION(...) __attribute__ ((exclusive_lock_function(__VA_ARGS__)))
+#define SHARED_LOCK_FUNCTION(...) __attribute__ ((shared_lock_function(__VA_ARGS__)))
+#define ASSERT_EXCLUSIVE_LOCK(...) __attribute__ ((assert_exclusive_lock(__VA_ARGS__)))
+#define ASSERT_SHARED_LOCK(...) __attribute__ ((assert_shared_lock(__VA_ARGS__)))
+#define EXCLUSIVE_TRYLOCK_FUNCTION(...) __attribute__ ((exclusive_trylock_function(__VA_ARGS__)))
+#define SHARED_TRYLOCK_FUNCTION(...) __attribute__ ((shared_trylock_function(__VA_ARGS__)))
+#define UNLOCK_FUNCTION(...) __attribute__ ((unlock_function(__VA_ARGS__)))
+#define LOCK_RETURNED(x) __attribute__ ((lock_returned(x)))
+#define LOCKS_EXCLUDED(...) __attribute__ ((locks_excluded(__VA_ARGS__)))
+#define EXCLUSIVE_LOCKS_REQUIRED(...) \
+ __attribute__ ((exclusive_locks_required(__VA_ARGS__)))
+#define SHARED_LOCKS_REQUIRED(...) \
+ __attribute__ ((shared_locks_required(__VA_ARGS__)))
+#define NO_THREAD_SAFETY_ANALYSIS __attribute__ ((no_thread_safety_analysis))
+
+// Define the mutex struct.
+// Simplified only for test purpose.
+struct LOCKABLE Mutex {};
+
+struct Foo {
+ 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) {
+}
+
+// Define global variables.
+struct Mutex mu1;
+struct Mutex mu2 ACQUIRED_AFTER(mu1);
+struct Foo foo_ = {&mu1};
+int a_ GUARDED_BY(foo_.mu_);
+int *b_ PT_GUARDED_BY(foo_.mu_) = &a_;
+int c_ GUARDED_VAR;
+int *d_ PT_GUARDED_VAR = &c_;
+
+// Define test functions.
+int Foo_fun1(int i) SHARED_LOCKS_REQUIRED(mu2) EXCLUSIVE_LOCKS_REQUIRED(mu1) {
+ return i;
+}
+
+int Foo_fun2(int i) EXCLUSIVE_LOCKS_REQUIRED(mu2) SHARED_LOCKS_REQUIRED(mu1) {
+ return i;
+}
+
+int Foo_func3(int i) LOCKS_EXCLUDED(mu1, mu2) {
+ return i;
+}
+
+static int Bar_fun1(int i) EXCLUSIVE_LOCKS_REQUIRED(mu1) {
+ return i;
+}
+
+void set_value(int *a, int value) EXCLUSIVE_LOCKS_REQUIRED(foo_.mu_) {
+ *a = value;
+}
+
+int get_value(int *p) SHARED_LOCKS_REQUIRED(foo_.mu_){
+ return *p;
+}
+
+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'}}
+
+ mutex_exclusive_lock(&mu1);
+ mutex_shared_lock(&mu2);
+ Foo_fun1(1);
+
+ mutex_shared_lock(&mu1); // expected-warning{{locking 'mu1' that is already locked}}
+ mutex_unlock(&mu1);
+ mutex_unlock(&mu2);
+ mutex_shared_lock(&mu1);
+ mutex_exclusive_lock(&mu2);
+ Foo_fun2(2);
+
+ mutex_unlock(&mu2);
+ mutex_unlock(&mu1);
+ mutex_exclusive_lock(&mu1);
+ Bar_fun1(3);
+ mutex_unlock(&mu1);
+
+ mutex_exclusive_lock(&mu1);
+ Foo_func3(4); // expected-warning{{cannot call function 'Foo_func3' while mutex 'mu1' is locked}}
+ 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_'}}
+ mutex_exclusive_lock(foo_.mu_);
+ set_value(&a_, 1);
+ mutex_unlock(foo_.mu_);
+ mutex_shared_lock(foo_.mu_);
+ (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}}
+ mutex_exclusive_lock(foo_.mu_);
+ c_ = 1;
+ (void)(*d_ == 1);
+ mutex_unlock(foo_.mu_);
+
+ return 0;
+}
diff --git a/test/Sema/warn-type-safety.c b/test/Sema/warn-type-safety.c
index 4ac453d380bd..dfab8f8c818b 100644
--- a/test/Sema/warn-type-safety.c
+++ b/test/Sema/warn-type-safety.c
@@ -7,7 +7,7 @@ struct A {};
typedef struct A *MPI_Datatype;
int wrong1(void *buf, MPI_Datatype datatype)
- __attribute__(( pointer_with_type_tag )); // expected-error {{attribute requires parameter 1 to be an identifier}}
+ __attribute__(( pointer_with_type_tag )); // expected-error {{'pointer_with_type_tag' attribute requires parameter 1 to be an identifier}}
int wrong2(void *buf, MPI_Datatype datatype)
__attribute__(( pointer_with_type_tag(mpi,0,7) )); // expected-error {{attribute parameter 2 is out of bounds}}
@@ -39,7 +39,7 @@ int wrong10(double buf, MPI_Datatype type)
extern struct A datatype_wrong1
- __attribute__(( type_tag_for_datatype )); // expected-error {{attribute requires parameter 1 to be an identifier}}
+ __attribute__(( type_tag_for_datatype )); // expected-error {{'type_tag_for_datatype' attribute requires parameter 1 to be an identifier}}
extern struct A datatype_wrong2
__attribute__(( type_tag_for_datatype(mpi,1,2) )); // expected-error {{expected a type}}
diff --git a/test/Sema/warn-unsequenced.c b/test/Sema/warn-unsequenced.c
new file mode 100644
index 000000000000..a14d3281662b
--- /dev/null
+++ b/test/Sema/warn-unsequenced.c
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -Wno-unused %s
+
+int f(int, int);
+
+typedef struct A {
+ int x, y;
+} A;
+
+void test() {
+ int a;
+ int xs[10];
+ a + ++a; // expected-warning {{unsequenced modification and access to 'a'}}
+ a = ++a; // expected-warning {{multiple unsequenced modifications to 'a'}}
+ a + a++; // expected-warning {{unsequenced modification and access to 'a'}}
+ a = a++; // expected-warning {{multiple unsequenced modifications to 'a'}}
+ (a++, a++); // ok
+ ++a + ++a; // expected-warning {{multiple unsequenced modifications}}
+ a++ + a++; // expected-warning {{multiple unsequenced modifications}}
+ a = xs[++a]; // expected-warning {{multiple unsequenced modifications}}
+ a = xs[a++]; // expected-warning {{multiple unsequenced modifications}}
+ a = (++a, ++a); // expected-warning {{multiple unsequenced modifications}}
+ a = (a++, ++a); // expected-warning {{multiple unsequenced modifications}}
+ a = (a++, a++); // expected-warning {{multiple unsequenced modifications}}
+ f(a, a); // ok
+ f(a = 0, a); // expected-warning {{unsequenced modification and access}}
+ f(a, a += 0); // expected-warning {{unsequenced modification and access}}
+ f(a = 0, a = 0); // expected-warning {{multiple unsequenced modifications}}
+ a = f(++a, 0); // ok
+ a = f(a++, 0); // ok
+ a = f(++a, a++); // expected-warning {{multiple unsequenced modifications}}
+
+ a = ++a; // expected-warning {{multiple unsequenced modifications}}
+ a += ++a; // expected-warning {{unsequenced modification and access}}
+
+ A agg1 = { a++, a++ }; // expected-warning {{multiple unsequenced modifications}}
+ A agg2 = { a++ + a, a++ }; // expected-warning {{unsequenced modification and access}}
+
+ (xs[2] && (a = 0)) + a; // ok
+ (0 && (a = 0)) + a; // ok
+ (1 && (a = 0)) + a; // expected-warning {{unsequenced modification and access}}
+
+ (xs[3] || (a = 0)) + a; // ok
+ (0 || (a = 0)) + a; // expected-warning {{unsequenced modification and access}}
+ (1 || (a = 0)) + a; // ok
+
+ (xs[4] ? a : ++a) + a; // ok
+ (0 ? a : ++a) + a; // expected-warning {{unsequenced modification and access}}
+ (1 ? a : ++a) + a; // ok
+ (xs[5] ? ++a : ++a) + a; // FIXME: warn here
+
+ (++a, xs[6] ? ++a : 0) + a; // FIXME: warn here
+
+ // Here, the read of the fourth 'a' might happen before or after the write to
+ // the second 'a'.
+ a += (a++, a) + a; // expected-warning {{unsequenced modification and access}}
+
+ int *p = xs;
+ a = *(a++, p); // ok
+ a = a++ && a; // ok
+
+ A *q = &agg1;
+ (q = &agg2)->y = q->x; // expected-warning {{unsequenced modification and access to 'q'}}
+
+ // This has undefined behavior if a == 0; otherwise, the side-effect of the
+ // increment is sequenced before the value computation of 'f(a, a)', which is
+ // sequenced before the value computation of the '&&', which is sequenced
+ // before the assignment. We treat the sequencing in '&&' as being
+ // unconditional.
+ a = a++ && f(a, a);
+
+ // This has undefined behavior if a != 0. FIXME: We should diagnose this.
+ (a && a++) + a;
+
+ (xs[7] && ++a) * (!xs[7] && ++a); // ok
+
+ xs[0] = (a = 1, a); // ok
+
+ xs[8] ? ++a + a++ : 0; // expected-warning {{multiple unsequenced modifications}}
+ xs[8] ? 0 : ++a + a++; // expected-warning {{multiple unsequenced modifications}}
+ xs[8] ? ++a : a++; // ok
+
+ xs[8] && (++a + a++); // expected-warning {{multiple unsequenced modifications}}
+ xs[8] || (++a + a++); // expected-warning {{multiple unsequenced modifications}}
+
+ (__builtin_classify_type(++a) ? 1 : 0) + ++a; // ok
+ (__builtin_constant_p(++a) ? 1 : 0) + ++a; // ok
+ (__builtin_expect(++a, 0) ? 1 : 0) + ++a; // FIXME: warn here
+}
diff --git a/test/Sema/warn-unused-function.c b/test/Sema/warn-unused-function.c
index a334e71e5067..013b925f89d8 100644
--- a/test/Sema/warn-unused-function.c
+++ b/test/Sema/warn-unused-function.c
@@ -12,10 +12,8 @@ int x = sizeof(f0());
static void f3();
extern void f3() { } // expected-warning{{unused}}
-// FIXME: This will trigger a warning when it should not.
-// Update once PR6281 is fixed.
-//inline static void f4();
-//void f4() { }
+inline static void f4();
+void f4() { } // expected-warning{{unused}}
static void __attribute__((used)) f5() {}
static void f6();
diff --git a/test/Sema/warn-unused-label.c b/test/Sema/warn-unused-label.c
index 48370a5fd641..4b1dbbf24692 100644
--- a/test/Sema/warn-unused-label.c
+++ b/test/Sema/warn-unused-label.c
@@ -9,3 +9,7 @@ void f() {
goto d;
return;
}
+
+void PR8455() {
+ L: __attribute__((unused)) return; // ok, no semicolon required
+}
diff --git a/test/Sema/warn-unused-parameters.c b/test/Sema/warn-unused-parameters.c
index af048e77e886..11db7300c5c4 100644
--- a/test/Sema/warn-unused-parameters.c
+++ b/test/Sema/warn-unused-parameters.c
@@ -22,7 +22,7 @@ static void achor() {};
// CHECK-unused: 1 warning generated
// RUN: %clang_cc1 -fblocks -fsyntax-only -Weverything %s 2>&1 | FileCheck -check-prefix=CHECK-everything %s
-// RUN: %clang_cc1 -fblocks -fsyntax-only -Weverything -Werror %s 2>&1 | FileCheck -check-prefix=CHECK-everything-error %s
+// RUN: not %clang_cc1 -fblocks -fsyntax-only -Weverything -Werror %s 2>&1 | FileCheck -check-prefix=CHECK-everything-error %s
// RUN: %clang_cc1 -fblocks -fsyntax-only -Weverything -Wno-unused %s 2>&1 | FileCheck -check-prefix=CHECK-everything-no-unused %s
// CHECK-everything: 6 warnings generated
// CHECK-everything-error: 5 errors generated
diff --git a/test/Sema/warn-variable-not-needed.c b/test/Sema/warn-variable-not-needed.c
new file mode 100644
index 000000000000..472ac8298999
--- /dev/null
+++ b/test/Sema/warn-variable-not-needed.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wall %s
+// expected-no-diagnostics
+
+static int a;
+int bar() {
+ extern int a;
+ return a;
+}
+static int a;
diff --git a/test/Sema/wchar.c b/test/Sema/wchar.c
index 816245f3c041..13c2f5855d5e 100644
--- a/test/Sema/wchar.c
+++ b/test/Sema/wchar.c
@@ -19,6 +19,6 @@ int check_wchar_size[sizeof(*L"") == sizeof(wchar_t) ? 1 : -1];
void foo() {
WCHAR_T_TYPE t1[] = L"x";
wchar_t tab[] = L"x";
- WCHAR_T_TYPE t2[] = "x"; // expected-error {{initializer}}
- char t3[] = L"x"; // expected-error {{initializer}}
+ WCHAR_T_TYPE t2[] = "x"; // expected-error {{initializing wide char array with non-wide string literal}}
+ char t3[] = L"x"; // expected-error {{initializing char array with wide string literal}}
}