public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Phase 1 of gcc-in-cxx now complete
@ 2009-06-25 20:33 Ian Lance Taylor
  2009-06-25 21:39 ` Richard Guenther
                   ` (5 more replies)
  0 siblings, 6 replies; 43+ messages in thread
From: Ian Lance Taylor @ 2009-06-25 20:33 UTC (permalink / raw)
  To: gcc

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.

This completes the first phase of the gcc-in-cxx project, which I
started about one year ago at the 2008 GCC Summit.

At this point I personally will probably not work on this project for
some weeks, other than bug fixing.  Further steps on the overall project
of converting gcc to C++ are:

* Write a coding standards document for gcc in C++.

* Convert more code to be compiled as C++ when using
  --enable-build-with-cxx.  Currently the generator programs
  (genattrtab, etc.) and libcpp are still compiled as C.

* Develop some trial patches which require C++, e.g., convert VEC to
  std::vector.

* Test starting the bootstrap with earlier versions of the compiler to
  see which C++ compiler version is required, and document that.

* Petition the steering committee for formal approval to switch to C++.

I do not expect to convert the compiler to require C++ in the 4.5
timeframe.

I encourage anybody who is interested to experiment with these further
steps.

Ian

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete
  2009-06-25 20:33 Phase 1 of gcc-in-cxx now complete Ian Lance Taylor
@ 2009-06-25 21:39 ` Richard Guenther
  2009-06-25 22:17 ` Phase 1 of gcc-in-cxx now complete (Ada) Laurent GUERBY
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 43+ messages in thread
From: Richard Guenther @ 2009-06-25 21:39 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc

On Thu, Jun 25, 2009 at 10:32 PM, Ian Lance Taylor<iant@google.com> 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.
>
> This completes the first phase of the gcc-in-cxx project, which I
> started about one year ago at the 2008 GCC Summit.
>
> At this point I personally will probably not work on this project for
> some weeks, other than bug fixing.  Further steps on the overall project
> of converting gcc to C++ are:
>
> * Write a coding standards document for gcc in C++.
>
> * Convert more code to be compiled as C++ when using
>  --enable-build-with-cxx.  Currently the generator programs
>  (genattrtab, etc.) and libcpp are still compiled as C.
>
> * Develop some trial patches which require C++, e.g., convert VEC to
>  std::vector.
>
> * Test starting the bootstrap with earlier versions of the compiler to
>  see which C++ compiler version is required, and document that.
>
> * Petition the steering committee for formal approval to switch to C++.
>
> I do not expect to convert the compiler to require C++ in the 4.5
> timeframe.

I think it would be a good thing to try forcing the C++ host compiler
requirement for GCC 4.5 with just building stage1 with C++ and stage2/3
with the stage1 C compiler.  --disable-build-with-cxx would be a
workaround for a missing C++ host compiler.

That should give us an idea on what problems we are going to face
when switching to actual C++ code.

Richard.

> I encourage anybody who is interested to experiment with these further
> steps.
>
> Ian
>

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete (Ada)
  2009-06-25 20:33 Phase 1 of gcc-in-cxx now complete Ian Lance Taylor
  2009-06-25 21:39 ` Richard Guenther
@ 2009-06-25 22:17 ` Laurent GUERBY
  2009-06-25 22:19   ` Richard Guenther
  2009-06-25 22:51   ` Ian Lance Taylor
  2009-06-25 22:29 ` Phase 1 of gcc-in-cxx now complete Joseph S. Myers
                   ` (3 subsequent siblings)
  5 siblings, 2 replies; 43+ messages in thread
From: Laurent GUERBY @ 2009-06-25 22:17 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc

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

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

