Re: Phase 1 of gcc-in-cxx now complete (Ada)

2009-06-27 Thread Eric Botcazou
 Interesting.  I've been testing my -Wc++-compat patches with full
 bootstraps including Ada, but I just looked at my make log and it does
 indeed appear that -Wc++-compat doesn't make it onto the Ada files.

 It seems to be because of this line in ada/gcc-interface/Make-lang.in:

 ada-warn = $(ADA_CFLAGS) $(WERROR)

 The other languages use

 DIR-warn = $(STRICT_WARN)

 which is what brings in -Wc++-compat.

I get -Wc++-compat warnings though:

/home/eric/gnat/gnat-head/src/gcc/ada/gcc-interface/decl.c: In 
function 'substitute_in_type':
/home/eric/gnat/gnat-head/src/gcc/ada/gcc-interface/decl.c:7865:8: warning: 
identifier 'new' conflicts with C++ keyword
/home/eric/gnat/gnat-head/src/gcc/ada/gcc-interface/decl.c:7886:4: warning: 
identifier 'new' conflicts with C++ keyword
/home/eric/gnat/gnat-head/src/gcc/ada/gcc-interface/decl.c:7894:11: warning: 
identifier 'new' conflicts with C++ keyword
/home/eric/gnat/gnat-head/src/gcc/ada/gcc-interface/decl.c:7907:4: warning: 
identifier 'new' conflicts with C++ keyword
/home/eric/gnat/gnat-head/src/gcc/ada/gcc-interface/decl.c:7911:11: warning: 
identifier 'new' conflicts with C++ keyword
/home/eric/gnat/gnat-head/src/gcc/ada/gcc-interface/decl.c:7917:7: warning: 
identifier 'new' conflicts with C++ keyword
/home/eric/gnat/gnat-head/src/gcc/ada/gcc-interface/decl.c:7918:11: warning: 
identifier 'new' conflicts with C++ keyword
/home/eric/gnat/gnat-head/src/gcc/ada/gcc-interface/decl.c:7921:34: warning: 
identifier 'new' conflicts with C++ keyword
/home/eric/gnat/gnat-head/src/gcc/ada/gcc-interface/decl.c:7938:2: warning: 
identifier 'new' conflicts with C++ keyword
/home/eric/gnat/gnat-head/src/gcc/ada/gcc-interface/decl.c:7947:9: warning: 
identifier 'new' conflicts with C++ keyword
/home/eric/gnat/gnat-head/src/gcc/ada/gcc-interface/decl.c:7960:2: warning: 
identifier 'new' conflicts with C++ keyword
/home/eric/gnat/gnat-head/src/gcc/ada/gcc-interface/decl.c:7992:33: warning: 
identifier 'new' conflicts with C++ keyword
/home/eric/gnat/gnat-head/src/gcc/ada/gcc-interface/decl.c:8008:9: warning: 
identifier 'new' conflicts with C++ keyword

but they don't stop the build because -Werror is not passed.  That needs to be 
fixed first.

-- 
Eric Botcazou


Re: Phase 1 of gcc-in-cxx now complete (Ada)

2009-06-27 Thread Laurent GUERBY
On Fri, 2009-06-26 at 12:52 -0700, Ian Lance Taylor wrote:
 Arnaud Charlet char...@adacore.com writes:
 
  Switching gnatbind to generate Ada if there's nothing against
  it might be a better solution since stage1 uses the system gnatbind, so
  a patch to current gnatbind will not help (unless we push it to branches
  and tell user to install a fairly recent gnatbind first).
 
  This does create a bootstrap incompatibility/issue indeed, interesting.
  Yet another alternative would be to use a C compiler to compile the binder
  generated file during bootstrap.
 
 Yes, I think that either compiling with a C compiler, or generating Ada
 bindings, would be the best approach here.

Switching gnatbind to generate Ada during bootstrap and with a mostly
mechanical patch adding #ifdef __cplusplus / extern C where needed to
honor matching pragma Import/Export (C, xxx) in Ada code I now get all
three stages and gnatlib to build successfully on the branch.

There was one other C/C++ compat issue: wrong code generated in
gcc/ada/gcc-interface/utils.c and Andrew Pinski suggested the solution
on IRC:

