Laurent GUERBY <laur...@guerby.net> writes:

> What is the way forward: fixing in some way the Ada Makefile? Or doing
> search and replace in case of keyword/identifier conflict? If
> search/replace, do AdaCore people have an opinion on the best way
> to proceed to avoid maintenance issues in the various trees? (eg: commit
> of those trivial patches directly on trunk or on AdaCore tree then
> trunk?)

I can't answer that--it's up to the Ada maintainers.


> I don't know much about C++/C compatibilities and the way to solve
> them choosen on the gcc-in-cxx branch, is there a document somewhere?

No.  In some cases the warnings given by -Wc++-compat will be more
helpful.


> Next error is related to enum in for loop:
>
> g++ -c  -g -g -DIN_GCC   -W -Wall -Wwrite-strings -Wcast-qual -fno-common  
> -DHAVE_CONFIG_H -I.. -I. -Iada -I../../gcc/gcc -I../../gcc/gcc/ada 
> -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include 
> -I/opt/cfarm/gmp-4.2.4//include -I/opt/cfarm/mpfr-2.4.1//include 
> -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/bid 
> -I../libdecnumber    ../../gcc/gcc/ada/gcc-interface/misc.c -o ada/misc.o
> ../../gcc/gcc/ada/gcc-interface/misc.c: In function 'void 
> enumerate_modes(void (*)(int, int, int, int, int, int, unsigned int))':
> ../../gcc/gcc/ada/gcc-interface/misc.c:734: error: invalid conversion from 
> 'int' to 'machine_mode'
> ../../gcc/gcc/ada/gcc-interface/misc.c:734: error: no 'operator++(int)' 
> declared for postfix '++', trying prefix operator instead
> ../../gcc/gcc/ada/gcc-interface/misc.c:734: error: no match for 'operator++' 
> in '++i'


In the C/C++ common subset you can not write loops in which the index
variable has enum type.  Loops like these must be written as something
along the lines of

  int iloop;

  for (iloop = 0; iloop < NUM_MACHINE_MODES; iloop++)
    {
      enum machine_mode i = (enum machine_mode) iloop;
      ...
    }


> Another kind of error on struct declarations:
>
> <<
> g++ -c  -g -g -DIN_GCC   -W -Wall -Wwrite-strings -Wcast-qual -fno-common  
> -DHAVE_CONFIG_H -I.. -I. -Iada -I../../gcc/gcc -I../../gcc/gcc/ada 
> -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include 
> -I/opt/cfarm/gmp-4.2.4//include -I/opt/cfarm/mpfr-2.4.1//include 
> -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/bid 
> -I../libdecnumber    ../../gcc/gcc/ada/gcc-interface/trans.c -o ada/trans.o
> ../../gcc/gcc/ada/gcc-interface/trans.c:111: error: conflicting declaration 
> 'typedef struct parm_attr* parm_attr'
> ../../gcc/gcc/ada/gcc-interface/trans.c:103: error: 'struct parm_attr' has a 
> previous declaration as 'struct parm_attr'

In C++, if a typedef and a struct tag have the same name, they must name
the same type.  I've been addressing these issues by consistently
renaming the struct with a "_d" suffix.  See, e.g., struct
alias_set_entry_d and alias_set_entry in alias.c.


> Last error is on void* arithmetic:
>
> <<
> g++ -c  -g -g -DIN_GCC   -W -Wall -Wwrite-strings -Wcast-qual -fno-common 
> -Wno-error -DHAVE_CONFIG_H  -I. -Iada -I../../gcc/gcc -I../../gcc/gcc/ada 
> -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include 
> -I/opt/cfarm/gmp-4.2.4//include -I/opt/cfarm/mpfr-2.4.1//include 
> -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/bid 
> -I../libdecnumber    \
>             -I. -Iada -I../../gcc/gcc -I../../gcc/gcc/ada 
> -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include 
> -I/opt/cfarm/gmp-4.2.4//include -I/opt/cfarm/mpfr-2.4.1//include 
> -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/bid 
> -I../libdecnumber   -fno-omit-frame-pointer ../../gcc/gcc/ada/tracebak.c -o 
> ada/tracebak.o
> In file included from ../../gcc/gcc/ada/tracebak.c:396:
> ../../gcc/gcc/ada/tb-gcc.c: In function '_Unwind_Reason_Code 
> trace_callback(_Unwind_Context*, uw_data_t*)':
> ../../gcc/gcc/ada/tb-gcc.c:86: error: pointer of type 'void *' used in 
> arithmetic

Here pc has type "void *", but the code computes "pc + PC_ADJUST".  This
is not permitted in C either, and is actually a gcc extension.  The fix
is to change pc to "char *".

Ian

Reply via email to