gcc16 has a collection of GCC versions:
guerby@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 of non-class type 'int'
../../gcc/gcc/ada/gcc-interface/decl.c:7814: error: expected type-specifier before ')' token
[...]
make[3]: *** [ada/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

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?

Sincerely,

Laurent



^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete (Ada)
  2009-06-25 22:17 ` Phase 1 of gcc-in-cxx now complete (Ada) Laurent GUERBY
@ 2009-06-25 22:19   ` Richard Guenther
  2009-06-25 22:38     ` Ian Lance Taylor
  2009-06-25 22:51   ` Ian Lance Taylor
  1 sibling, 1 reply; 43+ messages in thread
From: Richard Guenther @ 2009-06-25 22:19 UTC (permalink / raw)
  To: Laurent GUERBY; +Cc: Ian Lance Taylor, gcc

On Thu, Jun 25, 2009 at 11:50 PM, Laurent GUERBY<laurent@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):
>
> guerby@gcc16:~/cxx/build$ g++ --version
> g++ (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
>
> gcc16 has a collection of GCC versions:
> guerby@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 of non-class type 'int'
> ../../gcc/gcc/ada/gcc-interface/decl.c:7814: error: expected type-specifier before ')' token
> [...]
> make[3]: *** [ada/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
>
> 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?

Richard.

> Sincerely,
>
> Laurent
>
>
>
>

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete
  2009-06-25 20:33 Phase 1 of gcc-in-cxx now complete Ian Lance Taylor
  2009-06-25 21:39 ` Richard Guenther
  2009-06-25 22:17 ` Phase 1 of gcc-in-cxx now complete (Ada) Laurent GUERBY
@ 2009-06-25 22:29 ` Joseph S. Myers
  2009-06-25 22:47   ` Eric Botcazou
  2009-06-25 22:49   ` Joe Buck
  2009-06-26 18:21 ` Adam Nemet
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 43+ messages in thread
From: Joseph S. Myers @ 2009-06-25 22:29 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc

On Thu, 25 Jun 2009, Ian Lance Taylor wrote:

> * Test starting the bootstrap with earlier versions of the compiler to
>   see which C++ compiler version is required, and document that.

I think the right approach is not documenting observations like that, but 
investigating the causes of failures with older compilers and making it 
build with as wide a range of versions of GCC (and ideally at least one 
non-GCC C++ compiler, probably an EDG-based one such as the Intel 
compiler) as is reasonable.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete (Ada)
  2009-06-25 22:19   ` Richard Guenther
@ 2009-06-25 22:38     ` Ian Lance Taylor
  2009-06-26 11:20       ` Laurent GUERBY
  2009-06-27 10:55       ` Eric Botcazou
  0 siblings, 2 replies; 43+ messages in thread
From: Ian Lance Taylor @ 2009-06-25 22:38 UTC (permalink / raw)
  To: Richard Guenther; +Cc: Laurent GUERBY, gcc

Richard Guenther <richard.guenther@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

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete
  2009-06-25 22:29 ` Phase 1 of gcc-in-cxx now complete Joseph S. Myers
@ 2009-06-25 22:47   ` Eric Botcazou
  2009-06-25 22:49   ` Joe Buck
  1 sibling, 0 replies; 43+ messages in thread
From: Eric Botcazou @ 2009-06-25 22:47 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: gcc, Ian Lance Taylor

> I think the right approach is not documenting observations like that, but
> investigating the causes of failures with older compilers and making it
> build with as wide a range of versions of GCC (and ideally at least one
> non-GCC C++ compiler, probably an EDG-based one such as the Intel
> compiler) as is reasonable.

Yes, I don't think we should require GCC to build GCC, this would be a step 
backwards in my opinion.  I can experiment with the Sun Studio compiler.

-- 
Eric Botcazou

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete
  2009-06-25 22:29 ` Phase 1 of gcc-in-cxx now complete Joseph S. Myers
  2009-06-25 22:47   ` Eric Botcazou
@ 2009-06-25 22:49   ` Joe Buck
  2009-06-26  7:09     ` Gabriel Dos Reis
  1 sibling, 1 reply; 43+ messages in thread
From: Joe Buck @ 2009-06-25 22:49 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: Ian Lance Taylor, gcc

On Thu, Jun 25, 2009 at 03:19:19PM -0700, Joseph S. Myers wrote:
> On Thu, 25 Jun 2009, Ian Lance Taylor wrote:
> 
> > * Test starting the bootstrap with earlier versions of the compiler to
> >   see which C++ compiler version is required, and document that.
> 
> I think the right approach is not documenting observations like that, but
> investigating the causes of failures with older compilers and making it
> build with as wide a range of versions of GCC (and ideally at least one
> non-GCC C++ compiler, probably an EDG-based one such as the Intel
> compiler) as is reasonable.

Microsoft's and Sun's compilers would be more likely to run into issues,
particularly Sun's; Sun has had a policy of preferring solid backward
compatibility to standards compliance, so I've tended to have more
problems getting correct, standard C++ to run on their compiler than on
others.  This is particularly true of template-based code and nested
classes.

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete (Ada)
  2009-06-25 22:17 ` Phase 1 of gcc-in-cxx now complete (Ada) Laurent GUERBY
  2009-06-25 22:19   ` Richard Guenther
@ 2009-06-25 22:51   ` Ian Lance Taylor
  1 sibling, 0 replies; 43+ messages in thread
From: Ian Lance Taylor @ 2009-06-25 22:51 UTC (permalink / raw)
  To: Laurent GUERBY; +Cc: gcc

Laurent GUERBY <laurent@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

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete
  2009-06-25 22:49   ` Joe Buck
@ 2009-06-26  7:09     ` Gabriel Dos Reis
  2009-06-26 14:12       ` Jack Howarth
  0 siblings, 1 reply; 43+ messages in thread
From: Gabriel Dos Reis @ 2009-06-26  7:09 UTC (permalink / raw)
  To: Joe Buck; +Cc: Joseph S. Myers, Ian Lance Taylor, gcc

On Thu, Jun 25, 2009 at 5:47 PM, Joe Buck<Joe.Buck@synopsys.com> wrote:
> On Thu, Jun 25, 2009 at 03:19:19PM -0700, Joseph S. Myers wrote:
>> On Thu, 25 Jun 2009, Ian Lance Taylor wrote:
>>
>> > * Test starting the bootstrap with earlier versions of the compiler to
>> >   see which C++ compiler version is required, and document that.
>>
>> I think the right approach is not documenting observations like that, but
>> investigating the causes of failures with older compilers and making it
>> build with as wide a range of versions of GCC (and ideally at least one
>> non-GCC C++ compiler, probably an EDG-based one such as the Intel
>> compiler) as is reasonable.
>
> Microsoft's and Sun's compilers would be more likely to run into issues,
> particularly Sun's; Sun has had a policy of preferring solid backward
> compatibility to standards compliance, so I've tended to have more
> problems getting correct, standard C++ to run on their compiler than on
> others.  This is particularly true of template-based code and nested
> classes.

Yes, but I also think that we should aim for a conservative subset
of C++ -- that is solid enough for the last decade.  I don't pretend
that is an easy task, but I believe that can only help us.

-- Gaby


>
>

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete (Ada)
  2009-06-25 22:38     ` Ian Lance Taylor
@ 2009-06-26 11:20       ` Laurent GUERBY
  2009-06-26 14:48         ` Ian Lance Taylor
  2009-06-27 10:55       ` Eric Botcazou
  1 sibling, 1 reply; 43+ messages in thread
From: Laurent GUERBY @ 2009-06-26 11:20 UTC (permalink / raw)
  To: Ian Lance Taylor, Eric Botcazou; +Cc: Richard Guenther, gcc

[-- Attachment #1: Type: text/plain, Size: 4330 bytes --]

On Thu, 2009-06-25 at 15:28 -0700, Ian Lance Taylor wrote:
> Richard Guenther <richard.guenther@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


[-- Attachment #2: patch-ada-gcc-in-cxx-new_class_template.txt --]
[-- Type: text/plain, Size: 19229 bytes --]

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),
-		       integer_zerop (TREE_OPERAND (size, 1))
-		       ? last_size : merge_sizes (last_size, first_bit,
-						  TREE_OPERAND (size, 1),
-						  1, has_rep),
-		       integer_zerop (TREE_OPERAND (size, 2))
-		       ? last_size : merge_sizes (last_size, first_bit,
-						  TREE_OPERAND (size, 2),
-						  1, has_rep));
+    new_tree = fold_build3 (COND_EXPR, type, TREE_OPERAND (size, 0),
+		            integer_zerop (TREE_OPERAND (size, 1))
+		            ? last_size : merge_sizes (last_size, first_bit,
+		     				  TREE_OPERAND (size, 1),
+		     				  1, has_rep),
+		            integer_zerop (TREE_OPERAND (size, 2))
+		            ? last_size : merge_sizes (last_size, first_bit,
+		     				  TREE_OPERAND (size, 2),
+		     				  1, has_rep));
 
   /* We don't need any NON_VALUE_EXPRs and they can confuse us (especially
      when fed through substitute_in_expr) into thinking that a constant
      size is not constant.  */
-  while (TREE_CODE (new) == NON_LVALUE_EXPR)
-    new = TREE_OPERAND (new, 0);
+  while (TREE_CODE (new_tree) == NON_LVALUE_EXPR)
+    new_tree = TREE_OPERAND (new_tree, 0);
 
-  return new;
+  return new_tree;
 }
 
 /* Utility function of above to see if OP0 and OP1, both of SIZETYPE, are
@@ -1160,18 +1160,18 @@
 tree
 copy_type (tree type)
 {
-  tree new = copy_node (type);
+  tree new_tree = copy_node (type);
 
   /* copy_node clears this field instead of copying it, because it is
      aliased with TREE_CHAIN.  */
-  TYPE_STUB_DECL (new) = TYPE_STUB_DECL (type);
+  TYPE_STUB_DECL (new_tree) = TYPE_STUB_DECL (type);
 
-  TYPE_POINTER_TO (new) = 0;
-  TYPE_REFERENCE_TO (new) = 0;
-  TYPE_MAIN_VARIANT (new) = new;
-  TYPE_NEXT_VARIANT (new) = 0;
+  TYPE_POINTER_TO (new_tree) = 0;
+  TYPE_REFERENCE_TO (new_tree) = 0;
+  TYPE_MAIN_VARIANT (new_tree) = new_tree;
+  TYPE_NEXT_VARIANT (new_tree) = 0;
 
-  return new;
+  return new_tree;
 }
 \f
 /* Return a subtype of sizetype with range MIN to MAX and whose
@@ -2512,7 +2512,7 @@
   tree record_type = make_node (RECORD_TYPE);
   tree pointer32_type;
   tree field_list = 0;
-  int class;
+  int class_i;
   int dtype = 0;
   tree inner_type;
   int ndim;
@@ -2624,22 +2624,22 @@
     {
     case By_Descriptor_A:
     case By_Short_Descriptor_A:
-      class = 4;
+      class_i = 4;
       break;
     case By_Descriptor_NCA:
     case By_Short_Descriptor_NCA:
-      class = 10;
+      class_i = 10;
       break;
     case By_Descriptor_SB:
     case By_Short_Descriptor_SB:
-      class = 15;
+      class_i = 15;
       break;
     case By_Descriptor:
     case By_Short_Descriptor:
     case By_Descriptor_S:
     case By_Short_Descriptor_S:
     default:
-      class = 1;
+      class_i = 1;
       break;
     }
 
@@ -2661,7 +2661,7 @@
   field_list = chainon (field_list,
 			make_descriptor_field ("CLASS",
 					       gnat_type_for_size (8, 1),
-					       record_type, size_int (class)));
+					       record_type, size_int (class_i)));
 
   /* Of course this will crash at run-time if the address space is not
      within the low 32 bits, but there is nothing else we can do.  */
@@ -2827,7 +2827,7 @@
   tree record64_type = make_node (RECORD_TYPE);
   tree pointer64_type;
   tree field_list64 = 0;
-  int class;
+  int class_i;
   int dtype = 0;
   tree inner_type;
   int ndim;
@@ -2938,18 +2938,18 @@
   switch (mech)
     {
     case By_Descriptor_A:
-      class = 4;
+      class_i = 4;
       break;
     case By_Descriptor_NCA:
-      class = 10;
+      class_i = 10;
       break;
     case By_Descriptor_SB:
-      class = 15;
+      class_i = 15;
       break;
     case By_Descriptor:
     case By_Descriptor_S:
     default:
-      class = 1;
+      class_i = 1;
       break;
     }
 
@@ -2968,7 +2968,7 @@
   field_list64 = chainon (field_list64,
 			make_descriptor_field ("CLASS",
 					       gnat_type_for_size (8, 1),
-					       record64_type, size_int (class)));
+					       record64_type, size_int (class_i)));
 
   field_list64 = chainon (field_list64,
 			make_descriptor_field ("MBMO",
@@ -3151,9 +3151,9 @@
   tree desc_type = TREE_TYPE (TREE_TYPE (gnu_expr));
   tree desc = build1 (INDIRECT_REF, desc_type, gnu_expr);
   /* The CLASS field is the 3rd field in the descriptor.  */
-  tree class = TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (desc_type)));
+  tree class_tree = TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (desc_type)));
   /* The POINTER field is the 6th field in the descriptor.  */
-  tree pointer64 = TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (class)));
+  tree pointer64 = TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (class_tree)));
 
   /* Retrieve the value of the POINTER field.  */
   tree gnu_expr64
@@ -3169,9 +3169,9 @@
       tree template_type = TREE_TYPE (p_bounds_type);
       tree min_field = TYPE_FIELDS (template_type);
       tree max_field = TREE_CHAIN (TYPE_FIELDS (template_type));
-      tree template, template_addr, aflags, dimct, t, u;
+      tree template_tree, template_addr, aflags, dimct, t, u;
       /* See the head comment of build_vms_descriptor.  */
-      int iclass = TREE_INT_CST_LOW (DECL_INITIAL (class));
+      int iclass = TREE_INT_CST_LOW (DECL_INITIAL (class_tree));
       tree lfield, ufield;
 
       /* Convert POINTER to the type of the P_ARRAY field.  */
@@ -3182,23 +3182,23 @@
 	case 1:  /* Class S  */
 	case 15: /* Class SB */
 	  /* Build {1, LENGTH} template; LENGTH64 is the 5th field.  */
-	  t = TREE_CHAIN (TREE_CHAIN (class));
+	  t = TREE_CHAIN (TREE_CHAIN (class_tree));
 	  t = build3 (COMPONENT_REF, TREE_TYPE (t), desc, t, NULL_TREE);
 	  t = tree_cons (min_field,
 			 convert (TREE_TYPE (min_field), integer_one_node),
 			 tree_cons (max_field,
 				    convert (TREE_TYPE (max_field), t),
 				    NULL_TREE));
-	  template = gnat_build_constructor (template_type, t);
-	  template_addr = build_unary_op (ADDR_EXPR, NULL_TREE, template);
+	  template_tree = gnat_build_constructor (template_type, t);
+	  template_addr = build_unary_op (ADDR_EXPR, NULL_TREE, template_tree);
 
 	  /* For class S, we are done.  */
 	  if (iclass == 1)
 	    break;
 
 	  /* Test that we really have a SB descriptor, like DEC Ada.  */
-	  t = build3 (COMPONENT_REF, TREE_TYPE (class), desc, class, NULL);
-	  u = convert (TREE_TYPE (class), DECL_INITIAL (class));
+	  t = build3 (COMPONENT_REF, TREE_TYPE (class_tree), desc, class_tree, NULL);
+	  u = convert (TREE_TYPE (class_tree), DECL_INITIAL (class_tree));
 	  u = build_binary_op (EQ_EXPR, integer_type_node, t, u);
 	  /* If so, there is already a template in the descriptor and
 	     it is located right after the POINTER field.  The fields are
@@ -3216,12 +3216,12 @@
 	  t = tree_cons (TYPE_FIELDS (template_type), lfield,
 			 tree_cons (TREE_CHAIN (TYPE_FIELDS (template_type)),
                                     ufield, NULL_TREE));
-	  template = gnat_build_constructor (template_type, t);
+	  template_tree = gnat_build_constructor (template_type, t);
 
 	  /* Otherwise use the {1, LENGTH} template we build above.  */
 	  template_addr = build3 (COND_EXPR, p_bounds_type, u,
 				  build_unary_op (ADDR_EXPR, p_bounds_type,
-				 		 template),
+				 		 template_tree),
 				  template_addr);
 	  break;
 
@@ -3263,12 +3263,12 @@
 	  t = tree_cons (TYPE_FIELDS (template_type), lfield,
 			 tree_cons (TREE_CHAIN (TYPE_FIELDS (template_type)),
                                     ufield, NULL_TREE));
-	  template = gnat_build_constructor (template_type, t);
-	  template = build3 (COND_EXPR, p_bounds_type, u,
+	  template_tree = gnat_build_constructor (template_type, t);
+	  template_tree = build3 (COND_EXPR, p_bounds_type, u,
 			    build_call_raise (CE_Length_Check_Failed, Empty,
 					      N_Raise_Constraint_Error),
-			    template);
-	  template_addr = build_unary_op (ADDR_EXPR, p_bounds_type, template);
+			    template_tree);
+	  template_addr = build_unary_op (ADDR_EXPR, p_bounds_type, template_tree);
 	  break;
 
 	case 10: /* Class NCA */
@@ -3299,9 +3299,9 @@
   tree desc_type = TREE_TYPE (TREE_TYPE (gnu_expr));
   tree desc = build1 (INDIRECT_REF, desc_type, gnu_expr);
   /* The CLASS field is the 3rd field in the descriptor.  */
-  tree class = TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (desc_type)));
+  tree class_tree = TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (desc_type)));
   /* The POINTER field is the 4th field in the descriptor.  */
-  tree pointer = TREE_CHAIN (class);
+  tree pointer = TREE_CHAIN (class_tree);
 
   /* Retrieve the value of the POINTER field.  */
   tree gnu_expr32
@@ -3317,9 +3317,9 @@
       tree template_type = TREE_TYPE (p_bounds_type);
       tree min_field = TYPE_FIELDS (template_type);
       tree max_field = TREE_CHAIN (TYPE_FIELDS (template_type));
-      tree template, template_addr, aflags, dimct, t, u;
+      tree template_tree, template_addr, aflags, dimct, t, u;
       /* See the head comment of build_vms_descriptor.  */
-      int iclass = TREE_INT_CST_LOW (DECL_INITIAL (class));
+      int iclass = TREE_INT_CST_LOW (DECL_INITIAL (class_tree));
 
       /* Convert POINTER to the type of the P_ARRAY field.  */
       gnu_expr32 = convert (p_array_type, gnu_expr32);
@@ -3336,25 +3336,25 @@
 			 tree_cons (max_field,
 				    convert (TREE_TYPE (max_field), t),
 				    NULL_TREE));
-	  template = gnat_build_constructor (template_type, t);
-	  template_addr = build_unary_op (ADDR_EXPR, NULL_TREE, template);
+	  template_tree = gnat_build_constructor (template_type, t);
+	  template_addr = build_unary_op (ADDR_EXPR, NULL_TREE, template_tree);
 
 	  /* For class S, we are done.  */
 	  if (iclass == 1)
 	    break;
 
 	  /* Test that we really have a SB descriptor, like DEC Ada.  */
-	  t = build3 (COMPONENT_REF, TREE_TYPE (class), desc, class, NULL);
-	  u = convert (TREE_TYPE (class), DECL_INITIAL (class));
+	  t = build3 (COMPONENT_REF, TREE_TYPE (class_tree), desc, class_tree, NULL);
+	  u = convert (TREE_TYPE (class_tree), DECL_INITIAL (class_tree));
 	  u = build_binary_op (EQ_EXPR, integer_type_node, t, u);
 	  /* If so, there is already a template in the descriptor and
 	     it is located right after the POINTER field.  */
 	  t = TREE_CHAIN (pointer);
-	  template = build3 (COMPONENT_REF, TREE_TYPE (t), desc, t, NULL_TREE);
+	  template_tree = build3 (COMPONENT_REF, TREE_TYPE (t), desc, t, NULL_TREE);
 	  /* Otherwise use the {1, LENGTH} template we build above.  */
 	  template_addr = build3 (COND_EXPR, p_bounds_type, u,
 				  build_unary_op (ADDR_EXPR, p_bounds_type,
-				 		 template),
+				 		 template_tree),
 				  template_addr);
 	  break;
 
@@ -3381,12 +3381,12 @@
 	  /* There is already a template in the descriptor and it is
 	     located at the start of block 3 (12th field).  */
 	  t = TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (t))));
-	  template = build3 (COMPONENT_REF, TREE_TYPE (t), desc, t, NULL_TREE);
-	  template = build3 (COND_EXPR, p_bounds_type, u,
+	  template_tree = build3 (COMPONENT_REF, TREE_TYPE (t), desc, t, NULL_TREE);
+	  template_tree = build3 (COND_EXPR, p_bounds_type, u,
 			    build_call_raise (CE_Length_Check_Failed, Empty,
 					      N_Raise_Constraint_Error),
-			    template);
-	  template_addr = build_unary_op (ADDR_EXPR, p_bounds_type, template);
+			    template_tree);
+	  template_addr = build_unary_op (ADDR_EXPR, p_bounds_type, template_tree);
 	  break;
 
 	case 10: /* Class NCA */
@@ -3717,7 +3717,7 @@
   tree template_type = TREE_TYPE (TREE_TYPE (TREE_CHAIN (TYPE_FIELDS (type))));
   tree p_array_type = TREE_TYPE (TYPE_FIELDS (type));
   tree etype = TREE_TYPE (expr);
-  tree template;
+  tree template_tree;
 
   /* If EXPR is null, make a fat pointer that contains null pointers to the
      template and array.  */
@@ -3743,7 +3743,7 @@
       else
 	expr = build1 (INDIRECT_REF, TREE_TYPE (etype), expr);
 
-      template = build_component_ref (expr, NULL_TREE, fields, false);
+      template_tree = build_component_ref (expr, NULL_TREE, fields, false);
       expr = build_unary_op (ADDR_EXPR, NULL_TREE,
 			     build_component_ref (expr, NULL_TREE,
 						  TREE_CHAIN (fields), false));
@@ -3751,7 +3751,7 @@
 
   /* Otherwise, build the constructor for the template.  */
   else
-    template = build_template (template_type, TREE_TYPE (etype), expr);
+    template_tree = build_template (template_type, TREE_TYPE (etype), expr);
 
   /* The final result is a constructor for the fat pointer.
 
@@ -3771,7 +3771,7 @@
        tree_cons (TYPE_FIELDS (type),
 		  convert (p_array_type, expr),
 		  tree_cons (TREE_CHAIN (TYPE_FIELDS (type)),
-			     build_unary_op (ADDR_EXPR, NULL_TREE, template),
+			     build_unary_op (ADDR_EXPR, NULL_TREE, template_tree),
 			     NULL_TREE)));
 }
 \f
@@ -4301,20 +4301,20 @@
 maybe_unconstrained_array (tree exp)
 {
   enum tree_code code = TREE_CODE (exp);
-  tree new;
+  tree new_tree;
 
   switch (TREE_CODE (TREE_TYPE (exp)))
     {
     case UNCONSTRAINED_ARRAY_TYPE:
       if (code == UNCONSTRAINED_ARRAY_REF)
 	{
-	  new
+	  new_tree
 	    = build_unary_op (INDIRECT_REF, NULL_TREE,
 			      build_component_ref (TREE_OPERAND (exp, 0),
 						   get_identifier ("P_ARRAY"),
 						   NULL_TREE, false));
-	  TREE_READONLY (new) = TREE_STATIC (new) = TREE_READONLY (exp);
-	  return new;
+	  TREE_READONLY (new_tree) = TREE_STATIC (new_tree) = TREE_READONLY (exp);
+	  return new_tree;
 	}
 
       else if (code == NULL_EXPR)
@@ -4328,12 +4328,12 @@
 	 it contains a template.  */
       if (TYPE_IS_PADDING_P (TREE_TYPE (exp)))
 	{
-	  new = convert (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (exp))), exp);
-	  if (TREE_CODE (TREE_TYPE (new)) == RECORD_TYPE
-	      && TYPE_CONTAINS_TEMPLATE_P (TREE_TYPE (new)))
+	  new_tree = convert (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (exp))), exp);
+	  if (TREE_CODE (TREE_TYPE (new_tree)) == RECORD_TYPE
+	      && TYPE_CONTAINS_TEMPLATE_P (TREE_TYPE (new_tree)))
 	    return
-	      build_component_ref (new, NULL_TREE,
-				   TREE_CHAIN (TYPE_FIELDS (TREE_TYPE (new))),
+	      build_component_ref (new_tree, NULL_TREE,
+				   TREE_CHAIN (TYPE_FIELDS (TREE_TYPE (new_tree))),
 				   0);
 	}
       else if (TYPE_CONTAINS_TEMPLATE_P (TREE_TYPE (exp)))
Index: gcc/ada/gcc-interface/decl.c
===================================================================
--- gcc/ada/gcc-interface/decl.c	(revision 148953)
+++ gcc/ada/gcc-interface/decl.c	(working copy)
@@ -7788,7 +7788,7 @@
 tree
 substitute_in_type (tree t, tree f, tree r)
 {
-  tree new;
+  tree new_tree;
 
   gcc_assert (CONTAINS_PLACEHOLDER_P (r));
 
@@ -7809,15 +7809,15 @@
 	  if (low == TYPE_GCC_MIN_VALUE (t) && high == TYPE_GCC_MAX_VALUE (t))
 	    return t;
 
-	  new = copy_type (t);
-	  TYPE_GCC_MIN_VALUE (new) = low;
-	  TYPE_GCC_MAX_VALUE (new) = high;
+	  new_tree = copy_type (t);
+	  TYPE_GCC_MIN_VALUE (new_tree) = low;
+	  TYPE_GCC_MAX_VALUE (new_tree) = high;
 
 	  if (TREE_CODE (t) == INTEGER_TYPE && TYPE_INDEX_TYPE (t))
 	    SET_TYPE_INDEX_TYPE
-	      (new, substitute_in_type (TYPE_INDEX_TYPE (t), f, r));
+	      (new_tree, substitute_in_type (TYPE_INDEX_TYPE (t), f, r));
 
-	  return new;
+	  return new_tree;
 	}
 
       /* Then the subtypes.  */
@@ -7830,21 +7830,21 @@
 	  if (low == TYPE_RM_MIN_VALUE (t) && high == TYPE_RM_MAX_VALUE (t))
 	    return t;
 
-	  new = copy_type (t);
-	  SET_TYPE_RM_MIN_VALUE (new, low);
-	  SET_TYPE_RM_MAX_VALUE (new, high);
+	  new_tree = copy_type (t);
+	  SET_TYPE_RM_MIN_VALUE (new_tree, low);
+	  SET_TYPE_RM_MAX_VALUE (new_tree, high);
 
-	  return new;
+	  return new_tree;
 	}
 
       return t;
 
     case COMPLEX_TYPE:
-      new = substitute_in_type (TREE_TYPE (t), f, r);
-      if (new == TREE_TYPE (t))
+      new_tree = substitute_in_type (TREE_TYPE (t), f, r);
+      if (new_tree == TREE_TYPE (t))
 	return t;
 
-      return build_complex_type (new);
+      return build_complex_type (new_tree);
 
     case OFFSET_TYPE:
     case METHOD_TYPE:
@@ -7861,16 +7861,16 @@
 	if (component == TREE_TYPE (t) && domain == TYPE_DOMAIN (t))
 	  return t;
 
-	new = build_array_type (component, domain);
-	TYPE_ALIGN (new) = TYPE_ALIGN (t);
-	TYPE_USER_ALIGN (new) = TYPE_USER_ALIGN (t);
-	SET_TYPE_MODE (new, TYPE_MODE (t));
-	TYPE_SIZE (new) = SUBSTITUTE_IN_EXPR (TYPE_SIZE (t), f, r);
-	TYPE_SIZE_UNIT (new) = SUBSTITUTE_IN_EXPR (TYPE_SIZE_UNIT (t), f, r);
-	TYPE_NONALIASED_COMPONENT (new) = TYPE_NONALIASED_COMPONENT (t);
-	TYPE_MULTI_ARRAY_P (new) = TYPE_MULTI_ARRAY_P (t);
-	TYPE_CONVENTION_FORTRAN_P (new) = TYPE_CONVENTION_FORTRAN_P (t);
-	return new;
+	new_tree = build_array_type (component, domain);
+	TYPE_ALIGN (new_tree) = TYPE_ALIGN (t);
+	TYPE_USER_ALIGN (new_tree) = TYPE_USER_ALIGN (t);
+	SET_TYPE_MODE (new_tree, TYPE_MODE (t));
+	TYPE_SIZE (new_tree) = SUBSTITUTE_IN_EXPR (TYPE_SIZE (t), f, r);
+	TYPE_SIZE_UNIT (new_tree) = SUBSTITUTE_IN_EXPR (TYPE_SIZE_UNIT (t), f, r);
+	TYPE_NONALIASED_COMPONENT (new_tree) = TYPE_NONALIASED_COMPONENT (t);
+	TYPE_MULTI_ARRAY_P (new_tree) = TYPE_MULTI_ARRAY_P (t);
+	TYPE_CONVENTION_FORTRAN_P (new_tree) = TYPE_CONVENTION_FORTRAN_P (t);
+	return new_tree;
       }
 
     case RECORD_TYPE:
@@ -7883,8 +7883,8 @@
 	/* Start out with no fields, make new fields, and chain them
 	   in.  If we haven't actually changed the type of any field,
 	   discard everything we've done and return the old type.  */
-	new = copy_type (t);
-	TYPE_FIELDS (new) = NULL_TREE;
+	new_tree = copy_type (t);
+	TYPE_FIELDS (new_tree) = NULL_TREE;
 
 	for (field = TYPE_FIELDS (t); field; field = TREE_CHAIN (field))
 	  {
@@ -7915,23 +7915,23 @@
 		  }
 	      }
 
-	    DECL_CONTEXT (new_field) = new;
+	    DECL_CONTEXT (new_field) = new_tree;
 	    SET_DECL_ORIGINAL_FIELD (new_field,
 				     (DECL_ORIGINAL_FIELD (field)
 				      ? DECL_ORIGINAL_FIELD (field) : field));
 
-	    TREE_CHAIN (new_field) = TYPE_FIELDS (new);
-	    TYPE_FIELDS (new) = new_field;
+	    TREE_CHAIN (new_field) = TYPE_FIELDS (new_tree);
+	    TYPE_FIELDS (new_tree) = new_field;
 	  }
 
 	if (!changed_field)
 	  return t;
 
-	TYPE_FIELDS (new) = nreverse (TYPE_FIELDS (new));
-	TYPE_SIZE (new) = SUBSTITUTE_IN_EXPR (TYPE_SIZE (t), f, r);
-	TYPE_SIZE_UNIT (new) = SUBSTITUTE_IN_EXPR (TYPE_SIZE_UNIT (t), f, r);
-	SET_TYPE_ADA_SIZE (new, SUBSTITUTE_IN_EXPR (TYPE_ADA_SIZE (t), f, r));
-	return new;
+	TYPE_FIELDS (new_tree) = nreverse (TYPE_FIELDS (new_tree));
+	TYPE_SIZE (new_tree) = SUBSTITUTE_IN_EXPR (TYPE_SIZE (t), f, r);
+	TYPE_SIZE_UNIT (new_tree) = SUBSTITUTE_IN_EXPR (TYPE_SIZE_UNIT (t), f, r);
+	SET_TYPE_ADA_SIZE (new_tree, SUBSTITUTE_IN_EXPR (TYPE_ADA_SIZE (t), f, r));
+	return new_tree;
       }
 
     default:

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete
  2009-06-26  7:09     ` Gabriel Dos Reis
@ 2009-06-26 14:12       ` Jack Howarth
  0 siblings, 0 replies; 43+ messages in thread
From: Jack Howarth @ 2009-06-26 14:12 UTC (permalink / raw)
  To: gdr; +Cc: Joe Buck, Joseph S. Myers, Ian Lance Taylor, gcc

On Fri, Jun 26, 2009 at 01:33:06AM -0500, Gabriel Dos Reis wrote:
> On Thu, Jun 25, 2009@5:47 PM, Joe Buck<Joe.Buck@synopsys.com> wrote:
> > On Thu, Jun 25, 2009@03:19:19PM -0700, Joseph S. Myers wrote:
> >> On Thu, 25 Jun 2009, Ian Lance Taylor wrote:
> >>
> >> > * Test starting the bootstrap with earlier versions of the compiler to
> >> >   see which C++ compiler version is required, and document that.
> >>
> >> I think the right approach is not documenting observations like that, but
> >> investigating the causes of failures with older compilers and making it
> >> build with as wide a range of versions of GCC (and ideally@least one
> >> non-GCC C++ compiler, probably an EDG-based one such as the Intel
> >> compiler) as is reasonable.
> >
> > Microsoft's and Sun's compilers would be more likely to run into issues,
> > particularly Sun's; Sun has had a policy of preferring solid backward
> > compatibility to standards compliance, so I've tended to have more
> > problems getting correct, standard C++ to run on their compiler than on
> > others.  This is particularly true of template-based code and nested
> > classes.
> 
> Yes, but I also think that we should aim for a conservative subset
> of C++ -- that is solid enough for the last decade.  I don't pretend
> that is an easy task, but I believe that can only help us.
> 
> -- Gaby
> 
> 

Certainly the minimum version of gcc required for compiling with the
cxx support should be well defined. On Mac OS X for instance, the ppl
required for the graphite support in gcc >= 4.4 doesn't compile with
Apple's g++-4.0.1 compilers and requires their g++-4.2.1 compilers 
instead. 
            Jack

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete (Ada)
  2009-06-26 11:20       ` Laurent GUERBY
@ 2009-06-26 14:48         ` Ian Lance Taylor
  2009-06-26 15:36           ` Arnaud Charlet
  2009-06-26 15:59           ` Laurent GUERBY
  0 siblings, 2 replies; 43+ messages in thread
From: Ian Lance Taylor @ 2009-06-26 14:48 UTC (permalink / raw)
  To: laurent; +Cc: Eric Botcazou, Richard Guenther, gcc

Laurent GUERBY <laurent@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

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete (Ada)
  2009-06-26 14:48         ` Ian Lance Taylor
@ 2009-06-26 15:36           ` Arnaud Charlet
  2009-06-26 15:59           ` Laurent GUERBY
  1 sibling, 0 replies; 43+ messages in thread
From: Arnaud Charlet @ 2009-06-26 15:36 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: laurent, Eric Botcazou, Richard Guenther, gcc

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

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete (Ada)
  2009-06-26 14:48         ` Ian Lance Taylor
  2009-06-26 15:36           ` Arnaud Charlet
@ 2009-06-26 15:59           ` Laurent GUERBY
  2009-06-26 17:32             ` Ian Lance Taylor
  1 sibling, 1 reply; 43+ messages in thread
From: Laurent GUERBY @ 2009-06-26 15:59 UTC (permalink / raw)
  To: Ian Lance Taylor, Arnaud Charlet; +Cc: Eric Botcazou, Richard Guenther, gcc

[-- Attachment #1: Type: text/plain, Size: 4568 bytes --]

On Fri, 2009-06-26 at 07:44 -0700, Ian Lance Taylor wrote:
> > 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 *".

Thanks for the advices, there were no other compile issue. As suggested
by Arnaud I will test my current patch (attached below as
patch-ada-gcc-in-cxx-v2.txt) on trunk (I checked and it applies cleanly)
and submit it on gcc-patches with a proper ChangeLog for trunk.

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 :).

Sincerely,

Laurent


[-- Attachment #2: patch-ada-gcc-in-cxx-v2.txt --]
[-- Type: text/plain, Size: 22001 bytes --]

Index: gcc/ada/tb-gcc.c
===================================================================
--- gcc/ada/tb-gcc.c	(revision 148953)
+++ gcc/ada/tb-gcc.c	(working copy)
@@ -64,13 +64,13 @@
 static _Unwind_Reason_Code
 trace_callback (struct _Unwind_Context * uw_context, uw_data_t * uw_data)
 {
-  void * pc;
+  char * pc;
 
 #if defined (__ia64__) && defined (__hpux__)
   /* Work around problem with _Unwind_GetIP on ia64 HP-UX. */
   uwx_get_reg ((struct uwx_env *) uw_context, UWX_REG_IP, (uint64_t *) &pc);
 #else
-  pc = (void *) _Unwind_GetIP (uw_context);
+  pc = (char *) _Unwind_GetIP (uw_context);
 #endif
 
   if (uw_data->n_frames_skipped < uw_data->n_frames_to_skip)
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),
-		       integer_zerop (TREE_OPERAND (size, 1))
-		       ? last_size : merge_sizes (last_size, first_bit,
-						  TREE_OPERAND (size, 1),
-						  1, has_rep),
-		       integer_zerop (TREE_OPERAND (size, 2))
-		       ? last_size : merge_sizes (last_size, first_bit,
-						  TREE_OPERAND (size, 2),
-						  1, has_rep));
+    new_tree = fold_build3 (COND_EXPR, type, TREE_OPERAND (size, 0),
+		            integer_zerop (TREE_OPERAND (size, 1))
+		            ? last_size : merge_sizes (last_size, first_bit,
+		     				  TREE_OPERAND (size, 1),
+		     				  1, has_rep),
+		            integer_zerop (TREE_OPERAND (size, 2))
+		            ? last_size : merge_sizes (last_size, first_bit,
+		     				  TREE_OPERAND (size, 2),
+		     				  1, has_rep));
 
   /* We don't need any NON_VALUE_EXPRs and they can confuse us (especially
      when fed through substitute_in_expr) into thinking that a constant
      size is not constant.  */
-  while (TREE_CODE (new) == NON_LVALUE_EXPR)
-    new = TREE_OPERAND (new, 0);
+  while (TREE_CODE (new_tree) == NON_LVALUE_EXPR)
+    new_tree = TREE_OPERAND (new_tree, 0);
 
-  return new;
+  return new_tree;
 }
 
 /* Utility function of above to see if OP0 and OP1, both of SIZETYPE, are
@@ -1160,18 +1160,18 @@
 tree
 copy_type (tree type)
 {
-  tree new = copy_node (type);
+  tree new_tree = copy_node (type);
 
   /* copy_node clears this field instead of copying it, because it is
      aliased with TREE_CHAIN.  */
-  TYPE_STUB_DECL (new) = TYPE_STUB_DECL (type);
+  TYPE_STUB_DECL (new_tree) = TYPE_STUB_DECL (type);
 
-  TYPE_POINTER_TO (new) = 0;
-  TYPE_REFERENCE_TO (new) = 0;
-  TYPE_MAIN_VARIANT (new) = new;
-  TYPE_NEXT_VARIANT (new) = 0;
+  TYPE_POINTER_TO (new_tree) = 0;
+  TYPE_REFERENCE_TO (new_tree) = 0;
+  TYPE_MAIN_VARIANT (new_tree) = new_tree;
+  TYPE_NEXT_VARIANT (new_tree) = 0;
 
-  return new;
+  return new_tree;
 }
 \f
 /* Return a subtype of sizetype with range MIN to MAX and whose
@@ -2512,7 +2512,7 @@
   tree record_type = make_node (RECORD_TYPE);
   tree pointer32_type;
   tree field_list = 0;
-  int class;
+  int class_i;
   int dtype = 0;
   tree inner_type;
   int ndim;
@@ -2624,22 +2624,22 @@
     {
     case By_Descriptor_A:
     case By_Short_Descriptor_A:
-      class = 4;
+      class_i = 4;
       break;
     case By_Descriptor_NCA:
     case By_Short_Descriptor_NCA:
-      class = 10;
+      class_i = 10;
       break;
     case By_Descriptor_SB:
     case By_Short_Descriptor_SB:
-      class = 15;
+      class_i = 15;
       break;
     case By_Descriptor:
     case By_Short_Descriptor:
     case By_Descriptor_S:
     case By_Short_Descriptor_S:
     default:
-      class = 1;
+      class_i = 1;
       break;
     }
 
@@ -2661,7 +2661,7 @@
   field_list = chainon (field_list,
 			make_descriptor_field ("CLASS",
 					       gnat_type_for_size (8, 1),
-					       record_type, size_int (class)));
+					       record_type, size_int (class_i)));
 
   /* Of course this will crash at run-time if the address space is not
      within the low 32 bits, but there is nothing else we can do.  */
