extern int i;
-int main ()
+int main (void)
{
typedef int16_t vSInt16 __attribute__ ((__vector_size__ (16)));
#ifdef HAVE
_Complex _Float16 a;
-void builtin_complex() {
+void builtin_complex(void) {
_Float16 a = 0;
(void)__builtin_complex(a, a); // expected-error {{'_Complex _Float16' is invalid}}
}
NESTED6; // expected-warning {{anonymous unions are a Microsoft extension}}
};
-void foo()
+void foo(void)
{
struct test var;
var.a;
void ptr_func2(int * __uptr __ptr32 i) {} // expected-error {{redefinition of 'ptr_func2'}}
// Check for warning when return types have the type attribute.
-void *__ptr32 ptr_func3() { return 0; } // expected-note {{previous definition is here}}
-void *__ptr64 ptr_func3() { return 0; } // expected-error {{redefinition of 'ptr_func3'}}
+void *__ptr32 ptr_func3(void) { return 0; } // expected-note {{previous definition is here}}
+void *__ptr64 ptr_func3(void) { return 0; } // expected-error {{redefinition of 'ptr_func3'}}
// Test that __ptr32/__ptr64 can be passed as arguments with other address
// spaces.
void ptr_func4(int *i);
void ptr_func5(int *__ptr32 i);
-void test_ptr_arguments() {
+void test_ptr_arguments(void) {
int *__ptr64 i64;
ptr_func4(i64);
ptr_func5(i64);
}
// __unaligned handling
-void test_unaligned() {
+void test_unaligned(void) {
__unaligned int *p1 = 0;
int *p2 = p1; // expected-warning {{initializing 'int *' with an expression of type '__unaligned int *' discards qualifiers}}
__unaligned int *p3 = p2;
int lock;
} audit_skb_queue;
-void fn1() {
+void fn1(void) {
audit_skb_queue = (lock); // expected-error {{use of undeclared identifier 'lock'; did you mean 'long'?}}
} // expected-error@-1 {{assigning to 'struct spinlock_t' from incompatible type '<overloaded function type>'}}
-void fn2() {
+void fn2(void) {
audit_skb_queue + (lock); // expected-error {{use of undeclared identifier 'lock'; did you mean 'long'?}}
} // expected-error@-1 {{reference to overloaded function could not be resolved; did you mean to call it?}}
struct EXCEPTION_INFO{};
-unsigned long __exception_code();
+unsigned long __exception_code(void);
#ifdef BORLAND
-struct EXCEPTION_INFO* __exception_info();
+struct EXCEPTION_INFO* __exception_info(void);
#endif
-int __abnormal_termination();
+int __abnormal_termination(void);
#define GetExceptionCode __exception_code
#define GetExceptionInformation __exception_info
DWORD FilterExpression(int); // expected-note{{declared here}}
DWORD FilterExceptionInformation(struct EXCEPTION_INFO*);
-const char * NotFilterExpression();
+const char * NotFilterExpression(void);
-void TEST() {
+void TEST(void) {
__try {
__try {
__try {
}
}
-void TEST() {
+void TEST(void) {
__try {
}
} // expected-error{{expected '__except' or '__finally' block}}
-void TEST() {
+void TEST(void) {
__except (FilterExpression()) { // expected-warning{{implicit declaration of function '__except' is invalid in C99}} \
// expected-error{{too few arguments to function call, expected 1, have 0}} \
// expected-error{{expected ';' after expression}}
}
}
-void TEST() {
+void TEST(void) {
__finally { } // expected-error{{}}
}
-void TEST() {
+void TEST(void) {
__try{
int try_scope = 0;
} // TODO: expected expression is an extra error
{}
}
-void TEST() {
+void TEST(void) {
__try {
}
}
}
-void TEST() {
+void TEST(void) {
__try {
}
}
}
-void TEST() {
+void TEST(void) {
__try {
}
}
}
-void TEST() {
+void TEST(void) {
int function_scope = 0;
__try {
int try_scope = 0;
}
}
-void TEST() {
+void TEST(void) {
int function_scope = 0;
__try {
int try_scope = 0;
}
}
-void TEST() {
+void TEST(void) {
int function_scope = 0;
__try {
}
#ifdef BORLAND
-void TEST() {
+void TEST(void) {
(void)__abnormal_termination(); // expected-error{{only allowed in __finally block}}
(void)AbnormalTermination(); // expected-error{{only allowed in __finally block}}
}
#endif
-void TEST() {
+void TEST(void) {
(void)__exception_info(); // expected-error{{only allowed in __except filter expression}}
(void)GetExceptionInformation(); // expected-error{{only allowed in __except filter expression}}
}
-void TEST() {
+void TEST(void) {
#ifndef BORLAND
(void)__exception_code; // expected-error{{builtin functions must be directly called}}
#endif
(void)GetExceptionCode(); // expected-error{{only allowed in __except block or filter expression}}
}
-void TEST() {
+void TEST(void) {
__try {
} __except(1) {
GetExceptionCode(); // valid
}
}
-void test_seh_leave_stmt() {
+void test_seh_leave_stmt(void) {
__leave; // expected-error{{'__leave' statement not in __try block}}
__try {
__leave; // expected-error{{'__leave' statement not in __try block}}
}
-void test_jump_out_of___finally() {
+void test_jump_out_of___finally(void) {
while(1) {
__try {
} __finally {
}
}
-void test_typo_in_except() {
+void test_typo_in_except(void) {
__try {
} __except(undeclared_identifier) { // expected-error {{use of undeclared identifier 'undeclared_identifier'}} expected-error {{expected expression}}
}
__attribute__((target("branch-protection=foo"))) // expected-error {{invalid or misplaced branch protection specification 'foo'}}
void
-badvalue0() {}
+badvalue0(void) {}
__attribute__((target("branch-protection=+bti"))) // expected-error {{invalid or misplaced branch protection specification '<empty>'}}
void
-badvalue1() {}
+badvalue1(void) {}
__attribute__((target("branch-protection=bti+"))) // expected-error {{invalid or misplaced branch protection specification '<empty>'}}
void
-badvalue2() {}
+badvalue2(void) {}
__attribute__((target("branch-protection=pac-ret+bkey"))) // expected-error {{invalid or misplaced branch protection specification 'bkey'}}
void
-badvalue3() {}
+badvalue3(void) {}
__attribute__((target("branch-protection=bti+leaf"))) // expected-error {{invalid or misplaced branch protection specification 'leaf'}}
void
-badoption0() {}
+badoption0(void) {}
__attribute__((target("branch-protection=bti+leaf+pac-ret"))) // expected-error {{invalid or misplaced branch protection specification 'leaf'}}
void
-badorder0() {}
+badorder0(void) {}
__attribute__((target("branch-protection=pac-ret+bti+leaf"))) // expected-error {{invalid or misplaced branch protection specification 'leaf'}}
void
-badorder1() {}
+badorder1(void) {}
__builtin_arm_wsr64("sysreg", v);
}
-unsigned rsr_1() {
+unsigned rsr_1(void) {
return __builtin_arm_rsr("sysreg");
}
-void *rsrp_1() {
+void *rsrp_1(void) {
return __builtin_arm_rsrp("sysreg");
}
-unsigned long rsr64_1() {
+unsigned long rsr64_1(void) {
return __builtin_arm_rsr64("sysreg");
}
__builtin_arm_wsr64("0:1:2:3:4", v);
}
-unsigned rsr_2() {
+unsigned rsr_2(void) {
return __builtin_arm_rsr("0:1:15:15:4");
}
-void *rsrp_2() {
+void *rsrp_2(void) {
return __builtin_arm_rsrp("0:1:2:3:4");
}
-unsigned long rsr64_2() {
+unsigned long rsr64_2(void) {
return __builtin_arm_rsr64("0:1:15:15:4");
}
__builtin_arm_wsr64("0:1:2", v); //expected-error {{invalid special register for builtin}}
}
-unsigned rsr_3() {
+unsigned rsr_3(void) {
return __builtin_arm_rsr("0:1:2"); //expected-error {{invalid special register for builtin}}
}
-unsigned rsr_4() {
+unsigned rsr_4(void) {
return __builtin_arm_rsr("0:1:2:3:8"); //expected-error {{invalid special register for builtin}}
}
-unsigned rsr_5() {
+unsigned rsr_5(void) {
return __builtin_arm_rsr("0:8:1:2:3"); //expected-error {{invalid special register for builtin}}
}
-unsigned rsr_6() {
+unsigned rsr_6(void) {
return __builtin_arm_rsr("0:1:16:16:2"); //expected-error {{invalid special register for builtin}}
}
-void *rsrp_3() {
+void *rsrp_3(void) {
return __builtin_arm_rsrp("0:1:2"); //expected-error {{invalid special register for builtin}}
}
-unsigned long rsr64_3() {
+unsigned long rsr64_3(void) {
return __builtin_arm_rsr64("0:1:2"); //expected-error {{invalid special register for builtin}}
}
-unsigned long rsr64_4() {
+unsigned long rsr64_4(void) {
return __builtin_arm_rsr64("0:1:2:3:8"); //expected-error {{invalid special register for builtin}}
}
-unsigned long rsr64_5() {
+unsigned long rsr64_5(void) {
return __builtin_arm_rsr64("0:8:2:3:4"); //expected-error {{invalid special register for builtin}}
}
-unsigned long rsr64_6() {
+unsigned long rsr64_6(void) {
return __builtin_arm_rsr64("0:1:16:16:2"); //expected-error {{invalid special register for builtin}}
}
// RUN: %clang_cc1 %s -triple aarch64-none-linux-gnu -target-feature +sve,+bf16 -fsyntax-only -verify
-void f() {
+void f(void) {
int size_s8[sizeof(__SVInt8_t) == 0 ? 1 : -1]; // expected-error {{invalid application of 'sizeof' to sizeless type '__SVInt8_t'}}
int align_s8[__alignof__(__SVInt8_t) == 16 ? 1 : -1]; // expected-error {{invalid application of '__alignof' to sizeless type '__SVInt8_t'}}
#include "arm_acle.h"
-void test_no_tme_funcs() {
+void test_no_tme_funcs(void) {
__tstart(); // expected-warning{{implicit declaration of function '__tstart'}}
__builtin_tstart(); // expected-error{{use of unknown builtin '__builtin_tstart'}}
}
}
// RUN: %clang_cc1 -triple aarch64-eabi -target-feature +tme -verify %s
-void t_cancel_range() {
+void t_cancel_range(void) {
__builtin_arm_tcancel(0x12345u); // expected-error{{argument value 74565 is outside the valid range [0, 65535]}}
}
typedef struct Arguable ArguableT;
-struct Arguable *get_arguable();
+struct Arguable *get_arguable(void);
void to_void(void *);
void to_intptr(intptr_t);
int d;
} __attribute__((packed, aligned(16))) s6;
-void g8()
+void g8(void)
{
f1(&s6.a); // no-warning
f1(&s6.c); // no-warning
struct __attribute__((aligned(8))) AlignedContainer { struct MisalignedContainee b; };
struct AlignedContainer *p;
-double* g9() {
+double* g9(void) {
return &p->b.d; // no-warning
}
typedef struct S9 __attribute__((__aligned__(16))) aligned_S9;
-void g10() {
+void g10(void) {
struct S9 x;
struct S9 __attribute__((__aligned__(8))) y;
aligned_S9 z;
#define AS3 __attribute__((AS(3)))
#define AS5 __attribute__((address_space(5))) char
-void normal_case() {
+void normal_case(void) {
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}}
}
test3_helper(test4_array); // expected-error{{passing 'AS2 char *' to parameter of type 'char *' changes address space of pointer}}
}
-void func() {
+void func(void) {
char AS1 *x;
char AS3 *x2;
AS5 *x3;
__attribute__((address_space(2))) int *y = x; // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
}
-void override_macro_name() {
+void override_macro_name(void) {
#define ATTRS __attribute__((noderef)) // expected-note{{previous definition is here}}
ATTRS
#define ATTRS __attribute__((address_space(1))) // expected-warning{{'ATTRS' macro redefined}}
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() {
+void partial_macro_declaration(void) {
#define ATTRS2 __attribute__((noderef))
ATTRS2 __attribute__((address_space(1))) int *x;
};
// Assertion failure was when the field was accessed
-void access_as_field()
+void access_as_field(void)
{
struct HasASFields x;
(void) bar.as_field;
// Compound literals in function scope are lvalues with automatic storage duration,
// so they cannot realistically be qualified with an address space.
-void as_compound_literal() {
+void as_compound_literal(void) {
(_AS1 struct SomeStruct){1, 2, 3}; // expected-error {{compound literal in function scope may not be qualified with an address space}}
(_AS1 char[]){"test"}; // expected-error {{compound literal in function scope may not be qualified with an address space}}
(_AS1 char[]){'a', 'b', 'c'}; // expected-error {{compound literal in function scope may not be qualified with an address space}}
// RUN: %clang_cc1 -triple x86_64-linux-gnu -Wunneeded-internal-declaration -x c -verify %s
// expected-no-diagnostics
-static int f() { return 42; }
-int g() __attribute__((alias("f")));
+static int f(void) { return 42; }
+int g(void) __attribute__((alias("f")));
static int foo [] = { 42, 0xDEAD };
extern typeof(foo) bar __attribute__((unused, alias("foo")));
typedef double * __attribute__((align_value(32*2))) aligned_double5;
// expected-warning@+1 {{'align_value' attribute only applies to variables and typedefs}}
-void foo() __attribute__((align_value(32)));
+void bar(void) __attribute__((align_value(32)));
void *passthrought(int a) {
return test_ptr_alloc_align(a);
}
-void *align16() {
+void *align16(void) {
return test_ptr_alloc_align(16);
}
-void *align15() {
+void *align15(void) {
return test_ptr_alloc_align(15); // expected-warning {{requested alignment is not a power of 2}}
}
-void *align1073741824() {
+void *align1073741824(void) {
return test_ptr_alloc_align(8589934592); // expected-warning {{requested alignment must be 4294967296 bytes or smaller; maximum alignment assumed}}
}
vector unsigned __int128 *__attribute__((__overloadable__)) convert2(__v1ulll);
#endif
-void test() {
+void test(void) {
__v16sc gv1;
__v16uc gv2;
__v8ss gv3;
{
}
-void test()
+void test(void)
{
v4 vGCC;
vector int vAltiVec;
// The following should not assert. See qiongsiwu1's comment here:
// https://reviews.llvm.org/D115670
-void test2() {
+void test2(void) {
vector signed local_vec = {1, 2, 3, 4};
VecMem VM;
VM.vec = ++local_vec;
};
int z; // expected-error{{duplicate member 'z'}}
- void zz(); // expected-error{{duplicate member 'zz'}}
+ void zz(void); // expected-error{{duplicate member 'zz'}}
};
union { // expected-warning{{declaration does not declare anything}}
float float_val2;
};
-void f() {
+void f(void) {
int_val2 = 0; // expected-error{{use of undeclared identifier}}
float_val2 = 0.0; // expected-error{{use of undeclared identifier}}
}
-void g() {
+void g(void) {
union { // expected-warning{{declaration does not declare anything}}
int i;
float f2;
__attribute__((target("branch-protection=foo"))) // expected-error {{invalid or misplaced branch protection specification 'foo'}}
void
-badvalue0() {}
+badvalue0(void) {}
__attribute__((target("branch-protection=+bti"))) // expected-error {{invalid or misplaced branch protection specification '<empty>'}}
void
-badvalue1() {}
+badvalue1(void) {}
__attribute__((target("branch-protection=bti+"))) // expected-error {{invalid or misplaced branch protection specification '<empty>'}}
void
-badvalue2() {}
+badvalue2(void) {}
__attribute__((target("branch-protection=pac-ret+bkey"))) // expected-error {{invalid or misplaced branch protection specification 'bkey'}}
void
-badvalue3() {}
+badvalue3(void) {}
__attribute__((target("branch-protection=pac-ret+b-key"))) // expected-warning {{unsupported branch protection specification 'b-key'}}
void
-badvalue4() {}
+badvalue4(void) {}
__attribute__((target("branch-protection=bti+leaf"))) // expected-error {{invalid or misplaced branch protection specification 'leaf'}}
void
-badoption0() {}
+badoption0(void) {}
__attribute__((target("branch-protection=bti+leaf+pac-ret"))) // expected-error {{invalid or misplaced branch protection specification 'leaf'}}
void
-badorder0() {}
+badorder0(void) {}
__attribute__((target("branch-protection=pac-ret+bti+leaf"))) // expected-error {{invalid or misplaced branch protection specification 'leaf'}}
void
-badorder1() {}
+badorder1(void) {}
// RUN: %clang_cc1 -triple thumbv6m -verify -fsyntax-only %s
// expected-warning@+1 {{unsupported 'branch-protection' in the 'target' attribute string; 'target' attribute ignored}}
-__attribute__((target("arch=cortex-m0,branch-protection=bti"))) void f1() {}
+__attribute__((target("arch=cortex-m0,branch-protection=bti"))) void f1(void) {}
// expected-warning@+1 {{unsupported 'branch-protection' in the 'target' attribute string; 'target' attribute ignored}}
-__attribute__((target("arch=cortex-m0,branch-protection=pac-ret"))) void f2() {}
+__attribute__((target("arch=cortex-m0,branch-protection=pac-ret"))) void f2(void) {}
// expected-warning@+1 {{unsupported 'branch-protection' in the 'target' attribute string; 'target' attribute ignored}}
-__attribute__((target("arch=cortex-m0,branch-protection=bti+pac-ret"))) void f3() {}
+__attribute__((target("arch=cortex-m0,branch-protection=bti+pac-ret"))) void f3(void) {}
// expected-warning@+1 {{unsupported 'branch-protection' in the 'target' attribute string; 'target' attribute ignored}}
-__attribute__((target("arch=cortex-m0,branch-protection=bti+pac-ret+leaf"))) void f4() {}
+__attribute__((target("arch=cortex-m0,branch-protection=bti+pac-ret+leaf"))) void f4(void) {}
// expected-warning@+1 {{unsupported 'branch-protection' in the 'target' attribute string; 'target' attribute ignored}}
-__attribute__((target("arch=cortex-a17,thumb,branch-protection=bti+pac-ret+leaf"))) void f5() {}
+__attribute__((target("arch=cortex-a17,thumb,branch-protection=bti+pac-ret+leaf"))) void f5(void) {}
// expected-no-diagnostics
// Armv8.1-M.Main
-__attribute__((target("arch=cortex-m55,branch-protection=bti"))) void f1() {}
-__attribute__((target("arch=cortex-m55,branch-protection=pac-ret"))) void f2() {}
-__attribute__((target("arch=cortex-m55,branch-protection=bti+pac-ret"))) void f3() {}
-__attribute__((target("arch=cortex-m55,branch-protection=bti+pac-ret+leaf"))) void f4() {}
+__attribute__((target("arch=cortex-m55,branch-protection=bti"))) void f1(void) {}
+__attribute__((target("arch=cortex-m55,branch-protection=pac-ret"))) void f2(void) {}
+__attribute__((target("arch=cortex-m55,branch-protection=bti+pac-ret"))) void f3(void) {}
+__attribute__((target("arch=cortex-m55,branch-protection=bti+pac-ret+leaf"))) void f4(void) {}
// Armv8-M.Main
-__attribute__((target("arch=cortex-m33,branch-protection=bti"))) void f5() {}
-__attribute__((target("arch=cortex-m33,branch-protection=pac-ret"))) void f6() {}
-__attribute__((target("arch=cortex-m33,branch-protection=bti+pac-ret"))) void f7() {}
-__attribute__((target("arch=cortex-m33,branch-protection=bti+pac-ret+leaf"))) void f8() {}
+__attribute__((target("arch=cortex-m33,branch-protection=bti"))) void f5(void) {}
+__attribute__((target("arch=cortex-m33,branch-protection=pac-ret"))) void f6(void) {}
+__attribute__((target("arch=cortex-m33,branch-protection=bti+pac-ret"))) void f7(void) {}
+__attribute__((target("arch=cortex-m33,branch-protection=bti+pac-ret+leaf"))) void f8(void) {}
// Armv7-M
-__attribute__((target("arch=cortex-m3,branch-protection=bti"))) void f9() {}
-__attribute__((target("arch=cortex-m3,branch-protection=pac-ret"))) void f10() {}
-__attribute__((target("arch=cortex-m3,branch-protection=bti+pac-ret"))) void f11() {}
-__attribute__((target("arch=cortex-m3,branch-protection=bti+pac-ret+leaf"))) void f12() {}
+__attribute__((target("arch=cortex-m3,branch-protection=bti"))) void f9(void) {}
+__attribute__((target("arch=cortex-m3,branch-protection=pac-ret"))) void f10(void) {}
+__attribute__((target("arch=cortex-m3,branch-protection=bti+pac-ret"))) void f11(void) {}
+__attribute__((target("arch=cortex-m3,branch-protection=bti+pac-ret+leaf"))) void f12(void) {}
// Armv7E-M
-__attribute__((target("arch=cortex-m4,branch-protection=bti"))) void f13() {}
-__attribute__((target("arch=cortex-m4,branch-protection=pac-ret"))) void f14() {}
-__attribute__((target("arch=cortex-m4,branch-protection=bti+pac-ret"))) void f15() {}
-__attribute__((target("arch=cortex-m4,branch-protection=bti+pac-ret+leaf"))) void f16() {}
+__attribute__((target("arch=cortex-m4,branch-protection=bti"))) void f13(void) {}
+__attribute__((target("arch=cortex-m4,branch-protection=pac-ret"))) void f14(void) {}
+__attribute__((target("arch=cortex-m4,branch-protection=bti+pac-ret"))) void f15(void) {}
+__attribute__((target("arch=cortex-m4,branch-protection=bti+pac-ret+leaf"))) void f16(void) {}
void (*fn2)(int, union U) __attribute__((cmse_nonsecure_call));
-union U xyzzy() __attribute__((cmse_nonsecure_entry)) {
+union U xyzzy(void) __attribute__((cmse_nonsecure_entry)) {
fn2(0, u);
return u;
}
// RUN: %clang_cc1 %s -triple thumbeb-none-eabi -target-feature +neon -verify -fsyntax-only
// RUN: %clang_cc1 %s -triple thumbeb-none-eabi -target-feature +neon -target-feature +soft-float -DSOFT -verify -fsyntax-only
-__attribute__((interrupt(IRQ))) void foo() {} // expected-error {{'interrupt' attribute requires a string}}
-__attribute__((interrupt("irq"))) void foo1() {} // expected-warning {{'interrupt' attribute argument not supported: irq}}
+__attribute__((interrupt(IRQ))) void foo(void) {} // expected-error {{'interrupt' attribute requires a string}}
+__attribute__((interrupt("irq"))) void foo1(void) {} // expected-warning {{'interrupt' attribute argument not supported: irq}}
-__attribute__((interrupt("IRQ", 1))) void foo2() {} // expected-error {{'interrupt' attribute takes no more than 1 argument}}
+__attribute__((interrupt("IRQ", 1))) void foo2(void) {} // expected-error {{'interrupt' attribute takes no more than 1 argument}}
-__attribute__((interrupt("IRQ"))) void foo3() {}
-__attribute__((interrupt("FIQ"))) void foo4() {}
-__attribute__((interrupt("SWI"))) void foo5() {}
-__attribute__((interrupt("ABORT"))) void foo6() {}
-__attribute__((interrupt("UNDEF"))) void foo7() {}
+__attribute__((interrupt("IRQ"))) void foo3(void) {}
+__attribute__((interrupt("FIQ"))) void foo4(void) {}
+__attribute__((interrupt("SWI"))) void foo5(void) {}
+__attribute__((interrupt("ABORT"))) void foo6(void) {}
+__attribute__((interrupt("UNDEF"))) void foo7(void) {}
-__attribute__((interrupt)) void foo8() {}
-__attribute__((interrupt())) void foo9() {}
-__attribute__((interrupt(""))) void foo10() {}
+__attribute__((interrupt)) void foo8(void) {}
+__attribute__((interrupt())) void foo9(void) {}
+__attribute__((interrupt(""))) void foo10(void) {}
#ifndef SOFT
// expected-note@+2 {{'callee1' declared here}}
#endif
-void callee1();
-__attribute__((interrupt("IRQ"))) void callee2();
-void caller1() {
+void callee1(void);
+__attribute__((interrupt("IRQ"))) void callee2(void);
+void caller1(void) {
callee1();
callee2();
}
#ifndef SOFT
-__attribute__((interrupt("IRQ"))) void caller2() {
+__attribute__((interrupt("IRQ"))) void caller2(void) {
callee1(); // expected-warning {{call to function without interrupt attribute could clobber interruptee's VFP registers}}
callee2();
}
-void (*callee3)();
-__attribute__((interrupt("IRQ"))) void caller3() {
+void (*callee3)(void);
+__attribute__((interrupt("IRQ"))) void caller3(void) {
callee3(); // expected-warning {{call to function without interrupt attribute could clobber interruptee's VFP registers}}
}
#else
-__attribute__((interrupt("IRQ"))) void caller2() {
+__attribute__((interrupt("IRQ"))) void caller2(void) {
callee1();
callee2();
}
-void (*callee3)();
-__attribute__((interrupt("IRQ"))) void caller3() {
+void (*callee3)(void);
+__attribute__((interrupt("IRQ"))) void caller3(void) {
callee3();
}
#endif
// RUN: %clang_cc1 -triple thumbv8m.base-none-eabi -verify %s
-typedef void (*callback_ns_1t)()
+typedef void (*callback_ns_1t)(void)
__attribute__((cmse_nonsecure_call)); // expected-warning{{'cmse_nonsecure_call' attribute ignored}}
-void f()
+void f(void)
__attribute__((cmse_nonsecure_entry)) {} // expected-warning{{'cmse_nonsecure_entry' attribute ignored}}
__builtin_arm_wsr64("sysreg", v); //expected-error {{invalid special register for builtin}}
}
-unsigned rsr_1() {
+unsigned rsr_1(void) {
return __builtin_arm_rsr("sysreg");
}
-void *rsrp_1() {
+void *rsrp_1(void) {
return __builtin_arm_rsrp("sysreg");
}
-unsigned long rsr64_1() {
+unsigned long rsr64_1(void) {
return __builtin_arm_rsr64("sysreg"); //expected-error {{invalid special register for builtin}}
}
__builtin_arm_wsr64("cp0:1:c2:c3:4", v); //expected-error {{invalid special register for builtin}}
}
-unsigned rsr_2() {
+unsigned rsr_2(void) {
return __builtin_arm_rsr("cp0:1:c15:c15:4");
}
-void *rsrp_2() {
+void *rsrp_2(void) {
return __builtin_arm_rsrp("cp0:1:c2:c3:4");
}
-unsigned long rsr64_2() {
+unsigned long rsr64_2(void) {
return __builtin_arm_rsr64("cp0:1:c2:c3:4"); //expected-error {{invalid special register for builtin}}
}
__builtin_arm_wsr64("cp0:1:c2", v);
}
-unsigned rsr_3() {
+unsigned rsr_3(void) {
return __builtin_arm_rsr("cp0:1:c2"); //expected-error {{invalid special register for builtin}}
}
-void *rsrp_3() {
+void *rsrp_3(void) {
return __builtin_arm_rsrp("cp0:1:c2"); //expected-error {{invalid special register for builtin}}
}
-unsigned long rsr64_3() {
+unsigned long rsr64_3(void) {
return __builtin_arm_rsr64("cp0:1:c15");
}
-unsigned rsr_4() {
+unsigned rsr_4(void) {
return __builtin_arm_rsr("0:1:2:3:4"); //expected-error {{invalid special register for builtin}}
}
-unsigned rsr_5() {
+unsigned rsr_5(void) {
return __builtin_arm_rsr("cp0:1:c2:c3:8"); //expected-error {{invalid special register for builtin}}
}
-unsigned rsr_6() {
+unsigned rsr_6(void) {
return __builtin_arm_rsr("cp0:8:c1:c2:3"); //expected-error {{invalid special register for builtin}}
}
-unsigned rsr_7() {
+unsigned rsr_7(void) {
return __builtin_arm_rsr("cp0:1:c16:c16:2"); //expected-error {{invalid special register for builtin}}
}
-void *rsrp_4() {
+void *rsrp_4(void) {
return __builtin_arm_rsrp("0:1:2:3:4"); //expected-error {{invalid special register for builtin}}
}
-unsigned long rsr64_4() {
+unsigned long rsr64_4(void) {
return __builtin_arm_rsr64("0:1:2"); //expected-error {{invalid special register for builtin}}
}
-unsigned long rsr64_5() {
+unsigned long rsr64_5(void) {
return __builtin_arm_rsr64("cp0:8:c1"); //expected-error {{invalid special register for builtin}}
}
-unsigned long rsr64_6() {
+unsigned long rsr64_6(void) {
return __builtin_arm_rsr64("cp0:1:c16"); //expected-error {{invalid special register for builtin}}
}
// RUN: %clang_cc1 -triple arm64-apple-ios7.1 -fsyntax-only -verify %s
-void foo() {
+void foo(void) {
asm volatile("USE(%0)" :: "z"(0LL));
asm volatile("USE(%x0)" :: "z"(0LL));
asm volatile("USE(%w0)" :: "z"(0));
struct RDar11387038_B { TabHandle x; };
typedef struct RDar11387038_B RDar11387038_B;
-void radar11387038() {
+void radar11387038(void) {
RDar11387038_B *pRDar11387038_B;
struct RDar11387038* y = &(*pRDar11387038_B->x)->z[4];
}
return z;
}
-void ff() {
+void ff(void) {
struct s v, *p; // expected-error {{variable has incomplete type 'struct s'}}
p = &v;
return f;
}
-void check_size() {
+void check_size(void) {
float f;
int size_not_int[f]; // expected-error {{size of array has non-integer type 'float'}}
int negative_size[1-2]; // expected-error{{array with a negative size}}
void strFunc(char *); // expected-note{{passing argument to parameter here}}
const char staticAry[] = "test";
-void checkStaticAry() {
+void checkStaticAry(void) {
strFunc(staticAry); // expected-warning{{passing 'const char[5]' to parameter of type 'char *' discards qualifiers}}
}
// RUN: %clang_cc1 -triple x86_64-apple-darwin -verify %s
-void f() {
+void f(void) {
int a[2147483647U][2147483647U]; // expected-error{{array is too large}}
int b[1073741825U - 1U][2147483647U]; // expected-error{{array is too large}}
}
-void pr8256 () {
+void pr8256(void) {
typedef char a[1LL<<61]; // expected-error {{array is too large}}
typedef char b[(long long)sizeof(a)-1];
}
// RUN: %clang_cc1 -triple i686-apple-darwin -verify %s
-void f() {
+void f(void) {
int x0[1073741824]; // expected-error{{array is too large}}
int x1[1073741824 + 1]; // expected-error{{array is too large}}
int x2[(unsigned)1073741824]; // expected-error{{array is too large}}
// RUN: %clang_cc1 -fsyntax-only -verify %s
-inline void __attribute__((artificial)) foo() {}
-void __attribute__((artificial)) bar() {} // expected-warning {{'artificial' attribute only applies to inline functions}}
+inline void __attribute__((artificial)) foo(void) {}
+void __attribute__((artificial)) bar(void) {} // expected-warning {{'artificial' attribute only applies to inline functions}}
// RUN: %clang_cc1 -verify %s
-void f();
-void f() __asm__("fish");
-void g();
+void f(void);
+void f(void) __asm__("fish");
+void g(void);
-void f() {
+void f(void) {
g();
}
-void g() __asm__("gold"); // expected-error{{cannot apply asm label to function after its first use}}
+void g(void) __asm__("gold"); // expected-error{{cannot apply asm label to function after its first use}}
-void h() __asm__("hose"); // expected-note{{previous declaration is here}}
-void h() __asm__("hair"); // expected-error{{conflicting asm label}}
+void h(void) __asm__("hose"); // expected-note{{previous declaration is here}}
+void h(void) __asm__("hair"); // expected-error{{conflicting asm label}}
int x;
int x __asm__("xenon");
int y;
-int test() { return y; }
+int test(void) { return y; }
int y __asm__("yacht"); // expected-error{{cannot apply asm label to variable after its first use}}
// No diagnostics on the following.
-void __real_readlink() __asm("readlink");
-void readlink() __asm("__protected_readlink");
-void readlink() { __real_readlink(); }
+void __real_readlink(void) __asm("readlink");
+void readlink(void) __asm("__protected_readlink");
+void readlink(void) { __real_readlink(); }
// RUN: %clang_cc1 %s -Wno-private-extern -triple i386-pc-linux-gnu -verify -fsyntax-only
-void f() {
+void f(void) {
int i;
asm ("foo\n" : : "a" (i + 2));
asm ("foo\n" : "=a" (i) : "" (i)); // expected-error {{invalid input constraint '' in asm}}
}
-void clobbers() {
+void clobbers(void) {
asm ("nop" : : : "ax", "#ax", "%ax");
asm ("nop" : : : "eax", "rax", "ah", "al");
asm ("nop" : : : "0", "%0", "#0");
}
// rdar://6094010
-void test3() {
+void test3(void) {
int x;
asm(L"foo" : "=r"(x)); // expected-error {{wide string}}
asm("foo" : L"=r"(x)); // expected-error {{wide string}}
}
// <rdar://problem/6512595>
-void test5() {
+void test5(void) {
asm("nop" : : "X" (8));
}
}
// PR15759.
-double test15() {
+double test15(void) {
double ret = 0;
__asm("0.0":"="(ret)); // expected-error {{invalid output constraint '=' in asm}}
__asm("0.0":"=&"(ret)); // expected-error {{invalid output constraint '=&' in asm}}
return result;
}
-void fn1() {
+void fn1(void) {
int l;
__asm__(""
: [l] "=r"(l)
: "[l],m"(l)); // expected-error {{asm constraint has an unexpected number of alternatives: 1 vs 2}}
}
-void fn2() {
+void fn2(void) {
int l;
__asm__(""
: "+&m"(l)); // expected-error {{invalid output constraint '+&m' in asm}}
}
-void fn3() {
+void fn3(void) {
int l;
__asm__(""
: "+#r"(l)); // expected-error {{invalid output constraint '+#r' in asm}}
}
-void fn4() {
+void fn4(void) {
int l;
__asm__(""
: "=r"(l)
: "m#"(l));
}
-void fn5() {
+void fn5(void) {
int l;
__asm__(""
: [g] "+r"(l)
: "[g]"(l)); // expected-error {{invalid input constraint '[g]' in asm}}
}
-void fn6() {
+void fn6(void) {
int a;
__asm__(""
: "=rm"(a), "=rm"(a)
typedef __attribute__((vector_size(16))) int test16_bar;
register int test16_baz asm("esp");
-void test16()
+void test16(void)
{
test16_foo a;
test16_bar b;
return r0 + r1;
}
-void test18()
+void test18(void)
{
// expected-error@+2 {{duplicate use of asm operand name "lab"}}
// expected-note@+1 {{asm operand name "lab" first referenced here}}
typedef void (*hookfunc)(void *arg);
hookfunc hook;
-void clear_hook() {
+void clear_hook(void) {
hook = NULL;
}
}
typedef int arr[10];
-void test3() {
+void test3(void) {
const arr b; // expected-note {{variable 'b' declared const here}}
const int b2[10]; // expected-note {{variable 'b2' declared const here}}
b[4] = 1; // expected-error {{cannot assign to variable 'b' with const-qualified type 'const arr' (aka 'const int[10]')}}
// REQUIRES: x86-registered-target
-void assembly() {
+void assembly(void) {
int added;
// CHECK: asm volatile ("addl %%ebx,%%eax" : "=a" (added) : "a" (1), "b" (2));
__asm__ __volatile__("addl %%ebx,%%eax" : "=a" (added) : "a" (1), "b" (2) );
return x << data2;
}
-int func_05 () {
+int func_05 (void) {
return data2 << data1;
}
-int func_06 () {
+int func_06 (void) {
return data1 << data2;
}
return data1 == x;
}
-int func_12 () {
+int func_12 (void) {
return data1 < data2;
}
return x ? data1 : y;
}
-int func_14 () {
+int func_14 (void) {
return data1 == 0;
}
*i = atom; // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
}
-void bad_assign_3() {
+void bad_assign_3(void) {
atom = atom; // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
}
}
_Atomic(int*) PR12527_a;
-void PR12527() { int *b = PR12527_a; }
+void PR12527(void) { int *b = PR12527_a; }
void PR16931(int* x) { // expected-note {{passing argument to parameter 'x' here}}
typedef struct { _Atomic(_Bool) flag; } flag;
(void)__atomic_compare_exchange_n(p, p, val, 0, memory_order_seq_cst, memory_order_relaxed);
}
-void nullPointerWarning() {
+void nullPointerWarning(void) {
volatile _Atomic(int) vai;
_Atomic(int) ai;
volatile int vi = 42;
struct foo bigThing;
_Atomic(struct foo) bigAtomic;
-void structAtomicStore() {
+void structAtomicStore(void) {
struct foo f = {0};
__c11_atomic_store(&bigAtomic, f, 5); // expected-error {{atomic store requires runtime support that is not available for this target}}
__atomic_store(&bigThing, &f, 5);
}
-void structAtomicLoad() {
+void structAtomicLoad(void) {
struct foo f = __c11_atomic_load(&bigAtomic, 5); // expected-error {{atomic load requires runtime support that is not available for this target}}
struct bar b;
__atomic_load(&smallThing, &b, 5);
extern _Atomic(int (*)(int(*)[10], int(*)[])) mergetest;
extern _Atomic(int (*)(int(*)[10], int(*)[10])) mergetest;
-_Atomic(int()) error1; // expected-error {{_Atomic cannot be applied to function type}}
+_Atomic(int(void)) error1; // expected-error {{_Atomic cannot be applied to function type}}
_Atomic(struct ErrorS) error2; // expected-error {{_Atomic cannot be applied to incomplete type}} expected-note {{forward declaration}}
_Atomic(int[10]) error3; // expected-error {{_Atomic cannot be applied to array type}}
_Atomic(const int) error4; // expected-error {{_Atomic cannot be applied to qualified type}}
// RUN: %clang_cc1 -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -fsyntax-only %s
int a;
-inline __attribute__((noreturn(a))) void *f1(); // expected-error {{'noreturn' attribute takes no arguments}}
-inline __attribute__((always_inline(a))) void *f2(); // expected-error {{'always_inline' attribute takes no arguments}}
-inline __attribute__((cdecl(a))) void *f3(); // expected-error {{'cdecl' attribute takes no arguments}}
-inline __attribute__((const(a))) void *f4(); // expected-error {{'const' attribute takes no arguments}}
-inline __attribute__((fastcall(a))) void *f5(); // expected-error {{'fastcall' attribute takes no arguments}}
-inline __attribute__((malloc(a))) void *f5(); // expected-error {{'malloc' attribute takes no arguments}}
-inline __attribute__((nothrow(a))) void *f7(); // expected-error {{'nothrow' attribute takes no arguments}}
-inline __attribute__((stdcall(a))) void *f8(); // expected-error {{'stdcall' attribute takes no arguments}}
-inline __attribute__((used(a))) void *f9(); // expected-error {{'used' attribute takes no arguments}}
-inline __attribute__((unused(a))) void *f10(); // expected-error {{'unused' attribute takes no arguments}}
-inline __attribute__((weak(a))) void *f11(); // expected-error {{'weak' attribute takes no arguments}}
+inline __attribute__((noreturn(a))) void *f1(void); // expected-error {{'noreturn' attribute takes no arguments}}
+inline __attribute__((always_inline(a))) void *f2(void); // expected-error {{'always_inline' attribute takes no arguments}}
+inline __attribute__((cdecl(a))) void *f3(void); // expected-error {{'cdecl' attribute takes no arguments}}
+inline __attribute__((const(a))) void *f4(void); // expected-error {{'const' attribute takes no arguments}}
+inline __attribute__((fastcall(a))) void *f5(void); // expected-error {{'fastcall' attribute takes no arguments}}
+inline __attribute__((malloc(a))) void *f5(void); // expected-error {{'malloc' attribute takes no arguments}}
+inline __attribute__((nothrow(a))) void *f7(void); // expected-error {{'nothrow' attribute takes no arguments}}
+inline __attribute__((stdcall(a))) void *f8(void); // expected-error {{'stdcall' attribute takes no arguments}}
+inline __attribute__((used(a))) void *f9(void); // expected-error {{'used' attribute takes no arguments}}
+inline __attribute__((unused(a))) void *f10(void); // expected-error {{'unused' attribute takes no arguments}}
+inline __attribute__((weak(a))) void *f11(void); // expected-error {{'weak' attribute takes no arguments}}
// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
-void f1() __attribute__((assume(3))); // expected-error {{'assume' attribute requires a string}}
-void f2() __attribute__((assume(int))); // expected-error {{expected expression}}
-void f3() __attribute__((assume(for))); // expected-error {{expected expression}}
-void f4() __attribute__((assume("QQQQ"))); // expected-warning {{unknown assumption string 'QQQQ'; attribute is potentially ignored}}
-void f5() __attribute__((assume("omp_no_openmp")));
-void f6() __attribute__((assume("omp_noopenmp"))); // expected-warning {{unknown assumption string 'omp_noopenmp' may be misspelled; attribute is potentially ignored, did you mean 'omp_no_openmp'?}}
-void f7() __attribute__((assume("omp_no_openmp_routine"))); // expected-warning {{unknown assumption string 'omp_no_openmp_routine' may be misspelled; attribute is potentially ignored, did you mean 'omp_no_openmp_routines'?}}
-void f8() __attribute__((assume("omp_no_openmp1"))); // expected-warning {{unknown assumption string 'omp_no_openmp1' may be misspelled; attribute is potentially ignored, did you mean 'omp_no_openmp'?}}
-void f9() __attribute__((assume("omp_no_openmp", "omp_no_openmp"))); // expected-error {{'assume' attribute takes one argument}}
+void f1(void) __attribute__((assume(3))); // expected-error {{'assume' attribute requires a string}}
+void f2(void) __attribute__((assume(int))); // expected-error {{expected expression}}
+void f3(void) __attribute__((assume(for))); // expected-error {{expected expression}}
+void f4(void) __attribute__((assume("QQQQ"))); // expected-warning {{unknown assumption string 'QQQQ'; attribute is potentially ignored}}
+void f5(void) __attribute__((assume("omp_no_openmp")));
+void f6(void) __attribute__((assume("omp_noopenmp"))); // expected-warning {{unknown assumption string 'omp_noopenmp' may be misspelled; attribute is potentially ignored, did you mean 'omp_no_openmp'?}}
+void f7(void) __attribute__((assume("omp_no_openmp_routine"))); // expected-warning {{unknown assumption string 'omp_no_openmp_routine' may be misspelled; attribute is potentially ignored, did you mean 'omp_no_openmp_routines'?}}
+void f8(void) __attribute__((assume("omp_no_openmp1"))); // expected-warning {{unknown assumption string 'omp_no_openmp1' may be misspelled; attribute is potentially ignored, did you mean 'omp_no_openmp'?}}
+void f9(void) __attribute__((assume("omp_no_openmp", "omp_no_openmp"))); // expected-error {{'assume' attribute takes one argument}}
int g1 __attribute__((assume(0))); // expected-warning {{'assume' attribute only applies to functions and Objective-C methods}}
int g2 __attribute__((assume("omp_no_openmp"))); // expected-warning {{'assume' attribute only applies to functions and Objective-C methods}}
void f4(int) __attribute__((availability(android,introduced=9,deprecated=11,obsoleted=16), availability(ios,introduced=2.0,deprecated=3.0))); // expected-note{{explicitly marked unavailable}}
void f5(int) __attribute__((availability(ios,introduced=3.2), availability(android,unavailable))); // expected-note{{'f5' has been explicitly marked unavailable here}}
-void test() {
+void test(void) {
f0(0);
f1(0);
f2(0); // expected-warning-re{{'f2' is deprecated: first deprecated in Android 16{{$}}}}
#endif
void f2(int); // expected-note {{'f2' has been explicitly marked unavailable here}}
-void test() {
+void test(void) {
f0(1); // expected-error {{'f0' is unavailable: not available on}}
f1(1); // expected-error {{'f1' is unavailable}}
f2(2); // expected-error {{'f2' is unavailable: not available on}}
void f7(int) __attribute__((availability(fuchsia, introduced = 16.1))); // expected-warning {{Fuchsia API Level prohibits specifying a minor or sub-minor version}}
void f8(int) __attribute__((availability(fuchsia, introduced = 19))); // nothing will happen as 'strict' is not specified.
-void test() {
+void test(void) {
f0(0);
f1(0);
f2(0); // expected-warning{{'f2' is deprecated: first deprecated in Fuchsia 16}}
void f6(int) __attribute__((availability(ios,deprecated=3.0))); // expected-note {{'f6' has been explicitly marked deprecated here}}
void f6(int) __attribute__((availability(iOS,introduced=2.0)));
-void test() {
+void test(void) {
f0(0); // expected-warning{{'f0' is deprecated: first deprecated in iOS 2.1}}
f1(0);
f2(0); // expected-warning{{'f2' is deprecated: first deprecated in iOS 3.0}}
void f4(void)
__attribute__((availability(macOS, introduced = 10, deprecated = 100000)));
-void fAvail() __attribute__((availability(macOS, unavailable)));
+void fAvail(void) __attribute__((availability(macOS, unavailable)));
-void f16() __attribute__((availability(macOS, introduced = 11.0)));
+void f16(void) __attribute__((availability(macOS, introduced = 11.0)));
#ifndef IOS14
// expected-note@-2 {{here}}
#endif
-void fObs() __attribute__((availability(macOS, introduced = 10.11, obsoleted = 10.15))); // expected-note {{'fObs' has been explicitly marked unavailable here}}
+void fObs(void) __attribute__((availability(macOS, introduced = 10.11, obsoleted = 10.15))); // expected-note {{'fObs' has been explicitly marked unavailable here}}
-void fAPItoDepr() __attribute__((availability(macOS, introduced = 10.11, deprecated = 100000)));
+void fAPItoDepr(void) __attribute__((availability(macOS, introduced = 10.11, deprecated = 100000)));
-void dontRemapFutureVers() __attribute__((availability(macOS, introduced = 20)));
+void dontRemapFutureVers(void) __attribute__((availability(macOS, introduced = 20)));
-void usage() {
+void usage(void) {
f0();
f1();
f2(); // expected-warning {{'f2' is deprecated: first deprecated in macCatalyst 13.1}}
void f15_3(void) __attribute__((availability(macOS, introduced = 10.15, deprecated = 10.15.3))); // expected-note {{here}}
void f15_2(void) __attribute__((availability(macOS, introduced = 10.15, deprecated = 10.15.2))); // expected-note {{here}}
-void usage16() {
+void usage16(void) {
f15_2(); // expected-warning {{'f15_2' is deprecated: first deprecated in macCatalyst 13.3}}
f15_3(); // expected-warning {{'f15_3' is deprecated: first deprecated in macCatalyst 13.3.1}}
f15_4(); // expected-warning {{'f15_4' is deprecated: first deprecated in macCatalyst 13.4}}
__attribute__((availability(maccatalyst,unavailable)))
__attribute__((availability(ios,introduced=2.0)));
-void test() {
+void test(void) {
f0(0);
#ifndef APPEXT
// expected-warning@-2 {{'f0' is deprecated: first deprecated in macCatalyst 9.1}}
void f103(void)
__attribute__((availability(maccatalyst,introduced=3.0)));
-void dontInheritObsoletedDeprecated() {
+void dontInheritObsoletedDeprecated(void) {
f100();
f101();
f102();
void f203(void) __attribute__((availability(ios,introduced=2.0, obsoleted=5.0))); // expected-note {{here}}
void f204(void) __attribute__((availability(ios,unavailable))); // expected-note {{here}}
-void inheritIosAvailability() {
+void inheritIosAvailability(void) {
f202();
#ifndef APPEXT
// expected-warning@-2 {{'f202' is deprecated: first deprecated in macCatalyst 13.1}}
void f5(int) __attribute__((availability(ios,introduced=3.2), availability(macosx,unavailable))); // expected-note{{'f5' has been explicitly marked unavailable here}}
void f6(int) __attribute__((availability(macOS,strict,introduced=10.6))); //expected-note{{'f6' has been explicitly marked unavailable here}}
-void test() {
+void test(void) {
f0(0);
f1(0);
f2(0); // expected-warning{{'f2' is deprecated: first deprecated in macOS 10.5}}
{
};
struct type_info;
-int test2() {
+int test2(void) {
struct type_info *t; // expected-error{{'type_info' is unavailable: introduced in macOS 10.9}}
return 0;
}
// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fsyntax-only -fdouble-square-bracket-attributes -verify %s
-[[clang::availability(macosx,introduced=10.4,deprecated=10.2)]] void f0(); // expected-warning{{feature cannot be deprecated in macOS version 10.2 before it was introduced in version 10.4; attribute ignored}}
-[[clang::availability(ios,obsoleted=2.1,deprecated=3.0)]] void f1(); // expected-warning{{feature cannot be obsoleted in iOS version 2.1 before it was deprecated in version 3.0; attribute ignored}}
-[[clang::availability(ios,introduced=2.1,deprecated=2.1)]] void f2();
+[[clang::availability(macosx,introduced=10.4,deprecated=10.2)]] void f0(void); // expected-warning{{feature cannot be deprecated in macOS version 10.2 before it was introduced in version 10.4; attribute ignored}}
+[[clang::availability(ios,obsoleted=2.1,deprecated=3.0)]] void f1(void); // expected-warning{{feature cannot be obsoleted in iOS version 2.1 before it was deprecated in version 3.0; attribute ignored}}
+[[clang::availability(ios,introduced=2.1,deprecated=2.1)]] void f2(void);
[[clang::availability(macosx,introduced=8.0,deprecated=9.0, message="use CTFontCopyFullName")]]
extern void
ATSFontGetName(const char *oName); // expected-note {{'ATSFontGetName' has been explicitly marked deprecated here}}
-void test_10095131() {
+void test_10095131(void) {
ATSFontGetName("Hello"); // expected-warning {{'ATSFontGetName' is deprecated: first deprecated in macOS 9.0 - use CTFontCopyFullName}}
}
void f6(int) __attribute__((availability(tvos,deprecated=13.0))); // expected-note {{'f6' has been explicitly marked deprecated here}}
void f6(int) __attribute__((availability(tvos,introduced=12.0)));
-void test() {
+void test(void) {
f0(0); // expected-warning{{'f0' is deprecated: first deprecated in tvOS 12.1}}
f1(0);
f2(0); // expected-warning{{'f2' is deprecated: first deprecated in tvOS 13.0}}
// Anything iOS later than 13 does not apply to tvOS.
void f9(int) __attribute__((availability(ios,introduced=12.0,deprecated=19.0)));
-void test_transcribed_availability() {
+void test_transcribed_availability(void) {
f9(0);
}
void f6_tvos(int) __attribute__((availability(tvos,deprecated=13.0))); // expected-note {{'f6_tvos' has been explicitly marked deprecated here}}
void f6_tvos(int) __attribute__((availability(tvOS,introduced=12.0)));
-void test_tvos() {
+void test_tvos(void) {
f0_tvos(0); // expected-warning{{'f0_tvos' is deprecated: first deprecated in tvOS 12.1}}
f1_tvos(0);
f2_tvos(0); // expected-warning{{'f2_tvos' is deprecated: first deprecated in tvOS 13.0}}
// iOS 9.3 corresponds to tvOS 9.2, as indicated in 'SDKSettings.json'.
void f11(int) __attribute__((availability(ios,deprecated=9.3))); // expected-note {{'f11' has been explicitly marked deprecated here}}
-void testWithVersionMap() {
+void testWithVersionMap(void) {
f11(0); // expected-warning {{'f11' is deprecated: first deprecated in tvOS 9.2}}
}
#else
// Without VersionMap, tvOS version is inferred incorrectly as 9.3.
void f11(int) __attribute__((availability(ios,deprecated=9.3))); // expected-note {{'f11' has been explicitly marked deprecated here}}
-void testWithoutVersionMap() {
+void testWithoutVersionMap(void) {
f11(0); // expected-warning {{'f11' is deprecated: first deprecated in tvOS 9.3}}
}
#endif
void f7(int) __attribute__((availability(ios,deprecated=8.3))); // expected-note {{'f7' has been explicitly marked deprecated here}}
void f8(int) __attribute__((availability(ios,introduced=2.0,obsoleted=10.0))); // expected-note {{explicitly marked unavailable}}
-void test() {
+void test(void) {
f0(0); // expected-warning{{'f0' is deprecated: first deprecated in watchOS 2.0}}
f1(0);
f2(0); // expected-warning{{'f2' is deprecated: first deprecated in watchOS 2.0}}
void f6_watchos(int) __attribute__((availability(watchos,deprecated=3.0))); // expected-note {{'f6_watchos' has been explicitly marked deprecated here}}
void f6_watchos(int) __attribute__((availability(watchOS,introduced=2.0)));
-void test_watchos() {
+void test_watchos(void) {
f0_watchos(0); // expected-warning{{'f0_watchos' is deprecated: first deprecated in watchOS 2.1}}
f1_watchos(0);
f2_watchos(0); // expected-warning{{'f2_watchos' is deprecated: first deprecated in watchOS 3.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 deprecatedAfterIntroduced(void) __attribute__((availability(ios,introduced=9.3,deprecated=10))); // expected-note {{here}}
-void test_ios_correctly_map_to_watchos() {
+void test_ios_correctly_map_to_watchos(void) {
deprecatedAfterIntroduced(); // expected-warning {{'deprecatedAfterIntroduced' is deprecated: first deprecated in watchOS 3}}
}
// iOS 10.3.1 corresponds to watchOS 3.2, as indicated in 'SDKSettings.json'.
void f9(int) __attribute__((availability(ios,deprecated=10.3.1))); // expected-note {{'f9' has been explicitly marked deprecated here}}
-void testWithVersionMap() {
+void testWithVersionMap(void) {
f9(0); // expected-warning {{'f9' is deprecated: first deprecated in watchOS 3.2}}
}
#else
// Without VersionMap, watchOS version is inferred incorrectly as 3.3.1.
void f9(int) __attribute__((availability(ios,deprecated=10.3.1))); // expected-note {{'f9' has been explicitly marked deprecated here}}
-void testWithoutVersionMap() {
+void testWithoutVersionMap(void) {
f9(0); // expected-warning {{'f9' is deprecated: first deprecated in watchOS 3.3.1}}
}
#endif
// RUN: %clang_cc1 -D WARN_PARTIAL -Wpartial-availability -triple x86_64-apple-darwin9 -fsyntax-only -fblocks -verify %s
//
-void f0() __attribute__((availability(macosx,introduced=10.4,deprecated=10.2))); // expected-warning{{feature cannot be deprecated in macOS version 10.2 before it was introduced in version 10.4; attribute ignored}}
-void f1() __attribute__((availability(ios,obsoleted=2.1,deprecated=3.0))); // expected-warning{{feature cannot be obsoleted in iOS version 2.1 before it was deprecated in version 3.0; attribute ignored}}
-void f2() __attribute__((availability(ios,introduced=2.1,deprecated=2.1)));
+void f0(void) __attribute__((availability(macosx,introduced=10.4,deprecated=10.2))); // expected-warning{{feature cannot be deprecated in macOS version 10.2 before it was introduced in version 10.4; attribute ignored}}
+void f1(void) __attribute__((availability(ios,obsoleted=2.1,deprecated=3.0))); // expected-warning{{feature cannot be obsoleted in iOS version 2.1 before it was deprecated in version 3.0; attribute ignored}}
+void f2(void) __attribute__((availability(ios,introduced=2.1,deprecated=2.1)));
-void f3() __attribute__((availability(otheros,introduced=2.2))); // expected-warning{{unknown platform 'otheros' in availability macro}}
+void f3(void) __attribute__((availability(otheros,introduced=2.2))); // expected-warning{{unknown platform 'otheros' in availability macro}}
// rdar://10095131
extern void
// expected-note@+3 {{'PartiallyAvailable' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5}}
#endif
extern void
-PartiallyAvailable() __attribute__((availability(macosx,introduced=10.8)));
+PartiallyAvailable(void) __attribute__((availability(macosx,introduced=10.8)));
#ifdef WARN_PARTIAL
// expected-note@+2 2 {{'PartialEnum' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5}}
kPartialEnumConstant,
};
-void test_10095131() {
+void test_10095131(void) {
ATSFontGetName("Hello"); // expected-warning {{'ATSFontGetName' is deprecated: first deprecated in macOS 9.0 - use CTFontCopyFullName}}
ATSFontGetPostScriptName(100); // expected-error {{'ATSFontGetPostScriptName' is unavailable: obsoleted in macOS 9.0 - use ATSFontGetFullPostScriptName}}
// attribute.
// expected-note@+2 {{'PartiallyAvailable' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5}}
#endif
-extern void PartiallyAvailable() ;
-void with_redeclaration() {
+extern void PartiallyAvailable(void) ;
+void with_redeclaration(void) {
#ifdef WARN_PARTIAL
// expected-warning@+4 {{'PartiallyAvailable' is only available on macOS 10.8 or newer}} expected-note@+4 {{__builtin_available}}
// expected-warning@+4 {{'PartialEnum' is only available on macOS 10.8 or newer}} expected-note@+4 {{__builtin_available}}
extern int x __attribute__((availability(macosx,introduced=10.5)));
extern int x;
-void f8() {
+void f8(void) {
int (^b)(int);
b = ^ (int i) __attribute__((availability(macosx,introduced=10.2))) { return 1; }; // expected-warning {{'availability' attribute only applies to named declarations}}
}
int g2 __attribute((cleanup(c1))); // expected-warning {{'cleanup' attribute only applies to local variables}}
static int g3 __attribute((cleanup(c1))); // expected-warning {{'cleanup' attribute only applies to local variables}}
-void t1()
+void t1(void)
{
int v1 __attribute((cleanup)); // expected-error {{'cleanup' attribute takes one argument}}
int v2 __attribute((cleanup(1, 2))); // expected-error {{'cleanup' attribute takes one argument}}
int a, b;
};
-void c2();
+void c2(void);
void c3(struct s a);
-void t2()
+void t2(void)
{
int v1 __attribute__((cleanup(c2))); // expected-error {{'cleanup' function 'c2' must take 1 parameter}}
int v2 __attribute__((cleanup(c3))); // expected-error {{'cleanup' function 'c3' parameter has type 'struct s' which is incompatible with type 'int *'}}
// This is a manufactured testcase, but gcc accepts it...
void c4(_Bool a);
-void t4() {
+void t4(void) {
__attribute((cleanup(c4))) void* g;
}
void c5(void*) __attribute__((deprecated)); // expected-note{{'c5' has been explicitly marked deprecated here}}
-void t5() {
+void t5(void) {
int i __attribute__((cleanup(c5))); // expected-warning {{'c5' is deprecated}}
}
// RUN: %clang_cc1 -fsyntax-only -verify %s
-int foo() __attribute__((__hot__));
-int bar() __attribute__((__cold__));
+int foo(void) __attribute__((__hot__));
+int bar(void) __attribute__((__cold__));
int var1 __attribute__((__cold__)); // expected-warning{{'__cold__' attribute only applies to functions}}
int var2 __attribute__((__hot__)); // expected-warning{{'__hot__' attribute only applies to functions}}
-int qux() __attribute__((__hot__)) __attribute__((__cold__)); // expected-error{{'__cold__' and 'hot' attributes are not compatible}} \
+int qux(void) __attribute__((__hot__)) __attribute__((__cold__)); // expected-error{{'__cold__' and 'hot' attributes are not compatible}} \
// expected-note{{conflicting attribute is here}}
-int baz() __attribute__((__cold__)) __attribute__((__hot__)); // expected-error{{'__hot__' and 'cold' attributes are not compatible}} \
+int baz(void) __attribute__((__cold__)) __attribute__((__hot__)); // expected-error{{'__hot__' and 'cold' attributes are not compatible}} \
// expected-note{{conflicting attribute is here}}
__attribute__((cold)) void test1(void); // expected-note{{conflicting attribute is here}}
// RUN: %clang_cc1 -fsyntax-only -verify %s
-void foo();
-void foo() __attribute__((unused));
-void foo() __attribute__((unused));
-void foo(){} // expected-note {{previous definition is here}}
-void foo() __attribute__((constructor)); // expected-warning {{must precede definition}}
-void foo();
+void foo(void);
+void foo(void) __attribute__((unused));
+void foo(void) __attribute__((unused));
+void foo(void){} // expected-note {{previous definition is here}}
+void foo(void) __attribute__((constructor)); // expected-warning {{must precede definition}}
+void foo(void);
int bar;
extern int bar;
// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c2x
-[[deprecated]] int f(); // expected-note 2 {{'f' has been explicitly marked deprecated here}}
-[[deprecated]] void g();// expected-note {{'g' has been explicitly marked deprecated here}}
-void g();
+[[deprecated]] int f(void); // expected-note 2 {{'f' has been explicitly marked deprecated here}}
+[[deprecated]] void g(void);// expected-note {{'g' has been explicitly marked deprecated here}}
+void g(void);
extern int var [[deprecated]]; // expected-note 2 {{'var' has been explicitly marked deprecated here}}
-int a() {
- int (*ptr)() = f; // expected-warning {{'f' is deprecated}}
+int a(void) {
+ int (*ptr)(void) = f; // expected-warning {{'f' is deprecated}}
f(); // expected-warning {{'f' is deprecated}}
// test if attributes propagate to functions
// test if attributes propagate to variables
extern int var;
-int w() {
+int w(void) {
return var; // expected-warning {{'var' is deprecated}}
}
-[[deprecated]] int old_fn();// expected-note {{'old_fn' has been explicitly marked deprecated here}}
-int old_fn();
-int (*fn_ptr)() = old_fn; // expected-warning {{'old_fn' is deprecated}}
+[[deprecated]] int old_fn(void);// expected-note {{'old_fn' has been explicitly marked deprecated here}}
+int old_fn(void);
+int (*fn_ptr)(void) = old_fn; // expected-warning {{'old_fn' is deprecated}}
-int old_fn() {
+int old_fn(void) {
return old_fn()+1; // no warning, deprecated functions can use deprecated symbols.
}
int g1;
int g2 __attribute__ ((deprecated("Please avoid g2"))); // expected-note {{'g2' has been explicitly marked deprecated here}}
-int func1()
+int func1(void)
{
- int (*pf)() = f1; // expected-warning {{'f1' is deprecated: Please avoid f1}}
+ int (*pf)(void) = f1; // expected-warning {{'f1' is deprecated: Please avoid f1}}
int i = f2();
return g1 + g2; // expected-warning {{'g2' is deprecated: Please avoid g2}}
}
// RUN: %clang_cc1 %s -std=c89 -verify -fsyntax-only
// RUN: %clang_cc1 %s -std=c99 -verify -fsyntax-only
-int f() __attribute__((deprecated)); // expected-note 2 {{'f' has been explicitly marked deprecated here}}
-void g() __attribute__((deprecated));// expected-note {{'g' has been explicitly marked deprecated here}}
-void g();
+int f(void) __attribute__((deprecated)); // expected-note 2 {{'f' has been explicitly marked deprecated here}}
+void g(void) __attribute__((deprecated));// expected-note {{'g' has been explicitly marked deprecated here}}
+void g(void);
extern int var __attribute__((deprecated)); // expected-note 2 {{'var' has been explicitly marked deprecated here}}
-int a() {
- int (*ptr)() = f; // expected-warning {{'f' is deprecated}}
+int a(void) {
+ int (*ptr)(void) = f; // expected-warning {{'f' is deprecated}}
f(); // expected-warning {{'f' is deprecated}}
// test if attributes propagate to functions
// test if attributes propagate to variables
extern int var;
-int w() {
+int w(void) {
return var; // expected-warning {{'var' is deprecated}}
}
-int old_fn() __attribute__ ((deprecated));// expected-note {{'old_fn' has been explicitly marked deprecated here}}
-int old_fn();
-int (*fn_ptr)() = old_fn; // expected-warning {{'old_fn' is deprecated}}
+int old_fn(void) __attribute__ ((deprecated));// expected-note {{'old_fn' has been explicitly marked deprecated here}}
+int old_fn(void);
+int (*fn_ptr)(void) = old_fn; // expected-warning {{'old_fn' is deprecated}}
-int old_fn() {
+int old_fn(void) {
return old_fn()+1; // no warning, deprecated functions can use deprecated symbols.
}
test20_a __attribute__((deprecated)), // expected-note {{'test20_a' has been explicitly marked deprecated here}}
test20_b
};
-void test20() {
+void test20(void) {
enum Test20 f; // expected-warning {{'Test20' is deprecated}}
f = test20_a; // expected-warning {{'test20_a' is deprecated}}
f = test20_b; // expected-warning {{'test20_b' is deprecated}}
return __builtin_memcpy(dst, src, c);
}
-void call_test_memcpy() {
+void call_test_memcpy(void) {
char bufferA[10];
char bufferB[11];
test_memcpy(bufferB, 10, bufferA);
test_memcpy(bufferB, 11, bufferA); // expected-warning {{'memcpy' will always overflow; destination buffer has size 10, but size argument is 11}}
}
-void failure_function_doesnt_exist() __attribute__((diagnose_as_builtin(__function_that_doesnt_exist))) {} // expected-error {{use of undeclared identifier '__function_that_doesnt_exist'}}
+void failure_function_doesnt_exist(void) __attribute__((diagnose_as_builtin(__function_that_doesnt_exist))) {} // expected-error {{use of undeclared identifier '__function_that_doesnt_exist'}}
-void not_a_builtin() {}
+void not_a_builtin(void) {}
-void failure_not_a_builtin() __attribute__((diagnose_as_builtin(not_a_builtin))) {} // expected-error {{'diagnose_as_builtin' attribute requires parameter 1 to be a builtin function}}
+void failure_not_a_builtin(void) __attribute__((diagnose_as_builtin(not_a_builtin))) {} // expected-error {{'diagnose_as_builtin' attribute requires parameter 1 to be a builtin function}}
void failure_too_many_parameters(void *dst, const void *src, size_t count, size_t nothing) __attribute__((diagnose_as_builtin(__builtin_memcpy, 1, 2, 3, 4))) {} // expected-error {{'diagnose_as_builtin' attribute references function '__builtin_memcpy', which takes exactly 3 arguments}}
void failure_not_an_integer(void *dst, const void *src, size_t count) __attribute__((diagnose_as_builtin(__builtin_memcpy, "abc", 2, 3))) {} // expected-error{{'diagnose_as_builtin' attribute requires parameter 2 to be an integer constant}}
-void failure_not_a_builtin2() __attribute__((diagnose_as_builtin("abc"))) {} // expected-error{{'diagnose_as_builtin' attribute requires parameter 1 to be a builtin function}}
+void failure_not_a_builtin2(void) __attribute__((diagnose_as_builtin("abc"))) {} // expected-error{{'diagnose_as_builtin' attribute requires parameter 1 to be a builtin function}}
void failure_parameter_index_bounds(void *dst, const void *src) __attribute__((diagnose_as_builtin(__builtin_memcpy, 1, 2, 3))) {} // expected-error{{'diagnose_as_builtin' attribute references parameter 3, but the function 'failure_parameter_index_bounds' has only 2 parameters}}
void to_redeclare(void *dst, const void *src, size_t count);
-void use_to_redeclare() {
+void use_to_redeclare(void) {
char src[10];
char dst[9];
// We shouldn't get an error yet.
void to_redeclare(void *dst, const void *src, size_t count) __attribute((diagnose_as_builtin(__builtin_memcpy, 1, 2, 3)));
-void error_to_redeclare() {
+void error_to_redeclare(void) {
char src[10];
char dst[9];
// Now we get an error.
// Make sure this works even with extra qualifiers and the pass_object_size attribute.
void *memcpy2(void *const dst __attribute__((pass_object_size(0))), const void *src, size_t copy_amount) __attribute((diagnose_as_builtin(__builtin_memcpy, 1, 2, 3)));
-void call_memcpy2() {
+void call_memcpy2(void) {
char buf1[10];
char buf2[11];
memcpy2(buf1, buf2, 11); // expected-warning {{'memcpy' will always overflow; destination buffer has size 10, but size argument is 11}}
// Variadics should work.
int mysscanf(const char *str, const char *format, ...) __attribute__((diagnose_as_builtin(sscanf, 1, 2)));
-void warn_mysccanf() {
+void warn_mysccanf(void) {
char buf[10];
mysscanf("", "%10s", buf); // expected-warning{{'sscanf' may overflow; destination buffer in argument 3 has size 10, but the corresponding specifier may require size 11}}
}
}
};
-void call_static_test_memcpy() {
+void call_static_test_memcpy(void) {
char bufferA[10];
char bufferB[11];
S::test_memcpy(bufferB, 10, bufferA);
void foo8 (void) PLACE_IN_TCB("bar") PLACE_IN_TCB("bar2");
void foo9 (void);
-void foo1() {
+void foo1(void) {
foo2(); // OK - function in same TCB
foo3(); // expected-warning {{calling 'foo3' is a violation of trusted computing base 'bar'}}
foo4(); // expected-warning {{calling 'foo4' is a violation of trusted computing base 'bar'}}
}
// Normal use without any attributes works
-void foo3() {
+void foo3(void) {
foo9(); // no-warning
}
-void foo5() {
+void foo5(void) {
// all calls should be okay, function in TCB leaf
foo2(); // no-warning
foo3(); // no-warning
foo4(); // no-warning
}
-void foo6() {
+void foo6(void) {
foo1(); // expected-warning {{calling 'foo1' is a violation of trusted computing base 'bar2'}}
foo4(); // expected-warning {{calling 'foo4' is a violation of trusted computing base 'bar'}}
foo8(); // no-warning
}
// Ensure that attribute merging works as expected across redeclarations.
-void foo10() PLACE_IN_TCB("bar");
-void foo10() PLACE_IN_TCB("bar2");
-void foo10() PLACE_IN_TCB("bar3");
-void foo10() {
+void foo10(void) PLACE_IN_TCB("bar");
+void foo10(void) PLACE_IN_TCB("bar2");
+void foo10(void) PLACE_IN_TCB("bar3");
+void foo10(void) {
foo1(); // #2
// expected-warning@#2 {{calling 'foo1' is a violation of trusted computing base 'bar2'}}
// expected-warning@#2 {{calling 'foo1' is a violation of trusted computing base 'bar3'}}
// RUN: %clang_cc1 -fsyntax-only -fblocks -verify -fdouble-square-bracket-attributes %s
-void threeClauses() __attribute__((external_source_symbol(language="Swift", defined_in="module", generated_declaration)));
+void threeClauses(void) __attribute__((external_source_symbol(language="Swift", defined_in="module", generated_declaration)));
-void twoClauses() __attribute__((external_source_symbol(language="Swift", defined_in="module")));
+void twoClauses(void) __attribute__((external_source_symbol(language="Swift", defined_in="module")));
-void fourClauses() __attribute__((external_source_symbol(language="Swift", defined_in="module", generated_declaration, generated_declaration))); // expected-error {{duplicate 'generated_declaration' clause in an 'external_source_symbol' attribute}}
+void fourClauses(void) __attribute__((external_source_symbol(language="Swift", defined_in="module", generated_declaration, generated_declaration))); // expected-error {{duplicate 'generated_declaration' clause in an 'external_source_symbol' attribute}}
-void oneClause() __attribute__((external_source_symbol(generated_declaration)));
+void oneClause(void) __attribute__((external_source_symbol(generated_declaration)));
-void noArguments()
+void noArguments(void)
__attribute__((external_source_symbol)); // expected-error {{'external_source_symbol' attribute takes at least 1 argument}}
-void namedDeclsOnly() {
+void namedDeclsOnly(void) {
int (^block)(void) = ^ (void)
__attribute__((external_source_symbol(language="Swift"))) { // expected-warning {{'external_source_symbol' attribute only applies to named declarations}}
return 1;
};
}
-[[clang::external_source_symbol(language="Swift", defined_in="module", generated_declaration)]] void threeClauses2();
+[[clang::external_source_symbol(language="Swift", defined_in="module", generated_declaration)]] void threeClauses2(void);
-[[clang::external_source_symbol(language="Swift", defined_in="module")]] void twoClauses2();
+[[clang::external_source_symbol(language="Swift", defined_in="module")]] void twoClauses2(void);
[[clang::external_source_symbol(language="Swift", defined_in="module", generated_declaration, generated_declaration)]] // expected-error {{duplicate 'generated_declaration' clause in an 'external_source_symbol' attribute}}
-void fourClauses2();
+void fourClauses2(void);
-[[clang::external_source_symbol(generated_declaration)]] void oneClause2();
+[[clang::external_source_symbol(generated_declaration)]] void oneClause2(void);
[[clang::external_source_symbol]] // expected-error {{'external_source_symbol' attribute takes at least 1 argument}}
-void noArguments2();
+void noArguments2(void);
// RUN: %clang_cc1 -triple %ms_abi_triple -fms-extensions -verify -std=c++11 -fsyntax-only -x c++ %s
// Function definition.
-__declspec(guard(nocf)) void testGuardNoCF() { // no warning
+__declspec(guard(nocf)) void testGuardNoCF(void) { // no warning
}
// Can not be used on variable, parameter, or function pointer declarations.
__declspec(guard(nocf)) typedef void (*FuncPtrWithGuardNoCF)(void); // expected-warning {{'guard' attribute only applies to functions}}
// 'guard' Attribute requries an argument.
-__declspec(guard) void testGuardNoCFParams() { // expected-error {{'guard' attribute takes one argument}}
+__declspec(guard) void testGuardNoCFParams(void) { // expected-error {{'guard' attribute takes one argument}}
}
// 'guard' Attribute requries an identifier as argument.
-__declspec(guard(1)) void testGuardNoCFParamType() { // expected-error {{'guard' attribute requires an identifier}}
+__declspec(guard(1)) void testGuardNoCFParamType(void) { // expected-error {{'guard' attribute requires an identifier}}
}
// 'guard' Attribute only takes a single argument.
-__declspec(guard(nocf, nocf)) void testGuardNoCFTooManyParams() { // expected-error {{use of undeclared identifier 'nocf'}}
+__declspec(guard(nocf, nocf)) void testGuardNoCFTooManyParams(void) { // expected-error {{use of undeclared identifier 'nocf'}}
}
// 'guard' Attribute argument must be a supported identifier.
-__declspec(guard(cf)) void testGuardNoCFInvalidParam() { // expected-warning {{'guard' attribute argument not supported: 'cf'}}
+__declspec(guard(cf)) void testGuardNoCFInvalidParam(void) { // expected-warning {{'guard' attribute argument not supported: 'cf'}}
}
// RUN: %clang_cc1 -verify -fsyntax-only %s
-void f1() __attribute__((leaf));
+void f1(void) __attribute__((leaf));
-void f2() __attribute__((leaf("abc"))); // expected-error {{'leaf' attribute takes no argument}}
+void f2(void) __attribute__((leaf("abc"))); // expected-error {{'leaf' attribute takes no argument}}
int var __attribute__ ((leaf())); // expected-warning {{'leaf' attribute only applies to functions}}
// FIXME: Might diagnose a warning if leaf attribute is used in function definition
// The leaf attribute has no effect on functions defined within the current compilation unit
-__attribute__((leaf)) void f3() {
+__attribute__((leaf)) void f3(void) {
}
// RUN: %clang_cc1 %s -fsyntax-only -fdouble-square-bracket-attributes -verify
-void g() {
+void g(void) {
if (1)
[[clang::likely]] {}
}
-void m() {
+void m(void) {
[[clang::likely]] int x = 42; // expected-error {{'likely' attribute cannot be applied to a declaration}}
if (x)
// RUN: %clang_cc1 -triple mips-linux-gnu -fsyntax-only -verify %s
// RUN: %clang_cc1 -triple mips64-linux-gnu -fsyntax-only -verify %s
-__attribute__((long_call(0))) void foo1(); // expected-error {{'long_call' attribute takes no arguments}}
-__attribute__((short_call(0))) void foo9(); // expected-error {{'short_call' attribute takes no arguments}}
-__attribute__((far(0))) void foo2(); // expected-error {{'far' attribute takes no arguments}}
-__attribute__((near(0))) void foo3(); // expected-error {{'near' attribute takes no arguments}}
+__attribute__((long_call(0))) void foo1(void); // expected-error {{'long_call' attribute takes no arguments}}
+__attribute__((short_call(0))) void foo9(void); // expected-error {{'short_call' attribute takes no arguments}}
+__attribute__((far(0))) void foo2(void); // expected-error {{'far' attribute takes no arguments}}
+__attribute__((near(0))) void foo3(void); // expected-error {{'near' attribute takes no arguments}}
__attribute((long_call)) int a; // expected-warning {{attribute only applies to functions}}
__attribute((short_call)) int d; // expected-warning {{attribute only applies to functions}}
__attribute((far)) int a; // expected-warning {{attribute only applies to functions}}
__attribute((near)) int a; // expected-warning {{attribute only applies to functions}}
-__attribute((long_call)) void foo4();
-__attribute((short_call)) void foo10();
-__attribute((far)) void foo5();
-__attribute((near)) void foo6();
+__attribute((long_call)) void foo4(void);
+__attribute((short_call)) void foo10(void);
+__attribute((far)) void foo5(void);
+__attribute((near)) void foo6(void);
-__attribute((long_call, far)) void foo7();
-__attribute((short_call, near)) void foo11();
+__attribute((long_call, far)) void foo7(void);
+__attribute((short_call, near)) void foo11(void);
-__attribute((far, near)) void foo8(); // expected-error {{'near' and 'far' attributes are not compatible}} \
+__attribute((far, near)) void foo8(void); // expected-error {{'near' and 'far' attributes are not compatible}} \
// expected-note {{conflicting attribute is here}}
-__attribute((short_call, long_call)) void foo12(); // expected-error {{'long_call' and 'short_call' attributes are not compatible}} \
+__attribute((short_call, long_call)) void foo12(void); // expected-error {{'long_call' and 'short_call' attributes are not compatible}} \
// expected-note {{conflicting attribute is here}}
typedef int * iptr;
iptr returns_iptr (void) __attribute((malloc)); // no-warning
-__attribute((malloc)) void *(*f)(); // expected-warning{{attribute only applies to functions}}
-__attribute((malloc)) int (*g)(); // expected-warning{{attribute only applies to functions}}
+__attribute((malloc)) void *(*f)(void); // expected-warning{{attribute only applies to functions}}
+__attribute((malloc)) int (*g)(void); // expected-warning{{attribute only applies to functions}}
__attribute((malloc))
void * xalloc(unsigned n) { return malloc(n); } // no-warning
// RUN: %clang_cc1 -triple mips-linux-gnu -fsyntax-only -verify %s
-__attribute__((nomicromips(0))) void foo1(); // expected-error {{'nomicromips' attribute takes no arguments}}
-__attribute__((micromips(1))) void foo2(); // expected-error {{'micromips' attribute takes no arguments}}
+__attribute__((nomicromips(0))) void foo1(void); // expected-error {{'nomicromips' attribute takes no arguments}}
+__attribute__((micromips(1))) void foo2(void); // expected-error {{'micromips' attribute takes no arguments}}
__attribute((nomicromips)) int a; // expected-error {{attribute only applies to functions}}
__attribute((micromips)) int b; // expected-error {{attribute only applies to functions}}
-__attribute__((micromips,mips16)) void foo5(); // expected-error {{'mips16' and 'micromips' attributes are not compatible}} \
+__attribute__((micromips,mips16)) void foo5(void); // expected-error {{'mips16' and 'micromips' attributes are not compatible}} \
// expected-note {{conflicting attribute is here}}
-__attribute__((mips16,micromips)) void foo6(); // expected-error {{'micromips' and 'mips16' attributes are not compatible}} \
+__attribute__((mips16,micromips)) void foo6(void); // expected-error {{'micromips' and 'mips16' attributes are not compatible}} \
// expected-note {{conflicting attribute is here}}
-__attribute((micromips)) void foo7();
-__attribute((nomicromips)) void foo8();
+__attribute((micromips)) void foo7(void);
+__attribute((nomicromips)) void foo8(void);
__attribute__((mips16)) void foo9(void) __attribute__((micromips)); // expected-error {{'micromips' and 'mips16' attributes are not compatible}} \
// expected-note {{conflicting attribute is here}}
__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)) void foo_void(void); // expected-warning{{'mig_server_routine' attribute only applies to routines that return a kern_return_t}}
+__attribute__((mig_server_routine)) int foo_int(void); // 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_extern(void); // no-warning
+__attribute__((mig_server_routine)) kern_return_t bar_forward(void); // no-warning
-__attribute__((mig_server_routine)) kern_return_t bar_definition() { // no-warning
+__attribute__((mig_server_routine)) kern_return_t bar_definition(void) { // no-warning
return KERN_SUCCESS;
}
-kern_return_t bar_forward() { // no-warning
+kern_return_t bar_forward(void) { // 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}}
+__attribute__((mig_server_routine(123))) kern_return_t bar_with_argument(void); // expected-error{{'mig_server_routine' attribute takes no arguments}}
@implementation I
- (kern_return_t)foo {
- kern_return_t (^block)() = ^ __attribute__((mig_server_routine)) { // no-warning
+ kern_return_t (^block)(void) = ^ __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)) {};
+ void (^invalid_block)(void) = ^ __attribute__((mig_server_routine)) {};
return block();
}
// RUN: %clang_cc1 -fsyntax-only -verify %s
-int foo() __attribute__((__minsize__));
+int foo(void) __attribute__((__minsize__));
int var1 __attribute__((__minsize__)); // expected-error{{'__minsize__' attribute only applies to functions and Objective-C methods}}
typedef enum { E4 } EnumType;
-int main() {
+int main(void) {
// Vector mode are not allowed with enums.
typedef enum { E1 } __attribute__((mode(V4QI))) RejectedType1; // expected-error{{mode 'V4QI' is not supported for enumeration types}}
// expected-warning@-1{{specifying vector types with the 'mode' attribute is deprecated}}
int **__attribute((mode(QI)))* i32; // expected-error{{mode attribute}}
-__attribute__((mode(QI))) int invalid_func() { return 1; } // expected-error{{'mode' attribute only applies to variables, enums, typedefs, and non-static data members}}
+__attribute__((mode(QI))) int invalid_func(void) { return 1; } // expected-error{{'mode' attribute only applies to variables, enums, typedefs, and non-static data members}}
enum invalid_enum { A1 __attribute__((mode(QI))) }; // expected-error{{'mode' attribute only applies to}}
typedef _Complex double c32 __attribute((mode(SC)));
__asm__ volatile("mov r0, #0");
}
-void t1() __attribute__((naked));
+void t1(void) __attribute__((naked));
-void t2() __attribute__((naked(2))); // expected-error {{'naked' attribute takes no arguments}}
+void t2(void) __attribute__((naked(2))); // expected-error {{'naked' attribute takes no arguments}}
-__attribute__((naked)) int t3() { // expected-note{{attribute is here}}
+__attribute__((naked)) int t3(void) { // expected-note{{attribute is here}}
return 42; // expected-error{{non-ASM statement in naked function is not supported}}
}
-__attribute__((naked)) int t4() {
+__attribute__((naked)) int t4(void) {
asm("movl $42, %eax");
asm("retl");
}
asm("retl");
}
-__attribute__((naked)) void t6() {
+__attribute__((naked)) void t6(void) {
;
}
-__attribute__((naked)) void t7() {
+__attribute__((naked)) void t7(void) {
asm("movl $42, %eax");
;
}
);
}
-__attribute__((naked)) void t10() { // expected-note{{attribute is here}}
+__attribute__((naked)) void t10(void) { // expected-note{{attribute is here}}
int a; // expected-error{{non-ASM statement in naked function is not supported}}
}
-__attribute__((naked)) void t11() { // expected-note{{attribute is here}}
+__attribute__((naked)) void t11(void) { // expected-note{{attribute is here}}
register int a asm("eax") = x; // expected-error{{non-ASM statement in naked function is not supported}}
}
-__attribute__((naked)) void t12() { // expected-note{{attribute is here}}
+__attribute__((naked)) void t12(void) { // expected-note{{attribute is here}}
register int a asm("eax"), b asm("ebx") = x; // expected-error{{non-ASM statement in naked function is not supported}}
}
-__attribute__((naked)) void t13() {
+__attribute__((naked)) void t13(void) {
register int a asm("eax");
register int b asm("ebx"), c asm("ecx");
}
typedef void (*FuncPointer)(void);
// Dont allow function declaration and definition mismatch.
-void __attribute__((nocf_check)) testNoCfCheck(); // expected-note {{previous declaration is here}}
-void testNoCfCheck(){}; // expected-error {{conflicting types for 'testNoCfCheck'}}
+void __attribute__((nocf_check)) testNoCfCheck(void); // expected-note {{previous declaration is here}}
+void testNoCfCheck(void){}; // expected-error {{conflicting types for 'testNoCfCheck'}}
// No variable or parameter declaration
__attribute__((nocf_check)) int i; // expected-warning {{'nocf_check' attribute only applies to function}}
}
// 'nocf_check' Attribute has no parameters.
-int testNoCfCheckParams() __attribute__((nocf_check(1))); // expected-error {{'nocf_check' attribute takes no arguments}}
+int testNoCfCheckParams(void) __attribute__((nocf_check(1))); // expected-error {{'nocf_check' attribute takes no arguments}}
int b __attribute__((nodebug));
}
-void t1() __attribute__((nodebug));
+void t1(void) __attribute__((nodebug));
-void t2() __attribute__((nodebug(2))); // expected-error {{'nodebug' attribute takes no arguments}}
+void t2(void) __attribute__((nodebug(2))); // expected-error {{'nodebug' attribute takes no arguments}}
int a __attribute__((noduplicate)); // expected-warning {{'noduplicate' attribute only applies to functions}}
-void t1() __attribute__((noduplicate));
+void t1(void) __attribute__((noduplicate));
-void t2() __attribute__((noduplicate(2))); // expected-error {{'noduplicate' attribute takes no arguments}}
+void t2(void) __attribute__((noduplicate(2))); // expected-error {{'noduplicate' attribute takes no arguments}}
int a __attribute__((noinline)); // expected-warning {{'noinline' attribute only applies to functions}}
-void t1() __attribute__((noinline));
+void t1(void) __attribute__((noinline));
-void t2() __attribute__((noinline(2))); // expected-error {{'noinline' attribute takes no arguments}}
+void t2(void) __attribute__((noinline(2))); // expected-error {{'noinline' attribute takes no arguments}}
// RUN: %clang_cc1 -fsyntax-only -verify %s
-int callee0() __attribute__((not_tail_called,always_inline)); // expected-error{{'always_inline' and 'not_tail_called' attributes are not compatible}} \
+int callee0(void) __attribute__((not_tail_called,always_inline)); // expected-error{{'always_inline' and 'not_tail_called' attributes are not compatible}} \
// expected-note{{conflicting attribute is here}}
-int callee1() __attribute__((always_inline,not_tail_called)); // expected-error{{'not_tail_called' and 'always_inline' attributes are not compatible}} \
+int callee1(void) __attribute__((always_inline,not_tail_called)); // expected-error{{'not_tail_called' and 'always_inline' attributes are not compatible}} \
// expected-note{{conflicting attribute is here}}
int foo(int a) {
// CHECK: short arr[3] __attribute__((aligned));
short arr[3] __attribute__((aligned));
+// FIXME: -ast-print is printing this function signature with a K&R C style.
// CHECK: void foo() __attribute__((const));
-void foo() __attribute__((const));
+void foo(void) __attribute__((const));
// CHECK: void bar() __attribute__((__const));
-void bar() __attribute__((__const));
+void bar(void) __attribute__((__const));
// CHECK: int * __ptr32 p32;
int * __ptr32 p32;
struct __attribute__((retain)) s { // expected-warning {{'retain' attribute only applies to variables with non-local storage, functions, and Objective-C methods}}
};
-void foo() {
+void foo(void) {
static int a __attribute__((retain));
int b __attribute__((retain)); // expected-warning {{'retain' attribute only applies to variables with non-local storage, functions, and Objective-C methods}}
(void)a;
(void)b;
}
-__attribute__((retain,used)) static void f0() {}
-__attribute__((retain)) static void f1() {} // expected-warning {{unused function 'f1'}}
-__attribute__((retain)) void f2() {}
+__attribute__((retain,used)) static void f0(void) {}
+__attribute__((retain)) static void f1(void) {} // expected-warning {{unused function 'f1'}}
+__attribute__((retain)) void f2(void) {}
/// Test attribute merging.
int tentative;
__attribute__((returns_twice)) void t0(void) {
}
-void t1() __attribute__((returns_twice));
+void t1(void) __attribute__((returns_twice));
-void t2() __attribute__((returns_twice(2))); // expected-error {{'returns_twice' attribute takes no arguments}}
+void t2(void) __attribute__((returns_twice(2))); // expected-error {{'returns_twice' attribute takes no arguments}}
typedef void (*t3)(void) __attribute__((returns_twice)); // expected-warning {{'returns_twice' attribute only applies to functions}}
"sadf"))); // expected-error {{mach-o section specifier requires a segment and section separated by a comma}}
// PR6007
-void test() {
+void test(void) {
__attribute__((section("NEAR,x"))) int n1; // expected-error {{'section' attribute only applies to functions, global variables, Objective-C methods, and Objective-C properties}}
__attribute__((section("NEAR,x"))) static int n2; // ok.
}
// Should we really warn on this?
extern __declspec(selectany) int x2 = 1; // expected-warning {{'extern' variable has an initializer}}
-__declspec(selectany) void foo() { } // expected-error{{'selectany' can only be applied to data items with external linkage}}
+__declspec(selectany) void foo(void) { } // expected-error{{'selectany' can only be applied to data items with external linkage}}
#define FOOMACRO(...) foo1(__VA_ARGS__)
-void test1() {
+void test1(void) {
foo1(1, NULL); // OK
foo1(1, 0) ; // expected-warning {{missing sentinel in function call}}
foo5(1, NULL, 2); // OK
void (*e) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (1,1)));
-void test2() {
+void test2(void) {
void (*b) (int arg, const char * format, ...) __attribute__ ((__sentinel__)); // expected-note {{function has been explicitly marked sentinel here}}
void (*z) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (2))); // expected-note {{function has been explicitly marked sentinel here}}
dupe_normal2(void);
int mv_after_use(void);
-int useage() {
+int useage(void) {
return mv_after_use();
}
// expected-error@+1 {{function declaration cannot become a multiversioned function after first usage}}
#ifdef __x86_64__
-int __attribute__((target("avx,sse4.2,arch=ivybridge"))) foo() { return 4; }
+int __attribute__((target("avx,sse4.2,arch=ivybridge"))) foo(void) { return 4; }
//expected-error@+1 {{'target' attribute takes one argument}}
-int __attribute__((target())) bar() { return 4; }
+int __attribute__((target())) bar(void) { return 4; }
// no warning, tune is supported for x86
-int __attribute__((target("tune=sandybridge"))) baz() { return 4; }
+int __attribute__((target("tune=sandybridge"))) baz(void) { return 4; }
//expected-warning@+1 {{unsupported 'fpmath=' in the 'target' attribute string; 'target' attribute ignored}}
-int __attribute__((target("fpmath=387"))) walrus() { return 4; }
+int __attribute__((target("fpmath=387"))) walrus(void) { return 4; }
//expected-warning@+1 {{unknown architecture 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
-int __attribute__((target("avx,sse4.2,arch=hiss"))) meow() { return 4; }
+int __attribute__((target("avx,sse4.2,arch=hiss"))) meow(void) { return 4; }
//expected-warning@+1 {{unsupported 'woof' in the 'target' attribute string; 'target' attribute ignored}}
-int __attribute__((target("woof"))) bark() { return 4; }
+int __attribute__((target("woof"))) bark(void) { return 4; }
// no warning, same as saying 'nothing'.
-int __attribute__((target("arch="))) turtle() { return 4; }
+int __attribute__((target("arch="))) turtle(void) { return 4; }
//expected-warning@+1 {{unknown architecture 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
-int __attribute__((target("arch=hiss,arch=woof"))) pine_tree() { return 4; }
+int __attribute__((target("arch=hiss,arch=woof"))) pine_tree(void) { return 4; }
//expected-warning@+1 {{duplicate 'arch=' in the 'target' attribute string; 'target' attribute ignored}}
-int __attribute__((target("arch=ivybridge,arch=haswell"))) oak_tree() { return 4; }
+int __attribute__((target("arch=ivybridge,arch=haswell"))) oak_tree(void) { return 4; }
//expected-warning@+1 {{unsupported 'branch-protection' in the 'target' attribute string; 'target' attribute ignored}}
-int __attribute__((target("branch-protection=none"))) birch_tree() { return 5; }
+int __attribute__((target("branch-protection=none"))) birch_tree(void) { return 5; }
//expected-warning@+1 {{unknown tune CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
-int __attribute__((target("tune=hiss,tune=woof"))) apple_tree() { return 4; }
+int __attribute__((target("tune=hiss,tune=woof"))) apple_tree(void) { return 4; }
#else
// tune is not supported by other targets.
//expected-warning@+1 {{unsupported 'tune=' in the 'target' attribute string; 'target' attribute ignored}}
-int __attribute__((target("tune=hiss"))) baz() { return 4; }
+int __attribute__((target("tune=hiss"))) baz(void) { return 4; }
#endif
#error "Should support tls_model attribute"
#endif
-int f() __attribute((tls_model("global-dynamic"))); // expected-error {{'tls_model' attribute only applies to thread-local variables}}
+int f(void) __attribute((tls_model("global-dynamic"))); // expected-error {{'tls_model' attribute only applies to thread-local variables}}
int x __attribute((tls_model("global-dynamic"))); // expected-error {{'tls_model' attribute only applies to thread-local variables}}
static __thread int y __attribute((tls_model("global-dynamic"))); // no-warning
// RUN: %clang_cc1 -fsyntax-only -verify %s
// rdar: //6734520
-void tooManyArgs() __attribute__((unavailable("a", "b"))); // expected-error {{'unavailable' attribute takes no more than 1 argument}}
+void tooManyArgs(void) __attribute__((unavailable("a", "b"))); // expected-error {{'unavailable' attribute takes no more than 1 argument}}
int foo(int) __attribute__((__unavailable__("USE IFOO INSTEAD"))); // expected-note {{'foo' has been explicitly marked unavailable here}}
double dfoo(double) __attribute__((__unavailable__("NO LONGER"))); // expected-note 2 {{'dfoo' has been explicitly marked unavailable here}}
-void bar() __attribute__((__unavailable__)); // expected-note {{explicitly marked unavailable}}
+void bar(void) __attribute__((__unavailable__)); // expected-note {{explicitly marked unavailable}}
int quux(void) __attribute__((__unavailable__(12))); // expected-error {{'__unavailable__' attribute requires a string}}
#define ACCEPTABLE "Use something else"
int quux2(void) __attribute__((__unavailable__(ACCEPTABLE)));
-void test_foo() {
+void test_foo(void) {
int ir = foo(1); // expected-error {{'foo' is unavailable: USE IFOO INSTEAD}}
double dr = dfoo(1.0); // expected-error {{'dfoo' is unavailable: NO LONGER}}
- void (*fp)() = &bar; // expected-error {{'bar' is unavailable}}
+ void (*fp)(void) = &bar; // expected-error {{'bar' is unavailable}}
double (*fp4)(double) = dfoo; // expected-error {{'dfoo' is unavailable: NO LONGER}}
}
// No complains inside an unavailable function.
int ir = foo(1);
double dr = dfoo(1.0);
- void (*fp)() = &bar;
+ void (*fp)(void) = &bar;
double (*fp4)(double) = dfoo;
}
t = 3
}__attribute__((unavailable()));
-enum fee f() { // expected-error {{'fee' is unavailable}}
+enum fee f(void) { // expected-error {{'fee' is unavailable}}
int i = a; // expected-warning {{'a' is deprecated}}
i = b; // expected-warning {{'b' is deprecated}}
// RUN: %clang_cc1 %s -verify -fsyntax-only
-void good() {
+void good(void) {
int dont_initialize_me __attribute((uninitialized));
}
-void bad() {
+void bad(void) {
int im_bad __attribute((uninitialized("zero"))); // expected-error {{'uninitialized' attribute takes no arguments}}
static int im_baaad __attribute((uninitialized)); // expected-warning {{'uninitialized' attribute only applies to local variables}}
}
int you_know __attribute((uninitialized)); // expected-warning {{'uninitialized' attribute only applies to local variables}}
static int and_the_whole_world_has_to __attribute((uninitialized)); // expected-warning {{'uninitialized' attribute only applies to local variables}}
-void answer_right_now() __attribute((uninitialized)) {} // expected-warning {{'uninitialized' attribute only applies to local variables}}
+void answer_right_now(void) __attribute((uninitialized)) {} // expected-warning {{'uninitialized' attribute only applies to local variables}}
void just_to_tell_you_once_again(__attribute((uninitialized)) int whos_bad) {} // expected-warning {{'uninitialized' attribute only applies to local variables}}
struct TheWordIsOut {
// RUN: %clang_cc1 -fsyntax-only -verify -Wattributes %s
int x __attribute__((foobar)); // expected-warning {{unknown attribute 'foobar' ignored}}
-void z() __attribute__((bogusattr)); // expected-warning {{unknown attribute 'bogusattr' ignored}}
+void z(void) __attribute__((bogusattr)); // expected-warning {{unknown attribute 'bogusattr' ignored}}
static void __attribute__((used)) f0(void) {
}
-void f1() {
+void f1(void) {
static int a __attribute__((used));
int b __attribute__((used)); // expected-warning {{'used' attribute only applies to variables with non-local storage, functions, and Objective-C methods}}
}
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
-void test0() __attribute__((visibility("default")));
-void test1() __attribute__((visibility("hidden")));
-void test2() __attribute__((visibility("internal")));
+void test0(void) __attribute__((visibility("default")));
+void test1(void) __attribute__((visibility("hidden")));
+void test2(void) __attribute__((visibility("internal")));
// rdar://problem/10753392
-void test3() __attribute__((visibility("protected"))); // expected-warning {{target does not support 'protected' visibility; using 'default'}}
+void test3(void) __attribute__((visibility("protected"))); // expected-warning {{target does not support 'protected' visibility; using 'default'}}
struct __attribute__((visibility("hidden"))) test4; // expected-note {{previous attribute is here}}
struct test4;
struct __attribute__((visibility("hidden"))) test5; // expected-note {{previous attribute is here}}
struct __attribute__((visibility("default"))) test5; // expected-error {{visibility does not match previous declaration}}
-void test6() __attribute__((visibility("default"), // expected-error {{visibility does not match previous declaration}}
+void test6(void) __attribute__((visibility("default"), // expected-error {{visibility does not match previous declaration}}
visibility("hidden"))); // expected-note {{previous attribute is here}}
extern int test7 __attribute__((visibility("default"))); // expected-note {{previous attribute is here}}
// RUN: %clang_cc1 -triple wasm32-unknown-unknown -fsyntax-only -verify %s
-void name_a() __attribute__((import_name)); //expected-error {{'import_name' attribute takes one argument}}
+void name_a(void) __attribute__((import_name)); //expected-error {{'import_name' attribute takes one argument}}
int name_b __attribute__((import_name("foo"))); //expected-error {{'import_name' attribute only applies to functions}}
-void name_c() __attribute__((import_name("foo", "bar"))); //expected-error {{'import_name' attribute takes one argument}}
+void name_c(void) __attribute__((import_name("foo", "bar"))); //expected-error {{'import_name' attribute takes one argument}}
-void name_d() __attribute__((import_name("foo", "bar", "qux"))); //expected-error {{'import_name' attribute takes one argument}}
+void name_d(void) __attribute__((import_name("foo", "bar", "qux"))); //expected-error {{'import_name' attribute takes one argument}}
-void name_z() __attribute__((import_name("foo"))); //expected-note {{previous attribute is here}}
+void name_z(void) __attribute__((import_name("foo"))); //expected-note {{previous attribute is here}}
-void name_z() __attribute__((import_name("bar"))); //expected-warning {{import name (bar) does not match the import name (foo) of the previous declaration}}
+void name_z(void) __attribute__((import_name("bar"))); //expected-warning {{import name (bar) does not match the import name (foo) of the previous declaration}}
-void module_a() __attribute__((import_module)); //expected-error {{'import_module' attribute takes one argument}}
+void module_a(void) __attribute__((import_module)); //expected-error {{'import_module' attribute takes one argument}}
int module_b __attribute__((import_module("foo"))); //expected-error {{'import_module' attribute only applies to functions}}
-void module_c() __attribute__((import_module("foo", "bar"))); //expected-error {{'import_module' attribute takes one argument}}
+void module_c(void) __attribute__((import_module("foo", "bar"))); //expected-error {{'import_module' attribute takes one argument}}
-void module_d() __attribute__((import_module("foo", "bar", "qux"))); //expected-error {{'import_module' attribute takes one argument}}
+void module_d(void) __attribute__((import_module("foo", "bar", "qux"))); //expected-error {{'import_module' attribute takes one argument}}
-void module_z() __attribute__((import_module("foo"))); //expected-note {{previous attribute is here}}
+void module_z(void) __attribute__((import_module("foo"))); //expected-note {{previous attribute is here}}
-void module_z() __attribute__((import_module("bar"))); //expected-warning {{import module (bar) does not match the import module (foo) of the previous declaration}}
+void module_z(void) __attribute__((import_module("bar"))); //expected-warning {{import module (bar) does not match the import module (foo) of the previous declaration}}
-void both() __attribute__((import_name("foo"), import_module("bar")));
+void both(void) __attribute__((import_name("foo"), import_module("bar")));
// RUN: %clang_cc1 -verify -fsyntax-only %s
-extern int f0() __attribute__((weak));
+extern int f0(void) __attribute__((weak));
extern int g0 __attribute__((weak));
extern int g1 __attribute__((weak_import));
-int f2() __attribute__((weak));
+int f2(void) __attribute__((weak));
int g2 __attribute__((weak));
int g3 __attribute__((weak_import)); // expected-warning {{'weak_import' attribute cannot be specified on a definition}}
int __attribute__((weak_import)) g4(void);
struct __attribute__((weak)) s0 {}; // expected-warning {{'weak' attribute only applies to variables, functions, and classes}}
struct __attribute__((weak_import)) s1 {}; // expected-warning {{'weak_import' attribute only applies to variables and functions}}
-static int f() __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}}
+static int f(void) __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}}
static int x __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}}
// rdar://9538608
static int pr14946_x;
extern int pr14946_x __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}}
-static void pr14946_f();
-void pr14946_f() __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}}
+static void pr14946_f(void);
+void pr14946_f(void) __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}}
__attribute__((interrupt(12))) void foo(void) { } // expected-error {{'interrupt' attribute takes no arguments}}
-__attribute__((interrupt)) void food() {}
+__attribute__((interrupt)) void food(void) {}
__attribute__((signal(12))) void foo(void) { } // expected-error {{'signal' attribute takes no arguments}}
-__attribute__((signal)) void food() {}
+__attribute__((signal)) void food(void) {}
void take(void*);
-void test() {
+void test(void) {
take(^(int x){});
take(^(int x, int y){});
take(^(int x, int y){});
}
// radar 7528255
-void f0() {
+void f0(void) {
^(int, double d, char) {}(1, 1.34, 'a'); // expected-warning {{omitting the parameter name in a function definition is a C2x extension}} \
// expected-warning {{omitting the parameter name in a function definition is a C2x extension}}
}
// rdar://problem/8962770
-void test4() {
- int (^f)() = ^((x)) { }; // expected-warning {{type specifier missing}} expected-error {{type-id cannot have a name}}
+void test4(void) {
+ int (^f)(void) = ^((x)) { }; // expected-warning {{type specifier missing}} expected-error {{type-id cannot have a name}}
}
// rdar://problem/9170609
typedef short SHORT;
-void f0() {
+void f0(void) {
(void) ^{
if (1)
return (float)1.0;
// RUN: %clang_cc1 %s -verify -fblocks -fsyntax-only
-void xx();
+void xx(void);
-int a() {
+int a(void) {
A:
if (1) xx();
A: return 1;
}();
}
-int b() {
+int b(void) {
A: return ^{int a; A:return 1;}();
}
-int d() {
+int d(void) {
A: return ^{int a; A: a = ^{int a; A:return 1;}() + ^{int b; A:return 2;}(); return a; }();
}
-int c() {
+int c(void) {
goto A; // expected-error {{use of undeclared label 'A'}}
return ^{
A:
void I( void (^)(void));
void (^noop)(void);
-void nothing();
+void nothing(void);
int printf(const char*, ...);
typedef void (^T) (void);
void takeblock(T);
int takeintint(int (^C)(int)) { return C(4); }
-T somefunction() {
+T somefunction(void) {
if (^{ })
nothing();
return ^{printf("\nClosure\n"); };
}
-void test2() {
+void test2(void) {
int x = 4;
takeblock(^{ printf("%d\n", x); });
}
-void (^test3())(void) {
+void (^test3(void))(void) {
return ^{};
}
-void test4() {
+void test4(void) {
void (^noop)(void) = ^{};
- void (*noop2)() = 0;
+ void (*noop2)(void) = 0;
}
void myfunc(int (^block)(int)) {}
void myfunc3(const int *x);
-void test5() {
+void test5(void) {
int a;
myfunc(^(int abcd) {
void *X;
-void test_arguments() {
+void test_arguments(void) {
int y;
int (^c)(char);
(1 ? c : 0)('x');
#include <stdarg.h>
-int main() {
+int main(void) {
void (^b) (int arg, const char * format, ...) __attribute__ ((__format__ (__printf__, 1, 3))) = // expected-error {{format argument not a string type}}
^ __attribute__ ((__format__ (__printf__, 1, 3))) (int arg, const char * format, ...) {}; // expected-error {{format argument not a string type}}
// RUN: %clang_cc1 -fsyntax-only %s -verify -fblocks
int j;
-void foo() {
+void foo(void) {
^ (void) { if (j) return 1; }(); // expected-error {{non-void block does not return a value in all control paths}}
}
// RUN: %clang_cc1 -fsyntax-only %s -verify -fblocks
-void foo() {
+void foo(void) {
^ (void) __attribute__((noreturn)) { }(); // expected-error {{block declared 'noreturn' should not return}}
}
// RUN: %clang_cc1 -fsyntax-only %s -verify -fblocks
-void foo() {
+void foo(void) {
^ int (void) { }(); // expected-error {{non-void block does not return a value}}
}
typedef void (^CL)(void);
-CL foo() {
+CL foo(void) {
short y;
short (^add1)(void) = ^{ return y+1; }; // expected-error {{incompatible block pointer types initializing 'short (^)(void)' with an expression of type 'int (^)(void)'}}
typedef int (^CL2)(void);
-CL2 foo2() {
+CL2 foo2(void) {
return ^{ return 1; };
}
Boolean (^isEqual)(const CFBasicHash *, uintptr_t stack_value_or_key1, uintptr_t stack_value_or_key2, Boolean is_key);
} CFBasicHashCallbacks;
-int foo3() {
+int foo3(void) {
CFBasicHashCallbacks cb;
Boolean (*value_equal)(uintptr_t, uintptr_t) = 0;
else
return 0;
}
-void next();
-void foo4() {
+void next(void);
+void foo4(void) {
int (^xx)(const char *s) = ^(char *s) { return 1; }; // expected-error {{incompatible block pointer types initializing 'int (^)(const char *)' with an expression of type 'int (^)(char *)'}}
int (*yy)(const char *s) = funk; // expected-warning {{incompatible function pointer types initializing 'int (*)(const char *)' with an expression of type 'int (char *)'}}
int sz8 = sizeof(^int (*[5])(long) {return funcptr3;}); // expected-error {{block cannot return array type}} expected-warning {{incompatible pointer to integer conversion}}
int sz9 = sizeof(^int(*())()[3]{ }); // expected-error {{function cannot return array type}}
-void foo6() {
+void foo6(void) {
int (^b)(int) __attribute__((noreturn));
b = ^ (int i) __attribute__((noreturn)) { return 1; }; // expected-error {{block declared 'noreturn' should not return}}
b(1);
}
-void foo7()
+void foo7(void)
{
const int (^BB) (void) = ^{ const int i = 1; return i; }; // OK - initializing 'const int (^)(void)' with an expression of type 'int (^)(void)'
void (^e) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (1,1)));
-int main() {
+int main(void) {
void (^bbad) (int arg, const char * format) __attribute__ ((__sentinel__)) ; // expected-warning {{'sentinel' attribute only supported for variadic blocks}}
bbad = ^void (int arg, const char * format) __attribute__ ((__sentinel__)) {} ; // expected-warning {{'sentinel' attribute only supported for variadic blocks}}
void (^b) (int arg, const char * format, ...) __attribute__ ((__sentinel__)) = // expected-note {{block has been explicitly marked sentinel here}}
int printf(const char *, ...);
void _Block_byref_release(void*src){}
-int main() {
+int main(void) {
__block int X = 1234;
__block const char * message = "HELLO";
struct s *p __reloc__; // expected-error {{'preserve_access_index' attribute only applies to structs, unions, and classes}}
void invalid1(const int __reloc__ *arg) {} // expected-error {{'preserve_access_index' attribute only applies to structs, unions, and classes}}
-void invalid2() { const int __reloc__ *arg; } // expected-error {{'preserve_access_index' attribute only applies to structs, unions, and classes}}
+void invalid2(void) { const int __reloc__ *arg; } // expected-error {{'preserve_access_index' attribute only applies to structs, unions, and classes}}
int valid3(struct t4 *arg) { return arg->a + arg->b[3] + arg->c + arg->d; }
int valid4(void *arg) {
struct local_t { int a; int b; } __reloc__;