aboutsummaryrefslogtreecommitdiff
path: root/test/Sema
diff options
context:
space:
mode:
Diffstat (limited to 'test/Sema')
-rw-r--r--test/Sema/MicrosoftCompatibility-x64.c13
-rw-r--r--test/Sema/MicrosoftCompatibility.c2
-rw-r--r--test/Sema/__try.c116
-rw-r--r--test/Sema/alias-redefinition.c23
-rw-r--r--test/Sema/align-systemz.c17
-rw-r--r--test/Sema/align-x86.c2
-rw-r--r--test/Sema/anonymous-struct-union.c7
-rw-r--r--test/Sema/assign.c5
-rw-r--r--test/Sema/atomic-compare.c5
-rw-r--r--test/Sema/attr-availability-android.c31
-rw-r--r--test/Sema/attr-availability-app-extensions.c18
-rw-r--r--test/Sema/attr-availability.c106
-rw-r--r--test/Sema/attr-capabilities.c4
-rw-r--r--test/Sema/attr-flag-enum.c73
-rw-r--r--test/Sema/attr-format.c7
-rw-r--r--test/Sema/attr-malloc.c10
-rw-r--r--test/Sema/attr-naked.cpp15
-rw-r--r--test/Sema/bitfield.c4
-rw-r--r--test/Sema/block-misc.c4
-rw-r--r--test/Sema/builtin-assume.c14
-rw-r--r--test/Sema/builtins-ppc.c51
-rw-r--r--test/Sema/builtins-x86.c47
-rw-r--r--test/Sema/builtins.cl8
-rw-r--r--test/Sema/callingconv.c2
-rw-r--r--test/Sema/complex-int.c2
-rw-r--r--test/Sema/crash-invalid-builtin.c4
-rw-r--r--test/Sema/dllexport.c8
-rw-r--r--test/Sema/dllimport.c8
-rw-r--r--test/Sema/format-strings-freebsd.c40
-rw-r--r--test/Sema/function.c6
-rw-r--r--test/Sema/i386-linux-android.c6
-rw-r--r--test/Sema/inline-asm-validate-aarch64.c16
-rw-r--r--test/Sema/integer-overflow.c147
-rw-r--r--test/Sema/invalid-assignment-constant-address-space.c8
-rw-r--r--test/Sema/member-reference.c2
-rw-r--r--test/Sema/ms-inline-asm.c2
-rw-r--r--test/Sema/parentheses.c10
-rw-r--r--test/Sema/pointer-addition.c6
-rw-r--r--test/Sema/pr9812.c21
-rw-r--r--test/Sema/pragma-ms_struct.c2
-rw-r--r--test/Sema/pragma-section-invalid.c7
-rw-r--r--test/Sema/statements.c15
-rw-r--r--test/Sema/struct-packed-align.c7
-rw-r--r--test/Sema/typo-correction.c12
-rw-r--r--test/Sema/vla.c3
-rw-r--r--test/Sema/warn-documentation-fixits.cpp7
-rw-r--r--test/Sema/warn-documentation-unknown-command.cpp11
-rw-r--r--test/Sema/warn-documentation.cpp6
-rw-r--r--test/Sema/warn-main.c2
-rw-r--r--test/Sema/warn-shift-negative.c6
-rw-r--r--test/Sema/warn-string-conversion.c25
-rw-r--r--test/Sema/warn-tautological-compare.c9
-rw-r--r--test/Sema/wchar.c2
-rw-r--r--test/Sema/x86-builtin-palignr.c7
-rw-r--r--test/Sema/x86_64-linux-android.c10
55 files changed, 923 insertions, 78 deletions
diff --git a/test/Sema/MicrosoftCompatibility-x64.c b/test/Sema/MicrosoftCompatibility-x64.c
index bf595af69939..7d1f64996eb3 100644
--- a/test/Sema/MicrosoftCompatibility-x64.c
+++ b/test/Sema/MicrosoftCompatibility-x64.c
@@ -1,8 +1,13 @@
-// RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-compatibility -triple x86_64-pc-win32
-int __stdcall f(void); /* expected-warning {{calling convention '__stdcall' ignored for this target}} */
+// RUN: %clang_cc1 %s -Wmicrosoft -verify -fms-compatibility -triple x86_64-pc-win32
-/* This should compile without warning because __stdcall is treated
-as __cdecl in MS compatibility mode for x64 compiles*/
+// None of these should warn. stdcall is treated as equivalent to cdecl on
+// x64.
+// expected-no-diagnostics
+
+int __stdcall f(void);
int __cdecl f(void) {
return 0;
}
+int __stdcall func_std(void);
+int __thiscall func_this(void);
+int __fastcall func_fast(void);
diff --git a/test/Sema/MicrosoftCompatibility.c b/test/Sema/MicrosoftCompatibility.c
index a193b26b4223..010033bba00c 100644
--- a/test/Sema/MicrosoftCompatibility.c
+++ b/test/Sema/MicrosoftCompatibility.c
@@ -21,3 +21,5 @@ struct __declspec(aligned) S2 {}; /* expected-warning {{__declspec attribute 'al
struct __declspec(appdomain) S3 {}; /* expected-warning {{__declspec attribute 'appdomain' is not supported}} */
__declspec(__noreturn__) void f7(void); /* expected-warning {{__declspec attribute '__noreturn__' is not supported}} */
+
+size_t x;
diff --git a/test/Sema/__try.c b/test/Sema/__try.c
index a355de9ccf94..cfb47e61d4ca 100644
--- a/test/Sema/__try.c
+++ b/test/Sema/__try.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -fborland-extensions -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-windows -fborland-extensions -DBORLAND -fsyntax-only -verify -fblocks %s
+// RUN: %clang_cc1 -triple x86_64-windows -fms-extensions -fsyntax-only -verify -fblocks %s
#define JOIN2(x,y) x ## y
#define JOIN(x,y) JOIN2(x,y)
@@ -10,9 +11,11 @@ typedef int DWORD;
struct EXCEPTION_INFO{};
-int __exception_code();
+unsigned long __exception_code();
+#ifdef BORLAND
struct EXCEPTION_INFO* __exception_info();
-void __abnormal_termination();
+#endif
+int __abnormal_termination();
#define GetExceptionCode __exception_code
#define GetExceptionInformation __exception_info
@@ -143,7 +146,11 @@ void TEST() {
__except( function_scope ? 1 : -1 ) {}
}
+#ifdef BORLAND
void TEST() {
+ (void)__abnormal_termination(); // expected-error{{only allowed in __finally block}}
+ (void)AbnormalTermination(); // expected-error{{only allowed in __finally block}}
+
__try {
(void)AbnormalTermination; // expected-error{{only allowed in __finally block}}
(void)__abnormal_termination; // expected-error{{only allowed in __finally block}}
@@ -160,15 +167,27 @@ void TEST() {
__abnormal_termination();
}
}
+#endif
void TEST() {
- (void)__exception_code; // expected-error{{only allowed in __except block}}
- (void)__exception_info; // expected-error{{only allowed in __except filter expression}}
- (void)__abnormal_termination; // expected-error{{only allowed in __finally block}}
-
- (void)GetExceptionCode(); // expected-error{{only allowed in __except block}}
+ (void)__exception_info(); // expected-error{{only allowed in __except filter expression}}
(void)GetExceptionInformation(); // expected-error{{only allowed in __except filter expression}}
- (void)AbnormalTermination(); // expected-error{{only allowed in __finally block}}
+}
+
+void TEST() {
+#ifndef BORLAND
+ (void)__exception_code; // expected-error{{builtin functions must be directly called}}
+#endif
+ (void)__exception_code(); // expected-error{{only allowed in __except block or filter expression}}
+ (void)GetExceptionCode(); // expected-error{{only allowed in __except block or filter expression}}
+}
+
+void TEST() {
+ __try {
+ } __except(1) {
+ GetExceptionCode(); // valid
+ GetExceptionInformation(); // expected-error{{only allowed in __except filter expression}}
+ }
}
void test_seh_leave_stmt() {
@@ -189,3 +208,82 @@ void test_seh_leave_stmt() {
__leave; // expected-error{{'__leave' statement not in __try block}}
}
+void test_jump_out_of___finally() {
+ while(1) {
+ __try {
+ } __finally {
+ continue; // expected-warning{{jump out of __finally block has undefined behavior}}
+ }
+ }
+ __try {
+ } __finally {
+ while (1) {
+ continue;
+ }
+ }
+
+ // Check that a deep __finally containing a block with a shallow continue
+ // doesn't trigger the warning.
+ while(1) {{{{
+ __try {
+ } __finally {
+ ^{
+ while(1)
+ continue;
+ }();
+ }
+ }}}}
+
+ while(1) {
+ __try {
+ } __finally {
+ break; // expected-warning{{jump out of __finally block has undefined behavior}}
+ }
+ }
+ switch(1) {
+ case 1:
+ __try {
+ } __finally {
+ break; // expected-warning{{jump out of __finally block has undefined behavior}}
+ }
+ }
+ __try {
+ } __finally {
+ while (1) {
+ break;
+ }
+ }
+
+ __try {
+ __try {
+ } __finally {
+ __leave; // expected-warning{{jump out of __finally block has undefined behavior}}
+ }
+ } __finally {
+ }
+ __try {
+ } __finally {
+ __try {
+ __leave;
+ } __finally {
+ }
+ }
+
+ __try {
+ } __finally {
+ return; // expected-warning{{jump out of __finally block has undefined behavior}}
+ }
+
+ __try {
+ } __finally {
+ ^{
+ return;
+ }();
+ }
+}
+
+void test_typo_in_except() {
+ __try {
+ } __except(undeclared_identifier) { // expected-error {{use of undeclared identifier 'undeclared_identifier'}} expected-error {{expected expression}}
+ }
+}
diff --git a/test/Sema/alias-redefinition.c b/test/Sema/alias-redefinition.c
index 6c6ebf80250b..91f4b2714cd0 100644
--- a/test/Sema/alias-redefinition.c
+++ b/test/Sema/alias-redefinition.c
@@ -23,22 +23,11 @@ void fun4(void);
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 var1 __attribute((alias("v1"))); // expected-error {{definition 'var1' cannot also be an alias}}
+static int var2 __attribute((alias("v2"))) = 2; // expected-error {{definition 'var2' cannot also be an alias}}
-int v2;
-int var2 = 2; // expected-note {{previous definition}}
-int var2 __attribute((alias("v2"))); // expected-error {{redefinition of 'var2'}}
+extern int var3 __attribute__((alias("C"))); // expected-note{{previous definition is here}}
+int var3 = 3; // expected-error{{redefinition of 'var3'}}
-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}}
+int var4; // expected-note{{previous definition is here}}
+extern int var4 __attribute__((alias("v4"))); // expected-error{{alias definition of 'var4' after tentative definition}}
diff --git a/test/Sema/align-systemz.c b/test/Sema/align-systemz.c
new file mode 100644
index 000000000000..6928549de110
--- /dev/null
+++ b/test/Sema/align-systemz.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple s390x-linux-gnu -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+// SystemZ prefers to align all global variables to two bytes,
+// but this should *not* be reflected in the ABI alignment as
+// retrieved via __alignof__.
+
+struct test {
+ signed char a;
+};
+
+char c;
+struct test s;
+
+int chk1[__alignof__(c) == 1 ? 1 : -1];
+int chk2[__alignof__(s) == 1 ? 1 : -1];
+
diff --git a/test/Sema/align-x86.c b/test/Sema/align-x86.c
index f112c6398c60..e3b8c704b858 100644
--- a/test/Sema/align-x86.c
+++ b/test/Sema/align-x86.c
@@ -27,6 +27,8 @@ double g6[3];
short chk1[__alignof__(g6) == 8 ? 1 : -1];
short chk2[__alignof__(double[3]) == 8 ? 1 : -1];
+enum { x = 18446744073709551615ULL } g7;
+short chk1[__alignof__(g7) == 8 ? 1 : -1];
// PR5637
diff --git a/test/Sema/anonymous-struct-union.c b/test/Sema/anonymous-struct-union.c
index 652383eabb72..c33bc52971e7 100644
--- a/test/Sema/anonymous-struct-union.c
+++ b/test/Sema/anonymous-struct-union.c
@@ -22,6 +22,7 @@ struct X {
};
void test_unqual_references(struct X x, const struct X xc) {
+ // expected-note@-1 3{{variable 'xc' declared const here}}
x.i = 0;
x.f = 0.0;
x.f2 = x.f;
@@ -29,9 +30,9 @@ void test_unqual_references(struct X x, const struct X xc) {
x.f3 = 0; // expected-error{{no member named 'f3'}}
x.a = 0;
- xc.d = 0.0; // expected-error{{read-only variable is not assignable}}
- xc.f = 0; // expected-error{{read-only variable is not assignable}}
- xc.a = 0; // expected-error{{read-only variable is not assignable}}
+ xc.d = 0.0; // expected-error{{cannot assign to variable 'xc' with const-qualified type 'const struct X'}}
+ xc.f = 0; // expected-error{{cannot assign to variable 'xc' with const-qualified type 'const struct X'}}
+ xc.a = 0; // expected-error{{cannot assign to variable 'xc' with const-qualified type 'const struct X'}}
}
diff --git a/test/Sema/assign.c b/test/Sema/assign.c
index 2d57029fc05f..1fff77864420 100644
--- a/test/Sema/assign.c
+++ b/test/Sema/assign.c
@@ -3,7 +3,10 @@
void *test1(void) { return 0; }
void test2 (const struct {int a;} *x) {
- x->a = 10; // expected-error {{read-only variable is not assignable}}
+ // expected-note@-1 {{variable 'x' declared const here}}
+
+ x->a = 10;
+ // expected-error-re@-1 {{cannot assign to variable 'x' with const-qualified type 'const struct (anonymous struct at {{.*}}assign.c:5:19) *'}}
}
typedef int arr[10];
diff --git a/test/Sema/atomic-compare.c b/test/Sema/atomic-compare.c
index 2eed09126026..01eb82004725 100644
--- a/test/Sema/atomic-compare.c
+++ b/test/Sema/atomic-compare.c
@@ -19,3 +19,8 @@ void f(_Atomic(int) a, _Atomic(int) b) {
if (!a > b) {} // no warning
if (!a > -1) {} // expected-warning {{comparison of constant -1 with boolean expression is always true}}
}
+
+typedef _Atomic(int) Ty;
+void PR23638(Ty *a) {
+ if (*a == 1) {} // no warning
+}
diff --git a/test/Sema/attr-availability-android.c b/test/Sema/attr-availability-android.c
new file mode 100644
index 000000000000..d4031b3b5292
--- /dev/null
+++ b/test/Sema/attr-availability-android.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 "-triple" "arm-linux-androideabi16" -fsyntax-only -verify %s
+
+void f0(int) __attribute__((availability(android,introduced=14,deprecated=19)));
+void f1(int) __attribute__((availability(android,introduced=16)));
+void f2(int) __attribute__((availability(android,introduced=14,deprecated=16))); // expected-note {{'f2' has been explicitly marked deprecated here}}
+void f3(int) __attribute__((availability(android,introduced=19)));
+void f4(int) __attribute__((availability(android,introduced=9,deprecated=11,obsoleted=16), availability(ios,introduced=2.0,deprecated=3.0))); // expected-note{{explicitly marked unavailable}}
+void f5(int) __attribute__((availability(ios,introduced=3.2), availability(android,unavailable))); // expected-note{{'f5' has been explicitly marked unavailable here}}
+
+void test() {
+ f0(0);
+ f1(0);
+ f2(0); // expected-warning{{'f2' is deprecated: first deprecated in Android 16}}
+ f3(0);
+ f4(0); // expected-error{{f4' is unavailable: obsoleted in Android 16}}
+ f5(0); // expected-error{{'f5' is unavailable: not available on Android}}
+}
+
+// rdar://10535640
+
+enum {
+ foo __attribute__((availability(android,introduced=8.0,deprecated=9.0)))
+};
+
+enum {
+ bar __attribute__((availability(android,introduced=8.0,deprecated=9.0))) = foo
+};
+
+enum __attribute__((availability(android,introduced=8.0,deprecated=9.0))) {
+ bar1 = foo
+};
diff --git a/test/Sema/attr-availability-app-extensions.c b/test/Sema/attr-availability-app-extensions.c
new file mode 100644
index 000000000000..a84709281938
--- /dev/null
+++ b/test/Sema/attr-availability-app-extensions.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9.0 -fsyntax-only -fapplication-extension %s -verify
+// RUN: %clang_cc1 -triple armv7-apple-ios9.0 -fsyntax-only -fapplication-extension %s -verify
+
+#if __has_feature(attribute_availability_app_extension)
+ __attribute__((availability(macosx_app_extension,unavailable)))
+ __attribute__((availability(ios_app_extension,unavailable)))
+#endif
+void f0(int); // expected-note {{'f0' has been explicitly marked unavailable here}}
+
+__attribute__((availability(macosx,unavailable)))
+__attribute__((availability(ios,unavailable)))
+void f1(int); // expected-note {{'f1' has been explicitly marked unavailable here}}
+
+void test() {
+ f0(1); // expected-error {{'f0' is unavailable: not available on}}
+ f1(1); // expected-error {{'f1' is unavailable}}
+}
+
diff --git a/test/Sema/attr-availability.c b/test/Sema/attr-availability.c
index b7a8e6ef0f59..d003e1e2e363 100644
--- a/test/Sema/attr-availability.c
+++ b/test/Sema/attr-availability.c
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fsyntax-only -fblocks -verify %s
+// RUN: %clang_cc1 -D WARN_PARTIAL -Wpartial-availability -triple x86_64-apple-darwin9 -fsyntax-only -fblocks -verify %s
+//
void f0() __attribute__((availability(macosx,introduced=10.4,deprecated=10.2))); // expected-warning{{feature cannot be deprecated in OS X version 10.2 before it was introduced in version 10.4; attribute ignored}}
void f1() __attribute__((availability(ios,obsoleted=2.1,deprecated=3.0))); // expected-warning{{feature cannot be obsoleted in iOS version 2.1 before it was deprecated in version 3.0; attribute ignored}}
@@ -13,9 +15,32 @@ ATSFontGetName(const char *oName) __attribute__((availability(macosx,introduced=
extern void
ATSFontGetPostScriptName(int flags) __attribute__((availability(macosx,introduced=8.0,obsoleted=9.0, message="use ATSFontGetFullPostScriptName"))); // expected-note {{'ATSFontGetPostScriptName' has been explicitly marked unavailable here}}
+#if defined(WARN_PARTIAL)
+// expected-note@+3 {{has been explicitly marked partial here}}
+#endif
+extern void
+PartiallyAvailable() __attribute__((availability(macosx,introduced=10.8)));
+
+enum __attribute__((availability(macosx,introduced=10.8))) PartialEnum {
+ kPartialEnumConstant,
+};
+
void test_10095131() {
ATSFontGetName("Hello"); // expected-warning {{'ATSFontGetName' is deprecated: first deprecated in OS X 9.0 - use CTFontCopyFullName}}
ATSFontGetPostScriptName(100); // expected-error {{'ATSFontGetPostScriptName' is unavailable: obsoleted in OS X 9.0 - use ATSFontGetFullPostScriptName}}
+
+#if defined(WARN_PARTIAL)
+ // expected-warning@+2 {{is partial: introduced in OS X 10.8}} expected-note@+2 {{explicitly redeclare 'PartiallyAvailable' to silence this warning}}
+#endif
+ PartiallyAvailable();
+}
+
+extern void PartiallyAvailable() ;
+void with_redeclaration() {
+ PartiallyAvailable(); // Don't warn.
+
+ // enums should never warn.
+ enum PartialEnum p = kPartialEnumConstant;
}
// rdar://10711037
@@ -54,3 +79,84 @@ void f8() {
extern int x2 __attribute__((availability(macosx,introduced=10.2))); // expected-note {{previous attribute is here}}
extern int x2 __attribute__((availability(macosx,introduced=10.5))); // expected-warning {{availability does not match previous declaration}}
+
+
+enum Original {
+ OriginalDeprecated __attribute__((availability(macosx, deprecated=10.2))), // expected-note + {{'OriginalDeprecated' has been explicitly marked deprecated here}}
+ OriginalUnavailable __attribute__((availability(macosx, unavailable))) // expected-note + {{'OriginalUnavailable' has been explicitly marked unavailable here}}
+};
+
+enum AllDeprecated {
+ AllDeprecatedCase, // expected-note + {{'AllDeprecatedCase' has been explicitly marked deprecated here}}
+ AllDeprecatedUnavailable __attribute__((availability(macosx, unavailable))) // expected-note + {{'AllDeprecatedUnavailable' has been explicitly marked unavailable here}}
+} __attribute__((availability(macosx, deprecated=10.2)));
+
+enum AllUnavailable {
+ AllUnavailableCase, // expected-note + {{'AllUnavailableCase' has been explicitly marked unavailable here}}
+} __attribute__((availability(macosx, unavailable)));
+
+enum User {
+ UserOD = OriginalDeprecated, // expected-warning {{deprecated}}
+ UserODDeprecated __attribute__((availability(macosx, deprecated=10.2))) = OriginalDeprecated,
+ UserODUnavailable __attribute__((availability(macosx, unavailable))) = OriginalDeprecated,
+
+ UserOU = OriginalUnavailable, // expected-error {{unavailable}}
+ UserOUDeprecated __attribute__((availability(macosx, deprecated=10.2))) = OriginalUnavailable, // expected-error {{unavailable}}
+ UserOUUnavailable __attribute__((availability(macosx, unavailable))) = OriginalUnavailable,
+
+ UserAD = AllDeprecatedCase, // expected-warning {{deprecated}}
+ UserADDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllDeprecatedCase,
+ UserADUnavailable __attribute__((availability(macosx, unavailable))) = AllDeprecatedCase,
+
+ UserADU = AllDeprecatedUnavailable, // expected-error {{unavailable}}
+ UserADUDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllDeprecatedUnavailable, // expected-error {{unavailable}}
+ UserADUUnavailable __attribute__((availability(macosx, unavailable))) = AllDeprecatedUnavailable,
+
+ UserAU = AllUnavailableCase, // expected-error {{unavailable}}
+ UserAUDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllUnavailableCase, // expected-error {{unavailable}}
+ UserAUUnavailable __attribute__((availability(macosx, unavailable))) = AllUnavailableCase,
+};
+
+enum UserDeprecated {
+ UserDeprecatedOD = OriginalDeprecated,
+ UserDeprecatedODDeprecated __attribute__((availability(macosx, deprecated=10.2))) = OriginalDeprecated,
+ UserDeprecatedODUnavailable __attribute__((availability(macosx, unavailable))) = OriginalDeprecated,
+
+ UserDeprecatedOU = OriginalUnavailable, // expected-error {{unavailable}}
+ UserDeprecatedOUDeprecated __attribute__((availability(macosx, deprecated=10.2))) = OriginalUnavailable, // expected-error {{unavailable}}
+ UserDeprecatedOUUnavailable __attribute__((availability(macosx, unavailable))) = OriginalUnavailable,
+
+ UserDeprecatedAD = AllDeprecatedCase,
+ UserDeprecatedADDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllDeprecatedCase,
+ UserDeprecatedADUnavailable __attribute__((availability(macosx, unavailable))) = AllDeprecatedCase,
+
+ UserDeprecatedADU = AllDeprecatedUnavailable, // expected-error {{unavailable}}
+ UserDeprecatedADUDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllDeprecatedUnavailable, // expected-error {{unavailable}}
+ UserDeprecatedADUUnavailable __attribute__((availability(macosx, unavailable))) = AllDeprecatedUnavailable,
+
+ UserDeprecatedAU = AllUnavailableCase, // expected-error {{unavailable}}
+ UserDeprecatedAUDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllUnavailableCase, // expected-error {{unavailable}}
+ UserDeprecatedAUUnavailable __attribute__((availability(macosx, unavailable))) = AllUnavailableCase,
+} __attribute__((availability(macosx, deprecated=10.2)));
+
+enum UserUnavailable {
+ UserUnavailableOD = OriginalDeprecated,
+ UserUnavailableODDeprecated __attribute__((availability(macosx, deprecated=10.2))) = OriginalDeprecated,
+ UserUnavailableODUnavailable __attribute__((availability(macosx, unavailable))) = OriginalDeprecated,
+
+ UserUnavailableOU = OriginalUnavailable,
+ UserUnavailableOUDeprecated __attribute__((availability(macosx, deprecated=10.2))) = OriginalUnavailable,
+ UserUnavailableOUUnavailable __attribute__((availability(macosx, unavailable))) = OriginalUnavailable,
+
+ UserUnavailableAD = AllDeprecatedCase,
+ UserUnavailableADDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllDeprecatedCase,
+ UserUnavailableADUnavailable __attribute__((availability(macosx, unavailable))) = AllDeprecatedCase,
+
+ UserUnavailableADU = AllDeprecatedUnavailable,
+ UserUnavailableADUDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllDeprecatedUnavailable,
+ UserUnavailableADUUnavailable __attribute__((availability(macosx, unavailable))) = AllDeprecatedUnavailable,
+
+ UserUnavailableAU = AllUnavailableCase,
+ UserUnavailableAUDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllUnavailableCase,
+ UserUnavailableAUUnavailable __attribute__((availability(macosx, unavailable))) = AllUnavailableCase,
+} __attribute__((availability(macosx, unavailable)));
diff --git a/test/Sema/attr-capabilities.c b/test/Sema/attr-capabilities.c
index cdbd2f3b2d26..5bfbdacf508f 100644
--- a/test/Sema/attr-capabilities.c
+++ b/test/Sema/attr-capabilities.c
@@ -7,8 +7,8 @@ struct NotACapability {};
// Test an invalid capability name
struct __attribute__((capability("wrong"))) IncorrectName {}; // expected-warning {{invalid capability name 'wrong'; capability name must be 'mutex' or 'role'}}
-int Test1 __attribute__((capability("test1"))); // expected-error {{'capability' attribute only applies to structs or typedefs}}
-int Test2 __attribute__((shared_capability("test2"))); // expected-error {{'shared_capability' attribute only applies to structs or typedefs}}
+int Test1 __attribute__((capability("test1"))); // expected-error {{'capability' attribute only applies to structs and typedefs}}
+int Test2 __attribute__((shared_capability("test2"))); // expected-error {{'shared_capability' attribute only applies to structs and typedefs}}
int Test3 __attribute__((acquire_capability("test3"))); // expected-warning {{'acquire_capability' attribute only applies to functions}}
int Test4 __attribute__((try_acquire_capability("test4"))); // expected-error {{'try_acquire_capability' attribute only applies to functions}}
int Test5 __attribute__((release_capability("test5"))); // expected-warning {{'release_capability' attribute only applies to functions}}
diff --git a/test/Sema/attr-flag-enum.c b/test/Sema/attr-flag-enum.c
new file mode 100644
index 000000000000..a53c1dc8e7d1
--- /dev/null
+++ b/test/Sema/attr-flag-enum.c
@@ -0,0 +1,73 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -std=c11 -Wassign-enum %s
+
+enum __attribute__((flag_enum)) flag {
+ ea = 0x1,
+ eb = 0x2,
+ ec = 0x8,
+};
+
+enum __attribute__((flag_enum)) flag2 {
+ ga = 0x1,
+ gb = 0x4,
+
+ gc = 0x5, // no-warning
+ gd = 0x7, // expected-warning {{enumeration value 'gd' is out of range}}
+ ge = ~0x2, // expected-warning {{enumeration value 'ge' is out of range}}
+ gf = ~0x4, // no-warning
+ gg = ~0x1, // no-warning
+ gh = ~0x5, // no-warning
+ gi = ~0x11, // expected-warning {{enumeration value 'gi' is out of range}}
+};
+
+enum __attribute__((flag_enum)) flag3 {
+ fa = 0x1,
+ fb = ~0x1u, // no-warning
+};
+
+// What happens here is that ~0x2 is negative, and so the enum must be signed.
+// But ~0x1u is unsigned and has the high bit set, so the enum must be 64-bit.
+// The result is that ~0x1u does not have high bits set, and so it is considered
+// to be an invalid value. See Sema::IsValueInFlagEnum in SemaDecl.cpp for more
+// discussion.
+enum __attribute__((flag_enum)) flag4 {
+ ha = 0x1,
+ hb = 0x2,
+
+ hc = ~0x1u, // expected-warning {{enumeration value 'hc' is out of range}}
+ hd = ~0x2, // no-warning
+};
+
+void f(void) {
+ enum flag e = 0; // no-warning
+ e = 0x1; // no-warning
+ e = 0x3; // no-warning
+ e = 0xa; // no-warning
+ e = 0x4; // expected-warning {{integer constant not in range of enumerated type}}
+ e = 0xf; // expected-warning {{integer constant not in range of enumerated type}}
+ e = ~0; // no-warning
+ e = ~0x1; // no-warning
+ e = ~0x2; // no-warning
+ e = ~0x3; // no-warning
+ e = ~0x4; // expected-warning {{integer constant not in range of enumerated type}}
+
+ switch (e) {
+ case 0: break; // no-warning
+ case 0x1: break; // no-warning
+ case 0x3: break; // no-warning
+ case 0xa: break; // no-warning
+ case 0x4: break; // expected-warning {{case value not in enumerated type}}
+ case 0xf: break; // expected-warning {{case value not in enumerated type}}
+ case ~0: break; // expected-warning {{case value not in enumerated type}}
+ case ~0x1: break; // expected-warning {{case value not in enumerated type}}
+ case ~0x2: break; // expected-warning {{case value not in enumerated type}}
+ case ~0x3: break; // expected-warning {{case value not in enumerated type}}
+ case ~0x4: break; // expected-warning {{case value not in enumerated type}}
+ default: break;
+ }
+
+ enum flag2 f = ~0x1; // no-warning
+ f = ~0x1u; // no-warning
+
+ enum flag4 h = ~0x1; // no-warning
+ h = ~0x1u; // expected-warning {{integer constant not in range of enumerated type}}
+}
diff --git a/test/Sema/attr-format.c b/test/Sema/attr-format.c
index 21d9585a57e9..3ea9d79a5fdf 100644
--- a/test/Sema/attr-format.c
+++ b/test/Sema/attr-format.c
@@ -57,6 +57,13 @@ void callnull(void){
null(0, (int*)0); // expected-warning {{incompatible pointer types}}
}
+// FreeBSD kernel extensions
+void a3(const char *a, ...) __attribute__((format(freebsd_kprintf, 1,2))); // no-error
+void b3(const char *a, ...) __attribute__((format(freebsd_kprintf, 1,1))); // expected-error {{'format' attribute parameter 3 is out of bounds}}
+void c3(const char *a, ...) __attribute__((format(freebsd_kprintf, 0,2))); // expected-error {{'format' attribute parameter 2 is out of bounds}}
+void d3(const char *a, int c) __attribute__((format(freebsd_kprintf, 1,2))); // expected-error {{format attribute requires variadic function}}
+void e3(char *str, int c, ...) __attribute__((format(freebsd_kprintf, 2,3))); // expected-error {{format argument not a string type}}
+
// PR4470
diff --git a/test/Sema/attr-malloc.c b/test/Sema/attr-malloc.c
index c78d15c802ce..5351d757a23f 100644
--- a/test/Sema/attr-malloc.c
+++ b/test/Sema/attr-malloc.c
@@ -6,16 +6,16 @@
// Declare malloc here explicitly so we don't depend on system headers.
void * malloc(size_t) __attribute((malloc));
-int no_vars __attribute((malloc)); // expected-warning {{functions returning a pointer type}}
+int no_vars __attribute((malloc)); // expected-warning {{attribute only applies to functions}}
-void returns_void (void) __attribute((malloc)); // expected-warning {{functions returning a pointer type}}
-int returns_int (void) __attribute((malloc)); // expected-warning {{functions returning a pointer type}}
+void returns_void (void) __attribute((malloc)); // expected-warning {{attribute only applies to return values that are pointers}}
+int returns_int (void) __attribute((malloc)); // expected-warning {{attribute only applies to return values that are pointers}}
int * returns_intptr(void) __attribute((malloc)); // no-warning
typedef int * iptr;
iptr returns_iptr (void) __attribute((malloc)); // no-warning
-__attribute((malloc)) void *(*f)(); // expected-warning{{'malloc' attribute only applies to functions returning a pointer type}}
-__attribute((malloc)) int (*g)(); // expected-warning{{'malloc' attribute only applies to functions returning a pointer type}}
+__attribute((malloc)) void *(*f)(); // expected-warning{{attribute only applies to functions}}
+__attribute((malloc)) int (*g)(); // expected-warning{{attribute only applies to functions}}
__attribute((malloc))
void * xalloc(unsigned n) { return malloc(n); } // no-warning
diff --git a/test/Sema/attr-naked.cpp b/test/Sema/attr-naked.cpp
new file mode 100644
index 000000000000..eaa8e223b83e
--- /dev/null
+++ b/test/Sema/attr-naked.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -triple arm-none-linux
+class Foo {
+ void bar();
+ static void bar2();
+ unsigned v;
+ static unsigned s;
+};
+
+void __attribute__((naked)) Foo::bar() { // expected-note{{attribute is here}}
+ asm("mov r2, %0" : : "r"(v)); // expected-error{{'this' pointer references not allowed in naked functions}}
+}
+
+void __attribute__((naked)) Foo::bar2() {
+ asm("mov r2, %0" : : "r"(s)); // static member reference is OK
+}
diff --git a/test/Sema/bitfield.c b/test/Sema/bitfield.c
index fb72213475ae..f214b671f6f9 100644
--- a/test/Sema/bitfield.c
+++ b/test/Sema/bitfield.c
@@ -74,3 +74,7 @@ typedef __typeof__(+(--t5.n)) Signed; // This should not promote to signed.
typedef __typeof__(+(t5.n++)) Unsigned; // Post-increment is underspecified, but seems to
typedef __typeof__(+(t5.n--)) Unsigned; // also act like compound-assignment.
+
+struct Test6 {
+ : 0.0; // expected-error{{type name requires a specifier or qualifier}}
+};
diff --git a/test/Sema/block-misc.c b/test/Sema/block-misc.c
index 0ca4f20f3695..c57b3e141064 100644
--- a/test/Sema/block-misc.c
+++ b/test/Sema/block-misc.c
@@ -184,8 +184,8 @@ void test17() {
}
void test18() {
- void (^const blockA)(void) = ^{ };
- blockA = ^{ }; // expected-error {{read-only variable is not assignable}}
+ void (^const blockA)(void) = ^{ }; // expected-note {{variable 'blockA' declared const here}}
+ blockA = ^{ }; // expected-error {{cannot assign to variable 'blockA' with const-qualified type 'void (^const)(void)}}
}
// rdar://7072507
diff --git a/test/Sema/builtin-assume.c b/test/Sema/builtin-assume.c
index 512eeeccdc4a..43b31375f200 100644
--- a/test/Sema/builtin-assume.c
+++ b/test/Sema/builtin-assume.c
@@ -1,16 +1,28 @@
// RUN: %clang_cc1 -triple i386-mingw32 -fms-extensions -fsyntax-only -verify %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
+int nonconst(void);
+int isconst(void) __attribute__((const));
+int ispure(int) __attribute__((pure));
+
int foo(int *a, int i) {
#ifdef _MSC_VER
__assume(i != 4);
__assume(++i > 2); //expected-warning {{the argument to '__assume' has side effects that will be discarded}}
+ __assume(nonconst() > 2); //expected-warning {{the argument to '__assume' has side effects that will be discarded}}
+ __assume(isconst() > 2);
+ __assume(ispure(i) > 2);
+ __assume(ispure(++i) > 2); //expected-warning {{the argument to '__assume' has side effects that will be discarded}}
int test = sizeof(struct{char qq[(__assume(i != 5), 7)];});
#else
__builtin_assume(i != 4);
__builtin_assume(++i > 2); //expected-warning {{the argument to '__builtin_assume' has side effects that will be discarded}}
-
+ __builtin_assume(nonconst() > 2); //expected-warning {{the argument to '__builtin_assume' has side effects that will be discarded}}
+ __builtin_assume(isconst() > 2);
+ __builtin_assume(ispure(i) > 2);
+ __builtin_assume(ispure(++i) > 2); //expected-warning {{the argument to '__builtin_assume' has side effects that will be discarded}}
+
int test = sizeof(struct{char qq[(__builtin_assume(i != 5), 7)];});
#endif
return a[i];
diff --git a/test/Sema/builtins-ppc.c b/test/Sema/builtins-ppc.c
new file mode 100644
index 000000000000..60872a614e4c
--- /dev/null
+++ b/test/Sema/builtins-ppc.c
@@ -0,0 +1,51 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -faltivec -target-feature +htm \
+// RUN: -triple powerpc64-unknown-unknown -DTEST_HTM -fsyntax-only \
+// RUN: -verify %s
+
+// RUN: %clang_cc1 -faltivec -target-feature +crypto \
+// RUN: -triple powerpc64le-unknown-unknown -DTEST_CRYPTO -fsyntax-only \
+// RUN: -verify %s
+
+#ifdef TEST_HTM
+void test_htm() {
+ __builtin_tbegin(4); // expected-error {{argument should be a value from 0 to 1}}
+ __builtin_tend(-1); // expected-error {{argument should be a value from 0 to 1}}
+ __builtin_tsr(55); // expected-error {{argument should be a value from 0 to 7}}
+ __builtin_tabortwc(-5, 2, 3); // expected-error {{argument should be a value from 0 to 31}}
+ __builtin_tabortdc(55, 2, 3); // expected-error {{argument should be a value from 0 to 31}}
+ __builtin_tabortwci(-5, 2, 5); // expected-error {{argument should be a value from 0 to 31}}
+ __builtin_tabortwci(5, 2, 55); // expected-error {{argument should be a value from 0 to 31}}
+ __builtin_tabortdci(-5, 2, 5); // expected-error {{argument should be a value from 0 to 31}}
+ __builtin_tabortdci(5, 2, 55); // expected-error {{argument should be a value from 0 to 31}}
+}
+#endif
+
+
+#ifdef TEST_CRYPTO
+#include <altivec.h>
+
+#define W_INIT { 0x01020304, 0x05060708, 0x090A0B0C, 0x0D0E0F10 };
+#define D_INIT { 0x0102030405060708, 0x090A0B0C0D0E0F10 };
+vector unsigned int test_vshasigmaw_or(void)
+{
+ vector unsigned int a = W_INIT
+ vector unsigned int b = __builtin_crypto_vshasigmaw(a, 2, 15); // expected-error {{argument should be a value from 0 to 1}}
+ vector unsigned int c = __builtin_crypto_vshasigmaw(a, -1, 15); // expected-error {{argument should be a value from 0 to 1}}
+ vector unsigned int d = __builtin_crypto_vshasigmaw(a, 0, 85); // expected-error {{argument should be a value from 0 to 15}}
+ vector unsigned int e = __builtin_crypto_vshasigmaw(a, 1, -15); // expected-error {{argument should be a value from 0 to 15}}
+ return __builtin_crypto_vshasigmaw(a, 1, 15);
+}
+
+vector unsigned long long test_vshasigmad_or(void)
+{
+ vector unsigned long long a = D_INIT
+ vector unsigned long long b = __builtin_crypto_vshasigmad(a, 2, 15); // expected-error {{argument should be a value from 0 to 1}}
+ vector unsigned long long c = __builtin_crypto_vshasigmad(a, -1, 15); // expected-error {{argument should be a value from 0 to 1}}
+ vector unsigned long long d = __builtin_crypto_vshasigmad(a, 0, 85); // expected-error {{argument should be a value from 0 to 1}}
+ vector unsigned long long e = __builtin_crypto_vshasigmad(a, 1, -15); // expected-error {{argument should be a value from 0 to 1}}
+ return __builtin_crypto_vshasigmad(a, 0, 15);
+}
+
+#endif
+
diff --git a/test/Sema/builtins-x86.c b/test/Sema/builtins-x86.c
index 9929e6135c00..326d2a3a7a16 100644
--- a/test/Sema/builtins-x86.c
+++ b/test/Sema/builtins-x86.c
@@ -1,8 +1,15 @@
// RUN: %clang_cc1 -triple=x86_64-apple-darwin -fsyntax-only -verify %s
+typedef long long __m128i __attribute__((__vector_size__(16)));
typedef float __m128 __attribute__((__vector_size__(16)));
typedef double __m128d __attribute__((__vector_size__(16)));
+typedef float __m512 __attribute__((__vector_size__(64)));
+typedef double __m512d __attribute__((__vector_size__(64)));
+
+typedef unsigned char __mmask8;
+typedef unsigned short __mmask16;
+
__m128 test__builtin_ia32_cmpps(__m128 __a, __m128 __b) {
__builtin_ia32_cmpps(__a, __b, 32); // expected-error {{argument should be a value from 0 to 31}}
}
@@ -18,3 +25,43 @@ __m128 test__builtin_ia32_cmpss(__m128 __a, __m128 __b) {
__m128d test__builtin_ia32_cmpsd(__m128d __a, __m128d __b) {
__builtin_ia32_cmpsd(__a, __b, 32); // expected-error {{argument should be a value from 0 to 31}}
}
+
+__mmask16 test__builtin_ia32_cmpps512_mask(__m512d __a, __m512d __b) {
+ __builtin_ia32_cmpps512_mask(__a, __b, 32, -1, 0); // expected-error {{argument should be a value from 0 to 31}}
+}
+
+__mmask8 test__builtin_ia32_cmppd512_mask(__m512d __a, __m512d __b) {
+ __builtin_ia32_cmppd512_mask(__a, __b, 32, -1, 0); // expected-error {{argument should be a value from 0 to 31}}
+}
+
+__m128i test__builtin_ia32_vpcomub(__m128i __a, __m128i __b) {
+ __builtin_ia32_vpcomub(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}}
+}
+
+__m128i test__builtin_ia32_vpcomuw(__m128i __a, __m128i __b) {
+ __builtin_ia32_vpcomuw(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}}
+}
+
+__m128i test__builtin_ia32_vpcomud(__m128i __a, __m128i __b) {
+ __builtin_ia32_vpcomud(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}}
+}
+
+__m128i test__builtin_ia32_vpcomuq(__m128i __a, __m128i __b) {
+ __builtin_ia32_vpcomuq(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}}
+}
+
+__m128i test__builtin_ia32_vpcomb(__m128i __a, __m128i __b) {
+ __builtin_ia32_vpcomub(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}}
+}
+
+__m128i test__builtin_ia32_vpcomw(__m128i __a, __m128i __b) {
+ __builtin_ia32_vpcomuw(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}}
+}
+
+__m128i test__builtin_ia32_vpcomd(__m128i __a, __m128i __b) {
+ __builtin_ia32_vpcomud(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}}
+}
+
+__m128i test__builtin_ia32_vpcomq(__m128i __a, __m128i __b) {
+ __builtin_ia32_vpcomuq(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}}
+}
diff --git a/test/Sema/builtins.cl b/test/Sema/builtins.cl
new file mode 100644
index 000000000000..8cde8f3d10ff
--- /dev/null
+++ b/test/Sema/builtins.cl
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic
+// expected-no-diagnostics
+
+kernel void test(global float *out, global float *in, global int* in2) {
+ out[0] = __builtin_nanf("");
+ __builtin_memcpy(out, in, 32);
+ out[0] = __builtin_frexpf(in[0], in2);
+}
diff --git a/test/Sema/callingconv.c b/test/Sema/callingconv.c
index 6a8be5ae050f..c7a4821412cd 100644
--- a/test/Sema/callingconv.c
+++ b/test/Sema/callingconv.c
@@ -59,8 +59,6 @@ void __attribute__((cdecl)) ctest3() {}
typedef __attribute__((stdcall)) void (*PROC)();
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);
diff --git a/test/Sema/complex-int.c b/test/Sema/complex-int.c
index 32249b35e1c5..2b797e5a14ad 100644
--- a/test/Sema/complex-int.c
+++ b/test/Sema/complex-int.c
@@ -8,6 +8,8 @@ __complex__ signed yy;
__complex__ int result;
int ii;
int aa = 1 + 1.0iF;
+int bb = 0;
+bb += 1i;
result = arr*ii;
result = ii*brr;
diff --git a/test/Sema/crash-invalid-builtin.c b/test/Sema/crash-invalid-builtin.c
new file mode 100644
index 000000000000..1c5221fa40d6
--- /dev/null
+++ b/test/Sema/crash-invalid-builtin.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin -fsyntax-only -verify %s
+// PR23086
+
+__builtin_isinf(...); // expected-warning {{type specifier missing, defaults to 'int'}} expected-error {{ISO C requires a named parameter before '...'}} // expected-error {{conflicting types for '__builtin_isinf'}} // expected-note {{'__builtin_isinf' is a builtin with type 'int ()'}}
diff --git a/test/Sema/dllexport.c b/test/Sema/dllexport.c
index 76b6f6dc5a0e..69aad2eb54c0 100644
--- a/test/Sema/dllexport.c
+++ b/test/Sema/dllexport.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -triple i686-win32 -fsyntax-only -verify -std=c99 %s
-// RUN: %clang_cc1 -triple x86_64-win32 -fsyntax-only -verify -std=c11 %s
-// RUN: %clang_cc1 -triple i686-mingw32 -fsyntax-only -verify -std=c11 %s
-// RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -verify -std=c99 %s
+// RUN: %clang_cc1 -triple i686-win32 -fsyntax-only -fms-extensions -verify -std=c99 %s
+// RUN: %clang_cc1 -triple x86_64-win32 -fsyntax-only -fms-extensions -verify -std=c11 %s
+// RUN: %clang_cc1 -triple i686-mingw32 -fsyntax-only -fms-extensions -verify -std=c11 %s
+// RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -fms-extensions -verify -std=c99 %s
// Invalid usage.
__declspec(dllexport) typedef int typedef1; // expected-warning{{'dllexport' attribute only applies to variables and functions}}
diff --git a/test/Sema/dllimport.c b/test/Sema/dllimport.c
index ac883822dea1..e066abdb72d3 100644
--- a/test/Sema/dllimport.c
+++ b/test/Sema/dllimport.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -triple i686-win32 -fsyntax-only -verify -std=c99 -DMS %s
-// RUN: %clang_cc1 -triple x86_64-win32 -fsyntax-only -verify -std=c11 -DMS %s
-// RUN: %clang_cc1 -triple i686-mingw32 -fsyntax-only -verify -std=c11 -DGNU %s
-// RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -verify -std=c99 -DGNU %s
+// RUN: %clang_cc1 -triple i686-win32 -fsyntax-only -fms-extensions -verify -std=c99 -DMS %s
+// RUN: %clang_cc1 -triple x86_64-win32 -fsyntax-only -fms-extensions -verify -std=c11 -DMS %s
+// RUN: %clang_cc1 -triple i686-mingw32 -fsyntax-only -fms-extensions -verify -std=c11 -DGNU %s
+// RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -fms-extensions -verify -std=c99 -DGNU %s
// Invalid usage.
__declspec(dllimport) typedef int typedef1; // expected-warning{{'dllimport' attribute only applies to variables and functions}}
diff --git a/test/Sema/format-strings-freebsd.c b/test/Sema/format-strings-freebsd.c
new file mode 100644
index 000000000000..cdf273ae1093
--- /dev/null
+++ b/test/Sema/format-strings-freebsd.c
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple i386-unknown-freebsd %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-unknown-freebsd %s
+
+// Test FreeBSD kernel printf extensions.
+int freebsd_kernel_printf(const char *, ...) __attribute__((__format__(__freebsd_kprintf__, 1, 2)));
+
+void check_freebsd_kernel_extensions(int i, long l, char *s)
+{
+ // %b expects an int and a char *
+ freebsd_kernel_printf("reg=%b\n", i, "\10\2BITTWO\1BITONE\n"); // no-warning
+ freebsd_kernel_printf("reg=%b\n", l, "\10\2BITTWO\1BITONE\n"); // expected-warning{{format specifies type 'int' but the argument has type 'long'}}
+ freebsd_kernel_printf("reg=%b\n", i, l); // expected-warning{{format specifies type 'char *' but the argument has type 'long'}}
+ freebsd_kernel_printf("reg=%b\n", i); // expected-warning{{more '%' conversions than data arguments}}
+ freebsd_kernel_printf("reg=%b\n", i, "\10\2BITTWO\1BITONE\n", l); // expected-warning{{data argument not used by format string}}
+
+ // %D expects an unsigned char * and a char *
+ freebsd_kernel_printf("%6D", s, ":"); // no-warning
+ freebsd_kernel_printf("%6D", i, ":"); // expected-warning{{format specifies type 'void *' but the argument has type 'int'}}
+ freebsd_kernel_printf("%6D", s, i); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
+ freebsd_kernel_printf("%6D", s); // expected-warning{{more '%' conversions than data arguments}}
+ freebsd_kernel_printf("%6D", s, ":", i); // expected-warning{{data argument not used by format string}}
+
+ freebsd_kernel_printf("%*D", 42, s, ":"); // no-warning
+ freebsd_kernel_printf("%*D", 42, i, ":"); // expected-warning{{format specifies type 'void *' but the argument has type 'int'}}
+ freebsd_kernel_printf("%*D", 42, s, i); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
+ freebsd_kernel_printf("%*D", 42, s); // expected-warning{{more '%' conversions than data arguments}}
+ freebsd_kernel_printf("%*D", 42, s, ":", i); // expected-warning{{data argument not used by format string}}
+
+ // %r expects an int
+ freebsd_kernel_printf("%r", i); // no-warning
+ freebsd_kernel_printf("%r", l); // expected-warning{{format specifies type 'int' but the argument has type 'long'}}
+ freebsd_kernel_printf("%lr", i); // expected-warning{{format specifies type 'long' but the argument has type 'int'}}
+ freebsd_kernel_printf("%lr", l); // no-warning
+
+ // %y expects an int
+ freebsd_kernel_printf("%y", i); // no-warning
+ freebsd_kernel_printf("%y", l); // expected-warning{{format specifies type 'int' but the argument has type 'long'}}
+ freebsd_kernel_printf("%ly", i); // expected-warning{{format specifies type 'long' but the argument has type 'int'}}
+ freebsd_kernel_printf("%ly", l); // no-warning
+}
diff --git a/test/Sema/function.c b/test/Sema/function.c
index 81d303c27f62..26be61416b3c 100644
--- a/test/Sema/function.c
+++ b/test/Sema/function.c
@@ -113,3 +113,9 @@ void t22(int *ptr, int (*array)[3]) {
decays(array);
no_decay(array);
}
+
+void const Bar (void); // ok on decl
+// PR 20146
+void const Bar (void) // expected-warning {{function cannot return qualified void type 'const void'}}
+{
+}
diff --git a/test/Sema/i386-linux-android.c b/test/Sema/i386-linux-android.c
new file mode 100644
index 000000000000..a22cef7bfdd0
--- /dev/null
+++ b/test/Sema/i386-linux-android.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple i386-linux-android -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+extern int a1_0[sizeof(long double) == 8 ? 1 : -1];
+extern int a1_i[__alignof(long double) == 4 ? 1 : -1];
+
diff --git a/test/Sema/inline-asm-validate-aarch64.c b/test/Sema/inline-asm-validate-aarch64.c
index 1364b6421eb0..014767d5a392 100644
--- a/test/Sema/inline-asm-validate-aarch64.c
+++ b/test/Sema/inline-asm-validate-aarch64.c
@@ -36,3 +36,19 @@ uint8_t constraint_r_symbolic_macro(uint8_t *addr) {
return byte;
}
+
+// CHECK: warning: value size does not match register size specified by the constraint and modifier
+// CHECK: asm ("%w0 %w1 %2" : "+r" (one) : "r" (wide_two));
+// CHECK: note: use constraint modifier "w"
+// CHECK: fix-it:{{.*}}:{47:17-47:19}:"%w2"
+
+void read_write_modifier0(int one, int two) {
+ long wide_two = two;
+ asm ("%w0 %w1 %2" : "+r" (one) : "r" (wide_two));
+}
+
+// CHECK-NOT: warning:
+void read_write_modifier1(int one, int two) {
+ long wide_two = two;
+ asm ("%w0 %1" : "+r" (one), "+r" (wide_two));
+}
diff --git a/test/Sema/integer-overflow.c b/test/Sema/integer-overflow.c
new file mode 100644
index 000000000000..44fbcd4c818e
--- /dev/null
+++ b/test/Sema/integer-overflow.c
@@ -0,0 +1,147 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+typedef unsigned long long uint64_t;
+typedef unsigned long long uint32_t;
+
+uint64_t f0(uint64_t);
+uint64_t f1(uint64_t, uint32_t);
+uint64_t f2(uint64_t, ...);
+
+static const uint64_t overflow = 1 * 4608 * 1024 * 1024; // expected-warning {{overflow in expression; result is 536870912 with type 'int'}}
+
+uint64_t check_integer_overflows(int i) {
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+ uint64_t overflow = 4608 * 1024 * 1024,
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+ overflow2 = (uint64_t)(4608 * 1024 * 1024),
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+ overflow3 = (uint64_t)(4608 * 1024 * 1024 * i),
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+ overflow4 = (1ULL * ((4608) * ((1024) * (1024))) + 2ULL),
+// expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}}
+ multi_overflow = (uint64_t)((uint64_t)(4608 * 1024 * 1024) * (uint64_t)(4608 * 1024 * 1024));
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+ overflow += overflow2 = overflow3 = (uint64_t)(4608 * 1024 * 1024);
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+ overflow += overflow2 = overflow3 = 4608 * 1024 * 1024;
+
+ uint64_t not_overflow = 4608 * 1024 * 1024ULL;
+ uint64_t not_overflow2 = (1ULL * ((uint64_t)(4608) * (1024 * 1024)) + 2ULL);
+
+// expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}}
+ overflow = 4608 * 1024 * 1024 ? 4608 * 1024 * 1024 : 0;
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+ overflow = 0 ? 0 : 4608 * 1024 * 1024;
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+ if (4608 * 1024 * 1024)
+ return 0;
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+ if ((uint64_t)(4608 * 1024 * 1024))
+ return 1;
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+ if ((uint64_t)(4608 * 1024 * 1024))
+ return 2;
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+ if ((uint64_t)(4608 * 1024 * 1024 * i))
+ return 3;
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+ if ((1ULL * ((4608) * ((1024) * (1024))) + 2ULL))
+ return 4;
+
+// expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}}
+ if ((uint64_t)((uint64_t)(4608 * 1024 * 1024) * (uint64_t)(4608 * 1024 * 1024)))
+ return 5;
+
+ switch (i) {
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+ case 4608 * 1024 * 1024:
+ return 6;
+// expected-warning@+1 {{overflow in expression; result is 537919488 with type 'int'}}
+ case (uint64_t)(4609 * 1024 * 1024):
+ return 7;
+// expected-error@+1 {{expression is not an integer constant expression}}
+ case ((uint64_t)(4608 * 1024 * 1024 * i)):
+ return 8;
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+ case ((1ULL * ((4608) * ((1024) * (1024))) + 2ULL)):
+ return 9;
+// expected-warning@+2 2{{overflow in expression; result is 536870912 with type 'int'}}
+// expected-warning@+1 {{overflow converting case value to switch condition type (288230376151711744 to 0)}}
+ case ((uint64_t)((uint64_t)(4608 * 1024 * 1024) * (uint64_t)(4608 * 1024 * 1024))):
+ return 10;
+ }
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+ while (4608 * 1024 * 1024);
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+ while ((uint64_t)(4608 * 1024 * 1024));
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+ while ((uint64_t)(4608 * 1024 * 1024));
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+ while ((uint64_t)(4608 * 1024 * 1024 * i));
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+ while ((1ULL * ((4608) * ((1024) * (1024))) + 2ULL));
+
+// expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}}
+ while ((uint64_t)((uint64_t)(4608 * 1024 * 1024) * (uint64_t)(4608 * 1024 * 1024)));
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+ do { } while (4608 * 1024 * 1024);
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+ do { } while ((uint64_t)(4608 * 1024 * 1024));
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+ do { } while ((uint64_t)(4608 * 1024 * 1024));
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+ do { } while ((uint64_t)(4608 * 1024 * 1024 * i));
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+ do { } while ((1ULL * ((4608) * ((1024) * (1024))) + 2ULL));
+
+// expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}}
+ do { } while ((uint64_t)((uint64_t)(4608 * 1024 * 1024) * (uint64_t)(4608 * 1024 * 1024)));
+
+// expected-warning@+3 {{overflow in expression; result is 536870912 with type 'int'}}
+// expected-warning@+3 {{overflow in expression; result is 536870912 with type 'int'}}
+// expected-warning@+3 {{overflow in expression; result is 536870912 with type 'int'}}
+ for (uint64_t i = 4608 * 1024 * 1024;
+ (uint64_t)(4608 * 1024 * 1024);
+ i += (uint64_t)(4608 * 1024 * 1024 * i));
+
+// expected-warning@+3 {{overflow in expression; result is 536870912 with type 'int'}}
+// expected-warning@+3 2{{overflow in expression; result is 536870912 with type 'int'}}
+// expected-warning@+3 2{{overflow in expression; result is 536870912 with type 'int'}}
+ for (uint64_t i = (1ULL * ((4608) * ((1024) * (1024))) + 2ULL);
+ ((uint64_t)((uint64_t)(4608 * 1024 * 1024) * (uint64_t)(4608 * 1024 * 1024)));
+ i = ((4608 * 1024 * 1024) + ((uint64_t)(4608 * 1024 * 1024))));
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+ _Complex long long x = 4608 * 1024 * 1024;
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+ (__real__ x) = 4608 * 1024 * 1024;
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+ (__imag__ x) = 4608 * 1024 * 1024;
+
+// expected-warning@+4 {{overflow in expression; result is 536870912 with type 'int'}}
+// expected-warning@+3 {{array index 536870912 is past the end of the array (which contains 10 elements)}}
+// expected-note@+1 {{array 'a' declared here}}
+ uint64_t a[10];
+ a[4608 * 1024 * 1024] = 1i;
+
+// expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}}
+ return ((4608 * 1024 * 1024) + ((uint64_t)(4608 * 1024 * 1024)));
+}
diff --git a/test/Sema/invalid-assignment-constant-address-space.c b/test/Sema/invalid-assignment-constant-address-space.c
new file mode 100644
index 000000000000..de2af64d00ec
--- /dev/null
+++ b/test/Sema/invalid-assignment-constant-address-space.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+
+#define OPENCL_CONSTANT 16776962
+int __attribute__((address_space(OPENCL_CONSTANT))) c[3] = {0};
+
+void foo() {
+ c[0] = 1; //expected-error{{read-only variable is not assignable}}
+}
diff --git a/test/Sema/member-reference.c b/test/Sema/member-reference.c
index 8939fd515709..4004673dfdac 100644
--- a/test/Sema/member-reference.c
+++ b/test/Sema/member-reference.c
@@ -20,5 +20,5 @@ void g(void) {
}
int PR17762(struct simple c) {
- return c->i; // expected-error {{member reference type 'struct simple' is not a pointer; maybe you meant to use '.'?}}
+ return c->i; // expected-error {{member reference type 'struct simple' is not a pointer; did you mean to use '.'?}}
}
diff --git a/test/Sema/ms-inline-asm.c b/test/Sema/ms-inline-asm.c
index 4c6948f4d45d..abf10b67cce1 100644
--- a/test/Sema/ms-inline-asm.c
+++ b/test/Sema/ms-inline-asm.c
@@ -1,5 +1,5 @@
// REQUIRES: x86-registered-target
-// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fasm-blocks -Wno-microsoft -Wunused-label -verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fms-extensions -fasm-blocks -Wno-microsoft -Wunused-label -verify -fsyntax-only
void t1(void) {
__asm __asm // expected-error {{__asm used with no assembly instructions}}
diff --git a/test/Sema/parentheses.c b/test/Sema/parentheses.c
index b7f1b6e93aa5..739561dd2b33 100644
--- a/test/Sema/parentheses.c
+++ b/test/Sema/parentheses.c
@@ -80,7 +80,7 @@ void bitwise_rel(unsigned i) {
_Bool someConditionFunc();
-void conditional_op(int x, int y, _Bool b) {
+void conditional_op(int x, int y, _Bool b, void* p) {
(void)(x + someConditionFunc() ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '+'}} \
// expected-note {{place parentheses around the '+' expression to silence this warning}} \
// expected-note {{place parentheses around the '?:' expression to evaluate it first}}
@@ -116,6 +116,14 @@ void conditional_op(int x, int y, _Bool b) {
// CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:24-[[@LINE-6]]:24}:")"
(void)(x % 2 ? 1 : 2); // no warning
+
+ (void)(x + p ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '+'}} expected-note 2{{place parentheses}}
+ (void)(p + x ? 1 : 2); // no warning
+
+ (void)(p + b ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '+'}} expected-note 2{{place parentheses}}
+
+ (void)(x + y > 0 ? 1 : 2); // no warning
+ (void)(x + (y > 0) ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '+'}} expected-note 2{{place parentheses}}
}
// RUN: not %clang_cc1 -fsyntax-only -Wparentheses -Werror -fdiagnostics-show-option %s 2>&1 | FileCheck %s -check-prefix=CHECK-FLAG
diff --git a/test/Sema/pointer-addition.c b/test/Sema/pointer-addition.c
index 21ce63b4381f..667fe9a68c15 100644
--- a/test/Sema/pointer-addition.c
+++ b/test/Sema/pointer-addition.c
@@ -1,6 +1,7 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic
+// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -std=c11
-typedef struct S S; // expected-note 3 {{forward declaration of 'struct S'}}
+typedef struct S S; // expected-note 4 {{forward declaration of 'struct S'}}
+extern _Atomic(S*) e;
void a(S* b, void* c) {
void (*fp)(int) = 0;
b++; // expected-error {{arithmetic on a pointer to an incomplete type}}
@@ -18,4 +19,5 @@ void a(S* b, void* c) {
d--; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}}
d -= 1; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}}
(void)(1 + d); // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}}
+ e++; // expected-error {{arithmetic on a pointer to an incomplete type}}
}
diff --git a/test/Sema/pr9812.c b/test/Sema/pr9812.c
new file mode 100644
index 000000000000..14bc6c810e86
--- /dev/null
+++ b/test/Sema/pr9812.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#define bool _Bool
+int main(int argc, char** argv)
+{
+ bool signed; // expected-error {{'bool' cannot be signed or unsigned}} expected-warning {{declaration does not declare anything}}
+
+ return 0;
+}
+#undef bool
+
+typedef int bool;
+
+int test2(int argc, char** argv)
+{
+ bool signed; // expected-error {{'type-name' cannot be signed or unsigned}} expected-warning {{declaration does not declare anything}}
+ _Bool signed; // expected-error {{'_Bool' cannot be signed or unsigned}} expected-warning {{declaration does not declare anything}}
+
+ return 0;
+}
+
diff --git a/test/Sema/pragma-ms_struct.c b/test/Sema/pragma-ms_struct.c
index e2c5ff1f481e..a2591b6a4c44 100644
--- a/test/Sema/pragma-ms_struct.c
+++ b/test/Sema/pragma-ms_struct.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin9 %s
+// RUN: %clang_cc1 -fsyntax-only -fms-extensions -verify -triple x86_64-apple-darwin9 %s
#pragma ms_struct on
diff --git a/test/Sema/pragma-section-invalid.c b/test/Sema/pragma-section-invalid.c
new file mode 100644
index 000000000000..b9075c4550f7
--- /dev/null
+++ b/test/Sema/pragma-section-invalid.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple x86_64-apple-darwin
+
+// expected-error@+1 {{argument to 'section' attribute is not valid for this target: mach-o section specifier requires a segment and section separated by a comma}}
+#pragma data_seg(".my_const")
+int a = 1;
+#pragma data_seg("__THINGY,thingy")
+int b = 1;
diff --git a/test/Sema/statements.c b/test/Sema/statements.c
index 9ab571521a3a..dbb4d56ee1d1 100644
--- a/test/Sema/statements.c
+++ b/test/Sema/statements.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -triple x86_64-pc-linux-gnu
+// RUN: %clang_cc1 %s -fsyntax-only -verify -triple x86_64-pc-linux-gnu -Wno-unevaluated-expression
typedef unsigned __uint32_t;
@@ -97,3 +97,16 @@ int test_pr8880() {
return 1;
}
+// In PR22849, we considered __ptr to be a static data member of the anonymous
+// union. Now we declare it in the parent DeclContext.
+void test_pr22849() {
+ struct Bug {
+ typeof(({ unsigned long __ptr; (int *)(0); })) __val;
+ union Nested {
+ typeof(({ unsigned long __ptr; (int *)(0); })) __val;
+ } n;
+ };
+ enum E {
+ SIZE = sizeof(({unsigned long __ptr; __ptr;}))
+ };
+}
diff --git a/test/Sema/struct-packed-align.c b/test/Sema/struct-packed-align.c
index 291de6762cd1..417c30308ca3 100644
--- a/test/Sema/struct-packed-align.c
+++ b/test/Sema/struct-packed-align.c
@@ -55,13 +55,16 @@ struct __attribute__((aligned(8))) as1 {
extern int e1[sizeof(struct as1) == 8 ? 1 : -1];
extern int e2[__alignof(struct as1) == 8 ? 1 : -1];
-// FIXME: Will need to force arch once max usable alignment isn't hard
-// coded.
struct __attribute__((aligned)) as1_2 {
char c;
};
+#ifdef __s390x__
+extern int e1_2[sizeof(struct as1_2) == 8 ? 1 : -1];
+extern int e2_2[__alignof(struct as1_2) == 8 ? 1 : -1];
+#else
extern int e1_2[sizeof(struct as1_2) == 16 ? 1 : -1];
extern int e2_2[__alignof(struct as1_2) == 16 ? 1 : -1];
+#endif
struct as2 {
char c;
diff --git a/test/Sema/typo-correction.c b/test/Sema/typo-correction.c
index 8276737e4fec..d457257b3c3a 100644
--- a/test/Sema/typo-correction.c
+++ b/test/Sema/typo-correction.c
@@ -28,3 +28,15 @@ void func(int arg) {
;
}
}
+
+void banana(void); // expected-note {{'banana' declared here}}
+int c11Generic(int arg) {
+ _Generic(hello, int : banana)(); // expected-error-re {{use of undeclared identifier 'hello'{{$}}}}
+ _Generic(arg, int : bandana)(); // expected-error {{use of undeclared identifier 'bandana'; did you mean 'banana'?}}
+}
+
+typedef long long __m128i __attribute__((__vector_size__(16)));
+int PR23101(__m128i __x) {
+ return foo((__v2di)__x); // expected-warning {{implicit declaration of function 'foo'}} \
+ // expected-error {{use of undeclared identifier '__v2di'}}
+}
diff --git a/test/Sema/vla.c b/test/Sema/vla.c
index e03dda8c5f6c..b9576bf8cfd6 100644
--- a/test/Sema/vla.c
+++ b/test/Sema/vla.c
@@ -61,6 +61,9 @@ void pr5185(int a[*]) // expected-error {{variable length array must be bound in
{
}
+void pr23151(int (*p1)[*]) // expected-error {{variable length array must be bound in function definition}}
+{}
+
// Make sure this isn't treated as an error
int TransformBug(int a) {
return sizeof(*(int(*)[({ goto v; v: a;})]) 0); // expected-warning {{use of GNU statement expression extension}}
diff --git a/test/Sema/warn-documentation-fixits.cpp b/test/Sema/warn-documentation-fixits.cpp
index 675d86c366db..95c0e9350758 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 -fcomment-block-commands=foobar -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -fcomment-block-commands=foobar -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -fcomment-block-commands=foobar -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -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.
@@ -67,6 +67,7 @@ int FooBar();
/// \fooba bbb IS_DOXYGEN_END
int gorf();
+// expected-warning@+1 {{unknown command tag name}}
/// \t bbb IS_DOXYGEN_END
int Bar();
@@ -88,4 +89,4 @@ int PR18051();
// 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"
+// CHECK: fix-it:"{{.*}}":{76:6-76:12}:"endcode"
diff --git a/test/Sema/warn-documentation-unknown-command.cpp b/test/Sema/warn-documentation-unknown-command.cpp
new file mode 100644
index 000000000000..3674a9c68010
--- /dev/null
+++ b/test/Sema/warn-documentation-unknown-command.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wdocumentation-unknown-command -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Werror -Wno-documentation-unknown-command %s
+
+// expected-warning@+1 {{unknown command tag name}}
+/// aaa \unknown
+int test_unknown_comand_1;
+
+// expected-warning@+1 {{unknown command tag name 'retur'; did you mean 'return'?}}
+/// \retur aaa
+int test_unknown_comand_2();
+
diff --git a/test/Sema/warn-documentation.cpp b/test/Sema/warn-documentation.cpp
index 4375cfcf560a..5d866359aa75 100644
--- a/test/Sema/warn-documentation.cpp
+++ b/test/Sema/warn-documentation.cpp
@@ -1038,6 +1038,12 @@ int test_nocrash12();
///@param x@param y
int test_nocrash13(int x, int y);
+/**
+ * \verbatim
+ * Aaa
+ **/
+int test_nocrash14();
+
// rdar://12379114
// expected-warning@+2 {{'@union' command should not be used in a comment attached to a non-union declaration}}
/*!
diff --git a/test/Sema/warn-main.c b/test/Sema/warn-main.c
index 58a6dfde108d..4620663037e2 100644
--- a/test/Sema/warn-main.c
+++ b/test/Sema/warn-main.c
@@ -29,3 +29,5 @@ _Noreturn int main() {
return 0;
}
+// expected-warning@+1 {{'main' is not allowed to be declared variadic}}
+int main(int argc, char**argv, ...) { return 0; }
diff --git a/test/Sema/warn-shift-negative.c b/test/Sema/warn-shift-negative.c
new file mode 100644
index 000000000000..c65d66c1214c
--- /dev/null
+++ b/test/Sema/warn-shift-negative.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -Wshift-count-negative -fblocks -verify %s
+
+int f(int a) {
+ const int i = -1;
+ return a << i; // expected-warning{{shift count is negative}}
+}
diff --git a/test/Sema/warn-string-conversion.c b/test/Sema/warn-string-conversion.c
index 708dd543e402..28dfc1b67dd5 100644
--- a/test/Sema/warn-string-conversion.c
+++ b/test/Sema/warn-string-conversion.c
@@ -1,12 +1,28 @@
// RUN: %clang_cc1 -verify -fsyntax-only -Wstring-conversion %s
-#define assert(EXPR) (void)(EXPR);
+void do_nothing();
+void assert_error();
+
+#define assert1(expr) \
+ if (expr) \
+ do_nothing(); \
+ else \
+ assert_error()
+
+#define assert2(expr) \
+ ((expr) ? do_nothing() : assert_error())
// Expection for common assert form.
void test1() {
- assert(0 && "foo");
- assert("foo" && 0);
- assert(0 || "foo"); // expected-warning {{string literal}}
+ assert1(0 && "foo");
+ assert1("foo" && 0);
+ assert1(0 || "foo"); // expected-warning {{string literal}}
+ assert1("foo"); // expected-warning {{string literal}}
+
+ assert2(0 && "foo");
+ assert2("foo" && 0);
+ assert2(0 || "foo"); // expected-warning {{string literal}}
+ assert2("foo"); // expected-warning {{string literal}}
}
void test2() {
@@ -14,4 +30,5 @@ void test2() {
while ("hello") {} // expected-warning {{string literal}}
for (;"howdy";) {} // expected-warning {{string literal}}
do { } while ("hey"); // expected-warning {{string literal}}
+ int x = "hey" ? 1 : 2; // expected-warning {{string literal}}
}
diff --git a/test/Sema/warn-tautological-compare.c b/test/Sema/warn-tautological-compare.c
index 55de6179a31a..e4eec11b42d2 100644
--- a/test/Sema/warn-tautological-compare.c
+++ b/test/Sema/warn-tautological-compare.c
@@ -84,3 +84,12 @@ void _HTTPClientErrorHandler(int me)
int *result;
SAVE_READ(&me);
}
+
+void test_conditional_operator() {
+ int x;
+ x = b ? 1 : 0; // expected-warning {{address of array}}
+ x = c.x ? 1 : 0; // expected-warning {{address of array}}
+ x = str ? 1 : 0; // expected-warning {{address of array}}
+ x = array ? 1 : 0; // expected-warning {{address of array}}
+ x = &x ? 1 : 0; // expected-warning {{address of 'x'}}
+}
diff --git a/test/Sema/wchar.c b/test/Sema/wchar.c
index a45a14daaef2..9e41f5329f9a 100644
--- a/test/Sema/wchar.c
+++ b/test/Sema/wchar.c
@@ -4,7 +4,7 @@
typedef __WCHAR_TYPE__ wchar_t;
#if defined(_WIN32) || defined(_M_IX86) || defined(__CYGWIN__) \
- || defined(_M_X64) || defined(SHORT_WCHAR)
+ || defined(_M_X64) || defined(__PS4__) || defined(SHORT_WCHAR)
#define WCHAR_T_TYPE unsigned short
#elif defined(__arm) || defined(__aarch64__)
#define WCHAR_T_TYPE unsigned int
diff --git a/test/Sema/x86-builtin-palignr.c b/test/Sema/x86-builtin-palignr.c
index 6f4b90dafa1c..f7e70b9c3c45 100644
--- a/test/Sema/x86-builtin-palignr.c
+++ b/test/Sema/x86-builtin-palignr.c
@@ -8,10 +8,3 @@ __m64 test1(__m64 a, __m64 b, int c) {
// be removed when that is fixed.
return _mm_alignr_pi8(a, b, c); // expected-error {{argument to '__builtin_ia32_palignr' must be a constant integer}} expected-error {{incompatible result type}}
}
-
-int test2(int N) {
- __m128i white2;
- white2 = __builtin_ia32_pslldqi128(white2, N); // expected-error {{argument to '__builtin_ia32_pslldqi128' must be a constant integer}}
- return 0;
-}
-
diff --git a/test/Sema/x86_64-linux-android.c b/test/Sema/x86_64-linux-android.c
new file mode 100644
index 000000000000..e09d50ca079c
--- /dev/null
+++ b/test/Sema/x86_64-linux-android.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-linux-android -emit-pch -o %t %s
+// RUN: %clang_cc1 -x ast -ast-print %t | FileCheck %s
+
+extern int a1_0[sizeof(long double) == 16 ? 1 : -1];
+extern int a1_i[__alignof(long double) == 16 ? 1 : -1];
+
+// Verify that long double is 128 bit IEEEquad
+
+long double foo = 1.0E4000L;
+// CHECK: long double foo = 1.00000000000000000000000000000000004E+4000L;