@@ -2827,7 +2827,7 @@
   tree record64_type = make_node (RECORD_TYPE);
   tree pointer64_type;
   tree field_list64 = 0;
-  int class;
+  int class_i;
   int dtype = 0;
   tree inner_type;
   int ndim;
@@ -2938,18 +2938,18 @@
   switch (mech)
     {
     case By_Descriptor_A:
-      class = 4;
+      class_i = 4;
       break;
     case By_Descriptor_NCA:
-      class = 10;
+      class_i = 10;
       break;
     case By_Descriptor_SB:
-      class = 15;
+      class_i = 15;
       break;
     case By_Descriptor:
     case By_Descriptor_S:
     default:
-      class = 1;
+      class_i = 1;
       break;
     }
 
@@ -2968,7 +2968,7 @@
   field_list64 = chainon (field_list64,
 			make_descriptor_field ("CLASS",
 					       gnat_type_for_size (8, 1),
-					       record64_type, size_int (class)));
+					       record64_type, size_int (class_i)));
 
   field_list64 = chainon (field_list64,
 			make_descriptor_field ("MBMO",
@@ -3151,9 +3151,9 @@
   tree desc_type = TREE_TYPE (TREE_TYPE (gnu_expr));
   tree desc = build1 (INDIRECT_REF, desc_type, gnu_expr);
   /* The CLASS field is the 3rd field in the descriptor.  */
-  tree class = TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (desc_type)));
+  tree class_tree = TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (desc_type)));
   /* The POINTER field is the 6th field in the descriptor.  */
-  tree pointer64 = TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (class)));
+  tree pointer64 = TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (class_tree)));
 
   /* Retrieve the value of the POINTER field.  */
   tree gnu_expr64
@@ -3169,9 +3169,9 @@
       tree template_type = TREE_TYPE (p_bounds_type);
       tree min_field = TYPE_FIELDS (template_type);
       tree max_field = TREE_CHAIN (TYPE_FIELDS (template_type));
-      tree template, template_addr, aflags, dimct, t, u;
+      tree template_tree, template_addr, aflags, dimct, t, u;
       /* See the head comment of build_vms_descriptor.  */
-      int iclass = TREE_INT_CST_LOW (DECL_INITIAL (class));
+      int iclass = TREE_INT_CST_LOW (DECL_INITIAL (class_tree));
       tree lfield, ufield;
 
       /* Convert POINTER to the type of the P_ARRAY field.  */
@@ -3182,23 +3182,23 @@
 	case 1:  /* Class S  */
 	case 15: /* Class SB */
 	  /* Build {1, LENGTH} template; LENGTH64 is the 5th field.  */
-	  t = TREE_CHAIN (TREE_CHAIN (class));
+	  t = TREE_CHAIN (TREE_CHAIN (class_tree));
 	  t = build3 (COMPONENT_REF, TREE_TYPE (t), desc, t, NULL_TREE);
 	  t = tree_cons (min_field,
 			 convert (TREE_TYPE (min_field), integer_one_node),
 			 tree_cons (max_field,
 				    convert (TREE_TYPE (max_field), t),
 				    NULL_TREE));
-	  template = gnat_build_constructor (template_type, t);
-	  template_addr = build_unary_op (ADDR_EXPR, NULL_TREE, template);
+	  template_tree = gnat_build_constructor (template_type, t);
+	  template_addr = build_unary_op (ADDR_EXPR, NULL_TREE, template_tree);
 
 	  /* For class S, we are done.  */
 	  if (iclass == 1)
 	    break;
 
 	  /* Test that we really have a SB descriptor, like DEC Ada.  */
-	  t = build3 (COMPONENT_REF, TREE_TYPE (class), desc, class, NULL);
-	  u = convert (TREE_TYPE (class), DECL_INITIAL (class));
+	  t = build3 (COMPONENT_REF, TREE_TYPE (class_tree), desc, class_tree, NULL);
+	  u = convert (TREE_TYPE (class_tree), DECL_INITIAL (class_tree));
 	  u = build_binary_op (EQ_EXPR, integer_type_node, t, u);
 	  /* If so, there is already a template in the descriptor and
 	     it is located right after the POINTER field.  The fields are
@@ -3216,12 +3216,12 @@
 	  t = tree_cons (TYPE_FIELDS (template_type), lfield,
 			 tree_cons (TREE_CHAIN (TYPE_FIELDS (template_type)),
                                     ufield, NULL_TREE));
-	  template = gnat_build_constructor (template_type, t);
+	  template_tree = gnat_build_constructor (template_type, t);
 
 	  /* Otherwise use the {1, LENGTH} template we build above.  */
 	  template_addr = build3 (COND_EXPR, p_bounds_type, u,
 				  build_unary_op (ADDR_EXPR, p_bounds_type,
-				 		 template),
+				 		 template_tree),
 				  template_addr);
 	  break;
 
@@ -3263,12 +3263,12 @@
 	  t = tree_cons (TYPE_FIELDS (template_type), lfield,
 			 tree_cons (TREE_CHAIN (TYPE_FIELDS (template_type)),
                                     ufield, NULL_TREE));
-	  template = gnat_build_constructor (template_type, t);
-	  template = build3 (COND_EXPR, p_bounds_type, u,
+	  template_tree = gnat_build_constructor (template_type, t);
+	  template_tree = build3 (COND_EXPR, p_bounds_type, u,
 			    build_call_raise (CE_Length_Check_Failed, Empty,
 					      N_Raise_Constraint_Error),
-			    template);
-	  template_addr = build_unary_op (ADDR_EXPR, p_bounds_type, template);
+			    template_tree);
+	  template_addr = build_unary_op (ADDR_EXPR, p_bounds_type, template_tree);
 	  break;
 
 	case 10: /* Class NCA */
@@ -3299,9 +3299,9 @@
   tree desc_type = TREE_TYPE (TREE_TYPE (gnu_expr));
   tree desc = build1 (INDIRECT_REF, desc_type, gnu_expr);
   /* The CLASS field is the 3rd field in the descriptor.  */
-  tree class = TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (desc_type)));
+  tree class_tree = TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (desc_type)));
   /* The POINTER field is the 4th field in the descriptor.  */
-  tree pointer = TREE_CHAIN (class);
+  tree pointer = TREE_CHAIN (class_tree);
 
   /* Retrieve the value of the POINTER field.  */
   tree gnu_expr32
@@ -3317,9 +3317,9 @@
       tree template_type = TREE_TYPE (p_bounds_type);
       tree min_field = TYPE_FIELDS (template_type);
       tree max_field = TREE_CHAIN (TYPE_FIELDS (template_type));
-      tree template, template_addr, aflags, dimct, t, u;
+      tree template_tree, template_addr, aflags, dimct, t, u;
       /* See the head comment of build_vms_descriptor.  */
-      int iclass = TREE_INT_CST_LOW (DECL_INITIAL (class));
+      int iclass = TREE_INT_CST_LOW (DECL_INITIAL (class_tree));
 
       /* Convert POINTER to the type of the P_ARRAY field.  */
       gnu_expr32 = convert (p_array_type, gnu_expr32);
@@ -3336,25 +3336,25 @@
 			 tree_cons (max_field,
 				    convert (TREE_TYPE (max_field), t),
 				    NULL_TREE));
-	  template = gnat_build_constructor (template_type, t);
-	  template_addr = build_unary_op (ADDR_EXPR, NULL_TREE, template);
+	  template_tree = gnat_build_constructor (template_type, t);
+	  template_addr = build_unary_op (ADDR_EXPR, NULL_TREE, template_tree);
 
 	  /* For class S, we are done.  */
 	  if (iclass == 1)
 	    break;
 
 	  /* Test that we really have a SB descriptor, like DEC Ada.  */
-	  t = build3 (COMPONENT_REF, TREE_TYPE (class), desc, class, NULL);
-	  u = convert (TREE_TYPE (class), DECL_INITIAL (class));
+	  t = build3 (COMPONENT_REF, TREE_TYPE (class_tree), desc, class_tree, NULL);
+	  u = convert (TREE_TYPE (class_tree), DECL_INITIAL (class_tree));
 	  u = build_binary_op (EQ_EXPR, integer_type_node, t, u);
 	  /* If so, there is already a template in the descriptor and
 	     it is located right after the POINTER field.  */
 	  t = TREE_CHAIN (pointer);
-	  template = build3 (COMPONENT_REF, TREE_TYPE (t), desc, t, NULL_TREE);
+	  template_tree = build3 (COMPONENT_REF, TREE_TYPE (t), desc, t, NULL_TREE);
 	  /* Otherwise use the {1, LENGTH} template we build above.  */
 	  template_addr = build3 (COND_EXPR, p_bounds_type, u,
 				  build_unary_op (ADDR_EXPR, p_bounds_type,
-				 		 template),
+				 		 template_tree),
 				  template_addr);
 	  break;
 
@@ -3381,12 +3381,12 @@
 	  /* There is already a template in the descriptor and it is
 	     located at the start of block 3 (12th field).  */
 	  t = TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (t))));
-	  template = build3 (COMPONENT_REF, TREE_TYPE (t), desc, t, NULL_TREE);
-	  template = build3 (COND_EXPR, p_bounds_type, u,
+	  template_tree = build3 (COMPONENT_REF, TREE_TYPE (t), desc, t, NULL_TREE);
+	  template_tree = build3 (COND_EXPR, p_bounds_type, u,
 			    build_call_raise (CE_Length_Check_Failed, Empty,
 					      N_Raise_Constraint_Error),
-			    template);
-	  template_addr = build_unary_op (ADDR_EXPR, p_bounds_type, template);
+			    template_tree);
+	  template_addr = build_unary_op (ADDR_EXPR, p_bounds_type, template_tree);
 	  break;
 
 	case 10: /* Class NCA */
@@ -3717,7 +3717,7 @@
   tree template_type = TREE_TYPE (TREE_TYPE (TREE_CHAIN (TYPE_FIELDS (type))));
   tree p_array_type = TREE_TYPE (TYPE_FIELDS (type));
   tree etype = TREE_TYPE (expr);
-  tree template;
+  tree template_tree;
 
   /* If EXPR is null, make a fat pointer that contains null pointers to the
      template and array.  */
@@ -3743,7 +3743,7 @@
       else
 	expr = build1 (INDIRECT_REF, TREE_TYPE (etype), expr);
 
-      template = build_component_ref (expr, NULL_TREE, fields, false);
+      template_tree = build_component_ref (expr, NULL_TREE, fields, false);
       expr = build_unary_op (ADDR_EXPR, NULL_TREE,
 			     build_component_ref (expr, NULL_TREE,
 						  TREE_CHAIN (fields), false));
@@ -3751,7 +3751,7 @@
 
   /* Otherwise, build the constructor for the template.  */
   else
-    template = build_template (template_type, TREE_TYPE (etype), expr);
+    template_tree = build_template (template_type, TREE_TYPE (etype), expr);
 
   /* The final result is a constructor for the fat pointer.
 
@@ -3771,7 +3771,7 @@
        tree_cons (TYPE_FIELDS (type),
 		  convert (p_array_type, expr),
 		  tree_cons (TREE_CHAIN (TYPE_FIELDS (type)),
-			     build_unary_op (ADDR_EXPR, NULL_TREE, template),
+			     build_unary_op (ADDR_EXPR, NULL_TREE, template_tree),
 			     NULL_TREE)));
 }
 \f
@@ -4301,20 +4301,20 @@
 maybe_unconstrained_array (tree exp)
 {
   enum tree_code code = TREE_CODE (exp);
-  tree new;
+  tree new_tree;
 
   switch (TREE_CODE (TREE_TYPE (exp)))
     {
     case UNCONSTRAINED_ARRAY_TYPE:
       if (code == UNCONSTRAINED_ARRAY_REF)
 	{
-	  new
+	  new_tree
 	    = build_unary_op (INDIRECT_REF, NULL_TREE,
 			      build_component_ref (TREE_OPERAND (exp, 0),
 						   get_identifier ("P_ARRAY"),
 						   NULL_TREE, false));
-	  TREE_READONLY (new) = TREE_STATIC (new) = TREE_READONLY (exp);
-	  return new;
+	  TREE_READONLY (new_tree) = TREE_STATIC (new_tree) = TREE_READONLY (exp);
+	  return new_tree;
 	}
 
       else if (code == NULL_EXPR)
@@ -4328,12 +4328,12 @@
 	 it contains a template.  */
       if (TYPE_IS_PADDING_P (TREE_TYPE (exp)))
 	{
-	  new = convert (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (exp))), exp);
-	  if (TREE_CODE (TREE_TYPE (new)) == RECORD_TYPE
-	      && TYPE_CONTAINS_TEMPLATE_P (TREE_TYPE (new)))
+	  new_tree = convert (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (exp))), exp);
+	  if (TREE_CODE (TREE_TYPE (new_tree)) == RECORD_TYPE
+	      && TYPE_CONTAINS_TEMPLATE_P (TREE_TYPE (new_tree)))
 	    return
