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 commit is contained in:
Aaron Ballman 2022-03-31 13:43:53 -04:00
parent 46774df307
commit 0e890904ea
18 changed files with 27 additions and 27 deletions

View File

@ -8,7 +8,7 @@
#define LANG_VER_OK
#endif
void atomic_types_test() {
void atomic_types_test(void) {
// OpenCL v2.0 s6.13.11.6 defines supported atomic types.
// Non-optional types

View File

@ -3,7 +3,7 @@
typedef int int3 __attribute__((ext_vector_type(3)));
void test()
void test(void)
{
int index = (int3)(1, 2, 3).x * (int3)(3, 2, 1).y;
}

View File

@ -15,7 +15,7 @@
int printf(__constant const char *st, ...);
void foo() {
void foo(void) {
NO_VAR_FUNC(1, 2, 3);
VAR_FUNC(1, 2, 3);
#if !__OPENCL_CPP_VERSION__

View File

@ -6,6 +6,6 @@ kernel void test(global float *out, global float *in, global int* in2) {
out[0] = __builtin_frexpf(in[0], in2);
}
void pr28651() {
void pr28651(void) {
__builtin_alloca(value); // expected-error{{use of undeclared identifier}}
}

View File

@ -385,7 +385,7 @@ void test_conversion(__global int *arg_glob, __local int *arg_loc,
#endif
}
void test_ternary() {
void test_ternary(void) {
AS int *var_cond;
__generic int *var_gen;
__global int *var_glob;
@ -500,7 +500,7 @@ void test_ternary() {
#endif
}
void test_pointer_chains() {
void test_pointer_chains(void) {
AS int *AS *var_as_as_int;
AS int *AS_COMP *var_asc_as_int;
AS_INCOMP int *AS_COMP *var_asc_asn_int;

View File

@ -4,7 +4,7 @@
// Confirm CL2.0 Clang builtins are not available in earlier versions and in OpenCL C 3.0 without required features.
kernel void dse_builtins() {
kernel void dse_builtins(void) {
int tmp;
enqueue_kernel(tmp, tmp, tmp, ^(void) { // expected-error{{implicit declaration of function 'enqueue_kernel' is invalid in OpenCL}}
return;
@ -22,7 +22,7 @@ kernel void dse_builtins() {
#endif
}
void pipe_builtins() {
void pipe_builtins(void) {
int tmp;
foo(void); // expected-error{{implicit declaration of function 'foo' is invalid in OpenCL}}

View File

@ -6,7 +6,7 @@
global clk_event_t ce; // expected-error {{the '__global clk_event_t' type cannot be used to declare a program scope variable}}
int clk_event_tests() {
int clk_event_tests(void) {
event_t e;
clk_event_t ce1;
clk_event_t ce2;

View File

@ -27,7 +27,7 @@
// First, test that Clang gracefully handles missing types.
#ifdef NO_HEADER
void test_without_header() {
void test_without_header(void) {
barrier(0);
// expected-note@-1 0+{{candidate function not viable}}
// expected-error@-2 0+{{argument type 'void' is incomplete}}
@ -215,7 +215,7 @@ void test_legacy_atomics_cpp(__generic volatile unsigned int *a) {
}
#endif
kernel void basic_conversion() {
kernel void basic_conversion(void) {
float f;
char2 c2;
long2 l2;
@ -233,7 +233,7 @@ kernel void basic_conversion() {
i4 = convert_int4_sat(f4);
}
kernel void basic_conversion_neg() {
kernel void basic_conversion_neg(void) {
int i;
float f;
@ -336,7 +336,7 @@ kernel void extended_subgroup(global uint4 *out, global int *scalar, global char
#endif
}
kernel void basic_vector_data() {
kernel void basic_vector_data(void) {
#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
generic void *generic_p;
#endif
@ -368,7 +368,7 @@ kernel void basic_vector_data() {
f16 = vload16(s, (const __private float *) private_p);
}
kernel void basic_work_item() {
kernel void basic_work_item(void) {
uint ui;
barrier(CLK_GLOBAL_MEM_FENCE);

View File

@ -2,6 +2,6 @@
int constant c[3] = {0};
void foo() {
void foo(void) {
c[0] = 1; //expected-error{{read-only variable is not assignable}}
}

View File

@ -60,7 +60,7 @@ void test2(write_only pipe int p, global int* ptr){
sub_group_commit_read_pipe(p, tmp); // expected-error{{invalid pipe access modifier (expecting read_only)}}
}
void test3(){
void test3(void){
int tmp;
get_pipe_num_packets(tmp); // expected-error {{first argument to 'get_pipe_num_packets' must be a pipe type}}
get_pipe_max_packets(tmp); // expected-error {{first argument to 'get_pipe_max_packets' must be a pipe type}}

View File

@ -25,7 +25,7 @@ typedef int pipe;
// expected-warning@-6 {{typedef requires a name}}
#endif
void bar() {
void bar(void) {
reserve_id_t r;
#if defined(__OPENCL_C_VERSION__)
// expected-error@-2 {{use of undeclared identifier 'reserve_id_t'}}

View File

@ -67,7 +67,7 @@ void bad(sampler_t *); // expected-error{{pointer to type 'sampler_t' is invalid
void bad(sampler_t*); // expected-error{{pointer to type 'sampler_t' is invalid in OpenCL}}
#endif
void bar() {
void bar(void) {
sampler_t smp1 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
sampler_t smp2 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST;
smp1=smp2; //expected-error{{invalid operands to binary expression ('sampler_t' and 'sampler_t')}}

View File

@ -35,7 +35,7 @@ char2 ptest06(char2 c) {
return c << 1;
}
void ptest07() {
void ptest07(void) {
char3 v = {1,1,1};
char3 w = {1,2,3};

View File

@ -19,10 +19,10 @@ extern local float g_local_extern_var; // expected-error {{extern variable m
extern private float g_private_extern_var; // expected-error {{extern variable must reside in global or constant address space}}
extern generic float g_generic_extern_var; // expected-error {{extern variable must reside in global or constant address space}}
static void kernel bar() { // expected-error{{kernel functions cannot be declared static}}
static void kernel bar(void) { // expected-error{{kernel functions cannot be declared static}}
}
void kernel foo() {
void kernel foo(void) {
constant int L1 = 0;
local int L2;
global int L3; // expected-error{{function scope variable cannot be declared in global address space}}

View File

@ -151,10 +151,10 @@ void kernel foo(int x) {
local int *constant L10 = &L2; // expected-error {{initializer element is not a compile-time constant}}
}
static void kernel bar() { // expected-error{{kernel functions cannot be declared static}}
static void kernel bar(void) { // expected-error{{kernel functions cannot be declared static}}
}
void f() {
void f(void) {
constant int L1 = 0; // expected-error{{non-kernel function variable cannot be declared in constant address space}}
local int L2; // expected-error{{non-kernel function variable cannot be declared in local address space}}
global int L3; // expected-error{{function scope variable cannot be declared in global address space}}

View File

@ -4,7 +4,7 @@
typedef __attribute__((ext_vector_type(2))) unsigned int uint2;
typedef __attribute__((ext_vector_type(2))) int int2;
void unsignedCompareOps()
void unsignedCompareOps(void)
{
uint2 A, B;
int2 result = A != B;

View File

@ -5,7 +5,7 @@ typedef __attribute__((ext_vector_type(4))) unsigned int uint4;
typedef __attribute__((ext_vector_type(8))) long long8;
typedef __attribute__((ext_vector_type(4))) float float4;
void vectorIncrementDecrementOps()
void vectorIncrementDecrementOps(void)
{
char2 A = (char2)(1);
uint4 B = (uint4)(1);
@ -18,7 +18,7 @@ void vectorIncrementDecrementOps()
C++;
}
void invalidIncrementDecrementOps() {
void invalidIncrementDecrementOps(void) {
((float4)(1.0f))++; // expected-error{{cannot increment value of type 'float4'}}
float4 i;
++i; // expected-error{{cannot increment value of type '__private float4'}}

View File

@ -2,7 +2,7 @@
typedef float float8 __attribute__((ext_vector_type(8)));
void foo() {
void foo(void) {
float8 f2 = (float8)(0, 0, 0, 0, 0, 0, 0, 0);
f2.s01234; // expected-error {{vector component access has invalid length 5. Supported: 1,2,3,4,8,16}}