Importing rustc-1.38.0
diff --git a/src/llvm-project/clang/test/Sema/address_space_print_macro.c b/src/llvm-project/clang/test/Sema/address_space_print_macro.c
new file mode 100644
index 0000000..9557149
--- /dev/null
+++ b/src/llvm-project/clang/test/Sema/address_space_print_macro.c
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+#define AS1 __attribute__((address_space(1)))
+#define AS2 __attribute__((address_space(2), annotate("foo")))
+#define AS_ND __attribute__((address_space(2), noderef))
+
+#define AS(i) address_space(i)
+#define AS3 __attribute__((AS(3)))
+#define AS5 __attribute__((address_space(5))) char
+
+void normal_case() {
+ int *p = 0;
+ __attribute__((address_space(1))) int *q = p; // expected-error{{initializing '__attribute__((address_space(1))) int *' with an expression of type 'int *' changes address space of pointer}}
+}
+
+char *cmp(AS1 char *x, AS2 char *y) {
+ return x < y ? x : y; // expected-error{{conditional operator with the second and third operands of type ('AS1 char *' and 'AS2 char *') which are pointers to non-overlapping address spaces}}
+}
+
+__attribute__((address_space(1))) char test_array[10];
+void test3(void) {
+ extern void test3_helper(char *p); // expected-note{{passing argument to parameter 'p' here}}
+ test3_helper(test_array); // expected-error{{passing '__attribute__((address_space(1))) char *' to parameter of type 'char *' changes address space of pointer}}
+}
+
+char AS2 *test4_array;
+void test4(void) {
+ extern void test3_helper(char *p); // expected-note{{passing argument to parameter 'p' here}}
+ test3_helper(test4_array); // expected-error{{passing 'AS2 char *' to parameter of type 'char *' changes address space of pointer}}
+}
+
+void func() {
+ char AS1 *x;
+ char AS3 *x2;
+ AS5 *x3;
+ char *y;
+ y = x; // expected-error{{assigning 'AS1 char *' to 'char *' changes address space of pointer}}
+ y = x2; // expected-error{{assigning 'AS3 char *' to 'char *' changes address space of pointer}}
+ y = x3; // expected-error{{assigning '__attribute__((address_space(5))) char *' to 'char *' changes address space of pointer}}
+}
+
+void multiple_attrs(AS_ND int *x) {
+ __attribute__((address_space(2))) int *y = x; // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
+}
+
+void override_macro_name() {
+#define ATTRS __attribute__((noderef)) // expected-note{{previous definition is here}}
+ ATTRS
+#define ATTRS __attribute__((address_space(1))) // expected-warning{{'ATTRS' macro redefined}}
+ ATTRS
+ int *x;
+
+ int AS_ND *y = x; // expected-error{{initializing 'AS_ND int *' with an expression of type 'ATTRS int *' changes address space of pointer}}
+}
+
+void partial_macro_declaration() {
+#define ATTRS2 __attribute__((noderef))
+ ATTRS2 __attribute__((address_space(1))) int *x;
+
+ int AS_ND *y = x; // expected-error{{initializing 'AS_ND int *' with an expression of type 'ATTRS2 int __attribute__((address_space(1))) *' changes address space of pointer}}
+
+ // The attribute not wrapped with a macro should be printed regularly.
+#define ATTRS3 __attribute__((address_space(1)))
+ ATTRS3 __attribute__((noderef)) int *x2;
+
+ int AS_ND *y2 = x2; // expected-error{{initializing 'AS_ND int *' with an expression of type 'ATTRS3 int * __attribute__((noderef))' changes address space of pointer}}
+}
diff --git a/src/llvm-project/clang/test/Sema/address_spaces.c b/src/llvm-project/clang/test/Sema/address_spaces.c
index a9046d8..5425ef7 100644
--- a/src/llvm-project/clang/test/Sema/address_spaces.c
+++ b/src/llvm-project/clang/test/Sema/address_spaces.c
@@ -71,7 +71,7 @@
// Clang extension doesn't forbid operations on pointers to different address spaces.
char* cmp(_AS1 char *x, _AS2 char *y) {
- return x < y ? x : y; // expected-error{{conditional operator with the second and third operands of type ('__attribute__((address_space(1))) char *' and '__attribute__((address_space(2))) char *') which are pointers to non-overlapping address spaces}}
+ return x < y ? x : y; // expected-error{{conditional operator with the second and third operands of type ('_AS1 char *' and '_AS2 char *') which are pointers to non-overlapping address spaces}}
}
struct SomeStruct {
diff --git a/src/llvm-project/clang/test/Sema/asm-goto.cpp b/src/llvm-project/clang/test/Sema/asm-goto.cpp
new file mode 100644
index 0000000..d857309
--- /dev/null
+++ b/src/llvm-project/clang/test/Sema/asm-goto.cpp
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 %s -triple i386-pc-linux-gnu -verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple x86_64-pc-linux-gnu -verify -fsyntax-only
+
+struct NonTrivial {
+ ~NonTrivial();
+ int f(int);
+private:
+ int k;
+};
+void JumpDiagnostics(int n) {
+// expected-error@+1 {{cannot jump from this goto statement to its label}}
+ goto DirectJump;
+// expected-note@+1 {{jump bypasses variable with a non-trivial destructor}}
+ NonTrivial tnp1;
+
+DirectJump:
+// expected-error@+1 {{cannot jump from this asm goto statement to one of its possible targets}}
+ asm goto("jmp %l0;" ::::Later);
+// expected-note@+1 {{jump bypasses variable with a non-trivial destructor}}
+ NonTrivial tnp2;
+// expected-note@+1 {{possible target of asm goto statement}}
+Later:
+ return;
+}
+
+struct S { ~S(); };
+void foo(int a) {
+ if (a) {
+FOO:
+// expected-note@+2 {{jump exits scope of variable with non-trivial destructor}}
+// expected-note@+1 {{jump exits scope of variable with non-trivial destructor}}
+ S s;
+ void *p = &&BAR;
+// expected-error@+1 {{cannot jump from this asm goto statement to one of its possible targets}}
+ asm goto("jmp %l0;" ::::BAR);
+// expected-error@+1 {{cannot jump from this indirect goto statement to one of its possible targets}}
+ goto *p;
+ p = &&FOO;
+ goto *p;
+ return;
+ }
+// expected-note@+2 {{possible target of asm goto statement}}
+// expected-note@+1 {{possible target of indirect goto statement}}
+BAR:
+ return;
+}
+
+
+//Asm goto:
+int test16(int n)
+{
+ // expected-error@+2 {{cannot jump from this asm goto statement to one of its possible targets}}
+ // expected-error@+1 {{cannot jump from this asm goto statement to one of its possible targets}}
+ asm volatile goto("testl %0, %0; jne %l1;" :: "r"(n)::label_true, loop);
+ // expected-note@+2 {{jump bypasses initialization of variable length array}}
+ // expected-note@+1 {{possible target of asm goto statement}}
+ return ({int a[n];label_true: 2;});
+ // expected-note@+1 {{jump bypasses initialization of variable length array}}
+ int b[n];
+// expected-note@+1 {{possible target of asm goto statement}}
+loop:
+ return 0;
+}
diff --git a/src/llvm-project/clang/test/Sema/asm.c b/src/llvm-project/clang/test/Sema/asm.c
index 04b7cb19..29a55c6 100644
--- a/src/llvm-project/clang/test/Sema/asm.c
+++ b/src/llvm-project/clang/test/Sema/asm.c
@@ -249,7 +249,7 @@
int a;
__asm__(""
: "=rm"(a), "=rm"(a)
- : "11m"(a)) // expected-error {{invalid input constraint '11m' in asm}}
+ : "11m"(a)); // expected-error {{invalid input constraint '11m' in asm}}
}
// PR14269
@@ -295,3 +295,24 @@
return r0 + r1;
}
+void test18()
+{
+ // expected-error@+2 {{duplicate use of asm operand name "lab"}}
+ // expected-note@+1 {{asm operand name "lab" first referenced here}}
+ asm goto ("" : : : : lab, lab, lab2, lab);
+ // expected-error@+2 {{duplicate use of asm operand name "lab"}}
+ // expected-note@+1 {{asm operand name "lab" first referenced here}}
+ asm goto ("xorw %[lab], %[lab]; je %l[lab]" : : [lab] "i" (0) : : lab);
+lab:;
+lab2:;
+ int x,x1;
+ // expected-error@+2 {{duplicate use of asm operand name "lab"}}
+ // expected-note@+1 {{asm operand name "lab" first referenced here}}
+ asm ("" : [lab] "=r" (x),[lab] "+r" (x) : [lab1] "r" (x));
+ // expected-error@+2 {{duplicate use of asm operand name "lab"}}
+ // expected-note@+1 {{asm operand name "lab" first referenced here}}
+ asm ("" : [lab] "=r" (x1) : [lab] "r" (x));
+ // expected-error@+1 {{invalid operand number in inline asm string}}
+ asm ("jne %l0":::);
+ asm goto ("jne %l0"::::lab);
+}
diff --git a/src/llvm-project/clang/test/Sema/attr-availability-watchos.c b/src/llvm-project/clang/test/Sema/attr-availability-watchos.c
index 866efac..dbcf2c2 100644
--- a/src/llvm-project/clang/test/Sema/attr-availability-watchos.c
+++ b/src/llvm-project/clang/test/Sema/attr-availability-watchos.c
@@ -52,3 +52,9 @@
f5c_watchos(0); // expected-warning {{'f5c_watchos' is deprecated: first deprecated in watchOS 2.0}}
f6_watchos(0); // expected-warning {{'f6_watchos' is deprecated: first deprecated in watchOS 3.0}}
}
+
+void deprecatedAfterIntroduced() __attribute__((availability(ios,introduced=9.3,deprecated=10))); // expected-note {{here}}
+
+void test_ios_correctly_map_to_watchos() {
+ deprecatedAfterIntroduced(); // expected-warning {{'deprecatedAfterIntroduced' is deprecated: first deprecated in watchOS 3}}
+}
diff --git a/src/llvm-project/clang/test/Sema/attr-callback-broken.c b/src/llvm-project/clang/test/Sema/attr-callback-broken.c
new file mode 100644
index 0000000..b9e5f45
--- /dev/null
+++ b/src/llvm-project/clang/test/Sema/attr-callback-broken.c
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+__attribute__((callback())) void no_callee(void (*callback)(void)); // expected-error {{'callback' attribute specifies no callback callee}}
+
+__attribute__((callback(1, 1))) void too_many_args_1(void (*callback)(void)) {} // expected-error {{'callback' attribute takes one argument}}
+__attribute__((callback(1, -1))) void too_many_args_2(double (*callback)(void)); // expected-error {{'callback' attribute takes one argument}}
+__attribute__((callback(1, 2, 2))) void too_many_args_3(void (*callback)(int), int); // expected-error {{'callback' attribute requires exactly 2 arguments}}
+
+__attribute__((callback(1, 2))) void too_few_args_1(void (*callback)(int, int), int); // expected-error {{'callback' attribute takes one argument}}
+__attribute__((callback(1))) void too_few_args_2(int (*callback)(int)); // expected-error {{'callback' attribute takes no arguments}}
+__attribute__((callback(1, -1))) void too_few_args_3(void (*callback)(int, int)) {} // expected-error {{'callback' attribute takes one argument}}
+
+__attribute__((callback(-1))) void oob_args_1(void (*callback)(void)); // expected-error {{'callback' attribute specifies invalid callback callee}}
+__attribute__((callback(2))) void oob_args_2(int *(*callback)(void)) {} // expected-error {{'callback' attribute parameter 1 is out of bounds}}
+__attribute__((callback(1, 3))) void oob_args_3(short (*callback)(int), int); // expected-error {{'callback' attribute parameter 2 is out of bounds}}
+__attribute__((callback(-2, 2))) void oob_args_4(void *(*callback)(int), int); // expected-error {{'callback' attribute parameter 1 is out of bounds}}
+__attribute__((callback(1, -2))) void oob_args_5(void *(*callback)(int), int); // expected-error {{'callback' attribute parameter 2 is out of bounds}}
+__attribute__((callback(1, 2))) void oob_args_6(void *(*callback)(int), ...); // expected-error {{'callback' attribute parameter 2 is out of bounds}}
+
+__attribute__((callback(1))) __attribute__((callback(1))) void multiple_cb_1(void (*callback)(void)); // expected-error {{multiple 'callback' attributes specified}}
+__attribute__((callback(1))) __attribute__((callback(2))) void multiple_cb_2(void (*callback1)(void), void (*callback2)(void)); // expected-error {{multiple 'callback' attributes specified}}
+
+#ifdef HAS_THIS
+__attribute__((callback(0))) void oob_args_0(void (*callback)(void)); // expected-error {{'callback' attribute specifies invalid callback callee}}
+#else
+__attribute__((callback(0))) void oob_args_0(void (*callback)(void)); // expected-error {{'callback' argument at position 1 references unavailable implicit 'this'}}
+__attribute__((callback(1, 0))) void no_this_1(void *(*callback)(void *)); // expected-error {{'callback' argument at position 2 references unavailable implicit 'this'}}
+__attribute__((callback(1, 0))) void no_this_2(void *(*callback)(int, void *)); // expected-error {{'callback' argument at position 2 references unavailable implicit 'this'}}
+#endif
+
+// We could allow the following declarations if we at some point need to:
+
+__attribute__((callback(1, -1))) void vararg_cb_1(void (*callback)(int, ...)) {} // expected-error {{'callback' attribute callee may not be variadic}}
+__attribute__((callback(1, 1))) void vararg_cb_2(void (*callback)(int, ...), int a); // expected-error {{'callback' attribute callee may not be variadic}}
+
+__attribute__((callback(1, -1, 1, 2, 3, 4, -1))) void varargs_1(void (*callback)(int, ...), int a, float b, double c) {} // expected-error {{'callback' attribute requires exactly 6 arguments}}
+__attribute__((callback(1, -1, 4, 2, 3, 4, -1))) void varargs_2(void (*callback)(void *, double, int, ...), int a, float b, double c); // expected-error {{'callback' attribute requires exactly 6 arguments}}
+
+__attribute__((callback(1, -1, 1))) void self_arg_1(void (*callback)(int, ...)) {} // expected-error {{'callback' attribute requires exactly 2 arguments}}
+__attribute__((callback(1, -1, 1, -1, -1, 1))) void self_arg_2(void (*callback)(int, ...)); // expected-error {{'callback' attribute requires exactly 5 arguments}}
+
+__attribute__((callback(cb))) void unknown_name1(void (*callback)(void)) {} // expected-error {{'callback' attribute argument 'cb' is not a known function parameter}}
+__attribute__((callback(cb, ab))) void unknown_name2(void (*cb)(int), int a) {} // expected-error {{'callback' attribute argument 'ab' is not a known function parameter}}
+
+__attribute__((callback(callback, 1))) void too_many_args_1b(void (*callback)(void)) {} // expected-error {{'callback' attribute takes one argument}}
+__attribute__((callback(callback, __))) void too_many_args_2b(double (*callback)(void)); // expected-error {{'callback' attribute takes one argument}}
+__attribute__((callback(callback, 2, 2))) void too_many_args_3b(void (*callback)(int), int); // expected-error {{'callback' attribute requires exactly 2 arguments}}
+
+__attribute__((callback(callback, a))) void too_few_args_1b(void (*callback)(int, int), int a); // expected-error {{'callback' attribute takes one argument}}
+__attribute__((callback(callback))) void too_few_args_2b(int (*callback)(int)); // expected-error {{'callback' attribute takes no arguments}}
+__attribute__((callback(callback, __))) void too_few_args_3b(void (*callback)(int, int)) {} // expected-error {{'callback' attribute takes one argument}}
+
+__attribute__((callback(__))) void oob_args_1b(void (*callback)(void)); // expected-error {{'callback' attribute specifies invalid callback callee}}
+
+__attribute__((callback(callback))) __attribute__((callback(callback))) void multiple_cb_1b(void (*callback)(void)); // expected-error {{multiple 'callback' attributes specified}}
+__attribute__((callback(1))) __attribute__((callback(callback2))) void multiple_cb_2b(void (*callback1)(void), void (*callback2)(void)); // expected-error {{multiple 'callback' attributes specified}}
+
+#ifdef HAS_THIS
+__attribute__((callback(this))) void oob_args_0b(void (*callback)(void)); // expected-error {{'callback' attribute specifies invalid callback callee}}
+#else
+__attribute__((callback(this))) void oob_args_0b(void (*callback)(void)); // expected-error {{'callback' argument at position 1 references unavailable implicit 'this'}}
+__attribute__((callback(1, this))) void no_this_1b(void *(*callback)(void *)); // expected-error {{'callback' argument at position 2 references unavailable implicit 'this'}}
+__attribute__((callback(1, this))) void no_this_2b(void *(*callback)(int, void *)); // expected-error {{'callback' argument at position 2 references unavailable implicit 'this'}}
+#endif
+
+// We could allow the following declarations if we at some point need to:
+
+__attribute__((callback(callback, __))) void vararg_cb_1b(void (*callback)(int, ...)) {} // expected-error {{'callback' attribute callee may not be variadic}}
+__attribute__((callback(1, a))) void vararg_cb_2b(void (*callback)(int, ...), int a); // expected-error {{'callback' attribute callee may not be variadic}}
+
+__attribute__((callback(callback, __, callback, a, b, c, __))) void varargs_1b(void (*callback)(int, ...), int a, float b, double c) {} // expected-error {{'callback' attribute requires exactly 6 arguments}}
+__attribute__((callback(1, __, c, a, b, c, -1))) void varargs_2b(void (*callback)(void *, double, int, ...), int a, float b, double c); // expected-error {{'callback' attribute requires exactly 6 arguments}}
+
+__attribute__((callback(1, __, callback))) void self_arg_1b(void (*callback)(int, ...)) {} // expected-error {{'callback' attribute requires exactly 2 arguments}}
+__attribute__((callback(callback, __, callback, __, __, callback))) void self_arg_2b(void (*callback)(int, ...)); // expected-error {{'callback' attribute requires exactly 5 arguments}}
diff --git a/src/llvm-project/clang/test/Sema/attr-callback.c b/src/llvm-project/clang/test/Sema/attr-callback.c
new file mode 100644
index 0000000..ec12b16
--- /dev/null
+++ b/src/llvm-project/clang/test/Sema/attr-callback.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+// expected-no-diagnostics
+
+__attribute__((callback(1))) void no_args(void (*callback)(void));
+__attribute__((callback(1, 2, 3))) void args_1(void (*callback)(int, double), int a, double b);
+__attribute__((callback(2, 3, 3))) void args_2(int a, void (*callback)(double, double), double b);
+__attribute__((callback(2, -1, -1))) void args_3(int a, void (*callback)(double, double), double b);
+
+__attribute__((callback(callback))) void no_argsb(void (*callback)(void));
+__attribute__((callback(callback, a, 3))) void args_1b(void (*callback)(int, double), int a, double b);
+__attribute__((callback(callback, b, b))) void args_2b(int a, void (*callback)(double, double), double b);
+__attribute__((callback(2, __, __))) void args_3b(int a, void (*callback)(double, double), double b);
+__attribute__((callback(callback, -1, __))) void args_3c(int a, void (*callback)(double, double), double b);
diff --git a/src/llvm-project/clang/test/Sema/attr-cpuspecific.c b/src/llvm-project/clang/test/Sema/attr-cpuspecific.c
index e87ad4d..ae86742 100644
--- a/src/llvm-project/clang/test/Sema/attr-cpuspecific.c
+++ b/src/llvm-project/clang/test/Sema/attr-cpuspecific.c
@@ -112,3 +112,6 @@
int use3(void) {
return called_invalid_value();
}
+
+// expected-warning@+1 {{CPU list contains duplicate entries; attribute ignored}}
+int __attribute__((cpu_dispatch(pentium_iii, pentium_iii_no_xmm_regs))) dupe_p3(void);
diff --git a/src/llvm-project/clang/test/Sema/attr-cx2.c b/src/llvm-project/clang/test/Sema/attr-cx2.c
index 5b53762..ec74edf 100644
--- a/src/llvm-project/clang/test/Sema/attr-cx2.c
+++ b/src/llvm-project/clang/test/Sema/attr-cx2.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -fdouble-square-bracket-attributes %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=c2x %s
struct S {};
struct S * [[clang::address_space(1)]] Foo;
diff --git a/src/llvm-project/clang/test/Sema/attr-deprecated-c2x.c b/src/llvm-project/clang/test/Sema/attr-deprecated-c2x.c
index 2505f12..744fb1f 100644
--- a/src/llvm-project/clang/test/Sema/attr-deprecated-c2x.c
+++ b/src/llvm-project/clang/test/Sema/attr-deprecated-c2x.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -fsyntax-only -fdouble-square-bracket-attributes
+// RUN: %clang_cc1 %s -verify -fsyntax-only --std=c2x
int f() [[deprecated]]; // expected-note 2 {{'f' has been explicitly marked deprecated here}}
void g() [[deprecated]];// expected-note {{'g' has been explicitly marked deprecated here}}
diff --git a/src/llvm-project/clang/test/Sema/attr-mig.c b/src/llvm-project/clang/test/Sema/attr-mig.c
new file mode 100644
index 0000000..3b16696
--- /dev/null
+++ b/src/llvm-project/clang/test/Sema/attr-mig.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef int kern_return_t;
+#define KERN_SUCCESS 0
+
+__attribute__((mig_server_routine)) kern_return_t var = KERN_SUCCESS; // expected-warning{{'mig_server_routine' attribute only applies to functions, Objective-C methods, and blocks}}
+
+__attribute__((mig_server_routine)) void foo_void(); // expected-warning{{'mig_server_routine' attribute only applies to routines that return a kern_return_t}}
+__attribute__((mig_server_routine)) int foo_int(); // expected-warning{{'mig_server_routine' attribute only applies to routines that return a kern_return_t}}
+
+__attribute__((mig_server_routine)) kern_return_t bar_extern(); // no-warning
+__attribute__((mig_server_routine)) kern_return_t bar_forward(); // no-warning
+
+__attribute__((mig_server_routine)) kern_return_t bar_definition() { // no-warning
+ return KERN_SUCCESS;
+}
+
+kern_return_t bar_forward() { // no-warning
+ return KERN_SUCCESS;
+}
+
+__attribute__((mig_server_routine(123))) kern_return_t bar_with_argument(); // expected-error{{'mig_server_routine' attribute takes no arguments}}
diff --git a/src/llvm-project/clang/test/Sema/attr-mig.cpp b/src/llvm-project/clang/test/Sema/attr-mig.cpp
new file mode 100644
index 0000000..5dfc43b
--- /dev/null
+++ b/src/llvm-project/clang/test/Sema/attr-mig.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef int kern_return_t;
+typedef kern_return_t IOReturn;
+#define KERN_SUCCESS 0
+#define kIOReturnSuccess KERN_SUCCESS
+
+class MyServer {
+public:
+ virtual __attribute__((mig_server_routine)) IOReturn externalMethod();
+ virtual __attribute__((mig_server_routine)) void anotherMethod(); // expected-warning{{'mig_server_routine' attribute only applies to routines that return a kern_return_t}}
+ virtual __attribute__((mig_server_routine)) int yetAnotherMethod(); // expected-warning{{'mig_server_routine' attribute only applies to routines that return a kern_return_t}}
+ [[clang::mig_server_routine]] virtual IOReturn cppAnnotatedMethod();
+ [[clang::mig_server_routine("arg")]] virtual IOReturn cppAnnotatedMethodWithInvalidArgs(); // expected-error{{'mig_server_routine' attribute takes no arguments}}
+ [[clang::mig_server_routine]] virtual int cppInvalidAnnotatedMethod(); // expected-warning{{'mig_server_routine' attribute only applies to routines that return a kern_return_t}}
+};
+
+IOReturn MyServer::externalMethod() {
+ return kIOReturnSuccess;
+}
diff --git a/src/llvm-project/clang/test/Sema/attr-mig.m b/src/llvm-project/clang/test/Sema/attr-mig.m
new file mode 100644
index 0000000..a40a917
--- /dev/null
+++ b/src/llvm-project/clang/test/Sema/attr-mig.m
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s
+
+typedef int kern_return_t;
+#define KERN_SUCCESS 0
+
+@interface NSObject
+@end
+
+@interface I: NSObject
+- (kern_return_t)foo __attribute__((mig_server_routine)); // no-warning
+- (void) bar_void __attribute__((mig_server_routine)); // expected-warning{{'mig_server_routine' attribute only applies to routines that return a kern_return_t}}
+- (int) bar_int __attribute__((mig_server_routine)); // expected-warning{{'mig_server_routine' attribute only applies to routines that return a kern_return_t}}
+@end
+
+@implementation I
+- (kern_return_t)foo {
+ kern_return_t (^block)() = ^ __attribute__((mig_server_routine)) { // no-warning
+ return KERN_SUCCESS;
+ };
+
+ // FIXME: Warn that this block doesn't return a kern_return_t.
+ void (^invalid_block)() = ^ __attribute__((mig_server_routine)) {};
+
+ return block();
+}
+- (void)bar_void {
+}
+- (int)bar_int {
+ return 0;
+}
+@end
diff --git a/src/llvm-project/clang/test/Sema/attr-mode.c b/src/llvm-project/clang/test/Sema/attr-mode.c
index c0e0426..c89cb65 100644
--- a/src/llvm-project/clang/test/Sema/attr-mode.c
+++ b/src/llvm-project/clang/test/Sema/attr-mode.c
@@ -6,6 +6,12 @@
// RUN: -verify %s
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnux32 -DTEST_64BIT_X86 -fsyntax-only \
// RUN: -verify %s
+// RUN: %clang_cc1 -triple mips-linux-gnu -DTEST_MIPS_32 -fsyntax-only \
+// RUN: -verify %s
+// RUN: %clang_cc1 -triple mips64-linux-gnuabin32 -DTEST_MIPS_N32 -fsyntax-only \
+// RUN: -verify %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -DTEST_MIPS_64 -fsyntax-only \
+// RUN: -verify %s
typedef int i16_1 __attribute((mode(HI)));
int i16_1_test[sizeof(i16_1) == 2 ? 1 : -1];
@@ -33,7 +39,7 @@
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.
+#if !defined(__ppc__) && !defined(__mips__) // Note, 'XC' mode is illegal for PPC64 and MIPS machines.
typedef _Complex float c80 __attribute((mode(XC)));
#endif
@@ -84,6 +90,15 @@
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); }
+#elif TEST_MIPS_32
+typedef unsigned int gcc_unwind_word __attribute__((mode(unwind_word)));
+int foo[sizeof(gcc_unwind_word) == 4 ? 1 : -1];
+#elif TEST_MIPS_N32
+typedef unsigned int gcc_unwind_word __attribute__((mode(unwind_word)));
+int foo[sizeof(gcc_unwind_word) == 8 ? 1 : -1];
+#elif TEST_MIPS_64
+typedef unsigned int gcc_unwind_word __attribute__((mode(unwind_word)));
+int foo[sizeof(gcc_unwind_word) == 8 ? 1 : -1];
#else
#error Unknown test architecture.
#endif
diff --git a/src/llvm-project/clang/test/Sema/attr-nodebug.c b/src/llvm-project/clang/test/Sema/attr-nodebug.c
index 3557784..3ae894a 100644
--- a/src/llvm-project/clang/test/Sema/attr-nodebug.c
+++ b/src/llvm-project/clang/test/Sema/attr-nodebug.c
@@ -2,7 +2,7 @@
int a __attribute__((nodebug));
-void b(int p __attribute__((nodebug))) { // expected-warning {{'nodebug' attribute only applies to functions, function pointers, Objective-C methods, and variables}}
+void b(int p __attribute__((nodebug))) { // expected-warning {{'nodebug' attribute only applies to typedefs, functions, function pointers, Objective-C methods, and variables}}
int b __attribute__((nodebug));
}
diff --git a/src/llvm-project/clang/test/Sema/attr-nothrow.c b/src/llvm-project/clang/test/Sema/attr-nothrow.c
new file mode 100644
index 0000000..c444628
--- /dev/null
+++ b/src/llvm-project/clang/test/Sema/attr-nothrow.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 %s -verify
+// RUN: %clang_cc1 %s -ast-dump | FileCheck %s
+// expected-no-diagnostics
+
+// PR42113: The following caused an assertion in mergeFunctionTypes
+// because it causes one side to have an exception specification, which
+// isn't typically supported in C.
+void PR42113a();
+void PR42113a(void) __attribute__((nothrow));
+// CHECK: FunctionDecl {{.*}} PR42113a
+// CHECK: FunctionDecl {{.*}} PR42113a
+// CHECK: NoThrowAttr
+void PR42113b() __attribute__((nothrow));
+// CHECK: FunctionDecl {{.*}} PR42113b
+// CHECK: NoThrowAttr
+ __attribute__((nothrow)) void PR42113c();
+// CHECK: FunctionDecl {{.*}} PR42113c
+// CHECK: NoThrowAttr
diff --git a/src/llvm-project/clang/test/Sema/builtin-object-size.c b/src/llvm-project/clang/test/Sema/builtin-object-size.c
index fcf86f3..fa66d2e 100644
--- a/src/llvm-project/clang/test/Sema/builtin-object-size.c
+++ b/src/llvm-project/clang/test/Sema/builtin-object-size.c
@@ -1,29 +1,36 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin9 -verify %s
+// RUN: %clang_cc1 -DDYNAMIC -fsyntax-only -triple x86_64-apple-darwin9 -verify %s
+
+#ifndef DYNAMIC
+#define OBJECT_SIZE_BUILTIN __builtin_object_size
+#else
+#define OBJECT_SIZE_BUILTIN __builtin_dynamic_object_size
+#endif
int a[10];
int f0() {
- return __builtin_object_size(&a); // expected-error {{too few arguments to function}}
+ return OBJECT_SIZE_BUILTIN(&a); // expected-error {{too few arguments to function}}
}
int f1() {
- return (__builtin_object_size(&a, 0) +
- __builtin_object_size(&a, 1) +
- __builtin_object_size(&a, 2) +
- __builtin_object_size(&a, 3));
+ return (OBJECT_SIZE_BUILTIN(&a, 0) +
+ OBJECT_SIZE_BUILTIN(&a, 1) +
+ OBJECT_SIZE_BUILTIN(&a, 2) +
+ OBJECT_SIZE_BUILTIN(&a, 3));
}
int f2() {
- return __builtin_object_size(&a, -1); // expected-error {{argument value -1 is outside the valid range [0, 3]}}
+ return OBJECT_SIZE_BUILTIN(&a, -1); // expected-error {{argument value -1 is outside the valid range [0, 3]}}
}
int f3() {
- return __builtin_object_size(&a, 4); // expected-error {{argument value 4 is outside the valid range [0, 3]}}
+ return OBJECT_SIZE_BUILTIN(&a, 4); // expected-error {{argument value 4 is outside the valid range [0, 3]}}
}
// rdar://6252231 - cannot call vsnprintf with va_list on x86_64
void f4(const char *fmt, ...) {
__builtin_va_list args;
- __builtin___vsnprintf_chk (0, 42, 0, 11, fmt, args); // expected-warning {{'__builtin___vsnprintf_chk' will always overflow; destination buffer has size 11, but size argument is 42}}
+ __builtin___vsnprintf_chk (0, 42, 0, 11, fmt, args); // expected-warning {{'vsnprintf' will always overflow; destination buffer has size 11, but size argument is 42}}
}
// rdar://18334276
@@ -31,9 +38,9 @@
void * memcset(void *restrict dst, int src, size_t n);
void * memcpy(void *restrict dst, const void *restrict src, size_t n);
-#define memset(dest, src, len) __builtin___memset_chk(dest, src, len, __builtin_object_size(dest, 0))
-#define memcpy(dest, src, len) __builtin___memcpy_chk(dest, src, len, __builtin_object_size(dest, 0))
-#define memcpy1(dest, src, len) __builtin___memcpy_chk(dest, src, len, __builtin_object_size(dest, 4))
+#define memset(dest, src, len) __builtin___memset_chk(dest, src, len, OBJECT_SIZE_BUILTIN(dest, 0))
+#define memcpy(dest, src, len) __builtin___memcpy_chk(dest, src, len, OBJECT_SIZE_BUILTIN(dest, 0))
+#define memcpy1(dest, src, len) __builtin___memcpy_chk(dest, src, len, OBJECT_SIZE_BUILTIN(dest, 4))
#define NULL ((void *)0)
void f5(void)
@@ -49,8 +56,8 @@
{
char b[5];
char buf[10];
- __builtin___memccpy_chk (buf, b, '\0', sizeof(b), __builtin_object_size (buf, 0));
- __builtin___memccpy_chk (b, buf, '\0', sizeof(buf), __builtin_object_size (b, 0)); // expected-warning {{'__builtin___memccpy_chk' will always overflow; destination buffer has size 5, but size argument is 10}}
+ __builtin___memccpy_chk (buf, b, '\0', sizeof(b), OBJECT_SIZE_BUILTIN (buf, 0));
+ __builtin___memccpy_chk (b, buf, '\0', sizeof(buf), OBJECT_SIZE_BUILTIN (b, 0)); // expected-warning {{'memccpy' will always overflow; destination buffer has size 5, but size argument is 10}}
}
int pr28314(void) {
@@ -70,10 +77,10 @@
} *p3;
int a = 0;
- a += __builtin_object_size(&p->a, 0);
- a += __builtin_object_size(p->b, 0);
- a += __builtin_object_size(p2->b, 0);
- a += __builtin_object_size(p3->b, 0);
+ a += OBJECT_SIZE_BUILTIN(&p->a, 0);
+ a += OBJECT_SIZE_BUILTIN(p->b, 0);
+ a += OBJECT_SIZE_BUILTIN(p2->b, 0);
+ a += OBJECT_SIZE_BUILTIN(p3->b, 0);
return a;
}
@@ -82,12 +89,12 @@
struct { int f; } a;
int b;
- n += __builtin_object_size(({&(b ? &a : &a)->f; pr31843;}), 0); // expected-warning{{expression result unused}}
+ n += OBJECT_SIZE_BUILTIN(({&(b ? &a : &a)->f; pr31843;}), 0); // expected-warning{{expression result unused}}
struct statfs { char f_mntonname[1024];};
struct statfs *outStatFSBuf;
- n += __builtin_object_size(outStatFSBuf->f_mntonname ? "" : "", 1); // expected-warning{{address of array}}
- n += __builtin_object_size(outStatFSBuf->f_mntonname ?: "", 1);
+ n += OBJECT_SIZE_BUILTIN(outStatFSBuf->f_mntonname ? "" : "", 1); // expected-warning{{address of array}}
+ n += OBJECT_SIZE_BUILTIN(outStatFSBuf->f_mntonname ?: "", 1);
return n;
}
@@ -104,7 +111,7 @@
void rd36094951_IAS_builtin_object_size_assertion(IncompleteArrayStruct *p) {
#define rd36094951_CHECK(mode) \
__builtin___strlcpy_chk(p->session[0].string, "ab", 2, \
- __builtin_object_size(p->session[0].string, mode))
+ OBJECT_SIZE_BUILTIN(p->session[0].string, mode))
rd36094951_CHECK(0);
rd36094951_CHECK(1);
rd36094951_CHECK(2);
diff --git a/src/llvm-project/clang/test/Sema/builtin-preserve-access-index.c b/src/llvm-project/clang/test/Sema/builtin-preserve-access-index.c
new file mode 100644
index 0000000..c10ceb5
--- /dev/null
+++ b/src/llvm-project/clang/test/Sema/builtin-preserve-access-index.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -x c -triple x86_64-pc-linux-gnu -dwarf-version=4 -fsyntax-only -verify %s
+
+const void *invalid1(const int *arg) {
+ return __builtin_preserve_access_index(&arg[1], 1); // expected-error {{too many arguments to function call, expected 1, have 2}}
+}
+
+void *invalid2(const int *arg) {
+ return __builtin_preserve_access_index(&arg[1]); // expected-warning {{returning 'const void *' from a function with result type 'void *' discards qualifiers}}
+}
+
+const void *invalid3(const int *arg) {
+ return __builtin_preserve_access_index(1); // expected-warning {{incompatible integer to pointer conversion passing 'int' to parameter of type 'const void *'}}
+}
diff --git a/src/llvm-project/clang/test/Sema/builtin-setjmp.c b/src/llvm-project/clang/test/Sema/builtin-setjmp.c
new file mode 100644
index 0000000..f8770d8
--- /dev/null
+++ b/src/llvm-project/clang/test/Sema/builtin-setjmp.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify -DNO_JMP_BUF %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
+
+#ifdef NO_JMP_BUF
+extern long setjmp(long *); // expected-warning {{declaration of built-in function 'setjmp' requires the declaration of the 'jmp_buf' type, commonly provided in the header <setjmp.h>.}}
+#else
+typedef long jmp_buf;
+extern int setjmp(char); // expected-warning@8 {{incompatible redeclaration of library function 'setjmp'}}
+ // expected-note@8 {{'setjmp' is a builtin with type 'int (jmp_buf)' (aka 'int (long)')}}
+#endif
diff --git a/src/llvm-project/clang/test/Sema/builtins-arm64-mte.c b/src/llvm-project/clang/test/Sema/builtins-arm64-mte.c
new file mode 100644
index 0000000..4f87eb0
--- /dev/null
+++ b/src/llvm-project/clang/test/Sema/builtins-arm64-mte.c
@@ -0,0 +1,136 @@
+// RUN: %clang_cc1 -triple arm64-arm-eabi %s -target-feature +mte -fsyntax-only -verify
+// RUN: %clang_cc1 -triple arm64-arm-eabi %s -target-feature +mte -x c++ -fsyntax-only -verify
+#include <stddef.h>
+#include <arm_acle.h>
+
+int *create_tag1(int a, unsigned b) {
+ // expected-error@+1 {{first argument of MTE builtin function must be a pointer ('int' invalid)}}
+ return __arm_mte_create_random_tag(a,b);
+}
+
+int *create_tag2(int *a, unsigned *b) {
+ // expected-error@+1 {{second argument of MTE builtin function must be an integer type ('unsigned int *' invalid)}}
+ return __arm_mte_create_random_tag(a,b);
+}
+
+int *create_tag3(const int *a, unsigned b) {
+#ifdef __cplusplus
+ // expected-error@+1 {{cannot initialize return object of type 'int *' with an rvalue of type 'const int *'}}
+ return __arm_mte_create_random_tag(a,b);
+#else
+ // expected-warning@+1 {{returning 'const int *' from a function with result type 'int *' discards qualifiers}}
+ return __arm_mte_create_random_tag(a,b);
+#endif
+}
+
+int *create_tag4(volatile int *a, unsigned b) {
+#ifdef __cplusplus
+ // expected-error@+1 {{cannot initialize return object of type 'int *' with an rvalue of type 'volatile int *'}}
+ return __arm_mte_create_random_tag(a,b);
+#else
+ // expected-warning@+1 {{returning 'volatile int *' from a function with result type 'int *' discards qualifiers}}
+ return __arm_mte_create_random_tag(a,b);
+#endif
+}
+
+int *increment_tag1(int *a, unsigned b) {
+ // expected-error@+1 {{argument to '__builtin_arm_addg' must be a constant integer}}
+ return __arm_mte_increment_tag(a,b);
+}
+
+int *increment_tag2(int *a) {
+ // expected-error@+1 {{argument value 16 is outside the valid range [0, 15]}}
+ return __arm_mte_increment_tag(a,16);
+}
+
+int *increment_tag3(int *a) {
+ // expected-error@+1 {{argument value -1 is outside the valid range [0, 15]}}
+ return __arm_mte_increment_tag(a,-1);
+}
+
+int *increment_tag4(const int *a) {
+#ifdef __cplusplus
+ // expected-error@+1 {{cannot initialize return object of type 'int *' with an rvalue of type 'const int *'}}
+ return __arm_mte_increment_tag(a,5);
+#else
+ // expected-warning@+1 {{returning 'const int *' from a function with result type 'int *' discards qualifiers}}
+ return __arm_mte_increment_tag(a,5);
+#endif
+}
+
+int *increment_tag5(const volatile int *a) {
+#ifdef __cplusplus
+ // expected-error@+1 {{cannot initialize return object of type 'int *' with an rvalue of type 'const volatile int *'}}
+ return __arm_mte_increment_tag(a,5);
+#else
+ // expected-warning@+1 {{returning 'const volatile int *' from a function with result type 'int *' discards qualifiers}}
+ return __arm_mte_increment_tag(a,5);
+#endif
+}
+
+unsigned exclude_tag1(int *ptr, unsigned m) {
+ // expected-error@+1 {{first argument of MTE builtin function must be a pointer ('int' invalid)}}
+ return __arm_mte_exclude_tag(*ptr, m);
+}
+
+unsigned exclude_tag2(int *ptr, int *m) {
+ // expected-error@+1 {{second argument of MTE builtin function must be an integer type ('int *' invalid)}}
+ return __arm_mte_exclude_tag(ptr, m);
+}
+
+void get_tag1() {
+ // expected-error@+1 {{too few arguments to function call, expected 1, have 0}}
+ __arm_mte_get_tag();
+}
+
+int *get_tag2(int ptr) {
+ // expected-error@+1 {{first argument of MTE builtin function must be a pointer ('int' invalid)}}
+ return __arm_mte_get_tag(ptr);
+}
+
+int *get_tag3(const volatile int *ptr) {
+#ifdef __cplusplus
+ // expected-error@+1 {{cannot initialize return object of type 'int *' with an rvalue of type 'const volatile int *'}}
+ return __arm_mte_get_tag(ptr);
+#else
+ // expected-warning@+1 {{returning 'const volatile int *' from a function with result type 'int *' discards qualifiers}}
+ return __arm_mte_get_tag(ptr);
+#endif
+}
+
+void set_tag1() {
+ // expected-error@+1 {{too few arguments to function call, expected 1, have 0}}
+ __arm_mte_set_tag();
+}
+
+void set_tag2(int ptr) {
+ // expected-error@+1 {{first argument of MTE builtin function must be a pointer ('int' invalid)}}
+ __arm_mte_set_tag(ptr);
+}
+
+ptrdiff_t subtract_pointers1(int a, int *b) {
+ // expected-error@+1 {{first argument of MTE builtin function must be a null or a pointer ('int' invalid)}}
+ return __arm_mte_ptrdiff(a, b);
+}
+
+ptrdiff_t subtract_pointers2(int *a, int b) {
+ // expected-error@+1 {{second argument of MTE builtin function must be a null or a pointer ('int' invalid)}}
+ return __arm_mte_ptrdiff(a, b);
+}
+
+ptrdiff_t subtract_pointers3(char *a, int *b) {
+ // expected-error@+1 {{'char *' and 'int *' are not pointers to compatible types}}
+ return __arm_mte_ptrdiff(a, b);
+}
+
+ptrdiff_t subtract_pointers4(int *a, char *b) {
+ // expected-error@+1 {{'int *' and 'char *' are not pointers to compatible types}}
+ return __arm_mte_ptrdiff(a, b);
+}
+
+#ifdef __cplusplus
+ptrdiff_t subtract_pointers5() {
+ // expected-error@+1 {{at least one argument of MTE builtin function must be a pointer ('nullptr_t', 'nullptr_t' invalid)}}
+ return __arm_mte_ptrdiff(nullptr, nullptr);
+}
+#endif
diff --git a/src/llvm-project/clang/test/Sema/builtins-x86.c b/src/llvm-project/clang/test/Sema/builtins-x86.c
index 9872a64..6a2a47d 100644
--- a/src/llvm-project/clang/test/Sema/builtins-x86.c
+++ b/src/llvm-project/clang/test/Sema/builtins-x86.c
@@ -81,6 +81,14 @@
return __builtin_ia32_cmpps512_mask(__a, __b, 0, __u, 0); // expected-error {{invalid rounding argument}}
}
+__m512 test__builtin_ia32_getmantps512_mask(__m512 a, __m512 b) {
+ return __builtin_ia32_getmantps512_mask(a, 0, b, (__mmask16)-1, 10); // expected-error {{invalid rounding argument}}
+}
+
+__m128 test__builtin_ia32_getmantss_round_mask(__m128 a, __m128 b, __m128 c) {
+ return __builtin_ia32_getmantss_round_mask(a, b, 0, c, (__mmask8)-1, 10); // expected-error {{invalid rounding argument}}
+}
+
__m128i test_mm_mask_i32gather_epi32(__m128i a, int const *b, __m128i c, __m128i mask) {
return __builtin_ia32_gatherd_d(a, b, c, mask, 5); // expected-error {{scale argument must be 1, 2, 4, or 8}}
}
diff --git a/src/llvm-project/clang/test/Sema/builtins.c b/src/llvm-project/clang/test/Sema/builtins.c
index 62992c0..1d41bcf 100644
--- a/src/llvm-project/clang/test/Sema/builtins.c
+++ b/src/llvm-project/clang/test/Sema/builtins.c
@@ -230,14 +230,14 @@
// expected-note {{change size argument to be the size of the destination}}
__builtin___strlcpy_chk(buf, b, sizeof(b), __builtin_object_size(buf, 0)); // expected-warning {{size argument in '__builtin___strlcpy_chk' call appears to be size of the source; expected the size of the destination}} \
// expected-note {{change size argument to be the size of the destination}} \
- // expected-warning {{'__builtin___strlcpy_chk' will always overflow; destination buffer has size 20, but size argument is 40}}
+ // expected-warning {{'strlcpy' will always overflow; destination buffer has size 20, but size argument is 40}}
strlcat(buf, b, sizeof(b)); // expected-warning {{size argument in 'strlcat' call appears to be size of the source; expected the size of the destination}} \
// expected-note {{change size argument to be the size of the destination}}
__builtin___strlcat_chk(buf, b, sizeof(b), __builtin_object_size(buf, 0)); // expected-warning {{size argument in '__builtin___strlcat_chk' call appears to be size of the source; expected the size of the destination}} \
// expected-note {{change size argument to be the size of the destination}} \
- // expected-warning {{'__builtin___strlcat_chk' will always overflow; destination buffer has size 20, but size argument is 40}}
+ // expected-warning {{'strlcat' will always overflow; destination buffer has size 20, but size argument is 40}}
}
// rdar://11076881
@@ -245,7 +245,7 @@
{
static char buf[10];
- __builtin___memcpy_chk (&buf[6], in, 5, __builtin_object_size (&buf[6], 0)); // expected-warning {{'__builtin___memcpy_chk' will always overflow; destination buffer has size 4, but size argument is 5}}
+ __builtin___memcpy_chk (&buf[6], in, 5, __builtin_object_size (&buf[6], 0)); // expected-warning {{'memcpy' will always overflow; destination buffer has size 4, but size argument is 5}}
__builtin___memcpy_chk (p, "abcde", n, __builtin_object_size (p, 0));
@@ -253,7 +253,7 @@
__builtin___memcpy_chk (&buf[5], "abcde", n, __builtin_object_size (&buf[5], 0));
- __builtin___memcpy_chk (&buf[6], "abcde", 5, __builtin_object_size (&buf[6], 0)); // expected-warning {{'__builtin___memcpy_chk' will always overflow; destination buffer has size 4, but size argument is 5}}
+ __builtin___memcpy_chk (&buf[6], "abcde", 5, __builtin_object_size (&buf[6], 0)); // expected-warning {{'memcpy' will always overflow; destination buffer has size 4, but size argument is 5}}
return buf;
}
@@ -312,5 +312,11 @@
char src[1024];
char buf[10];
memcpy(buf, src, 11); // expected-warning{{'memcpy' will always overflow; destination buffer has size 10, but size argument is 11}}
- my_memcpy(buf, src, 11); // expected-warning{{'__builtin___memcpy_chk' will always overflow; destination buffer has size 10, but size argument is 11}}
+ my_memcpy(buf, src, 11); // expected-warning{{'memcpy' will always overflow; destination buffer has size 10, but size argument is 11}}
+}
+
+// Test that __builtin_is_constant_evaluated() is not allowed in C
+int test_cxx_builtin() {
+ // expected-error@+1 {{use of unknown builtin '__builtin_is_constant_evaluated'}}
+ return __builtin_is_constant_evaluated();
}
diff --git a/src/llvm-project/clang/test/Sema/c2x-maybe_unused-errors.c b/src/llvm-project/clang/test/Sema/c2x-maybe_unused-errors.c
index 68150dd..39ec2da 100644
--- a/src/llvm-project/clang/test/Sema/c2x-maybe_unused-errors.c
+++ b/src/llvm-project/clang/test/Sema/c2x-maybe_unused-errors.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wunused -fdouble-square-bracket-attributes -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wunused -std=c2x -verify %s
struct [[maybe_unused]] S1 { // ok
int a [[maybe_unused]];
diff --git a/src/llvm-project/clang/test/Sema/c2x-maybe_unused.c b/src/llvm-project/clang/test/Sema/c2x-maybe_unused.c
index 816cf78..82b9634 100644
--- a/src/llvm-project/clang/test/Sema/c2x-maybe_unused.c
+++ b/src/llvm-project/clang/test/Sema/c2x-maybe_unused.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wunused -fdouble-square-bracket-attributes -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wunused -std=c2x -verify %s
struct [[maybe_unused]] S1 { // ok
int a [[maybe_unused]];
diff --git a/src/llvm-project/clang/test/Sema/c2x-nodiscard.c b/src/llvm-project/clang/test/Sema/c2x-nodiscard.c
index fc5b123..5eaeda4 100644
--- a/src/llvm-project/clang/test/Sema/c2x-nodiscard.c
+++ b/src/llvm-project/clang/test/Sema/c2x-nodiscard.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fdouble-square-bracket-attributes -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c2x -verify %s
struct [[nodiscard]] S1 { // ok
int i;
diff --git a/src/llvm-project/clang/test/Sema/calling-conv-complete-params.c b/src/llvm-project/clang/test/Sema/calling-conv-complete-params.c
new file mode 100644
index 0000000..db203c3
--- /dev/null
+++ b/src/llvm-project/clang/test/Sema/calling-conv-complete-params.c
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -fsyntax-only -fms-extensions -verify -triple i686-pc-win32 %s
+// RUN: %clang_cc1 -fsyntax-only -fms-extensions -verify -triple x86_64-pc-win32 %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -fms-extensions -verify -triple i686-pc-win32 %s
+// RUN: %clang_cc1 -x c++ -DEXTERN_C='extern "C"' -fsyntax-only -fms-extensions -verify -triple i686-pc-win32 %s
+
+#ifndef EXTERN_C
+#define EXTERN_C
+#if defined(__cplusplus)
+#define EXPECT_NODIAG
+// expected-no-diagnostics
+#endif
+#endif
+
+#ifndef EXPECT_NODIAG
+// expected-note-re@+2 1+ {{forward declaration of '{{(struct )?}}Foo'}}
+#endif
+struct Foo;
+
+EXTERN_C void __stdcall fwd_std(struct Foo p);
+#if !defined(EXPECT_NODIAG) && defined(_M_IX86)
+// expected-error@+2 {{parameter 'p' must have a complete type to use function 'fwd_std' with the stdcall calling convention}}
+#endif
+void (__stdcall *fp_fwd_std)(struct Foo) = &fwd_std;
+
+EXTERN_C void __fastcall fwd_fast(struct Foo p);
+#if !defined(EXPECT_NODIAG) && defined(_M_IX86)
+// expected-error@+2 {{parameter 'p' must have a complete type to use function 'fwd_fast' with the fastcall calling convention}}
+#endif
+void (__fastcall *fp_fwd_fast)(struct Foo) = &fwd_fast;
+
+EXTERN_C void __vectorcall fwd_vector(struct Foo p);
+#if !defined(EXPECT_NODIAG)
+// expected-error@+2 {{parameter 'p' must have a complete type to use function 'fwd_vector' with the vectorcall calling convention}}
+#endif
+void (__vectorcall *fp_fwd_vector)(struct Foo) = &fwd_vector;
+
+#if defined(__cplusplus)
+template <typename T> struct TemplateWrapper {
+#ifndef EXPECT_NODIAG
+ // expected-error@+2 {{field has incomplete type 'Foo'}}
+#endif
+ T field;
+};
+
+EXTERN_C void __vectorcall tpl_ok(TemplateWrapper<int> p);
+void(__vectorcall *fp_tpl_ok)(TemplateWrapper<int>) = &tpl_ok;
+
+EXTERN_C void __vectorcall tpl_fast(TemplateWrapper<Foo> p);
+#ifndef EXPECT_NODIAG
+// expected-note@+2 {{requested here}}
+#endif
+void(__vectorcall *fp_tpl_fast)(TemplateWrapper<Foo>) = &tpl_fast;
+#endif
diff --git a/src/llvm-project/clang/test/Sema/callingconv-iamcu.c b/src/llvm-project/clang/test/Sema/callingconv-iamcu.c
index b66320e..248e98b 100644
--- a/src/llvm-project/clang/test/Sema/callingconv-iamcu.c
+++ b/src/llvm-project/clang/test/Sema/callingconv-iamcu.c
@@ -1,35 +1,35 @@
// RUN: %clang_cc1 %s -fsyntax-only -triple i686-intel-elfiamcu -verify
-void __attribute__((fastcall)) foo(float *a) { // expected-warning {{calling convention 'fastcall' ignored for this target}}
+void __attribute__((fastcall)) foo(float *a) { // expected-warning {{'fastcall' calling convention is not supported for this target}}
}
-void __attribute__((stdcall)) bar(float *a) { // expected-warning {{calling convention 'stdcall' ignored for this target}}
+void __attribute__((stdcall)) bar(float *a) { // expected-warning {{'stdcall' calling convention is not supported for this target}}
}
void __attribute__((fastcall(1))) baz(float *a) { // expected-error {{'fastcall' attribute takes no arguments}}
}
-void __attribute__((fastcall)) test2(int a, ...) { // expected-warning {{calling convention 'fastcall' ignored for this target}}
+void __attribute__((fastcall)) test2(int a, ...) { // expected-warning {{'fastcall' calling convention is not supported for this target}}
}
-void __attribute__((stdcall)) test3(int a, ...) { // expected-warning {{calling convention 'stdcall' ignored for this target}}
+void __attribute__((stdcall)) test3(int a, ...) { // expected-warning {{'stdcall' calling convention is not supported for this target}}
}
-void __attribute__((thiscall)) test4(int a, ...) { // expected-warning {{calling convention 'thiscall' ignored for this target}}
+void __attribute__((thiscall)) test4(int a, ...) { // expected-warning {{'thiscall' calling convention is not supported for this target}}
}
void __attribute__((cdecl)) ctest0() {}
void __attribute__((cdecl(1))) ctest1(float x) {} // expected-error {{'cdecl' attribute takes no arguments}}
-void (__attribute__((fastcall)) *pfoo)(float*) = foo; // expected-warning {{calling convention 'fastcall' ignored for this target}}
+void (__attribute__((fastcall)) *pfoo)(float*) = foo; // expected-warning {{'fastcall' calling convention is not supported for this target}}
-void (__attribute__((stdcall)) *pbar)(float*) = bar; // expected-warning {{calling convention 'stdcall' ignored for this target}}
+void (__attribute__((stdcall)) *pbar)(float*) = bar; // expected-warning {{'stdcall' calling convention is not supported for this target}}
void (*pctest0)() = ctest0;
void ctest2() {}
void (__attribute__((cdecl)) *pctest2)() = ctest2;
-typedef void (__attribute__((fastcall)) *Handler) (float *); // expected-warning {{calling convention 'fastcall' ignored for this target}}
+typedef void (__attribute__((fastcall)) *Handler) (float *); // expected-warning {{'fastcall' calling convention is not supported for this target}}
Handler H = foo;
int __attribute__((pcs("aapcs", "aapcs"))) pcs1(void); // expected-error {{'pcs' attribute takes one argument}}
@@ -38,16 +38,16 @@
// 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}}
+int __attribute__((pcs("aapcs"))) pcs5(void); // expected-warning {{'pcs' calling convention is not supported for this target}}
+int __attribute__((pcs("aapcs-vfp"))) pcs6(void); // expected-warning {{'pcs' calling convention is not supported for this target}}
int __attribute__((pcs("foo"))) pcs7(void); // expected-error {{invalid PCS type}}
void ctest3();
void __attribute__((cdecl)) ctest3() {}
-typedef __attribute__((stdcall)) void (*PROC)(); // expected-warning {{calling convention 'stdcall' ignored for this target}}
+typedef __attribute__((stdcall)) void (*PROC)(); // expected-warning {{'stdcall' calling convention is not supported for this target}}
PROC __attribute__((cdecl)) ctest4(const char *x) {}
-void __attribute__((intel_ocl_bicc)) inteloclbifunc(float *a) {} // expected-warning {{calling convention 'intel_ocl_bicc' ignored for this target}}
+void __attribute__((intel_ocl_bicc)) inteloclbifunc(float *a) {} // expected-warning {{'intel_ocl_bicc' calling convention is not supported for this target}}
-struct type_test {} __attribute__((stdcall)); // expected-warning {{calling convention 'stdcall' ignored for this target}} expected-warning {{'stdcall' attribute only applies to functions and methods}}
+struct type_test {} __attribute__((stdcall)); // expected-warning {{'stdcall' calling convention is not supported for this target}} expected-warning {{'stdcall' attribute only applies to functions and methods}}
diff --git a/src/llvm-project/clang/test/Sema/callingconv.c b/src/llvm-project/clang/test/Sema/callingconv.c
index 8b64bee..6273d04 100644
--- a/src/llvm-project/clang/test/Sema/callingconv.c
+++ b/src/llvm-project/clang/test/Sema/callingconv.c
@@ -16,9 +16,9 @@
void __attribute__((fastcall)) test1(void) {
}
-void __attribute__((fastcall)) test2(int a, ...) { // expected-warning {{fastcall calling convention ignored on variadic function}}
+void __attribute__((fastcall)) test2(int a, ...) { // expected-warning {{fastcall calling convention is not supported on variadic function}}
}
-void __attribute__((stdcall)) test3(int a, ...) { // expected-warning {{stdcall calling convention ignored on variadic function}}
+void __attribute__((stdcall)) test3(int a, ...) { // expected-warning {{stdcall calling convention is not supported on variadic function}}
}
void __attribute__((thiscall)) test4(int a, ...) { // expected-error {{variadic function cannot use thiscall calling convention}}
}
@@ -47,11 +47,11 @@
// 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}}
+int __attribute__((pcs("aapcs"))) pcs5(void); // expected-warning {{'pcs' calling convention is not supported for this target}}
+int __attribute__((pcs("aapcs-vfp"))) pcs6(void); // expected-warning {{'pcs' calling convention is not supported for this target}}
int __attribute__((pcs("foo"))) pcs7(void); // expected-error {{invalid PCS type}}
-int __attribute__((aarch64_vector_pcs)) aavpcs(void); // expected-warning {{calling convention 'aarch64_vector_pcs' ignored for this target}}
+int __attribute__((aarch64_vector_pcs)) aavpcs(void); // expected-warning {{'aarch64_vector_pcs' calling convention is not supported for this target}}
// PR6361
void ctest3();
@@ -68,3 +68,5 @@
void __attribute__((stdcall)) typedef_fun(int x) { } // expected-error {{function declared 'stdcall' here was previously declared without calling convention}}
struct type_test {} __attribute__((stdcall)); // expected-warning {{'stdcall' attribute only applies to functions and methods}}
+
+void __vectorcall __builtin_unreachable(); // expected-warning {{vectorcall calling convention is not supported on builtin function}}
diff --git a/src/llvm-project/clang/test/Sema/captured-statements.c b/src/llvm-project/clang/test/Sema/captured-statements.c
index 86e9273..ac04915 100644
--- a/src/llvm-project/clang/test/Sema/captured-statements.c
+++ b/src/llvm-project/clang/test/Sema/captured-statements.c
@@ -65,11 +65,18 @@
int b;
#pragma clang __debug captured
{
- __block int c;
int d;
^{
a = b; // expected-error{{__block variable 'a' cannot be captured in a captured statement}}
+ a = b; // (duplicate diagnostic suppressed)
b = d; // OK - Consistent with block inside a lambda
+ }();
+ }
+ #pragma clang __debug captured
+ {
+ __block int c;
+ int d;
+ ^{
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/src/llvm-project/clang/test/Sema/compare.c b/src/llvm-project/clang/test/Sema/compare.c
index b2b486f..25aa13f 100644
--- a/src/llvm-project/clang/test/Sema/compare.c
+++ b/src/llvm-project/clang/test/Sema/compare.c
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -pedantic -verify -Wsign-compare -Wtautological-constant-in-range-compare %s -Wno-unreachable-code
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -pedantic -verify -Wsign-compare -Wtype-limits %s -Wno-unreachable-code
int test(char *C) { // nothing here should warn.
return C != ((void*)0);
diff --git a/src/llvm-project/clang/test/Sema/conversion-target-dep.c b/src/llvm-project/clang/test/Sema/conversion-target-dep.c
new file mode 100644
index 0000000..e16685f
--- /dev/null
+++ b/src/llvm-project/clang/test/Sema/conversion-target-dep.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -Wdouble-promotion -Wimplicit-float-conversion %s -triple x86_64-apple-macosx10.12 -verify=x86,expected
+// RUN: %clang_cc1 -Wdouble-promotion -Wimplicit-float-conversion %s -triple armv7-apple-ios9.0 -verify=arm,expected
+
+// On ARM, long double and double both map to double precision 754s, so there
+// isn't any reason to warn on conversions back and forth.
+
+long double ld;
+double d;
+_Float16 f16; // x86-error {{_Float16 is not supported on this target}}
+
+int main() {
+ ld = d; // x86-warning {{implicit conversion increases floating-point precision: 'double' to 'long double'}}
+ d = ld; // x86-warning {{implicit conversion loses floating-point precision: 'long double' to 'double'}}
+
+ ld += d; // x86-warning {{implicit conversion increases floating-point precision: 'double' to 'long double'}}
+ d += ld; // x86-warning {{implicit conversion when assigning computation result loses floating-point precision: 'long double' to 'double'}}
+
+ f16 = ld; // expected-warning {{implicit conversion loses floating-point precision: 'long double' to '_Float16'}}
+ ld = f16; // expected-warning {{implicit conversion increases floating-point precision: '_Float16' to 'long double'}}
+
+ f16 += ld; // expected-warning {{implicit conversion when assigning computation result loses floating-point precision: 'long double' to '_Float16'}}
+ ld += f16; // expected-warning {{implicit conversion increases floating-point precision: '_Float16' to 'long double'}}
+}
+
diff --git a/src/llvm-project/clang/test/Sema/crash-deduction-guide-access.cpp b/src/llvm-project/clang/test/Sema/crash-deduction-guide-access.cpp
new file mode 100644
index 0000000..c0203ef
--- /dev/null
+++ b/src/llvm-project/clang/test/Sema/crash-deduction-guide-access.cpp
@@ -0,0 +1,11 @@
+// RUN: not %clang_cc1 -x c++ -std=c++17 -fsyntax-only %s
+template <typename U>
+class Imp {
+ template <typename F>
+ explicit Imp(F f);
+};
+
+template <typename T>
+class Cls {
+ explicit Imp() : f() {}
+};
diff --git a/src/llvm-project/clang/test/Sema/dllexport-1.cpp b/src/llvm-project/clang/test/Sema/dllexport-1.cpp
new file mode 100644
index 0000000..6180d35
--- /dev/null
+++ b/src/llvm-project/clang/test/Sema/dllexport-1.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -fms-extensions -verify %s
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -fsyntax-only -fms-extensions -verify %s -DMSVC
+
+// Export const variable initialization.
+
+#ifdef MSVC
+// expected-no-diagnostics
+#endif
+
+#ifndef MSVC
+// expected-warning@+2 {{__declspec attribute 'dllexport' is not supported}}
+#endif
+__declspec(dllexport) int const x = 3;
+
+namespace {
+namespace named {
+#ifndef MSVC
+// expected-warning@+2 {{__declspec attribute 'dllexport' is not supported}}
+#endif
+__declspec(dllexport) int const x = 3;
+}
+} // namespace
+
+namespace named1 {
+namespace {
+namespace named {
+#ifndef MSVC
+// expected-warning@+2 {{__declspec attribute 'dllexport' is not supported}}
+#endif
+__declspec(dllexport) int const x = 3;
+}
+} // namespace
+} // namespace named1
diff --git a/src/llvm-project/clang/test/Sema/dllexport-2.cpp b/src/llvm-project/clang/test/Sema/dllexport-2.cpp
new file mode 100644
index 0000000..41d96cc
--- /dev/null
+++ b/src/llvm-project/clang/test/Sema/dllexport-2.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -fms-extensions -verify %s
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -fsyntax-only -fms-extensions -verify %s -DMSVC
+
+// Export const variable.
+
+#ifdef MSVC
+// expected-error@+4 {{'j' must have external linkage when declared 'dllexport'}}
+#else
+// expected-warning@+2 {{__declspec attribute 'dllexport' is not supported}}
+#endif
+__declspec(dllexport) int const j; // expected-error {{default initialization of an object of const type 'const int'}}
+
+// With typedef
+typedef const int CInt;
+
+#ifdef MSVC
+// expected-error@+4 {{'j2' must have external linkage when declared 'dllexport'}}
+#else
+// expected-warning@+2 {{__declspec attribute 'dllexport' is not supported}}
+#endif
+__declspec(dllexport) CInt j2; //expected-error {{default initialization of an object of const type 'CInt'}}
+
+#ifndef MSVC
+// expected-warning@+2 {{__declspec attribute 'dllexport' is not supported}}
+#endif
+__declspec(dllexport) CInt j3 = 3;
diff --git a/src/llvm-project/clang/test/Sema/enable_if.c b/src/llvm-project/clang/test/Sema/enable_if.c
index 9125bfa..b4bb2ec 100644
--- a/src/llvm-project/clang/test/Sema/enable_if.c
+++ b/src/llvm-project/clang/test/Sema/enable_if.c
@@ -21,12 +21,12 @@
size_t __strnlen_chk(const char *s, size_t requested_amount, size_t s_len);
-size_t strnlen(const char *s, size_t maxlen) // expected-note{{candidate function}}
+size_t strnlen(const char *s, size_t maxlen)
__attribute__((overloadable))
__asm__("strnlen_real1");
__attribute__((always_inline))
-inline size_t strnlen(const char *s, size_t maxlen) // expected-note{{candidate function}}
+inline size_t strnlen(const char *s, size_t maxlen)
__attribute__((overloadable))
__attribute__((enable_if(__builtin_object_size(s, 0) != -1,
"chosen when target buffer size is known")))
@@ -34,7 +34,7 @@
return __strnlen_chk(s, maxlen, __builtin_object_size(s, 0));
}
-size_t strnlen(const char *s, size_t maxlen) // expected-note{{candidate disabled: chosen when 'maxlen' is known to be less than or equal to the buffer size}}
+size_t strnlen(const char *s, size_t maxlen)
__attribute__((overloadable))
__attribute__((enable_if(__builtin_object_size(s, 0) != -1,
"chosen when target buffer size is known")))
@@ -42,7 +42,7 @@
"chosen when 'maxlen' is known to be less than or equal to the buffer size")))
__asm__("strnlen_real2");
-size_t strnlen(const char *s, size_t maxlen) // expected-note{{candidate function has been explicitly made unavailable}}
+size_t strnlen(const char *s, size_t maxlen) // expected-note {{'strnlen' has been explicitly marked unavailable here}}
__attribute__((overloadable))
__attribute__((enable_if(__builtin_object_size(s, 0) != -1,
"chosen when target buffer size is known")))
@@ -62,12 +62,12 @@
strnlen(c, i);
// CHECK: call {{.*}}strnlen_chk
#ifndef CODEGEN
- strnlen(c, 999); // expected-error{{call to unavailable function 'strnlen': 'maxlen' is larger than the buffer size}}
+ strnlen(c, 999); // expected-error{{'strnlen' is unavailable: 'maxlen' is larger than the buffer size}}
#endif
}
-int isdigit(int c) __attribute__((overloadable)); // expected-note{{candidate function}}
-int isdigit(int c) __attribute__((overloadable)) // expected-note{{candidate function has been explicitly made unavailable}}
+int isdigit(int c) __attribute__((overloadable));
+int isdigit(int c) __attribute__((overloadable)) // expected-note {{'isdigit' has been explicitly marked unavailable here}}
__attribute__((enable_if(c <= -1 || c > 255, "'c' must have the value of an unsigned char or EOF")))
__attribute__((unavailable("'c' must have the value of an unsigned char or EOF")));
@@ -75,13 +75,13 @@
isdigit(c); // expected-warning{{ignoring return value of function declared with pure attribute}}
isdigit(10); // expected-warning{{ignoring return value of function declared with pure attribute}}
#ifndef CODEGEN
- isdigit(-10); // expected-error{{call to unavailable function 'isdigit': 'c' must have the value of an unsigned char or EOF}}
+ isdigit(-10); // expected-error{{'isdigit' is unavailable: 'c' must have the value of an unsigned char or EOF}}
#endif
}
// Verify that the alternate spelling __enable_if__ works as well.
-int isdigit2(int c) __attribute__((overloadable)); // expected-note{{candidate function}}
-int isdigit2(int c) __attribute__((overloadable)) // expected-note{{candidate function has been explicitly made unavailable}}
+int isdigit2(int c) __attribute__((overloadable));
+int isdigit2(int c) __attribute__((overloadable)) // expected-note {{'isdigit2' has been explicitly marked unavailable here}}
__attribute__((__enable_if__(c <= -1 || c > 255, "'c' must have the value of an unsigned char or EOF")))
__attribute__((unavailable("'c' must have the value of an unsigned char or EOF")));
@@ -89,7 +89,7 @@
isdigit2(c);
isdigit2(10);
#ifndef CODEGEN
- isdigit2(-10); // expected-error{{call to unavailable function 'isdigit2': 'c' must have the value of an unsigned char or EOF}}
+ isdigit2(-10); // expected-error{{'isdigit2' is unavailable: 'c' must have the value of an unsigned char or EOF}}
#endif
}
diff --git a/src/llvm-project/clang/test/Sema/fixed-enum.c b/src/llvm-project/clang/test/Sema/fixed-enum.c
index 60a4bc4..c77f5b0 100644
--- a/src/llvm-project/clang/test/Sema/fixed-enum.c
+++ b/src/llvm-project/clang/test/Sema/fixed-enum.c
@@ -2,6 +2,7 @@
// RUN: %clang_cc1 -Weverything -xc++ -std=c++03 -DCXX03 -verify %s
// RUN: %clang_cc1 -Weverything -xobjective-c -DOBJC -verify %s
// RUN: %clang_cc1 -Weverything -std=c11 -xc -DC11 -verify %s
+// RUN: %clang_cc1 -pedantic -std=c11 -xc -DC11 -verify %s
// RUN: %clang_cc1 -Weverything -std=c11 -xc -fms-extensions -DMS -verify %s
enum X : int {e};
@@ -10,9 +11,29 @@
#elif defined(CXX03)
// expected-warning@-4{{enumeration types with a fixed underlying type are a C++11 extension}}
#elif defined(OBJC)
-// expected-no-diagnostics
+// No diagnostic
#elif defined(C11)
// expected-warning@-8{{enumeration types with a fixed underlying type are a Clang extension}}
#elif defined(MS)
// expected-warning@-10{{enumeration types with a fixed underlying type are a Microsoft extension}}
#endif
+
+// Don't warn about the forward declaration in any language mode.
+enum Fwd : int;
+enum Fwd : int { e2 };
+#ifndef OBJC
+// expected-warning@-3 {{enumeration types with a fixed underlying type}}
+// expected-warning@-3 {{enumeration types with a fixed underlying type}}
+#endif
+
+// Always error on the incompatible redeclaration.
+enum BadFwd : int;
+#ifndef OBJC
+// expected-warning@-2 {{enumeration types with a fixed underlying type}}
+#endif
+// expected-note@-4 {{previous declaration is here}}
+enum BadFwd : char { e3 };
+#ifndef OBJC
+// expected-warning@-2 {{enumeration types with a fixed underlying type}}
+#endif
+// expected-error@-4 {{enumeration redeclared with different underlying type 'char' (was 'int')}}
diff --git a/src/llvm-project/clang/test/Sema/format-strings.c b/src/llvm-project/clang/test/Sema/format-strings.c
index a9af8ce..45bf260 100644
--- a/src/llvm-project/clang/test/Sema/format-strings.c
+++ b/src/llvm-project/clang/test/Sema/format-strings.c
@@ -329,7 +329,11 @@
printf("%S", s); // no-warning
printf("%s", s); // expected-warning{{format specifies type 'char *' but the argument has type 'wchar_t *'}}
printf("%C", s[0]); // no-warning
+#if defined(__sun) && !defined(__LP64__)
+ printf("%c", s[0]); // expected-warning{{format specifies type 'int' but the argument has type 'wchar_t' (aka 'long')}}
+#else
printf("%c", s[0]);
+#endif
// FIXME: This test reports inconsistent results. On Windows, '%C' expects
// 'unsigned short'.
// printf("%C", 10);
@@ -401,7 +405,7 @@
void pr7981(wint_t c, wchar_t c2) {
printf("%lc", c); // no-warning
printf("%lc", 1.0); // expected-warning{{the argument has type 'double'}}
-#if __WINT_WIDTH__ == 32
+#if __WINT_WIDTH__ == 32 && !(defined(__sun) && !defined(__LP64__))
printf("%lc", (char) 1); // no-warning
#else
printf("%lc", (char) 1); // expected-warning{{the argument has type 'char'}}
@@ -617,6 +621,8 @@
printf("%v4d", x); // expected-warning{{invalid conversion specifier 'v'}}
printf("%vd", x); // expected-warning{{invalid conversion specifier 'v'}}
printf("%0vd", x); // expected-warning{{invalid conversion specifier 'v'}}
+ printf("%hlf", x); // expected-warning{{invalid conversion specifier 'l'}}
+ printf("%hld", x); // expected-warning{{invalid conversion specifier 'l'}}
}
// Test that we correctly merge the format in both orders.
diff --git a/src/llvm-project/clang/test/Sema/implicit-builtin-decl.c b/src/llvm-project/clang/test/Sema/implicit-builtin-decl.c
index 3c2ff94..3a3dfa9 100644
--- a/src/llvm-project/clang/test/Sema/implicit-builtin-decl.c
+++ b/src/llvm-project/clang/test/Sema/implicit-builtin-decl.c
@@ -55,14 +55,17 @@
void snprintf() { }
-// PR8316
-void longjmp(); // expected-warning{{declaration of built-in function 'longjmp' requires inclusion of the header <setjmp.h>}}
+// PR8316 & PR40692
+void longjmp(); // expected-warning{{declaration of built-in function 'longjmp' requires the declaration of the 'jmp_buf' type, commonly provided in the header <setjmp.h>.}}
extern float fmaxf(float, float);
struct __jmp_buf_tag {};
-void sigsetjmp(struct __jmp_buf_tag[1], int); // expected-warning{{declaration of built-in function 'sigsetjmp' requires inclusion of the header <setjmp.h>}}
+void sigsetjmp(struct __jmp_buf_tag[1], int); // expected-warning{{declaration of built-in function 'sigsetjmp' requires the declaration of the 'jmp_buf' type, commonly provided in the header <setjmp.h>.}}
// CHECK: FunctionDecl {{.*}} <line:[[@LINE-2]]:1, col:44> col:6 sigsetjmp '
// CHECK-NOT: FunctionDecl
// CHECK: ReturnsTwiceAttr {{.*}} <{{.*}}> Implicit
+
+// PR40692
+void pthread_create(); // no warning expected
diff --git a/src/llvm-project/clang/test/Sema/inline-asm-validate-riscv.c b/src/llvm-project/clang/test/Sema/inline-asm-validate-riscv.c
new file mode 100644
index 0000000..744f73e
--- /dev/null
+++ b/src/llvm-project/clang/test/Sema/inline-asm-validate-riscv.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple riscv32 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple riscv64 -fsyntax-only -verify %s
+
+void I(int i) {
+ static const int BelowMin = -2049;
+ static const int AboveMax = 2048;
+ asm volatile ("" :: "I"(BelowMin)); // expected-error{{value '-2049' out of range for constraint 'I'}}
+ asm volatile ("" :: "I"(AboveMax)); // expected-error{{value '2048' out of range for constraint 'I'}}
+}
+
+void J(int j) {
+ static const int BelowMin = -1;
+ static const int AboveMax = 1;
+ asm volatile ("" :: "J"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'J'}}
+ asm volatile ("" :: "J"(AboveMax)); // expected-error{{value '1' out of range for constraint 'J'}}
+}
+
+void K(int k) {
+ static const int BelowMin = -1;
+ static const int AboveMax = 32;
+ asm volatile ("" :: "K"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'K'}}
+ asm volatile ("" :: "K"(AboveMax)); // expected-error{{value '32' out of range for constraint 'K'}}
+}
diff --git a/src/llvm-project/clang/test/Sema/inline-asm-validate-tmpl.cpp b/src/llvm-project/clang/test/Sema/inline-asm-validate-tmpl.cpp
index cf7eac3..9e234ca 100644
--- a/src/llvm-project/clang/test/Sema/inline-asm-validate-tmpl.cpp
+++ b/src/llvm-project/clang/test/Sema/inline-asm-validate-tmpl.cpp
@@ -23,3 +23,13 @@
asm("rol %1, %0" :"=r"(value): "I"(N + 1));
}
int foo() { testc<2>(10); }
+
+// these should compile without error
+template <int N> bool testd()
+{
+ __asm goto ("" : : : : lab);
+ return true;
+lab:
+ return false;
+}
+bool foox() { return testd<0> (); }
diff --git a/src/llvm-project/clang/test/Sema/inline-asm-validate-x86.c b/src/llvm-project/clang/test/Sema/inline-asm-validate-x86.c
index 5ea20ee..87b60a0 100644
--- a/src/llvm-project/clang/test/Sema/inline-asm-validate-x86.c
+++ b/src/llvm-project/clang/test/Sema/inline-asm-validate-x86.c
@@ -6,9 +6,6 @@
static const int AboveMax = 32;
__asm__("xorl %0,%2"
: "=r"(i)
- : "0"(i), "I"(j)); // expected-error{{constraint 'I' expects an integer constant expression}}
- __asm__("xorl %0,%2"
- : "=r"(i)
: "0"(i), "I"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'I'}}
__asm__("xorl %0,%2"
: "=r"(i)
@@ -23,9 +20,6 @@
static const int AboveMax = 64;
__asm__("xorl %0,%2"
: "=r"(i)
- : "0"(i), "J"(j)); // expected-error{{constraint 'J' expects an integer constant expression}}
- __asm__("xorl %0,%2"
- : "=r"(i)
: "0"(i), "J"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'J'}}
__asm__("xorl %0,%2"
: "=r"(i)
@@ -40,9 +34,6 @@
static const int AboveMax = 128;
__asm__("xorl %0,%2"
: "=r"(i)
- : "0"(i), "K"(j)); // expected-error{{constraint 'K' expects an integer constant expression}}
- __asm__("xorl %0,%2"
- : "=r"(i)
: "0"(i), "K"(BelowMin)); // expected-error{{value '-129' out of range for constraint 'K'}}
__asm__("xorl %0,%2"
: "=r"(i)
@@ -56,14 +47,12 @@
static const int Invalid1 = 1;
static const int Invalid2 = 42;
static const int Invalid3 = 0;
+ static const long long Invalid4 = 0x1000000ff;
static const int Valid1 = 0xff;
static const int Valid2 = 0xffff;
static const int Valid3 = 0xffffffff;
__asm__("xorl %0,%2"
: "=r"(i)
- : "0"(i), "L"(j)); // expected-error{{constraint 'L' expects an integer constant expression}}
- __asm__("xorl %0,%2"
- : "=r"(i)
: "0"(i), "L"(Invalid1)); // expected-error{{value '1' out of range for constraint 'L'}}
__asm__("xorl %0,%2"
: "=r"(i)
@@ -73,6 +62,9 @@
: "0"(i), "L"(Invalid3)); // expected-error{{value '0' out of range for constraint 'L'}}
__asm__("xorl %0,%2"
: "=r"(i)
+ : "0"(i), "L"(Invalid4)); // expected-error{{value '4294967551' out of range for constraint 'L'}}
+ __asm__("xorl %0,%2"
+ : "=r"(i)
: "0"(i), "L"(Valid1)); // expected-no-error
__asm__("xorl %0,%2"
: "=r"(i)
@@ -87,9 +79,6 @@
static const int AboveMax = 4;
__asm__("xorl %0,%2"
: "=r"(i)
- : "0"(i), "M"(j)); // expected-error{{constraint 'M' expects an integer constant expression}}
- __asm__("xorl %0,%2"
- : "=r"(i)
: "0"(i), "M"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'M'}}
__asm__("xorl %0,%2"
: "=r"(i)
@@ -104,9 +93,6 @@
static const int AboveMax = 256;
__asm__("xorl %0,%2"
: "=r"(i)
- : "0"(i), "N"(j)); // expected-error{{constraint 'N' expects an integer constant expression}}
- __asm__("xorl %0,%2"
- : "=r"(i)
: "0"(i), "N"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'N'}}
__asm__("xorl %0,%2"
: "=r"(i)
@@ -121,9 +107,6 @@
static const int AboveMax = 128;
__asm__("xorl %0,%2"
: "=r"(i)
- : "0"(i), "O"(j)); // expected-error{{constraint 'O' expects an integer constant expression}}
- __asm__("xorl %0,%2"
- : "=r"(i)
: "0"(i), "O"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'O'}}
__asm__("xorl %0,%2"
: "=r"(i)
@@ -142,10 +125,6 @@
__asm__ __volatile__("\n#define S_A abcd%0\n" : : "n"(&((struct s*)0)->a));
// This offset-from-null pointer can be used as an integer constant expression.
__asm__ __volatile__("\n#define S_B abcd%0\n" : : "n"(&((struct s*)0)->b));
- // This pointer cannot be used as an integer constant expression.
- __asm__ __volatile__("\n#define GLOBAL_A abcd%0\n" : : "n"(&s.a)); // expected-error{{constraint 'n' expects an integer constant expression}}
- // Floating-point is also not okay.
- __asm__ __volatile__("\n#define PI abcd%0\n" : : "n"(3.14f)); // expected-error{{constraint 'n' expects an integer constant expression}}
#ifdef AMD64
// This arbitrary pointer is fine.
__asm__ __volatile__("\n#define BEEF abcd%0\n" : : "n"((int*)0xdeadbeeeeeef));
diff --git a/src/llvm-project/clang/test/Sema/mingw-macro-qualified-type.c b/src/llvm-project/clang/test/Sema/mingw-macro-qualified-type.c
new file mode 100644
index 0000000..3e10c17
--- /dev/null
+++ b/src/llvm-project/clang/test/Sema/mingw-macro-qualified-type.c
@@ -0,0 +1,13 @@
+// Ensure that builtin attributes do not get treated as user defined macros to
+// be weapped in macro qualified types. This addresses P41852.
+//
+// RUN: %clang_cc1 %s -triple i686-w64-mingw32 -fsyntax-only -verify
+// expected-no-diagnostics
+
+typedef int WINBOOL;
+typedef unsigned int UINT_PTR, *PUINT_PTR;
+typedef unsigned long long ULONG64, *PULONG64;
+#define WINAPI __stdcall
+#define CALLBACK __stdcall
+
+typedef WINBOOL(CALLBACK WINAPI *PSYMBOLSERVERCALLBACKPROC)(UINT_PTR action, ULONG64 data, ULONG64 context);
diff --git a/src/llvm-project/clang/test/Sema/mrtd.c b/src/llvm-project/clang/test/Sema/mrtd.c
index 7bdeb27..0ce0888 100644
--- a/src/llvm-project/clang/test/Sema/mrtd.c
+++ b/src/llvm-project/clang/test/Sema/mrtd.c
@@ -12,7 +12,7 @@
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}}
+// expected-warning@+2 {{stdcall calling convention is not supported on variadic function}}
void variadic(int a, ...);
void __attribute__((stdcall)) variadic(int a, ...);
@@ -33,6 +33,6 @@
extern void (*c)(int, int);
__attribute__((stdcall)) extern void (*c)(int, int);
-// expected-warning@+2 {{stdcall calling convention ignored on variadic function}}
+// expected-warning@+2 {{stdcall calling convention is not supported on variadic function}}
extern void (*d)(int, ...);
__attribute__((stdcall)) extern void (*d)(int, ...);
diff --git a/src/llvm-project/clang/test/Sema/objc-bool-constant-conversion-fixit.m b/src/llvm-project/clang/test/Sema/objc-bool-constant-conversion-fixit.m
new file mode 100644
index 0000000..57f5752
--- /dev/null
+++ b/src/llvm-project/clang/test/Sema/objc-bool-constant-conversion-fixit.m
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -Werror=constant-conversion %s -fixit-recompile -fixit-to-temporary -E -o - | FileCheck %s
+
+typedef signed char BOOL;
+
+BOOL b;
+
+int main() {
+ BOOL b = 2;
+ // CHECK: BOOL b = 2 ? YES : NO;
+
+ b = b ? 2 : 1;
+ // CHECK: b = b ? 2 ? YES : NO : 1;
+
+ b = b ? 1 : 2;
+ // CHECK: b = b ? 1 : 2 ? YES : NO;
+
+ b = b ? 2 : 2;
+ // CHECK: b = b ? 2 ? YES : NO : 2 ? YES : NO;
+
+ b = 1 + 1;
+ // CHECK: b = (1 + 1) ? YES : NO;
+
+ b = 1 | 2;
+ // CHECK: b = (1 | 2) ? YES : NO;
+
+ b = 1 << 1;
+ // CHECK: b = (1 << 1) ? YES : NO;
+}
+
+@interface BoolProp
+@property BOOL b;
+@end
+
+void f(BoolProp *bp) {
+ bp.b = 43;
+ // CHECK: bp.b = 43 ? YES : NO;
+
+ [bp setB:43];
+ // CHECK: [bp setB:43 ? YES : NO];
+}
diff --git a/src/llvm-project/clang/test/Sema/objc-bool-constant-conversion.m b/src/llvm-project/clang/test/Sema/objc-bool-constant-conversion.m
new file mode 100644
index 0000000..3638e2f
--- /dev/null
+++ b/src/llvm-project/clang/test/Sema/objc-bool-constant-conversion.m
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+typedef signed char BOOL;
+#define YES __objc_yes
+#define NO __objc_no
+
+BOOL B;
+
+int main() {
+ B = 0;
+ B = 1;
+ B = YES;
+ B = NO;
+
+ B = -1; // expected-warning{{implicit conversion from constant value -1 to BOOL; the only well defined values for BOOL are YES and NO}}
+ B = 0 - 1; // expected-warning{{implicit conversion from constant value -1 to BOOL; the only well defined values for BOOL are YES and NO}}
+ B = YES + YES; // expected-warning {{implicit conversion from constant value 2 to BOOL; the only well defined values for BOOL are YES and NO}}
+ B = YES | YES;
+
+ B = B ? 2 : 2; // expected-warning 2 {{implicit conversion from constant value 2 to BOOL; the only well defined values for BOOL are YES and NO}}
+
+ BOOL Init = -1; // expected-warning{{implicit conversion from constant value -1 to BOOL; the only well defined values for BOOL are YES and NO}}
+ BOOL Init2 = B ? 2 : 2; // expected-warning 2 {{implicit conversion from constant value 2 to BOOL; the only well defined values for BOOL are YES and NO}}
+
+ void takesbool(BOOL);
+ takesbool(43); // expected-warning {{implicit conversion from constant value 43 to BOOL; the only well defined values for BOOL are YES and NO}}
+
+ BOOL OutOfRange = 400; // expected-warning{{implicit conversion from constant value 400 to BOOL; the only well defined values for BOOL are YES and NO}}
+}
+
+@interface BoolProp
+@property BOOL b;
+@end
+
+void f(BoolProp *bp) {
+ bp.b = 43; // expected-warning {{implicit conversion from constant value 43 to BOOL; the only well defined values for BOOL are YES and NO}}
+ [bp setB:43]; // expected-warning {{implicit conversion from constant value 43 to BOOL; the only well defined values for BOOL are YES and NO}}
+}
diff --git a/src/llvm-project/clang/test/Sema/overloadable.c b/src/llvm-project/clang/test/Sema/overloadable.c
index 4bdec85..61ef3fd 100644
--- a/src/llvm-project/clang/test/Sema/overloadable.c
+++ b/src/llvm-project/clang/test/Sema/overloadable.c
@@ -41,16 +41,15 @@
double *f(int) __attribute__((overloadable)); // expected-error{{conflicting types for 'f'}}
-double promote(float) __attribute__((__overloadable__)); // expected-note {{candidate}}
-double promote(double) __attribute__((__overloadable__)); // expected-note {{candidate}}
-long double promote(long double) __attribute__((__overloadable__)); // expected-note {{candidate}}
+double promote(float) __attribute__((__overloadable__));
+double promote(double) __attribute__((__overloadable__));
+long double promote(long double) __attribute__((__overloadable__));
-void promote(...) __attribute__((__overloadable__, __unavailable__)); // \
- // expected-note{{candidate function}}
+void promote(...) __attribute__((__overloadable__, __unavailable__)); // expected-note {{marked unavailable here}}
void test_promote(short* sp) {
promote(1.0);
- promote(sp); // expected-error{{call to unavailable function 'promote'}}
+ promote(sp); // expected-error{{'promote' is unavailable}}
}
// PR6600
diff --git a/src/llvm-project/clang/test/Sema/pass-object-size.c b/src/llvm-project/clang/test/Sema/pass-object-size.c
index 0745105..445d20b 100644
--- a/src/llvm-project/clang/test/Sema/pass-object-size.c
+++ b/src/llvm-project/clang/test/Sema/pass-object-size.c
@@ -17,6 +17,9 @@
void i(char *p __attribute__((pass_object_size(0)))); // OK -- const is only necessary on definitions, not decls.
void j(char *p __attribute__((pass_object_size(0), pass_object_size(1)))); //expected-error{{'pass_object_size' attribute can only be applied once per parameter}}
+void k(char *p __attribute__((pass_dynamic_object_size))); // expected-error {{'pass_dynamic_object_size' attribute takes one argument}}
+void l(int p __attribute__((pass_dynamic_object_size(0)))); // expected-error {{'pass_dynamic_object_size' attribute only applies to constant pointer arguments}}
+
#define PS(N) __attribute__((pass_object_size(N)))
#define overloaded __attribute__((overloadable))
void Overloaded(void *p PS(0)) overloaded; //expected-note{{previous declaration is here}}
@@ -32,14 +35,17 @@
void TakeFnOvl(void (*)(int *)) overloaded;
void NotOverloaded(void *p PS(0));
-void IsOverloaded(void *p PS(0)) overloaded;
-void IsOverloaded(char *p) overloaded; // char* inestead of void* is intentional
+void IsOverloaded(void *p PS(0)) overloaded; // expected-note 2 {{candidate address cannot be taken because parameter 1 has pass_object_size attribute}}
+
+// char* inestead of void* is intentional
+void IsOverloaded(char *p) overloaded; // expected-note{{passing argument to parameter 'p' here}} expected-note 2 {{type mismatch}}
+
void FunctionPtrs() {
void (*p)(void *) = NotOverloaded; //expected-error{{cannot take address of function 'NotOverloaded' because parameter 1 has pass_object_size attribute}}
void (*p2)(void *) = &NotOverloaded; //expected-error{{cannot take address of function 'NotOverloaded' because parameter 1 has pass_object_size attribute}}
- void (*p3)(void *) = IsOverloaded; //expected-warning{{incompatible pointer types initializing 'void (*)(void *)' with an expression of type '<overloaded function type>'}} expected-note@-6{{candidate address cannot be taken because parameter 1 has pass_object_size attribute}} expected-note@-5{{type mismatch}}
- void (*p4)(void *) = &IsOverloaded; //expected-warning{{incompatible pointer types initializing 'void (*)(void *)' with an expression of type '<overloaded function type>'}} expected-note@-7{{candidate address cannot be taken because parameter 1 has pass_object_size attribute}} expected-note@-6{{type mismatch}}
+ void (*p3)(void *) = IsOverloaded; //expected-warning{{incompatible pointer types initializing 'void (*)(void *)' with an expression of type '<overloaded function type>'}}
+ void (*p4)(void *) = &IsOverloaded; //expected-warning{{incompatible pointer types initializing 'void (*)(void *)' with an expression of type '<overloaded function type>'}}
void (*p5)(char *) = IsOverloaded;
void (*p6)(char *) = &IsOverloaded;
@@ -52,5 +58,11 @@
int P;
(&NotOverloaded)(&P); //expected-error{{cannot take address of function 'NotOverloaded' because parameter 1 has pass_object_size attribute}}
- (&IsOverloaded)(&P); //expected-warning{{incompatible pointer types passing 'int *' to parameter of type 'char *'}} expected-note@36{{passing argument to parameter 'p' here}}
+ (&IsOverloaded)(&P); //expected-warning{{incompatible pointer types passing 'int *' to parameter of type 'char *'}}
}
+
+void mismatch(void *p __attribute__((pass_object_size(0)))); // expected-note {{previous declaration is here}}
+void mismatch(void *p __attribute__((pass_dynamic_object_size(0)))); // expected-error {{conflicting pass_object_size attributes on parameters}}
+
+void mismatch2(void *p __attribute__((pass_dynamic_object_size(0)))); // expected-note {{previous declaration is here}}
+void mismatch2(void *p __attribute__((pass_dynamic_object_size(1)))); // expected-error {{conflicting pass_object_size attributes on parameters}}
diff --git a/src/llvm-project/clang/test/Sema/pr25786.c b/src/llvm-project/clang/test/Sema/pr25786.c
index 2ce6531..f79d814 100644
--- a/src/llvm-project/clang/test/Sema/pr25786.c
+++ b/src/llvm-project/clang/test/Sema/pr25786.c
@@ -2,8 +2,8 @@
// RUN: %clang_cc1 -triple i686-unknown-linux-gnu -fsyntax-only -verify %s
#if TEST
-void (__attribute__((regparm(3), stdcall)) *pf) (); //expected-warning {{calling convention 'stdcall' ignored for this target}}
-void (__attribute__((regparm(2), stdcall)) foo)(int a) { //expected-warning {{calling convention 'stdcall' ignored for this target}}
+void (__attribute__((regparm(3), stdcall)) *pf) (); //expected-warning {{'stdcall' calling convention is not supported for this target}}
+void (__attribute__((regparm(2), stdcall)) foo)(int a) { //expected-warning {{'stdcall' calling convention is not supported for this target}}
}
#else
//expected-no-diagnostics
diff --git a/src/llvm-project/clang/test/Sema/pragma-attribute-strict-subjects.c b/src/llvm-project/clang/test/Sema/pragma-attribute-strict-subjects.c
index a84e2bd..42e3e20 100644
--- a/src/llvm-project/clang/test/Sema/pragma-attribute-strict-subjects.c
+++ b/src/llvm-project/clang/test/Sema/pragma-attribute-strict-subjects.c
@@ -56,7 +56,8 @@
#pragma clang attribute pop
#pragma clang attribute push (__attribute__((abi_tag("a"))), apply_to = any(enum_constant, function, record(unless(is_union)), variable, variable(is_parameter)))
-// expected-error@-1 {{attribute 'abi_tag' can't be applied to 'variable(is_parameter)', and 'enum_constant'}}
+// FIXME: comma in this diagnostic is wrong.
+// expected-error@-2 {{attribute 'abi_tag' can't be applied to 'enum_constant', and 'variable(is_parameter)'}}
#pragma clang attribute pop
#pragma clang attribute push (__attribute__((abi_tag("a"))), apply_to = any(function, record(unless(is_union)), enum))
diff --git a/src/llvm-project/clang/test/Sema/pragma-section.c b/src/llvm-project/clang/test/Sema/pragma-section.c
index 2906fab..03aa053 100644
--- a/src/llvm-project/clang/test/Sema/pragma-section.c
+++ b/src/llvm-project/clang/test/Sema/pragma-section.c
@@ -42,3 +42,20 @@
#pragma section(".my_seg", nopage) // expected-warning {{known but unsupported action 'nopage' for '#pragma section' - ignored}}
#pragma section(".my_seg", read, write) // expected-error {{this causes a section type conflict with a prior #pragma section}}
#pragma section(".my_seg", read, write, 1) // expected-warning {{expected action or ')' in '#pragma section' - ignored}}
+
+#pragma bss_seg(".drectve") // expected-warning{{#pragma bss_seg(".drectve") has undefined behavior, use #pragma comment(linker, ...) instead}}
+#pragma code_seg(".drectve") // expected-warning{{#pragma code_seg(".drectve") has undefined behavior, use #pragma comment(linker, ...) instead}}
+#pragma const_seg(".drectve") // expected-warning{{#pragma const_seg(".drectve") has undefined behavior, use #pragma comment(linker, ...) instead}}
+#pragma data_seg(".drectve") // expected-warning{{#pragma data_seg(".drectve") has undefined behavior, use #pragma comment(linker, ...) instead}}
+#pragma code_seg(".my_seg")
+
+// cl.exe doesn't warn on this, so match that.
+// (Technically it ICEs on this particular example, but if it's on a class then
+// it just doesn't warn.)
+__declspec(code_seg(".drectve")) void drectve_fn(void) {}
+
+// This shouldn't warn; mingw users likely want to use
+// __attribute__((section(".drective")))
+// const char LinkerFlags[] = "-export:foo -export:bar";
+// for interop with gcc.
+__attribute__((section(".drectve"))) int drectve_int;
diff --git a/src/llvm-project/clang/test/Sema/shift.c b/src/llvm-project/clang/test/Sema/shift.c
index 47744fb..63c9538 100644
--- a/src/llvm-project/clang/test/Sema/shift.c
+++ b/src/llvm-project/clang/test/Sema/shift.c
@@ -20,6 +20,9 @@
c = 1 >> -0;
c = 1 << -1; // expected-warning {{shift count is negative}}
c = 1 >> -1; // expected-warning {{shift count is negative}}
+ c = 1 << (unsigned)-1; // expected-warning {{shift count >= width of type}}
+ // expected-warning@-1 {{implicit conversion}}
+ c = 1 >> (unsigned)-1; // expected-warning {{shift count >= width of type}}
c = 1 << c;
c <<= 0;
c >>= 0;
diff --git a/src/llvm-project/clang/test/Sema/source_location.c b/src/llvm-project/clang/test/Sema/source_location.c
new file mode 100644
index 0000000..d7f3154
--- /dev/null
+++ b/src/llvm-project/clang/test/Sema/source_location.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -std=c90 -fconst-strings -DCONST_STRINGS -verify %s
+// RUN: %clang_cc1 -std=c90 -verify %s
+
+// expected-no-diagnostics
+
+#define IsEqual(L, R) (__builtin_strcmp(L, R) == 0)
+
+const char *const FILE = __builtin_FILE();
+const char *const FUNC = __builtin_FUNCTION();
+const unsigned LINE = __builtin_LINE();
+const unsigned COL = __builtin_COLUMN();
+
+#ifndef CONST_STRINGS
+char *const NCFILE = __builtin_FILE();
+char *const NCFUNC = __builtin_FUNCTION();
+#endif
+
+#ifdef CONST_STRINGS
+_Static_assert(IsEqual(__builtin_FILE(), __FILE__), "");
+_Static_assert(__builtin_LINE() == __LINE__, "");
+_Static_assert(IsEqual("", __builtin_FUNCTION()), "");
+
+#line 42 "my_file.c"
+_Static_assert(__builtin_LINE() == 42, "");
+_Static_assert(IsEqual(__builtin_FILE(), "my_file.c"), "");
+
+_Static_assert(__builtin_COLUMN() == __builtin_strlen("_Static_assert(_"), "");
+
+void foo() {
+ _Static_assert(IsEqual(__builtin_FUNCTION(), "foo"), "");
+}
+#endif // CONST_STRINGS
diff --git a/src/llvm-project/clang/test/Sema/statements.c b/src/llvm-project/clang/test/Sema/statements.c
index ddaec8d..b410383 100644
--- a/src/llvm-project/clang/test/Sema/statements.c
+++ b/src/llvm-project/clang/test/Sema/statements.c
@@ -119,3 +119,21 @@
SIZE = sizeof(({unsigned long __ptr; __ptr;}))
};
}
+
+// GCC ignores empty statements at the end of compound expressions where the
+// result type is concerned.
+void test13() {
+ int a;
+ a = ({ 1; });
+ a = ({1;; });
+ a = ({int x = 1; (void)x; }); // expected-error {{assigning to 'int' from incompatible type 'void'}}
+ a = ({int x = 1; (void)x;; }); // expected-error {{assigning to 'int' from incompatible type 'void'}}
+}
+
+void test14() { return ({}); }
+void test15() {
+ return ({;;;; });
+}
+void test16() {
+ return ({test:;; });
+}
diff --git a/src/llvm-project/clang/test/Sema/static-array.c b/src/llvm-project/clang/test/Sema/static-array.c
index 304485d..cc1043f 100644
--- a/src/llvm-project/clang/test/Sema/static-array.c
+++ b/src/llvm-project/clang/test/Sema/static-array.c
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.14.0 -fsyntax-only -fblocks -verify %s
void cat0(int a[static 0]) {} // expected-warning {{'static' has no effect on zero-length arrays}}
-void cat(int a[static 3]) {} // expected-note 2 {{callee declares array parameter as static here}}
+void cat(int a[static 3]) {} // expected-note 4 {{callee declares array parameter as static here}} expected-note 2 {{passing argument to parameter 'a' here}}
void vat(int i, int a[static i]) {} // expected-note {{callee declares array parameter as static here}}
@@ -19,6 +19,14 @@
vat(1, 0); // expected-warning {{null passed to a callee that requires a non-null argument}}
vat(3, b);
+
+ char d[4];
+ cat((int *)d); // expected-warning {{array argument is too small; is of size 4, callee requires at least 12}}
+ cat(d); // expected-warning {{array argument is too small; is of size 4, callee requires at least 12}} expected-warning {{incompatible pointer types}}
+
+ char e[12];
+ cat((int *)e);
+ cat(e); // expected-warning {{incompatible pointer types}}
}
diff --git a/src/llvm-project/clang/test/Sema/stdcall-fastcall-x64.c b/src/llvm-project/clang/test/Sema/stdcall-fastcall-x64.c
index d2a475e..335da41 100644
--- a/src/llvm-project/clang/test/Sema/stdcall-fastcall-x64.c
+++ b/src/llvm-project/clang/test/Sema/stdcall-fastcall-x64.c
@@ -5,16 +5,16 @@
int __attribute__((fastcall)) var2; // expected-warning{{'fastcall' only applies to function types; type here is 'int'}}
// Different CC qualifiers are not compatible
-void __attribute__((stdcall, fastcall)) foo3(void); // expected-warning{{calling convention 'stdcall' ignored for this target}} expected-warning {{calling convention 'fastcall' ignored for this target}}
-void __attribute__((stdcall)) foo4(); // expected-warning{{calling convention 'stdcall' ignored for this target}}
-void __attribute__((fastcall)) foo4(void); // expected-warning {{calling convention 'fastcall' ignored for this target}}
+void __attribute__((stdcall, fastcall)) foo3(void); // expected-warning{{'stdcall' calling convention is not supported for this target}} expected-warning {{'fastcall' calling convention is not supported for this target}}
+void __attribute__((stdcall)) foo4(); // expected-warning{{'stdcall' calling convention is not supported for this target}}
+void __attribute__((fastcall)) foo4(void); // expected-warning {{'fastcall' calling convention is not supported for this target}}
// rdar://8876096
-void rdar8876096foo1(int i, int j) __attribute__((fastcall, cdecl)); // expected-warning{{calling convention 'fastcall' ignored for this target}}
-void rdar8876096foo2(int i, int j) __attribute__((fastcall, stdcall)); // expected-warning{{calling convention 'stdcall' ignored for this target}} expected-warning {{calling convention 'fastcall' ignored for this target}}
-void rdar8876096foo3(int i, int j) __attribute__((fastcall, regparm(2))); // expected-warning {{calling convention 'fastcall' ignored for this target}}
-void rdar8876096foo4(int i, int j) __attribute__((stdcall, cdecl)); // expected-warning{{calling convention 'stdcall' ignored for this target}}
-void rdar8876096foo5(int i, int j) __attribute__((stdcall, fastcall)); // expected-warning{{calling convention 'stdcall' ignored for this target}} expected-warning {{calling convention 'fastcall' ignored for this target}}
-void rdar8876096foo6(int i, int j) __attribute__((cdecl, fastcall)); // expected-warning {{calling convention 'fastcall' ignored for this target}}
-void rdar8876096foo7(int i, int j) __attribute__((cdecl, stdcall)); // expected-warning{{calling convention 'stdcall' ignored for this target}}
-void rdar8876096foo8(int i, int j) __attribute__((regparm(2), fastcall)); // expected-warning {{calling convention 'fastcall' ignored for this target}}
+void rdar8876096foo1(int i, int j) __attribute__((fastcall, cdecl)); // expected-warning{{'fastcall' calling convention is not supported for this target}}
+void rdar8876096foo2(int i, int j) __attribute__((fastcall, stdcall)); // expected-warning{{'stdcall' calling convention is not supported for this target}} expected-warning {{'fastcall' calling convention is not supported for this target}}
+void rdar8876096foo3(int i, int j) __attribute__((fastcall, regparm(2))); // expected-warning {{'fastcall' calling convention is not supported for this target}}
+void rdar8876096foo4(int i, int j) __attribute__((stdcall, cdecl)); // expected-warning{{'stdcall' calling convention is not supported for this target}}
+void rdar8876096foo5(int i, int j) __attribute__((stdcall, fastcall)); // expected-warning{{'stdcall' calling convention is not supported for this target}} expected-warning {{'fastcall' calling convention is not supported for this target}}
+void rdar8876096foo6(int i, int j) __attribute__((cdecl, fastcall)); // expected-warning {{'fastcall' calling convention is not supported for this target}}
+void rdar8876096foo7(int i, int j) __attribute__((cdecl, stdcall)); // expected-warning{{'stdcall' calling convention is not supported for this target}}
+void rdar8876096foo8(int i, int j) __attribute__((regparm(2), fastcall)); // expected-warning {{'fastcall' calling convention is not supported for this target}}
diff --git a/src/llvm-project/clang/test/Sema/tautological-constant-compare.c b/src/llvm-project/clang/test/Sema/tautological-constant-compare.c
index b242f35..4f9b43b 100644
--- a/src/llvm-project/clang/test/Sema/tautological-constant-compare.c
+++ b/src/llvm-project/clang/test/Sema/tautological-constant-compare.c
@@ -2,6 +2,8 @@
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wtautological-constant-in-range-compare -DTEST -verify -x c++ %s
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wtautological-type-limit-compare -DTEST -verify %s
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wtautological-type-limit-compare -DTEST -verify -x c++ %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wtype-limits -DTEST -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wtype-limits -DTEST -verify -x c++ %s
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra -Wno-sign-compare -verify %s
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra -Wno-sign-compare -verify -x c++ %s
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wall -verify %s
diff --git a/src/llvm-project/clang/test/Sema/tautological-constant-enum-compare.c b/src/llvm-project/clang/test/Sema/tautological-constant-enum-compare.c
index 99481c7..dcac245 100644
--- a/src/llvm-project/clang/test/Sema/tautological-constant-enum-compare.c
+++ b/src/llvm-project/clang/test/Sema/tautological-constant-enum-compare.c
@@ -2,6 +2,8 @@
// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -DSIGNED -Wtautological-constant-in-range-compare -verify %s
// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -DUNSIGNED -DSILENCE -Wno-tautological-constant-compare -verify %s
// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -DSIGNED -DSILENCE -Wno-tautological-constant-compare -verify %s
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -DUNSIGNED -Wtype-limits -verify %s
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -DUNSIGNED -DSILENCE -Wno-type-limits -verify %s
int main() {
enum A { A_a = 2 };
diff --git a/src/llvm-project/clang/test/Sema/tautological-objc-bool-compare.m b/src/llvm-project/clang/test/Sema/tautological-objc-bool-compare.m
new file mode 100644
index 0000000..525862e
--- /dev/null
+++ b/src/llvm-project/clang/test/Sema/tautological-objc-bool-compare.m
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 %s -verify
+
+typedef signed char BOOL;
+#define YES __objc_yes
+#define NO __objc_no
+
+BOOL B;
+
+void test() {
+ int r;
+ r = B > 0;
+ r = B > 1; // expected-warning {{result of comparison of constant 1 with expression of type BOOL is always false, as the only well defined values for BOOL are YES and NO}}
+ r = B < 1;
+ r = B < 0; // expected-warning {{result of comparison of constant 0 with expression of type BOOL is always false, as the only well defined values for BOOL are YES and NO}}
+ r = B >= 0; // expected-warning {{result of comparison of constant 0 with expression of type BOOL is always true, as the only well defined values for BOOL are YES and NO}}
+ r = B <= 0;
+
+ r = B > YES; // expected-warning {{result of comparison of constant YES with expression of type BOOL is always false, as the only well defined values for BOOL are YES and NO}}
+ r = B > NO;
+ r = B < NO; // expected-warning {{result of comparison of constant NO with expression of type BOOL is always false, as the only well defined values for BOOL are YES and NO}}
+ r = B < YES;
+ r = B >= NO; // expected-warning {{result of comparison of constant NO with expression of type BOOL is always true, as the only well defined values for BOOL are YES and NO}}
+ r = B <= NO;
+}
diff --git a/src/llvm-project/clang/test/Sema/transpose-memset.c b/src/llvm-project/clang/test/Sema/transpose-memset.c
index 6112fde..daad3f0 100644
--- a/src/llvm-project/clang/test/Sema/transpose-memset.c
+++ b/src/llvm-project/clang/test/Sema/transpose-memset.c
@@ -10,7 +10,7 @@
int main() {
memset(array, sizeof(array), 0); // expected-warning{{'size' argument to memset is '0'; did you mean to transpose the last two arguments?}} expected-note{{parenthesize the third argument to silence}}
- memset(array, sizeof(array), 0xff); // expected-warning{{setting buffer to a 'sizeof' expression; did you mean to transpose the last two arguments?}} expected-note{{cast the second argument to 'int' to silence}}
+ memset(array, sizeof(array), 0xff); // expected-warning{{setting buffer to a 'sizeof' expression; did you mean to transpose the last two arguments?}} expected-note{{cast the second argument to 'int' to silence}} expected-warning{{'memset' will always overflow; destination buffer has size 40, but size argument is 255}}
memset(ptr, sizeof(ptr), 0); // expected-warning{{'size' argument to memset is '0'; did you mean to transpose the last two arguments?}} expected-note{{parenthesize the third argument to silence}}
memset(ptr, sizeof(*ptr) * 10, 1); // expected-warning{{setting buffer to a 'sizeof' expression; did you mean to transpose the last two arguments?}} expected-note{{cast the second argument to 'int' to silence}}
memset(ptr, 10 * sizeof(int *), 1); // expected-warning{{setting buffer to a 'sizeof' expression; did you mean to transpose the last two arguments?}} expected-note{{cast the second argument to 'int' to silence}}
diff --git a/src/llvm-project/clang/test/Sema/varargs-aix.c b/src/llvm-project/clang/test/Sema/varargs-aix.c
new file mode 100644
index 0000000..5aaa209
--- /dev/null
+++ b/src/llvm-project/clang/test/Sema/varargs-aix.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple powerpc-ibm-aix
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple powerpc64-ibm-aix
+// expected-no-diagnostics
+
+extern __builtin_va_list ap;
+extern char *ap;
diff --git a/src/llvm-project/clang/test/Sema/warn-binary-conditional-expression-unused.c b/src/llvm-project/clang/test/Sema/warn-binary-conditional-expression-unused.c
new file mode 100644
index 0000000..982d66d
--- /dev/null
+++ b/src/llvm-project/clang/test/Sema/warn-binary-conditional-expression-unused.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunused-value -verify %s
+int main() {
+ int a;
+ int b;
+ a ? : b; //expected-warning{{expression result unused}}
+ a ? a : b; //expected-warning{{expression result unused}}
+ a ? : ++b;
+ a ? a : ++b;
+ ++a ? : b; //expected-warning{{expression result unused}}
+ ++a ? a : b; //expected-warning{{expression result unused}}
+ ++a ? : ++b;
+ ++a ? a : ++b;
+ return 0;
+};
+
diff --git a/src/llvm-project/clang/test/Sema/warn-double-promotion.c b/src/llvm-project/clang/test/Sema/warn-double-promotion.c
index 0cf33e8..5742a4f 100644
--- a/src/llvm-project/clang/test/Sema/warn-double-promotion.c
+++ b/src/llvm-project/clang/test/Sema/warn-double-promotion.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fsyntax-only %s -Wdouble-promotion
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -verify -fsyntax-only %s -Wdouble-promotion
float ReturnFloatFromDouble(double d) {
return d;
diff --git a/src/llvm-project/clang/test/Sema/warn-fortify-source.c b/src/llvm-project/clang/test/Sema/warn-fortify-source.c
new file mode 100644
index 0000000..d9c21c0
--- /dev/null
+++ b/src/llvm-project/clang/test/Sema/warn-fortify-source.c
@@ -0,0 +1,119 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.14.0 %s -verify
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.14.0 %s -verify -DUSE_PASS_OBJECT_SIZE
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.14.0 %s -verify -DUSE_BUILTINS
+// RUN: %clang_cc1 -xc++ -triple x86_64-apple-macosx10.14.0 %s -verify
+// RUN: %clang_cc1 -xc++ -triple x86_64-apple-macosx10.14.0 %s -verify -DUSE_PASS_OBJECT_SIZE
+// RUN: %clang_cc1 -xc++ -triple x86_64-apple-macosx10.14.0 %s -verify -DUSE_BUILTINS
+
+typedef unsigned long size_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(USE_PASS_OBJECT_SIZE)
+void *memcpy(void *dst, const void *src, size_t c);
+static void *memcpy(void *dst __attribute__((pass_object_size(1))), const void *src, size_t c) __attribute__((overloadable)) __asm__("merp");
+static void *memcpy(void *const dst __attribute__((pass_object_size(1))), const void *src, size_t c) __attribute__((overloadable)) {
+ return 0;
+}
+#elif defined(USE_BUILTINS)
+#define memcpy(x,y,z) __builtin_memcpy(x,y,z)
+#else
+void *memcpy(void *dst, const void *src, size_t c);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+void call_memcpy() {
+ char dst[10];
+ char src[20];
+ memcpy(dst, src, 20); // expected-warning {{memcpy' will always overflow; destination buffer has size 10, but size argument is 20}}
+
+ if (sizeof(dst) == sizeof(src))
+ memcpy(dst, src, 20); // no warning, unreachable
+}
+
+void call_memcpy_type() {
+ struct pair {
+ int first;
+ int second;
+ };
+ struct pair p;
+ char buf[20];
+ memcpy(&p.first, buf, 20);
+#ifdef USE_PASS_OBJECT_SIZE
+ // Use the more strict checking mode on the pass_object_size attribute:
+ // expected-warning@-3 {{memcpy' will always overflow; destination buffer has size 4, but size argument is 20}}
+#else
+ // Or just fallback to type 0:
+ // expected-warning@-6 {{memcpy' will always overflow; destination buffer has size 8, but size argument is 20}}
+#endif
+}
+
+void call_strncat() {
+ char s1[10], s2[20];
+ __builtin_strncat(s2, s1, 20);
+ __builtin_strncat(s1, s2, 20); // expected-warning {{'strncat' size argument is too large; destination buffer has size 10, but size argument is 20}}
+}
+
+void call_strncpy() {
+ char s1[10], s2[20];
+ __builtin_strncpy(s2, s1, 20);
+ __builtin_strncpy(s1, s2, 20); // expected-warning {{'strncpy' size argument is too large; destination buffer has size 10, but size argument is 20}}
+}
+
+void call_stpncpy() {
+ char s1[10], s2[20];
+ __builtin_stpncpy(s2, s1, 20);
+ __builtin_stpncpy(s1, s2, 20); // expected-warning {{'stpncpy' size argument is too large; destination buffer has size 10, but size argument is 20}}
+}
+
+void call_memmove() {
+ char s1[10], s2[20];
+ __builtin_memmove(s2, s1, 20);
+ __builtin_memmove(s1, s2, 20); // expected-warning {{'memmove' will always overflow; destination buffer has size 10, but size argument is 20}}
+}
+
+void call_memset() {
+ char buf[10];
+ __builtin_memset(buf, 0xff, 10);
+ __builtin_memset(buf, 0xff, 11); // expected-warning {{'memset' will always overflow; destination buffer has size 10, but size argument is 11}}
+}
+
+void call_snprintf() {
+ char buf[10];
+ __builtin_snprintf(buf, 10, "merp");
+ __builtin_snprintf(buf, 11, "merp"); // expected-warning {{'snprintf' size argument is too large; destination buffer has size 10, but size argument is 11}}
+}
+
+void call_vsnprintf() {
+ char buf[10];
+ __builtin_va_list list;
+ __builtin_vsnprintf(buf, 10, "merp", list);
+ __builtin_vsnprintf(buf, 11, "merp", list); // expected-warning {{'vsnprintf' size argument is too large; destination buffer has size 10, but size argument is 11}}
+}
+
+#ifdef __cplusplus
+template <class> struct S {
+ void mf() const {
+ __builtin_memset(const_cast<char *>(mv), 0, 0);
+ }
+
+ char mv[10];
+};
+
+template <int A, int B>
+void call_memcpy_dep() {
+ char bufferA[A];
+ char bufferB[B];
+ memcpy(bufferA, bufferB, 10); // expected-warning{{'memcpy' will always overflow; destination buffer has size 9, but size argument is 10}}
+}
+
+void call_call_memcpy() {
+ call_memcpy_dep<10, 9>();
+ call_memcpy_dep<9, 10>(); // expected-note {{in instantiation of function template specialization 'call_memcpy_dep<9, 10>' requested here}}
+}
+#endif
diff --git a/src/llvm-project/clang/test/Sema/warn-missing-prototypes.c b/src/llvm-project/clang/test/Sema/warn-missing-prototypes.c
index 10018b6..5940a49 100644
--- a/src/llvm-project/clang/test/Sema/warn-missing-prototypes.c
+++ b/src/llvm-project/clang/test/Sema/warn-missing-prototypes.c
@@ -1,21 +1,29 @@
// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -Wmissing-prototypes -verify %s
// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -Wmissing-prototypes -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
-int f();
+int f(); // expected-note{{this declaration is not a prototype; add parameter declarations to make it one}}
+// CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:{{.*}}-[[@LINE-1]]:{{.*}}}:"{{.*}}"
int f(int x) { return x; } // expected-warning{{no previous prototype for function 'f'}}
static int g(int x) { return x; }
int h(int x) { return x; } // expected-warning{{no previous prototype for function 'h'}}
+// expected-note@-1{{declare 'static' if the function is not intended to be used outside of this translation unit}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:1-[[@LINE-2]]:1}:"static "
static int g2();
int g2(int x) { return x; }
+extern int g3(int x) { return x; } // expected-warning{{no previous prototype for function 'g3'}}
+// expected-note@-1{{declare 'static' if the function is not intended to be used outside of this translation unit}}
+// CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-2]]:{{.*}}-[[@LINE-2]]:{{.*}}}:"{{.*}}"
+
void test(void);
-int h3();
+int h3(); // expected-note{{this declaration is not a prototype; add parameter declarations to make it one}}
+// CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:{{.*}}-[[@LINE-1]]:{{.*}}}:"{{.*}}"
int h4(int);
int h4();
@@ -26,6 +34,7 @@
}
int h2(int x) { return x; } // expected-warning{{no previous prototype for function 'h2'}}
+// expected-note@-1{{declare 'static' if the function is not intended to be used outside of this translation unit}}
int h3(int x) { return x; } // expected-warning{{no previous prototype for function 'h3'}}
int h4(int x) { return x; }
@@ -38,6 +47,5 @@
int main(void) { return 0; }
void not_a_prototype_test(); // expected-note{{this declaration is not a prototype; add 'void' to make it a prototype for a zero-parameter function}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:27-[[@LINE-1]]:27}:"void"
void not_a_prototype_test() { } // expected-warning{{no previous prototype for function 'not_a_prototype_test'}}
-
-// CHECK: fix-it:"{{.*}}":{40:27-40:27}:"void"
diff --git a/src/llvm-project/clang/test/Sema/warn-missing-variable-declarations.c b/src/llvm-project/clang/test/Sema/warn-missing-variable-declarations.c
index e5ce97d..f9644be 100644
--- a/src/llvm-project/clang/test/Sema/warn-missing-variable-declarations.c
+++ b/src/llvm-project/clang/test/Sema/warn-missing-variable-declarations.c
@@ -1,16 +1,19 @@
// RUN: %clang_cc1 -Wmissing-variable-declarations -fsyntax-only -verify %s
int vbad1; // expected-warning{{no previous extern declaration for non-static variable 'vbad1'}}
+// expected-note@-1{{declare 'static' if the variable is not intended to be used outside of this translation unit}}
int vbad2;
int vbad2 = 10; // expected-warning{{no previous extern declaration for non-static variable 'vbad2'}}
+// expected-note@-1{{declare 'static' if the variable is not intended to be used outside of this translation unit}}
-struct {
+struct { // expected-note{{declare 'static' if the variable is not intended to be used outside of this translation unit}}
int mgood1;
} vbad3; // expected-warning{{no previous extern declaration for non-static variable 'vbad3'}}
int vbad4;
int vbad4 = 10; // expected-warning{{no previous extern declaration for non-static variable 'vbad4'}}
+// expected-note@-1{{declare 'static' if the variable is not intended to be used outside of this translation unit}}
extern int vbad4;
extern int vgood1;
diff --git a/src/llvm-project/clang/test/Sema/warn-strict-prototypes.c b/src/llvm-project/clang/test/Sema/warn-strict-prototypes.c
index 0c23b3b..5565a09 100644
--- a/src/llvm-project/clang/test/Sema/warn-strict-prototypes.c
+++ b/src/llvm-project/clang/test/Sema/warn-strict-prototypes.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple i386-pc-unknown -fsyntax-only -Wstrict-prototypes -verify %s
+// RUN: %clang_cc1 -triple i386-pc-unknown -fsyntax-only -Wstrict-prototypes -Wno-implicit-function-declaration -verify %s
// RUN: %clang_cc1 -triple i386-pc-unknown -fsyntax-only -Wstrict-prototypes -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
// function declaration with unspecified params
@@ -71,3 +71,9 @@
// rdar://problem/33251668
void foo13(...) __attribute__((overloadable));
void foo13(...) __attribute__((overloadable)) {}
+
+// We should not generate a strict-prototype warning for an implicit
+// declaration. Leave that up to the implicit-function-declaration warning.
+void foo14(void) {
+ foo14_call(); // no-warning
+}
diff --git a/src/llvm-project/clang/test/Sema/warn-strncat-size.c b/src/llvm-project/clang/test/Sema/warn-strncat-size.c
index dcc3367..c050dd1 100644
--- a/src/llvm-project/clang/test/Sema/warn-strncat-size.c
+++ b/src/llvm-project/clang/test/Sema/warn-strncat-size.c
@@ -39,7 +39,7 @@
strncat(dest, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", sizeof(dest) - strlen(dest)); // expected-warning{{the value of the size argument in 'strncat' is too large, might lead to a buffer overflow}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}
strncat((*s5)->f2[x], s2, sizeof(s2)); // expected-warning {{size argument in 'strncat' call appears to be size of the source}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}
- strncat(s1+3, s2, sizeof(s2)); // expected-warning {{size argument in 'strncat' call appears to be size of the source}}
+ strncat(s1+3, s2, sizeof(s2)); // expected-warning {{size argument in 'strncat' call appears to be size of the source}} expected-warning {{strncat' size argument is too large; destination buffer has size 97, but size argument is 200}}
strncat(s4.f1, s2, sizeof(s2)); // expected-warning {{size argument in 'strncat' call appears to be size of the source}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}
}
diff --git a/src/llvm-project/clang/test/Sema/warn-thread-safety-analysis.c b/src/llvm-project/clang/test/Sema/warn-thread-safety-analysis.c
index 0a375b8..11b3140 100644
--- a/src/llvm-project/clang/test/Sema/warn-thread-safety-analysis.c
+++ b/src/llvm-project/clang/test/Sema/warn-thread-safety-analysis.c
@@ -77,7 +77,7 @@
Foo_fun1(1); // expected-warning{{calling function 'Foo_fun1' requires holding mutex 'mu2'}} \
expected-warning{{calling function 'Foo_fun1' requires holding mutex 'mu1' exclusively}}
- mutex_exclusive_lock(&mu1);
+ mutex_exclusive_lock(&mu1); // expected-note{{mutex acquired here}}
mutex_shared_lock(&mu2);
Foo_fun1(1);
@@ -117,11 +117,11 @@
(void)(*d_ == 1);
mutex_unlock(foo_.mu_);
- mutex_exclusive_lock(&mu1);
+ mutex_exclusive_lock(&mu1); // expected-note {{mutex acquired here}}
mutex_shared_unlock(&mu1); // expected-warning {{releasing mutex 'mu1' using shared access, expected exclusive access}}
mutex_exclusive_unlock(&mu1); // expected-warning {{releasing mutex 'mu1' that was not held}}
- mutex_shared_lock(&mu1);
+ mutex_shared_lock(&mu1); // expected-note {{mutex acquired here}}
mutex_exclusive_unlock(&mu1); // expected-warning {{releasing mutex 'mu1' using exclusive access, expected shared access}}
mutex_shared_unlock(&mu1); // expected-warning {{releasing mutex 'mu1' that was not held}}
diff --git a/src/llvm-project/clang/test/Sema/warn-uninitialized-statement-expression.c b/src/llvm-project/clang/test/Sema/warn-uninitialized-statement-expression.c
new file mode 100644
index 0000000..4e29ee0
--- /dev/null
+++ b/src/llvm-project/clang/test/Sema/warn-uninitialized-statement-expression.c
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -verify %s
+
+void init(int *);
+
+void foo(void) {
+ int i = ({
+ init(&i);
+ i;
+ });
+}
+
+void foo_bad(void) {
+ int i = ({
+ int z = i; // expected-warning{{variable 'i' is uninitialized when used within its own initialization}}
+ init(&i);
+ i;
+ });
+}
+
+struct widget {
+ int x, y;
+};
+void init2(struct widget *);
+
+void bar(void) {
+ struct widget my_widget = ({
+ init2(&my_widget);
+ my_widget;
+ });
+ struct widget a = (init2(&a), a);
+}
+
+void bar_bad(void) {
+ struct widget my_widget = ({
+ struct widget z = my_widget; // expected-warning{{variable 'my_widget' is uninitialized when used within its own initialization}}
+ int x = my_widget.x; //FIXME: There should be an uninitialized warning here
+ init2(&my_widget);
+ my_widget;
+ });
+}
+
+void baz(void) {
+ struct widget a = ({
+ struct widget b = ({
+ b = a; // expected-warning{{variable 'a' is uninitialized when used within its own initialization}}
+ });
+ a;
+ });
+}
+
+void f(void) {
+ struct widget *a = ({
+ init2(a); // expected-warning{{variable 'a' is uninitialized when used within its own initialization}}
+ a;
+ });
+}
diff --git a/src/llvm-project/clang/test/Sema/warn-unsequenced.c b/src/llvm-project/clang/test/Sema/warn-unsequenced.c
index 70163dc..9654cda 100644
--- a/src/llvm-project/clang/test/Sema/warn-unsequenced.c
+++ b/src/llvm-project/clang/test/Sema/warn-unsequenced.c
@@ -93,4 +93,13 @@
_Generic(++a, default: 0) + ++a; // ok
sizeof(++a) + ++a; // ok
_Alignof(++a) + ++a; // expected-warning {{extension}}
+
+ __builtin_constant_p(f(++a, 0)) ? f(f(++a, 0), f(++a, 0)) : 0;
+
+ if (0) ++a + ++a; // ok, unreachable
+}
+
+void g(const char *p, int n) {
+ // This resembles code produced by some macros in glibc's <string.h>.
+ __builtin_constant_p(p) && __builtin_constant_p(++n) && (++n + ++n);
}
diff --git a/src/llvm-project/clang/test/Sema/wchar.c b/src/llvm-project/clang/test/Sema/wchar.c
index e84fe3e..6a4b75b 100644
--- a/src/llvm-project/clang/test/Sema/wchar.c
+++ b/src/llvm-project/clang/test/Sema/wchar.c
@@ -9,7 +9,11 @@
#elif defined(__arm) || defined(__aarch64__)
#define WCHAR_T_TYPE unsigned int
#elif defined(__sun)
- #define WCHAR_T_TYPE long
+ #if defined(__LP64__)
+ #define WCHAR_T_TYPE int
+ #else
+ #define WCHAR_T_TYPE long
+ #endif
#else /* Solaris. */
#define WCHAR_T_TYPE int
#endif
diff --git a/src/llvm-project/clang/test/Sema/zero-initializer.c b/src/llvm-project/clang/test/Sema/zero-initializer.c
index 0ab410d..e54021a 100644
--- a/src/llvm-project/clang/test/Sema/zero-initializer.c
+++ b/src/llvm-project/clang/test/Sema/zero-initializer.c
@@ -7,6 +7,8 @@
struct B { struct A a; };
struct C { struct B b; };
struct D { struct C c; int n; };
+struct E { short e; };
+struct F { struct E e; int n; };
int main(void)
{
@@ -23,6 +25,9 @@
struct C p = { 0 }; // no-warning
struct C q = { 9 }; // warning suppressed for struct with single element
struct D r = { 9 }; // expected-warning {{suggest braces around initialization of subobject}} expected-warning {{missing field 'n' initializer}}
+ struct F s = { 0 }; // no-warning
+ struct F t = { 9 }; // expected-warning {{suggest braces around initialization of subobject}} expected-warning {{missing field 'n' initializer}}
+
f = (struct foo ) { 0 }; // no-warning
g = (struct foo ) { 9 }; // expected-warning {{missing field 'y' initializer}}
h = (struct foo ) { 9, 9 }; // no-warning
@@ -36,6 +41,8 @@
p = (struct C) { 0 }; // no-warning
q = (struct C) { 9 }; // warning suppressed for struct with single element
r = (struct D) { 9 }; // expected-warning {{suggest braces around initialization of subobject}} expected-warning {{missing field 'n' initializer}}
+ s = (struct F) { 0 }; // no-warning
+ t = (struct F) { 9 }; // expected-warning {{suggest braces around initialization of subobject}} expected-warning {{missing field 'n' initializer}}
return 0;
}