-	      build_component_ref (new, NULL_TREE,
-				   TREE_CHAIN (TYPE_FIELDS (TREE_TYPE (new))),
+	      build_component_ref (new_tree, NULL_TREE,
+				   TREE_CHAIN (TYPE_FIELDS (TREE_TYPE (new_tree))),
 				   0);
 	}
       else if (TYPE_CONTAINS_TEMPLATE_P (TREE_TYPE (exp)))
Index: gcc/ada/gcc-interface/decl.c
===================================================================
--- gcc/ada/gcc-interface/decl.c	(revision 148953)
+++ gcc/ada/gcc-interface/decl.c	(working copy)
@@ -7788,7 +7788,7 @@
 tree
 substitute_in_type (tree t, tree f, tree r)
 {
-  tree new;
+  tree new_tree;
 
   gcc_assert (CONTAINS_PLACEHOLDER_P (r));
 
@@ -7809,15 +7809,15 @@
 	  if (low == TYPE_GCC_MIN_VALUE (t) && high == TYPE_GCC_MAX_VALUE (t))
 	    return t;
 
-	  new = copy_type (t);
-	  TYPE_GCC_MIN_VALUE (new) = low;
-	  TYPE_GCC_MAX_VALUE (new) = high;
+	  new_tree = copy_type (t);
+	  TYPE_GCC_MIN_VALUE (new_tree) = low;
+	  TYPE_GCC_MAX_VALUE (new_tree) = high;
 
 	  if (TREE_CODE (t) == INTEGER_TYPE && TYPE_INDEX_TYPE (t))
 	    SET_TYPE_INDEX_TYPE
-	      (new, substitute_in_type (TYPE_INDEX_TYPE (t), f, r));
+	      (new_tree, substitute_in_type (TYPE_INDEX_TYPE (t), f, r));
 
-	  return new;
+	  return new_tree;
 	}
 
       /* Then the subtypes.  */
@@ -7830,21 +7830,21 @@
 	  if (low == TYPE_RM_MIN_VALUE (t) && high == TYPE_RM_MAX_VALUE (t))
 	    return t;
 
-	  new = copy_type (t);
-	  SET_TYPE_RM_MIN_VALUE (new, low);
-	  SET_TYPE_RM_MAX_VALUE (new, high);
+	  new_tree = copy_type (t);
+	  SET_TYPE_RM_MIN_VALUE (new_tree, low);
+	  SET_TYPE_RM_MAX_VALUE (new_tree, high);
 
-	  return new;
+	  return new_tree;
 	}
 
       return t;
 
     case COMPLEX_TYPE:
-      new = substitute_in_type (TREE_TYPE (t), f, r);
-      if (new == TREE_TYPE (t))
+      new_tree = substitute_in_type (TREE_TYPE (t), f, r);
+      if (new_tree == TREE_TYPE (t))
 	return t;
 
-      return build_complex_type (new);
+      return build_complex_type (new_tree);
 
     case OFFSET_TYPE:
     case METHOD_TYPE:
@@ -7861,16 +7861,16 @@
 	if (component == TREE_TYPE (t) && domain == TYPE_DOMAIN (t))
 	  return t;
 
-	new = build_array_type (component, domain);
-	TYPE_ALIGN (new) = TYPE_ALIGN (t);
-	TYPE_USER_ALIGN (new) = TYPE_USER_ALIGN (t);
-	SET_TYPE_MODE (new, TYPE_MODE (t));
-	TYPE_SIZE (new) = SUBSTITUTE_IN_EXPR (TYPE_SIZE (t), f, r);
-	TYPE_SIZE_UNIT (new) = SUBSTITUTE_IN_EXPR (TYPE_SIZE_UNIT (t), f, r);
-	TYPE_NONALIASED_COMPONENT (new) = TYPE_NONALIASED_COMPONENT (t);
-	TYPE_MULTI_ARRAY_P (new) = TYPE_MULTI_ARRAY_P (t);
-	TYPE_CONVENTION_FORTRAN_P (new) = TYPE_CONVENTION_FORTRAN_P (t);
-	return new;
+	new_tree = build_array_type (component, domain);
+	TYPE_ALIGN (new_tree) = TYPE_ALIGN (t);
+	TYPE_USER_ALIGN (new_tree) = TYPE_USER_ALIGN (t);
+	SET_TYPE_MODE (new_tree, TYPE_MODE (t));
+	TYPE_SIZE (new_tree) = SUBSTITUTE_IN_EXPR (TYPE_SIZE (t), f, r);
+	TYPE_SIZE_UNIT (new_tree) = SUBSTITUTE_IN_EXPR (TYPE_SIZE_UNIT (t), f, r);
+	TYPE_NONALIASED_COMPONENT (new_tree) = TYPE_NONALIASED_COMPONENT (t);
+	TYPE_MULTI_ARRAY_P (new_tree) = TYPE_MULTI_ARRAY_P (t);
+	TYPE_CONVENTION_FORTRAN_P (new_tree) = TYPE_CONVENTION_FORTRAN_P (t);
+	return new_tree;
       }
 
     case RECORD_TYPE:
@@ -7883,8 +7883,8 @@
 	/* Start out with no fields, make new fields, and chain them
 	   in.  If we haven't actually changed the type of any field,
 	   discard everything we've done and return the old type.  */
-	new = copy_type (t);
-	TYPE_FIELDS (new) = NULL_TREE;
+	new_tree = copy_type (t);
+	TYPE_FIELDS (new_tree) = NULL_TREE;
 
 	for (field = TYPE_FIELDS (t); field; field = TREE_CHAIN (field))
 	  {
@@ -7915,23 +7915,23 @@
 		  }
 	      }
 
-	    DECL_CONTEXT (new_field) = new;
+	    DECL_CONTEXT (new_field) = new_tree;
 	    SET_DECL_ORIGINAL_FIELD (new_field,
 				     (DECL_ORIGINAL_FIELD (field)
 				      ? DECL_ORIGINAL_FIELD (field) : field));
 
-	    TREE_CHAIN (new_field) = TYPE_FIELDS (new);
-	    TYPE_FIELDS (new) = new_field;
+	    TREE_CHAIN (new_field) = TYPE_FIELDS (new_tree);
+	    TYPE_FIELDS (new_tree) = new_field;
 	  }
 
 	if (!changed_field)
 	  return t;
 
-	TYPE_FIELDS (new) = nreverse (TYPE_FIELDS (new));
-	TYPE_SIZE (new) = SUBSTITUTE_IN_EXPR (TYPE_SIZE (t), f, r);
-	TYPE_SIZE_UNIT (new) = SUBSTITUTE_IN_EXPR (TYPE_SIZE_UNIT (t), f, r);
-	SET_TYPE_ADA_SIZE (new, SUBSTITUTE_IN_EXPR (TYPE_ADA_SIZE (t), f, r));
-	return new;
+	TYPE_FIELDS (new_tree) = nreverse (TYPE_FIELDS (new_tree));
+	TYPE_SIZE (new_tree) = SUBSTITUTE_IN_EXPR (TYPE_SIZE (t), f, r);
+	TYPE_SIZE_UNIT (new_tree) = SUBSTITUTE_IN_EXPR (TYPE_SIZE_UNIT (t), f, r);
+	SET_TYPE_ADA_SIZE (new_tree, SUBSTITUTE_IN_EXPR (TYPE_ADA_SIZE (t), f, r));
+	return new_tree;
       }
 
     default:
Index: gcc/ada/gcc-interface/trans.c
===================================================================
--- gcc/ada/gcc-interface/trans.c	(revision 148953)
+++ gcc/ada/gcc-interface/trans.c	(working copy)
@@ -100,7 +100,7 @@
 /* When not optimizing, we cache the 'First, 'Last and 'Length attributes
    of unconstrained array IN parameters to avoid emitting a great deal of
    redundant instructions to recompute them each time.  */
