Use functions with prototypes when appropriate; NFC

A significant number of our tests in C accidentally use functions
without prototypes. This patch converts the function signatures to have
a prototype for the situations where the test is not specific to K&R C
declarations. e.g.,

  void func();

becomes

  void func(void);

This is the second batch of tests being updated (there are a significant
number of other tests left to be updated).
This commit is contained in:
Aaron Ballman 2022-02-04 15:19:56 -05:00
parent eeb29c8477
commit 8c5edb59cf
138 changed files with 492 additions and 487 deletions

View File

@ -1,6 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// PR 1603
void func()
void func(void)
{
const int *arr;
arr[0] = 1; // expected-error {{read-only variable is not assignable}}
@ -11,7 +11,7 @@ struct foo {
};
struct foo sfoo = { 0 };
int func2()
int func2(void)
{
const struct foo *fp;
fp = &sfoo;

View File

@ -1,5 +1,5 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -verify %s
void g() {}
void g(void) {}
void f() __attribute__((alias("g"))); //expected-error {{aliases are not supported on darwin}}
void f(void) __attribute__((alias("g"))); //expected-error {{aliases are not supported on darwin}}

View File

@ -28,6 +28,6 @@ void test7(int a) {
__builtin_alloca_with_align(a, 2); // expected-error {{requested alignment must be 8 or greater}}
}
void test8() {
void test8(void) {
__builtin_alloca_with_align(sizeof(__INT64_TYPE__), __alignof__(__INT64_TYPE__)); // expected-warning {{second argument to __builtin_alloca_with_align is supposed to be in bits}}
}

View File

@ -5,9 +5,9 @@ struct {
int f2;
} tmp = {};
unsigned invalid1() { return __builtin_btf_type_id(1, tmp); } // expected-error {{__builtin_btf_type_id argument 2 not a constant}}
unsigned invalid2() { return __builtin_btf_type_id(1, 1, 1); } // expected-error {{too many arguments to function call, expected 2, have 3}}
unsigned invalid1(void) { return __builtin_btf_type_id(1, tmp); } // expected-error {{__builtin_btf_type_id argument 2 not a constant}}
unsigned invalid2(void) { return __builtin_btf_type_id(1, 1, 1); } // expected-error {{too many arguments to function call, expected 2, have 3}}
int valid1() { return __builtin_btf_type_id(tmp, 0); }
int valid2() { return __builtin_btf_type_id(&tmp, 1); }
int valid3() { return __builtin_btf_type_id(tmp.f1[4], 10); }
int valid1(void) { return __builtin_btf_type_id(tmp, 0); }
int valid2(void) { return __builtin_btf_type_id(&tmp, 1); }
int valid3(void) { return __builtin_btf_type_id(tmp.f1[4], 10); }

View File

@ -14,18 +14,18 @@ enum gcc_type_class {
lang_type_class
};
void foo() {
void foo(void) {
int i;
char c;
enum { red, green, blue } enum_obj;
int *p;
double d;
_Complex double cc;
extern void f();
extern void f(void);
struct { int a; float b; } s_obj;
union { int a; float b; } u_obj;
int arr[10];
int (^block)();
int (^block)(void);
__attribute__((vector_size(16))) int vec;
typedef __attribute__((ext_vector_type(4))) int evec_t;
evec_t evec;
@ -55,5 +55,5 @@ void foo() {
int a19[__builtin_classify_type(complex_d) == complex_type_class ? 1 : -1];
}
extern int (^p)();
extern int (^p)(void);
int n = __builtin_classify_type(p);

View File

@ -5,7 +5,7 @@ extern void a(const char *);
extern const char *str;
int main() {
int main(void) {
#ifdef __x86_64__
if (__builtin_cpu_supports("ss")) // expected-error {{invalid cpu feature string}}
a("sse4.2");

View File

@ -10,19 +10,19 @@
int a[10];
int f0() {
int f0(void) {
return OBJECT_SIZE_BUILTIN(&a); // expected-error {{too few arguments to function}}
}
int f1() {
int f1(void) {
return (OBJECT_SIZE_BUILTIN(&a, 0) +
OBJECT_SIZE_BUILTIN(&a, 1) +
OBJECT_SIZE_BUILTIN(&a, 2) +
OBJECT_SIZE_BUILTIN(&a, 3));
}
int f2() {
int f2(void) {
return OBJECT_SIZE_BUILTIN(&a, -1); // expected-error {{argument value -1 is outside the valid range [0, 3]}}
}
int f3() {
int f3(void) {
return OBJECT_SIZE_BUILTIN(&a, 4); // expected-error {{argument value 4 is outside the valid range [0, 3]}}
}
@ -84,7 +84,7 @@ int pr28314(void) {
return a;
}
int pr31843() {
int pr31843(void) {
int n = 0;
struct { int f; } a;

View File

@ -1,6 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
void foo() {
void foo(void) {
int a;
__builtin_prefetch(&a);
__builtin_prefetch(&a, 1);

View File

@ -31,7 +31,7 @@ extern int setjmp(long); // OK, right type.
typedef int *jmp_buf;
#endif
void use() {
void use(void) {
setjmp(0);
#if NO_SETJMP
// cxx-error@-2 {{undeclared identifier 'setjmp'}}
@ -60,7 +60,7 @@ int _setjmp(void *, void *);
// c-warning@-2 {{incompatible redeclaration of library function '_setjmp'}}
// c-note@-3 {{'_setjmp' is a builtin with type 'int (jmp_buf)'}}
#endif
void use_mingw() {
void use_mingw(void) {
_setjmp(0, 0);
}

View File

@ -1,6 +1,6 @@
// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic
void check(int);
void a() {
void a(void) {
check(__builtin_isfinite(1.0f));
check(__builtin_isinf(1.0));
check(__builtin_isinf_sign(1.0L));

View File

@ -15,7 +15,7 @@ void test_clear_cache_voids(void *start, void *end) {
__clear_cache(start, end);
}
void test_clear_cache_no_args() {
void test_clear_cache_no_args(void) {
// AArch32 version of this is variadic (at least syntactically).
// However, on AArch64 GCC does not permit this call and the
// implementation I've seen would go disastrously wrong.

View File

@ -106,7 +106,7 @@ int test_stlex(char *addr) {
return res;
}
void test_clrex() {
void test_clrex(void) {
__builtin_arm_clrex();
__builtin_arm_clrex(1); // expected-error {{too many arguments to function call}}
}

View File

@ -15,37 +15,37 @@ void __clear_cache(void*, void*);
#if defined(__ARM_PCS) || defined(__ARM_EABI__)
// va_list on ARM AAPCS is struct { void* __ap }.
void test1() {
void test1(void) {
__builtin_va_list ptr;
ptr.__ap = "x";
*(ptr.__ap) = '0'; // expected-error {{incomplete type 'void' is not assignable}}
}
#else
// va_list on ARM apcs-gnu is void*.
void test1() {
void test1(void) {
__builtin_va_list ptr;
ptr.__ap = "x"; // expected-error {{member reference base type '__builtin_va_list' is not a structure or union}}
*(ptr.__ap) = '0';// expected-error {{member reference base type '__builtin_va_list' is not a structure or union}}
}
void test2() {
void test2(void) {
__builtin_va_list ptr = "x";
*ptr = '0'; // expected-error {{incomplete type 'void' is not assignable}}
}
#endif
void test3() {
void test3(void) {
__builtin_arm_dsb(16); // expected-error-re {{argument value {{.*}} is outside the valid range}}
__builtin_arm_dmb(17); // expected-error-re {{argument value {{.*}} is outside the valid range}}
__builtin_arm_isb(18); // expected-error-re {{argument value {{.*}} is outside the valid range}}
}
void test4() {
void test4(void) {
__builtin_arm_prefetch(0, 2, 0); // expected-error-re {{argument value {{.*}} is outside the valid range}}
__builtin_arm_prefetch(0, 0, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}
}
void test5() {
void test5(void) {
__builtin_arm_dbg(16); // expected-error-re {{argument value {{.*}} is outside the valid range}}
}

View File

@ -102,7 +102,7 @@ int test_stlex(char *addr) {
return res;
}
void test_clrex() {
void test_clrex(void) {
__builtin_arm_clrex();
__builtin_arm_clrex(1); // expected-error {{too many arguments to function call}}
}

View File

@ -78,7 +78,7 @@ unsigned exclude_tag2(int *ptr, int *m) {
return __arm_mte_exclude_tag(ptr, m);
}
void get_tag1() {
void get_tag1(void) {
// expected-error@+1 {{too few arguments to function call, expected 1, have 0}}
__arm_mte_get_tag();
}
@ -98,7 +98,7 @@ int *get_tag3(const volatile int *ptr) {
#endif
}
void set_tag1() {
void set_tag1(void) {
// expected-error@+1 {{too few arguments to function call, expected 1, have 0}}
__arm_mte_set_tag();
}

View File

@ -13,17 +13,17 @@ void test_clear_cache_voids(void *start, void *end) {
__clear_cache(start, end);
}
void test_clear_cache_no_args() {
void test_clear_cache_no_args(void) {
__clear_cache(); // expected-error {{too few arguments to function call}}
}
void test_memory_barriers() {
void test_memory_barriers(void) {
__builtin_arm_dmb(16); // expected-error-re {{argument value {{.*}} is outside the valid range}}
__builtin_arm_dsb(17); // expected-error-re {{argument value {{.*}} is outside the valid range}}
__builtin_arm_isb(18); // expected-error-re {{argument value {{.*}} is outside the valid range}}
}
void test_prefetch() {
void test_prefetch(void) {
__builtin_arm_prefetch(0, 2, 0, 0, 0); // expected-error-re {{argument value {{.*}} is outside the valid range}}
__builtin_arm_prefetch(0, 0, 3, 0, 0); // expected-error-re {{argument value {{.*}} is outside the valid range}}
__builtin_arm_prefetch(0, 0, 0, 2, 0); // expected-error-re {{argument value {{.*}} is outside the valid range}}

View File

@ -68,34 +68,34 @@ unsigned invalid11(struct s *arg, int info_kind) {
return __builtin_preserve_field_info(arg->a, info_kind); // expected-error {{__builtin_preserve_field_info argument 2 not a constant}}
}
unsigned valid12() {
unsigned valid12(void) {
const struct s t;
return __builtin_preserve_type_info(t, 0) +
__builtin_preserve_type_info(*(struct s *)0, 1);
}
unsigned valid13() {
unsigned valid13(void) {
__t t;
return __builtin_preserve_type_info(t, 1) +
__builtin_preserve_type_info(*(__t *)0, 0);
}
unsigned valid14() {
unsigned valid14(void) {
enum AA t;
return __builtin_preserve_type_info(t, 0) +
__builtin_preserve_type_info(*(enum AA *)0, 1);
}
unsigned valid15() {
unsigned valid15(void) {
return __builtin_preserve_enum_value(*(enum AA *)VAL1, 1) +
__builtin_preserve_enum_value(*(enum AA *)VAL2, 1);
}
unsigned invalid16() {
unsigned invalid16(void) {
return __builtin_preserve_enum_value(*(enum AA *)0, 1); // expected-error {{__builtin_preserve_enum_value argument 1 invalid}}
}
unsigned invalid17() {
unsigned invalid17(void) {
return __builtin_preserve_enum_value(*(enum AA *)VAL10, 1); // expected-error {{__builtin_preserve_enum_value argument 1 invalid}}
}

View File

@ -3,7 +3,7 @@
#include <intrin.h>
void check__getReg() {
void check__getReg(void) {
__getReg(-1); // expected-error-re {{argument value {{.*}} is outside the valid range}}
__getReg(32); // expected-error-re {{argument value {{.*}} is outside the valid range}}
}

View File

@ -1,7 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// expected-no-diagnostics
void test() {
void test(void) {
int z[1];
__builtin_add_overflow(1, 1, z);
}

View File

@ -24,7 +24,7 @@ int test6(float a, long double b) {
#define CFSTR __builtin___CFStringMakeConstantString
void test7() {
void test7(void) {
const void *X;
X = CFSTR("\242"); // expected-warning {{input conversion stopped}}
X = CFSTR("\0"); // no-warning
@ -101,12 +101,12 @@ void test_unknown_builtin(int a, int b) {
// expected-note{{did you mean '__builtin_isless'?}}
}
int test13() {
int test13(void) {
__builtin_eh_return(0, 0); // no warning, eh_return never returns.
}
// <rdar://problem/8228293>
void test14() {
void test14(void) {
int old;
old = __sync_fetch_and_min((volatile int *)&old, 1);
}
@ -117,7 +117,7 @@ void test15(const char *s) {
}
// PR7885
int test16() {
int test16(void) {
return __builtin_constant_p() + // expected-error{{too few arguments}}
__builtin_constant_p(1, 2); // expected-error {{too many arguments}}
}
@ -140,7 +140,7 @@ enum Enum { EnumValue1, EnumValue2 };
typedef __typeof(sizeof(int)) size_t;
size_t strlen(const char *);
void test17() {
void test17(void) {
#define ASSERT(...) { enum { folded = (__VA_ARGS__) }; int arr[folded ? 1 : -1]; }
#define T(...) ASSERT(__builtin_constant_p(__VA_ARGS__))
#define F(...) ASSERT(!__builtin_constant_p(__VA_ARGS__))
@ -191,7 +191,7 @@ void test17() {
#undef F
}
void test18() {
void test18(void) {
char src[1024];
char dst[2048];
size_t result;
@ -206,13 +206,13 @@ void test18() {
ptr = __builtin___strlcat_chk(dst, src, sizeof(dst), sizeof(dst)); // expected-warning {{incompatible integer to pointer conversion}}
}
void no_ms_builtins() {
void no_ms_builtins(void) {
__assume(1); // expected-warning {{implicit declaration}}
__noop(1); // expected-warning {{implicit declaration}}
__debugbreak(); // expected-warning {{implicit declaration}}
}
void unavailable() {
void unavailable(void) {
__builtin_operator_new(0); // expected-error {{'__builtin_operator_new' is only available in C++}}
__builtin_operator_delete(0); // expected-error {{'__builtin_operator_delete' is only available in C++}}
}
@ -348,7 +348,7 @@ void test22(void) {
#define memcpy(x,y,z) __builtin___memcpy_chk(x,y,z, __builtin_object_size(x,0))
#define my_memcpy(x,y,z) __builtin___memcpy_chk(x,y,z, __builtin_object_size(x,0))
void test23() {
void test23(void) {
char src[1024];
char buf[10];
memcpy(buf, src, 11); // expected-warning{{'memcpy' will always overflow; destination buffer has size 10, but size argument is 11}}
@ -356,12 +356,12 @@ void test23() {
}
// Test that __builtin_is_constant_evaluated() is not allowed in C
int test_cxx_builtin() {
int test_cxx_builtin(void) {
// expected-error@+1 {{use of unknown builtin '__builtin_is_constant_evaluated'}}
return __builtin_is_constant_evaluated();
}
void test_builtin_complex() {
void test_builtin_complex(void) {
__builtin_complex(); // expected-error {{too few}}
__builtin_complex(1); // expected-error {{too few}}
__builtin_complex(1, 2, 3); // expected-error {{too many}}

View File

@ -1,8 +1,8 @@
// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s
void f();
void f(void);
void g() {
void g(void) {
__builtin_call_with_static_chain(f(), f);
__builtin_call_with_static_chain(f, f); // expected-error {{first argument to __builtin_call_with_static_chain must be a non-member call expression}}
__builtin_call_with_static_chain(^{}(), f); // expected-error {{first argument to __builtin_call_with_static_chain must not be a block call}}

View File

@ -29,7 +29,7 @@ void WINAPI mismatched_stdcall(int x) {}
void take_opaque_fn(void (*callback)(int));
int main() {
int main(void) {
// expected-warning@+1 {{cast between incompatible calling conventions 'cdecl' and 'stdcall'}}
take_callback((callback_t)mismatched);

View File

@ -1,6 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s -fblocks
void test_gotos() {
void test_gotos(void) {
goto L1; // expected-error {{use of undeclared label 'L1'}}
goto L3; // OK
#pragma clang __debug captured
@ -13,7 +13,7 @@ L2:
L3: ;
}
void test_break_continue() {
void test_break_continue(void) {
while (1) {
#pragma clang __debug captured
{
@ -23,7 +23,7 @@ void test_break_continue() {
}
}
void test_return() {
void test_return(void) {
while (1) {
#pragma clang __debug captured
{
@ -32,7 +32,7 @@ void test_return() {
}
}
void test_nest() {
void test_nest(void) {
int x;
#pragma clang __debug captured
{
@ -48,7 +48,7 @@ void test_nest() {
}
}
void test_nest_block() {
void test_nest_block(void) {
__block int x; // expected-note {{'x' declared here}}
int y;
^{

View File

@ -5,7 +5,7 @@ enum x; // expected-note {{forward declaration}}
extern struct y a; // expected-note {{forward declaration}}
extern union z b; // expected-note 2 {{forward declaration}}
void foo() {
void foo(void) {
(enum x)1; // expected-error {{cast to incomplete type}}
(struct y)a; // expected-error {{cast to incomplete type}}
(union z)b; // expected-error {{cast to incomplete type}}

View File

@ -2,10 +2,10 @@
typedef struct { unsigned long bits[(((1) + (64) - 1) / (64))]; } cpumask_t;
cpumask_t x;
void foo() {
void foo(void) {
(void)x;
}
void bar() {
void bar(void) {
char* a;
double b;
b = (double)a; // expected-error {{pointer cannot be cast to type}}
@ -183,7 +183,7 @@ void *intToPointerCast2(X x) {
return (void*)x;
}
void *intToPointerCast3() {
void *intToPointerCast3(void) {
return (void*)(1 + 3);
}

View File

@ -3,7 +3,7 @@
int printf(const char *, ...);
typedef int *pint;
int main() {
int main(void) {
int a[5] = {0};
pint p = a;
p++;

View File

@ -262,7 +262,7 @@ int test2(int i32) {
}
// PR5887
void test3() {
void test3(void) {
unsigned short x, y;
unsigned int z;
if ((x > y ? x : y) > z)
@ -271,7 +271,7 @@ void test3() {
// PR5961
extern char *ptr4;
void test4() {
void test4(void) {
long value;
if (value < (unsigned long) &ptr4) // expected-warning {{comparison of integers of different signs}}
return;
@ -320,7 +320,7 @@ int rdar8414119_bar(unsigned x) {
#undef ZERO
#undef CHECK
int rdar8511238() {
int rdar8511238(void) {
enum A { A_foo, A_bar };
enum A a;

View File

@ -4,7 +4,7 @@
int incomplete[]; // expected-warning {{tentative array definition assumed to have one element}}
int complete[6];
int test_comparison_between_incomplete_and_complete_pointer() {
int test_comparison_between_incomplete_and_complete_pointer(void) {
return (&incomplete < &complete) && // expected-warning {{pointer comparisons before C11 need to be between two complete or two incomplete types; 'int (*)[]' is incomplete and 'int (*)[6]' is complete}}
(&incomplete <= &complete) && // expected-warning {{pointer comparisons before C11 need to be between two complete or two incomplete types; 'int (*)[]' is incomplete and 'int (*)[6]' is complete}}
(&incomplete > &complete) && // expected-warning {{pointer comparisons before C11 need to be between two complete or two incomplete types; 'int (*)[]' is incomplete and 'int (*)[6]' is complete}}

View File

@ -1,27 +1,27 @@
// RUN: %clang_cc1 -verify %s
void f1() {
void f1(void) {
int a = 1;
int b = __imag a;
int *c = &__real a;
int *d = &__imag a; // expected-error {{cannot take the address of an rvalue of type 'int'}}
}
void f2() {
void f2(void) {
_Complex int a = 1;
int b = __imag a;
int *c = &__real a;
int *d = &__imag a;
}
void f3() {
void f3(void) {
double a = 1;
double b = __imag a;
double *c = &__real a;
double *d = &__imag a; // expected-error {{cannot take the address of an rvalue of type 'double'}}
}
void f4() {
void f4(void) {
_Complex double a = 1;
double b = __imag a;
double *c = &__real a;

View File

@ -1,6 +1,6 @@
// RUN: %clang_cc1 %s -verify -fsyntax-only
void a() {
void a(void) {
__complex__ int arr;
__complex__ short brr;
__complex__ unsigned xx;
@ -27,7 +27,7 @@ switch (ii) {
}
}
void Tester() {
void Tester(void) {
__complex short a1;
__complex int a2;
__complex float a3;

View File

@ -1,5 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -Wno-pointer-to-int-cast -verify -pedantic -Wsign-conversion %s
void foo() {
void foo(void) {
*(0 ? (double *)0 : (void *)0) = 0;
// FIXME: GCC doesn't consider the following two statements to be errors.
*(0 ? (double *)0 : (void *)(int *)0) = 0; // expected-error {{incomplete type 'void' is not assignable}}
@ -79,7 +79,7 @@ void foo() {
(test0 ? (test0 ? adr2 : adr2) : nonconst_int); // expected-error{{conditional operator with the second and third operands of type ('__attribute__((address_space(2))) int *' and 'int *') which are pointers to non-overlapping address spaces}}
}
int Postgresql() {
int Postgresql(void) {
char x;
return ((((&x) != ((void *) 0)) ? (*(&x) = ((char) 1)) : (void) ((void *) 0)), (unsigned long) ((void *) 0)); // expected-warning {{C99 forbids conditional expressions with only one void side}}
}
@ -100,7 +100,7 @@ int f2(int x) {
#define NULL (void*)0
void PR9236() {
void PR9236(void) {
struct A {int i;} A1;
(void)(1 ? A1 : NULL); // expected-error{{non-pointer operand type 'struct A' incompatible with NULL}}
(void)(1 ? NULL : A1); // expected-error{{non-pointer operand type 'struct A' incompatible with NULL}}

View File

@ -5,15 +5,15 @@ const char* test1 = 1 ? "i" : 1 == 1 ? "v" : "r";
void _efree(void *ptr);
void free(void *ptr);
int _php_stream_free1() {
int _php_stream_free1(void) {
return (1 ? free(0) : _efree(0)); // expected-error {{returning 'void' from a function with incompatible result type 'int'}}
}
int _php_stream_free2() {
int _php_stream_free2(void) {
return (1 ? _efree(0) : free(0)); // expected-error {{returning 'void' from a function with incompatible result type 'int'}}
}
void pr39809() {
void pr39809(void) {
_Generic(0 ? (int const *)0 : (void *)0, int const *: (void)0);
_Generic(0 ? (int const *)0 : (void *)1, void const *: (void)0);
_Generic(0 ? (int volatile*)0 : (void const*)1, void volatile const*: (void)0);

View File

@ -22,7 +22,7 @@ EVAL_EXPR(13, x || 3.0) // expected-error {{not an integer constant expression}}
unsigned int l_19 = 1;
EVAL_EXPR(14, (1 ^ l_19) && 1); // expected-error {{not an integer constant expression}}
void f()
void f(void)
{
int a;
EVAL_EXPR(15, (_Bool)&a);
@ -86,7 +86,7 @@ EVAL_EXPR(40, __imag__(1.f) == 0 ? 1 : -1)
EVAL_EXPR(41, (int)(1+(_Complex unsigned)2))
// rdar://8875946
void rdar8875946() {
void rdar8875946(void) {
double _Complex P;
float _Complex P2 = 3.3f + P;
}
@ -133,9 +133,9 @@ EVAL_EXPR(50, &Test50 < (struct Test50S*)((unsigned long)&Test50 + 10)) // expec
EVAL_EXPR(51, 0 != (float)1e99)
// PR21945
void PR21945() { int i = (({}), 0l); }
void PR21945(void) { int i = (({}), 0l); }
void PR24622();
void PR24622(void);
struct PR24622 {} pr24622;
EVAL_EXPR(52, &pr24622 == (void *)&PR24622); // expected-error {{not an integer constant expression}}

View File

@ -208,7 +208,7 @@ char clrsb12[__builtin_clrsb(~0x1f) == BITSIZE(int) - 6 ? 1 : -1];
// GCC misc stuff
extern int f();
extern int f(void);
int h0 = __builtin_types_compatible_p(int, float);
//int h1 = __builtin_choose_expr(1, 10, f());

View File

@ -17,7 +17,7 @@ long double g5 = __builtin_infl();
// GCC misc stuff
extern int f();
extern int f(void);
int h0 = __builtin_types_compatible_p(int,float);
//int h1 = __builtin_choose_expr(1, 10, f());
@ -26,7 +26,7 @@ int h3 = __builtin_bswap16(0x1234) == 0x3412 ? 1 : f();
int h4 = __builtin_bswap32(0x1234) == 0x34120000 ? 1 : f();
int h5 = __builtin_bswap64(0x1234) == 0x3412000000000000 ? 1 : f();
short somefunc();
short somefunc(void);
short t = __builtin_constant_p(5353) ? 42 : somefunc();

View File

@ -14,7 +14,7 @@ void test_7809123(void) {
a.i5 = 36; // expected-warning {{implicit truncation from 'int' to bit-field changes value from 36 to 4}}
}
void test() {
void test(void) {
struct { int bit : 1; } a;
a.bit = 1; // shouldn't warn
}
@ -25,7 +25,7 @@ enum Test2 test2(enum Test2 *t) {
return 10; // shouldn't warn
}
void test3() {
void test3(void) {
struct A {
unsigned int foo : 2;
int bar : 2;
@ -38,7 +38,7 @@ void test3() {
struct A e = { .foo = 10 }; // expected-warning {{implicit truncation from 'int' to bit-field changes value from 10 to 2}}
}
void test4() {
void test4(void) {
struct A {
char c : 2;
} a;
@ -46,7 +46,7 @@ void test4() {
a.c = 0x101; // expected-warning {{implicit truncation from 'int' to bit-field changes value from 257 to 1}}
}
void test5() {
void test5(void) {
struct A {
_Bool b : 1;
} a;
@ -56,13 +56,13 @@ void test5() {
a.b = 100;
}
void test6() {
void test6(void) {
// Test that unreachable code doesn't trigger the truncation warning.
unsigned char x = 0 ? 65535 : 1; // no-warning
unsigned char y = 1 ? 65535 : 1; // expected-warning {{changes value}}
}
void test7() {
void test7(void) {
struct {
unsigned int twoBits1:2;
unsigned int twoBits2:2;
@ -76,13 +76,13 @@ void test7() {
f.twoBits2 &= ~2; // no-warning
}
void test8() {
void test8(void) {
enum E { A, B, C };
struct { enum E x : 1; } f;
f.x = C; // expected-warning {{implicit truncation from 'int' to bit-field changes value from 2 to 0}}
}
void test9() {
void test9(void) {
const char max_char = 0x7F;
const short max_short = 0x7FFF;
const int max_int = 0x7FFFFFFF;
@ -117,7 +117,7 @@ void test9() {
#define A 1
void test10() {
void test10(void) {
struct S {
unsigned a : 4;
} s;

View File

@ -1,16 +1,16 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
int x __attribute__((constructor)); // expected-warning {{'constructor' attribute only applies to functions}}
int f() __attribute__((constructor));
int f() __attribute__((constructor(1)));
int f() __attribute__((constructor(1,2))); // expected-error {{'constructor' attribute takes no more than 1 argument}}
int f() __attribute__((constructor(1.0))); // expected-error {{'constructor' attribute requires an integer constant}}
int f() __attribute__((constructor(0x100000000))); // expected-error {{integer constant expression evaluates to value 4294967296 that cannot be represented in a 32-bit unsigned integer type}}
int f(void) __attribute__((constructor));
int f(void) __attribute__((constructor(1)));
int f(void) __attribute__((constructor(1,2))); // expected-error {{'constructor' attribute takes no more than 1 argument}}
int f(void) __attribute__((constructor(1.0))); // expected-error {{'constructor' attribute requires an integer constant}}
int f(void) __attribute__((constructor(0x100000000))); // expected-error {{integer constant expression evaluates to value 4294967296 that cannot be represented in a 32-bit unsigned integer type}}
int x __attribute__((destructor)); // expected-warning {{'destructor' attribute only applies to functions}}
int f() __attribute__((destructor));
int f() __attribute__((destructor(1)));
int f() __attribute__((destructor(1,2))); // expected-error {{'destructor' attribute takes no more than 1 argument}}
int f() __attribute__((destructor(1.0))); // expected-error {{'destructor' attribute requires an integer constant}}
int f(void) __attribute__((destructor));
int f(void) __attribute__((destructor(1)));
int f(void) __attribute__((destructor(1,2))); // expected-error {{'destructor' attribute takes no more than 1 argument}}
int f(void) __attribute__((destructor(1.0))); // expected-error {{'destructor' attribute requires an integer constant}}
void knr() __attribute__((constructor));

View File

@ -8,7 +8,7 @@ long double ld;
double d;
_Float16 f16; // x86-error {{_Float16 is not supported on this target}}
int main() {
int main(void) {
ld = d; // x86-warning {{implicit conversion increases floating-point precision: 'double' to 'long double'}}
d = ld; // x86-warning {{implicit conversion loses floating-point precision: 'long double' to 'double'}}

View File

@ -313,7 +313,7 @@ void test16(void) {
}
// PR 5938
void test17() {
void test17(void) {
union {
unsigned long long a : 8;
unsigned long long b : 32;
@ -327,7 +327,7 @@ void test17() {
}
// PR 5939
void test18() {
void test18(void) {
union {
unsigned long long a : 1;
unsigned long long b;

View File

@ -1,7 +1,7 @@
// RUN: %clang_cc1 -triple=x86_64-apple-darwin -fsyntax-only -verify %s
// PR6913
int main()
int main(void)
{
int x[10][10];
int (*p)[] = x;

View File

@ -53,7 +53,7 @@ void enum_in_fun_in_fun(void (*fp)(enum { AA, BB } e)) { // expected-warning {{w
SA(2, BB == 0);
}
void f7() {
void f7(void) {
extern void ext(struct S { enum E7 { a, b } o; } p); // expected-warning 2 {{will not be visible}}
ext(a); // expected-error {{use of undeclared identifier}}
}
@ -87,7 +87,7 @@ int f11(
} // expected-error {{expected member name or ';'}}
e);
void f12() {
void f12(void) {
extern int ext12(
struct S12 { } e // expected-warning {{will not be visible}}
);

View File

@ -5,8 +5,8 @@ typedef union <anonymous> __mbstate_t; // expected-error {{declaration of anony
// PR2017
void x();
int a() {
void x(void);
int a(void) {
int r[x()]; // expected-error {{size of array has non-integer type 'void'}}
static y ?; // expected-error{{unknown type name 'y'}} \

View File

@ -6,7 +6,7 @@ int testx[(sizeof(x) == sizeof(int) * 10) ? 1 : -1];
int (*a)(int (*x)[10], int (*y)[]);
int (*a)(int (*x)[], int (*y)[5]);
void b() {
void b(void) {
int x[10], y[5];
a(&x, &y);
a(&y, &y); // expected-warning {{incompatible pointer}}

View File

@ -5,7 +5,7 @@ T foo(int n, int m) { } // expected-error {{cannot return array type}}
void foof(const char *, ...) __attribute__((__format__(__printf__, 1, 2))), barf (void);
int typedef validTypeDecl() { } // expected-error {{function definition declared 'typedef'}}
int typedef validTypeDecl(void) { } // expected-error {{function definition declared 'typedef'}}
struct _zend_module_entry { } // expected-error {{expected ';' after struct}}
int gv1;
@ -29,7 +29,7 @@ restrict struct hallo; // expected-error {{restrict requires a pointer or refere
struct test1 {
} // expected-error {{expected ';' after struct}}
void test2() {}
void test2(void) {}
// PR6423
@ -43,9 +43,9 @@ volatile volatile int pr8264_2; // expected-warning {{duplicate 'volatile' decl
char * restrict restrict pr8264_3; // expected-warning {{duplicate 'restrict' declaration specifier}}
extern extern int pr8264_4; // expected-warning {{duplicate 'extern' declaration specifier}}
void pr8264_5() {
void pr8264_5(void) {
register register int x; // expected-warning {{duplicate 'register' declaration specifier}}
}
inline inline void pr8264_6() {} // expected-warning {{duplicate 'inline' declaration specifier}}
_Noreturn _Noreturn void pr8264_7(); // expected-warning {{duplicate '_Noreturn' declaration specifier}}
inline inline void pr8264_6(void) {} // expected-warning {{duplicate 'inline' declaration specifier}}
_Noreturn _Noreturn void pr8264_7(void); // expected-warning {{duplicate '_Noreturn' declaration specifier}}

View File

@ -125,9 +125,9 @@ struct X {
};
int counter = 0;
int get8() { ++counter; return 8; }
int get8(void) { ++counter; return 8; }
void test() {
void test(void) {
struct X xs[] = {
[0] = (struct X){1, 2}, // expected-note 2 {{previous initialization is here}}
[0].c = 3, // expected-warning{{initializer partially overrides prior initialization of this subobject}}

View File

@ -10,7 +10,7 @@ typedef __declspec(dllexport) int typedef2;
// 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) Enum { EnumVal };
// expected-warning@-1{{'dllexport' attribute only applies to}}
@ -45,7 +45,7 @@ __declspec(dllexport) extern int GlobalRedecl2;
int GlobalRedecl2;
extern int GlobalRedecl3; // expected-note{{previous declaration is here}}
int useGlobalRedecl3() { return GlobalRedecl3; }
int useGlobalRedecl3(void) { return GlobalRedecl3; }
__declspec(dllexport) extern int GlobalRedecl3; // expected-error{{redeclaration of 'GlobalRedecl3' cannot add 'dllexport' attribute}}
extern int GlobalRedecl4; // expected-note{{previous declaration is here}}
@ -59,7 +59,7 @@ __declspec(dllexport) static int StaticGlobal; // expected-error{{'StaticGlobal'
__declspec(dllexport) __thread int ThreadLocalGlobal; // expected-error{{'ThreadLocalGlobal' cannot be thread local when declared 'dllexport'}}
// Export in local scope.
void functionScope() {
void functionScope(void) {
__declspec(dllexport) int LocalVarDecl; // expected-error{{'LocalVarDecl' must have external linkage when declared 'dllexport'}}
__declspec(dllexport) int LocalVarDef = 1; // expected-error{{'LocalVarDef' must have external linkage when declared 'dllexport'}}
__declspec(dllexport) extern int ExternLocalVarDecl;
@ -73,50 +73,50 @@ void functionScope() {
//===----------------------------------------------------------------------===//
// Export function declaration. Check different placements.
__attribute__((dllexport)) void decl1A(); // Basic check with __attribute__
__declspec(dllexport) void decl1B();
__attribute__((dllexport)) void decl1A(void); // Basic check with __attribute__
__declspec(dllexport) void decl1B(void);
void __attribute__((dllexport)) decl2A();
void __declspec(dllexport) decl2B();
void __attribute__((dllexport)) decl2A(void);
void __declspec(dllexport) decl2B(void);
// Export function definition.
__declspec(dllexport) void def() {}
__declspec(dllexport) void def(void) {}
// Export inline function.
__declspec(dllexport) inline void inlineFunc1() {}
extern void inlineFunc1();
__declspec(dllexport) inline void inlineFunc1(void) {}
extern void inlineFunc1(void);
inline void __attribute__((dllexport)) inlineFunc2() {}
extern void inlineFunc2();
inline void __attribute__((dllexport)) inlineFunc2(void) {}
extern void inlineFunc2(void);
// Redeclarations
__declspec(dllexport) void redecl1();
__declspec(dllexport) void redecl1();
__declspec(dllexport) void redecl1(void);
__declspec(dllexport) void redecl1(void);
__declspec(dllexport) void redecl2();
void redecl2();
__declspec(dllexport) void redecl2(void);
void redecl2(void);
__declspec(dllexport) void redecl3();
void redecl3() {}
__declspec(dllexport) void redecl3(void);
void redecl3(void) {}
void redecl4(); // expected-note{{previous declaration is here}}
void useRedecl4() { redecl4(); }
__declspec(dllexport) void redecl4(); // expected-error{{redeclaration of 'redecl4' cannot add 'dllexport' attribute}}
void redecl4(void); // expected-note{{previous declaration is here}}
void useRedecl4(void) { redecl4(); }
__declspec(dllexport) void redecl4(void); // expected-error{{redeclaration of 'redecl4' cannot add 'dllexport' attribute}}
void redecl5(); // expected-note{{previous declaration is here}}
void useRedecl5() { redecl5(); }
__declspec(dllexport) inline void redecl5() {} // expected-error{{redeclaration of 'redecl5' cannot add 'dllexport' attribute}}
void redecl5(void); // expected-note{{previous declaration is here}}
void useRedecl5(void) { redecl5(); }
__declspec(dllexport) inline void redecl5(void) {} // expected-error{{redeclaration of 'redecl5' cannot add 'dllexport' attribute}}
// Allow with a warning if the decl hasn't been used yet.
void redecl6(); // expected-note{{previous declaration is here}}
__declspec(dllexport) void redecl6(); // expected-warning{{redeclaration of 'redecl6' should not add 'dllexport' attribute}}
void redecl6(void); // expected-note{{previous declaration is here}}
__declspec(dllexport) void redecl6(void); // expected-warning{{redeclaration of 'redecl6' should not add 'dllexport' attribute}}
// External linkage is required.
__declspec(dllexport) static int staticFunc(); // expected-error{{'staticFunc' must have external linkage when declared 'dllexport'}}
__declspec(dllexport) static int staticFunc(void); // expected-error{{'staticFunc' must have external linkage when declared 'dllexport'}}
// Static locals don't count as having external linkage.
void staticLocalFunc() {
void staticLocalFunc(void) {
__declspec(dllexport) static int staticLocal; // expected-error{{'staticLocal' must have external linkage when declared 'dllexport'}}
}
@ -151,14 +151,14 @@ __declspec(dllimport) int PrecedenceGlobalRedecl1; // expected-warning{{'
__declspec(dllimport) extern int PrecedenceGlobalRedecl2; // expected-warning{{'dllimport' attribute ignored}}
__declspec(dllexport) int PrecedenceGlobalRedecl2;
void __attribute__((dllimport, dllexport)) precedence1A() {} // expected-warning{{'dllimport' attribute ignored}}
void __declspec(dllimport) __declspec(dllexport) precedence1B() {} // expected-warning{{'dllimport' attribute ignored}}
void __attribute__((dllimport, dllexport)) precedence1A(void) {} // expected-warning{{'dllimport' attribute ignored}}
void __declspec(dllimport) __declspec(dllexport) precedence1B(void) {} // expected-warning{{'dllimport' attribute ignored}}
void __attribute__((dllexport, dllimport)) precedence2A() {} // expected-warning{{'dllimport' attribute ignored}}
void __declspec(dllexport) __declspec(dllimport) precedence2B() {} // expected-warning{{'dllimport' attribute ignored}}
void __attribute__((dllexport, dllimport)) precedence2A(void) {} // expected-warning{{'dllimport' attribute ignored}}
void __declspec(dllexport) __declspec(dllimport) precedence2B(void) {} // expected-warning{{'dllimport' attribute ignored}}
void __declspec(dllimport) precedenceRedecl1(); // expected-warning{{'dllimport' attribute ignored}}
void __declspec(dllexport) precedenceRedecl1() {}
void __declspec(dllimport) precedenceRedecl1(void); // expected-warning{{'dllimport' attribute ignored}}
void __declspec(dllexport) precedenceRedecl1(void) {}
void __declspec(dllexport) precedenceRedecl2();
void __declspec(dllimport) precedenceRedecl2() {} // expected-warning{{'dllimport' attribute ignored}}
void __declspec(dllexport) precedenceRedecl2(void);
void __declspec(dllimport) precedenceRedecl2(void) {} // expected-warning{{'dllimport' attribute ignored}}

View File

@ -15,7 +15,7 @@ typedef __declspec(dllimport) int typedef2;
// 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) Enum { EnumVal };
// expected-warning@-1{{'dllimport' attribute only applies to}}
@ -108,7 +108,7 @@ __declspec(dllimport) extern int GlobalRedecl3; // expected-note{{previous decla
// Adding an attribute on redeclaration.
extern int GlobalRedecl4; // expected-note{{previous declaration is here}}
int useGlobalRedecl4() { return GlobalRedecl4; }
int useGlobalRedecl4(void) { return GlobalRedecl4; }
__declspec(dllimport) extern int GlobalRedecl4; // expected-error{{redeclaration of 'GlobalRedecl4' cannot add 'dllimport' attribute}}
// Allow with a warning if the decl hasn't been used yet.
@ -127,7 +127,7 @@ __declspec(dllimport) float LocalRedecl1; // expected-note{{previous declaration
__declspec(dllimport) float LocalRedecl2; // expected-note{{previous declaration is here}}
__declspec(dllimport) float LocalRedecl3; // expected-note{{previous declaration is here}}
__declspec(dllimport) float LocalRedecl4;
void functionScope() {
void functionScope(void) {
__declspec(dllimport) int LocalRedecl1; // expected-error{{redeclaration of 'LocalRedecl1' with a different type: 'int' vs 'float'}}
int *__attribute__((dllimport)) LocalRedecl2; // expected-error{{redeclaration of 'LocalRedecl2' with a different type: 'int *' vs 'float'}}
int LocalRedecl3 __attribute__((dllimport)); // expected-error{{redeclaration of 'LocalRedecl3' with a different type: 'int' vs 'float'}}
@ -149,62 +149,62 @@ void functionScope() {
//===----------------------------------------------------------------------===//
// Import function declaration. Check different placements.
__attribute__((dllimport)) void decl1A(); // Basic check with __attribute__
__declspec(dllimport) void decl1B();
__attribute__((dllimport)) void decl1A(void); // Basic check with __attribute__
__declspec(dllimport) void decl1B(void);
void __attribute__((dllimport)) decl2A();
void __declspec(dllimport) decl2B();
void __attribute__((dllimport)) decl2A(void);
void __declspec(dllimport) decl2B(void);
// Address of functions can be used for initialization in C language modes.
// However, the address of the thunk wrapping the function is used instead of
// the address in the import address table.
void (*FunForInit)() = &decl2A;
void (*FunForInit)(void) = &decl2A;
// Not allowed on function definitions.
__declspec(dllimport) void def() {} // expected-error{{dllimport cannot be applied to non-inline function definition}}
__declspec(dllimport) void def(void) {} // expected-error{{dllimport cannot be applied to non-inline function definition}}
// Import inline function.
#ifdef GNU
// expected-warning@+3{{'dllimport' attribute ignored on inline function}}
// expected-warning@+3{{'dllimport' attribute ignored on inline function}}
#endif
__declspec(dllimport) inline void inlineFunc1() {}
inline void __attribute__((dllimport)) inlineFunc2() {}
__declspec(dllimport) inline void inlineFunc1(void) {}
inline void __attribute__((dllimport)) inlineFunc2(void) {}
// Redeclarations
__declspec(dllimport) void redecl1();
__declspec(dllimport) void redecl1();
__declspec(dllimport) void redecl1(void);
__declspec(dllimport) void redecl1(void);
__declspec(dllimport) void redecl2(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
void redecl2(); // expected-warning{{'redecl2' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
__declspec(dllimport) void redecl2(void); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
void redecl2(void); // expected-warning{{'redecl2' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
#ifdef GNU
// expected-note@+2{{previous attribute is here}}
#endif
__declspec(dllimport) void redecl3(); // expected-note{{previous declaration is here}}
__declspec(dllimport) void redecl3(void); // expected-note{{previous declaration is here}}
// NB: Both MSVC and Clang issue a warning and make redecl3 dllexport.
#if defined(MS) || defined(WI)
// expected-warning@+4{{'redecl3' redeclared without 'dllimport' attribute: 'dllexport' attribute added}}
#else
// expected-warning@+2{{'redecl3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
#endif
void redecl3() {}
void redecl3(void) {}
void redecl4(); // expected-note{{previous declaration is here}}
void useRedecl4() { redecl4(); }
__declspec(dllimport) void redecl4(); // expected-warning{{redeclaration of 'redecl4' should not add 'dllimport' attribute}}
void redecl4(void); // expected-note{{previous declaration is here}}
void useRedecl4(void) { redecl4(); }
__declspec(dllimport) void redecl4(void); // expected-warning{{redeclaration of 'redecl4' should not add 'dllimport' attribute}}
// Allow with a warning if the decl hasn't been used yet.
void redecl5(); // expected-note{{previous declaration is here}}
__declspec(dllimport) void redecl5(); // expected-warning{{redeclaration of 'redecl5' should not add 'dllimport' attribute}}
void redecl5(void); // expected-note{{previous declaration is here}}
__declspec(dllimport) void redecl5(void); // expected-warning{{redeclaration of 'redecl5' should not add 'dllimport' attribute}}
// Inline redeclarations.
#ifdef GNU
// expected-warning@+3{{'redecl6' redeclared inline; 'dllimport' attribute ignored}}
#endif
__declspec(dllimport) void redecl6();
inline void redecl6() {}
__declspec(dllimport) void redecl6(void);
inline void redecl6(void) {}
#if defined(MS) || defined (WI)
// expected-note@+5{{previous declaration is here}}
@ -212,8 +212,8 @@ __declspec(dllimport) void redecl6();
#else
// expected-warning@+3{{'dllimport' attribute ignored on inline function}}
#endif
void redecl7();
__declspec(dllimport) inline void redecl7() {}
void redecl7(void);
__declspec(dllimport) inline void redecl7(void) {}
// PR31069: Don't crash trying to merge attributes for redeclaration of invalid
// decl.
@ -225,9 +225,9 @@ void __declspec(dllimport) redecl9(void); // expected-note{{previous declaration
int redecl9(void) {} // expected-error{{conflicting types for 'redecl9'}}
// External linkage is required.
__declspec(dllimport) static int staticFunc(); // expected-error{{'staticFunc' must have external linkage when declared 'dllimport'}}
__declspec(dllimport) static int staticFunc(void); // expected-error{{'staticFunc' must have external linkage when declared 'dllimport'}}
// Static locals don't count as having external linkage.
void staticLocalFunc() {
void staticLocalFunc(void) {
__declspec(dllimport) static int staticLocal; // expected-error{{'staticLocal' must have external linkage when declared 'dllimport'}}
}

View File

@ -42,7 +42,7 @@ struct emp_9 { // expected-warning {{struct has size 0 in C, non-zero size in C+
// Checks for pointer subtraction (PR15683)
struct emp_1 *func_1p(struct emp_1 *x) { return x - 5; }
int func_1() {
int func_1(void) {
struct emp_1 v[1];
return v - v; // expected-warning {{subtraction of pointers to type 'struct emp_1' of zero size has undefined behavior}}
}
@ -63,7 +63,7 @@ int func_5(volatile struct emp_1 *x, const struct emp_1 *y) {
return x - y; // expected-warning {{subtraction of pointers to type 'struct emp_1' of zero size has undefined behavior}}
}
int func_6() {
int func_6(void) {
union emp_2 v[1];
return v - v; // expected-warning {{subtraction of pointers to type 'union emp_2' of zero size has undefined behavior}}
}

View File

@ -12,39 +12,39 @@ __attribute__ (( enable_if(1, "") ))
#if defined(WARN_PEDANTIC)
// expected-warning@-2 {{'enable_if' is a clang extension}}
#endif
void f() { }
void f(void) { }
__attribute__ (( __enable_if__(1, "") ))
#if defined(WARN_PEDANTIC)
// expected-warning@-2 {{'enable_if' is a clang extension}}
#endif
void g() { }
void g(void) { }
__attribute__ (( enable_if(0, "") ))
#if defined(WARN_PEDANTIC)
// expected-warning@-2 {{'enable_if' is a clang extension}}
#endif
void h() { }
void h(void) { }
__attribute__ (( __enable_if__(0, "") ))
#if defined(WARN_PEDANTIC)
// expected-warning@-2 {{'enable_if' is a clang extension}}
#endif
void i() { }
void i(void) { }
#pragma clang system_header
__attribute__ (( enable_if(1, "") ))
void j() { }
void j(void) { }
__attribute__ (( __enable_if__(1, "") ))
void k() { }
void k(void) { }
__attribute__ (( enable_if(0, "") ))
void l() { }
void l(void) { }
__attribute__ (( __enable_if__(0, "") ))
void m() { }
void m(void) { }
#endif

View File

@ -10,7 +10,7 @@ enum { TRUE = 1 };
int open(const char *pathname, int flags) __attribute__((enable_if(!(flags & O_CREAT), "must specify mode when using O_CREAT"))) __attribute__((overloadable)); // expected-note{{candidate disabled: must specify mode when using O_CREAT}}
int open(const char *pathname, int flags, mode_t mode) __attribute__((overloadable)); // expected-note{{candidate function not viable: requires 3 arguments, but 2 were provided}}
void test1() {
void test1(void) {
#ifndef CODEGEN
open("path", O_CREAT); // expected-error{{no matching function for call to 'open'}}
#endif
@ -93,7 +93,7 @@ void test4(int c) {
#endif
}
void test5() {
void test5(void) {
int (*p1)(int) = &isdigit2;
int (*p2)(int) = isdigit2;
void *p3 = (void *)&isdigit2;
@ -116,12 +116,12 @@ void f(int n) __attribute__((enable_if(global == 0, "chosen when 'global' is zer
enum { cst = 7 };
void return_cst(void) __attribute__((overloadable)) __attribute__((enable_if(cst == 7, "chosen when 'cst' is 7")));
void test_return_cst() { return_cst(); }
void test_return_cst(void) { return_cst(); }
void f2(void) __attribute__((overloadable)) __attribute__((enable_if(1, "always chosen")));
void f2(void) __attribute__((overloadable)) __attribute__((enable_if(0, "never chosen")));
void f2(void) __attribute__((overloadable)) __attribute__((enable_if(TRUE, "always chosen #2")));
void test6() {
void test6(void) {
void (*p1)(void) = &f2; // expected-error{{initializing 'void (*)(void)' with an expression of incompatible type '<overloaded function type>'}} expected-note@121{{candidate function}} expected-note@122{{candidate function made ineligible by enable_if}} expected-note@123{{candidate function}}
void (*p2)(void) = f2; // expected-error{{initializing 'void (*)(void)' with an expression of incompatible type '<overloaded function type>'}} expected-note@121{{candidate function}} expected-note@122{{candidate function made ineligible by enable_if}} expected-note@123{{candidate function}}
void *p3 = (void*)&f2; // expected-error{{address of overloaded function 'f2' is ambiguous}} expected-note@121{{candidate function}} expected-note@122{{candidate function made ineligible by enable_if}} expected-note@123{{candidate function}}
@ -130,7 +130,7 @@ void test6() {
void f3(int m) __attribute__((overloadable)) __attribute__((enable_if(m >= 0, "positive")));
void f3(int m) __attribute__((overloadable)) __attribute__((enable_if(m < 0, "negative")));
void test7() {
void test7(void) {
void (*p1)(int) = &f3; // expected-error{{initializing 'void (*)(int)' with an expression of incompatible type '<overloaded function type>'}} expected-note@131{{candidate function made ineligible by enable_if}} expected-note@132{{candidate function made ineligible by enable_if}}
void (*p2)(int) = f3; // expected-error{{initializing 'void (*)(int)' with an expression of incompatible type '<overloaded function type>'}} expected-note@131{{candidate function made ineligible by enable_if}} expected-note@132{{candidate function made ineligible by enable_if}}
void *p3 = (void*)&f3; // expected-error{{address of overloaded function 'f3' does not match required type 'void'}} expected-note@131{{candidate function made ineligible by enable_if}} expected-note@132{{candidate function made ineligible by enable_if}}
@ -138,13 +138,13 @@ void test7() {
}
void f4(int m) __attribute__((enable_if(0, "")));
void test8() {
void test8(void) {
void (*p1)(int) = &f4; // expected-error{{cannot take address of function 'f4' because it has one or more non-tautological enable_if conditions}}
void (*p2)(int) = f4; // expected-error{{cannot take address of function 'f4' because it has one or more non-tautological enable_if conditions}}
}
void regular_enable_if(int a) __attribute__((enable_if(a, ""))); // expected-note 3{{declared here}}
void PR27122_ext() {
void PR27122_ext(void) {
regular_enable_if(0, 2); // expected-error{{too many arguments}}
regular_enable_if(1, 2); // expected-error{{too many arguments}}
regular_enable_if(); // expected-error{{too few arguments}}
@ -152,7 +152,7 @@ void PR27122_ext() {
// We had a bug where we'd crash upon trying to evaluate varargs.
void variadic_enable_if(int a, ...) __attribute__((enable_if(a, ""))); // expected-note 6 {{disabled}}
void variadic_test() {
void variadic_test(void) {
variadic_enable_if(1);
variadic_enable_if(1, 2);
variadic_enable_if(1, "c", 3);

View File

@ -40,7 +40,7 @@ enum __attribute__((enum_extensibility())) EnumTooFewArgs { // expected-error{{'
struct __attribute__((enum_extensibility(open))) S { // expected-warning{{'enum_extensibility' attribute only applies to enums}}{
};
void test() {
void test(void) {
enum Enum t0 = 100; // expected-warning{{integer constant not in range of enumerated type}}
t0 = 1;

View File

@ -2,7 +2,7 @@
// expected-no-diagnostics
enum A { A1, A2, A3 };
typedef enum A A;
void test() {
void test(void) {
A a;
a++;
a--;

View File

@ -18,7 +18,7 @@ enum x // expected-warning {{enumeration values exceed rang
{ y = -9223372036854775807LL-1, // expected-warning {{ISO C restricts enumerator values to range of 'int'}}
z = 9223372036854775808ULL }; // expected-warning {{ISO C restricts enumerator values to range of 'int'}}
int test() {
int test(void) {
return sizeof(enum e) ;
}
@ -39,7 +39,7 @@ enum u0 { U0A }; // expected-error {{use of 'u0' with tag type that does not mat
// rdar://6095136
extern enum some_undefined_enum ve2; // expected-warning {{ISO C forbids forward references to 'enum' types}}
void test4() {
void test4(void) {
for (; ve2;) // expected-error {{statement requires expression of scalar type}}
;
(_Bool)ve2; // expected-error {{arithmetic or pointer type is required}}
@ -62,7 +62,7 @@ enum e0 { // expected-note {{previous definition is here}}
enum { PR3173A, PR3173B = PR3173A+50 };
// PR2753
void foo() {
void foo(void) {
enum xpto; // expected-warning{{ISO C forbids forward references to 'enum' types}}
enum xpto; // expected-warning{{ISO C forbids forward references to 'enum' types}}
}
@ -99,7 +99,7 @@ int CheckPR4515[PR4515b==0?1:-1];
// PR7911
extern enum PR7911T PR7911V; // expected-warning{{ISO C forbids forward references to 'enum' types}}
void PR7911F() {
void PR7911F(void) {
switch (PR7911V) // expected-error {{statement requires expression of integer type}}
;
}

View File

@ -6,7 +6,7 @@ struct entry { struct xx *whatever;
int bitf:1; };
void add_one(int *p) { (*p)++; }
void test() {
void test(void) {
register struct entry *p;
add_one(&p->value);
struct entry pvalue;
@ -15,7 +15,7 @@ void test() {
add_one(&p->whatever->bitf); // expected-error {{address of bit-field requested}}
}
void foo() {
void foo(void) {
register int x[10];
&x[10]; // expected-error {{address of register variable requested}}
@ -25,7 +25,7 @@ void foo() {
int *x3 = &y[10];
}
void testVectorComponentAccess() {
void testVectorComponentAccess(void) {
typedef float v4sf __attribute__ ((vector_size (16)));
static v4sf q;
float* r = &q[0]; // expected-error {{address of vector element requested}}
@ -37,7 +37,7 @@ float *testExtVectorComponentAccess(float4 x) {
return &x.w; // expected-error {{address of vector element requested}}
}
void f0() {
void f0(void) {
register int *x0;
int *_dummy0 = &(*x0);
@ -45,7 +45,7 @@ void f0() {
int *_dummy1 = &(*(x1 + 1));
}
void f1() {
void f1(void) {
register int x0[10];
int *_dummy00 = x0; // expected-error {{address of register variable requested}}
int *_dummy01 = &(*x0); // expected-error {{address of register variable requested}}
@ -68,25 +68,25 @@ void f1() {
int *p = ((int *)x0)++; // expected-error {{address of register variable requested}}
}
void f2() {
void f2(void) {
register int *y;
int *_dummy0 = &y; // expected-error {{address of register variable requested}}
int *_dummy1 = &y[10];
}
void f3() {
extern void f4();
void (*_dummy0)() = &****f4;
void f3(void) {
extern void f4(void);
void (*_dummy0)(void) = &****f4;
}
void f4() {
void f4(void) {
register _Complex int x;
int *_dummy0 = &__real__ x; // expected-error {{address of register variable requested}}
}
void f5() {
void f5(void) {
register int arr[2];
int *_dummy0 = &(int*) arr; // expected-error {{address of register variable requested}}
@ -97,7 +97,7 @@ void f6(register int x) {
int * dummy0 = &x; // expected-error {{address of register variable requested}}
}
char* f7() {
char* f7(void) {
register struct {char* x;} t1 = {"Hello"};
char* dummy1 = &(t1.x[0]);
@ -108,7 +108,7 @@ char* f7() {
void* t3 = &(*(void*)0);
}
void f8() {
void f8(void) {
void *dummy0 = &f8(); // expected-error {{cannot take the address of an rvalue of type 'void'}}
extern void v;
@ -118,3 +118,8 @@ void f8() {
void *dummy3 = &({ ; }); // expected-error {{cannot take the address of an rvalue of type 'void'}}
}
void f9(void) {
extern void knr();
void (*_dummy0)() = &****knr;
}

View File

@ -14,13 +14,13 @@
// Test that we don't report divide-by-zero errors in unreachable code.
// This test should be left as is, as it also tests CFG functionality.
void radar9171946() {
void radar9171946(void) {
if (0) {
0 / (0 ? 1 : 0); // no-warning
}
}
int test_pr8876() {
int test_pr8876(void) {
PR8876(0); // no-warning
PR8876_pos(0); // expected-warning{{indirection of non-volatile null pointer will be deleted, not trap}} expected-note{{consider using __builtin_trap() or qualifying pointer with 'volatile'}}
return 0;
@ -35,22 +35,22 @@ void pr8183(unsigned long long test)
}
// PR1966
_Complex double test1() {
_Complex double test1(void) {
return __extension__ 1.0if;
}
_Complex double test2() {
_Complex double test2(void) {
return 1.0if; // expected-warning {{imaginary constants are a GNU extension}}
}
// rdar://6097308
void test3() {
void test3(void) {
int x;
(__extension__ x) = 10;
}
// rdar://6162726
void test4() {
void test4(void) {
static int var;
var =+ 5; // expected-warning {{use of unary operator that may be intended as compound assignment (+=)}}
var =- 5; // expected-warning {{use of unary operator that may be intended as compound assignment (-=)}}
@ -72,7 +72,7 @@ void test5(int *X, float *P) {
FOO = P; // expected-error {{assignment to cast is illegal, lvalue casts are not supported}}
}
void test6() {
void test6(void) {
int X;
X(); // expected-error {{called object type 'int' is not a function or function pointer}}
}
@ -128,12 +128,12 @@ int test12b(const char *X) {
// rdar://6719156
void test13(
void (^P)()) { // expected-error {{blocks support disabled - compile with -fblocks}}
void (^P)(void)) { // expected-error {{blocks support disabled - compile with -fblocks}}
P();
P = ^(){}; // expected-error {{blocks support disabled - compile with -fblocks}}
P = ^(void){}; // expected-error {{blocks support disabled - compile with -fblocks}}
}
void test14() {
void test14(void) {
typedef long long __m64 __attribute__((__vector_size__(8)));
typedef short __v4hi __attribute__((__vector_size__(8)));
@ -186,7 +186,7 @@ void test18(int b) {
typedef int __attribute__((address_space(256))) int_AS256;
// PR7569
void test19() {
void test19(void) {
*(int *)0 = 0; // expected-warning {{indirection of non-volatile null pointer}} \
// expected-note {{consider using __builtin_trap}}
*(volatile int *)0 = 0; // Ok.
@ -256,7 +256,7 @@ void test21(volatile struct Test21 *ptr) {
}
// Make sure we do function/array decay.
void test22() {
void test22(void) {
if ("help")
(void) 0;

View File

@ -12,7 +12,7 @@ typedef __typeof__(sizeof(int)) size_t;
typedef unsigned long ulong2 __attribute__ ((ext_vector_type(2)));
typedef size_t stride4 __attribute__((ext_vector_type(4)));
static void test() {
static void test(void) {
float2 vec2;
float3 vec3;
float4 vec4, vec4_2;

View File

@ -2,7 +2,7 @@
typedef __attribute__(( ext_vector_type(4) )) int int4;
static int4 test1() {
static int4 test1(void) {
int4 vec, rv;
// comparisons to self...
@ -17,7 +17,7 @@ static int4 test1() {
typedef __attribute__(( ext_vector_type(4) )) float float4;
static int4 test2() {
static int4 test2(void) {
float4 vec, rv;
// comparisons to self. no warning, they're floats
@ -29,14 +29,14 @@ static int4 test2() {
return vec >= vec; // no-warning
}
static int4 test3() {
static int4 test3(void) {
int4 i0, i1;
return i0 > i1 ? i0 : i1; // no-error
return i0 ? i0 : i1; // no-error
}
static float4 test4() {
static float4 test4(void) {
float4 f0, f1;
// This would actually generate implicit casting warning

View File

@ -7,7 +7,7 @@ typedef __attribute__(( ext_vector_type(16) )) float float16;
static float4 vec4_0 = (float4)0.5f;
static void test() {
static void test(void) {
float2 vec2, vec2_2;
float3 vec3;
float4 vec4, vec4_2, *vec4p;

View File

@ -4,7 +4,7 @@ typedef __attribute__((ext_vector_type(4))) char char4;
typedef __attribute__((ext_vector_type(4))) short short4;
typedef __attribute__((ext_vector_type(1))) float float1;
static void test() {
static void test(void) {
char4 vc4;
float f;
// Not allowed. There's no splatting conversion between float and int vector,

View File

@ -6,7 +6,7 @@ struct one {
struct one x2 = { 5, 1, 2, 3 }; // expected-warning{{flexible array initialization is a GNU extension}}
void test() {
void test(void) {
struct one x3 = {5, {1, 2, 3}}; // expected-error{{initialization of flexible array member is not allowed}}
struct one x3a = { 5 };
struct one x3b = { .a = 5 };
@ -70,7 +70,7 @@ struct PR8217a {
char v[]; // expected-note 2 {{initialized flexible array member 'v' is here}}
};
void PR8217() {
void PR8217(void) {
struct PR8217a foo1 = { .i = 0, .v = "foo" }; // expected-error {{initialization of flexible array member is not allowed}}
struct PR8217a foo2 = { .i = 0 };
struct PR8217a foo3 = { .i = 0, .v = { 'b', 'a', 'r', '\0' } }; // expected-error {{initialization of flexible array member is not allowed}}
@ -81,11 +81,11 @@ typedef struct PR10648 {
unsigned long n;
int v[]; // expected-note {{initialized flexible array member 'v' is here}}
} PR10648;
int f10648() {
int f10648(void) {
return (PR10648){2, {3, 4}}.v[1]; // expected-error {{initialization of flexible array member is not allowed}}
}
struct FlexWithUnnamedBitfield { int : 10; int x; int y[]; }; // expected-note {{initialized flexible array member 'y' is here}}
void TestFlexWithUnnamedBitfield() {
void TestFlexWithUnnamedBitfield(void) {
struct FlexWithUnnamedBitfield x = {10, {3}}; // expected-error {{initialization of flexible array member is not allowed}}
}

View File

@ -19,7 +19,7 @@ BOOL b;
#define NO __objc_no
#endif
int main() {
int main(void) {
p("%d", b);
p("%hd", b);
#ifdef TYPE_CONF

View File

@ -10,7 +10,7 @@ struct bitfields {
unsigned long d : 32; // assumes that int is 32 bits
} bf;
void bitfield_promotion() {
void bitfield_promotion(void) {
printf("%ld", bf.a); // expected-warning {{format specifies type 'long' but the argument has type 'int'}}
printf("%lu", bf.b); // expected-warning {{format specifies type 'unsigned long' but the argument has type 'int'}}
printf("%ld", bf.c); // expected-warning {{format specifies type 'long' but the argument has type 'int'}}

View File

@ -10,7 +10,7 @@
int printf(const char *restrict, ...);
int scanf(const char * restrict, ...) ;
void test() {
void test(void) {
int justRight = 1;
long tooLong = 2;

View File

@ -40,7 +40,7 @@ void testLong(LongEnum input) {
// GNU C allows forward declaring enums.
extern enum forward_declared *fwd;
void forward_enum() {
void forward_enum(void) {
printf("%u", fwd); // expected-warning{{format specifies type 'unsigned int' but the argument has type 'enum forward_declared *}}
printf("%p", fwd);

View File

@ -11,7 +11,7 @@
int printf(char const *, ...);
int scanf(const char *, ...);
void test() {
void test(void) {
typedef signed long int ssize_t;
printf("%f", (ssize_t) 42);
ssize_t s;

View File

@ -16,7 +16,7 @@ typedef __UINTMAX_TYPE__ uintmax_t;
typedef __PTRDIFF_TYPE__ ptrdiff_t;
typedef __WCHAR_TYPE__ wchar_t;
void test() {
void test(void) {
// Basic types
printf("%s", (int) 123);
printf("abc%0f", "testing testing 123");

View File

@ -9,7 +9,7 @@
int printf(const char *restrict, ...);
int scanf(const char * restrict, ...) ;
void test() {
void test(void) {
long notLongEnough = 1;
long long quiteLong = 2;
@ -29,7 +29,7 @@ void test() {
#endif
}
void testAlwaysInvalid() {
void testAlwaysInvalid(void) {
// We should not suggest 'll' here!
printf("%Lc", 'a'); // expected-warning {{length modifier 'L' results in undefined behavior or no effect with 'c' conversion specifier}}
printf("%Ls", "a"); // expected-warning {{length modifier 'L' results in undefined behavior or no effect with 's' conversion specifier}}

View File

@ -18,7 +18,7 @@ void non_iso_warning_test(__int32 i32, __int64 i64, wchar_t c, void *p) {
#else
void signed_test() {
void signed_test(void) {
short val = 30;
printf("val = %I64d\n", val); // expected-warning{{format specifies type '__int64' (aka 'long long') but the argument has type 'short'}}
long long bigval = 30;
@ -26,7 +26,7 @@ void signed_test() {
printf("val = %Id\n", bigval); // expected-warning{{format specifies type '__int32' (aka 'int') but the argument has type 'long long'}}
}
void unsigned_test() {
void unsigned_test(void) {
unsigned short val = 30;
printf("val = %I64u\n", val); // expected-warning{{format specifies type 'unsigned __int64' (aka 'unsigned long long') but the argument has type 'unsigned short'}}
unsigned long long bigval = 30;

View File

@ -10,7 +10,7 @@
int printf(char const *, ...);
int scanf(char const *, ...);
void pr9751() {
void pr9751(void) {
const char kFormat1[] = "%s";
printf(kFormat1, 5);
printf("%s", 5);

View File

@ -5,7 +5,7 @@
__attribute__((format(printf, 1, 2)))
int printf(const char *restrict, ...);
int main() {
int main(void) {
printf("%p", (int *)0); // expected-warning {{format specifies type 'void *' but the argument has type 'int *'}}
printf("%p", (void *)0);

View File

@ -68,7 +68,7 @@ void bad_length_modifiers(char *s, void *p, wchar_t *ws, long double *ld) {
// Test that the scanf call site is where the warning is attached. If the
// format string is somewhere else, point to it in a note.
void pr9751() {
void pr9751(void) {
int *i;
char str[100];
const char kFormat1[] = "%00d"; // expected-note{{format string is defined here}}}
@ -190,7 +190,7 @@ void test_qualifiers(const int *cip, volatile int* vip,
scanf("%d", (cip_t)0); // expected-warning{{format specifies type 'int *' but the argument has type 'cip_t' (aka 'const int *')}}
}
void test_size_types() {
void test_size_types(void) {
size_t s = 0;
scanf("%zu", &s); // No warning.
@ -210,7 +210,7 @@ void test_size_types() {
scanf("%zn", &d3); // expected-warning-re{{format specifies type 'ssize_t *' (aka '{{.+}}') but the argument has type 'double *'}}
}
void test_ptrdiff_t_types() {
void test_ptrdiff_t_types(void) {
__UNSIGNED_PTRDIFF_TYPE__ p1 = 0;
scanf("%tu", &p1); // No warning.

View File

@ -122,7 +122,7 @@ void check_conditional_literal(const char* s, int i) {
#if !defined(__ANDROID__) && !defined(__Fuchsia__)
void check_writeback_specifier()
void check_writeback_specifier(void)
{
int x;
char *b;
@ -160,7 +160,7 @@ void check_writeback_specifier()
#else
void check_writeback_specifier()
void check_writeback_specifier(void)
{
int x;
printf("%n", &x); // expected-warning{{'%n' specifier not supported on this platform}}
@ -244,7 +244,7 @@ void check_asterisk_precision_width(int x) {
void __attribute__((format(printf,1,3))) myprintf(const char*, int blah, ...);
void test_myprintf() {
void test_myprintf(void) {
myprintf("%d", 17, 18); // okay
}
@ -318,7 +318,7 @@ void test10(int x, float f, int i, long long lli) {
typedef unsigned char uint8_t;
void should_understand_small_integers() {
void should_understand_small_integers(void) {
printf("%hhu", (short) 10); // expected-warning{{format specifies type 'unsigned char' but the argument has type 'short'}}
printf("%hu\n", (unsigned char)1); // warning with -Wformat-pedantic only
printf("%hu\n", (uint8_t)1); // warning with -Wformat-pedantic only
@ -389,7 +389,7 @@ void test_unicode_conversions(wchar_t *s) {
// Mac OS X supports positional arguments in format strings.
// This is an IEEE extension (IEEE Std 1003.1).
// FIXME: This is probably not portable everywhere.
void test_positional_arguments() {
void test_positional_arguments(void) {
printf("%0$", (int)2); // expected-warning{{position arguments in format strings start counting at 1 (not 0)}}
printf("%1$*0$d", (int) 2); // expected-warning{{position arguments in format strings start counting at 1 (not 0)}}
printf("%1$d", (int) 2); // no-warning
@ -404,7 +404,7 @@ void test_positional_arguments() {
// PR 6697 - Handle format strings where the data argument is not adjacent to the format string
void myprintf_PR_6697(const char *format, int x, ...) __attribute__((__format__(printf,1, 3)));
void test_pr_6697() {
void test_pr_6697(void) {
myprintf_PR_6697("%s\n", 1, "foo"); // no-warning
myprintf_PR_6697("%s\n", 1, (int)0); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
// FIXME: Not everything should clearly support positional arguments,
@ -419,7 +419,7 @@ void rdar8026030(FILE *fp) {
fprintf(fp, "\%"); // expected-warning{{incomplete format specifier}}
}
void bug7377_bad_length_mod_usage() {
void bug7377_bad_length_mod_usage(void) {
// Bad length modifiers
printf("%hhs", "foo"); // expected-warning{{length modifier 'hh' results in undefined behavior or no effect with 's' conversion specifier}}
printf("%1$zp", (void *)0); // expected-warning{{length modifier 'z' results in undefined behavior or no effect with 'p' conversion specifier}}
@ -480,7 +480,7 @@ void pr7981(wint_t c, wchar_t c2) {
}
// <rdar://problem/8269537> -Wformat-security says NULL is not a string literal
void rdar8269537() {
void rdar8269537(void) {
// This is likely to crash in most cases, but -Wformat-nonliteral technically
// doesn't warn in this case.
printf(0); // no-warning
@ -496,12 +496,12 @@ void rdar8332221(va_list ap, int *x, long *y) {
}
// PR8641
void pr8641() {
void pr8641(void) {
printf("%#x\n", 10);
printf("%#X\n", 10);
}
void posix_extensions() {
void posix_extensions(void) {
// Test %'d, "thousands grouping".
// <rdar://problem/8816343>
printf("%'d\n", 123456789); // no-warning
@ -516,13 +516,13 @@ void posix_extensions() {
#pragma GCC diagnostic warning "-Wformat"
#pragma GCC diagnostic ignored "-Wformat-security"
void pr8486() {
void pr8486(void) {
printf("%s", 1); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
}
// PR9314
// Don't warn about string literals that are PreDefinedExprs, e.g. __func__.
void pr9314() {
void pr9314(void) {
printf(__PRETTY_FUNCTION__); // no-warning
printf(__func__); // no-warning
}
@ -544,7 +544,7 @@ void check_char(unsigned char x, signed char y) {
// Test suppression of individual warnings.
void test_suppress_invalid_specifier() {
void test_suppress_invalid_specifier(void) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wformat-invalid-specifier"
printf("%@", 12); // no-warning
@ -557,7 +557,7 @@ void test_suppress_invalid_specifier() {
// Test that the printf call site is where the warning is attached. If the
// format string is somewhere else, point to it in a note.
void pr9751() {
void pr9751(void) {
const char kFormat1[] = "%d %d \n"; // expected-note{{format string is defined here}}}
printf(kFormat1, 0); // expected-warning{{more '%' conversions than data arguments}}
printf("%d %s\n", 0); // expected-warning{{more '%' conversions than data arguments}}
@ -638,7 +638,7 @@ void pr9751() {
0.0); // expected-warning{{format specifies}}
}
void pr18905() {
void pr18905(void) {
const char s1[] = "s\0%s"; // expected-note{{format string is defined here}}
const char s2[1] = "s"; // expected-note{{format string is defined here}}
const char s3[2] = "s\0%s"; // expected-warning{{initializer-string for char array is too long}}
@ -657,7 +657,7 @@ void __attribute__((format(strfmon,1,2))) monformat(const char *fmt, ...);
void __attribute__((format(strftime,1,0))) dateformat(const char *fmt);
// Other formats
void test_other_formats() {
void test_other_formats(void) {
char *str = "";
monformat("", 1); // expected-warning{{format string is empty}}
monformat(str); // expected-warning{{format string is not a string literal (potentially insecure)}}
@ -788,7 +788,7 @@ void test_char_pointer_arithmetic(int b) {
// expected-note@-2{{format string is defined here}}
}
void PR30481() {
void PR30481(void) {
// This caused crashes due to invalid casts.
printf(1 > 0); // expected-warning{{format string is not a string literal}} expected-warning{{incompatible integer to pointer conversion}} expected-note@format-strings.c:*{{passing argument to parameter here}} expected-note{{to avoid this}}
}
@ -797,7 +797,7 @@ void test_printf_opaque_ptr(void *op) {
printf("%s", op); // expected-warning{{format specifies type 'char *' but the argument has type 'void *'}}
}
void test_block() {
void test_block(void) {
void __attribute__((__format__(__printf__, 1, 2))) (^printf_arg1)(
const char *, ...) =
^(const char *fmt, ...) __attribute__((__format__(__printf__, 1, 2))) {

View File

@ -5,7 +5,7 @@ int printf(const char *msg, ...);
#define FMT "%hd %hu %d %u %hhd %hhu %c"
int main() {
int main(void) {
_Bool b = 0;
printf(FMT,
b, // expected-warning {{format specifies type 'short' but the argument has type '_Bool'}}

View File

@ -78,7 +78,7 @@ struct { int x; } emptyinit = {};
// expected-warning@+7 {{use of GNU indirect-goto extension}}
#endif
void labelvalue() {
void labelvalue(void) {
void *ptr;
ptr = &&foo;
foo:
@ -90,7 +90,7 @@ foo:
// expected-warning@+5 {{use of GNU statement expression extension}}
#endif
void statementexp()
void statementexp(void)
{
int a = ({ 1; });
}

View File

@ -2,4 +2,4 @@
int f(int restrict);
void main() {} // expected-warning {{return type of 'main' is not 'int'}} expected-note {{change return type to 'int'}}
void main(void) {} // expected-warning {{return type of 'main' is not 'int'}} expected-note {{change return type to 'int'}}

View File

@ -1,6 +1,6 @@
// RUN: %clang_cc1 %s -verify
int foo() {
int foo(void) {
int a;
// PR3788
asm("nop" : : "m"((int)(a))); // expected-error {{cast in a inline asm context requiring an lvalue}}

View File

@ -1,6 +1,6 @@
// RUN: %clang_cc1 %s -verify -fheinous-gnu-extensions
void foo() {
void foo(void) {
int a;
// PR3788
asm("nop" : : "m"((int)(a))); // expected-warning {{cast in an inline asm context requiring an lvalue}}

View File

@ -3,7 +3,7 @@
#include <stdint.h>
#include <limits.h>
int a() {int p; *(1 ? &p : (void*)(0 && (a(),1))) = 10;} // expected-error {{incomplete type 'void' is not assignable}}
int a(void) {int p; *(1 ? &p : (void*)(0 && (a(),1))) = 10;} // expected-error {{incomplete type 'void' is not assignable}}
// rdar://6091492 - ?: with __builtin_constant_p as the operand is an i-c-e.
int expr;
@ -27,7 +27,7 @@ struct c {
// Check that we can evaluate statement-expressions properly when
// constant-folding inside an ICE.
void PR49239() {
void PR49239(void) {
goto check_not_vla;
char not_vla[__builtin_constant_p(1) ? ({ 42; }) : -1]; // expected-warning {{statement expression}}
check_not_vla:;

View File

@ -13,13 +13,13 @@ void f1(void) {
calloc(0, 0, 0);
}
void f2() {
void f2(void) {
int index = 1;
}
static int index;
int f3() {
int f3(void) {
return index << 2;
}

View File

@ -8,7 +8,7 @@ typedef unsigned char Boolean;
extern int printf(__const char *__restrict __format, ...); // expected-note{{'printf' declared here}}
void func() {
void func(void) {
int32_t *vector[16];
const char compDesc[16 + 1];
int32_t compCount = 0;
@ -27,7 +27,7 @@ Boolean _CFCalendarDecomposeAbsoluteTimeV(const char *componentDesc, int32_t **v
// Test the typo-correction callback in Sema::ImplicitlyDefineFunction
extern int sformatf(char *str, __const char *__restrict __format, ...); // expected-note{{'sformatf' declared here}}
void test_implicit() {
void test_implicit(void) {
int formats = 0;
formatd("Hello, World!\n"); // expected-error{{implicit declaration of function 'formatd' is invalid in C99}} \
// expected-note{{did you mean 'sformatf'?}}

View File

@ -2,7 +2,7 @@
* RUN: not %clang_cc1 -fsyntax-only %s -std=c99 -pedantic-errors
*/
int A() {
int A(void) {
return X();
}

View File

@ -3,7 +3,7 @@
// RUN: %clang_cc1 %s -verify -Wconversion -Wno-implicit-float-conversion -DSMALL=float -DBIG=double -DNO_DIAG
// RUN: %clang_cc1 %s -verify -Wno-conversion -Wimplicit-float-conversion -DSMALL=float -DBIG=double
void f() {
void f(void) {
SMALL a;
BIG b = 0;
a = b;

View File

@ -8,7 +8,7 @@ long testReturn(long a, float b) {
}
#endif
void testAssignment() {
void testAssignment(void) {
float f = 222222;
double b = 222222222222L;
@ -21,7 +21,7 @@ void testAssignment() {
#endif
}
void testExpression() {
void testExpression(void) {
float a = 0.0f;
float b = 222222222222L + a; // expected-warning {{changes value from 222222222222 to 222222221312}}
@ -38,7 +38,7 @@ void testExpression() {
double f = i + e;
}
void testCNarrowing() {
void testCNarrowing(void) {
// Since this is a C file. C++11 narrowing is not in effect.
// In this case, we should issue warnings.
float a = {222222222222L}; // expected-warning {{changes value from 222222222222 to 222222221312}}

View File

@ -1,7 +1,7 @@
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-feature +sse2 -fsyntax-only -verify %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-feature +sse2 -fsyntax-only -verify %s -x c++
void f() {
void f(void) {
(void)_mm_getcsr(); // expected-warning{{implicitly declaring library function '_mm_getcsr'}} \
// expected-note{{include the header <xmmintrin.h> or explicitly provide a declaration for '_mm_getcsr'}}
_mm_setcsr(1); // expected-warning{{implicitly declaring library function '_mm_setcsr'}} \
@ -19,16 +19,16 @@ void f() {
// expected-note{{include the header <emmintrin.h> or explicitly provide a declaration for '_mm_pause'}}
}
unsigned int _mm_getcsr();
unsigned int _mm_getcsr(void);
void _mm_setcsr(unsigned int);
void _mm_sfence();
void _mm_sfence(void);
void _mm_clflush(void const *);
void _mm_lfence();
void _mm_mfence();
void _mm_pause();
void _mm_lfence(void);
void _mm_mfence(void);
void _mm_pause(void);
void g() {
void g(void) {
(void)_mm_getcsr();
_mm_setcsr(1);
_mm_sfence();

View File

@ -1,26 +1,26 @@
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s -fms-extensions
// RUN: %clang_cc1 -triple i386-unknown-unknown -fsyntax-only -verify %s -fms-extensions
void f() {
void f(void) {
(void)_byteswap_ushort(42); // expected-warning{{implicitly declaring library function '_byteswap_ushort'}} \
// expected-note{{include the header <stdlib.h> or explicitly provide a declaration for '_byteswap_ushort'}}
(void)_byteswap_uint64(42LL); // expected-warning{{implicitly declaring library function '_byteswap_uint64'}} \
// expected-note{{include the header <stdlib.h> or explicitly provide a declaration for '_byteswap_uint64'}}
}
void _byteswap_ulong(); // expected-warning{{incompatible redeclaration of library function '_byteswap_ulong'}} \
void _byteswap_ulong(void); // expected-warning{{incompatible redeclaration of library function '_byteswap_ulong'}} \
// expected-note{{'_byteswap_ulong' is a builtin}}
unsigned short _byteswap_ushort(unsigned short);
unsigned long long _byteswap_uint64(unsigned long long);
void g() {
void g(void) {
(void)_byteswap_ushort(42);
(void)_byteswap_uint64(42LL);
}
#if defined(__x86_64__)
void h() {
void h(void) {
(void)__mulh(21, 2); // expected-warning{{implicitly declaring library function '__mulh'}} \
// expected-note{{include the header <intrin.h> or explicitly provide a declaration for '__mulh'}}
(void)__umulh(21, 2); // expected-warning{{implicitly declaring library function '__umulh'}} \
@ -30,14 +30,14 @@ void h() {
long long __mulh(long long, long long);
unsigned long long __umulh(unsigned long long, unsigned long long);
void i() {
void i(void) {
(void)__mulh(21, 2);
(void)__umulh(21, 2);
}
#endif
#if defined(i386)
void h() {
void h(void) {
(void)__mulh(21LL, 2LL); // expected-warning{{implicit declaration of function '__mulh' is invalid}}
(void)__umulh(21ULL, 2ULL); // expected-warning{{implicit declaration of function '__umulh' is invalid}}
}

View File

@ -9,6 +9,6 @@ typedef int (*MyFnTyA)(int *, char *);
int bar(char *a, int *b) { return 0; }
int foo(MyFnTyA x) { return 0; } // expected-note {{passing argument to parameter 'x' here}}
void baz() {
void baz(void) {
foo(&bar); // expected-warning {{incompatible function pointer types passing 'int (*)(char *, int *)' to parameter of type 'MyFnTyA' (aka 'int (*)(int *, char *)')}}
}

View File

@ -15,7 +15,7 @@ extern struct foo e;
int ary[]; // expected-warning {{tentative array definition assumed to have one element}}
struct foo bary[]; // expected-error {{array has incomplete element type 'struct foo'}}
void func() {
void func(void) {
int ary[]; // expected-error{{definition of variable with array type needs an explicit size or an initializer}}
void b; // expected-error {{variable has incomplete type 'void'}}
struct foo f; // expected-error {{variable has incomplete type 'struct foo'}}

View File

@ -1,6 +1,6 @@
// RUN: %clang_cc1 -triple arm-unknown-gnu -fsyntax-only -verify %s
void f() {
void f(void) {
struct EmptyStruct {};
struct EmptyStruct S;
__builtin_va_end(S); // no-crash, expected-error {{non-const lvalue reference to type '__builtin_va_list' cannot bind to a value of unrelated type 'struct EmptyStruct'}}

View File

@ -7,7 +7,7 @@ typedef struct _NSRect { NSPoint origin; NSSize size; } NSRect;
extern const NSPoint NSZeroPoint;
extern NSSize canvasSize();
void func() {
extern NSSize canvasSize(void);
void func(void) {
const NSRect canvasRect = { NSZeroPoint, canvasSize() };
}

View File

@ -25,7 +25,7 @@ struct union_crash
};
};
int test() {
int test(void) {
int a[10];
int b[10] = a; // expected-error {{array initializer must be an initializer list}}
int +; // expected-error {{expected identifier or '('}}
@ -38,9 +38,9 @@ int test() {
struct cdiff_cmd {
const char *name;
unsigned short argc;
int (*handler)();
int (*handler)(void);
};
int cdiff_cmd_open();
int cdiff_cmd_open(void);
struct cdiff_cmd commands[] = {
{"OPEN", 1, &cdiff_cmd_open }
};
@ -148,14 +148,14 @@ const double pr5447 = (0.05 < -1.0) ? -1.0 : 0.0499878;
// behaviour of accepting bar and zed but not foo. GCC's behaviour was
// changed in 2007 (rev 122551), so we should be able to change too one
// day.
int PR4386_bar();
int PR4386_foo() __attribute((weak));
int PR4386_zed();
int PR4386_bar(void);
int PR4386_foo(void) __attribute((weak));
int PR4386_zed(void);
int PR4386_a = ((void *) PR4386_bar) != 0;
int PR4386_b = ((void *) PR4386_foo) != 0; // expected-error{{initializer element is not a compile-time constant}}
int PR4386_c = ((void *) PR4386_zed) != 0;
int PR4386_zed() __attribute((weak));
int PR4386_zed(void) __attribute((weak));
// <rdar://problem/10185490> (derived from SPEC vortex benchmark)
typedef char strty[10];

View File

@ -7,26 +7,26 @@
// Check the use of static variables in non-static inline functions.
static int staticVar; // expected-note + {{'staticVar' declared here}}
static int staticFunction(); // expected-note + {{'staticFunction' declared here}}
static int staticFunction(void); // expected-note + {{'staticFunction' declared here}}
static struct { int x; } staticStruct; // expected-note + {{'staticStruct' declared here}}
inline int useStatic () { // expected-note 3 {{use 'static' to give inline function 'useStatic' internal linkage}}
inline int useStatic (void) { // expected-note 3 {{use 'static' to give inline function 'useStatic' internal linkage}}
staticFunction(); // expected-warning{{static function 'staticFunction' is used in an inline function with external linkage}}
(void)staticStruct.x; // expected-warning{{static variable 'staticStruct' is used in an inline function with external linkage}}
return staticVar; // expected-warning{{static variable 'staticVar' is used in an inline function with external linkage}}
}
extern inline int useStaticFromExtern () { // no suggestions
extern inline int useStaticFromExtern (void) { // no suggestions
staticFunction(); // expected-warning{{static function 'staticFunction' is used in an inline function with external linkage}}
return staticVar; // expected-warning{{static variable 'staticVar' is used in an inline function with external linkage}}
}
static inline int useStaticFromStatic () {
static inline int useStaticFromStatic (void) {
staticFunction(); // no-warning
return staticVar; // no-warning
}
extern inline int useStaticInlineFromExtern () {
extern inline int useStaticInlineFromExtern (void) {
// Heuristic: if the function we're using is also inline, don't warn.
// This can still be wrong (in this case, we end up inlining calls to
// staticFunction and staticVar) but this got very noisy even using
@ -34,9 +34,9 @@ extern inline int useStaticInlineFromExtern () {
return useStaticFromStatic(); // no-warning
}
static int constFunction() __attribute__((const));
static int constFunction(void) __attribute__((const));
inline int useConst () {
inline int useConst (void) {
return constFunction(); // no-warning
}
@ -56,7 +56,7 @@ int d(inline int a); // expected-error{{'inline' can only appear on functions}}
// Check that the warnings from the "header file" aren't on by default in
// the main source file.
inline int useStaticMainFile () {
inline int useStaticMainFile (void) {
staticFunction(); // no-warning
return staticVar; // no-warning
}
@ -66,32 +66,32 @@ inline int useStaticMainFile () {
#pragma clang diagnostic push
#pragma clang diagnostic warning "-Wstatic-in-inline"
inline int useStaticAgain () { // expected-note 2 {{use 'static' to give inline function 'useStaticAgain' internal linkage}}
inline int useStaticAgain (void) { // expected-note 2 {{use 'static' to give inline function 'useStaticAgain' internal linkage}}
staticFunction(); // expected-warning{{static function 'staticFunction' is used in an inline function with external linkage}}
return staticVar; // expected-warning{{static variable 'staticVar' is used in an inline function with external linkage}}
}
#pragma clang diagnostic pop
inline void defineStaticVar() { // expected-note {{use 'static' to give inline function 'defineStaticVar' internal linkage}}
inline void defineStaticVar(void) { // expected-note {{use 'static' to give inline function 'defineStaticVar' internal linkage}}
static const int x = 0; // ok
static int y = 0; // expected-warning {{non-constant static local variable in inline function may be different in different files}}
}
extern inline void defineStaticVarInExtern() {
extern inline void defineStaticVarInExtern(void) {
static const int x = 0; // ok
static int y = 0; // ok
}
// Check behavior of line markers.
# 1 "XXX.h" 1
inline int useStaticMainFileInLineMarker() { // expected-note 2 {{use 'static' to give inline function 'useStaticMainFileInLineMarker' internal linkage}}
inline int useStaticMainFileInLineMarker(void) { // expected-note 2 {{use 'static' to give inline function 'useStaticMainFileInLineMarker' internal linkage}}
staticFunction(); // expected-warning{{static function 'staticFunction' is used in an inline function with external linkage}}
return staticVar; // expected-warning{{static variable 'staticVar' is used in an inline function with external linkage}}
}
# 100 "inline.c" 2
inline int useStaticMainFileAfterLineMarker() {
inline int useStaticMainFileAfterLineMarker(void) {
staticFunction(); // no-warning
return staticVar; // no-warning
}

View File

@ -158,7 +158,7 @@ uint64_t check_integer_overflows(int i) {
return ((4608 * 1024 * 1024) + ((uint64_t)(4608 * 1024 * 1024)));
}
void check_integer_overflows_in_function_calls() {
void check_integer_overflows_in_function_calls(void) {
// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
(void)f0(4608 * 1024 * 1024);
@ -172,7 +172,7 @@ void check_integer_overflows_in_function_calls() {
// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
(void)f2(0, f0(4608 * 1024 * 1024));
}
void check_integer_overflows_in_array_size() {
void check_integer_overflows_in_array_size(void) {
int arr[4608 * 1024 * 1024]; // expected-warning {{overflow in expression; result is 536870912 with type 'int'}}
}
@ -204,7 +204,7 @@ struct s2 {
}
};
void PR49619() {
void PR49619(void) {
int n;
n = ({
while (1)

View File

@ -13,11 +13,11 @@ int var4 __attribute__((internal_linkage)); // expected-error{{'internal_linkage
int var5 __attribute__((internal_linkage)); // expected-note{{conflicting attribute is here}}
int var5 __attribute__((common)); // expected-error{{'common' and 'internal_linkage' attributes are not compatible}}
__attribute__((internal_linkage)) int f() {}
__attribute__((internal_linkage)) int f(void) {}
struct __attribute__((internal_linkage)) S { // expected-warning{{'internal_linkage' attribute only applies to variables, functions, and classes}}
};
__attribute__((internal_linkage("foo"))) int g() {} // expected-error{{'internal_linkage' attribute takes no arguments}}
__attribute__((internal_linkage("foo"))) int g(void) {} // expected-error{{'internal_linkage' attribute takes no arguments}}
int var6 [[clang::internal_linkage]];
int var7 [[clang::internal_linkage]] __attribute__((common)); // expected-error{{'internal_linkage' and 'common' attributes are not compatible}} \

View File

@ -1,7 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsyntax-only -x c++ -Werror %s
int pr8880_1() {
int pr8880_1(void) {
int first = 1;
for ( ; ({ if (first) { first = 0; continue; } 0; }); )
return 0;

View File

@ -9,7 +9,7 @@ typedef int vec __attribute__((vector_size(4)));
typedef struct test_struct {
} test_struct;
void f1() {
void f1(void) {
cx4x4 m1;
ix4x4 m2;
sx4x4 m3;
@ -49,7 +49,7 @@ typedef signed int signed_int_12x12 __attribute__((matrix_type(12, 12)));
typedef unsigned int unsigned_int_12x12 __attribute__((matrix_type(12, 12)));
typedef unsigned int unsigned_int_10x10 __attribute__((matrix_type(10, 10)));
void f2() {
void f2(void) {
float2_8x8 m1;
double_10x10 m2;
double_8x8 m3;

View File

@ -128,7 +128,7 @@ void matrix_matrix_divide(sx10x10_t a, sx5x10_t b, ix10x5_t c, ix10x10_t d, floa
// expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'sx10x10_t')}}
}
sx5x10_t get_matrix();
sx5x10_t get_matrix(void);
void insert(sx5x10_t a, float f) {
// Non integer indexes.

View File

@ -1,6 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only %s -verify
char memset(); // expected-warning {{incompatible redeclaration of library function 'memset'}} expected-note{{'memset' is a builtin with type}}
char test() {
char memset(void); // expected-warning {{incompatible redeclaration of library function 'memset'}} expected-note{{'memset' is a builtin with type}}
char test(void) {
return memset();
}

View File

@ -3,27 +3,27 @@ struct a { int b; };
struct a test __attribute__((interrupt)); // expected-warning {{'interrupt' attribute only applies to functions and methods}}
__attribute__((interrupt("EIC"))) void foo1() {} // expected-warning {{'interrupt' attribute argument not supported: 'EIC'}}
__attribute__((interrupt("EIC"))) void foo1(void) {} // expected-warning {{'interrupt' attribute argument not supported: 'EIC'}}
__attribute__((interrupt("eic", 1))) void foo2() {} // expected-error {{'interrupt' attribute takes no more than 1 argument}}
__attribute__((interrupt("eic", 1))) void foo2(void) {} // expected-error {{'interrupt' attribute takes no more than 1 argument}}
__attribute__((interrupt("eic"))) void foo3() {}
__attribute__((interrupt("vector=sw0"))) void foo4() {}
__attribute__((interrupt("vector=hw0"))) void foo5() {}
__attribute__((interrupt("vector=hw1"))) void foo6() {}
__attribute__((interrupt("vector=hw2"))) void foo7() {}
__attribute__((interrupt("vector=hw3"))) void foo8() {}
__attribute__((interrupt("vector=hw4"))) void foo9() {}
__attribute__((interrupt("vector=hw5"))) void fooa() {}
__attribute__((interrupt(""))) void food() {}
__attribute__((interrupt("eic"))) void foo3(void) {}
__attribute__((interrupt("vector=sw0"))) void foo4(void) {}
__attribute__((interrupt("vector=hw0"))) void foo5(void) {}
__attribute__((interrupt("vector=hw1"))) void foo6(void) {}
__attribute__((interrupt("vector=hw2"))) void foo7(void) {}
__attribute__((interrupt("vector=hw3"))) void foo8(void) {}
__attribute__((interrupt("vector=hw4"))) void foo9(void) {}
__attribute__((interrupt("vector=hw5"))) void fooa(void) {}
__attribute__((interrupt(""))) void food(void) {}
__attribute__((interrupt)) int foob() {return 0;} // expected-warning {{MIPS 'interrupt' attribute only applies to functions that have a 'void' return type}}
__attribute__((interrupt)) int foob(void) {return 0;} // expected-warning {{MIPS 'interrupt' attribute only applies to functions that have a 'void' return type}}
__attribute__((interrupt())) void fooc(int a) {} // expected-warning {{MIPS 'interrupt' attribute only applies to functions that have no parameters}}
__attribute__((interrupt,mips16)) void fooe() {} // expected-error {{'mips16' and 'interrupt' attributes are not compatible}} \
__attribute__((interrupt,mips16)) void fooe(void) {} // expected-error {{'mips16' and 'interrupt' attributes are not compatible}} \
// expected-note {{conflicting attribute is here}}
__attribute__((mips16,interrupt)) void foof() {} // expected-error {{'interrupt' and 'mips16' attributes are not compatible}} \
__attribute__((mips16,interrupt)) void foof(void) {} // expected-error {{'interrupt' and 'mips16' attributes are not compatible}} \
// expected-note {{conflicting attribute is here}}
__attribute__((interrupt)) __attribute__ ((mips16)) void foo10() {} // expected-error {{'mips16' and 'interrupt' attributes are not compatible}} \
__attribute__((interrupt)) __attribute__ ((mips16)) void foo10(void) {} // expected-error {{'mips16' and 'interrupt' attributes are not compatible}} \
// expected-note {{conflicting attribute is here}}
__attribute__((mips16)) __attribute ((interrupt)) void foo11() {} // expected-error {{'interrupt' and 'mips16' attributes are not compatible}} \
__attribute__((mips16)) __attribute ((interrupt)) void foo11(void) {} // expected-error {{'interrupt' and 'mips16' attributes are not compatible}} \
// expected-note {{conflicting attribute is here}}

View File

@ -1,23 +1,23 @@
// RUN: %clang_cc1 -triple mipsel-linux-gnu -fsyntax-only -verify %s
void foo32();
void foo16();
void __attribute__((nomips16)) foo32();
void __attribute__((mips16)) foo16();
void foo32(void);
void foo16(void);
void __attribute__((nomips16)) foo32(void);
void __attribute__((mips16)) foo16(void);
void __attribute__((nomips16)) foo32_();
void __attribute__((mips16)) foo16_();
void foo32_();
void foo16_();
void __attribute__((nomips16)) foo32_(void);
void __attribute__((mips16)) foo16_(void);
void foo32_(void);
void foo16_(void);
void foo32__() __attribute__((nomips16));
void foo32__() __attribute__((mips16));
void foo32__(void) __attribute__((nomips16));
void foo32__(void) __attribute__((mips16));
void foo32a() __attribute__((nomips16(0))) ; // expected-error {{'nomips16' attribute takes no arguments}}
void __attribute__((mips16(1))) foo16a(); // expected-error {{'mips16' attribute takes no arguments}}
void foo32a(void) __attribute__((nomips16(0))) ; // expected-error {{'nomips16' attribute takes no arguments}}
void __attribute__((mips16(1))) foo16a(void); // expected-error {{'mips16' attribute takes no arguments}}
void __attribute__((nomips16(1, 2))) foo32b(); // expected-error {{'nomips16' attribute takes no arguments}}
void __attribute__((mips16(1, 2))) foo16b(); // expected-error {{'mips16' attribute takes no arguments}}
void __attribute__((nomips16(1, 2))) foo32b(void); // expected-error {{'nomips16' attribute takes no arguments}}
void __attribute__((mips16(1, 2))) foo16b(void); // expected-error {{'mips16' attribute takes no arguments}}
__attribute((nomips16)) int a; // expected-error {{attribute only applies to functions}}

View File

@ -1,7 +1,7 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
void __attribute__((nomips16)) foo32(); // expected-warning {{unknown attribute 'nomips16' ignored}}
void __attribute__((mips16)) foo16(); // expected-warning {{unknown attribute 'mips16' ignored}}
void __attribute__((nomips16)) foo32(void); // expected-warning {{unknown attribute 'nomips16' ignored}}
void __attribute__((mips16)) foo16(void); // expected-warning {{unknown attribute 'mips16' ignored}}

Some files were not shown because too many files have changed in this diff Show More