@@ -4861,7 +4861,7 @@
   va_start (list, n);
   for (i = 0; i  n; ++i)
 {
-  builtin_type a = va_arg (list, builtin_type);
+  builtin_type a = (builtin_type)va_arg (list, int);
   t = builtin_types[a];
   if (t == error_mark_node)
goto egress;

This was the only va_arg usage, may be we should apply it on trunk too
as the patched version is supposed to work for both C and C++.

For toplevel gnattools I have a link issue since the LINKER
variable used in the gcc subdir is not passed at toplevel, I'm currently
trying wether passing LINKER=$(CXX) will do but I'm not sure that we
really want here.

I will submit the gnatbind switch to Ada patch separately for review on
trunk after testing completes.

Hopefully there seem to be no major issue in having Ada working
on the gcc-in-cxx branch.

Sincerely,

Laurent





Re: Phase 1 of gcc-in-cxx now complete (Ada)

2009-06-27 Thread Eric Botcazou
 This was the only va_arg usage, may be we should apply it on trunk too
 as the patched version is supposed to work for both C and C++.

Yes, but I'm testing a patch for trunk with more changes.

-- 
Eric Botcazou


Re: Phase 1 of gcc-in-cxx now complete (Ada)

2009-06-27 Thread Laurent GUERBY
On Sat, 2009-06-27 at 13:25 +0200, Eric Botcazou wrote:
  This was the only va_arg usage, may be we should apply it on trunk too
  as the patched version is supposed to work for both C and C++.
 
 Yes, but I'm testing a patch for trunk with more changes.

For reference here is my current draft patch to gcc-in-cxx branch,
it completes make bootstrap including gnattools, check
running.

Laurent

Index: gcc/ada/adadecode.h
===
--- gcc/ada/adadecode.h (revision 148953)
+++ gcc/ada/adadecode.h (working copy)
@@ -29,6 +29,11 @@
  *  *
  /
 
+
+#ifdef __cplusplus
+extern C {
+#endif
+
 /* This function will return the Ada name from the encoded form.
The Ada coding is done in exp_dbug.ads and this is the inverse function.
see exp_dbug.ads for full encoding rules, a short description is added
@@ -51,3 +56,8 @@
function used in the binutils and GDB. Always consider using __gnat_decode
instead of ada_demangle. Caller must free the pointer returned.  */
 extern char *ada_demangle (const char *);
+
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/sysdep.c
===
--- gcc/ada/sysdep.c(revision 148953)
+++ gcc/ada/sysdep.c(working copy)
@@ -32,6 +32,10 @@
 /* This file contains system dependent symbols that are referenced in the
GNAT Run Time Library */
 
+#ifdef __cplusplus
+extern C {
+#endif
+
 #ifdef __vxworks
 #include ioLib.h
 #include dosFsLib.h
@@ -938,3 +942,7 @@
  return 0;
}
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/targext.c
===
--- gcc/ada/targext.c   (revision 148953)
+++ gcc/ada/targext.c   (working copy)
@@ -33,6 +33,10 @@
 /*  extension for object and executable files. It is used by the compiler,  */
 /*  binder and tools.   */
 
+#ifdef __cplusplus
+extern C {
+#endif
+
 #include system.h
 #include coretypes.h
 #include tm.h
@@ -48,3 +52,8 @@
 const char *__gnat_target_object_extension = TARGET_OBJECT_SUFFIX;
 const char *__gnat_target_executable_extension = TARGET_EXECUTABLE_SUFFIX;
 const char *__gnat_target_debuggable_extension = TARGET_EXECUTABLE_SUFFIX;
+
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/s-oscons-tmplt.c
===
--- gcc/ada/s-oscons-tmplt.c(revision 148953)
+++ gcc/ada/s-oscons-tmplt.c(working copy)
@@ -79,6 +79,11 @@
  **
  **/
 
+
+#ifdef __cplusplus
+extern C {
+#endif
+
 #include stdlib.h
 #include string.h
 #include limits.h
@@ -1307,8 +1312,14 @@
 
 #endif
 
+
 /*
 
 end System.OS_Constants;
 */
 }
+
+
+#ifdef __cplusplus
+  }
+#endif
Index: gcc/ada/env.c
===
--- gcc/ada/env.c   (revision 148953)
+++ gcc/ada/env.c   (working copy)
@@ -29,6 +29,11 @@
  *  *
  /
 
+
+#ifdef __cplusplus
+extern C {
+#endif
+
 #ifdef IN_RTS
 #include tconfig.h
 #include tsystem.h
@@ -313,3 +318,7 @@
   clearenv ();
 #endif
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/final.c
===
--- gcc/ada/final.c (revision 148953)
+++ gcc/ada/final.c (working copy)
@@ -29,6 +29,11 @@
  *  *
  /
 
+
+#ifdef __cplusplus
+extern C {
+#endif
+
 extern void __gnat_finalize (void);
 
 /* This routine is called at the extreme end of execution of an Ada program
@@ -40,3 +45,8 @@
 __gnat_finalize (void)
 {
 }
+
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/init.c
===
--- gcc/ada/init.c  (revision 148953)
+++ gcc/ada/init.c  (working copy)
@@ -38,6 +38,11 @@
 installed by this file are used to catch the resulting signals that come
 from these probes failing (i.e. touching protected pages).  */
 
+
+#ifdef __cplusplus
+extern C {
+#endif
+
 /* This file should be kept synchronized with 2sinit.ads, 2sinit.adb,
s-init-ae653-cert.adb and s-init-xi-sparc.adb.  All these files implement
the required functionality for different targets.  */
@@ -2319,3 +2324,7 @@
 }
 
 #endif
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/xsnamest.adb
===
--- gcc/ada/xsnamest.adb(revision 148953)
+++ gcc/ada/xsnamest.adb(working copy)
@@ -194,6 +194,10 @@
Create (OutB, Out_File, snames.nb);
Create (OutH, Out_File, snames.nh);
 
+   

Re: Phase 1 of gcc-in-cxx now complete (Ada)

2009-06-27 Thread Laurent GUERBY
On Sat, 2009-06-27 at 13:51 +0200, Laurent GUERBY wrote:
 On Sat, 2009-06-27 at 13:25 +0200, Eric Botcazou wrote:
   This was the only va_arg usage, may be we should apply it on trunk too
   as the patched version is supposed to work for both C and C++.
  
  Yes, but I'm testing a patch for trunk with more changes.
 
 For reference here is my current draft patch to gcc-in-cxx branch,
 it completes make bootstrap including gnattools, check
 running.

During make check gnat.dg was clean but there were two FAIL in ACATS:

=== acats tests ===
FAIL:   c940005
FAIL:   c940007

=== acats Summary ===
# of expected passes2313
# of unexpected failures2
Native configuration is x86_64-unknown-linux-gnu

=== gnat Summary ===

# of expected passes659
# of expected failures  5


,.,. C940005 ACATS 2.5 09-06-27 14:16:44
 C940005 Check internal calls of protected functions and procedures.
   * C940005 Unexpected paths taken.
 C940005 FAILED .

,.,. C940007 ACATS 2.5 09-06-27 14:16:46
 C940007 Check internal calls of protected functions and procedures
in objects declared as a type.
   * C940007 Unexpected paths taken.
 C940007 FAILED .

I haven't investigated those FAIL.

make install worked too and the installed compiler is able to compile
and link small Ada programs.

I'll let maintainers comment on what we should do and with what timing.

Sincerely,

Laurent





Re: Phase 1 of gcc-in-cxx now complete (Ada)

2009-06-27 Thread Paolo Bonzini

CC=../../xgcc -B../../ \
+   LINKER=$(CXX) \
CFLAGS=$(CFLAGS) $(WARN_CFLAGS) \

I think you should rather do

CC=../../xgcc -B../../ \
+   CXX=../../g++ -B../../ \
CFLAGS=$(CFLAGS) $(WARN_CFLAGS) \
+   CXXFLAGS=$(CXXFLAGS) $(WARN_CFLAGS) \

and copy the setting of COMPILER and LINKER from gcc/Makefile.in into 
gcc/ada/gcc-interface/Makefile.in:


ENABLE_BUILD_WITH_CXX = @ENABLE_BUILD_WITH_CXX@
ifneq ($(ENABLE_BUILD_WITH_CXX),yes)
COMPILER = $(CC)
COMPILER_FLAGS = $(CFLAGS)
LINKER = $(CC)
LINKER_FLAGS = $(CFLAGS)
else
COMPILER = $(CXX)
COMPILER_FLAGS = $(CXXFLAGS)
LINKER = $(CXX)
LINKER_FLAGS = $(CXXFLAGS)
endif

Paolo


Re: Phase 1 of gcc-in-cxx now complete (Ada)

2009-06-26 Thread Laurent GUERBY
On Thu, 2009-06-25 at 15:28 -0700, Ian Lance Taylor wrote:
 Richard Guenther richard.guent...@gmail.com writes:
 
  I guess this has to do with reserved word conflict on new:
 
  
  tree
  substitute_in_type (tree t, tree f, tree r)
  {
   tree new;
 
 
  Do you have some way to deal with this?
 
  Use a non-reserved identifier.  I guess on trunk Ada doesn't build
  with -Wc++-compat, does it?
 
 Interesting.  I've been testing my -Wc++-compat patches with full
 bootstraps including Ada, but I just looked at my make log and it does
 indeed appear that -Wc++-compat doesn't make it onto the Ada files.
 
 It seems to be because of this line in ada/gcc-interface/Make-lang.in:
 
 ada-warn = $(ADA_CFLAGS) $(WERROR)
 
 The other languages use
 
 DIR-warn = $(STRICT_WARN)
 
 which is what brings in -Wc++-compat.

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 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?

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'


void
enumerate_modes (void (*f) (int, int, int, int, int, int, unsigned int))
{
  enum machine_mode i;

  for (i = 0; i  NUM_MACHINE_MODES; i++)


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'


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


Patch welcomed as these three are not obvious to me :).

I did touch xx.o to get past and with the quick search/replace
of new/class/template patch below it then tried to link libbackend.o.

Thanks in advance,

Laurent

Index: gcc/ada/gcc-interface/utils.c
===
--- gcc/ada/gcc-interface/utils.c   (revision 148953)
+++ gcc/ada/gcc-interface/utils.c   (working copy)
@@ -1014,33 +1014,33 @@
 bool has_rep)
 {
   tree type = TREE_TYPE (last_size);
-  tree new;
+  tree new_tree;
 
   if (!special || TREE_CODE (size) != COND_EXPR)
 {
-  new = size_binop (PLUS_EXPR, first_bit, size);
+  new_tree = size_binop (PLUS_EXPR, first_bit, size);
   if (has_rep)
-   new = size_binop (MAX_EXPR, last_size, new);
+   new_tree = size_binop (MAX_EXPR, last_size, new_tree);
 }
 
   else
-new = fold_build3 (COND_EXPR, type, TREE_OPERAND (size, 0),
- 

Re: Phase 1 of gcc-in-cxx now complete (Ada)

2009-06-26 Thread Ian Lance Taylor
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


Re: Phase 1 of gcc-in-cxx now complete (Ada)

2009-06-26 Thread Arnaud Charlet
  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 think we do want to fix these warnings. Apart from trivial keyword issues,
they do point to dubious C constructs anyway, so nice to clean up in
any case.

I'd suggest posting patching to gcc-patches as usual.

Arno


Re: Phase 1 of gcc-in-cxx now complete (Ada)

2009-06-26 Thread Ian Lance Taylor
Laurent GUERBY laur...@guerby.net writes:

 Next issue is that gnat1 link fails on many missing symbols:

 ada/b_gnat1.o: In function `adainit()':
 ada/b_gnat1.c:287: undefined reference to `system__soft_links___elabb()'
 ada/b_gnat1.c:291: undefined reference to
 `system__secondary_stack___elabb()'
 
 ada/b_gnat1.c:89: undefined reference to
 `system__standard_library__adafinal()'
 ada/b_gnat1.o:(.eh_frame+0x12): undefined reference to
 `__gxx_personality_v0'
 ada/adadecode.o:(.eh_frame+0x12): undefined reference to
 `__gxx_personality_v0'
 ...

 (full log attached as b.log.gz)

 I suspect some Makefile+gnatbind work specific to this branch is needed
 to go past this issue but I've no idea on what is the exact source
 of the issue and how to fix it, I've no experience in C++/Ada code
 mixing. Help welcomed :).

I don't really know how the Ada compiler works, but it looks like this
code is generated by the gnatbind program.  I bet it would work if
gnatbind -C emitted this at the start of the output:

#ifdef __cplusplus
extern C {
#endif

and emitted this at the end:

#ifdef __cplusplus
}
#endif

I think the function to change is Gen_Output_File_C in bindgen.adb.

Ian


Re: Phase 1 of gcc-in-cxx now complete (Ada)

2009-06-26 Thread Arnaud Charlet
 I don't really know how the Ada compiler works, but it looks like this
 code is generated by the gnatbind program.  I bet it would work if
 gnatbind -C emitted this at the start of the output:
 
 #ifdef __cplusplus
 extern C {
 #endif
 
 and emitted this at the end:
 
 #ifdef __cplusplus
 }
 #endif
 
 I think the function to change is Gen_Output_File_C in bindgen.adb.

Looks like a good track indeed and a reasonable change to make IMO.

Arno


Re: Phase 1 of gcc-in-cxx now complete (Ada)

2009-06-26 Thread Robert Dewar

Ian Lance Taylor wrote:


I think the function to change is Gen_Output_File_C in bindgen.adb.


I don't really see any urgency for this change, yes gnatbind has
the option to generate C, but it is not the normal path, and only
of use in unusual circumstances, so I don't really see the need
for this output to be C++ compatible. The documentation doesn't
claim this after all.


Re: Phase 1 of gcc-in-cxx now complete (Ada)

2009-06-26 Thread Arnaud Charlet
 I don't really see any urgency for this change, yes gnatbind has
 the option to generate C, but it is not the normal path, and only
 of use in unusual circumstances, so I don't really see the need
 for this output to be C++ compatible. The documentation doesn't
 claim this after all.

We're talking about bootstrapping GNAT itself. The other PATH would be
to change the Makefile to use gnatbind instead of gnatbind -C. Note sure
one option is simpler than the other (I suspect the gnatbind change is
actually simpler than the Makefile change).

Arno


Re: Phase 1 of gcc-in-cxx now complete (Ada)

2009-06-26 Thread Ian Lance Taylor
Robert Dewar de...@adacore.com writes:

 Ian Lance Taylor wrote:

 I think the function to change is Gen_Output_File_C in bindgen.adb.

 I don't really see any urgency for this change, yes gnatbind has
 the option to generate C, but it is not the normal path, and only
 of use in unusual circumstances, so I don't really see the need
 for this output to be C++ compatible. The documentation doesn't
 claim this after all.

gnatbind -C appears to be used when bootstrapping gcc to generate .c
files.  With --enable-build-with-cxx, those .c files will be compiled
with a C++ compiler.  The symbols emitted by that compilation need to be
linkable with the symbols emitted when compiling Ada code, so the .c
files need extern C to avoid C++ mangling.

Or at least so it seems to me.  I may be missing some key step.

Ian


Re: Phase 1 of gcc-in-cxx now complete (Ada)

2009-06-26 Thread Robert Dewar

Ian Lance Taylor wrote:


gnatbind -C appears to be used when bootstrapping gcc to generate .c
files.  With --enable-build-with-cxx, those .c files will be compiled
with a C++ compiler.  The symbols emitted by that compilation need to be
linkable with the symbols emitted when compiling Ada code, so the .c
files need extern C to avoid C++ mangling.

Or at least so it seems to me.  I may be missing some key step.


No, I think that analysis is correct. I agree that if we can make
the gnatbind output C++ compatible (remembering that it must be
strictly standard, you cannot assume that gcc will be used to
compile it!) easily, we may as well do so.

I am not clear why we have to use gnatbind -C in the build context,
but in any case, let's fix this if it is easy to do so.


Ian




Re: Phase 1 of gcc-in-cxx now complete (Ada)

2009-06-26 Thread Laurent GUERBY
On Fri, 2009-06-26 at 14:07 -0400, Robert Dewar wrote:
 Ian Lance Taylor wrote:
 
  gnatbind -C appears to be used when bootstrapping gcc to generate .c
  files.  With --enable-build-with-cxx, those .c files will be compiled
  with a C++ compiler.  The symbols emitted by that compilation need to be
  linkable with the symbols emitted when compiling Ada code, so the .c
  files need extern C to avoid C++ mangling.
  
  Or at least so it seems to me.  I may be missing some key step.
 
 No, I think that analysis is correct. I agree that if we can make
 the gnatbind output C++ compatible (remembering that it must be
 strictly standard, you cannot assume that gcc will be used to
 compile it!) easily, we may as well do so.
 
 I am not clear why we have to use gnatbind -C in the build context,
 but in any case, let's fix this if it is easy to do so.

Switching gnatbind to generate Ada if there's nothing against
it might be a better solution since stage1 uses the system gnatbind, so
a patch to current gnatbind will not help (unless we push it to branches
and tell user to install a fairly recent gnatbind first).

Laurent





Re: Phase 1 of gcc-in-cxx now complete (Ada)

2009-06-26 Thread Arnaud Charlet
 Switching gnatbind to generate Ada if there's nothing against
 it might be a better solution since stage1 uses the system gnatbind, so
 a patch to current gnatbind will not help (unless we push it to branches
 and tell user to install a fairly recent gnatbind first).

This does create a bootstrap incompatibility/issue indeed, interesting.
Yet another alternative would be to use a C compiler to compile the binder
generated file during bootstrap.

Arno


Re: Phase 1 of gcc-in-cxx now complete (Ada)

2009-06-26 Thread Ian Lance Taylor
Arnaud Charlet char...@adacore.com writes:

 Switching gnatbind to generate Ada if there's nothing against
 it might be a better solution since stage1 uses the system gnatbind, so
 a patch to current gnatbind will not help (unless we push it to branches
 and tell user to install a fairly recent gnatbind first).

 This does create a bootstrap incompatibility/issue indeed, interesting.
 Yet another alternative would be to use a C compiler to compile the binder
 generated file during bootstrap.

Yes, I think that either compiling with a C compiler, or generating Ada
bindings, would be the best approach here.

Ian


Re: Phase 1 of gcc-in-cxx now complete (Ada)

2009-06-25 Thread Laurent GUERBY
On Thu, 2009-06-25 at 13:32 -0700, Ian Lance Taylor wrote:
 I am pleased to report that if you configure gcc with
 --enable-build-with-cxx, which causes the core compiler to be built
 using a C++ compiler, a bootstrap on x86_64-unknown-linux-gnu now
 completes.
 
 I would like to encourage people to try using --enable-build-with-cxx in
 other configuration--other bootstraps, cross-compilers--to see how well
 it works.  Please let me know if you run into problems that you don't
 know how, or don't have time, to fix.

Hi,

Wanting to test Ada on the branch, after checkout I did on x86_64-linux:

../gcc/configure --enable-languages=c,c++,ada --enable-__cxa_atexit
--disable-nls --enable-threads=posix --with-mpfr=/opt/cfarm/mpfr-2.4.1/
--with-gmp=/opt/cfarm/gmp-4.2.4/  --prefix=/n/16/guerby/cxx/install
--enable-build-with-cxx

make bootstrap
...
g++ -c  -g -g -DIN_GCC   -W -Wall -Wwrite-strings -Wcast-qual
-Wmissing-format-attribute -fno-common  -DHAVE_CONFIG_H -I. -I.
-I../../gcc/gcc -I../../gcc/gcc/. -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/c-decl.c -o c-decl.o
/usr/include/libintl.h:40: error: expected unqualified-id before ‘const’
/usr/include/libintl.h:40: error: expected `)' before ‘const’
/usr/include/libintl.h:40: error: expected initializer before ‘const’
/usr/include/libintl.h:81: error: expected unqualified-id before ‘const’
/usr/include/libintl.h:81: error: expected `)' before ‘const’
/usr/include/libintl.h:81: error: expected initializer before ‘const’
/usr/include/libintl.h:85: error: expected unqualified-id before ‘const’
/usr/include/libintl.h:85: error: expected `)' before ‘const’
/usr/include/libintl.h:85: error: expected initializer before ‘const’
../../gcc/gcc/c-decl.c: In function ‘tree_node* finish_enum(tree_node*,
tree_node*, tree_node*)’:
../../gcc/gcc/c-decl.c:7011: warning: comparison between signed and
unsigned integer expressions
../../gcc/gcc/c-decl.c:7032: warning: comparison between signed and
unsigned integer expressions
make[3]: *** [c-decl.o] Error 1
make[3]: Leaving directory `/home/guerby/cxx/build/gcc'
make[2]: *** [all-stage1-gcc] Error 2
make[2]: Leaving directory `/home/guerby/cxx/build'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/home/guerby/cxx/build'
make: *** [bootstrap] Error 2

Given the error is in non Ada-related code I guess this has to do
with the base C++ compiler and system headers in C++ mode, gcc16 is
running Debian 4.0 and GCC 4.1.2 (which works for trunk bootstrap of c,c
++,ada):

gue...@gcc16:~/cxx/build$ g++ --version
g++ (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)

gcc16 has a collection of GCC versions:
gue...@gcc16:~/cxx/build$ ls /opt/cfarm/release/
4.2.0  4.2.1  4.2.2  4.2.3  4.2.4  4.3.0  4.3.1  4.3.2  4.3.3  4.4.0

Using 4.2.3 as base compiler failed with the same error as system 4.1.2.

Using 4.3.3 and 4.4.0 as base compiler bootstrap failed on Ada-related
stuff, here gcc/ada/gcc-interface/decl.c:

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/decl.c -o ada/decl.o
../../gcc/gcc/ada/gcc-interface/decl.c: In function 'tree_node* 
substitute_in_type(tree_node*, tree_node*, tree_node*)':
../../gcc/gcc/ada/gcc-interface/decl.c:7791: error: expected unqualified-id 
before 'new'
../../gcc/gcc/ada/gcc-interface/decl.c:7812: error: expected type-specifier 
before '=' token
../../gcc/gcc/ada/gcc-interface/decl.c:7812: error: lvalue required as left 
operand of assignment
../../gcc/gcc/ada/gcc-interface/decl.c:7813: error: expected type-specifier 
before ')' token
../../gcc/gcc/ada/gcc-interface/decl.c:7813: error: request for member 'base' 
in '*(int*)__t', which is of non-class type 'int'
../../gcc/gcc/ada/gcc-interface/decl.c:7813: error: request for member 'base' 
in '*(int*)__t', which is of non-class type 'int'
../../gcc/gcc/ada/gcc-interface/decl.c:7813: error: request for member 'base' 
in '*(int*)__t', which is of non-class type 'int'
../../gcc/gcc/ada/gcc-interface/decl.c:7813: error: request for member 'base' 
in '*(int*)__t', which is of non-class type 'int'
../../gcc/gcc/ada/gcc-interface/decl.c:7813: error: request for member 'base' 
in '*(int*)__t', which is of non-class type 'int'
../../gcc/gcc/ada/gcc-interface/decl.c:7813: error: cannot convert 'int* const' 
to 'const tree_node*' for argument '1' to 'void tree_check_failed(const 
tree_node*, const char*, int, const char*, ...)'
../../gcc/gcc/ada/gcc-interface/decl.c:7813: error: request for member 'type' 
in '*({...})', which is 

Re: Phase 1 of gcc-in-cxx now complete (Ada)

2009-06-25 Thread Richard Guenther
On Thu, Jun 25, 2009 at 11:50 PM, Laurent GUERBYlaur...@guerby.net wrote:
 On Thu, 2009-06-25 at 13:32 -0700, Ian Lance Taylor wrote:
 I am pleased to report that if you configure gcc with
 --enable-build-with-cxx, which causes the core compiler to be built
 using a C++ compiler, a bootstrap on x86_64-unknown-linux-gnu now
 completes.

 I would like to encourage people to try using --enable-build-with-cxx in
 other configuration--other bootstraps, cross-compilers--to see how well
 it works.  Please let me know if you run into problems that you don't
 know how, or don't have time, to fix.

 Hi,

 Wanting to test Ada on the branch, after checkout I did on x86_64-linux:

 ../gcc/configure --enable-languages=c,c++,ada --enable-__cxa_atexit
 --disable-nls --enable-threads=posix --with-mpfr=/opt/cfarm/mpfr-2.4.1/
 --with-gmp=/opt/cfarm/gmp-4.2.4/  --prefix=/n/16/guerby/cxx/install
 --enable-build-with-cxx

 make bootstrap
 ...
 g++ -c  -g -g -DIN_GCC   -W -Wall -Wwrite-strings -Wcast-qual
 -Wmissing-format-attribute -fno-common  -DHAVE_CONFIG_H -I. -I.
 -I../../gcc/gcc -I../../gcc/gcc/. -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/c-decl.c -o c-decl.o
 /usr/include/libintl.h:40: error: expected unqualified-id before ‘const’
 /usr/include/libintl.h:40: error: expected `)' before ‘const’
 /usr/include/libintl.h:40: error: expected initializer before ‘const’
 /usr/include/libintl.h:81: error: expected unqualified-id before ‘const’
 /usr/include/libintl.h:81: error: expected `)' before ‘const’
 /usr/include/libintl.h:81: error: expected initializer before ‘const’
 /usr/include/libintl.h:85: error: expected unqualified-id before ‘const’
 /usr/include/libintl.h:85: error: expected `)' before ‘const’
 /usr/include/libintl.h:85: error: expected initializer before ‘const’
 ../../gcc/gcc/c-decl.c: In function ‘tree_node* finish_enum(tree_node*,
 tree_node*, tree_node*)’:
 ../../gcc/gcc/c-decl.c:7011: warning: comparison between signed and
 unsigned integer expressions
 ../../gcc/gcc/c-decl.c:7032: warning: comparison between signed and
 unsigned integer expressions
 make[3]: *** [c-decl.o] Error 1
 make[3]: Leaving directory `/home/guerby/cxx/build/gcc'
 make[2]: *** [all-stage1-gcc] Error 2
 make[2]: Leaving directory `/home/guerby/cxx/build'
 make[1]: *** [stage1-bubble] Error 2
 make[1]: Leaving directory `/home/guerby/cxx/build'
 make: *** [bootstrap] Error 2

 Given the error is in non Ada-related code I guess this has to do
 with the base C++ compiler and system headers in C++ mode, gcc16 is
 running Debian 4.0 and GCC 4.1.2 (which works for trunk bootstrap of c,c
 ++,ada):

 gue...@gcc16:~/cxx/build$ g++ --version
 g++ (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)

 gcc16 has a collection of GCC versions:
 gue...@gcc16:~/cxx/build$ ls /opt/cfarm/release/
 4.2.0  4.2.1  4.2.2  4.2.3  4.2.4  4.3.0  4.3.1  4.3.2  4.3.3  4.4.0

 Using 4.2.3 as base compiler failed with the same error as system 4.1.2.

 Using 4.3.3 and 4.4.0 as base compiler bootstrap failed on Ada-related
 stuff, here gcc/ada/gcc-interface/decl.c:

 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/decl.c -o ada/decl.o
 ../../gcc/gcc/ada/gcc-interface/decl.c: In function 'tree_node* 
 substitute_in_type(tree_node*, tree_node*, tree_node*)':
 ../../gcc/gcc/ada/gcc-interface/decl.c:7791: error: expected unqualified-id 
 before 'new'
 ../../gcc/gcc/ada/gcc-interface/decl.c:7812: error: expected type-specifier 
 before '=' token
 ../../gcc/gcc/ada/gcc-interface/decl.c:7812: error: lvalue required as left 
 operand of assignment
 ../../gcc/gcc/ada/gcc-interface/decl.c:7813: error: expected type-specifier 
 before ')' token
 ../../gcc/gcc/ada/gcc-interface/decl.c:7813: error: request for member 'base' 
 in '*(int*)__t', which is of non-class type 'int'
 ../../gcc/gcc/ada/gcc-interface/decl.c:7813: error: request for member 'base' 
 in '*(int*)__t', which is of non-class type 'int'
 ../../gcc/gcc/ada/gcc-interface/decl.c:7813: error: request for member 'base' 
 in '*(int*)__t', which is of non-class type 'int'
 ../../gcc/gcc/ada/gcc-interface/decl.c:7813: error: request for member 'base' 
 in '*(int*)__t', which is of non-class type 'int'
 ../../gcc/gcc/ada/gcc-interface/decl.c:7813: error: request for member 'base' 
 in '*(int*)__t', which is of non-class type 'int'
 ../../gcc/gcc/ada/gcc-interface/decl.c:7813: error: cannot convert 'int* 
 const' to 'const tree_node*' for argument '1' to 'void 
 tree_check_failed(const 

Re: Phase 1 of gcc-in-cxx now complete (Ada)

2009-06-25 Thread Ian Lance Taylor
Richard Guenther richard.guent...@gmail.com writes:

 I guess this has to do with reserved word conflict on new:

 
 tree
 substitute_in_type (tree t, tree f, tree r)
 {
  tree new;


 Do you have some way to deal with this?

 Use a non-reserved identifier.  I guess on trunk Ada doesn't build
 with -Wc++-compat, does it?

Interesting.  I've been testing my -Wc++-compat patches with full
bootstraps including Ada, but I just looked at my make log and it does
indeed appear that -Wc++-compat doesn't make it onto the Ada files.

It seems to be because of this line in ada/gcc-interface/Make-lang.in:

ada-warn = $(ADA_CFLAGS) $(WERROR)

The other languages use

DIR-warn = $(STRICT_WARN)

which is what brings in -Wc++-compat.

Ian


Re: Phase 1 of gcc-in-cxx now complete (Ada)

2009-06-25 Thread Ian Lance Taylor
Laurent GUERBY laur...@guerby.net writes:

 Wanting to test Ada on the branch, after checkout I did on x86_64-linux:

 ../gcc/configure --enable-languages=c,c++,ada --enable-__cxa_atexit
 --disable-nls --enable-threads=posix --with-mpfr=/opt/cfarm/mpfr-2.4.1/
 --with-gmp=/opt/cfarm/gmp-4.2.4/  --prefix=/n/16/guerby/cxx/install
 --enable-build-with-cxx

 make bootstrap
 ...
 g++ -c  -g -g -DIN_GCC   -W -Wall -Wwrite-strings -Wcast-qual
 -Wmissing-format-attribute -fno-common  -DHAVE_CONFIG_H -I. -I.
 -I../../gcc/gcc -I../../gcc/gcc/. -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/c-decl.c -o c-decl.o
 /usr/include/libintl.h:40: error: expected unqualified-id before ‘const’
 /usr/include/libintl.h:40: error: expected `)' before ‘const’
 /usr/include/libintl.h:40: error: expected initializer before ‘const’
 /usr/include/libintl.h:81: error: expected unqualified-id before ‘const’
 /usr/include/libintl.h:81: error: expected `)' before ‘const’
 /usr/include/libintl.h:81: error: expected initializer before ‘const’
 /usr/include/libintl.h:85: error: expected unqualified-id before ‘const’
 /usr/include/libintl.h:85: error: expected `)' before ‘const’
 /usr/include/libintl.h:85: error: expected initializer before ‘const’

I looked at this.  It's due to the use of --disable-nls.  That causes
gcc/intl.h in the gcc sources to do this:

# undef gettext
# define gettext(msgid) (msgid)

Later, gmp.h is #included.  When gmp.h is compiled with C++, it
#includes iosfwd which (in gcc 4.1) #includes bits/c++locale.h which
#include libintl.h.  libintl.h does this:

extern char *gettext (__const char *__msgid)
 __THROW __attribute_format_arg__ (1);

which fails because of the #define of gettext.

I think the simple fix may be to always have gcc/intl.h include
libintl.h if it exists, to ensure that it does not get included later
after the gettext macro is defined.

Ian