-struct GTY (()) parm_attr {
+struct GTY (()) parm_attr_d {
   int id; /* GTY doesn't like Entity_Id.  */
   int dim;
   tree first;
@@ -108,7 +108,7 @@
   tree length;
 };
 
-typedef struct parm_attr *parm_attr;
+typedef struct parm_attr_d *parm_attr;
 
 DEF_VEC_P(parm_attr);
 DEF_VEC_ALLOC_P(parm_attr,gc);
@@ -1464,7 +1464,7 @@
 	int Dimension = (Present (Expressions (gnat_node))
 			 ? UI_To_Int (Intval (First (Expressions (gnat_node))))
 			 : 1), i;
-	struct parm_attr *pa = NULL;
+	struct parm_attr_d *pa = NULL;
 	Entity_Id gnat_param = Empty;
 
 	/* Make sure any implicit dereference gets done.  */
@@ -1508,7 +1508,7 @@
 
 	    if (!pa)
 	      {
-		pa = GGC_CNEW (struct parm_attr);
+		pa = GGC_CNEW (struct parm_attr_d);
 		pa->id = gnat_param;
 		pa->dim = Dimension;
 		VEC_safe_push (parm_attr, gc, f_parm_attr_cache, pa);
@@ -2273,7 +2273,7 @@
   cache = DECL_STRUCT_FUNCTION (gnu_subprog_decl)->language->parm_attr_cache;
   if (cache)
     {
-      struct parm_attr *pa;
+      struct parm_attr_d *pa;
       int i;
 
       start_stmt_group ();
Index: gcc/ada/gcc-interface/misc.c
===================================================================
--- gcc/ada/gcc-interface/misc.c	(revision 148953)
+++ gcc/ada/gcc-interface/misc.c	(working copy)
@@ -729,10 +729,11 @@
 void
 enumerate_modes (void (*f) (int, int, int, int, int, int, unsigned int))
 {
-  enum machine_mode i;
+  int iloop;
 
-  for (i = 0; i < NUM_MACHINE_MODES; i++)
+  for (iloop = 0; iloop < NUM_MACHINE_MODES; iloop++)
     {
+      enum machine_mode i = (enum machine_mode) iloop;
       enum machine_mode j;
       bool float_p = 0;
       bool complex_p = 0;

[-- Attachment #3: b.log.gz --]
[-- Type: application/x-gzip, Size: 34874 bytes --]

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete (Ada)
  2009-06-26 15:59           ` Laurent GUERBY
@ 2009-06-26 17:32             ` Ian Lance Taylor
  2009-06-26 17:36               ` Arnaud Charlet
  2009-06-26 17:38               ` Robert Dewar
  0 siblings, 2 replies; 43+ messages in thread
From: Ian Lance Taylor @ 2009-06-26 17:32 UTC (permalink / raw)
  To: laurent; +Cc: Arnaud Charlet, Eric Botcazou, Richard Guenther, gcc

Laurent GUERBY <laurent@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

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete (Ada)
  2009-06-26 17:32             ` Ian Lance Taylor
@ 2009-06-26 17:36               ` Arnaud Charlet
  2009-06-26 17:38               ` Robert Dewar
  1 sibling, 0 replies; 43+ messages in thread
From: Arnaud Charlet @ 2009-06-26 17:36 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: laurent, Eric Botcazou, Richard Guenther, gcc

> 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

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete (Ada)
  2009-06-26 17:32             ` Ian Lance Taylor
  2009-06-26 17:36               ` Arnaud Charlet
@ 2009-06-26 17:38               ` Robert Dewar
  2009-06-26 17:59                 ` Arnaud Charlet
  2009-06-26 18:07                 ` Ian Lance Taylor
  1 sibling, 2 replies; 43+ messages in thread
From: Robert Dewar @ 2009-06-26 17:38 UTC (permalink / raw)
  To: Ian Lance Taylor
  Cc: laurent, Arnaud Charlet, Eric Botcazou, Richard Guenther, gcc

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.

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete (Ada)
  2009-06-26 17:38               ` Robert Dewar
@ 2009-06-26 17:59                 ` Arnaud Charlet
  2009-06-26 18:07                 ` Ian Lance Taylor
  1 sibling, 0 replies; 43+ messages in thread
From: Arnaud Charlet @ 2009-06-26 17:59 UTC (permalink / raw)
  To: Robert Dewar
  Cc: Ian Lance Taylor, laurent, Eric Botcazou, Richard Guenther, gcc

> 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

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete (Ada)
  2009-06-26 17:38               ` Robert Dewar
  2009-06-26 17:59                 ` Arnaud Charlet
@ 2009-06-26 18:07                 ` Ian Lance Taylor
  2009-06-26 18:18                   ` Robert Dewar
  1 sibling, 1 reply; 43+ messages in thread
From: Ian Lance Taylor @ 2009-06-26 18:07 UTC (permalink / raw)
  To: Robert Dewar
  Cc: laurent, Arnaud Charlet, Eric Botcazou, Richard Guenther, gcc

Robert Dewar <dewar@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

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete (Ada)
  2009-06-26 18:07                 ` Ian Lance Taylor
@ 2009-06-26 18:18                   ` Robert Dewar
  2009-06-26 19:24                     ` Laurent GUERBY
  0 siblings, 1 reply; 43+ messages in thread
From: Robert Dewar @ 2009-06-26 18:18 UTC (permalink / raw)
  To: Ian Lance Taylor
  Cc: laurent, Arnaud Charlet, Eric Botcazou, Richard Guenther, gcc

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

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete
  2009-06-25 20:33 Phase 1 of gcc-in-cxx now complete Ian Lance Taylor
                   ` (2 preceding siblings ...)
  2009-06-25 22:29 ` Phase 1 of gcc-in-cxx now complete Joseph S. Myers
@ 2009-06-26 18:21 ` Adam Nemet
  2009-06-27 16:51 ` Adam Nemet
  2009-06-27 18:07 ` David Edelsohn
  5 siblings, 0 replies; 43+ messages in thread
From: Adam Nemet @ 2009-06-26 18:21 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc

Ian Lance Taylor <iant@google.com> writes:
> 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.

With GMP 4.2.1 build fails like this:

g++ -mabi=n32 -c  -g -DIN_GCC   -W -Wall -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fno-common  -DHAVE_CONFIG_H -I. -I. -I../../src/gcc -I../../src/gcc/. -I../../src/gcc/../include -I../../src/gcc/../libcpp/include  -I../../src/gcc/../libdecnumber -I../../src/gcc/../libdecnumber/dpd -I../libdecnumber
../../src/gcc/c-lang.c -o c-lang.o
In file included from ../../src/gcc/double-int.h:24,
                 from ../../src/gcc/tree.h:30,
                 from ../../src/gcc/c-lang.c:27:
//usr/include/gmp.h:515: error: 'std::FILE' has not been declared
make[3]: *** [c-lang.o] Error 1
make[3]: Leaving directory `/mnt/src/gcc-tmp/mips64octeon-linux/gcc'
make[2]: *** [all-stage1-gcc] Error 2
make[2]: Leaving directory `/mnt/src/gcc-tmp/mips64octeon-linux'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/mnt/src/gcc-tmp/mips64octeon-linux'
make: *** [all] Error 2

We need at least GMP 4.2.3 with --enable-build-with-cxx:

From <http://gmplib.org/gmp4.2.html>:

Changes in GMP 4.2.3
Bugs:

    ...
    * For C++, gmp.h now includes cstdio, improving compiler
    compatibility. 
    ...

Adam

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete (Ada)
  2009-06-26 18:18                   ` Robert Dewar
@ 2009-06-26 19:24                     ` Laurent GUERBY
  2009-06-26 19:24                       ` Arnaud Charlet
  0 siblings, 1 reply; 43+ messages in thread
From: Laurent GUERBY @ 2009-06-26 19:24 UTC (permalink / raw)
  To: Robert Dewar
  Cc: Ian Lance Taylor, Arnaud Charlet, Eric Botcazou, Richard Guenther, gcc

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



^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete (Ada)
  2009-06-26 19:24                     ` Laurent GUERBY
@ 2009-06-26 19:24                       ` Arnaud Charlet
  2009-06-26 23:53                         ` Ian Lance Taylor
  0 siblings, 1 reply; 43+ messages in thread
From: Arnaud Charlet @ 2009-06-26 19:24 UTC (permalink / raw)
  To: Laurent GUERBY
  Cc: Robert Dewar, Ian Lance Taylor, Eric Botcazou, Richard Guenther, gcc

> 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

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete (Ada)
  2009-06-26 19:24                       ` Arnaud Charlet
@ 2009-06-26 23:53                         ` Ian Lance Taylor
  2009-06-27 11:24                           ` Laurent GUERBY
  0 siblings, 1 reply; 43+ messages in thread
From: Ian Lance Taylor @ 2009-06-26 23:53 UTC (permalink / raw)
  To: Arnaud Charlet
  Cc: Laurent GUERBY, Robert Dewar, Eric Botcazou, Richard Guenther, gcc

Arnaud Charlet <charlet@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

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete (Ada)
  2009-06-25 22:38     ` Ian Lance Taylor
  2009-06-26 11:20       ` Laurent GUERBY
@ 2009-06-27 10:55       ` Eric Botcazou
  1 sibling, 0 replies; 43+ messages in thread
From: Eric Botcazou @ 2009-06-27 10:55 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc, Richard Guenther, Laurent GUERBY

> 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

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete (Ada)
  2009-06-26 23:53                         ` Ian Lance Taylor
@ 2009-06-27 11:24                           ` Laurent GUERBY
  2009-06-27 11:54                             ` Eric Botcazou
  0 siblings, 1 reply; 43+ messages in thread
From: Laurent GUERBY @ 2009-06-27 11:24 UTC (permalink / raw)
  To: Ian Lance Taylor
  Cc: Arnaud Charlet, Robert Dewar, Eric Botcazou, Richard Guenther,
	gcc, Andrew Pinski

On Fri, 2009-06-26 at 12:52 -0700, Ian Lance Taylor wrote:
> Arnaud Charlet <charlet@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



^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete (Ada)
  2009-06-27 11:24                           ` Laurent GUERBY
@ 2009-06-27 11:54                             ` Eric Botcazou
  2009-06-27 12:53                               ` Laurent GUERBY
  0 siblings, 1 reply; 43+ messages in thread
From: Eric Botcazou @ 2009-06-27 11:54 UTC (permalink / raw)
  To: laurent
  Cc: Ian Lance Taylor, Arnaud Charlet, Robert Dewar, Richard Guenther,
	gcc, Andrew Pinski

> 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

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete (Ada)
  2009-06-27 11:54                             ` Eric Botcazou
@ 2009-06-27 12:53                               ` Laurent GUERBY
  2009-06-27 13:39                                 ` Laurent GUERBY
  2009-06-27 16:14                                 ` Paolo Bonzini
  0 siblings, 2 replies; 43+ messages in thread
From: Laurent GUERBY @ 2009-06-27 12:53 UTC (permalink / raw)
  To: Eric Botcazou
  Cc: Ian Lance Taylor, Arnaud Charlet, Robert Dewar, Richard Guenther,
	gcc, Andrew Pinski

[-- Attachment #1: Type: text/plain, Size: 403 bytes --]

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


[-- Attachment #2: patch-ada-gcc-in-cxx-ifdef.txt --]
[-- Type: text/plain, Size: 55246 bytes --]

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");
 
+   Put_Line (OutH, "#ifdef __cplusplus");
+   Put_Line (OutH, "extern ""C"" {");
+   Put_Line (OutH, "#endif");
+
    Anchored_Mode := True;
    Val := 0;
 
@@ -274,4 +278,8 @@
       Line := Get_Line (InH);
       Put_Line (OutH, Line);
    end loop;
+
+   Put_Line (OutH, "#ifdef __cplusplus");
+   Put_Line (OutH, "}");
+   Put_Line (OutH, "#endif");
 end XSnamesT;
Index: gcc/ada/errno.c
===================================================================
--- gcc/ada/errno.c	(revision 148953)
+++ gcc/ada/errno.c	(working copy)
@@ -36,6 +36,10 @@
 */
 
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define _REENTRANT
 #define _THREAD_SAFE
 #define _SGI_MP_SOURCE
@@ -64,3 +68,8 @@
 {
   errno = err;
 }
+
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/xsinfo.adb
===================================================================
--- gcc/ada/xsinfo.adb	(revision 148953)
+++ gcc/ada/xsinfo.adb	(working copy)
@@ -159,6 +159,11 @@
    end loop;
 
    Put_Line (Ofile, "");
+
+   Put_Line (Ofile, "#ifdef __cplusplus");
+   Put_Line (Ofile, "extern ""C"" {");
+   Put_Line (Ofile, "#endif");
+
    NKV := 0;
 
    --  Loop through node kind codes
@@ -242,6 +247,10 @@
 exception
    when Done =>
       Put_Line (Ofile, "");
+      Put_Line (Ofile, "#ifdef __cplusplus");
+      Put_Line (Ofile, "}");
+      Put_Line (Ofile, "#endif");
+
       Set_Exit_Status (0);
 
 end XSinfo;
Index: gcc/ada/nlists.h
===================================================================
--- gcc/ada/nlists.h	(revision 148953)
+++ gcc/ada/nlists.h	(working copy)
@@ -31,6 +31,11 @@
    Note that only routines for reading the tree are included, since the
    tree transformer is not supposed to modify the tree in any way. */
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*  The following is the structure used for the list headers table */
 
 struct List_Header
@@ -128,3 +133,8 @@
 {
   return Nodes_Ptr[Node - First_Node_Id].V.NX.link;
 }
+
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/aux-io.c
===================================================================
--- gcc/ada/aux-io.c	(revision 148953)
+++ gcc/ada/aux-io.c	(working copy)
@@ -29,6 +29,11 @@
  *                                                                          *
  ****************************************************************************/
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <stdio.h>
 
 #ifdef IN_RTS
@@ -96,3 +101,7 @@
 {
   return fileno (s);
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/initialize.c
===================================================================
--- gcc/ada/initialize.c	(revision 148953)
+++ gcc/ada/initialize.c	(working copy)
@@ -34,6 +34,11 @@
     in a separate file/object so that users can replace it easily.
     The default implementation should be null on most targets. */
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* The following include is here to meet the published VxWorks requirement
    that the __vxworks header appear before any other include. */
 #ifdef __vxworks
@@ -369,3 +374,8 @@
 }
 
 #endif
+
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/tb-alvms.c
===================================================================
--- gcc/ada/tb-alvms.c	(revision 148953)
+++ gcc/ada/tb-alvms.c	(working copy)
@@ -39,6 +39,10 @@
    Most of the contents is directed by the OpenVMS/Alpha Conventions (ABI)
    document, sections of which we will refer to as ABI-<section_number>.  */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <vms/pdscdef.h>
 #include <vms/libicb.h>
 #include <vms/chfctxdef.h>
@@ -394,3 +398,7 @@
 
   return cnt;
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/repinfo.h
===================================================================
--- gcc/ada/repinfo.h	(revision 148953)
+++ gcc/ada/repinfo.h	(working copy)
@@ -31,6 +31,11 @@
 
 /* This file corresponds to the Ada file repinfo.ads.  */
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef Uint Node_Ref;
 typedef Uint Node_Ref_Or_Val;
 typedef char TCode;
@@ -75,3 +80,8 @@
 #define Create_Node repinfo__create_node
 extern Node_Ref Create_Node	(TCode, Node_Ref_Or_Val,
 				 Node_Ref_Or_Val, Node_Ref_Or_Val);
+
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/vx_stack_info.c
===================================================================
--- gcc/ada/vx_stack_info.c	(revision 148953)
+++ gcc/ada/vx_stack_info.c	(working copy)
@@ -32,6 +32,10 @@
 /* VxWorks-specific file to have access to task-specific data and be able
    to extract the stack boundaries for stack checking. */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <taskLib.h>
 
 typedef struct
@@ -59,3 +63,7 @@
   vxworks_stack_info->base = descriptor.td_pStackBase;
   vxworks_stack_info->end  = descriptor.td_pStackEnd;
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/fe.h
===================================================================
--- gcc/ada/fe.h	(revision 148953)
+++ gcc/ada/fe.h	(working copy)
@@ -32,6 +32,11 @@
 /* This file contains definitions to access front-end functions and
    variables used by gigi.  */
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* comperr:  */
 
 #define Compiler_Abort comperr__compiler_abort
@@ -243,3 +248,8 @@
 extern Boolean Backend_Overflow_Checks_On_Target;
 extern Boolean Stack_Check_Probes_On_Target;
 extern Boolean Stack_Check_Limits_On_Target;
+
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/tb-ivms.c
===================================================================
--- gcc/ada/tb-ivms.c	(revision 148953)
+++ gcc/ada/tb-ivms.c	(working copy)
@@ -30,6 +30,10 @@
  *                                                                          *
  ****************************************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Itanium Open/VMS implementation of backtrace.  Use ICB (Invocation
    Context Block) routines.  */
 #include <stdlib.h>
@@ -87,3 +91,8 @@
   LIB$I64_FREE_INVO_CONTEXT (ctxt);
   return res;
 }
+
+#ifdef __cplusplus
+}
+#endif
+
Index: gcc/ada/mkdir.c
===================================================================
--- gcc/ada/mkdir.c	(revision 148953)
+++ gcc/ada/mkdir.c	(working copy)
@@ -29,6 +29,11 @@
  *                                                                          *
  ****************************************************************************/
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef __vxworks
 #include "vxWorks.h"
 #include <version.h>
@@ -71,3 +76,8 @@
   return mkdir (dir_name, S_IRWXU | S_IRWXG | S_IRWXO);
 #endif
 }
+
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/xsnames.adb
===================================================================
--- gcc/ada/xsnames.adb	(revision 148953)
+++ gcc/ada/xsnames.adb	(working copy)
@@ -163,6 +163,10 @@
    Create (OutB, Out_File, "snames.nb");
    Create (OutH, Out_File, "snames.nh");
 
+   Put_Line (OutH, "#ifdef __cplusplus");
+   Put_Line (OutH, "extern ""C"" {");
+   Put_Line (OutH, "#endif");
+
    Anchored_Mode := True;
    Val := 0;
 
@@ -241,4 +245,9 @@
       Line := Get_Line (InH);
       Put_Line (OutH, Line);
    end loop;
+
+   Put_Line (OutH, "#ifdef __cplusplus");
+   Put_Line (OutH, "}");
+   Put_Line (OutH, "#endif");
+
 end XSnames;
Index: gcc/ada/socket.c
===================================================================
--- gcc/ada/socket.c	(revision 148953)
+++ gcc/ada/socket.c	(working copy)
@@ -31,6 +31,12 @@
 
 /*  This file provides a portable binding to the sockets API                */
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
 #include "gsocket.h"
 #ifdef VMS
 /*
@@ -491,3 +497,8 @@
 #else
 # warning Sockets are not supported on this platform
 #endif /* defined(HAVE_SOCKETS) */
+
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/raise.c
===================================================================
--- gcc/ada/raise.c	(revision 148953)
+++ gcc/ada/raise.c	(working copy)
@@ -35,6 +35,10 @@
    __gnat_unhandled_terminate is code shared between all exception handling
    mechanisms */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef IN_RTS
 #include "tconfig.h"
 #include "tsystem.h"
@@ -76,3 +80,8 @@
   /* Default termination handling */
   __gnat_os_exit (1);
 }
+
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/tb-alvxw.c
===================================================================
--- gcc/ada/tb-alvxw.c	(revision 148953)
+++ gcc/ada/tb-alvxw.c	(working copy)
@@ -34,6 +34,10 @@
    from GDB. This file is #included within tracebak.c in the appropriate
    case.  */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <stddef.h>
 #include <stdlib.h>
 #include <limits.h>
@@ -939,3 +943,7 @@
 
   return cnt;
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/raise.h
===================================================================
--- gcc/ada/raise.h	(revision 148953)
+++ gcc/ada/raise.h	(working copy)
@@ -29,6 +29,9 @@
  *                                                                          *
  ****************************************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /* C counterparts of what System.Standard_Library defines.  */
 
@@ -71,3 +74,8 @@
 extern void __gnat_adjust_context_for_raise (int, void *);
 
 extern int gnat_exit_status;
+
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/xeinfo.adb
===================================================================
--- gcc/ada/xeinfo.adb	(revision 148953)
+++ gcc/ada/xeinfo.adb	(working copy)
@@ -269,6 +269,10 @@
 
    Put_Line (Ofile, "");
 
+   Put_Line (Ofile, "#ifdef __cplusplus");
+   Put_Line (Ofile, "extern ""C"" {");
+   Put_Line (Ofile, "#endif");
+
    --  Find and record pragma Inlines
 
    loop
@@ -483,6 +487,11 @@
    end loop;
 
    Put_Line (Ofile, "");
+
+   Put_Line (Ofile, "#ifdef __cplusplus");
+   Put_Line (Ofile, "}");
+   Put_Line (Ofile, "#endif");
+
    Put_Line
      (Ofile,
       "/* End of einfo.h (C version of Einfo package specification) */");
Index: gcc/ada/exit.c
===================================================================
--- gcc/ada/exit.c	(revision 148953)
+++ gcc/ada/exit.c	(working copy)
@@ -29,6 +29,11 @@
  *                                                                          *
  ****************************************************************************/
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef __alpha_vxworks
 #include "vxWorks.h"
 #endif
@@ -53,3 +58,8 @@
 {
   gnat_exit_status = i;
 }
+
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/arit64.c
===================================================================
--- gcc/ada/arit64.c	(revision 148953)
+++ gcc/ada/arit64.c	(working copy)
@@ -29,6 +29,11 @@
  *                                                                          *
  ****************************************************************************/
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 extern void __gnat_rcheck_10(char *file, int line)
   __attribute__ ((__noreturn__));
 
@@ -55,3 +60,7 @@
 
   return (long long int) (neg ? -low : low);
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/adaint.c
===================================================================
--- gcc/ada/adaint.c	(revision 148953)
+++ gcc/ada/adaint.c	(working copy)
@@ -34,6 +34,11 @@
    package Osint.  Many of the subprograms in OS_Lib import standard
    library calls directly. This file contains all other routines.  */
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef __vxworks
 
 /* No need to redefine exit here.  */
@@ -288,9 +293,9 @@
 /* This variable is used in hostparm.ads to say whether the host is a VMS
    system.  */
 #ifdef VMS
-const int __gnat_vmsp = 1;
+int __gnat_vmsp = 1;
 #else
-const int __gnat_vmsp = 0;
+int __gnat_vmsp = 0;
 #endif
 
 #ifdef __EMX__
@@ -3597,3 +3602,7 @@
    return (void *) syscall (__NR_gettid);
 }
 #endif
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/adaint.h
===================================================================
--- gcc/ada/adaint.h	(revision 148953)
+++ gcc/ada/adaint.h	(working copy)
@@ -29,6 +29,12 @@
  *                                                                          *
  ****************************************************************************/
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
 #include <sys/stat.h>
 #include <stdio.h>
 
@@ -194,3 +200,8 @@
 
 extern int    __gnat_binder_supports_auto_init     (void);
 extern int    __gnat_sals_init_using_constructors  (void);
+
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/ctrl_c.c
===================================================================
--- gcc/ada/ctrl_c.c	(revision 148953)
+++ gcc/ada/ctrl_c.c	(working copy)
@@ -29,6 +29,11 @@
  *                                                                          *
  ****************************************************************************/
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef IN_RTS
 #include "tconfig.h"
 #include "tsystem.h"
@@ -164,3 +169,8 @@
 {
 }
 #endif
+
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/cio.c
===================================================================
--- gcc/ada/cio.c	(revision 148953)
+++ gcc/ada/cio.c	(working copy)
@@ -29,6 +29,11 @@
  *                                                                          *
  ****************************************************************************/
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef IN_RTS
 #include "tconfig.h"
 #include "tsystem.h"
@@ -129,3 +134,8 @@
   return tmpnam (NULL);
 }
 #endif
+
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/raise-gcc.c
===================================================================
--- gcc/ada/raise-gcc.c	(revision 148953)
+++ gcc/ada/raise-gcc.c	(working copy)
@@ -32,6 +32,10 @@
 /* Code related to the integration of the GCC mechanism for exception
    handling.  */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef IN_RTS
 #include "tconfig.h"
 #include "tsystem.h"
@@ -1221,3 +1225,8 @@
 }
 
 #endif /* IN_RTS */
+
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/cstreams.c
===================================================================
--- gcc/ada/cstreams.c	(revision 148953)
+++ gcc/ada/cstreams.c	(working copy)
@@ -31,6 +31,11 @@
 
 /* Routines required for implementing routines in Interfaces.C.Streams */
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef __vxworks
 #include "vxWorks.h"
 #endif
@@ -254,3 +259,8 @@
 
   return buffer;
 }
+
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/cal.c
===================================================================
--- gcc/ada/cal.c	(revision 148953)
+++ gcc/ada/cal.c	(working copy)
@@ -35,6 +35,11 @@
 /*  struct timeval fields type are not normalized (they are generally       */
 /*  defined as int or long values).                                         */
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #if defined(VMS) || defined(__nucleus__)
 
 /* this is temporary code to avoid build failure under VMS */
@@ -107,3 +112,8 @@
 {
   return time (0);
 }
+
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/uintp.h
===================================================================
--- gcc/ada/uintp.h	(revision 148953)
+++ gcc/ada/uintp.h	(working copy)
@@ -26,6 +26,11 @@
 /* This file corresponds to the Ada package specification Uintp. It was
    created manually from the files uintp.ads and uintp.adb  */
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Support for universal integer arithmetic */
 
 struct Uint_Entry
@@ -78,3 +83,7 @@
 
 #define Uint_0 (Uint_Direct_Bias + 0)
 #define Uint_1 (Uint_Direct_Bias + 1)
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/tracebak.c
===================================================================
--- gcc/ada/tracebak.c	(revision 148953)
+++ gcc/ada/tracebak.c	(working copy)
@@ -46,6 +46,10 @@
    Alpha/VMS
 */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef __alpha_vxworks
 #include "vxWorks.h"
 #endif
@@ -507,3 +511,7 @@
 #endif
 
 #endif
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/urealp.h
===================================================================
--- gcc/ada/urealp.h	(revision 148953)
+++ gcc/ada/urealp.h	(working copy)
@@ -26,6 +26,11 @@
 /* This file corresponds to the Ada package specification Urealp. It was
    created manually from the files urealp.ads and urealp.adb  */
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Support for universal real arithmetic.  */
 
 #define Numerator urealp__numerator
@@ -48,3 +53,8 @@
 #define Machine eval_fat__machine
 extern Ureal Machine		(Entity_Id, Ureal, enum Rounding_Mode,
 				 Node_Id);
+
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/namet.h
===================================================================
--- gcc/ada/namet.h	(revision 148953)
+++ gcc/ada/namet.h	(working copy)
@@ -26,6 +26,11 @@
 /* This is the C file that corresponds to the Ada package specification
    Namet. It was created manually from files namet.ads and namet.adb.  */
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Structure defining a names table entry.  */
 
 struct Name_Entry
@@ -127,3 +132,8 @@
 extern Logical_Line_Number Get_Logical_Line_Number (Source_Ptr);
 extern Column_Number Get_Column_Number (Source_Ptr);
 extern Source_Ptr Instantiation (Source_File_Index);
+
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/tb-gcc.c
===================================================================
--- gcc/ada/tb-gcc.c	(revision 148953)
+++ gcc/ada/tb-gcc.c	(working copy)
@@ -35,6 +35,10 @@
    underlying GCC unwinding support associated with the exception handling
    infrastructure.  This will only work for ZCX based applications.  */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <unwind.h>
 
 /* The implementation boils down to a call to _Unwind_Backtrace with a
@@ -64,13 +68,13 @@
 static _Unwind_Reason_Code
 trace_callback (struct _Unwind_Context * uw_context, uw_data_t * uw_data)
 {
-  void * pc;
+  char * pc;
 
 #if defined (__ia64__) && defined (__hpux__)
   /* Work around problem with _Unwind_GetIP on ia64 HP-UX. */
   uwx_get_reg ((struct uwx_env *) uw_context, UWX_REG_IP, (uint64_t *) &pc);
 #else
-  pc = (void *) _Unwind_GetIP (uw_context);
+  pc = (char *) _Unwind_GetIP (uw_context);
 #endif
 
   if (uw_data->n_frames_skipped < uw_data->n_frames_to_skip)
@@ -123,3 +127,7 @@
   return uw_data.n_entries_filled;
 #endif
 }
+
+#ifdef __cplusplus
+}
+#endif
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),
-		       integer_zerop (TREE_OPERAND (size, 1))
-		       ? last_size : merge_sizes (last_size, first_bit,
-						  TREE_OPERAND (size, 1),
-						  1, has_rep),
-		       integer_zerop (TREE_OPERAND (size, 2))
-		       ? last_size : merge_sizes (last_size, first_bit,
-						  TREE_OPERAND (size, 2),
-						  1, has_rep));
+    new_tree = fold_build3 (COND_EXPR, type, TREE_OPERAND (size, 0),
+		            integer_zerop (TREE_OPERAND (size, 1))
+		            ? last_size : merge_sizes (last_size, first_bit,
+		     				  TREE_OPERAND (size, 1),
+		     				  1, has_rep),
+		            integer_zerop (TREE_OPERAND (size, 2))
+		            ? last_size : merge_sizes (last_size, first_bit,
+		     				  TREE_OPERAND (size, 2),
+		     				  1, has_rep));
 
   /* We don't need any NON_VALUE_EXPRs and they can confuse us (especially
      when fed through substitute_in_expr) into thinking that a constant
      size is not constant.  */
-  while (TREE_CODE (new) == NON_LVALUE_EXPR)
-    new = TREE_OPERAND (new, 0);
+  while (TREE_CODE (new_tree) == NON_LVALUE_EXPR)
+    new_tree = TREE_OPERAND (new_tree, 0);
 
-  return new;
+  return new_tree;
 }
 
 /* Utility function of above to see if OP0 and OP1, both of SIZETYPE, are
@@ -1160,18 +1160,18 @@
 tree
 copy_type (tree type)
 {
-  tree new = copy_node (type);
+  tree new_tree = copy_node (type);
 
   /* copy_node clears this field instead of copying it, because it is
      aliased with TREE_CHAIN.  */
-  TYPE_STUB_DECL (new) = TYPE_STUB_DECL (type);
+  TYPE_STUB_DECL (new_tree) = TYPE_STUB_DECL (type);
 
-  TYPE_POINTER_TO (new) = 0;
-  TYPE_REFERENCE_TO (new) = 0;
-  TYPE_MAIN_VARIANT (new) = new;
-  TYPE_NEXT_VARIANT (new) = 0;
+  TYPE_POINTER_TO (new_tree) = 0;
+  TYPE_REFERENCE_TO (new_tree) = 0;
+  TYPE_MAIN_VARIANT (new_tree) = new_tree;
+  TYPE_NEXT_VARIANT (new_tree) = 0;
 
-  return new;
+  return new_tree;
 }
 \f
 /* Return a subtype of sizetype with range MIN to MAX and whose
@@ -2512,7 +2512,7 @@
   tree record_type = make_node (RECORD_TYPE);
   tree pointer32_type;
   tree field_list = 0;
-  int class;
+  int class_i;
   int dtype = 0;
   tree inner_type;
   int ndim;
@@ -2624,22 +2624,22 @@
     {
     case By_Descriptor_A:
     case By_Short_Descriptor_A:
-      class = 4;
+      class_i = 4;
       break;
     case By_Descriptor_NCA:
     case By_Short_Descriptor_NCA:
-      class = 10;
+      class_i = 10;
       break;
     case By_Descriptor_SB:
     case By_Short_Descriptor_SB:
-      class = 15;
+      class_i = 15;
       break;
     case By_Descriptor:
     case By_Short_Descriptor:
     case By_Descriptor_S:
     case By_Short_Descriptor_S:
     default:
-      class = 1;
+      class_i = 1;
       break;
     }
 
@@ -2661,7 +2661,7 @@
   field_list = chainon (field_list,
 			make_descriptor_field ("CLASS",
 					       gnat_type_for_size (8, 1),
-					       record_type, size_int (class)));
+					       record_type, size_int (class_i)));
 
   /* Of course this will crash at run-time if the address space is not
      within the low 32 bits, but there is nothing else we can do.  */
@@ -2827,7 +2827,7 @@
   tree record64_type = make_node (RECORD_TYPE);
   tree pointer64_type;
   tree field_list64 = 0;
-  int class;
+  int class_i;
   int dtype = 0;
   tree inner_type;
   int ndim;
@@ -2938,18 +2938,18 @@
   switch (mech)
     {
     case By_Descriptor_A:
-      class = 4;
+      class_i = 4;
       break;
     case By_Descriptor_NCA:
-      class = 10;
+      class_i = 10;
       break;
     case By_Descriptor_SB:
-      class = 15;
+      class_i = 15;
       break;
     case By_Descriptor:
     case By_Descriptor_S:
     default:
-      class = 1;
+      class_i = 1;
       break;
     }
 
@@ -2968,7 +2968,7 @@
   field_list64 = chainon (field_list64,
 			make_descriptor_field ("CLASS",
 					       gnat_type_for_size (8, 1),
-					       record64_type, size_int (class)));
+					       record64_type, size_int (class_i)));
 
   field_list64 = chainon (field_list64,
 			make_descriptor_field ("MBMO",
@@ -3151,9 +3151,9 @@
   tree desc_type = TREE_TYPE (TREE_TYPE (gnu_expr));
   tree desc = build1 (INDIRECT_REF, desc_type, gnu_expr);
   /* The CLASS field is the 3rd field in the descriptor.  */
-  tree class = TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (desc_type)));
+  tree class_tree = TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (desc_type)));
   /* The POINTER field is the 6th field in the descriptor.  */
-  tree pointer64 = TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (class)));
+  tree pointer64 = TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (class_tree)));
 
   /* Retrieve the value of the POINTER field.  */
   tree gnu_expr64
@@ -3169,9 +3169,9 @@
       tree template_type = TREE_TYPE (p_bounds_type);
       tree min_field = TYPE_FIELDS (template_type);
       tree max_field = TREE_CHAIN (TYPE_FIELDS (template_type));
-      tree template, template_addr, aflags, dimct, t, u;
+      tree template_tree, template_addr, aflags, dimct, t, u;
       /* See the head comment of build_vms_descriptor.  */
-      int iclass = TREE_INT_CST_LOW (DECL_INITIAL (class));
+      int iclass = TREE_INT_CST_LOW (DECL_INITIAL (class_tree));
       tree lfield, ufield;
 
       /* Convert POINTER to the type of the P_ARRAY field.  */
@@ -3182,23 +3182,23 @@
 	case 1:  /* Class S  */
 	case 15: /* Class SB */
 	  /* Build {1, LENGTH} template; LENGTH64 is the 5th field.  */
-	  t = TREE_CHAIN (TREE_CHAIN (class));
+	  t = TREE_CHAIN (TREE_CHAIN (class_tree));
 	  t = build3 (COMPONENT_REF, TREE_TYPE (t), desc, t, NULL_TREE);
 	  t = tree_cons (min_field,
 			 convert (TREE_TYPE (min_field), integer_one_node),
 			 tree_cons (max_field,
 				    convert (TREE_TYPE (max_field), t),
 				    NULL_TREE));
-	  template = gnat_build_constructor (template_type, t);
-	  template_addr = build_unary_op (ADDR_EXPR, NULL_TREE, template);
+	  template_tree = gnat_build_constructor (template_type, t);
+	  template_addr = build_unary_op (ADDR_EXPR, NULL_TREE, template_tree);
 
 	  /* For class S, we are done.  */
 	  if (iclass == 1)
 	    break;
 
 	  /* Test that we really have a SB descriptor, like DEC Ada.  */
-	  t = build3 (COMPONENT_REF, TREE_TYPE (class), desc, class, NULL);
-	  u = convert (TREE_TYPE (class), DECL_INITIAL (class));
+	  t = build3 (COMPONENT_REF, TREE_TYPE (class_tree), desc, class_tree, NULL);
+	  u = convert (TREE_TYPE (class_tree), DECL_INITIAL (class_tree));
 	  u = build_binary_op (EQ_EXPR, integer_type_node, t, u);
 	  /* If so, there is already a template in the descriptor and
 	     it is located right after the POINTER field.  The fields are
@@ -3216,12 +3216,12 @@
 	  t = tree_cons (TYPE_FIELDS (template_type), lfield,
 			 tree_cons (TREE_CHAIN (TYPE_FIELDS (template_type)),
                                     ufield, NULL_TREE));
-	  template = gnat_build_constructor (template_type, t);
+	  template_tree = gnat_build_constructor (template_type, t);
 
 	  /* Otherwise use the {1, LENGTH} template we build above.  */
 	  template_addr = build3 (COND_EXPR, p_bounds_type, u,
 				  build_unary_op (ADDR_EXPR, p_bounds_type,
-				 		 template),
+				 		 template_tree),
 				  template_addr);
 	  break;
 
@@ -3263,12 +3263,12 @@
 	  t = tree_cons (TYPE_FIELDS (template_type), lfield,
 			 tree_cons (TREE_CHAIN (TYPE_FIELDS (template_type)),
                                     ufield, NULL_TREE));
-	  template = gnat_build_constructor (template_type, t);
-	  template = build3 (COND_EXPR, p_bounds_type, u,
+	  template_tree = gnat_build_constructor (template_type, t);
+	  template_tree = build3 (COND_EXPR, p_bounds_type, u,
 			    build_call_raise (CE_Length_Check_Failed, Empty,
 					      N_Raise_Constraint_Error),
-			    template);
-	  template_addr = build_unary_op (ADDR_EXPR, p_bounds_type, template);
+			    template_tree);
+	  template_addr = build_unary_op (ADDR_EXPR, p_bounds_type, template_tree);
 	  break;
 
 	case 10: /* Class NCA */
@@ -3299,9 +3299,9 @@
   tree desc_type = TREE_TYPE (TREE_TYPE (gnu_expr));
   tree desc = build1 (INDIRECT_REF, desc_type, gnu_expr);
   /* The CLASS field is the 3rd field in the descriptor.  */
-  tree class = TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (desc_type)));
+  tree class_tree = TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (desc_type)));
   /* The POINTER field is the 4th field in the descriptor.  */
-  tree pointer = TREE_CHAIN (class);
+  tree pointer = TREE_CHAIN (class_tree);
 
   /* Retrieve the value of the POINTER field.  */
   tree gnu_expr32
@@ -3317,9 +3317,9 @@
       tree template_type = TREE_TYPE (p_bounds_type);
       tree min_field = TYPE_FIELDS (template_type);
       tree max_field = TREE_CHAIN (TYPE_FIELDS (template_type));
-      tree template, template_addr, aflags, dimct, t, u;
+      tree template_tree, template_addr, aflags, dimct, t, u;
       /* See the head comment of build_vms_descriptor.  */
-      int iclass = TREE_INT_CST_LOW (DECL_INITIAL (class));
+      int iclass = TREE_INT_CST_LOW (DECL_INITIAL (class_tree));
 
       /* Convert POINTER to the type of the P_ARRAY field.  */
       gnu_expr32 = convert (p_array_type, gnu_expr32);
@@ -3336,25 +3336,25 @@
 			 tree_cons (max_field,
 				    convert (TREE_TYPE (max_field), t),
 				    NULL_TREE));
-	  template = gnat_build_constructor (template_type, t);
-	  template_addr = build_unary_op (ADDR_EXPR, NULL_TREE, template);
+	  template_tree = gnat_build_constructor (template_type, t);
+	  template_addr = build_unary_op (ADDR_EXPR, NULL_TREE, template_tree);
 
 	  /* For class S, we are done.  */
 	  if (iclass == 1)
 	    break;
 
 	  /* Test that we really have a SB descriptor, like DEC Ada.  */
-	  t = build3 (COMPONENT_REF, TREE_TYPE (class), desc, class, NULL);
-	  u = convert (TREE_TYPE (class), DECL_INITIAL (class));
+	  t = build3 (COMPONENT_REF, TREE_TYPE (class_tree), desc, class_tree, NULL);
+	  u = convert (TREE_TYPE (class_tree), DECL_INITIAL (class_tree));
 	  u = build_binary_op (EQ_EXPR, integer_type_node, t, u);
 	  /* If so, there is already a template in the descriptor and
 	     it is located right after the POINTER field.  */
 	  t = TREE_CHAIN (pointer);
-	  template = build3 (COMPONENT_REF, TREE_TYPE (t), desc, t, NULL_TREE);
+	  template_tree = build3 (COMPONENT_REF, TREE_TYPE (t), desc, t, NULL_TREE);
 	  /* Otherwise use the {1, LENGTH} template we build above.  */
 	  template_addr = build3 (COND_EXPR, p_bounds_type, u,
 				  build_unary_op (ADDR_EXPR, p_bounds_type,
-				 		 template),
+				 		 template_tree),
 				  template_addr);
 	  break;
 
@@ -3381,12 +3381,12 @@
 	  /* There is already a template in the descriptor and it is
 	     located at the start of block 3 (12th field).  */
 	  t = TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (t))));
-	  template = build3 (COMPONENT_REF, TREE_TYPE (t), desc, t, NULL_TREE);
-	  template = build3 (COND_EXPR, p_bounds_type, u,
+	  template_tree = build3 (COMPONENT_REF, TREE_TYPE (t), desc, t, NULL_TREE);
+	  template_tree = build3 (COND_EXPR, p_bounds_type, u,
 			    build_call_raise (CE_Length_Check_Failed, Empty,
 					      N_Raise_Constraint_Error),
-			    template);
-	  template_addr = build_unary_op (ADDR_EXPR, p_bounds_type, template);
+			    template_tree);
+	  template_addr = build_unary_op (ADDR_EXPR, p_bounds_type, template_tree);
 	  break;
 
 	case 10: /* Class NCA */
@@ -3717,7 +3717,7 @@
   tree template_type = TREE_TYPE (TREE_TYPE (TREE_CHAIN (TYPE_FIELDS (type))));
   tree p_array_type = TREE_TYPE (TYPE_FIELDS (type));
   tree etype = TREE_TYPE (expr);
-  tree template;
+  tree template_tree;
 
   /* If EXPR is null, make a fat pointer that contains null pointers to the
      template and array.  */
@@ -3743,7 +3743,7 @@
       else
 	expr = build1 (INDIRECT_REF, TREE_TYPE (etype), expr);
 
-      template = build_component_ref (expr, NULL_TREE, fields, false);
+      template_tree = build_component_ref (expr, NULL_TREE, fields, false);
       expr = build_unary_op (ADDR_EXPR, NULL_TREE,
 			     build_component_ref (expr, NULL_TREE,
 						  TREE_CHAIN (fields), false));
@@ -3751,7 +3751,7 @@
 
   /* Otherwise, build the constructor for the template.  */
   else
-    template = build_template (template_type, TREE_TYPE (etype), expr);
+    template_tree = build_template (template_type, TREE_TYPE (etype), expr);
 
   /* The final result is a constructor for the fat pointer.
 
@@ -3771,7 +3771,7 @@
        tree_cons (TYPE_FIELDS (type),
 		  convert (p_array_type, expr),
 		  tree_cons (TREE_CHAIN (TYPE_FIELDS (type)),
-			     build_unary_op (ADDR_EXPR, NULL_TREE, template),
+			     build_unary_op (ADDR_EXPR, NULL_TREE, template_tree),
 			     NULL_TREE)));
 }
 \f
@@ -4301,20 +4301,20 @@
 maybe_unconstrained_array (tree exp)
 {
   enum tree_code code = TREE_CODE (exp);
-  tree new;
+  tree new_tree;
 
   switch (TREE_CODE (TREE_TYPE (exp)))
     {
     case UNCONSTRAINED_ARRAY_TYPE:
       if (code == UNCONSTRAINED_ARRAY_REF)
 	{
-	  new
+	  new_tree
 	    = build_unary_op (INDIRECT_REF, NULL_TREE,
 			      build_component_ref (TREE_OPERAND (exp, 0),
 						   get_identifier ("P_ARRAY"),
 						   NULL_TREE, false));
-	  TREE_READONLY (new) = TREE_STATIC (new) = TREE_READONLY (exp);
-	  return new;
+	  TREE_READONLY (new_tree) = TREE_STATIC (new_tree) = TREE_READONLY (exp);
+	  return new_tree;
 	}
 
       else if (code == NULL_EXPR)
@@ -4328,12 +4328,12 @@
 	 it contains a template.  */
       if (TYPE_IS_PADDING_P (TREE_TYPE (exp)))
 	{
-	  new = convert (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (exp))), exp);
-	  if (TREE_CODE (TREE_TYPE (new)) == RECORD_TYPE
-	      && TYPE_CONTAINS_TEMPLATE_P (TREE_TYPE (new)))
+	  new_tree = convert (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (exp))), exp);
+	  if (TREE_CODE (TREE_TYPE (new_tree)) == RECORD_TYPE
+	      && TYPE_CONTAINS_TEMPLATE_P (TREE_TYPE (new_tree)))
 	    return
-	      build_component_ref (new, NULL_TREE,
-				   TREE_CHAIN (TYPE_FIELDS (TREE_TYPE (new))),
+	      build_component_ref (new_tree, NULL_TREE,
+				   TREE_CHAIN (TYPE_FIELDS (TREE_TYPE (new_tree))),
 				   0);
 	}
       else if (TYPE_CONTAINS_TEMPLATE_P (TREE_TYPE (exp)))
@@ -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;
Index: gcc/ada/gcc-interface/Makefile.in
===================================================================
--- gcc/ada/gcc-interface/Makefile.in	(revision 148953)
+++ gcc/ada/gcc-interface/Makefile.in	(working copy)
@@ -2043,7 +2043,7 @@
 
 LIBGNAT=../$(RTSDIR)/libgnat.a
 
-GCC_LINK=$(CC) -static-libgcc $(ADA_INCLUDES)
+GCC_LINK=$(LINKER) -static-libgcc $(ADA_INCLUDES)
 
 # when compiling the tools, the runtime has to be first on the path so that
 # it hides the runtime files lying with the rest of the sources
@@ -2463,13 +2463,15 @@
 # because all that file does, when not compiling with GCC,
 # is include the system varargs.h.
 
-b_gnatl.c : $(GNATLINK_OBJS)
-	$(GNATBIND) -C $(ADA_INCLUDES) -o b_gnatl.c gnatlink.ali
-b_gnatl.o : b_gnatl.c
+b_gnatl.adb : $(GNATLINK_OBJS)
+	$(GNATBIND) -A $(ADA_INCLUDES) -o b_gnatl.adb gnatlink.ali
+b_gnatl.o : b_gnatl.adb
+	$(CC) -c $(CFLAGS) $(ADA_CFLAGS) $(ADA_INCLUDES) $< $(OUTPUT_OPTION)
 
-b_gnatm.c : $(GNATMAKE_OBJS)
-	$(GNATBIND) -C $(ADA_INCLUDES) -o b_gnatm.c gnatmake.ali
-b_gnatm.o : b_gnatm.c
+b_gnatm.adb : $(GNATMAKE_OBJS)
+	$(GNATBIND) -A $(ADA_INCLUDES) -o b_gnatm.adb gnatmake.ali
+b_gnatm.o : b_gnatm.adb
+	$(CC) -c $(CFLAGS) $(ADA_CFLAGS) $(ADA_INCLUDES) $< $(OUTPUT_OPTION)
 
 ADA_INCLUDE_DIR = $(libsubdir)/adainclude
 ADA_RTL_OBJ_DIR = $(libsubdir)/adalib
Index: gcc/ada/gcc-interface/decl.c
===================================================================
--- gcc/ada/gcc-interface/decl.c	(revision 148953)
+++ gcc/ada/gcc-interface/decl.c	(working copy)
@@ -7788,7 +7788,7 @@
 tree
 substitute_in_type (tree t, tree f, tree r)
 {
-  tree new;
+  tree new_tree;
 
   gcc_assert (CONTAINS_PLACEHOLDER_P (r));
 
@@ -7809,15 +7809,15 @@
 	  if (low == TYPE_GCC_MIN_VALUE (t) && high == TYPE_GCC_MAX_VALUE (t))
 	    return t;
 
-	  new = copy_type (t);
-	  TYPE_GCC_MIN_VALUE (new) = low;
-	  TYPE_GCC_MAX_VALUE (new) = high;
+	  new_tree = copy_type (t);
+	  TYPE_GCC_MIN_VALUE (new_tree) = low;
+	  TYPE_GCC_MAX_VALUE (new_tree) = high;
 
 	  if (TREE_CODE (t) == INTEGER_TYPE && TYPE_INDEX_TYPE (t))
 	    SET_TYPE_INDEX_TYPE
-	      (new, substitute_in_type (TYPE_INDEX_TYPE (t), f, r));
+	      (new_tree, substitute_in_type (TYPE_INDEX_TYPE (t), f, r));
 
-	  return new;
+	  return new_tree;
 	}
 
       /* Then the subtypes.  */
@@ -7830,21 +7830,21 @@
 	  if (low == TYPE_RM_MIN_VALUE (t) && high == TYPE_RM_MAX_VALUE (t))
 	    return t;
 
-	  new = copy_type (t);
-	  SET_TYPE_RM_MIN_VALUE (new, low);
-	  SET_TYPE_RM_MAX_VALUE (new, high);
+	  new_tree = copy_type (t);
+	  SET_TYPE_RM_MIN_VALUE (new_tree, low);
+	  SET_TYPE_RM_MAX_VALUE (new_tree, high);
 
-	  return new;
+	  return new_tree;
 	}
 
       return t;
 
     case COMPLEX_TYPE:
-      new = substitute_in_type (TREE_TYPE (t), f, r);
-      if (new == TREE_TYPE (t))
+      new_tree = substitute_in_type (TREE_TYPE (t), f, r);
+      if (new_tree == TREE_TYPE (t))
 	return t;
 
-      return build_complex_type (new);
+      return build_complex_type (new_tree);
 
     case OFFSET_TYPE:
     case METHOD_TYPE:
@@ -7861,16 +7861,16 @@
 	if (component == TREE_TYPE (t) && domain == TYPE_DOMAIN (t))
 	  return t;
 
-	new = build_array_type (component, domain);
-	TYPE_ALIGN (new) = TYPE_ALIGN (t);
-	TYPE_USER_ALIGN (new) = TYPE_USER_ALIGN (t);
-	SET_TYPE_MODE (new, TYPE_MODE (t));
-	TYPE_SIZE (new) = SUBSTITUTE_IN_EXPR (TYPE_SIZE (t), f, r);
-	TYPE_SIZE_UNIT (new) = SUBSTITUTE_IN_EXPR (TYPE_SIZE_UNIT (t), f, r);
-	TYPE_NONALIASED_COMPONENT (new) = TYPE_NONALIASED_COMPONENT (t);
-	TYPE_MULTI_ARRAY_P (new) = TYPE_MULTI_ARRAY_P (t);
-	TYPE_CONVENTION_FORTRAN_P (new) = TYPE_CONVENTION_FORTRAN_P (t);
-	return new;
+	new_tree = build_array_type (component, domain);
+	TYPE_ALIGN (new_tree) = TYPE_ALIGN (t);
+	TYPE_USER_ALIGN (new_tree) = TYPE_USER_ALIGN (t);
+	SET_TYPE_MODE (new_tree, TYPE_MODE (t));
+	TYPE_SIZE (new_tree) = SUBSTITUTE_IN_EXPR (TYPE_SIZE (t), f, r);
+	TYPE_SIZE_UNIT (new_tree) = SUBSTITUTE_IN_EXPR (TYPE_SIZE_UNIT (t), f, r);
+	TYPE_NONALIASED_COMPONENT (new_tree) = TYPE_NONALIASED_COMPONENT (t);
+	TYPE_MULTI_ARRAY_P (new_tree) = TYPE_MULTI_ARRAY_P (t);
+	TYPE_CONVENTION_FORTRAN_P (new_tree) = TYPE_CONVENTION_FORTRAN_P (t);
+	return new_tree;
       }
 
     case RECORD_TYPE:
@@ -7883,8 +7883,8 @@
 	/* Start out with no fields, make new fields, and chain them
 	   in.  If we haven't actually changed the type of any field,
 	   discard everything we've done and return the old type.  */
-	new = copy_type (t);
-	TYPE_FIELDS (new) = NULL_TREE;
+	new_tree = copy_type (t);
+	TYPE_FIELDS (new_tree) = NULL_TREE;
 
 	for (field = TYPE_FIELDS (t); field; field = TREE_CHAIN (field))
 	  {
@@ -7915,23 +7915,23 @@
 		  }
 	      }
 
-	    DECL_CONTEXT (new_field) = new;
+	    DECL_CONTEXT (new_field) = new_tree;
 	    SET_DECL_ORIGINAL_FIELD (new_field,
 				     (DECL_ORIGINAL_FIELD (field)
 				      ? DECL_ORIGINAL_FIELD (field) : field));
 
-	    TREE_CHAIN (new_field) = TYPE_FIELDS (new);
-	    TYPE_FIELDS (new) = new_field;
+	    TREE_CHAIN (new_field) = TYPE_FIELDS (new_tree);
+	    TYPE_FIELDS (new_tree) = new_field;
 	  }
 
 	if (!changed_field)
 	  return t;
 
-	TYPE_FIELDS (new) = nreverse (TYPE_FIELDS (new));
-	TYPE_SIZE (new) = SUBSTITUTE_IN_EXPR (TYPE_SIZE (t), f, r);
-	TYPE_SIZE_UNIT (new) = SUBSTITUTE_IN_EXPR (TYPE_SIZE_UNIT (t), f, r);
-	SET_TYPE_ADA_SIZE (new, SUBSTITUTE_IN_EXPR (TYPE_ADA_SIZE (t), f, r));
-	return new;
+	TYPE_FIELDS (new_tree) = nreverse (TYPE_FIELDS (new_tree));
+	TYPE_SIZE (new_tree) = SUBSTITUTE_IN_EXPR (TYPE_SIZE (t), f, r);
+	TYPE_SIZE_UNIT (new_tree) = SUBSTITUTE_IN_EXPR (TYPE_SIZE_UNIT (t), f, r);
+	SET_TYPE_ADA_SIZE (new_tree, SUBSTITUTE_IN_EXPR (TYPE_ADA_SIZE (t), f, r));
+	return new_tree;
       }
 
     default:
Index: gcc/ada/gcc-interface/Make-lang.in
===================================================================
--- gcc/ada/gcc-interface/Make-lang.in	(revision 148953)
+++ gcc/ada/gcc-interface/Make-lang.in	(working copy)
@@ -105,7 +105,7 @@
 	"GNATLINK=../../gnatlink"	\
 	"GNATBIND=../../gnatbind"
 
-GCC_LINK=$(CC) -static-libgcc $(LDFLAGS)
+GCC_LINK=$(LINKER) -static-libgcc $(LDFLAGS)
 
 # Lists of files for various purposes.
 
@@ -927,13 +927,19 @@
 ada_extra_files : ada/treeprs.ads ada/einfo.h ada/sinfo.h ada/nmake.adb \
 	ada/nmake.ads ada/snames.ads ada/snames.adb ada/snames.h
 
-ada/b_gnat1.c : $(GNAT1_ADA_OBJS)
-	$(GNATBIND) -C $(ADA_INCLUDES) -o ada/b_gnat1.c -n ada/gnat1drv.ali
-ada/b_gnat1.o : ada/b_gnat1.c
+ada/b_gnat1.adb : $(GNAT1_ADA_OBJS)
+	$(GNATBIND) -A $(ADA_INCLUDES) -o b_gnat1.adb -n ada/gnat1drv.ali
+	$(MV) -f b_gnat1.adb ada/
+	$(MV) -f b_gnat1.ads ada/
+ada/b_gnat1.o : ada/b_gnat1.adb
+	$(CC) -c $(CFLAGS) $(ADA_CFLAGS) $(ADA_INCLUDES) $< $(OUTPUT_OPTION)
 
-ada/b_gnatb.c : $(GNATBIND_OBJS) ada/gnatbind.o ada/interfac.o
-	$(GNATBIND) -C $(ADA_INCLUDES) -o ada/b_gnatb.c ada/gnatbind.ali
-ada/b_gnatb.o : ada/b_gnatb.c
+ada/b_gnatb.adb : $(GNATBIND_OBJS) ada/gnatbind.o ada/interfac.o
+	$(GNATBIND) -A $(ADA_INCLUDES) -o b_gnatb.adb ada/gnatbind.ali
+	$(MV) -f b_gnatb.adb ada/
+	$(MV) -f b_gnatb.ads ada/
+ada/b_gnatb.o : ada/b_gnatb.adb
+	$(CC) -c $(CFLAGS) $(ADA_CFLAGS) $(ADA_INCLUDES) $< $(OUTPUT_OPTION)
 
 # We delete the files before copying, below, in case they are read-only.
 ada/treeprs.ads : ada/treeprs.adt ada/sinfo.ads ada/xtreeprs.adb
Index: gcc/ada/gcc-interface/gigi.h
===================================================================
--- gcc/ada/gcc-interface/gigi.h	(revision 148953)
+++ gcc/ada/gcc-interface/gigi.h	(working copy)
@@ -175,6 +175,10 @@
   Nat Num_Source_Lines;
 };
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* This is the main program of the back-end.  It sets up all the table
    structures and then generates code.
 
@@ -195,6 +199,11 @@
                   Entity_Id standard_exception_type,
                   Int gigi_operating_mode);
 
+
+#ifdef __cplusplus
+}
+#endif
+
 /* GNAT_NODE is the root of some GNAT tree.  Return the root of the
    GCC tree corresponding to that GNAT tree.  Normally, no code is generated;
    we just return an equivalent tree which is used elsewhere to generate
@@ -915,6 +924,11 @@
 /* These functions return the basic data type sizes and related parameters
    about the target machine.  */
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 extern Pos get_target_bits_per_unit (void);
 extern Pos get_target_bits_per_word (void);
 extern Pos get_target_char_size (void);
@@ -939,6 +953,10 @@
 extern Nat get_target_double_float_alignment (void);
 extern Nat get_target_double_scalar_alignment (void);
 
+#ifdef __cplusplus
+}
+#endif
+
 /* Let code know whether we are targetting VMS without need of
    intrusive preprocessor directives.  */
 #ifndef TARGET_ABI_OPEN_VMS
Index: gcc/ada/gcc-interface/trans.c
===================================================================
--- gcc/ada/gcc-interface/trans.c	(revision 148953)
+++ gcc/ada/gcc-interface/trans.c	(working copy)
@@ -75,8 +75,17 @@
 #endif
 #endif
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 extern char *__gnat_to_canonical_file_spec (char *);
 
+#ifdef __cplusplus
+}
+#endif
+
 int max_gnat_nodes;
 int number_names;
 int number_files;
@@ -100,7 +109,7 @@
 /* When not optimizing, we cache the 'First, 'Last and 'Length attributes
    of unconstrained array IN parameters to avoid emitting a great deal of
    redundant instructions to recompute them each time.  */
-struct GTY (()) parm_attr {
+struct GTY (()) parm_attr_d {
   int id; /* GTY doesn't like Entity_Id.  */
   int dim;
   tree first;
@@ -108,7 +117,7 @@
   tree length;
 };
 
-typedef struct parm_attr *parm_attr;
+typedef struct parm_attr_d *parm_attr;
 
 DEF_VEC_P(parm_attr);
 DEF_VEC_ALLOC_P(parm_attr,gc);
@@ -1464,7 +1473,7 @@
 	int Dimension = (Present (Expressions (gnat_node))
 			 ? UI_To_Int (Intval (First (Expressions (gnat_node))))
 			 : 1), i;
-	struct parm_attr *pa = NULL;
+	struct parm_attr_d *pa = NULL;
 	Entity_Id gnat_param = Empty;
 
 	/* Make sure any implicit dereference gets done.  */
@@ -1508,7 +1517,7 @@
 
 	    if (!pa)
 	      {
-		pa = GGC_CNEW (struct parm_attr);
+		pa = GGC_CNEW (struct parm_attr_d);
 		pa->id = gnat_param;
 		pa->dim = Dimension;
 		VEC_safe_push (parm_attr, gc, f_parm_attr_cache, pa);
@@ -2273,7 +2282,7 @@
   cache = DECL_STRUCT_FUNCTION (gnu_subprog_decl)->language->parm_attr_cache;
   if (cache)
     {
-      struct parm_attr *pa;
+      struct parm_attr_d *pa;
       int i;
 
       start_stmt_group ();
Index: gcc/ada/gcc-interface/misc.c
===================================================================
--- gcc/ada/gcc-interface/misc.c	(revision 148953)
+++ gcc/ada/gcc-interface/misc.c	(working copy)
@@ -150,12 +150,23 @@
 extern int gnat_argc;
 extern char **gnat_argv;
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Declare functions we use as part of startup.  */
 extern void __gnat_initialize           (void *);
 extern void __gnat_install_SEH_handler  (void *);
 extern void adainit		        (void);
 extern void _ada_gnat1drv	        (void);
 
+
+#ifdef __cplusplus
+}
+#endif
+
+
 /* The parser for the language.  For us, we process the GNAT tree.  */
 
 static void
@@ -729,10 +740,11 @@
 void
 enumerate_modes (void (*f) (int, int, int, int, int, int, unsigned int))
 {
-  enum machine_mode i;
+  int iloop;
 
-  for (i = 0; i < NUM_MACHINE_MODES; i++)
+  for (iloop = 0; iloop < NUM_MACHINE_MODES; iloop++)
     {
+      enum machine_mode i = (enum machine_mode) iloop;
       enum machine_mode j;
       bool float_p = 0;
       bool complex_p = 0;
Index: gcc/ada/argv.c
===================================================================
--- gcc/ada/argv.c	(revision 148953)
+++ gcc/ada/argv.c	(working copy)
@@ -42,6 +42,11 @@
    main program, and these routines are accessed from the
    Ada.Command_Line.Environment package. */
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef IN_RTS
 #include "tconfig.h"
 #include "tsystem.h"
@@ -116,3 +121,7 @@
   if (gnat_envp != NULL)
     strncpy (a, gnat_envp[i], strlen (gnat_envp[i]));
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/atree.h
===================================================================
--- gcc/ada/atree.h	(revision 148953)
+++ gcc/ada/atree.h	(working copy)
@@ -31,6 +31,11 @@
    Note that only routines for reading the tree are included, since the tree
    transformer is not supposed to modify the tree in any way. */
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Structure used for the first part of the node in the case where we have
    an Nkind.  */
 
@@ -760,3 +765,8 @@
 #define Flag245(N)     (Nodes_Ptr[(N) - First_Node_Id + 4].V.EX.U.fw5.flag245)
 #define Flag246(N)     (Nodes_Ptr[(N) - First_Node_Id + 4].V.EX.U.fw5.flag246)
 #define Flag247(N)     (Nodes_Ptr[(N) - First_Node_Id + 4].V.EX.U.fw5.flag247)
+
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/expect.c
===================================================================
--- gcc/ada/expect.c	(revision 148953)
+++ gcc/ada/expect.c	(working copy)
@@ -30,6 +30,11 @@
  *                                                                          *
  ****************************************************************************/
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef __alpha_vxworks
 #include "vxWorks.h"
 #endif
@@ -557,3 +562,8 @@
   return -1;
 }
 #endif
+
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/seh_init.c
===================================================================
--- gcc/ada/seh_init.c	(revision 148953)
+++ gcc/ada/seh_init.c	(working copy)
@@ -32,6 +32,11 @@
 /*  This unit contains support for SEH (Structured Exception Handling).
     Right now the only implementation is for Win32.  */
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef IN_RTS
 #include "tconfig.h"
 #include "tsystem.h"
@@ -230,3 +235,8 @@
 {
 }
 #endif
+
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/gmem.c
===================================================================
--- gcc/ada/gmem.c	(revision 148953)
+++ gcc/ada/gmem.c	(working copy)
@@ -49,6 +49,10 @@
 
 */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef VMS
 #include <string.h>
 #define xstrdup32(S)  strcpy ((__char_ptr32) _malloc32 (strlen (S) + 1), S)
@@ -215,3 +219,7 @@
 
   __gnat_convert_addresses (addresses, 1, buf, length);
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/adadecode.c
===================================================================
--- gcc/ada/adadecode.c	(revision 148953)
+++ gcc/ada/adadecode.c	(working copy)
@@ -29,6 +29,11 @@
  *                                                                          *
  ****************************************************************************/
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef IN_GCC
 #include "config.h"
 #include "system.h"
@@ -372,3 +377,7 @@
 
   *dest_index = '\0';
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/link.c
===================================================================
--- gcc/ada/link.c	(revision 148953)
+++ gcc/ada/link.c	(working copy)
@@ -33,6 +33,11 @@
 /*  of the linker. It is used by gnatlink as well as all tools that use     */
 /*  Mlib.                                                                   */
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <string.h>
 
 /*  objlist_file_supported is set to 1 when the system linker allows        */
@@ -206,3 +211,8 @@
 const char *__gnat_object_library_extension = ".a";
 unsigned char __gnat_separate_run_path_options = 0;
 #endif
+
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/prefix.h
===================================================================
--- gcc/prefix.h	(revision 148953)
+++ gcc/prefix.h	(working copy)
@@ -21,10 +21,22 @@
 #ifndef GCC_PREFIX_H
 #define GCC_PREFIX_H
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* These functions are called by the Ada frontend with C convention. */
+
 /* Update PATH using KEY if PATH starts with PREFIX.  The returned
    string is always malloc-ed, and the caller is responsible for
    freeing it.  */
 extern char *update_path (const char *path, const char *key);
 extern void set_std_prefix (const char *, int);
 
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* ! GCC_PREFIX_H */
Index: gnattools/Makefile.in
===================================================================
--- gnattools/Makefile.in	(revision 148953)
+++ gnattools/Makefile.in	(working copy)
@@ -67,6 +67,7 @@
 # Variables for gnattools1, native
 TOOLS_FLAGS_TO_PASS_1= \
 	"CC=../../xgcc -B../../" \
+	"LINKER=$(CXX)" \
 	"CFLAGS=$(CFLAGS) $(WARN_CFLAGS)" \
 	"LDFLAGS=$(LDFLAGS)" \
 	"ADAFLAGS=$(ADAFLAGS)" \
@@ -82,6 +83,7 @@
 # Variables for regnattools
 TOOLS_FLAGS_TO_PASS_1re= \
 	"CC=../../xgcc -B../../" \
+	"LINKER=$(CXX)" \
 	"CFLAGS=$(CFLAGS)" \
 	"ADAFLAGS=$(ADAFLAGS)" \
 	"ADA_CFLAGS=$(ADA_CFLAGS)" \
@@ -99,6 +101,7 @@
 # Variables for gnattools2, native
 TOOLS_FLAGS_TO_PASS_NATIVE= \
 	"CC=../../xgcc -B../../" \
+	"LINKER=$(CXX)" \
 	"CFLAGS=$(CFLAGS)" \
 	"ADAFLAGS=$(ADAFLAGS)" \
 	"ADA_CFLAGS=$(ADA_CFLAGS)" \
@@ -115,6 +118,7 @@
 # Variables for gnattools, cross
 TOOLS_FLAGS_TO_PASS_CROSS= \
 	"CC=$(CC)" \
+	"LINKER=$(CXX)" \
 	"CFLAGS=$(CFLAGS) $(WARN_CFLAGS)" \
 	"LDFLAGS=$(LDFLAGS)" \
 	"ADAFLAGS=$(ADAFLAGS)"	\

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete (Ada)
  2009-06-27 12:53                               ` Laurent GUERBY
@ 2009-06-27 13:39                                 ` Laurent GUERBY
  2009-06-27 16:14                                 ` Paolo Bonzini
  1 sibling, 0 replies; 43+ messages in thread
From: Laurent GUERBY @ 2009-06-27 13:39 UTC (permalink / raw)
  To: Eric Botcazou
  Cc: Ian Lance Taylor, Arnaud Charlet, Robert Dewar, Richard Guenther,
	gcc, Andrew Pinski

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 passes		2313
# of unexpected failures	2
Native configuration is x86_64-unknown-linux-gnu

		=== gnat Summary ===

# of expected passes		659
# 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



^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete (Ada)
  2009-06-27 12:53                               ` Laurent GUERBY
  2009-06-27 13:39                                 ` Laurent GUERBY
@ 2009-06-27 16:14                                 ` Paolo Bonzini
  1 sibling, 0 replies; 43+ messages in thread
From: Paolo Bonzini @ 2009-06-27 16:14 UTC (permalink / raw)
  To: laurent
  Cc: Eric Botcazou, Ian Lance Taylor, Arnaud Charlet, Robert Dewar,
	Richard Guenther, gcc, Andrew Pinski

  	"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

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete
  2009-06-25 20:33 Phase 1 of gcc-in-cxx now complete Ian Lance Taylor
                   ` (3 preceding siblings ...)
  2009-06-26 18:21 ` Adam Nemet
@ 2009-06-27 16:51 ` Adam Nemet
  2009-06-27 18:07 ` David Edelsohn
  5 siblings, 0 replies; 43+ messages in thread
From: Adam Nemet @ 2009-06-27 16:51 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc

Ian Lance Taylor <iant@google.com> writes:
> 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.

MIPS bootstraps fine with --enable-build-with-cxx:

  http://gcc.gnu.org/ml/gcc-testresults/2009-06/msg02323.html

I don't know if the new failures are related to C++; I will do a C build
later and compare.

Ian, thanks for your C++ work!

Adam

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete
  2009-06-25 20:33 Phase 1 of gcc-in-cxx now complete Ian Lance Taylor
                   ` (4 preceding siblings ...)
  2009-06-27 16:51 ` Adam Nemet
@ 2009-06-27 18:07 ` David Edelsohn
  2009-06-27 19:50   ` Sebastian Pop
  5 siblings, 1 reply; 43+ messages in thread
From: David Edelsohn @ 2009-06-27 18:07 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc

On Thu, Jun 25, 2009 at 4:32 PM, Ian Lance Taylor<iant@google.com> wrote:

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

I tried bootstrap with AIX.  Because AIX static libstdc++ requires
libsupc++, the search path for that library in the build directory
needs to be on the link line.  Manually adding that directory allows
GCC on AIX to get through stage3 bootstrap.

There are two other problems / annoyances independent of AIX:

1) All of the multilibs for libstdc++ are configured and built during
bootstrap.  This always has been the case for libgcc, but it was not
as much of an inconvenience.

2) The Graphite CLooG headers are not C++-clean, so enabling Graphite
fails in CXX mode.

David

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete
  2009-06-27 18:07 ` David Edelsohn
@ 2009-06-27 19:50   ` Sebastian Pop
  0 siblings, 0 replies; 43+ messages in thread
From: Sebastian Pop @ 2009-06-27 19:50 UTC (permalink / raw)
  To: David Edelsohn; +Cc: Ian Lance Taylor, gcc

On Sat, Jun 27, 2009 at 11:51, David Edelsohn<dje.gcc@gmail.com> wrote:
> 2) The Graphite CLooG headers are not C++-clean, so enabling Graphite
> fails in CXX mode.

I did applied the patches from Ian to the cloog-ppl git.
The git version should compile with a C++ compiler.

Sebastian

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete
  2009-06-29 13:10       ` NightStrike
  2009-06-29 13:13         ` Andrew Haley
@ 2009-06-29 16:26         ` Gabriel Dos Reis
  1 sibling, 0 replies; 43+ messages in thread
From: Gabriel Dos Reis @ 2009-06-29 16:26 UTC (permalink / raw)
  To: NightStrike; +Cc: Ian Lance Taylor, Richard Guenther, Matt, gcc

On Mon, Jun 29, 2009 at 5:39 AM, NightStrike<nightstrike@gmail.com> wrote:
> On Sat, Jun 27, 2009 at 6:25 PM, Ian Lance Taylor<iant@google.com> wrote:
>> Richard Guenther <richard.guenther@gmail.com> writes:
>>
>>> All that above said - do you expect us to carry both vec.h (for VEC in
>>> GC memory) and std::vector (for VECs in heap memory) (and vec.h
>>> for the alloca trick ...)?  Or do you think we should try to make the GTY
>>> machinery C++ aware and annotate the standard library (ick...)?
>>
>> I expect us to write a GC allocator, and use that with std::vector.
>> This will require more hooks into the GC code, but I think it is doable.
>
> I'm curious about this.  I thought c++ wasn't a garbage collected
> language on purpose.

Many people are confused about what the 'purpose' is.

>  Why does GCC have one?  What purpose does it
> serve?  I'm not suggesting otherwise, but just trying to learn more
> about the way things are done.
>

This is usually an ingredient for long, heated, debates :-)

-- Gaby

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete
  2009-06-29 13:10       ` NightStrike
@ 2009-06-29 13:13         ` Andrew Haley
  2009-06-29 16:26         ` Gabriel Dos Reis
  1 sibling, 0 replies; 43+ messages in thread
From: Andrew Haley @ 2009-06-29 13:13 UTC (permalink / raw)
  To: NightStrike; +Cc: Ian Lance Taylor, Richard Guenther, Matt, gcc

NightStrike wrote:
> On Sat, Jun 27, 2009 at 6:25 PM, Ian Lance Taylor<iant@google.com> wrote:
>> Richard Guenther <richard.guenther@gmail.com> writes:
>>
>>> All that above said - do you expect us to carry both vec.h (for VEC in
>>> GC memory) and std::vector (for VECs in heap memory) (and vec.h
>>> for the alloca trick ...)?  Or do you think we should try to make the GTY
>>> machinery C++ aware and annotate the standard library (ick...)?
>> I expect us to write a GC allocator, and use that with std::vector.
>> This will require more hooks into the GC code, but I think it is doable.
> 
> I'm curious about this.  I thought c++ wasn't a garbage collected
> language on purpose.  Why does GCC have one?  What purpose does it
> serve?  I'm not suggesting otherwise, but just trying to learn more
> about the way things are done.

This is for gcc's internal use, not for the users of gcc.  We have to
manage memory inside gcc somehow, so we use a garbage collector.

Andrew.

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete
  2009-06-28  3:09     ` Ian Lance Taylor
@ 2009-06-29 13:10       ` NightStrike
  2009-06-29 13:13         ` Andrew Haley
  2009-06-29 16:26         ` Gabriel Dos Reis
  0 siblings, 2 replies; 43+ messages in thread
From: NightStrike @ 2009-06-29 13:10 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: Richard Guenther, Matt, gcc

On Sat, Jun 27, 2009 at 6:25 PM, Ian Lance Taylor<iant@google.com> wrote:
> Richard Guenther <richard.guenther@gmail.com> writes:
>
>> All that above said - do you expect us to carry both vec.h (for VEC in
>> GC memory) and std::vector (for VECs in heap memory) (and vec.h
>> for the alloca trick ...)?  Or do you think we should try to make the GTY
>> machinery C++ aware and annotate the standard library (ick...)?
>
> I expect us to write a GC allocator, and use that with std::vector.
> This will require more hooks into the GC code, but I think it is doable.

I'm curious about this.  I thought c++ wasn't a garbage collected
language on purpose.  Why does GCC have one?  What purpose does it
serve?  I'm not suggesting otherwise, but just trying to learn more
about the way things are done.

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete
  2009-06-27 10:35   ` Richard Guenther
  2009-06-27 13:41     ` Daniel Berlin
@ 2009-06-28  3:09     ` Ian Lance Taylor
  2009-06-29 13:10       ` NightStrike
  1 sibling, 1 reply; 43+ messages in thread
From: Ian Lance Taylor @ 2009-06-28  3:09 UTC (permalink / raw)
  To: Richard Guenther; +Cc: Matt, gcc

Richard Guenther <richard.guenther@gmail.com> writes:

> All that above said - do you expect us to carry both vec.h (for VEC in
> GC memory) and std::vector (for VECs in heap memory) (and vec.h
> for the alloca trick ...)?  Or do you think we should try to make the GTY
> machinery C++ aware and annotate the standard library (ick...)?

I expect us to write a GC allocator, and use that with std::vector.
This will require more hooks into the GC code, but I think it is doable.

> IMHO we should at least try without the standard library for a start,
> fixing the GTY machinery.

If we can't write a GC allocator, then I agree.

Ian

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete
  2009-06-27 13:41     ` Daniel Berlin
@ 2009-06-27 15:19       ` Robert Dewar
  0 siblings, 0 replies; 43+ messages in thread
From: Robert Dewar @ 2009-06-27 15:19 UTC (permalink / raw)
  To: Daniel Berlin; +Cc: Richard Guenther, Ian Lance Taylor, Matt, gcc

Daniel Berlin wrote:
>> All that above said - do you expect us to carry both vec.h (for VEC in
>> GC memory) and std::vector (for VECs in heap memory) (and vec.h
>> for the alloca trick ...)?  Or do you think we should try to make the GTY
>> machinery C++ aware and annotate the standard library (ick...)?
> 
> Since the containers have mostly standard iterators, i'm not sure we
> have to do much to the standard library. Simply require a set of
> iterators with the right properties exist and generate code that
> depends on this.
> If you make your own container, you have to implement the iterators.

Shouldn't this be a new thread, or is this really part of phase 1?

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete
  2009-06-27 10:35   ` Richard Guenther
@ 2009-06-27 13:41     ` Daniel Berlin
  2009-06-27 15:19       ` Robert Dewar
  2009-06-28  3:09     ` Ian Lance Taylor
  1 sibling, 1 reply; 43+ messages in thread
From: Daniel Berlin @ 2009-06-27 13:41 UTC (permalink / raw)
  To: Richard Guenther; +Cc: Ian Lance Taylor, Matt, gcc

>
> All that above said - do you expect us to carry both vec.h (for VEC in
> GC memory) and std::vector (for VECs in heap memory) (and vec.h
> for the alloca trick ...)?  Or do you think we should try to make the GTY
> machinery C++ aware and annotate the standard library (ick...)?

Since the containers have mostly standard iterators, i'm not sure we
have to do much to the standard library. Simply require a set of
iterators with the right properties exist and generate code that
depends on this.
If you make your own container, you have to implement the iterators.

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete
  2009-06-27  9:48 ` Ian Lance Taylor
@ 2009-06-27 10:35   ` Richard Guenther
  2009-06-27 13:41     ` Daniel Berlin
  2009-06-28  3:09     ` Ian Lance Taylor
  0 siblings, 2 replies; 43+ messages in thread
From: Richard Guenther @ 2009-06-27 10:35 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: Matt, gcc

On Sat, Jun 27, 2009 at 2:55 AM, Ian Lance Taylor<iant@google.com> wrote:
> Matt <matt@use.net> writes:
>
>>> * Develop some trial patches which require C++, e.g., convert VEC to
>>>  std::vector.
>>
>> Do you have any ideas for the easiest starting points? Is there
>> anywhere that is decently self-contained, or will if have to be a big
>> bang?
>
> Thanks for your interest.
>
> I think the one I mentioned--converting VEC to std::vector--is a good
> starting point.  This is the interface in vec.h.
>
> Another easy starting point would be converting uses of htab_t to type
> safe C++ hash tables, e.g., std::tr1:;unordered_map.  Here portability
> suggests the ability to switch to different hash table implementations;
> see gold/gold.h in the GNU binutils for one way to approach that.
>
> Another easy starting point is finding calls to qsort and converting
> them to std::sort, which typically leads to code which is larger but
> runs faster.
>
> Longer term, we know that memory usage is an issue in gcc.  In the old
> obstack days, we had a range of obstacks with different lifespans, so we
> could create RTL with a temporary lifetime which was given a longer
> lifetime when needed.  We got away from that because we spent far too
> much time chasing bugs in which RTL should have been saved to a longer
> lifetime but wasn't.  However, that model should permit us to run with
> significantly less memory, which would translate to less compile time.
> I think we might be able to do it by implementing a custom allocator,
> such as a pool allocator which permits allocating different sizes of
> memory, and never frees memory.  Then the tree class could take an
> allocator as a template parameter.  Then we would provide convertors
> which copied the tree class to a different allocation style.  Then, for
> example, fold-const.c could use a temporary pool which lived only for
> the length of the call to fold.  If it returned a new value, the
> convertor would force a copy out of the temporary pool.  If this works
> out, we can use type safety to enforce memory discipline, use
> significantly less memory during compilation, and take a big step toward
> getting rid of the garbage collector.

All that above said - do you expect us to carry both vec.h (for VEC in
GC memory) and std::vector (for VECs in heap memory) (and vec.h
for the alloca trick ...)?  Or do you think we should try to make the GTY
machinery C++ aware and annotate the standard library (ick...)?

That said - I was more expecting to re-write the existing vec.h to
C++ to avoid this GC vs. non-GC use differences.  Also as the
standard library uses a very inefficient allocator by default, should
we for example switch from bitmap to an equivalend standard
library container.

IMHO we should at least try without the standard library for a start,
fixing the GTY machinery.

Richard.

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete
  2009-06-27  0:26 Matt
@ 2009-06-27  9:48 ` Ian Lance Taylor
  2009-06-27 10:35   ` Richard Guenther
  0 siblings, 1 reply; 43+ messages in thread
From: Ian Lance Taylor @ 2009-06-27  9:48 UTC (permalink / raw)
  To: Matt; +Cc: gcc

Matt <matt@use.net> writes:

>> * Develop some trial patches which require C++, e.g., convert VEC to
>>  std::vector.
>
> Do you have any ideas for the easiest starting points? Is there
> anywhere that is decently self-contained, or will if have to be a big
> bang?

Thanks for your interest.

I think the one I mentioned--converting VEC to std::vector--is a good
starting point.  This is the interface in vec.h.

Another easy starting point would be converting uses of htab_t to type
safe C++ hash tables, e.g., std::tr1:;unordered_map.  Here portability
suggests the ability to switch to different hash table implementations;
see gold/gold.h in the GNU binutils for one way to approach that.

Another easy starting point is finding calls to qsort and converting
them to std::sort, which typically leads to code which is larger but
runs faster.

Longer term, we know that memory usage is an issue in gcc.  In the old
obstack days, we had a range of obstacks with different lifespans, so we
could create RTL with a temporary lifetime which was given a longer
lifetime when needed.  We got away from that because we spent far too
much time chasing bugs in which RTL should have been saved to a longer
lifetime but wasn't.  However, that model should permit us to run with
significantly less memory, which would translate to less compile time.
I think we might be able to do it by implementing a custom allocator,
such as a pool allocator which permits allocating different sizes of
memory, and never frees memory.  Then the tree class could take an
allocator as a template parameter.  Then we would provide convertors
which copied the tree class to a different allocation style.  Then, for
example, fold-const.c could use a temporary pool which lived only for
the length of the call to fold.  If it returned a new value, the
convertor would force a copy out of the temporary pool.  If this works
out, we can use type safety to enforce memory discipline, use
significantly less memory during compilation, and take a big step toward
getting rid of the garbage collector.

Ian

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: Phase 1 of gcc-in-cxx now complete
@ 2009-06-27  0:26 Matt
  2009-06-27  9:48 ` Ian Lance Taylor
  0 siblings, 1 reply; 43+ messages in thread
From: Matt @ 2009-06-27  0:26 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc


> * Develop some trial patches which require C++, e.g., convert VEC to
>  std::vector.

Do you have any ideas for the easiest starting points? Is there anywhere 
that is decently self-contained, or will if have to be a big bang?

I'd love to see this happen so there's more exercising of template 
expansion during the profiledbootstrap. If I can get pointed in the right 
direction, I can probably produce a patch within the next week.

Thanks for this work and adding all the extra warnings!

--
tangled strands of DNA explain the way that I behave.
http://www.clock.org/~matt

^ permalink raw reply	[flat|nested] 43+ messages in thread

end of thread, other threads:[~2009-06-29 14:23 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-25 20:33 Phase 1 of gcc-in-cxx now complete Ian Lance Taylor
2009-06-25 21:39 ` Richard Guenther
2009-06-25 22:17 ` Phase 1 of gcc-in-cxx now complete (Ada) Laurent GUERBY
2009-06-25 22:19   ` Richard Guenther
2009-06-25 22:38     ` Ian Lance Taylor
2009-06-26 11:20       ` Laurent GUERBY
2009-06-26 14:48         ` Ian Lance Taylor
2009-06-26 15:36           ` Arnaud Charlet
2009-06-26 15:59           ` Laurent GUERBY
2009-06-26 17:32             ` Ian Lance Taylor
2009-06-26 17:36               ` Arnaud Charlet
2009-06-26 17:38               ` Robert Dewar
2009-06-26 17:59                 ` Arnaud Charlet
2009-06-26 18:07                 ` Ian Lance Taylor
2009-06-26 18:18                   ` Robert Dewar
2009-06-26 19:24                     ` Laurent GUERBY
2009-06-26 19:24                       ` Arnaud Charlet
2009-06-26 23:53                         ` Ian Lance Taylor
2009-06-27 11:24                           ` Laurent GUERBY
2009-06-27 11:54                             ` Eric Botcazou
2009-06-27 12:53                               ` Laurent GUERBY
2009-06-27 13:39                                 ` Laurent GUERBY
2009-06-27 16:14                                 ` Paolo Bonzini
2009-06-27 10:55       ` Eric Botcazou
2009-06-25 22:51   ` Ian Lance Taylor
2009-06-25 22:29 ` Phase 1 of gcc-in-cxx now complete Joseph S. Myers
2009-06-25 22:47   ` Eric Botcazou
2009-06-25 22:49   ` Joe Buck
2009-06-26  7:09     ` Gabriel Dos Reis
2009-06-26 14:12       ` Jack Howarth
2009-06-26 18:21 ` Adam Nemet
2009-06-27 16:51 ` Adam Nemet
2009-06-27 18:07 ` David Edelsohn
2009-06-27 19:50   ` Sebastian Pop
2009-06-27  0:26 Matt
2009-06-27  9:48 ` Ian Lance Taylor
2009-06-27 10:35   ` Richard Guenther
2009-06-27 13:41     ` Daniel Berlin
2009-06-27 15:19       ` Robert Dewar
2009-06-28  3:09     ` Ian Lance Taylor
2009-06-29 13:10       ` NightStrike
2009-06-29 13:13         ` Andrew Haley
2009-06-29 16:26         ` Gabriel Dos Reis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).