// RUN: %clang_cc1 -fsyntax-only -verify %s
-void foo() {
+void foo(void) {
{
typedef float X;
}
// Ignored type qualifiers after comma in declarator lists
typedef int ignored_quals_dummy1, const volatile __ptr32 __ptr64 __w64 __unaligned __sptr __uptr ignored_quals1; // expected-warning {{qualifiers after comma in declarator list are ignored}}
-typedef void(*ignored_quals_dummy2)(), __fastcall ignored_quals2; // expected-warning {{qualifiers after comma in declarator list are ignored}}
-typedef void(*ignored_quals_dummy3)(), __stdcall ignored_quals3; // expected-warning {{qualifiers after comma in declarator list are ignored}}
-typedef void(*ignored_quals_dummy4)(), __thiscall ignored_quals4; // expected-warning {{qualifiers after comma in declarator list are ignored}}
-typedef void(*ignored_quals_dummy5)(), __cdecl ignored_quals5; // expected-warning {{qualifiers after comma in declarator list are ignored}}
-typedef void(*ignored_quals_dummy6)(), __vectorcall ignored_quals6; // expected-warning {{qualifiers after comma in declarator list are ignored}}
+typedef void(*ignored_quals_dummy2)(void), __fastcall ignored_quals2; // expected-warning {{qualifiers after comma in declarator list are ignored}}
+typedef void(*ignored_quals_dummy3)(void), __stdcall ignored_quals3; // expected-warning {{qualifiers after comma in declarator list are ignored}}
+typedef void(*ignored_quals_dummy4)(void), __thiscall ignored_quals4; // expected-warning {{qualifiers after comma in declarator list are ignored}}
+typedef void(*ignored_quals_dummy5)(void), __cdecl ignored_quals5; // expected-warning {{qualifiers after comma in declarator list are ignored}}
+typedef void(*ignored_quals_dummy6)(void), __vectorcall ignored_quals6; // expected-warning {{qualifiers after comma in declarator list are ignored}}
__declspec(align(16)) struct align_before_key1 {};
__declspec(align(16)) struct align_before_key2 {} align_before_key2_var;
// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-ibm-aix-xcoff
// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-linux-gnu
-int vector();
+int vector(void);
-void test() {
+void test(void) {
vector unsigned int v = {0};
}
typedef int vector;
-void test() {
+void test(void) {
vector unsigned int v = {0};
}
__vector __bool int vv___bi;
__vector __pixel vv_p;
__vector pixel vv__p;
-__vector int vf__r();
+__vector int vf__r(void);
void vf__a(__vector int a);
void vf__a2(int b, __vector int a);
vector __bool int v___bi;
vector __pixel v_p;
vector pixel v__p;
-vector int f__r();
+vector int f__r(void);
void f_a(vector int a);
void f_a2(int b, vector int a);
vector short i32;
};
-void f() {
+void f(void) {
__vector unsigned int v = {0,0,0,0};
__vector int v__cast = (__vector int)v;
__vector int v_cast = (vector int)v;
#error Extension 'gnu_asm' should be available by default
#endif
-void f1() {
+void f1(void) {
// PR7673: Some versions of GCC support an empty clobbers section.
asm ("ret" : : :);
}
-void f2() {
+void f2(void) {
asm("foo" : "=r" (a)); // expected-error {{use of undeclared identifier 'a'}}
asm("foo" : : "r" (b)); // expected-error {{use of undeclared identifier 'b'}}
}
-void a() __asm__(""); // expected-error {{cannot use an empty string literal in 'asm'}}
-void a() {
+void a(void) __asm__(""); // expected-error {{cannot use an empty string literal in 'asm'}}
+void a(void) {
__asm__(""); // ok
}
typedef int _Atomic *int_atomic_ptr; // ext-warning {{'_Atomic' is a C11 extension}}
typedef _Atomic(int) *int_atomic_ptr; // ext-warning {{'_Atomic' is a C11 extension}}
-typedef int int_fn();
-typedef _Atomic int_fn atomic_int_fn; // expected-error {{_Atomic cannot be applied to function type 'int_fn' (aka 'int ()')}} \
+typedef int int_fn(void);
+typedef _Atomic int_fn atomic_int_fn; // expected-error {{_Atomic cannot be applied to function type 'int_fn' (aka 'int (void)')}} \
// ext-warning {{'_Atomic' is a C11 extension}}
typedef _Atomic int atomic_int_array[3]; // ext-warning {{'_Atomic' is a C11 extension}}
typedef _Atomic atomic_int_array atomic_int_atomic_array; // expected-error {{_Atomic cannot be applied to array type 'atomic_int_array' (aka '_Atomic(int)[3]')}} \
struct S
_Atomic atomic_s_no_missing_semicolon; // ext-warning {{'_Atomic' is a C11 extension}}
-int *const _Atomic atomic_return_type(); // ext-warning {{'_Atomic' is a C11 extension}}
+int *const _Atomic atomic_return_type(void); // ext-warning {{'_Atomic' is a C11 extension}}
# error 'availability' attribute is not available
#endif
-void f0() __attribute__((availability(macosx,introduced=10.2,deprecated=10.4,obsoleted=10.6)));
+void f0(void) __attribute__((availability(macosx,introduced=10.2,deprecated=10.4,obsoleted=10.6)));
-void f1() __attribute__((availability(macosx,deprecated=10.4,introduced=10.2,obsoleted=10.6)));
+void f1(void) __attribute__((availability(macosx,deprecated=10.4,introduced=10.2,obsoleted=10.6)));
-void f2() __attribute__((availability(ios,deprecated=10.4.7,introduced=10,obsoleted=10.6)));
+void f2(void) __attribute__((availability(ios,deprecated=10.4.7,introduced=10,obsoleted=10.6)));
-void f3() __attribute__((availability(ios,deprecated=10.4.7,introduced=10,obsoleted=10.6,introduced=10.2))); // expected-error{{redundant 'introduced' availability change; only the last specified change will be used}}
+void f3(void) __attribute__((availability(ios,deprecated=10.4.7,introduced=10,obsoleted=10.6,introduced=10.2))); // expected-error{{redundant 'introduced' availability change; only the last specified change will be used}}
-void f4() __attribute__((availability(macosx,introduced=10.5), availability(ios,unavailable)));
+void f4(void) __attribute__((availability(macosx,introduced=10.5), availability(ios,unavailable)));
-void f5() __attribute__((availability(macosx,introduced=10.5), availability(ios,unavailable, unavailable))); // expected-error{{redundant 'unavailable' availability change; only the last specified change will be used}}
+void f5(void) __attribute__((availability(macosx,introduced=10.5), availability(ios,unavailable, unavailable))); // expected-error{{redundant 'unavailable' availability change; only the last specified change will be used}}
-void f6() __attribute__((availability(macosx,unavailable,introduced=10.5))); // expected-warning{{'unavailable' availability overrides all other availability information}}
+void f6(void) __attribute__((availability(macosx,unavailable,introduced=10.5))); // expected-warning{{'unavailable' availability overrides all other availability information}}
-void f7() __attribute__((availability(macosx,message=L"wide"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
+void f7(void) __attribute__((availability(macosx,message=L"wide"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
-void f8() __attribute__((availability(macosx,message="a" L"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
+void f8(void) __attribute__((availability(macosx,message="a" L"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
-void f9() __attribute__((availability(macosx,message=u8"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
+void f9(void) __attribute__((availability(macosx,message=u8"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
-void f10() __attribute__((availability(macosx,message="a" u8"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
+void f10(void) __attribute__((availability(macosx,message="a" u8"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
-void f11() __attribute__((availability(macosx,message=u"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
+void f11(void) __attribute__((availability(macosx,message=u"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
-void f12() __attribute__((availability(macosx,message="a" u"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
+void f12(void) __attribute__((availability(macosx,message="a" u"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
// rdar://10095131
enum E{
// RUN: %clang_cc1 -fsyntax-only -verify %s
-void function() __attribute__((external_source_symbol(language="Swift", defined_in="module", generated_declaration)));
+void function(void) __attribute__((external_source_symbol(language="Swift", defined_in="module", generated_declaration)));
__attribute__((external_source_symbol(language="Swift", defined_in="module")))
@interface I
CaseB __attribute__((external_source_symbol(generated_declaration, language="Swift")))
} __attribute__((external_source_symbol(language = "Swift")));
-void f2()
+void f2(void)
__attribute__((external_source_symbol())); // expected-error {{expected 'language', 'defined_in', or 'generated_declaration'}}
-void f3()
+void f3(void)
__attribute__((external_source_symbol(invalid))); // expected-error {{expected 'language', 'defined_in', or 'generated_declaration'}}
-void f4()
+void f4(void)
__attribute__((external_source_symbol(language))); // expected-error {{expected '=' after language}}
-void f5()
+void f5(void)
__attribute__((external_source_symbol(language=))); // expected-error {{expected string literal for language name in 'external_source_symbol' attribute}}
-void f6()
+void f6(void)
__attribute__((external_source_symbol(defined_in=20))); // expected-error {{expected string literal for source container name in 'external_source_symbol' attribute}}
-void f7()
+void f7(void)
__attribute__((external_source_symbol(generated_declaration, generated_declaration))); // expected-error {{duplicate 'generated_declaration' clause in an 'external_source_symbol' attribute}}
-void f8()
+void f8(void)
__attribute__((external_source_symbol(language="Swift", language="Swift"))); // expected-error {{duplicate 'language' clause in an 'external_source_symbol' attribute}}
-void f9()
+void f9(void)
__attribute__((external_source_symbol(defined_in="module", language="Swift", defined_in="foo"))); // expected-error {{duplicate 'defined_in' clause in an 'external_source_symbol' attribute}}
-void f10()
+void f10(void)
__attribute__((external_source_symbol(generated_declaration, language="Swift", defined_in="foo", generated_declaration, generated_declaration, language="Swift"))); // expected-error {{duplicate 'generated_declaration' clause in an 'external_source_symbol' attribute}}
-void f11()
+void f11(void)
__attribute__((external_source_symbol(language="Objective-C++", defined_in="Some file with spaces")));
-void f12()
+void f12(void)
__attribute__((external_source_symbol(language="C Sharp", defined_in="file:////Hello world with spaces. cs")));
-void f13()
+void f13(void)
__attribute__((external_source_symbol(language=Swift))); // expected-error {{expected string literal for language name in 'external_source_symbol' attribute}}
-void f14()
+void f14(void)
__attribute__((external_source_symbol(=))); // expected-error {{expected 'language', 'defined_in', or 'generated_declaration'}}
-void f15()
+void f15(void)
__attribute__((external_source_symbol(="Swift"))); // expected-error {{expected 'language', 'defined_in', or 'generated_declaration'}}
-void f16()
+void f16(void)
__attribute__((external_source_symbol("Swift", "module", generated_declaration))); // expected-error {{expected 'language', 'defined_in', or 'generated_declaration'}}
-void f17()
+void f17(void)
__attribute__((external_source_symbol(language="Swift", "generated_declaration"))); // expected-error {{expected 'language', 'defined_in', or 'generated_declaration'}}
-void f18()
+void f18(void)
__attribute__((external_source_symbol(language= =))); // expected-error {{expected string literal for language name in 'external_source_symbol' attribute}}
-void f19()
+void f19(void)
__attribute__((external_source_symbol(defined_in="module" language="swift"))); // expected-error {{expected ')'}} expected-note {{to match this '('}}
-void f20()
+void f20(void)
__attribute__((external_source_symbol(defined_in="module" language="swift" generated_declaration))); // expected-error {{expected ')'}} expected-note {{to match this '('}}
-void f21()
+void f21(void)
__attribute__((external_source_symbol(defined_in= language="swift"))); // expected-error {{expected string literal for source container name in 'external_source_symbol' attribute}}
-void f22()
+void f22(void)
__attribute__((external_source_symbol)); // expected-error {{'external_source_symbol' attribute takes at least 1 argument}}
-void f23()
+void f23(void)
__attribute__((external_source_symbol(defined_in=, language="swift" generated_declaration))); // expected-error {{expected string literal for source container name in 'external_source_symbol' attribute}} expected-error{{expected ')'}} expected-note{{to match this '('}}
-void f24()
+void f24(void)
__attribute__((external_source_symbol(language = generated_declaration))); // expected-error {{expected string literal for language name in 'external_source_symbol' attribute}}
-void f25()
+void f25(void)
__attribute__((external_source_symbol(defined_in=123, defined_in="module"))); // expected-error {{expected string literal for source container name in 'external_source_symbol'}} expected-error {{duplicate 'defined_in' clause in an 'external_source_symbol' attribute}}
-void f26()
+void f26(void)
__attribute__((external_source_symbol(language=Swift, language="Swift", error))); // expected-error {{expected string literal for language name in 'external_source_symbol'}} expected-error {{duplicate 'language' clause in an 'external_source_symbol' attribute}} expected-error {{expected 'language', 'defined_in', or 'generated_declaration'}}
// PR6287
-void __attribute__((returns_twice)) returns_twice_test();
+void __attribute__((returns_twice)) returns_twice_test(void);
int aligned(int);
int __attribute__((vec_type_hint(char, aligned(16) )) missing_rparen_1; // expected-error 2{{expected ')'}} expected-note {{to match}} expected-warning {{does not declare anything}}
}
// noreturn is lifted to type qualifier
-void testFundef2() __attribute__((noreturn)) { // \
+void testFundef2(void) __attribute__((noreturn)) { // \
// expected-warning {{GCC does not allow 'noreturn' attribute in this position on a function definition}}
testFundef2();
}
}
// GCC allows these
-void testFundef5() __attribute__(()) { }
+void testFundef5(void) __attribute__(()) { }
__attribute__((pure)) int testFundef6(int a) { return a; }
/* RUN: %clang_cc1 -fsyntax-only -verify %s
*/
-void foo() {
+void foo(void) {
break; /* expected-error {{'break' statement not in loop or switch statement}} */
}
-void foo2() {
+void foo2(void) {
continue; /* expected-error {{'continue' statement not in loop statement}} */
}
}
}
-void pr8880_24() {
+void pr8880_24(void) {
for (({break;});;); // expected-error {{'break' statement not in loop or switch statement}}
}
-void pr8880_25() {
+void pr8880_25(void) {
for (({continue;});;); // expected-error {{'continue' statement not in loop statement}}
}
int printf(const char *, ...);
void _Block_byref_release(void*src){}
-int main() {
+int main(void) {
__block int X = 1234;
__block const char * message = "HELLO";
// RUN: %clang_cc1 -fsyntax-only %t -x c -DFIXIT
// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -strict-whitespace
-void test1() {
+void test1(void) {
int a[] = {0,1,1,2,3};
int []b = {0,1,4,9,16};
// expected-error@-1{{brackets are not allowed here; to declare an array, place the brackets after the identifier}}
} s;
#ifndef FIXIT
-void test2() {
+void test2(void) {
int [][][];
// expected-error@-1{{expected identifier or '('}}
// CHECK: {{^}} int [][][];
};
}
-void test3() {
+void test3(void) {
int [5] *;
// expected-error@-1{{expected identifier or '('}}
// CHECK: {{^}} int [5] *;
struct foo { int a; };
-int main() {
+int main(void) {
int a;
float b;
double d;
// RUN: %clang_cc1 -fsyntax-only -verify %s
-int main() {
+int main(void) {
int line = __builtin_LINE();
__builtin_LINE(42); // expected-error {{expected ')'}}
__builtin_LINE(double); // expected-error {{expected ')'}}
__builtin_choose_expr(__builtin_types_compatible_p(typeof(expr), float), funcFloat(expr), \
__builtin_choose_expr(__builtin_types_compatible_p(typeof(expr), double), funcDouble(expr), (void)0)))
-static void test()
+static void test(void)
{
int a;
float b;
enum E1 { E1Foo };
enum E2 { E2Foo };
-static void testGccCompatibility() {
+static void testGccCompatibility(void) {
_Static_assert(__builtin_types_compatible_p(const volatile int, int), "");
_Static_assert(__builtin_types_compatible_p(int[5], int[]), "");
_Static_assert(!__builtin_types_compatible_p(int[5], int[4]), "");
// RUN: %clang_cc1 -fsyntax-only %s
-void bla1() {
+void bla1(void) {
struct XXX;
int XXX;
}
// RUN: %clang_cc1 -std=c11 -fsyntax-only -verify %s
// RUN: not %clang_cc1 -std=c99 -pedantic -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-EXT %s
-_Noreturn int f();
-int _Noreturn f(); // expected-note {{previous}}
+_Noreturn int f(void);
+int _Noreturn f(void); // expected-note {{previous}}
int f _Noreturn(); // expected-error {{expected ';'}} expected-error 2{{}}
-int f() _Noreturn; // expected-error {{'_Noreturn' keyword must precede function declarator}}
+int f(void) _Noreturn; // expected-error {{'_Noreturn' keyword must precede function declarator}}
_Noreturn char c1; // expected-error {{'_Noreturn' can only appear on functions}}
char _Noreturn c2; // expected-error {{'_Noreturn' can only appear on functions}}
-typedef _Noreturn int g(); // expected-error {{'_Noreturn' can only appear on functions}}
+typedef _Noreturn int g(void); // expected-error {{'_Noreturn' can only appear on functions}}
_Noreturn int; // expected-error {{'_Noreturn' can only appear on functions}} expected-warning {{does not declare anything}}
_Noreturn struct S; // expected-error {{'_Noreturn' can only appear on functions}}
// RUN: %clang_cc1 -verify %s
-void test1()
+void test1(void)
{
#pragma clang __debug captured x // expected-warning {{extra tokens at end of #pragma clang __debug captured directive}}
{
}
}
-void test2()
+void test2(void)
{
#pragma clang __debug captured
int x; // expected-error {{expected '{'}}
int a;
};
-int main() {
+int main(void) {
struct foo xxx;
int i;
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsyntax-only -verify -x c++ %s
// expected-no-diagnostics
-int main() {
+int main(void) {
char *s;
s = (char []){"whatever"};
s = (char(*)){s};
// RUN: %clang_cc1 -fsyntax-only -fdebugger-support -verify %s
// expected-no-diagnostics
-void importAModule() {
+void importAModule(void) {
@import AModuleThatDoesntExist
}
// RUN: %clang_cc1 -fsyntax-only -verify %s
-void test1() {
+void test1(void) {
if (sizeof (int){ 1}) {} // sizeof compound literal
if (sizeof (int)) {} // sizeof type
return a = b = c;
}
-int test4() {
+int test4(void) {
test4();
return 0;
}
struct X0 { struct { struct { int c[10][9]; } b; } a; };
-int test_offsetof() {
+int test_offsetof(void) {
(void)__builtin_offsetof(struct X0, a.b.c[4][5]);
return 0;
}
-void test_sizeof(){
+void test_sizeof(void){
int arr[10];
(void)sizeof arr[0];
(void)sizeof(arr[0]);
}
// PR3418
-int test_leading_extension() {
+int test_leading_extension(void) {
__extension__ (*(char*)0) = 1; // expected-warning {{indirection of non-volatile null pointer}} \
// expected-note {{consider using __builtin_trap}}
return 0;
}
// PR8394
-void test7() {
+void test7(void) {
({} // expected-note {{to match}}
; // expected-error {{expected ')'}}
}
// PR16992
struct pr16992 { int x; };
-void func_16992 () {
+void func_16992 (void) {
int x1 = sizeof int; // expected-error {{expected parentheses around type name in sizeof expression}}
int x2 = sizeof struct pr16992; // expected-error {{expected parentheses around type name in sizeof expression}}
int x3 = __alignof int; // expected-error {{expected parentheses around type name in __alignof expression}}
}
void callee(double, double);
-void test8() {
+void test8(void) {
callee(foobar, // expected-error {{use of undeclared identifier 'foobar'}}
fizbin); // expected-error {{use of undeclared identifier 'fizbin'}}
}
// RUN: %clang_cc1 -fsyntax-only -verify %s
-void test1() {
+void test1(void) {
@"s"; // expected-warning {{expression result unused}}
}
/* Decl/expr __extension__ marker. */
-void bar() {
+void bar(void) {
__extension__ int i;
int j;
__extension__ (j = 10LL);
// expected-no-diagnostics
#endif
-void foo() {
+void foo(void) {
#ifndef C99
// expected-warning@+2{{GCC does not allow variable declarations in for loop initializers before C99}}
#endif
/* RUN: %clang_cc1 -fsyntax-only -verify %s
*/
-void test1() {
+void test1(void) {
goto ; /* expected-error {{expected identifier}} */
}
-void test2() {
+void test2(void) {
l: /* expected-note {{previous definition is here}} */
{
void test1(int c) {
X = 5;
}
-void test2() {
+void test2(void) {
int i;
double d = i;
double _Complex a = 5;
a = 5;
d = i;
}
-int test3() {
+int test3(void) {
int a[2];
- a[0] = test3; // expected-warning{{incompatible pointer to integer conversion assigning to 'int' from 'int ()'}}
+ a[0] = test3; // expected-warning{{incompatible pointer to integer conversion assigning to 'int' from 'int (void)'}}
return 0;
}
short x; void test4(char c) { x += c; }
struct Type {
};
-void test_if_exists_stmts() {
+void test_if_exists_stmts(void) {
int b = 0;
__if_exists(Type) {
b++;
}
}
-int if_exists_creates_no_scope() {
+int if_exists_creates_no_scope(void) {
__if_exists(Type) {
int x; // 'x' is declared in the parent scope.
}
int var244;
}
-void test_if_exists_init_list() {
+void test_if_exists_init_list(void) {
int array1[] = {
0,
}
-void test_nested_if_exists() {
+void test_nested_if_exists(void) {
__if_exists(Type) {
int x = 42;
__if_not_exists(Type_not) {
// REQUIRES: x86-registered-target
// RUN: %clang_cc1 %s -triple i386-apple-darwin10 -verify -fasm-blocks
-int t_fail() { // expected-note {{to match this}}
+int t_fail(void) { // expected-note {{to match this}}
__asm
{ // expected-note {{to match this}}
{ // expected-note {{to match this}}
void t2(void) { __asm int 2ch }
void t3(void) { __asm M2 2ch }
void t4(void) { __asm mov eax, fs:[10h] }
-void t5() {
+void t5(void) {
__asm {
int 0x2c ; } asm comments are fun! }{
}
__asm {}
}
-int t6() {
+int t6(void) {
__asm int 3 ; } comments for single-line asm
__asm {}
__asm int 4
return 10;
}
-void t7() {
+void t7(void) {
__asm {
push ebx
mov ebx, 07h
pop ebx
}
}
-void t8() {
+void t8(void) {
__asm nop __asm nop __asm nop
}
-void t9() {
+void t9(void) {
__asm nop __asm nop ; __asm nop
}
-void t10() {
+void t10(void) {
__asm {
mov eax, 0
__asm {
}
}
}
-void t11() {
+void t11(void) {
do { __asm mov eax, 0 __asm { __asm mov edx, 1 } } while(0);
}
-void t12() {
+void t12(void) {
__asm jmp label // expected-error {{use of undeclared label 'label'}}
}
-void t13() {
+void t13(void) {
__asm m{o}v eax, ebx // expected-error {{unknown token in expression}}
}
-void t14() {
+void t14(void) {
enum { A = 1, B };
__asm mov eax, offset A // expected-error {{offset operator cannot yet handle constants}}
}
-int t_fail() { // expected-note {{to match this}}
+int t_fail(void) { // expected-note {{to match this}}
__asm
__asm { // expected-error 3 {{expected}} expected-note {{to match this}}
// RUN: %clang_cc1 %s -fsyntax-only -Wmicrosoft -verify -fms-extensions
-void f() {
+void f(void) {
int a;
__try a; // expected-error {{expected '{'}} expected-warning {{expression result unused}}
}
} // expected-error {{expected '__except' or '__finally' block}}
-void g() {
+void g(void) {
int a;
__try {
} __except(1) a; // expected-error {{expected '{'}} expected-warning {{expression result unused}}
}
-void h() {
+void h(void) {
int a;
__try {
// RUN: %clang_cc1 -triple thumbv7-unknown-windows-msvc -fobjc-exceptions -fobjc-runtime=ios -verify %s
extern void g(void);
-void f() {
+void f(void) {
@try {
g();
} @catch (Class c) { // expected-error{{@catch parameter is not a pointer to an interface type}}
@interface A @end
@protocol P;
-void f() {
+void f(void) {
@try {
} @catch (void a) { // expected-error{{@catch parameter is not a pointer to an interface type}}
} @catch (int) { // expected-error{{@catch parameter is not a pointer to an interface type}}
}
@end
-int main() {return 0;}
+int main(void) {return 0;}
@interface Gorf @end // expected-error {{redefinition of 'Gorf' as different kind of symbol}} expected-note {{previous definition is here}}
-void Gorf() // expected-error {{redefinition of 'Gorf' as different kind of symbol}}
+void Gorf(void) // expected-error {{redefinition of 'Gorf' as different kind of symbol}}
{
int Bar, Foo, FooBar;
}
[s addObject:s]; // expected-warning {{adding 's' to 's' might cause circular dependency in container}}
}
-void checkNSMutableArray() {
+void checkNSMutableArray(void) {
NSMutableArray *a = nil; // expected-note 5 {{'a' declared here}} 5
[a addObject:a]; // expected-warning {{adding 'a' to 'a' might cause circular dependency in container}}
a[0] = a; // expected-warning {{adding 'a' to 'a' might cause circular dependency in container}}
}
-void checkNSMutableDictionary() {
+void checkNSMutableDictionary(void) {
NSMutableDictionary *d = nil; // expected-note 4 {{'d' declared here}}
[d setObject:d forKey:@"key"]; // expected-warning {{adding 'd' to 'd' might cause circular dependency in container}}
d[@"key"] = d; // expected-warning {{adding 'd' to 'd' might cause circular dependency in container}}
}
-void checkNSMutableSet() {
+void checkNSMutableSet(void) {
NSMutableSet *s = nil; // expected-note {{'s' declared here}}
[s addObject:s]; // expected-warning {{adding 's' to 's' might cause circular dependency in container}}
}
-void checkNSCountedSet() {
+void checkNSCountedSet(void) {
NSCountedSet *s = nil; // expected-note {{'s' declared here}}
[s addObject:s]; // expected-warning {{adding 's' to 's' might cause circular dependency in container}}
}
-void checkNSMutableOrderedSet() {
+void checkNSMutableOrderedSet(void) {
NSMutableOrderedSet *s = nil; // expected-note 5 {{'s' declared here}}
[s addObject:s]; // expected-warning {{adding 's' to 's' might cause circular dependency in container}}
@end
-void subclassingNSMutableArray() {
+void subclassingNSMutableArray(void) {
FootableArray *a = nil; // expected-note 5 {{'a' declared here}} 5
[a addObject:a]; // expected-warning {{adding 'a' to 'a' might cause circular dependency in container}}
a[0] = a; // expected-warning {{adding 'a' to 'a' might cause circular dependency in container}}
}
-void subclassingNSMutableDictionary() {
+void subclassingNSMutableDictionary(void) {
FootableDictionary *d = nil; // expected-note 4 {{'d' declared here}}
[d setObject:d forKey:@"key"]; // expected-warning {{adding 'd' to 'd' might cause circular dependency in container}}
d[@"key"] = d; // expected-warning {{adding 'd' to 'd' might cause circular dependency in container}}
}
-void subclassingNSMutableSet() {
+void subclassingNSMutableSet(void) {
FootableSet *s = nil; // expected-note {{'s' declared here}}
[s addObject:s]; // expected-warning {{adding 's' to 's' might cause circular dependency in container}}
+ (id)alloc { return 0; }
@end
-int main ()
+int main (void)
{
Class<TestProtocol> c = [c alloc]; // expected-warning {{class method '+alloc' not found (return type defaults to 'id')}}
Class<Test2Protocol> c1 = [c1 alloc2]; // expected-warning {{instance method 'alloc2' found instead of class method 'alloc2'}}
- (int)two;
@end
-int main ()
+int main (void)
{
return Test.one.two;
}
@end
@interface Subclass : RootClass @end
-void Test1() {
+void Test1(void) {
// now okay
(void)RootClass.property;
(void)Subclass.property;
@end
__attribute__((objc_class_stub)) // expected-error {{'objc_class_stub' attribute only applies to Objective-C interfaces}}
-int cannotHaveObjCClassStubAttribute() {}
+int cannotHaveObjCClassStubAttribute(void) {}
@implementation MyClass (Cat2) // no error.
@end
-int main() {
+int main(void) {
[MyClass new]; // expected-error {{'MyClass' is unavailable: not available}}
[MyClass self]; // expected-error {{'MyClass' is unavailable: not available}}
[MyClass addObject:((void *)0)]; // expected-error {{'MyClass' is unavailable: not available}}
@class Foo;
@class Foo;
@class Foo;
-Foo * f_func() { // expected-error {{'Foo' is unavailable}}
+Foo * f_func(void) { // expected-error {{'Foo' is unavailable}}
return 0;
}
@interface SomeObject <SomeProtocol>
@end
-int main () {
+int main (void) {
Class <SomeProtocol> classA;
Class <SomeProtocol> classB;
Class <SomeProtocol, SomeProtocol1> classC;
@interface A
@end
-void f() {
+void f(void) {
(A){ 0 }; // expected-error{{cannot initialize Objective-C class type 'A'}}
}
#define nil (void *)0;
-extern void foo();
+extern void foo(void);
@protocol MyProtocol
- (void) foo;
- (void) foo;
@end
-int main()
+int main(void)
{
id obj = nil;
id<MyProtocol> obj_p = nil;
@interface MyClass
@end
-int main()
+int main(void)
{
id obj = nil;
id<MyProtocol> obj_p = nil;
#define nil (void *)0;
-extern void foo();
+extern void foo(void);
@protocol MyProtocolA
- (void) methodA;
- (void) methodC;
@end
-int main()
+int main(void)
{
id<MyProtocolA> obj_a = nil;
id<MyProtocolB> obj_b = nil;
// RUN: %clang_cc1 -fsyntax-only -verify %s
-extern void foo();
+extern void foo(void);
@protocol MyProtocol @end
@interface MyClass @end
-int main()
+int main(void)
{
MyClass <MyProtocol> *obj_p;
MyClass *obj_cp;
#define nil (void *)0;
-extern void foo();
+extern void foo(void);
@protocol MyProtocol
- (void) method;
@interface MyOtherClass : MyClass
@end
-int main()
+int main(void)
{
id <MyProtocol> obj_id_p = nil;
MyClass *obj_c_cat_p = nil;
#define nil (void *)0;
-extern void foo();
+extern void foo(void);
@protocol MyProtocol
- (void) method;
@interface MyClass
@end
-int main()
+int main(void)
{
id obj = nil;
id <MyProtocol> obj_p = nil;
id<MyProtocol> obj_p = 0;
-int main()
+int main(void)
{
obj_p = 0;
}
*ivar = value;
}
static NSString *_logProcessPrefix = 0;
-void func() {
+void func(void) {
__setRetained(&_logProcessPrefix, _logProcessPrefix, &_logProcessPrefix);
}
@implementation NSObject (ScopeAdditions)
// RUN: %clang_cc1 -funknown-anytype -fsyntax-only -fdebugger-support -fdebugger-cast-result-to-id -verify %s
extern __unknown_anytype test0;
-extern __unknown_anytype test1();
+extern __unknown_anytype test1(void);
-void test_unknown_anytype_receiver() {
+void test_unknown_anytype_receiver(void) {
(void)(int)[[test0 unknownMethod] otherUnknownMethod];;
(void)(id)[[test1() unknownMethod] otherUnknownMethod];
id x = test0;
// rdar://10988847
@class NSString; // expected-note {{forward declaration of class here}}
-void rdar10988847() {
+void rdar10988847(void) {
id s = [NSString stringWithUTF8String:"foo"]; // expected-warning {{receiver 'NSString' is a forward class and corresponding @interface may not exist}}
}
static int getMe;
-static int test() {
+static int test(void) {
return 0;
}
// rdar://10414277
@protocol P
-void p_foo() {} // expected-warning {{function definition inside an Objective-C container is deprecated}}
+void p_foo(void) {} // expected-warning {{function definition inside an Objective-C container is deprecated}}
@end
@interface I
-void foo() {} // expected-warning {{function definition inside an Objective-C container is deprecated}}
-inline void v_foo() {} // expected-warning {{function definition inside an Objective-C container is deprecated}}
-static int s_foo() {return 0; } // expected-warning {{function definition inside an Objective-C container is deprecated}}
-static inline int si_val() { return 1; } // expected-warning {{function definition inside an Objective-C container is deprecated}}
+void foo(void) {} // expected-warning {{function definition inside an Objective-C container is deprecated}}
+inline void v_foo(void) {} // expected-warning {{function definition inside an Objective-C container is deprecated}}
+static int s_foo(void) {return 0; } // expected-warning {{function definition inside an Objective-C container is deprecated}}
+static inline int si_val(void) { return 1; } // expected-warning {{function definition inside an Objective-C container is deprecated}}
@end
@interface I(CAT)
-void cat_foo() {} // expected-warning {{function definition inside an Objective-C container is deprecated}}
+void cat_foo(void) {} // expected-warning {{function definition inside an Objective-C container is deprecated}}
@end
@implementation I
-inline void v_imp_foo() {}
+inline void v_imp_foo(void) {}
@end
@implementation I(CAT)
-void cat_imp_foo() {}
+void cat_imp_foo(void) {}
@end
// rdar://16859666
-(id)foo;
@end
-static void func() {
+static void func(void) {
id x;
count:(unsigned long)cnt;
@end
-void test() {
+void test(void) {
NSDictionary *t1 = @{
@"foo" : @0, // expected-note 2 {{previous equal key is here}}
@"foo" : @0, // expected-warning{{duplicate key in dictionary literal}}
// expected-warning@-1{{'dllexport' attribute only applies to}}
typedef int __declspec(dllexport) typedef3;
// expected-warning@-1{{'dllexport' attribute only applies to}}
-typedef __declspec(dllexport) void (*FunTy)();
+typedef __declspec(dllexport) void (*FunTy)(void);
// expected-warning@-1{{'dllexport' attribute only applies to}}
enum __declspec(dllexport) E { Val };
// expected-warning@-1{{'dllexport' attribute only applies to}}
// expected-warning@-1{{'dllimport' attribute only applies to}}
typedef int __declspec(dllimport) typedef3;
// expected-warning@-1{{'dllimport' attribute only applies to}}
-typedef __declspec(dllimport) void (*FunTy)();
+typedef __declspec(dllimport) void (*FunTy)(void);
// expected-warning@-1{{'dllimport' attribute only applies to}}
enum __declspec(dllimport) E { Val };
// expected-warning@-1{{'dllimport' attribute only applies to}}
@implementation Intf
@end
-int main()
+int main(void)
{
int i;
typeof(@encode(typeof(i))) e = @encode(typeof(Intf)); // expected-warning {{initializer-string for char array is too long}}
char *string;
};
-const char *RetEncode () {
+const char *RetEncode (void) {
return @encode(struct foo); // expected-warning {{encoding of 'struct foo' type is incomplete because 'short8' (vector of 8 'short' values) component has unknown encoding}}
}
enum : Integer { Blah, Blarg } field4 : 4;
};
-void test() {
+void test(void) {
long value = 2;
Enumeration e = value;
}
@end
void
-doLaunchdJobCPU()
+doLaunchdJobCPU(void)
{
[uuids_jobs enumerateKeysAndObjectsUsingBlock]; // expected-error {{use of undeclared identifier 'uuids_jobs'}}
}
// rdar://6079877
-void test2() {
+void test2(void) {
id str = @"foo"
"bar\0" // no-warning
@"baz" " blarg";
@class Incomplete_ObjC_class; // expected-note{{forward declaration of class here}}
struct Incomplete_struct; // expected-note {{forward declaration}}
-void test_encode() {
+void test_encode(void) {
(void)@encode(Incomplete_ObjC_class); // expected-error {{incomplete type}}
(void)@encode(struct Incomplete_struct); // expected-error {{incomplete type}}
(void)@encode(Incomplete_ObjC_class*);
@interface ObjCTy
@end
-void test1() {
+void test1(void) {
EXT_RET int a; // expected-warning{{'objc_externally_retained' can only be applied to}}
EXT_RET __weak ObjCTy *b; // expected-warning{{'objc_externally_retained' can only be applied to}}
- EXT_RET __weak int (^c)(); // expected-warning{{'objc_externally_retained' can only be applied to}}
+ EXT_RET __weak int (^c)(void); // expected-warning{{'objc_externally_retained' can only be applied to}}
- EXT_RET int (^d)() = ^{return 0;};
+ EXT_RET int (^d)(void) = ^{return 0;};
EXT_RET ObjCTy *e = 0;
EXT_RET __strong ObjCTy *f = 0;
}
@end
-void test4() {
+void test4(void) {
__attribute__((objc_externally_retained(0))) ObjCTy *a; // expected-error{{'objc_externally_retained' attribute takes no arguments}}
}
@end
-int main ()
+int main (void)
{
NSObject<NSFastEnumeration>* collection = ((void*)0);
for (id thing in collection) { } /* expected-warning {{unused variable 'thing'}} */
}
}
-int cond();
+int cond(void);
void test3(NSObject<NSFastEnumeration> *a0, NSObject<NSFastEnumeration> *a1) {
for (id i in a0) { /* expected-note 2 {{jump enters Objective-C fast enumeration loop}} */
extern void MyCFStringCreateWithFormat(CFStringRef format, ...) __attribute__((format(__CFString__, 1, 2))); // expected-note {{'MyCFStringCreateWithFormat' declared here}}
extern void XMyNSLog(int, NSString *format, ...) __attribute__((format(__NSString__, 2, 3))); // expected-note {{'XMyNSLog' declared here}}
-void Test2() {
+void Test2(void) {
MyNSLog(@"%s\n", "Hello"); // expected-warning {{using %s directive in CFString which is being passed as a formatting argument to the formatting CFfunction}}
MyCFStringCreateWithFormat((CFStringRef)@"%s", "Hello"); // expected-warning {{using %s directive in CFString which is being passed as a formatting argument to the formatting CFfunction}}
extern void XMyOSLog(int, const char* format, ...) __attribute__((format(os_trace, 2, 3)));
extern void os_trace(const char *format, ...) __attribute__((format(os_trace, 1, 2)));
-void Test2() {
+void Test2(void) {
MyOSLog("%s\n", "Hello");
MyFStringCreateWithFormat("%s", "Hello");
extern void NSLog(NSString *format, ...);
-void testSizeSpecifier() {
+void testSizeSpecifier(void) {
NSInteger i = 0;
NSUInteger j = 0;
NSLog(@"max NSInteger = %zi", i);
extern void CFStringCreateWithFormat2(int *format, ...) __attribute__((format(CFString, 1, 2))); // expected-error {{format argument not a CFString}}
// <rdar://problem/7068334> - Catch use of long long with int arguments.
-void rdar_7068334() {
+void rdar_7068334(void) {
long long test = 500;
printf("%i ",test); // expected-warning{{format specifies type 'int' but the argument has type 'long long'}}
NSLog(@"%i ",test); // expected-warning{{format specifies type 'int' but the argument has type 'long long'}}
}
// <rdar://problem/7697748>
-void rdar_7697748() {
+void rdar_7697748(void) {
NSLog(@"%@!"); // expected-warning{{more '%' conversions than data arguments}}
}
extern void MyNSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
extern void MyCFStringCreateWithFormat(CFStringRef format, ...) __attribute__((format(__CFString__, 1, 2)));
-void check_mylog() {
+void check_mylog(void) {
MyNSLog(@"%@"); // expected-warning {{more '%' conversions than data arguments}}
MyCFStringCreateWithFormat(CFSTR("%@")); // expected-warning {{more '%' conversions than data arguments}}
}
+ (id)fooWithCStringFormat:(const char *)format, ... __attribute__((format(__printf__, 1, 2)));
@end
-void check_method() {
+void check_method(void) {
[Foo fooWithFormat:@"%@"]; // expected-warning {{more '%' conversions than data arguments}}
[Foo fooWithCStringFormat:"%@"]; // expected-warning {{invalid conversion specifier '@'}}
}
#define MyNSLocalizedString(key) GetLocalizedString(key)
#define MyNSAssert(fmt, arg) NSLog(fmt, arg, 0, 0)
-void check_NSLocalizedString() {
+void check_NSLocalizedString(void) {
[Foo fooWithFormat:NSLocalizedString(@"format"), @"arg"]; // no-warning
[Foo fooWithFormat:MyNSLocalizedString(@"format"), @"arg"]; // expected-warning {{format string is not a string literal}}}
}
-void check_NSAssert() {
+void check_NSAssert(void) {
NSAssert(@"Hello %@", @"World"); // no-warning
MyNSAssert(@"Hello %@", @"World"); // expected-warning {{data argument not used by format string}}
}
// Test that %S, %C, %ls check for 16 bit types in ObjC strings, as described at
// http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html#//apple_ref/doc/uid/TP40004265
-void test_percent_S() {
+void test_percent_S(void) {
const unsigned short data[] = { 'a', 'b', 0 };
const unsigned short* ptr = data;
NSLog(@"%S", ptr); // no-warning
NSLog(@"%S", wchar_ptr); // expected-warning{{format specifies type 'const unichar *' (aka 'const unsigned short *') but the argument has type 'const wchar_t *'}}
}
-void test_percent_ls() {
+void test_percent_ls(void) {
const unsigned short data[] = { 'a', 'b', 0 };
const unsigned short* ptr = data;
NSLog(@"%ls", ptr); // no-warning
NSLog(@"%ls", wchar_ptr); // expected-warning{{format specifies type 'const unichar *' (aka 'const unsigned short *') but the argument has type 'const wchar_t *'}}
}
-void test_percent_C() {
+void test_percent_C(void) {
const unsigned short data = 'a';
NSLog(@"%C", data); // no-warning
// Test that it is okay to use %p with the address of a block.
-void rdar11049844_aux();
-int rdar11049844() {
+void rdar11049844_aux(void);
+int rdar11049844(void) {
typedef void (^MyBlock)(void);
- MyBlock x = ^void() { rdar11049844_aux(); };
+ MyBlock x = ^void(void) { rdar11049844_aux(); };
printf("%p", x); // no-warning
}
-void test_nonBuiltinCFStrings() {
+void test_nonBuiltinCFStrings(void) {
CFStringCreateWithFormat(__CFStringMakeConstantString("%@"), 1); // expected-warning{{format specifies type 'id' but the argument has type 'int'}}
}
NSLog(@"dW %d dH %d",({ __typeof__(dW) __a = (dW); __a < 0 ? -__a : __a; }),({ __typeof__(dH) __a = (dH); __a < 0 ? -__a : __a; })); // expected-warning 2 {{format specifies type 'int' but the argument has type 'long'}}
}
-void testUnicode() {
+void testUnicode(void) {
NSLog(@"%C", 0x2022); // no-warning
NSLog(@"%C", 0x202200); // expected-warning{{format specifies type 'unichar' (aka 'unsigned short') but the argument has type 'int'}}
}
// Test Objective-C modifier flags.
-void testObjCModifierFlags() {
+void testObjCModifierFlags(void) {
NSLog(@"%[]@", @"Foo"); // expected-warning {{missing object format flag}}
NSLog(@"%[", @"Foo"); // expected-warning {{incomplete format specifier}}
NSLog(@"%[tt", @"Foo"); // expected-warning {{incomplete format specifier}}
void f0(__strong A**); // expected-note{{passing argument to parameter here}}
-void test_f0() {
+void test_f0(void) {
A *a;
static __weak A *a2;
f0(&a);
void f1(__weak A**); // expected-note{{passing argument to parameter here}}
-void test_f1() {
+void test_f1(void) {
A *a;
__strong A *a2;
f1(&a);
@property IBOutlet __weak WeakOutlet* WeakProp;
@end
-WeakOutlet* func() {
+WeakOutlet* func(void) {
__weak WeakOutlet* pwi;
pwi.WeakProp = (WeakOutlet*)0;
pwi.WeakProp = pwi.WeakProp;
Class T;
id<Foo> S;
id R;
-void foo() {
+void foo(void) {
// Test assignment compatibility of Class and id. No warning should be
// produced.
// rdar://6770142 - Class and id<foo> are compatible.
void takeCopyableId(id<NSCopying> test) {}
-id<NSCopying> Test () {
+id<NSCopying> Test (void) {
NSString const *constantString = @"Test";
takeId(constantString);
takeCopyableId(constantString);
@interface NSString
@end
-CFTypeRef CFCreateSomething();
-CFStringRef CFCreateString();
-CFTypeRef CFGetSomething();
-CFStringRef CFGetString();
+CFTypeRef CFCreateSomething(void);
+CFStringRef CFCreateString(void);
+CFTypeRef CFGetSomething(void);
+CFStringRef CFGetString(void);
-id CreateSomething();
-NSString *CreateNSString();
+id CreateSomething(void);
+NSString *CreateNSString(void);
-void from_cf() {
+void from_cf(void) {
id obj1 = (__bridge_transfer id)CFCreateSomething(); // expected-warning {{'__bridge_transfer' casts have no effect when not using ARC}}
id obj2 = (__bridge_transfer NSString*)CFCreateString(); // expected-warning {{'__bridge_transfer' casts have no effect when not using ARC}}
(__bridge int*)CFCreateSomething(); // expected-warning {{expression result unused}} expected-warning {{cast from 'const void *' to 'int *' drops const qualifier}}
CFStringRef cf4 = (__bridge CFStringRef)CreateNSString();
}
-void fixits() {
+void fixits(void) {
id obj1 = (id)CFCreateSomething();
CFTypeRef cf1 = (CFTypeRef)CreateSomething();
}
// Check that clang doesn't warn about dropping const from Objective-C object
// types.
-void test_wcast_qual() {
+void test_wcast_qual(void) {
CFStringRef c;
NSString *n0 = (NSString *)c;
NSString **n1 = (NSString **)&c;
-(instancetype)init __attribute__((unavailable)); // expected-note{{'init' has been explicitly marked unavailable here}}
@end
-void usemyobject() {
+void usemyobject(void) {
[MyObject new]; // expected-error{{'new' is unavailable}}
}
+(instancetype)new;
@end
-void usemyotherobject() {
+void usemyotherobject(void) {
[MyOtherObject new]; // no error; new is overrideen.
}
+(instancetype)new: (int)x;
@end
-void usenotgoodoverride() {
+void usenotgoodoverride(void) {
[NotGoodOverride new]; // no error
}
-(instancetype)init __attribute__((unavailable));
@end
-void usenotmyobject() {
+void usenotmyobject(void) {
[NotMyObject new]; // no error; this isn't NSObject
}
@end
// Check the basic initialization pattern.
-void test_instancetype_alloc_init_simple() {
+void test_instancetype_alloc_init_simple(void) {
Root *r1 = [[Root alloc] init];
Subclass1 *sc1 = [[Subclass1 alloc] init];
}
// Test that message sends to instancetype methods have the right type.
-void test_instancetype_narrow_method_search() {
+void test_instancetype_narrow_method_search(void) {
// instancetype on class methods
Subclass1 *sc1 = [[Subclass1 alloc] initSubclass2]; // expected-warning{{'Subclass1' may not respond to 'initSubclass2'}}
Subclass2 *sc2 = [[Subclass2 alloc] initSubclass2]; // okay
// Check that inherited related return types influence the types of
// message sends.
-void test_instancetype_inherited() {
+void test_instancetype_inherited(void) {
[[Subclass4 alloc] initSubclass1]; // expected-warning{{'Subclass4' may not respond to 'initSubclass1'}}
[[Subclass4 alloc] initOther];
}
@interface INT1
@end
-void test2() {
+void test2(void) {
// rdar://6827200
INT1 b[3]; // expected-error {{array of interface 'INT1' is invalid (probably should be an array of pointers)}}
INT1 *c = &b[0];
// RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions -Wno-objc-root-class %s
// rdar://6124613
-void test1() {
+void test1(void) {
void *xyzzy = 0;
void *p = @xyzzy; // expected-error {{unexpected '@' in program}}
}
// <rdar://problem/7881045>
// This previously triggered a crash because a ';' was expected after the @throw statement.
-void foo() {
+void foo(void) {
@throw (id)0 // expected-error{{expected ';' after @throw}}
}
int a, b;
} NotAClass;
-void foo() {
+void foo(void) {
[NotAClass nonexistent_method]; // expected-error {{receiver type 'NotAClass' (aka 'struct NotAClass') is not an Objective-C class}}
}
// RUN: %clang_cc1 -fsyntax-only -verify %s
struct S; // expected-note{{forward declaration of 'struct S'}}
-typedef int FOO();
+typedef int FOO(void);
@interface INTF
{
@interface B : NSObject
@property (getter=isActive, readonly) BOOL active;
@end
-void foo() {
+void foo(void) {
__kindof B *NSApp;
if ([NSApp isActive]) {
}
// __kindof + nullability
// ---------------------------------------------------------------------------
-void testNullability() {
+void testNullability(void) {
// The base type being a pointer type tickles the bug.
- extern __kindof id <NSCopying> _Nonnull getSomeCopyable();
+ extern __kindof id <NSCopying> _Nonnull getSomeCopyable(void);
NSString *string = getSomeCopyable(); // no-warning
void processCopyable(__typeof(getSomeCopyable()) string);
[generic test:NSString_str];
}
-void testGenericAssignment() {
+void testGenericAssignment(void) {
NSMutableString *NSMutableString_str;
NSNumber *NSNumber_obj;
NSNumber_obj = typedef_generic.kindof_object; // expected-warning{{incompatible pointer types assigning to 'NSNumber *' from '__kindof Typedef_NSString'}}
}
-void testKindofNonObjectType() {
+void testKindofNonObjectType(void) {
typedef void (^BlockType)(int);
NSGeneric<BlockType> *generic;
}
INTF* pi;
-INTF* FUNC()
+INTF* FUNC(void)
{
return pi;
}
[ ob nonVararg: 0, 1, 2]; // expected-error {{too many arguments to method call}}
}
-int f2() {
+int f2(void) {
const id foo;
[foo bar]; // expected-warning {{method '-bar' not found (return type defaults to 'id')}}
return 0;
}
// PR4021
-void foo4() {
+void foo4(void) {
struct objc_object X[10];
[X rect]; // expected-warning {{receiver type 'struct objc_object *' is not 'id' or interface pointer, consider casting it to 'id'}}
static NSString const * Identifier2 = @"Identifier2";
static NSString * const Identifier3 = @"Identifier3";
-int main () {
+int main (void) {
[@"Identifier1" isEqualToString:Identifier1]; // expected-warning {{sending 'const NSString *' to parameter of type 'NSString *' discards qualifiers}}
[@"Identifier2" isEqualToString:Identifier2]; // expected-warning {{sending 'const NSString *' to parameter of type 'NSString *' discards qualifiers}}
}
void somefunc(foo x) {} // expected-error {{interface type 'foo' cannot be passed by value; did you forget * in 'foo'}}
-foo somefunc2() {} // expected-error {{interface type 'foo' cannot be returned by value; did you forget * in 'foo'}}
+foo somefunc2(void) {} // expected-error {{interface type 'foo' cannot be returned by value; did you forget * in 'foo'}}
// rdar://6780761
void f0(foo *a0) {
@interface arrayfun
- (int[6])arrayRet; // expected-error {{function cannot return array type 'int[6]'}}
-- (int())funcRet; // expected-error {{function cannot return function type 'int ()'}}
+- (int(void))funcRet; // expected-error {{function cannot return function type 'int (void)'}}
@end
@interface qux
@interface Foo // expected-note {{receiver is instance of class declared here}}
@end
-void test() {
+void test(void) {
Foo *fooObj;
id obj;
- (id) foo16 : (id**)firstObj, ... __attribute__((sentinel(0,1)));
@end
-int main ()
+int main (void)
{
INTF *p;
@synthesize sd = _sd;
@end
-void test_goto() {
+void test_goto(void) {
goto after; // expected-error {{cannot jump from this goto statement to its label}}
__weak id x; // expected-note {{jump bypasses initialization of __weak variable}}}
after:
// RUN: %clang_cc1 -fsyntax-only -verify %s
-void f() {
+void f(void) {
@throw @"Hello"; // expected-error {{cannot use '@throw' with Objective-C exceptions disabled}}
}
-void g() {
+void g(void) {
@try { // expected-error {{cannot use '@try' with Objective-C exceptions disabled}}
f();
} @finally {
// expected-no-diagnostics
// rdar://17259812
-typedef void (^BT) ();
+typedef void (^BT) (void);
-BT foo() __attribute__((ns_returns_retained));
+BT foo(void) __attribute__((ns_returns_retained));
@interface I
-BT foo() __attribute__((ns_returns_retained));
+BT foo(void) __attribute__((ns_returns_retained));
- (BT) Meth __attribute__((ns_returns_retained));
+ (BT) ClsMeth __attribute__((ns_returns_retained));
@end
@implementation I
-BT foo() __attribute__((ns_returns_retained)) {return ^{}; }
+BT foo(void) __attribute__((ns_returns_retained)) {return ^{}; }
- (BT) Meth {return ^{}; }
+ (BT) ClsMeth {return ^{}; }
@end
// <rdar://problem/10930507>
@property (nonatomic, retain) __attribute__((NSObject)) CGColorRefNoNSObject color; // // no-warning
@end
-void test_10453342() {
+void test_10453342(void) {
char* __attribute__((NSObject)) string2 = 0; // expected-warning {{'NSObject' attribute may be put on a typedef only; attribute is ignored}}
}
ip = foo.e; // expected-error{{incompatible type 'MultiProp *(^ _Nullable)(int)'}}
}
-void testBlockLiterals() {
+void testBlockLiterals(void) {
(void)(^id(void) { return 0; });
(void)(^id _Nullable (void) { return 0; });
(void)(^ _Nullable id(void) { return 0; });
[sc async_get:^(X *_Nullable rptr, NSError *err) {}];
}
-void test_conversion() {
+void test_conversion(void) {
X *_Nullable_result nr;
X *_Nonnull l = nr; // expected-warning{{implicit conversion from nullable pointer 'X * _Nullable_result' to non-nullable pointer type 'X * _Nonnull'}}
};
}
-void test_dup() {
+void test_dup(void) {
id _Nullable_result _Nullable_result a; // expected-warning {{duplicate nullability specifier _Nullable_result}}
id _Nullable _Nullable_result b; // expected-error{{nullability specifier _Nullable_result conflicts with existing specifier '_Nullable'}}
id _Nullable_result _Nonnull c; // expected-error{{nullability specifier '_Nonnull' conflicts with existing specifier _Nullable_result}}
typedef unsigned int NSUInteger;
#endif
-void checkNSArrayUnavailableDiagnostic() {
+void checkNSArrayUnavailableDiagnostic(void) {
id obj;
id arr = @[obj]; // expected-error {{definition of class NSArray must be available to use Objective-C array literals}}
}
@class NSArray; // expected-note {{forward declaration of class here}}
-void checkNSArrayFDDiagnostic() {
+void checkNSArrayFDDiagnostic(void) {
id obj;
id arr = @[obj]; // expected-error {{definition of class NSArray must be available to use Objective-C array literals}}
}
@end
-int main() {
+int main(void) {
NSArray *array = @[@"Hello", @"There", @"How Are You", [NSNumber numberWithInt:42]];
for (id string in array)
}
// rdar://14303083
-id Test14303083() {
+id Test14303083(void) {
id obj = @[ @"A", (@"B" @"C")];
return @[ @"A", @"B" @"C"]; // expected-warning {{concatenated NSString literal for an NSArray expression - possibly missing a comma}}
}
-id radar15147688() {
+id radar15147688(void) {
#define R15147688_A @"hello"
#define R15147688_B "world"
#define CONCATSTR R15147688_A R15147688_B
}
enum XXXYYYZZZType { XXXYYYZZZTypeAny }; // expected-note {{'XXXYYYZZZTypeAny' declared here}}
-void foo() {
+void foo(void) {
NSArray *array = @[
@(XXXYYYZZZTypeA), // expected-error {{use of undeclared identifier 'XXXYYYZZZTypeA'; did you mean 'XXXYYYZZZTypeAny'}}
@(XXXYYYZZZTypeSomethingSomething) // expected-error {{use of undeclared identifier 'XXXYYYZZZTypeSomethingSomething'}}
int dummy;
} BoxableUnion;
-void checkNSValueDiagnostic() {
+void checkNSValueDiagnostic(void) {
NSRect rect;
id value = @(rect); // expected-error{{definition of class NSValue must be available to use Objective-C boxed expressions}}
}
+ (NSValue *)valueWithBytes:(const void *)value objCType:(const char *)type;
@end
-int main() {
+int main(void) {
NSPoint ns_point;
id ns_point_value = @(ns_point);
id err = @(s); // expected-error{{illegal type 'SomeStruct' (aka 'struct _SomeStruct') used in a boxed expression}}
}
-CGRect getRect() {
+CGRect getRect(void) {
CGRect r;
return r;
}
-SomeStruct getSomeStruct() {
+SomeStruct getSomeStruct(void) {
SomeStruct s;
return s;
}
-void rvalue() {
+void rvalue(void) {
id rv_rect = @(getRect());
id rv_some_struct = @(getSomeStruct()); // expected-error {{illegal type 'SomeStruct' (aka 'struct _SomeStruct') used in a boxed expression}}
}
@implementation I
+ (void) _defaultMinSize { };
-static void _initCommon() {
+static void _initCommon(void) {
Class graphicClass;
[graphicClass _defaultMinSize];
}
@dynamic customGetterProperty;
@end
-int test() {
+int test(void) {
A *a = [[A alloc] init];
a.c; // expected-error {{property 'c' is a class property; did you mean to access it with class 'A'}}
return a.x + A.c;
}
-void customSelectors() {
+void customSelectors(void) {
A.customSetterProperty = 1;
(void)A.customGetterProperty;
}
@interface XNSMutableArray
@end
-int main() {
+int main(void) {
id array;
id oldObject = array[10]; // expected-warning {{instance method '-objectAtIndexedSubscript:' not found (return type defaults to 'id')}}
- (void)setObject:(id)object forKeyedSubscript:(size_t)key;
@end
-id func() {
+id func(void) {
NSMutableArray *array;
float f;
array[f] = array; // expected-error {{indexing expression is invalid because subscript type 'float' is not an integral or Objective-C pointer type}}
return array[3.14]; // expected-error {{indexing expression is invalid because subscript type 'double' is not an integral or Objective-C pointer type}}
}
-void test_unused() {
+void test_unused(void) {
NSMutableArray *array;
array[10]; // expected-warning {{container access result unused - container access should not be used for side effects}}
- (void)setObject:(int)object forKeyedSubscript:(id)key; // expected-note {{parameter of type 'int' is declared here}}
@end
-int main() {
+int main(void) {
Test *array;
int i = array[10]; // expected-error {{method for accessing array element must have Objective-C object return type instead of 'int'}}
array[2] = i; // expected-error {{cannot assign to this array because assigning method's 2nd parameter of type 'int' is not an Objective-C pointer type}}
@end
@interface I @end
-int main() {
+int main(void) {
NSMutableArray<P> * array;
id oldObject = array[10]; // expected-error {{method index parameter type 'double' is not integral type}}
array[3] = 0; // expected-error {{method index parameter type 'void *' is not integral type}} \
@end
@class NSString;
-void testDict() {
+void testDict(void) {
NSMutableDictionary *dictionary;
NSString *key;
id newObject, oldObject;
@end
-int main() {
+int main(void) {
Foo *foo;
[foo test:@"One", @"Two"];
[foo bad:@"One", @"Two"]; // expected-error {{too few arguments to method call}}
#define nil ((void *)0)
-void checkNSDictionaryUnavailableDiagnostic() {
+void checkNSDictionaryUnavailableDiagnostic(void) {
id key;
id value;
id dict = @{ key : value }; // expected-error {{definition of class NSDictionary must be available to use Objective-C dictionary literals}}
@class NSDictionary; // expected-note {{forward declaration of class here}}
-void checkNSDictionaryFDDiagnostic() {
+void checkNSDictionaryFDDiagnostic(void) {
id key;
id value;
id dic = @{ key : value }; // expected-error {{definition of class NSDictionary must be available to use Objective-C dictionary literals}}
@end
void *pvoid;
-int main() {
+int main(void) {
NSDictionary *dict = @{ @"name":@666 };
dict[@"name"] = @666;
}
enum XXXYYYZZZType { XXXYYYZZZTypeAny }; // expected-note {{'XXXYYYZZZTypeAny' declared here}}
-void foo() {
+void foo(void) {
NSDictionary *d = @{
@"A" : @(XXXYYYZZZTypeA), // expected-error {{use of undeclared identifier 'XXXYYYZZZTypeA'; did you mean 'XXXYYYZZZTypeAny'}}
@"F" : @(XXXYYYZZZTypeSomethingSomething), // expected-error {{use of undeclared identifier 'XXXYYYZZZTypeSomethingSomething'}}
NSObject *__attribute__((objc_independent_class)) ns; // expected-warning {{'objc_independent_class' attribute may be put on a typedef only; attribute is ignored}}
} __attribute__((objc_independent_class)) T;
-dispatch_queue_t dispatch_queue_create();
+dispatch_queue_t dispatch_queue_create(void);
@interface DispatchQPointerCastIssue : NSObject {
NSObject *__attribute__((objc_independent_class)) Ivar; // expected-warning {{'objc_independent_class' attribute may be put on a typedef only; attribute is ignored}}
}
@end
-NSObject *get_nsobject() {
+NSObject *get_nsobject(void) {
typedef NSObject * __attribute__((objc_independent_class))dispatch_queue_t;
dispatch_queue_t dt;
return dt;
+(instancetype)numberWithBool:(BOOL)value;
@end
-void test() {
+void test(void) {
NSNumber *n = YES; // expected-error{{numeric literal must be prefixed by '@'}}
NSNumber *n1 = 1; // expected-error{{numeric literal must be prefixed by '@'}}
typedef int NSInteger;
#endif
-void checkNSNumberUnavailableDiagnostic() {
+void checkNSNumberUnavailableDiagnostic(void) {
id num = @1000; // expected-error {{definition of class NSNumber must be available to use Objective-C numeric literals}}
int x = 1000;
@class NSNumber; // expected-note 2 {{forward declaration of class here}}
-void checkNSNumberFDDiagnostic() {
+void checkNSNumberFDDiagnostic(void) {
id num = @1000; // expected-error {{definition of class NSNumber must be available to use Objective-C numeric literals}}
int x = 1000;
// rdar://16417427
int big = 1391126400;
int thousand = 1000;
-int main() {
+int main(void) {
NSNumber * N = @3.1415926535; // expected-error {{declaration of 'numberWithDouble:' is missing in NSNumber class}}
NSNumber *noNumber = @__objc_yes; // expected-error {{declaration of 'numberWithBool:' is missing in NSNumber class}}
NSNumber * NInt = @1000;
// Dictionary test
@class NSDictionary; // expected-note {{forward declaration of class here}}
-NSDictionary *err() {
+NSDictionary *err(void) {
return @{@"name" : @"value"}; // expected-error {{definition of class NSDictionary must be available to use Objective-C dictionary literals}}
}
@interface NSString<NSCopying>
@end
-id NSUserName();
+id NSUserName(void);
-int Int();
+int Int(void);
-NSDictionary * blocks() {
+NSDictionary * blocks(void) {
return @{ @"task" : ^ { return 17; } };
}
-NSDictionary * warn() {
+NSDictionary * warn(void) {
NSDictionary *dictionary = @{@"name" : NSUserName(),
@"date" : [NSDate date],
@"name2" : @"other",
// rdar:// 11231426
typedef float BOOL;
-BOOL radar11231426() {
+BOOL radar11231426(void) {
return __objc_yes;
}
// and then used un-checked.
const char *getStr(void);
-void test_sig() {
+void test_sig(void) {
(void)@__objc_yes; // expected-error{{literal construction method 'numberWithBool:' has incompatible signature}}
(void)@__objc_yes; // expected-error{{literal construction method 'numberWithBool:' has incompatible signature}}
id array = @[ @17 ]; // expected-error{{literal construction method 'arrayWithObjects:count:' has incompatible signature}}
extern __strong id p1;
extern id p1;
-extern id CFRunLoopGetMain();
-extern __strong id CFRunLoopGetMain();
+extern id CFRunLoopGetMain(void);
+extern __strong id CFRunLoopGetMain(void);
-extern __weak id WLoopGetMain(); // expected-note {{previous declaration is here}}
-extern id WLoopGetMain(); // expected-error {{conflicting types for 'WLoopGetMain'}}
+extern __weak id WLoopGetMain(void); // expected-note {{previous declaration is here}}
+extern id WLoopGetMain(void); // expected-error {{conflicting types for 'WLoopGetMain'}}
extern id p3; // expected-note {{previous declaration is here}}
extern __weak id p3; // expected-error {{redeclaration of 'p3' with a different type}}
__weak id p; // expected-warning {{__weak attribute cannot be specified on a field declaration}}
};
-int main ()
+int main (void)
{
__weak id local; // expected-warning {{Objective-C GC does not allow weak variables on the stack}}
}
(void)(id<P1, P2, P3, P4, P5>)cf; // expected-warning {{'CFMyPersonalErrorRef' (aka 'struct __CFMyPersonalErrorRef *') bridges to MyPersonalError, not 'id<P1,P2,P3,P4,P5>'}}
}
-CFDictionaryRef bar() __attribute__((cf_returns_not_retained));
+CFDictionaryRef bar(void) __attribute__((cf_returns_not_retained));
@class NSNumber;
-void Test9() {
+void Test9(void) {
NSNumber *w2 = (NSNumber*) bar(); // expected-error {{CF object of type 'CFDictionaryRef' (aka 'struct __CFDictionary *') is bridged to 'NSDictionary', which is not an Objective-C class}}
}
+self;
@end
-static void func() {
+static void func(void) {
id x;
+self;
@end
-static void func() {
+static void func(void) {
id x;
[x testStr:"someStringLiteral"];
}
-id CreateSomething();
+id CreateSomething(void);
@interface TakesCFTypeRef
- (void) testCFTypeRef:(CFTypeRef)arg;
typedef typeArgs15<NSObject> typeArgsAndProtocolQuals6;
-void testSpecializedTypePrinting() {
+void testSpecializedTypePrinting(void) {
int *ip;
ip = (typeArgs15*)0; // expected-warning{{'typeArgs15 *' (aka 'PC1<NSObject *,NSString *> *')}}
}
@end
-void test2() {
+void test2(void) {
(void)@selector(inBase); // strict-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inBaseImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inBaseCat); // strict-warning{{@selector expression formed with potentially direct selector}}
@property id p4; // expected-warning {{no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed}}, expected-warning {{default property attribute 'assign' not appropriate for object}}
-@property(nonatomic,copy) int (^includeMailboxCondition)();
-@property(nonatomic,copy) int (*includeMailboxCondition2)(); // expected-error {{property with 'copy' attribute must be of object type}}
+@property(nonatomic,copy) int (^includeMailboxCondition)(void);
+@property(nonatomic,copy) int (*includeMailboxCondition2)(void); // expected-error {{property with 'copy' attribute must be of object type}}
@end
@interface I0()
@property (retain) int PROP; // expected-error {{property with 'retain (or strong)' attribute must be of object type}}
@property (strong) int SPROP; // expected-error {{property with 'retain (or strong)' attribute must be of object type}}
-@property(nonatomic,copy) int (*PROP1)(); // expected-error {{property with 'copy' attribute must be of object type}}
-@property(nonatomic,weak) int (*PROP2)(); // expected-error {{property with 'weak' attribute must be of object type}}
+@property(nonatomic,copy) int (*PROP1)(void); // expected-error {{property with 'copy' attribute must be of object type}}
+@property(nonatomic,weak) int (*PROP2)(void); // expected-error {{property with 'weak' attribute must be of object type}}
@end
// rdar://10357768
@end
void abort(void);
-int main ()
+int main (void)
{
Test *x = [[Test alloc] init];
/* 1. Test of a required property */
int i1, i2;
} NSRect;
-NSRect NSMakeRect();
+NSRect NSMakeRect(void);
@interface NSWindow
{
@synthesize index;
@end
-int main() {
+int main(void) {
AddressMyProperties *object;
&object.index; // expected-error {{address of property expression requested}}
return 0;
}
typedef int Foo;
-void test() {
+void test(void) {
Foo.x; // expected-error {{expected identifier or '('}}
}
@property (readonly) int bar;
@end
-void FUNC () {
+void FUNC (void) {
Foo *foo;
foo.bar = 0; // expected-error {{assignment to readonly property}}
}
@property NSSize size;
@end
-void foo() {
+void foo(void) {
Foo *f;
f.size.width = 2.2; // expected-error {{expression is not assignable}}
f.size.inner.dim = 200; // expected-error {{expression is not assignable}}
@property double bar;
@end
-int func1() {
+int func1(void) {
id foo;
double bar = [foo bar];
return 0;
@synthesize window; // expected-error {{missing context for property implementation declaration}}
// rdar://10408414
-Class test6_getClass();
+Class test6_getClass(void);
@interface Test6
@end
@implementation Test6
id <XProto> idX = 0; // expected-error {{'XProto' is unavailable}}
-int main ()
+int main (void)
{
MyClass1 <MyProto1> *p1; // expected-warning {{'MyProto1' is deprecated}}
}
@class cl;
-int main()
+int main(void)
{
Protocol *proto = @protocol(p1);
Protocol *fproto = @protocol(fproto);
@class cl;
-int main()
+int main(void)
{
Protocol *proto = @protocol(p1);
Protocol *fproto = @protocol(fproto); // expected-error {{@protocol is using a forward protocol declaration of 'fproto'}}
@end
-void func() {
+void func(void) {
NSObject <PWhatever, XCElementSpacerP> * flexer;
NSObject <PWhatever, XCElementP> * flexer2;
XX *obj;
@implementation UIWebPDFView
@end
-UIWebPDFView *getView()
+UIWebPDFView *getView(void)
{
UIWebBrowserView *browserView;
UIWebPDFView *pdfView;
// Test case for:
// <rdar://problem/6248119> @finally doesn't introduce a new scope
-void f0() {
+void f0(void) {
int i;
@try {
} @finally {
}
}
-void f1() {
+void f1(void) {
int i;
@try {
int i =0;
}
}
-void f2() {
+void f2(void) {
int i;
@try {
} @catch(id e) {
+ (Unrelated *)newUnrelated;
@end
-void test_inference() {
+void test_inference(void) {
// Inference based on method family
__typeof__(([[NSString alloc] init])) *str = (NSString**)0;
__typeof__(([[[[NSString new] self] retain] autorelease])) *str2 = (NSString **)0;
@interface AppDelegate
@end
-AppDelegate* GetDelegate()
+AppDelegate* GetDelegate(void)
{
return [NSApp delegate];
}
// RUN: %clang_cc1 -fsyntax-only -verify -Wmissing-noreturn -fobjc-exceptions -Wno-objc-root-class %s
-int test1() {
+int test1(void) {
id a;
@throw a;
}
// issue a noreturn warning.
@class NSException;
@class NSString;
-NSString *rdar_4289832() { // no-warning
+NSString *rdar_4289832(void) { // no-warning
@try
{
return @"a";
@class A, B, C;
-void test1() {
+void test1(void) {
goto L; // expected-error{{cannot jump}}
goto L2; // expected-error{{cannot jump}}
goto L3; // expected-error{{cannot jump}}
}
// rdar://6803963
-void test3() {
+void test3(void) {
@try {
goto blargh;
blargh: ;
- (id) compare: (id) arg1; // expected-note {{method 'compare:' declared here}}
@end
-SEL func()
+SEL func(void)
{
return @selector(compare:); // expected-warning {{several methods with selector 'compare:' of mismatched types are found for the @selector expression}}
}
// rdar://16458579
-void Test16458579() {
+void Test16458579(void) {
SEL s = @selector((retain));
SEL s1 = @selector((meth1:));
SEL s2 = @selector((retainArgument::));
SEL s7 = @selector((char:float:double:unsigned:short:long:));
SEL s9 = @selector((:enum:bool:));
}
-int main() {
+int main(void) {
SEL s = @selector(retain);
SEL s1 = @selector(meth1:);
SEL s2 = @selector(retainArgument::);
- length;
@end
-static inline SEL IsEmpty() {
+static inline SEL IsEmpty(void) {
return @selector(length);
}
- length;
@end
-SEL func()
+SEL func(void)
{
return @selector(length); // expected-warning {{no method with selector 'length' is implemented in this translation unit}}
}
}
@end
-void test16428638() {
+void test16428638(void) {
SEL s = @selector(compare:);
(void)s;
}
@end
#else
-int main() {
+int main(void) {
(void)@selector(compare:);
}
@end
-int main() {
+int main(void) {
id xx = [[Car alloc] init]; // expected-warning {{incompatible types assigning 'int' to 'id'}}
[xx method:4];
@interface MyClass : NSObject <MyProtocol>
@end
-int main ()
+int main (void)
{
id<MyProtocol> c;
c.level = 10;
@end
-void foo() {
+void foo(void) {
X *x = [X new];
signed int sint = -1;
[x setUint:sint]; // expected-warning {{implicit conversion changes signedness: 'int' to 'NSUInteger'}}
}
// rdar://13855682
-void Test1() {
+void Test1(void) {
signed int si = -1;
NSArray *array;
int i;
int *ptr;
-void t1() {
+void t1(void) {
b = boolean;
b = fl; // expected-warning {{implicit conversion from floating-point type 'float' to 'BOOL'}}
b = i; // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}}
@interface Foo @end
-int foo()
+int foo(void)
{
Foo *f;
+(id)new;
@end
-void foo() {
+void foo(void) {
[DEPRECATED new]; // expected-warning {{'DEPRECATED' is deprecated}}
}
current *pc;
-int foo()
+int foo(void)
{
return pc->ivar2 + (*pc).ivar + pc->ivar1;
}
}
@end
-void f0() {
+void f0(void) {
// FIXME: not implemented yet.
//int l1 = A.classGetter;
int l2 = [A classGetter2];
typedef Foo FooTD;
-void test() {
+void test(void) {
[FooTD cMethod];
[super cMethod];
}
int X;
};
-int test2() {
+int test2(void) {
struct SomeStruct super = { 0 };
return super.X;
}
-int test3() {
+int test3(void) {
id super = 0;
[(B*)super instanceMethod];
int *s1 = (int*)super;
struct x { int a; } b;
-void test1() {
+void test1(void) {
@synchronized (b) { // expected-error {{@synchronized requires an Objective-C object type ('struct x' invalid)}}
}
@property(assign) BOOL isAppleInternal;
@end
-static BOOL isAppleInternal() {return 0; }
+static BOOL isAppleInternal(void) {return 0; }
@implementation MailApp
void takesNonNull(NSString * _Nonnull ptr);
-void testBoxedString() {
+void testBoxedString(void) {
// No diagnostic emitted as this doesn't need a stringWithUTF8String message
// send.
takesNonNull(@("hey"));
} // FIXME: This should warn about a missing return too.
@end
-int foo() {
+int foo(void) {
struct s { int a, b; } agg, *pagg;
@throw 42; // expected-error {{@throw requires an Objective-C object type ('int' invalid)}}
@class NSString;
extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
-int main() {
+int main(void) {
NSLog(@"Hi…");
NSLog(@"Exposé");
NSLog(@"\U00010400\U0001D12B");
#define AVAILABLE_CURRENT __attribute__((availability(macCatalyst, introduced = 14)))
#define AVAILABLE_NEXT __attribute__((availability(macCatalyst, introduced = 14.1)))
-void previouslyAvailable() AVAILABLE_PREV;
-void currentlyAvailable() AVAILABLE_CURRENT;
-void willBeAvailabile() AVAILABLE_NEXT;
+void previouslyAvailable(void) AVAILABLE_PREV;
+void currentlyAvailable(void) AVAILABLE_CURRENT;
+void willBeAvailabile(void) AVAILABLE_NEXT;
#ifndef NO_WARNING
// expected-note@-2 {{'willBeAvailabile' has been marked as being introduced in macCatalyst 14.1 here, but the deployment target is macCatalyst 14}}
#endif
AVAILABLE_NEXT
Record var2;
-void test() {
+void test(void) {
previouslyAvailable();
currentlyAvailable();
willBeAvailabile();
willBeAvailabile(); // OK
}
-void previouslyAvailableIOS() __attribute__((availability(ios, introduced = 10)));
-void currentlyAvailableIOS() __attribute__((availability(ios, introduced = 14)));
-void willBeAvailabileIOS() __attribute__((availability(ios, introduced = 14.1)));
+void previouslyAvailableIOS(void) __attribute__((availability(ios, introduced = 10)));
+void currentlyAvailableIOS(void) __attribute__((availability(ios, introduced = 14)));
+void willBeAvailabileIOS(void) __attribute__((availability(ios, introduced = 14.1)));
#ifndef NO_WARNING
// expected-note@-2 {{'willBeAvailabileIOS' has been marked as being introduced in macCatalyst 14.1 here, but the deployment target is macCatalyst 14}}
#endif
-void testIOSAvailabilityAlsoWorks() {
+void testIOSAvailabilityAlsoWorks(void) {
previouslyAvailableIOS();
currentlyAvailableIOS();
willBeAvailabileIOS();
#define AVAILABLE_NEXT __attribute__((availability(watchos, introduced = 5)))
#endif
-void previouslyAvailable() AVAILABLE_PREV;
+void previouslyAvailable(void) AVAILABLE_PREV;
#ifdef WARN_PREV
// expected-note@-2 {{'previouslyAvailable' has been marked as being introduced}}
#endif
-void currentlyAvailable() AVAILABLE_CURRENT;
+void currentlyAvailable(void) AVAILABLE_CURRENT;
#ifdef WARN_CURRENT
// expected-note@-2 {{'currentlyAvailable' has been marked as being introduced}}
#endif
-void willBeAvailabile() AVAILABLE_NEXT;
+void willBeAvailabile(void) AVAILABLE_NEXT;
#ifndef NO_WARNING
// expected-note@-2 {{'willBeAvailabile' has been marked as being introduced in}}
#endif
#endif
#endif
-void test() FUNC_AVAILABLE {
+void test(void) FUNC_AVAILABLE {
previouslyAvailable();
#ifdef WARN_PREV
#ifdef MAC
typedef int AVAILABLE_10_12 new_int; // expected-note + {{'new_int' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9}}
-int func_10_11() AVAILABLE_10_11; // expected-note 8 {{'func_10_11' has been marked as being introduced in macOS 10.11 here, but the deployment target is macOS 10.9}}
+int func_10_11(void) AVAILABLE_10_11; // expected-note 8 {{'func_10_11' has been marked as being introduced in macOS 10.11 here, but the deployment target is macOS 10.9}}
#ifdef OBJCPP
// expected-note@+2 6 {{'func_10_12' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9}}
#endif
-int func_10_12() AVAILABLE_10_12; // expected-note 7 {{'func_10_12' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9}}
+int func_10_12(void) AVAILABLE_10_12; // expected-note 7 {{'func_10_12' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9}}
-int func_10_0() AVAILABLE_10_0;
+int func_10_0(void) AVAILABLE_10_0;
-void use_func() {
+void use_func(void) {
func_10_11(); // expected-warning{{'func_10_11' is only available on macOS 10.11 or newer}} expected-note{{enclose 'func_10_11' in an @available check to silence this warning}}
if (@available(macos 10.11, *))
func_10_11(); // expected-warning{{'func_10_11' is only available on macOS 10.11 or newer}} expected-note{{enclose 'func_10_11' in an @available check to silence this warning}}
}
-void defn_10_11() AVAILABLE_10_11;
+void defn_10_11(void) AVAILABLE_10_11;
-void defn_10_11() {
+void defn_10_11(void) {
func_10_11();
}
-void nested_ifs() {
+void nested_ifs(void) {
if (@available(macos 10.12, *)) {
if (@available(macos 10.10, *)) {
func_10_12();
}
}
-void star_case() {
+void star_case(void) {
if (@available(ios 9, *)) {
func_10_11(); // expected-warning{{'func_10_11' is only available on macOS 10.11 or newer}} expected-note{{enclose 'func_10_11' in an @available check to silence this warning}}
func_10_0();
#endif
typedef int int_10_12 AVAILABLE_10_12; // expected-note 2 {{'int_10_12' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9}}
-void use_typedef() {
+void use_typedef(void) {
int_10_11 x; // expected-warning{{'int_10_11' is only available on macOS 10.11 or newer}} expected-note{{enclose 'int_10_11' in an @available check to silence this warning}}
}
@end
-int protected_scope() {
+int protected_scope(void) {
if (@available(macos 10.20, *)) { // expected-note 2 {{jump enters controlled statement of if available}}
label1:
return 0;
} n;
};
-int test_members() {
+int test_members(void) {
struct S s;
(void)s.m1;
(void)s.m2; // expected-warning{{'m2' is only available on macOS 10.12 or newer}} expected-note{{@available}}
(void)s.n.nested_member; // expected-warning{{'nested_member' is only available on macOS 10.12 or newer}} expected-note{{@available}}
}
-void test_blocks() {
+void test_blocks(void) {
(void) ^{
func_10_12(); // expected-warning{{'func_10_12' is only available on macOS 10.12 or newer}} expected-note{{@available}}
};
void test_params2(int_10_12 x) AVAILABLE_10_12; // no warn
-void (^topLevelBlockDecl)() = ^ {
+void (^topLevelBlockDecl)(void) = ^ {
func_10_12(); // expected-warning{{'func_10_12' is only available on macOS 10.12 or newer}} expected-note{{@available}}
if (@available(macos 10.12, *))
func_10_12();
id y = x[42]; // expected-warning{{'objectAtIndexedSubscript:' is only available on macOS 10.12 or newer}} expected-note{{@available}}
}
-void uncheckAtAvailable() {
+void uncheckAtAvailable(void) {
if (@available(macOS 10.12, *) || 0) // expected-warning {{@available does not guard availability here; use if (@available) instead}}
func_10_12(); // expected-warning {{'func_10_12' is only available on macOS 10.12 or newer}}
// expected-note@-1 {{enclose 'func_10_12' in an @available check to silence this warning}}
}
-void justAtAvailable() {
+void justAtAvailable(void) {
int availability = @available(macOS 10.12, *); // expected-warning {{@available does not guard availability here; use if (@available) instead}}
}
@property (class) new_int x; // expected-warning{{'new_int' is only available}}
@end
-void with_local_struct() {
+void with_local_struct(void) {
struct local {
new_int x; // expected-warning{{'new_int' is only available}} expected-note{{enclose 'new_int' in an @available check}}
};
@end
__attribute__((constructor))
-void is_constructor();
+void is_constructor(void);
AVAILABLE_10_11 // expected-warning{{ignoring availability attribute with constructor attribute}}
-void is_constructor() {
+void is_constructor(void) {
func_10_11(); // expected-warning{{'func_10_11' is only available on macOS 10.11 or newer}} expected-note{{enclose 'func_10_11' in an @available check to silence this warning}}
}
AVAILABLE_10_11 // expected-warning{{ignoring availability attribute with destructor attribute}}
__attribute__((destructor))
-void is_destructor() {
+void is_destructor(void) {
func_10_11(); // expected-warning{{'func_10_11' is only available on macOS 10.11 or newer}} expected-note{{enclose 'func_10_11' in an @available check to silence this warning}}
}
// Duplicated from uninit-variables.c.
// Test just to ensure the analysis is working.
-int test1() {
+int test1(void) {
int x; // expected-note{{initialize the variable 'x' to silence this warning}}
return x; // expected-warning{{variable 'x' is uninitialized when used here}}
}
// Test ObjC fast enumeration.
-void test2() {
+void test2(void) {
id collection = 0;
for (id obj in collection) {
if (0 == obj) // no-warning
}
}
-void test3() {
+void test3(void) {
id collection = 0;
id obj;
for (obj in collection) { // no-warning
// RUN: %clang_cc1 -funknown-anytype -fsyntax-only -fdebugger-support -verify %s
extern __unknown_anytype test0;
-extern __unknown_anytype test1();
+extern __unknown_anytype test1(void);
@interface A
- (int*)getIntPtr;
- (short*)getSomePtr;
@end
-void test_unknown_anytype_receiver() {
+void test_unknown_anytype_receiver(void) {
int *ip = [test0 getIntPtr];
float *fp = [test1() getFloatPtr];
double *dp = [test1() getSomePtr]; // okay: picks first method found
void functionTakingAClassConformingToAProtocol(AClass <Fooable> *instance) { // expected-note {{passing argument to parameter 'instance' here}}
}
-int main () {
+int main (void) {
AClass *aobject = 0;
BClass *bobject = 0;
functionTakingAClassConformingToAProtocol(aobject); // expected-warning {{incompatible pointer types passing 'AClass *' to parameter of type 'AClass<Fooable> *'}}
- (int)length;
@end
-void test2() {
+void test2(void) {
@"pointless example call for test purposes".length; // expected-warning {{property access result unused - getters should not be used for side effects}}
}
SEL sel_registerName(const char *);
-int main() {
+int main(void) {
(char *)s; // expected-warning {{cast of type 'SEL' to 'char *' is deprecated; use sel_getName instead}}
(void *)s; // ok
(const char *)sel_registerName("foo"); // expected-warning {{cast of type 'SEL' to 'const char *' is deprecated; use sel_getName instead}}
- (void) dealloc { _myLeader = 0; }
@end
-MyObject * foo ()
+MyObject * foo (void)
{
MyObject* p=0;
p.isTickledPink = p.myLeader; // ok
- (void)foo:(Class)class; // expected-note{{passing argument to parameter 'class' here}}
@end
-void FUNC() {
+void FUNC(void) {
Class c, c1;
SEL s1, s2;
id i, i1;
// Do not warn on objc classes has objectAtIndexedSubscript method.
MyArray *test;
-void foo()
+void foo(void)
{
unsigned int i;
for (i = 42; i > 0;) // No warnings here
// RUN: not %clang_cc1 -fsyntax-only -fblocks -Wno-objc-root-class %s 2>&1 | FileCheck %s
// rdar://11761511
-extern void doSomething();
+extern void doSomething(void);
@interface Test
{
@dynamic aBlockW, aBlockS, aBlockR, aBlockC, aBlockA;
@end
-int main() {
+int main(void) {
Test *t;
t.aBlock = ^{ doSomething(); };
t.aBlockW = ^{ doSomething(); };
@end
-void testBlockVariable() {
+void testBlockVariable(void) {
typedef void (^block_t)(void);
// This case will be caught by -Wuninitialized, and does not create a
-(float) method; // expected-note {{also found}}
@end
-int main() { [(id)0 method]; } // expected-warning {{multiple methods named 'method' found}}
+int main(void) { [(id)0 method]; } // expected-warning {{multiple methods named 'method' found}}
@interface Object @end
// This previously triggered a warning from -Wunreachable-code because of
// a busted CFG.
typedef signed char BOOL;
-BOOL radar10989084() {
+BOOL radar10989084(void) {
@autoreleasepool { // no-warning
return __objc_yes;
}
}
// Test the warning works.
-void test_unreachable() {
+void test_unreachable(void) {
return;
return; // expected-warning {{will never be executed}}
}
#define CONFIG NO
// Test that 'NO' and 'YES' are not treated as configuration macros.
-int test_NO() {
+int test_NO(void) {
if (NO)
return 1; // expected-warning {{will never be executed}}
else
return 0;
}
-int test_YES() {
+int test_YES(void) {
if (YES)
return 1;
else
return 0; // expected-warning {{will never be executed}}
}
-int test_CONFIG() {
+int test_CONFIG(void) {
if (CONFIG)
return 1;
else
}
}
-void calledFun() {}
+void calledFun(void) {}
// Test "silencing" with parentheses.
void test_with_paren_silencing(int x) {
// RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions -Wunused-exception-parameter %s
-void f0() {
+void f0(void) {
@try {} @catch(id a) {} // expected-warning{{unused exception parameter 'a'}}
}
- (void) foo { w = 0; LHS = w; }
@end
-int main ()
+int main (void)
{
struct I {
__weak id w1; // expected-warning {{__weak attribute cannot be specified on a field declaration}}