[clang] 0e89090 - Use functions with prototypes when appropriate; NFC

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 31 10:45:50 PDT 2022


Author: Aaron Ballman
Date: 2022-03-31T13:45:39-04:00
New Revision: 0e890904ea342aba088ed2a55b537ffdb0562234

URL: https://github.com/llvm/llvm-project/commit/0e890904ea342aba088ed2a55b537ffdb0562234
DIFF: https://github.com/llvm/llvm-project/commit/0e890904ea342aba088ed2a55b537ffdb0562234.diff

LOG: 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);

Added: 
    

Modified: 
    clang/test/Parser/opencl-atomics-cl20.cl
    clang/test/Parser/vector-cast-define.cl
    clang/test/Preprocessor/macro_variadic.cl
    clang/test/Sema/builtins.cl
    clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
    clang/test/SemaOpenCL/clang-builtin-version.cl
    clang/test/SemaOpenCL/clk_event_t.cl
    clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
    clang/test/SemaOpenCL/invalid-assignment-constant-address-space.cl
    clang/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
    clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
    clang/test/SemaOpenCL/sampler_t.cl
    clang/test/SemaOpenCL/shifts.cl
    clang/test/SemaOpenCL/storageclass-cl20.cl
    clang/test/SemaOpenCL/storageclass.cl
    clang/test/SemaOpenCL/vec_compare.cl
    clang/test/SemaOpenCL/vector_inc_dec_ops.cl
    clang/test/SemaOpenCL/vector_swizzle_length.cl

Removed: 
    


################################################################################
diff  --git a/clang/test/Parser/opencl-atomics-cl20.cl b/clang/test/Parser/opencl-atomics-cl20.cl
index 50866dd61591e..2648142f28e7c 100644
--- a/clang/test/Parser/opencl-atomics-cl20.cl
+++ b/clang/test/Parser/opencl-atomics-cl20.cl
@@ -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

diff  --git a/clang/test/Parser/vector-cast-define.cl b/clang/test/Parser/vector-cast-define.cl
index ec4eba7a78488..44acf9a6b0e62 100644
--- a/clang/test/Parser/vector-cast-define.cl
+++ b/clang/test/Parser/vector-cast-define.cl
@@ -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;
 }

diff  --git a/clang/test/Preprocessor/macro_variadic.cl b/clang/test/Preprocessor/macro_variadic.cl
index e588964871216..04e96e3c21465 100644
--- a/clang/test/Preprocessor/macro_variadic.cl
+++ b/clang/test/Preprocessor/macro_variadic.cl
@@ -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__

diff  --git a/clang/test/Sema/builtins.cl b/clang/test/Sema/builtins.cl
index 7cde5e1a9e4d4..c6bdbfc827b84 100644
--- a/clang/test/Sema/builtins.cl
+++ b/clang/test/Sema/builtins.cl
@@ -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}}
 }

diff  --git a/clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl b/clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
index 482254190789a..5942efb624ad3 100644
--- a/clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
+++ b/clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
@@ -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;

diff  --git a/clang/test/SemaOpenCL/clang-builtin-version.cl b/clang/test/SemaOpenCL/clang-builtin-version.cl
index 7111db1784c60..a3e5b5bd80fff 100644
--- a/clang/test/SemaOpenCL/clang-builtin-version.cl
+++ b/clang/test/SemaOpenCL/clang-builtin-version.cl
@@ -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}}

diff  --git a/clang/test/SemaOpenCL/clk_event_t.cl b/clang/test/SemaOpenCL/clk_event_t.cl
index 4cc579aa3da20..b45226e0ab195 100644
--- a/clang/test/SemaOpenCL/clk_event_t.cl
+++ b/clang/test/SemaOpenCL/clk_event_t.cl
@@ -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;

diff  --git a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
index 89a4646839acb..e3602aa95e2a9 100644
--- a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -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 at -1 0+{{candidate function not viable}}
   // expected-error at -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);

diff  --git a/clang/test/SemaOpenCL/invalid-assignment-constant-address-space.cl b/clang/test/SemaOpenCL/invalid-assignment-constant-address-space.cl
index 32917c493ce3a..1734b258937ed 100644
--- a/clang/test/SemaOpenCL/invalid-assignment-constant-address-space.cl
+++ b/clang/test/SemaOpenCL/invalid-assignment-constant-address-space.cl
@@ -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}}
 }

diff  --git a/clang/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl b/clang/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
index 36e76621d24a6..1e02b8f0e675d 100644
--- a/clang/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
+++ b/clang/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
@@ -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}}

diff  --git a/clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl b/clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
index a6920e963e990..9e2869af87b4e 100644
--- a/clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
+++ b/clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
@@ -25,7 +25,7 @@ typedef int pipe;
 // expected-warning at -6 {{typedef requires a name}}
 #endif
 
-void bar() {
+void bar(void) {
  reserve_id_t r;
 #if defined(__OPENCL_C_VERSION__)
 // expected-error at -2 {{use of undeclared identifier 'reserve_id_t'}}

diff  --git a/clang/test/SemaOpenCL/sampler_t.cl b/clang/test/SemaOpenCL/sampler_t.cl
index 33086343489f3..3a23f688c7530 100644
--- a/clang/test/SemaOpenCL/sampler_t.cl
+++ b/clang/test/SemaOpenCL/sampler_t.cl
@@ -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')}}

diff  --git a/clang/test/SemaOpenCL/shifts.cl b/clang/test/SemaOpenCL/shifts.cl
index 257f70a956d51..c34401df8efb1 100644
--- a/clang/test/SemaOpenCL/shifts.cl
+++ b/clang/test/SemaOpenCL/shifts.cl
@@ -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};
 

diff  --git a/clang/test/SemaOpenCL/storageclass-cl20.cl b/clang/test/SemaOpenCL/storageclass-cl20.cl
index f07966e5bd01f..98a1e9270170f 100644
--- a/clang/test/SemaOpenCL/storageclass-cl20.cl
+++ b/clang/test/SemaOpenCL/storageclass-cl20.cl
@@ -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}}

diff  --git a/clang/test/SemaOpenCL/storageclass.cl b/clang/test/SemaOpenCL/storageclass.cl
index 827c4fa839935..4b9d6e9dd4f2d 100644
--- a/clang/test/SemaOpenCL/storageclass.cl
+++ b/clang/test/SemaOpenCL/storageclass.cl
@@ -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}}

diff  --git a/clang/test/SemaOpenCL/vec_compare.cl b/clang/test/SemaOpenCL/vec_compare.cl
index 567629c10d56f..064305951158f 100644
--- a/clang/test/SemaOpenCL/vec_compare.cl
+++ b/clang/test/SemaOpenCL/vec_compare.cl
@@ -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;

diff  --git a/clang/test/SemaOpenCL/vector_inc_dec_ops.cl b/clang/test/SemaOpenCL/vector_inc_dec_ops.cl
index 533253ee696f6..1e3c599453d00 100644
--- a/clang/test/SemaOpenCL/vector_inc_dec_ops.cl
+++ b/clang/test/SemaOpenCL/vector_inc_dec_ops.cl
@@ -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'}}

diff  --git a/clang/test/SemaOpenCL/vector_swizzle_length.cl b/clang/test/SemaOpenCL/vector_swizzle_length.cl
index 4dbb5bd76ee0a..f36ae201205e0 100644
--- a/clang/test/SemaOpenCL/vector_swizzle_length.cl
+++ b/clang/test/SemaOpenCL/vector_swizzle_length.cl
@@ -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}}


        


More information about the cfe-commits mailing list