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.
This commit is contained in:
Cary R 2011-09-22 19:57:59 -07:00 committed by Stephen Williams
parent 609c038484
commit eab5bacf9f
13 changed files with 52 additions and 34 deletions

View File

@ -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;

View File

@ -23,6 +23,8 @@
#include <cstdlib>
#include <sstream>
using namespace std;
bool vhdlint::is_negative() const
{
return value_ < 0L;

View File

@ -21,8 +21,6 @@
#include <stdint.h>
using namespace std;
class vhdlint
{
public:

View File

@ -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;
};
};

View File

@ -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;

View File

@ -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<struct enum_name_s>*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;
};
/*

View File

@ -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; }

View File

@ -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;

View File

@ -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 {

View File

@ -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)

View File

@ -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)

View File

@ -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_;

View File

@ -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_;
};