From eab5bacf9f06eb6c37a070d89c403693d09f17a7 Mon Sep 17 00:00:00 2001 From: Cary R Date: Thu, 22 Sep 2011 19:57:59 -0700 Subject: [PATCH] Remove clang/clang++ warnings. This patch makes the code consistently use struct/class in the C++ files, it removes a couple shadow warnings and where a class pointer is passed to the C routines, it defines the pointer as a class for C++ and as struct for C and it removes a namespace std duplication. --- ivl_target.h | 18 ++++++++++++++++++ vhdlpp/vhdlint.cc | 2 ++ vhdlpp/vhdlint.h | 2 -- vvp/codes.h | 2 +- vvp/compile.cc | 8 ++++---- vvp/compile.h | 6 +++--- vvp/schedule.cc | 16 ++++++++-------- vvp/vpi_priv.h | 2 +- vvp/vvp_island.h | 4 ++-- vvp/vvp_net.cc | 8 ++++---- vvp/vvp_net.h | 8 ++++---- vvp/vvp_net_sig.h | 4 ++-- vvp/vvp_vpi_callback.h | 6 +++--- 13 files changed, 52 insertions(+), 34 deletions(-) diff --git a/ivl_target.h b/ivl_target.h index d46454cd4..1c5db1177 100644 --- a/ivl_target.h +++ b/ivl_target.h @@ -157,8 +157,21 @@ typedef struct ivl_array_s *ivl_array_t; typedef struct ivl_branch_s *ivl_branch_t; typedef struct ivl_delaypath_s*ivl_delaypath_t; typedef struct ivl_design_s *ivl_design_t; +/* clang++ wants this to be class to match the definition, but clang + * (the C) compiler needs it to be a struct since class is not defined + * in C. They are effecively both pointers to an object so everything + * works out. */ +#ifdef __cplusplus +typedef class ivl_discipline_s*ivl_discipline_t; +#else typedef struct ivl_discipline_s*ivl_discipline_t; +#endif +/* See the comments above. */ +#ifdef __cplusplus +typedef class netenum_t *ivl_enumtype_t; +#else typedef struct netenum_t *ivl_enumtype_t; +#endif typedef struct ivl_event_s *ivl_event_t; typedef struct ivl_expr_s *ivl_expr_t; typedef struct ivl_island_s *ivl_island_t; @@ -167,7 +180,12 @@ typedef struct ivl_lval_s *ivl_lval_t; typedef struct ivl_net_const_s*ivl_net_const_t; typedef struct ivl_net_logic_s*ivl_net_logic_t; typedef struct ivl_udp_s *ivl_udp_t; +/* See the comments above. */ +#ifdef __cplusplus +typedef class ivl_nature_s *ivl_nature_t; +#else typedef struct ivl_nature_s *ivl_nature_t; +#endif typedef struct ivl_net_probe_s*ivl_net_probe_t; typedef struct ivl_nexus_s *ivl_nexus_t; typedef struct ivl_nexus_ptr_s*ivl_nexus_ptr_t; diff --git a/vhdlpp/vhdlint.cc b/vhdlpp/vhdlint.cc index 51f3357b2..9828f6349 100644 --- a/vhdlpp/vhdlint.cc +++ b/vhdlpp/vhdlint.cc @@ -23,6 +23,8 @@ #include #include +using namespace std; + bool vhdlint::is_negative() const { return value_ < 0L; diff --git a/vhdlpp/vhdlint.h b/vhdlpp/vhdlint.h index 3a4b841dd..4b3e535f6 100644 --- a/vhdlpp/vhdlint.h +++ b/vhdlpp/vhdlint.h @@ -21,8 +21,6 @@ #include -using namespace std; - class vhdlint { public: diff --git a/vvp/codes.h b/vvp/codes.h index 68769b496..5da260791 100644 --- a/vvp/codes.h +++ b/vvp/codes.h @@ -193,7 +193,7 @@ struct vvp_code_s { uint32_t bit_idx[2]; vvp_net_t *net2; vvp_code_t cptr2; - struct ufunc_core*ufunc_core_ptr; + class ufunc_core*ufunc_core_ptr; }; }; diff --git a/vvp/compile.cc b/vvp/compile.cc index 04bd6c717..0050678c4 100644 --- a/vvp/compile.cc +++ b/vvp/compile.cc @@ -341,14 +341,14 @@ vvp_net_t* vvp_net_lookup(const char*label) * this call is its last chance. If it cannot complete the operation, * it must print an error message and return false. */ -static struct resolv_list_s*resolv_list = 0; +static class resolv_list_s*resolv_list = 0; resolv_list_s::~resolv_list_s() { free(label_); } -void resolv_submit(struct resolv_list_s*cur) +void resolv_submit(class resolv_list_s*cur) { if (cur->resolve()) { delete cur; @@ -635,13 +635,13 @@ void compile_cleanup(void) } do { - struct resolv_list_s *res = resolv_list; + class resolv_list_s *res = resolv_list; resolv_list = 0x0; last = nerrs == lnerrs; lnerrs = nerrs; nerrs = 0; while (res) { - struct resolv_list_s *cur = res; + class resolv_list_s *cur = res; res = res->next; if (cur->resolve(last)) delete cur; diff --git a/vvp/compile.h b/vvp/compile.h index 547891c18..29fb2cb1e 100644 --- a/vvp/compile.h +++ b/vvp/compile.h @@ -207,7 +207,7 @@ extern void compile_enum2_type(char*label, long width, bool signed_flag, extern void compile_enum4_type(char*label, long width, bool signed_flag, std::list*names); -class __vpiModPath; +struct __vpiModPath; extern __vpiModPath* compile_modpath(char*label, unsigned width, struct symb_s drv, @@ -291,11 +291,11 @@ class resolv_list_s { const char*label() const { return label_; } private: - friend void resolv_submit(struct resolv_list_s*cur); + friend void resolv_submit(class resolv_list_s*cur); friend void compile_cleanup(void); char*label_; - struct resolv_list_s*next; + class resolv_list_s*next; }; /* diff --git a/vvp/schedule.cc b/vvp/schedule.cc index a8973c9ed..f2ab78f54 100644 --- a/vvp/schedule.cc +++ b/vvp/schedule.cc @@ -136,9 +136,9 @@ inline void* vthread_event_s::operator new(size_t size) return vthread_event_heap.alloc_slab(); } -void vthread_event_s::operator delete(void*ptr) +void vthread_event_s::operator delete(void*dptr) { - vthread_event_heap.free_slab(ptr); + vthread_event_heap.free_slab(dptr); } struct del_thr_event_s : public event_s { @@ -211,9 +211,9 @@ inline void* assign_vector4_event_s::operator new(size_t size) return assign4_heap.alloc_slab(); } -void assign_vector4_event_s::operator delete(void*ptr) +void assign_vector4_event_s::operator delete(void*dptr) { - assign4_heap.free_slab(ptr); + assign4_heap.free_slab(dptr); } unsigned long count_assign4_pool(void) { return assign4_heap.pool; } @@ -248,9 +248,9 @@ inline void* assign_vector8_event_s::operator new(size_t size) return assign8_heap.alloc_slab(); } -void assign_vector8_event_s::operator delete(void*ptr) +void assign_vector8_event_s::operator delete(void*dptr) { - assign8_heap.free_slab(ptr); + assign8_heap.free_slab(dptr); } unsigned long count_assign8_pool() { return assign8_heap.pool; } @@ -285,9 +285,9 @@ inline void* assign_real_event_s::operator new (size_t size) return assignr_heap.alloc_slab(); } -void assign_real_event_s::operator delete(void*ptr) +void assign_real_event_s::operator delete(void*dptr) { - assignr_heap.free_slab(ptr); + assignr_heap.free_slab(dptr); } unsigned long count_assign_real_pool(void) { return assignr_heap.pool; } diff --git a/vvp/vpi_priv.h b/vvp/vpi_priv.h index 68272c41c..b6b244fde 100644 --- a/vvp/vpi_priv.h +++ b/vvp/vpi_priv.h @@ -448,7 +448,7 @@ struct __vpiSysTaskCall { /* These represent where in the vthread to put the return value. */ unsigned vbit; signed vwid; - class vvp_net_t*fnet; + class vvp_net_t*fnet; unsigned file_idx; unsigned lineno; bool put_value; diff --git a/vvp/vvp_island.h b/vvp/vvp_island.h index afe27e1d5..2ff84027c 100644 --- a/vvp/vvp_island.h +++ b/vvp/vvp_island.h @@ -1,7 +1,7 @@ #ifndef __vvp_island_H #define __vvp_island_H /* - * Copyright (c) 2008,2011 Stephen Williams (steve@icarus.com) + * Copyright (c) 2008-2011 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -54,7 +54,7 @@ * branches of analog within the island. */ -class vvp_island_branch; +struct vvp_island_branch; class vvp_island_node; class vvp_island : private vvp_gen_event_s { diff --git a/vvp/vvp_net.cc b/vvp/vvp_net.cc index ca55be7db..e11504cc9 100644 --- a/vvp/vvp_net.cc +++ b/vvp/vvp_net.cc @@ -438,7 +438,7 @@ int edge(vvp_bit4_t from, vvp_bit4_t to) void vvp_send_vec8(vvp_net_ptr_t ptr, const vvp_vector8_t&val) { - while (struct vvp_net_t*cur = ptr.ptr()) { + while (class vvp_net_t*cur = ptr.ptr()) { vvp_net_ptr_t next = cur->port[ptr.port()]; if (cur->fun) @@ -450,7 +450,7 @@ void vvp_send_vec8(vvp_net_ptr_t ptr, const vvp_vector8_t&val) void vvp_send_real(vvp_net_ptr_t ptr, double val, vvp_context_t context) { - while (struct vvp_net_t*cur = ptr.ptr()) { + while (class vvp_net_t*cur = ptr.ptr()) { vvp_net_ptr_t next = cur->port[ptr.port()]; if (cur->fun) @@ -462,7 +462,7 @@ void vvp_send_real(vvp_net_ptr_t ptr, double val, vvp_context_t context) void vvp_send_long(vvp_net_ptr_t ptr, long val) { - while (struct vvp_net_t*cur = ptr.ptr()) { + while (class vvp_net_t*cur = ptr.ptr()) { vvp_net_ptr_t next = cur->port[ptr.port()]; if (cur->fun) @@ -475,7 +475,7 @@ void vvp_send_long(vvp_net_ptr_t ptr, long val) void vvp_send_long_pv(vvp_net_ptr_t ptr, long val, unsigned base, unsigned wid) { - while (struct vvp_net_t*cur = ptr.ptr()) { + while (class vvp_net_t*cur = ptr.ptr()) { vvp_net_ptr_t next = cur->port[ptr.port()]; if (cur->fun) diff --git a/vvp/vvp_net.h b/vvp/vvp_net.h index 112a9bc7c..5fd8525cc 100644 --- a/vvp/vvp_net.h +++ b/vvp/vvp_net.h @@ -1291,7 +1291,7 @@ class vvp_net_fil_t : public vvp_vpi_callback { // the forced value to get through. bool force_propagate_; // force link back. - struct vvp_net_t*force_link_; + class vvp_net_t*force_link_; }; /* **** Some core net functions **** */ @@ -1496,7 +1496,7 @@ class vvp_wide_fun_t : public vvp_net_fun_t { inline void vvp_send_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&val, vvp_context_t context) { - while (struct vvp_net_t*cur = ptr.ptr()) { + while (class vvp_net_t*cur = ptr.ptr()) { vvp_net_ptr_t next = cur->port[ptr.port()]; if (cur->fun) @@ -1536,7 +1536,7 @@ inline void vvp_send_vec4_pv(vvp_net_ptr_t ptr, const vvp_vector4_t&val, unsigned base, unsigned wid, unsigned vwid, vvp_context_t context) { - while (struct vvp_net_t*cur = ptr.ptr()) { + while (class vvp_net_t*cur = ptr.ptr()) { vvp_net_ptr_t next = cur->port[ptr.port()]; if (cur->fun) @@ -1550,7 +1550,7 @@ inline void vvp_net_t::send_vec8_pv(const vvp_vector8_t&val, unsigned base, unsigned wid, unsigned vwid) { vvp_net_ptr_t ptr = out_; - while (struct vvp_net_t*cur = ptr.ptr()) { + while (class vvp_net_t*cur = ptr.ptr()) { vvp_net_ptr_t next = cur->port[ptr.port()]; if (cur->fun) diff --git a/vvp/vvp_net_sig.h b/vvp/vvp_net_sig.h index 6914b76e3..92c5e0119 100644 --- a/vvp/vvp_net_sig.h +++ b/vvp/vvp_net_sig.h @@ -1,7 +1,7 @@ #ifndef __vvp_net_sig_H #define __vvp_net_sig_H /* - * Copyright (c) 2004-2010 Stephen Williams (steve@icarus.com) + * Copyright (c) 2004-2011 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -78,7 +78,7 @@ class vvp_fun_signal_base : public vvp_net_fun_t { /* The %cassign/link instruction needs a place to write the source node of the force, so that subsequent %cassign and %deassign instructions can undo the link as needed. */ - struct vvp_net_t*cassign_link; + class vvp_net_t*cassign_link; protected: bool continuous_assign_active_; diff --git a/vvp/vvp_vpi_callback.h b/vvp/vvp_vpi_callback.h index 8b96e5afc..6a9cc2f35 100644 --- a/vvp/vvp_vpi_callback.h +++ b/vvp/vvp_vpi_callback.h @@ -1,7 +1,7 @@ #ifndef __vvp_vpi_callback_H #define __vvp_vpi_callback_H /* - * Copyright (c) 2009 Stephen Williams (steve@icarus.com) + * Copyright (c) 2009-2011 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -36,7 +36,7 @@ class vvp_vpi_callback { vvp_vpi_callback(); virtual ~vvp_vpi_callback(); - void attach_as_word(class __vpiArray* arr, unsigned long addr); + void attach_as_word(struct __vpiArray* arr, unsigned long addr); void add_vpi_callback(struct __vpiCallback*); #ifdef CHECK_WITH_VALGRIND @@ -55,7 +55,7 @@ class vvp_vpi_callback { private: struct __vpiCallback*vpi_callbacks_; - class __vpiArray* array_; + struct __vpiArray* array_; unsigned long array_word_; };