Re: Java front-end and library patches.

2022-12-14 Thread Zopolis0 via Gcc-patches
Re: 1dedc12d186a110854537e1279b4e6c29f2df35a breakage

I've done some more research, it's not the -dumpbase. Comparing the
java frontend on master as opposed to one based on a commit right
before 1dedc12, the master has '-dumpdir' '.libs/jv-convert-' while
the one before does not, which I believe is causing the breakage.

Master:
zopolis4@epidural ~/g/x/libjava> /bin/bash ./libtool --tag=GCJ
--mode=link /home/zopolis4/gcjbuild/./gcc/gcj
-B/home/zopolis4/gcjbuild/x86_64-pc-linux-gnu/libjava/ -B/h
ome/zopolis4/gcjbuild/./gcc/ -B/usr/local/x86_64-pc-linux-gnu/bin/
-B/usr/local/x86_64-pc-linux-gnu/lib/ -isystem
/usr/local/x86_64-pc-linux-gnu/include -isystem /usr/local
/x86_64-pc-linux-gnu/sys-include
-L/home/zopolis4/gcjbuild/x86_64-pc-linux-gnu/libjava
-fomit-frame-pointer -Usun -v -g -O2  -o jv-convert
--main=gnu.gcj.convert.Convert
 -rpath /usr/local/lib/../lib64 -shared-libgcc
-L/home/zopolis4/gcjbuild/x86_64-pc-linux-gnu/libjava/.libs libgcj.la
libtool: link: /home/zopolis4/gcjbuild/./gcc/gcj
-B/home/zopolis4/gcjbuild/x86_64-pc-linux-gnu/libjava/
-B/home/zopolis4/gcjbuild/./gcc/ -B/usr/local/x86_64-pc-linux-gnu/bin/
-B/usr/local/x86_64-pc-linux-gnu/lib/ -isystem
/usr/local/x86_64-pc-linux-gnu/include -isystem
/usr/local/x86_64-pc-linux-gnu/sys-include -fomit-frame-pointer -Usun
-v -g -O2 -o .libs/jv-convert --main=gnu.gcj.convert.Convert
-shared-libgcc
-L/home/zopolis4/gcjbuild/x86_64-pc-linux-gnu/libjava/.libs
-L/home/zopolis4/gcjbuild/x86_64-pc-linux-gnu/libjava
./.libs/libgcj.so -lpthread -lrt -lltdl -lgc -Wl,-rpath
-Wl,/usr/local/lib/../lib64
Reading specs from /home/zopolis4/gcjbuild/./gcc/specs
Reading specs from
/home/zopolis4/gcjbuild/x86_64-pc-linux-gnu/libjava/libgcj.spec
rename spec startfile to startfileorig
rename spec lib to liborig
COLLECT_GCC=/home/zopolis4/gcjbuild/./gcc/gcj
COLLECT_LTO_WRAPPER=/home/zopolis4/gcjbuild/./gcc/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /home/zopolis4/gcjbuild/../gcj/configure
--disable-bootstrap --disable-multilib --disable-libstdcxx
--disable-libquadmath --disable-libgomp --disable-libgfortran
--enable-languages=java : (reconfigured)
/home/zopolis4/gcjbuild/../gcj/configure --disable-bootstrap
--disable-multilib --disable-libstdcxx --disable-libquadmath
--disable-libgomp --disable-libgfortran --disable-libgm2
--enable-languages=java : (reconfigured)
/home/zopolis4/gcjbuild/../gcj/configure --disable-bootstrap
--disable-multilib --disable-libstdcxx --disable-libquadmath
--disable-libgomp --disable-libgfortran --disable-libgm2
LDFLAGS='-static-libstdc++ -static-libgcc
-L/usr/lib/gcc/x86_64-linux-gnu/12' --enable-languages=c,c++,java,lto
--no-create --no-recursion
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.0.0 20221214 (experimental) (GCC)
COLLECT_GCC_OPTIONS='-B'
'/home/zopolis4/gcjbuild/x86_64-pc-linux-gnu/libjava/' '-B'
'/home/zopolis4/gcjbuild/./gcc/' '-B'
'/usr/local/x86_64-pc-linux-gnu/bin/' '-B'
'/usr/local/x86_64-pc-linux-gnu/lib/' '-isystem'
'/usr/local/x86_64-pc-linux-gnu/include' '-isystem'
'/usr/local/x86_64-pc-linux-gnu/sys-include' '-fomit-frame-pointer'
'-U' 'sun' '-v' '-g' '-O2' '-o' '.libs/jv-convert' '-shared-libgcc'
'-L/home/zopolis4/gcjbuild/x86_64-pc-linux-gnu/libjava/.libs'
'-L/home/zopolis4/gcjbuild/x86_64-pc-linux-gnu/libjava'
'-fbootclasspath=./:/usr/local/share/java/libgcj-13.0.0.jar'
'-specs=/home/zopolis4/gcjbuild/x86_64-pc-linux-gnu/libjava/libgcj.spec'
'-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir'
'.libs/jv-convert-' //here is the big differentiation point
 /home/zopolis4/gcjbuild/./gcc/jvgenmain
.libs/jv-convert-gnu.gcj.convert.Convertmain /tmp/ccomuP4d.i
COLLECT_GCC_OPTIONS='-B'
'/home/zopolis4/gcjbuild/x86_64-pc-linux-gnu/libjava/' '-B'
'/home/zopolis4/gcjbuild/./gcc/' '-B'
'/usr/local/x86_64-pc-linux-gnu/bin/' '-B'
'/usr/local/x86_64-pc-linux-gnu/lib/' '-isystem'
'/usr/local/x86_64-pc-linux-gnu/include' '-isystem'
'/usr/local/x86_64-pc-linux-gnu/sys-include' '-fomit-frame-pointer'
'-U' 'sun' '-v' '-g' '-O2' '-o' '.libs/jv-convert' '-shared-libgcc'
'-L/home/zopolis4/gcjbuild/x86_64-pc-linux-gnu/libjava/.libs'
'-L/home/zopolis4/gcjbuild/x86_64-pc-linux-gnu/libjava'
'-specs=/home/zopolis4/gcjbuild/x86_64-pc-linux-gnu/libjava/libgcj.spec'
'-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir'
'.libs/jv-convert-'
 /home/zopolis4/gcjbuild/./gcc/cc1 /tmp/ccomuP4d.i -quiet
-mtune=generic -march=x86-64 -g -O2 -imultiarch x86_64-linux-gnu
-iprefix /home/zopolis4/gcjbuild/gcc/../lib/gcc/x86_64-pc-linux-gnu/13.0.0/
-isystem /home/zopolis4/gcjbuild/x86_64-pc-linux-gnu/libjava/include
-isystem /home/zopolis4/gcjbuild/./gcc/include -isystem
/home/zopolis4/gcjbuild/./gcc/include-fixed/x86_64-linux-gnu -isystem
/home/zopolis4/gcjbuild/./gcc/include-fixed -version
-fomit-frame-pointer -fdollars-in-identifiers -o /tmp/ccG4mONV.s
GNU C17 (GCC) version 13.0.0 20221214 (experimental) (x86_64-pc-linux-gnu)
compiled by GNU C version 12.2.0, GMP version 6.2.1, MPFR

Re: Java front-end and library patches.

2022-12-14 Thread Zopolis0 via Gcc-patches
Patch 19 has been resolved.


Re: [PATCH 19/56] Revert "Move void_list_node init to common code". (8ff2a92a0450243e52d3299a13b30f208bafa7e0)

2022-12-14 Thread Zopolis0 via Gcc-patches
I had a look-- issue fixed, rough patch below. Full patch will be part of v2.

>From b0d93d8212328fabcbdb32c266c265a4eed49e00 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 15 Dec 2022 09:54:36 +1100
Subject: [PATCH] java: Adjustments to end_params_node and void_list_node.

gcc/java/ChangeLog:

* builtins.cc (initialize_builtins): Do not set void_list_node to
end_params_node.
* decl.cc (java_init_decl_processing): Set end_params_node to void_list_node.
---
 gcc/java/builtins.cc | 2 --
 gcc/java/decl.cc | 2 +-
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/gcc/java/builtins.cc b/gcc/java/builtins.cc
index 45d736a0d7b8..a882a5c4d521 100644
--- a/gcc/java/builtins.cc
+++ b/gcc/java/builtins.cc
@@ -499,8 +499,6 @@ initialize_builtins (void)
   java_builtins[i].method_name.t = m;
 }

-  void_list_node = end_params_node;
-
   float_ftype_float_float
 = build_function_type_list (float_type_node,
  float_type_node, float_type_node, NULL_TREE);
diff --git a/gcc/java/decl.cc b/gcc/java/decl.cc
index 6319d1ce18a0..018003104ced 100644
--- a/gcc/java/decl.cc
+++ b/gcc/java/decl.cc
@@ -957,7 +957,7 @@ java_init_decl_processing (void)
   build_decl (BUILTINS_LOCATION,
   TYPE_DECL, get_identifier ("Method"), method_type_node);

-  end_params_node = tree_cons (NULL_TREE, void_type_node, NULL_TREE);
+  end_params_node = void_list_node;

   t = build_function_type_list (ptr_type_node, class_ptr_type, NULL_TREE);
   alloc_object_node = add_builtin_function ("_Jv_AllocObject", t,


Re: Java front-end and library patches.

2022-12-11 Thread Zopolis0 via Gcc-patches
I've been looking over the reviews as well as a few things I've
encountered locally, and collected this list:

Unfortunately, I am simply not familiar enough with the gcc tree to
implement patch 16, although there is a slight possibility that I may
be able to do patch 19, and a stronger one that I could do patch 16.
(Although I have been working on patch 19 and 16 for a few months now
and with little success).

I can definitely do patch 53, and am working on that.

While patch 13, 16 and 19 are all sub-par solutions, they are
solutions, and as such implementing better solutions is a lower
priority than fixing the remaining issue, the -dumpbase caused linker
error. I would very much appreciate help in that area specifically, as
once that is solved we'll have a working compiler and library, and
then I can focus on improving the library.

(Patch 13) Re-add flag_evaluation_order, reorder_operands_p, and add
reorder bool argument to tree_swap_operands_p:
Replace with front-end specific function ala flag_strong_eval_order

(Patch 16) gcc: Re-add TYPE_METHODS:
Remove, replace instances of TYPE_METHODS with TYPE_FIELDS in the java frontend

(Patch 19) Revert "Move void_list_node init to common code".
(8ff2a92a0450243e52d3299a13b30f208bafa7e0):
Remove, handle properly in Java frontend.

Breakage caused by 1dedc12d186a110854537e1279b4e6c29f2df35a:
Changes to -dumpbase cause undefined link errors, fix usage of
-dumpbase in gcc/java/jvspec.cc

(Patch 53) classpath: Use modern autotools mkdir -p handling:
Find way to make MKDIR_P propagate to generated copy-vmresources.sh


Re: [PATCH 14/56] middle-end: Set TREE_ADDRESSABLE in folding debug stmts.

2022-12-06 Thread Zopolis0 via Gcc-patches
New plan-- this patch is entirely pointless! I have reverted it in a
local build and had no regressions.

As such, simply do not review or consider this patch. I am not not
planning on re-sending the patchset even though it adjusts the patch
numbers because it is such an arduous process given that gmail no
longer supports git send-email.


Re: Java front-end and library patches.

2022-12-06 Thread Zopolis0 via Gcc-patches
> Patches 1 and 2 don't seem to have reached the mailing list.

File size issues on the receiving server. I bzip3 compressed them, but
they were still too big.


Re: [PATCH 19/56] Revert "Move void_list_node init to common code". (8ff2a92a0450243e52d3299a13b30f208bafa7e0)

2022-12-02 Thread Zopolis0 via Gcc-patches
Ok, well following that logic it should work to just remove the
void_list_node definition that java uses, as per 8ff2a92. However, it
doesn't, so clearly java does something else to the end_params_node
definition that it shouldn't be, or something similar. I'll have a
look.


Re: Java front-end and library patches.

2022-12-01 Thread Zopolis0 via Gcc-patches
>  the "all in one go" approach that you seem to have attempted (?)

I did do all the patches in one go onto master, but for rebases and
bisects I did apply them on various baselines. See
https://github.com/Zopolis4/gcj-branches, where all the branches
labellled newplan/year-month-day will have these patches reapplied on
that date.

On Fri, Dec 2, 2022 at 11:24 AM Zopolis0  wrote:
>
> In response to the testing thing, one critical issue is that these
> patches aren't entirely functional (see the second point of my
> original message), so I can't test yet. I'll check once I can though.


Re: Java front-end and library patches.

2022-12-01 Thread Zopolis0 via Gcc-patches
In response to the testing thing, one critical issue is that these
patches aren't entirely functional (see the second point of my
original message), so I can't test yet. I'll check once I can though.


Re: [PATCH 19/56] Revert "Move void_list_node init to common code". (8ff2a92a0450243e52d3299a13b30f208bafa7e0)

2022-12-01 Thread Zopolis0 via Gcc-patches
> But that looks like the correct thing to do.

It's not. The patch I reverted changes it so that no matter what,
void_list_node = build_tree_list (NULL_TREE, void_type_node);.

Before, each front-end set it in their own way, but they all set it
via void_list_node = build_tree_list (NULL_TREE, void_type_node); or a
synonym anyway. So while the patch made sense in a java-free context,
given that java sets it a different way, I can't see a world in which
this commit stays active and Java works, unless we find a way to set
it in tree.cc for every language except Java.


Re: Java front-end and library patches.

2022-11-30 Thread Zopolis0 via Gcc-patches
> * Each patch should have its own explanation of what it is doing and why,
> in the message body (not in an attachment).  Just the commit summary line
> and ChangeLog entries aren't enough, we need the actual substantive commit
> message explaining the patch.

The thing is, most of the patches do not need an explanation. Patches
1-13 are just re-adding code, 20-43 and 47 are just applying treewide
changes that Java missed out on, and patches 44-56 are either
incredibly simple or self-evident. If you feel like any of the listed
patches require an explanation, let me know and I will provide one,
but for now I dont see a reason to explain those.

However, patches 14-19 do need an explanation, as proven by multiple
reviews simply asking why I had made them. I'll send follow up
messages to those.

> Why is it now considered useful to add this front end back?

The way I see it, the Java front end was removed due to a lack of
maintenance and improvement. To put it simply, I am going to maintain
and improve it. That is the difference between now and then. There is
more nuance, but that is the gist of it.

> Which version is the basis of the one being added back...?

The exact same one that was removed from GCC, with the version taken
being the one right before it was removed.

> How has the series been validated?

I'm not exactly sure what you mean by this.

> Would you propose to maintain the front end and libraries in future?

I have big plans for the library, and plan to maintain that long into
the future. In regards to the actual front-end code, I will do what I
can to make sure it remains at its previous level of function, but
that is about it. I dislike working with the front end code, so I will
fix it, but I will not make sweeping changes to it.

>  Would you re-open any bugs against the front end or libraries that were 
> closed...as a result of it being removed from the tree...?

Good point, I hadn't thought of that. It makes sense to re-open them,
as they are by definition valid again, although I may have difficulty
with the frontend ones, as that is not my strong suit.




Just a brief overview of my plans for the frontend and library-- When
GCJ was first introduced it was "the free Java implementation". It was
trying to offer a bytecode compiler, a machine code compiler and a
runtime library. Clearly, this was too much, as it borrowed another
bytecode compiler and runtime library, and even then the runtime
library fell into dissaray.

Now, we have many pieces of the puzzle. We have a bounty of free Java
bytecode compilers, and a free runtime library. The only thing missing
is a free machine code compiler, which GCJ was and is. I plan to
replace Classpath with the OpenJDK, and double down on the machine
code aspect of GCJ, dropping bytecode and interpreted support.


Re: [PATCH 19/56] Revert "Move void_list_node init to common code". (8ff2a92a0450243e52d3299a13b30f208bafa7e0)

2022-11-26 Thread Zopolis0 via Gcc-patches
> What happens if you remove end_params_node from the Java front-end and
> replace it with void_list_node?

Sadly, nothing.


Re: [PATCH 16/56] gcc: Re-add TYPE_METHODS.

2022-11-26 Thread Zopolis0 via Gcc-patches
> No.  Java was removed to reduce the maintenance burden, you can't just
> reintroduce the burden and say "hey, I don't want to pay for the burden
> so you please do it".

There were two sentences there. You appear to only have read the first one.

I just took on 6 years of that maintenance burden in 4 months while
teaching myself the gcc tree.
I can confirm with absolute certainty that the burden would have been
pitiful had java been in the tree. Many of the changes were just
idiomatic find and replaces that I had to do myself, tracking down the
commit that removed or renamed something, in some cases just silently
breaking things so I had to bisect 6 years of changes. If Java had
been in the tree, it would have introduced a pitiful additional
burden. I can think of around 5 changes that I made that would have
required something more than just a sed script, and even then those
were very simple changes.

I am not suggesting that I wish to shift the overall burden of
maintenance away from myself, rather that it would be nice if I did
not have to track down breaking commits every 3 months, when the
author could have very easily included Java in the changes if it was
in the tree.

> And we are in stage 3 now so it's not possible to merge 50+ patches
> (completely not reviewed in stage 1) until GCC 14 stage 1 opens.

On a lighter note, this is fair. I was hoping to make the stage 1
window, but with 2 front-ends already in contention I thought my odds
of making it in regardless were poor, and I just didn't have the time
to fix the last issues.

I've sent these patches now so they can get reviewed now, so that they
aren't waiting in review limbo when merging is open again.


Re: [PATCH 19/56] Revert "Move void_list_node init to common code". (8ff2a92a0450243e52d3299a13b30f208bafa7e0)

2022-11-25 Thread Zopolis0 via Gcc-patches
> How does the Java FE initialize void_list_node?
https://github.com/Zopolis4/gcj/blob/master/gcc/java/builtins.cc#L503
```
void_list_node = end_params_node;
```

end_params_node is defined a couple times around the Java frontend,
not sure which definition it is using.


Re: [PATCH 16/56] gcc: Re-add TYPE_METHODS.

2022-11-25 Thread Zopolis0 via Gcc-patches
> TYPE_METHODS uses the field used by TYPE_BINFO so the patches are related.

As the person who wrote the patches, I can confirm that they are not
in fact related. Or, at least, they fix different issues and have no
reliance upon each other. If you mean related as in they both contain
RECORD_OR_UNION_CHECK, sure, but even then they are two very different
patches, with one being a temporary stopgap and the other being a
thought-through change that solves a large issue with minimal addition
and leaves existing functionality intact.

> Re-adding a field to all types is a no-go

To be entirely honest, my current priority is simply to get this
merged so I can spend less time keeping up with upstream changes
breaking everything and spend more time actually improving things. The
additional labour cost for the maintainer who is making the change and
understands it deeply is much less than what it takes for me to bisect
the issue, find the commit, understand it and fix the issue.

>From my point of view, temporarily re-adding a grand total of two
lines is worth that goal.
If you consider this a large enough issue that you won't accept that,
then let me know so we don't dance around the issue and I can get on
with solving the issue.


Re: [PATCH 16/56] gcc: Re-add TYPE_METHODS.

2022-11-25 Thread Zopolis0 via Gcc-patches
Oh wait wrong patch. You talking about binfo confused me.

Anyways, I re-added this because replacing Java's usage of
TYPE_METHODS with TYPE_FIELDS even when I properly checked for
different types of functions still broke things, so I added this as a
stopgap.

No idea what you are talking about with binfo though, I added binfo
for the reasons you can see in the email above, nothing to do with
TYPE_METHODS.

On Sat, Nov 26, 2022 at 11:16 AM Zopolis0  wrote:
>
> Because the frontend uses TYPE_BINFO specifically. It expects a TYPE_BINFO 
> that writes to this value, and will break with replacements. I have tried a 
> number of alternatives, and this is what works.
>
> I can't use lang_1 because other frontends use it in ways that java doesn't 
> expect and I can't create a replacement for TYPE_BINFO because then it won't 
> have the regular checks that TYPE_BINFO has.
>
> I couldn't find a better solution because I'm not particularly versed with 
> the internal workings of gcc, if you can think of a better idea feel free to 
> let me know.
>
> On Sat, 26 Nov 2022 at 07:20, Richard Biener  
> wrote:
>>
>> On Fri, Nov 25, 2022 at 9:55 AM Zopolis0 via Gcc-patches
>>  wrote:
>> >
>>
>> Why add this when nothing uses it and you need to re-add binfo because
>> of this?  If the frontend uses
>> it then add it to lang_type.


Re: [PATCH 19/56] Revert "Move void_list_node init to common code". (8ff2a92a0450243e52d3299a13b30f208bafa7e0)

2022-11-25 Thread Zopolis0 via Gcc-patches
Because if I don't, all java files break:

/bin/bash ./libtool  --tag=GCJ   --mode=compile
/home/zopolis4/trustme/./gcc/gcj
-B/home/zopolis4/trustme/x86_64-pc-linux-gnu/libjava/
-B/home/zopolis4/trustme/./gcc/ -B/usr/local/x86_64-pc-linux-gnu/bin/
-B/usr/local/x86_64-pc-linux-gnu/lib/ -isystem
/usr/local/x86_64-pc-linux-gnu/include -isystem
/usr/local/x86_64-pc-linux-gnu/sys-include-fomit-frame-pointer
-Usun -fclasspath=
-fbootclasspath=/home/zopolis4/trustme/../gcj/libjava/classpath/lib
--encoding=UTF-8 -Wno-deprecated -fbootstrap-classes -g -O2 -c -o
java/lang/Object.lo
-fsource-filename=/home/zopolis4/trustme/../gcj/libjava/java/lang/Object.java
/home/zopolis4/trustme/../gcj/libjava/classpath/lib/java/lang/Object.class
libtool: compile:  /home/zopolis4/trustme/./gcc/gcj
-B/home/zopolis4/trustme/x86_64-pc-linux-gnu/libjava/
-B/home/zopolis4/trustme/./gcc/ -B/usr/local/x86_64-pc-linux-gnu/bin/
-B/usr/local/x86_64-pc-linux-gnu/lib/ -isystem
/usr/local/x86_64-pc-linux-gnu/include -isystem
/usr/local/x86_64-pc-linux-gnu/sys-include -fomit-frame-pointer -Usun
-fclasspath= -fbootclasspath=/home/zopolis4/trustme/../gcj/libjava/classpath/lib
--encoding=UTF-8 -Wno-deprecated -fbootstrap-classes -g -O2 -c
-fsource-filename=/home/zopolis4/trustme/../gcj/libjava/java/lang/Object.java
/home/zopolis4/trustme/../gcj/libjava/classpath/lib/java/lang/Object.class
 -fPIC -o java/lang/.libs/Object.o
/home/zopolis4/trustme/../gcj/libjava/java/lang/Object.java: In class
'java.lang.Object':
/home/zopolis4/trustme/../gcj/libjava/java/lang/Object.java: In method
'java.lang.Object.finalize(void)':
In file included from :63:
/home/zopolis4/trustme/../gcj/libjava/java/lang/Object.java:119:
internal compiler error: in start_java_method, at java/decl.cc:1779
  119 |   }
  |
0x662bca start_java_method(tree_node*)
/home/zopolis4/trustme/../gcj/gcc/java/decl.cc:1779
0x862829 parse_class_file
/home/zopolis4/trustme/../gcj/gcc/java/jcf-parse.cc:1634
0x8630ed java_parse_file()
/home/zopolis4/trustme/../gcj/gcc/java/jcf-parse.cc:1970
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
make[3]: *** [Makefile:10643: java/lang/Object.lo] Error 1
make[3]: Leaving directory '/home/zopolis4/trustme/x86_64-pc-linux-gnu/libjava'
make[2]: *** [Makefile:10265: all-recursive] Error 1
make[2]: Leaving directory '/home/zopolis4/trustme/x86_64-pc-linux-gnu/libjava'
make[1]: *** [Makefile:15471: all-target-libjava] Error 2
make[1]: Leaving directory '/home/zopolis4/trustme'
make: *** [Makefile:1016: all] Error 2

I asked about this in
https://gcc.gnu.org/pipermail/gcc-help/2022-November/141981.html, but
got no response, so I reverted the commit.

On Sat, Nov 26, 2022 at 7:17 AM Richard Biener
 wrote:
>
> On Fri, Nov 25, 2022 at 9:46 AM Zopolis0 via Gcc-patches
>  wrote:
> >
>
> Why?!


Re: [PATCH 14/56] middle-end: Set TREE_ADDRESSABLE in folding debug stmts.

2022-11-25 Thread Zopolis0 via Gcc-patches
I was reverting a076632e274abe344ca7648b7c7f299273d4cbe0 as it removed code
for Java, but I may have misunderstood the change and made the incorrect
edits.

On Sat, 26 Nov 2022 at 07:16, Richard Biener 
wrote:

> On Fri, Nov 25, 2022 at 9:43 AM Zopolis0 via Gcc-patches
>  wrote:
> >
>
> That's wrong and the comment you remove explains why.
>


Re: [PATCH 16/56] gcc: Re-add TYPE_METHODS.

2022-11-25 Thread Zopolis0 via Gcc-patches
Because the frontend uses TYPE_BINFO specifically. It expects a TYPE_BINFO
that writes to this value, and will break with replacements. I have tried a
number of alternatives, and this is what works.

I can't use lang_1 because other frontends use it in ways that java doesn't
expect and I can't create a replacement for TYPE_BINFO because then it
won't have the regular checks that TYPE_BINFO has.

I couldn't find a better solution because I'm not particularly versed with
the internal workings of gcc, if you can think of a better idea feel free
to let me know.

On Sat, 26 Nov 2022 at 07:20, Richard Biener 
wrote:

> On Fri, Nov 25, 2022 at 9:55 AM Zopolis0 via Gcc-patches
>  wrote:
> >
>
> Why add this when nothing uses it and you need to re-add binfo because
> of this?  If the frontend uses
> it then add it to lang_type.
>


[PATCH 56/56] java, libjava: Upgrade from in-tree boehm-gc to external boehm-gc 8.3.0.

2022-11-25 Thread Zopolis0 via Gcc-patches

From a267b06e1e2ef0cd7da0b8d418c348c51b4904e7 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 25 Nov 2022 17:05:30 +1100
Subject: [PATCH 56/56] java, libjava: Upgrade from in-tree boehm-gc to
 external boehm-gc 8.3.0.

gcc/java/ChangeLog:

	* boehm.cc (get_boehm_type_descriptor): Remove check for flag_use_boehm_gc.
	(uses_jv_markobj_p): Remove flag_use_boehm_gc assert.
	* jvspec.cc: Remove fuse-boehm-gc.
	* lang.opt: Likewise.

libjava/ChangeLog:

	* boehm.cc (GC_REDIRECT_TO_LOCAL): Include gc/gc.h instead of gc_local_alloc.h.
	(_Jv_SetGCFreeSpaceDivisor): Use GC_get_free_space_divisor to get old_div (before GC_set_free_space_divisor call).
	(_Jv_InitGC): Use GC_set variants of functions.
	(_Jv_GCInitializeFinalizers): Likewise.
	* configure.ac: Replace in-tree check with external checks from libobjc, check that found version is modern enough.
	* gnu/gcj/util/natGCInfo.cc (PACKAGE_NAME): Remove.
	(PACKAGE_STRING): Likewise.
	(PACKAGE_TARNAME): Likewise.
	(PACKAGE_VERSION): Likewise.
	(TRUE): Likewise.
	(FALSE): Likewise.
	(GC_print_debug_callback): Replace GC_n_set_marks with public functions.
	(struct print_hblkfl_s): Add.
	(UNIQUE_THRESHOLD): Remove.
	(HUGE_THRESHOLD): Likewise.
	(FL_COMPRESSION): Likewise.
	(N_HBLK_FLS): Likewise.
	(print_hblkfl_file_item): Add.
	(IS_MAPPED): Remove.
	(GC_print_hblkfreelist_file): Handle lack of HDR macro.
	(GC_print_debug_info_file): Use GC_word instead of word, handle lack of struct hblkhdr.
	(GC_enumerator::enumerate): Use GC_word instead of word.
	(GC_enumerator::enumerate_callback_adaptor): Use GC_word instead of word, handle lack of struct hblkhdr.
	(GC_enumerator::enumerate_callback): Handle lack of HDR macro.
	* include/boehm-gc.h: Include gc/gc.h instead of gc_ext_config.h, adjust comment accordingly.
	* libgcj.spec.in: Remove GCSPEC and JC1GCSPEC.
	* Makefile.in: Reconfigure.
	* configure: Likewise.
	* gcj/Makefile.in: Likewise.
	* include/Makefile.in: Likewise.
	* include/config.h.in: Likewise.
	* testsuite/Makefile.in: Likewise.

Co-authored-by: Ivan Maidanski 
---
 gcc/java/boehm.cc |   6 -
 gcc/java/jvspec.cc|   2 +-
 gcc/java/lang.opt |   4 -
 libjava/Makefile.in   |   4 -
 libjava/boehm.cc  |  24 +--
 libjava/configure | 309 +-
 libjava/configure.ac  | 202 +++
 libjava/gcj/Makefile.in   |   4 -
 libjava/gnu/gcj/util/natGCInfo.cc | 171 +
 libjava/include/Makefile.in   |   4 -
 libjava/include/boehm-gc.h|   5 +-
 libjava/include/config.h.in   |   3 +
 libjava/libgcj.spec.in|   4 +-
 libjava/testsuite/Makefile.in |   4 -
 14 files changed, 501 insertions(+), 245 deletions(-)

diff --git a/gcc/java/boehm.cc b/gcc/java/boehm.cc
index 38a2131e6f8..5859f038998 100644
--- a/gcc/java/boehm.cc
+++ b/gcc/java/boehm.cc
@@ -136,10 +136,6 @@ get_boehm_type_descriptor (tree type)
   int pointer_after_end = 0;
   tree field, value, value_type;
 
-  /* If the GC wasn't requested, just use a null pointer.  */
-  if (! flag_use_boehm_gc)
-return null_pointer_node;
-
   value_type = java_type_for_mode (ptr_mode, 1);
   wide_int mask = wi::zero (TYPE_PRECISION (value_type));
 
@@ -223,8 +219,6 @@ bool
 uses_jv_markobj_p (tree dtable)
 {
   tree v;
-  /* FIXME: what do we return if !flag_use_boehm_gc ? */
-  gcc_assert (flag_use_boehm_gc);
   /* FIXME: this is wrong if TARGET_VTABLE_USES_DESCRIPTORS.  However,
  this function is only used with flag_reduced_reflection.  No
  point in asserting unless we hit the bad case.  */
diff --git a/gcc/java/jvspec.cc b/gcc/java/jvspec.cc
index 58142368621..3786926e8d9 100644
--- a/gcc/java/jvspec.cc
+++ b/gcc/java/jvspec.cc
@@ -66,7 +66,7 @@ static const char jvgenmain_spec[] =
 		   %
-
 // Set GC_DEBUG before including gc.h!
 #ifdef LIBGCJ_GC_DEBUG
 # define GC_DEBUG
 #endif
 
-#include 
-#include 
-#include   // GC_finalize_all declaration.  
+#include 
+#include 
+#include   // GC_finalize_all declaration.
 
 #ifdef THREAD_LOCAL_ALLOC
 # define GC_REDIRECT_TO_LOCAL
-# include 
+# include 
 #endif
 
   // From boehm's misc.c 
@@ -468,7 +466,9 @@ _Jv_GCSetMaximumHeapSize (size_t size)
 int
 _Jv_SetGCFreeSpaceDivisor (int div)
 {
-  return (int)GC_set_free_space_divisor ((GC_word)div);
+  int old_div = (int)GC_get_free_space_divisor ();
+  GC_set_free_space_divisor ((GC_word)div);
+  return old_div;
 }
 
 void
@@ -523,7 +523,7 @@ _Jv_InitGC (void)
   gc_initialized = 1;
 
   // Ignore pointers that do not point to the start of an object.
-  GC_all_interior_pointers = 0;
+  GC_set_all_interior_pointers(0);
 
 #if defined (HAVE_DLFCN_H) && defined (HAVE_DLADDR)
   // Tell the collector to ask us before scanning DSOs.
@@ -538,9 +538,9 @@ _Jv_InitGC (void)
 
   // Cause an out of memory error to be thrown from the allocators,
   // instead of returning 0.  This is cheaper than checking on allocation.
-  

[PATCH 53/56] classpath: Use modern autotools mkdir -p handling.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 6cddfc752e14a4e8084e62dc03872411ee7493df Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 25 Nov 2022 16:35:31 +1100
Subject: [PATCH 53/56] classpath: Use modern autotools mkdir -p handling.

libjava/classpath/ChangeLog:

	* configure.ac: Add AC_PROG_MKDIR_P call, replace @mkdir_p@ with $(MKDIR_P).
	* configure: Reconfigure.
	* lib/Makefile.am: Replace @mkdir_p@ with $(MKDIR_P).
	* lib/Makefile.in: Reconfigure.
	* lib/copy-vmresources.sh.in: Replace @mkdir_p@ with $(MKDIR_P).
---
 libjava/classpath/configure  | 10 ++
 libjava/classpath/configure.ac   |  2 ++
 libjava/classpath/lib/Makefile.am| 10 +-
 libjava/classpath/lib/Makefile.in| 10 +-
 libjava/classpath/lib/copy-vmresources.sh.in |  4 ++--
 5 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/libjava/classpath/configure b/libjava/classpath/configure
index 8214e1ba7cd..dbde6463c94 100755
--- a/libjava/classpath/configure
+++ b/libjava/classpath/configure
@@ -24338,6 +24338,8 @@ fi
 
 
 
+
+
 # Extract the first word of "find", so it can be a program name with args.
 set dummy find; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
@@ -25559,7 +25561,7 @@ else
 JAVA_TEST=Object.java
 CLASS_TEST=Object.class
 cat << \EOF > $JAVA_TEST
-/* #line 25562 "configure" */
+/* #line 25564 "configure" */
 package java.lang;
 
 public class Object
@@ -25652,7 +25654,7 @@ EOF
 if uudecode$EXEEXT Test.uue; then
 ac_cv_prog_uudecode_base64=yes
 else
-echo "configure: 25655: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
+echo "configure: 25657: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
 echo "configure: failed file was:" >&5
 cat Test.uue >&5
 ac_cv_prog_uudecode_base64=no
@@ -25680,7 +25682,7 @@ JAVA_TEST=Test.java
 CLASS_TEST=Test.class
 TEST=Test
 cat << \EOF > $JAVA_TEST
-/* [#]line 25683 "configure" */
+/* [#]line 25685 "configure" */
 public class Test {
 public static void main (String args[]) {
 System.exit (0);
@@ -25888,7 +25890,7 @@ if test "x${use_glibj_zip}" = xfalse || \
   JAVA_TEST=Test.java
   CLASS_TEST=Test.class
   cat << \EOF > $JAVA_TEST
-  /* #line 25891 "configure" */
+  /* #line 25893 "configure" */
   public class Test
   {
 public static void main(String args)
diff --git a/libjava/classpath/configure.ac b/libjava/classpath/configure.ac
index 2079fd2121b..40439f594dc 100644
--- a/libjava/classpath/configure.ac
+++ b/libjava/classpath/configure.ac
@@ -1008,6 +1008,8 @@ AC_PATH_PROG(MKDIR, mkdir)
 AC_PATH_PROG(CP, cp)
 AC_PATH_PROG(DATE, date)
 
+AC_PROG_MKDIR_P
+
 dnl ---
 dnl According to the GNU coding guide, we shouldn't require find, 
 dnl and zip, however GNU provides both so it should be okay 
diff --git a/libjava/classpath/lib/Makefile.am b/libjava/classpath/lib/Makefile.am
index 2d47009f459..2f9e32ae98c 100644
--- a/libjava/classpath/lib/Makefile.am
+++ b/libjava/classpath/lib/Makefile.am
@@ -86,18 +86,18 @@ endif # USE_PREBUILT_GLIBJ_ZIP
 resources: copy-vmresources.sh
 	@list=`cd $(top_srcdir)/resource && $(FIND) gnu java javax org -name \*\.properties -print -o -name \*\.css -print`; for p in $$list; do \
   dirname=`dirname $$p`; \
-  if ! test -d "$$dirname"; then @mkdir_p@ "$$dirname"; fi; \
+  if ! test -d "$$dirname"; then $(MKDIR_P) "$$dirname"; fi; \
 	  cp $(top_srcdir)/resource/$$p $$p; \
 	done
 	@list=`cd $(top_srcdir)/resource && $(FIND) META-INF -name CVS -prune -o -name .svn -prune -o -name \*\.in -prune -o -type f -print`; for p in $$list; do \
   dirname=`dirname $$p`; \
-  if ! test -d "$$dirname"; then @mkdir_p@ "$$dirname"; fi; \
+  if ! test -d "$$dirname"; then $(MKDIR_P) "$$dirname"; fi; \
 	  cp $(top_srcdir)/resource/$$p $$p; \
 	done
 	@$(SHELL) ./copy-vmresources.sh
 	@list=`cd $(top_srcdir) && $(FIND) gnu/javax/swing/plaf/gtk/icons -name *.png -type f -print`; for p in $$list; do \
   dirname=`dirname $$p`; \
-  if ! test -d "$$dirname"; then @mkdir_p@ "$$dirname"; fi; \
+  if ! test -d "$$dirname"; then $(MKDIR_P) "$$dirname"; fi; \
 	  cp $(top_srcdir)/$$p $$p; \
 	done
 	touch resources
@@ -105,7 +105,7 @@ resources: copy-vmresources.sh
 classes: genclasses
 
 $(top_builddir)/gnu/java/locale/LocaleData.java: $(top_srcdir)/scripts/generate-locale-list.sh 
-	@mkdir_p@ $(top_builddir)/gnu/java/locale
+	$(MKDIR_P) $(top_builddir)/gnu/java/locale
 	$(top_srcdir)/scripts/generate-locale-list.sh > $(top_builddir)/gnu/java/locale/LocaleData.java
 
 genclasses: gen-classlist.sh standard.omit $(top_builddir)/gnu/java/locale/LocaleData.java gen-xpath-parser
@@ -165,7 +165,7 @@ clean-local:
 	-rm -rf lists
 
 dist-hook:
-	@mkdir_p@ $(distdir)
+	$(MKDIR_P) $(distdir)
 	cp -pdfR $(top_srcdir)/gnu $(top_srcdir)/java $(top_srcdir)/javax $(top_srcdir)/org 

[PATCH 50/56] libjava: Replace AC_LANG_PROGRAM with AC_LANG_SOURCE.

2022-11-25 Thread Zopolis0 via Gcc-patches

From a1a703a9e118ed76cace8165d8ed3e5ec88c6477 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 19:37:56 +1100
Subject: [PATCH 50/56] libjava: Replace AC_LANG_PROGRAM with AC_LANG_SOURCE.

libjava/classpath/ChangeLog:

	* configure.ac: Replace AC_LANG_PROGRAM with AC_LANG_SOURCE.
	* configure: Regenerate.

libjava/ChangeLog:

	* configure.ac: Replace AC_LANG_PROGRAM with AC_LANG_SOURCE, add additional AC_LANG_SOURCE call.
	* configure: Regenerate.
---
 libjava/classpath/configure|  57 ++---
 libjava/classpath/configure.ac |  14 ++---
 libjava/configure  | 109 +
 libjava/configure.ac   |  34 +-
 4 files changed, 46 insertions(+), 168 deletions(-)

diff --git a/libjava/classpath/configure b/libjava/classpath/configure
index 091d96058f8..12ef419fa6b 100755
--- a/libjava/classpath/configure
+++ b/libjava/classpath/configure
@@ -17613,13 +17613,6 @@ $as_echo_n "checking whether struct sockaddr_in6 is in netinet/in.h... " >&6; }
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include 
-int
-main ()
-{
-struct sockaddr_in6 addr6;
-  ;
-  return 0;
-}
 _ACEOF
 if ac_fn_c_try_compile "$LINENO"; then :
 
@@ -17779,13 +17772,6 @@ $as_echo_n "checking for tm_gmtoff in struct tm... " >&6; }
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include 
-int
-main ()
-{
-struct tm tim; tim.tm_gmtoff = 0;
-  ;
-  return 0;
-}
 _ACEOF
 if ac_fn_c_try_compile "$LINENO"; then :
 
@@ -17801,13 +17787,6 @@ $as_echo_n "checking for global timezone variable... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include 
-int
-main ()
-{
-void i(){long z2 = 2*timezone;}
-  ;
-  return 0;
-}
 _ACEOF
 if ac_fn_c_try_compile "$LINENO"; then :
 
@@ -17823,13 +17802,6 @@ $as_echo_n "checking for global _timezone variable... " >&6; }
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include 
-int
-main ()
-{
-long z2 = _timezone;
-  ;
-  return 0;
-}
 _ACEOF
 if ac_fn_c_try_compile "$LINENO"; then :
 
@@ -22205,13 +22177,6 @@ $as_echo_n "checking for MSG_NOSIGNAL... " >&6; }
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include 
-int
-main ()
-{
- int f = MSG_NOSIGNAL;
-  ;
-  return 0;
-}
 _ACEOF
 if ac_fn_c_try_compile "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
@@ -22230,13 +22195,6 @@ $as_echo_n "checking for SO_NOSIGPIPE ... " >&6; }
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include 
-int
-main ()
-{
- int f = SO_NOSIGPIPE;
-  ;
-  return 0;
-}
 _ACEOF
 if ac_fn_c_try_compile "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
@@ -22255,13 +22213,6 @@ $as_echo_n "checking for MSG_WAITALL... " >&6; }
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include 
-int
-main ()
-{
- int f = MSG_WAITALL;
-  ;
-  return 0;
-}
 _ACEOF
 if ac_fn_c_try_compile "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
@@ -25591,7 +25542,7 @@ else
 JAVA_TEST=Object.java
 CLASS_TEST=Object.class
 cat << \EOF > $JAVA_TEST
-/* #line 25594 "configure" */
+/* #line 25545 "configure" */
 package java.lang;
 
 public class Object
@@ -25684,7 +25635,7 @@ EOF
 if uudecode$EXEEXT Test.uue; then
 ac_cv_prog_uudecode_base64=yes
 else
-echo "configure: 25687: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
+echo "configure: 25638: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
 echo "configure: failed file was:" >&5
 cat Test.uue >&5
 ac_cv_prog_uudecode_base64=no
@@ -25712,7 +25663,7 @@ JAVA_TEST=Test.java
 CLASS_TEST=Test.class
 TEST=Test
 cat << \EOF > $JAVA_TEST
-/* [#]line 25715 "configure" */
+/* [#]line 25666 "configure" */
 public class Test {
 public static void main (String args[]) {
 System.exit (0);
@@ -25920,7 +25871,7 @@ if test "x${use_glibj_zip}" = xfalse || \
   JAVA_TEST=Test.java
   CLASS_TEST=Test.class
   cat << \EOF > $JAVA_TEST
-  /* #line 25923 "configure" */
+  /* #line 25874 "configure" */
   public class Test
   {
 public static void main(String args)
diff --git a/libjava/classpath/configure.ac b/libjava/classpath/configure.ac
index 95c7b599297..77ed70300e9 100644
--- a/libjava/classpath/configure.ac
+++ b/libjava/classpath/configure.ac
@@ -532,7 +532,7 @@ if test "x${COMPILE_JNI}" = xyes; then
   AC_SUBST(LIBMAGIC)
 
   AC_MSG_CHECKING([whether struct sockaddr_in6 is in netinet/in.h])
-  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[struct sockaddr_in6 addr6;]])],
+  AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include ]], [[struct sockaddr_in6 addr6;]])],
 [AC_DEFINE(HAVE_INET6, 1,
  [Define if inet6 structures are defined in netinet/in.h.])
  AC_MSG_RESULT(yes)],
@@ -543,7 +543,7 @@ if test 

[PATCH 48/56] classpath: Rename documentation files from .texinfo to .texi.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 971906a595876549c0a2e3ecefa38aac6efaf487 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 19:09:27 +1100
Subject: [PATCH 48/56] classpath: Rename documentation files from .texinfo to
 .texi.

libjava/classpath/ChangeLog:

	* doc/Makefile.am: Rename documentation files from .texinfo to .texi.
	* doc/cp-hacking.texinfo: Moved to...
	* doc/cp-hacking.texi: ...here.
	* doc/cp-tools.texinfo: Moved to...
	* doc/cp-tools.texi: ...here.
	* doc/cp-vmintegration.texinfo: Moved to...
	* doc/cp-vmintegration.texi: ...here.
---
 libjava/classpath/doc/Makefile.am | 32 +--
 .../{cp-hacking.texinfo => cp-hacking.texi}   |  0
 .../doc/{cp-tools.texinfo => cp-tools.texi}   |  0
 ...egration.texinfo => cp-vmintegration.texi} |  0
 4 files changed, 16 insertions(+), 16 deletions(-)
 rename libjava/classpath/doc/{cp-hacking.texinfo => cp-hacking.texi} (100%)
 rename libjava/classpath/doc/{cp-tools.texinfo => cp-tools.texi} (100%)
 rename libjava/classpath/doc/{cp-vmintegration.texinfo => cp-vmintegration.texi} (100%)

diff --git a/libjava/classpath/doc/Makefile.am b/libjava/classpath/doc/Makefile.am
index 27a378d07be..27ea7c00a95 100644
--- a/libjava/classpath/doc/Makefile.am
+++ b/libjava/classpath/doc/Makefile.am
@@ -3,12 +3,12 @@ SUBDIRS = api
 EXTRA_DIST = README.jaxp texi2pod.pl $(man_MANS)
 
 ## GCJ LOCAL: we don't want to install all of Classpath's info files.
-## info_TEXINFOS = cp-hacking.texinfo cp-vmintegration.texinfo cp-tools.texinfo
+## info_TEXINFOS = cp-hacking.texi cp-vmintegration.texi cp-tools.texi
 TEXINFO_TEX = ../../gcc/doc/include/texinfo.tex
-info_TEXINFOS = cp-tools.texinfo
+info_TEXINFOS = cp-tools.texi
 
 # POSIX locale necessary to make grep work; see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=586134
-.texinfo.dvi:
+.texi.dvi:
 	LC_ALL=POSIX texi2dvi --build-dir=$(builddir) -o $@ $<
 
 .dvi.ps:
@@ -46,47 +46,47 @@ STAMP = echo timestamp >
 	gkeytool.pod gnative2ascii.pod gorbd.pod grmid.pod grmiregistry.pod \
 	gserialver.pod gtnameserv.pod gcjh.pod gjdoc.pod
 
-gappletviewer.pod: $(srcdir)/cp-tools.texinfo
+gappletviewer.pod: $(srcdir)/cp-tools.texi
 	-$(TEXI2POD) -D gappletviewer < $< > $@
 
-gjarsigner.pod: $(srcdir)/cp-tools.texinfo
+gjarsigner.pod: $(srcdir)/cp-tools.texi
 	-$(TEXI2POD) -D gjarsigner < $< > $@
 
-gjar.pod: $(srcdir)/cp-tools.texinfo
+gjar.pod: $(srcdir)/cp-tools.texi
 	-$(TEXI2POD) -D gjar < $< > $@
 
-gcjh.pod: $(srcdir)/cp-tools.texinfo
+gcjh.pod: $(srcdir)/cp-tools.texi
 	-$(TEXI2POD) -D gcjh < $< > $@
 
-gjavah.pod: $(srcdir)/cp-tools.texinfo
+gjavah.pod: $(srcdir)/cp-tools.texi
 	-$(TEXI2POD) -D gjavah < $< > $@
 
 # hack around the cross references and the enumeration
-gkeytool.pod: $(srcdir)/cp-tools.texinfo
+gkeytool.pod: $(srcdir)/cp-tools.texi
 	-$(TEXI2POD) -D gkeytool < $< \
 	  | sed -e 's/^For more details.*/See I for more details./' \
 	-e 's/1\.<\([^>]*\)>/- \1/' \
 		> $@
 
-gnative2ascii.pod: $(srcdir)/cp-tools.texinfo
+gnative2ascii.pod: $(srcdir)/cp-tools.texi
 	-$(TEXI2POD) -D gnative2ascii < $< > $@
 
-gorbd.pod: $(srcdir)/cp-tools.texinfo
+gorbd.pod: $(srcdir)/cp-tools.texi
 	-$(TEXI2POD) -D gorbd < $< > $@
 
-grmid.pod: $(srcdir)/cp-tools.texinfo
+grmid.pod: $(srcdir)/cp-tools.texi
 	-$(TEXI2POD) -D grmid < $< > $@
 
-grmiregistry.pod: $(srcdir)/cp-tools.texinfo
+grmiregistry.pod: $(srcdir)/cp-tools.texi
 	-$(TEXI2POD) -D grmiregistry < $< > $@
 
-gserialver.pod: $(srcdir)/cp-tools.texinfo
+gserialver.pod: $(srcdir)/cp-tools.texi
 	-$(TEXI2POD) -D gserialver < $< > $@
 
-gtnameserv.pod: $(srcdir)/cp-tools.texinfo
+gtnameserv.pod: $(srcdir)/cp-tools.texi
 	-$(TEXI2POD) -D gtnameserv < $< > $@
 
-gjdoc.pod: $(srcdir)/cp-tools.texinfo
+gjdoc.pod: $(srcdir)/cp-tools.texi
 	-$(TEXI2POD) -D gjdoc < $< > $@
 
 # GCJ LOCAL CHANGE
diff --git a/libjava/classpath/doc/cp-hacking.texinfo b/libjava/classpath/doc/cp-hacking.texi
similarity index 100%
rename from libjava/classpath/doc/cp-hacking.texinfo
rename to libjava/classpath/doc/cp-hacking.texi
diff --git a/libjava/classpath/doc/cp-tools.texinfo b/libjava/classpath/doc/cp-tools.texi
similarity index 100%
rename from libjava/classpath/doc/cp-tools.texinfo
rename to libjava/classpath/doc/cp-tools.texi
diff --git a/libjava/classpath/doc/cp-vmintegration.texinfo b/libjava/classpath/doc/cp-vmintegration.texi
similarity index 100%
rename from libjava/classpath/doc/cp-vmintegration.texinfo
rename to libjava/classpath/doc/cp-vmintegration.texi
-- 
2.38.1



[PATCH 49/56] libjava: Move to autoconf 2.69, automake 1.15.

2022-11-25 Thread Zopolis0 via Gcc-patches
libjava/classpath/ChangeLog:

* configure.ac: Remove autoconf2.64 prerequisite.
* Makefile.in: Regenerate.
* aclocal.m4: Likewise.
* configure: Likewise.
* doc/Makefile.in: Likewise.
* doc/api/Makefile.in: Likewise.
* examples/Makefile.in: Likewise.
* external/Makefile.in: Likewise.
* external/jsr166/Makefile.in: Likewise.
* external/relaxngDatatype/Makefile.in: Likewise.
* external/sax/Makefile.in: Likewise.
* external/w3c_dom/Makefile.in: Likewise.
* include/Makefile.in: Likewise.
* include/config.h.in: Likewise.
* lib/Makefile.in: Likewise.
* native/Makefile.in: Likewise.
* native/fdlibm/Makefile.in: Likewise.
* native/jawt/Makefile.in: Likewise.
* native/jni/Makefile.in: Likewise.
* native/jni/Makefile.in: Likewise.
* native/jni/gconf-peer/Makefile.in: Likewise.
* native/jni/gstreamer-peer/Makefile.in: Likewise.
* native/jni/gtk-peer/Makefile.in: Likewise.
* native/jni/java-io/Makefile.in: Likewise.
* native/jni/java-lang/Makefile.in: Likewise.
* native/jni/java-math/Makefile.in: Likewise.
* native/jni/java-net/Makefile.in: Likewise.
* native/jni/java-nio/Makefile.in: Likewise.
* native/jni/java-util/Makefile.in: Likewise.
* native/jni/midi-alsa/Makefile.in: Likewise.
* native/jni/midi-dssi/Makefile.in: Likewise.
* native/jni/native-lib/Makefile.in: Likewise.
* native/jni/qt-peer/Makefile.in: Likewise.
* native/jni/xmlj/Makefile.in: Likewise.
* native/plugin/Makefile.in: Likewise.
* resource/Makefile.in: Likewise.
* scripts/Makefile.in: Likewise.
* tools/Makefile.in: Likewise.

libjava/ChangeLog:

* configure.ac: Remove autoconf2.64 prerequisite, relocate
AM_INIT_AUTOMAKE call, use modern multilib configuration, use autoconf
builtins for noncanonical build and target macros.
* Makefile.in: Regenerate.
* aclocal.m4: Likewise.
* configure: Likewise.
* gcj/Makefile.in: Likewise.
* include/Makefile.in: Likewise.
* include/config.h.in: Likewise.
* testsuite/Makefile.in: Likewise.

libjava/libltdl/ChangeLog:

* configure.ac: Set AC_CONFIG_AUX_DIR to root of gcc tree.
* Makefile.in: Regenerate.
* aclocal.m4: Likewise.
* configure: Likewise.


0049-libjava-Move-to-autoconf-2.69-automake-1.15.patch.bz3
Description: Binary data


[PATCH 46/56] libjava: Remove unnecessary parentheses.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 9727bbe203cb3e32bd4f70c3e6c1e7a5f08ecc6c Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 19:07:31 +1100
Subject: [PATCH 46/56] libjava: Remove unnecessary parentheses.

libjava/ChangeLog:

	* gnu/gcj/jvmti/Breakpoint.h (_Jv_RewriteBreakpointInsn): Remove unnecessary parentheses.
---
 libjava/gnu/gcj/jvmti/Breakpoint.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libjava/gnu/gcj/jvmti/Breakpoint.h b/libjava/gnu/gcj/jvmti/Breakpoint.h
index f614df9e5e1..107e13cbc4d 100644
--- a/libjava/gnu/gcj/jvmti/Breakpoint.h
+++ b/libjava/gnu/gcj/jvmti/Breakpoint.h
@@ -30,7 +30,7 @@ class gnu::gcj::jvmti::Breakpoint : public ::java::lang::Object
 {
 
 #ifdef DIRECT_THREADED
-friend void (::_Jv_RewriteBreakpointInsn (jmethodID, jlocation, pc_t));
+friend void ::_Jv_RewriteBreakpointInsn (jmethodID, jlocation, pc_t);
 #endif
 
 public:
-- 
2.38.1



[PATCH 47/56] libjava: Use ucontext_t instead of struct ucontext.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 0a48a9b40e58611602df083296fb9e272ec47214 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 19:08:08 +1100
Subject: [PATCH 47/56] libjava: Use ucontext_t instead of struct ucontext.

libjava/ChangeLog:

	* include/i386-signal.h: Use ucontext_t instead of struct ucontext.
	* include/s390-signal.h: Likewise.
	* include/x86_64-signal.h: Likewise.
---
 libjava/include/i386-signal.h   | 2 +-
 libjava/include/s390-signal.h   | 2 +-
 libjava/include/x86_64-signal.h | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libjava/include/i386-signal.h b/libjava/include/i386-signal.h
index c2409b0e301..3a15415510d 100644
--- a/libjava/include/i386-signal.h
+++ b/libjava/include/i386-signal.h
@@ -29,7 +29,7 @@ static void _Jv_##_name (int, siginfo_t *,			\
 #define HANDLE_DIVIDE_OVERFLOW		\
 do	\
 {	\
-  struct ucontext *_uc = (struct ucontext *)_p;\
+  ucontext_t *_uc = (ucontext_t *)_p;\
   gregset_t &_gregs = _uc->uc_mcontext.gregs;\
   unsigned char *_eip = (unsigned char *)_gregs[REG_EIP];		\
 	\
diff --git a/libjava/include/s390-signal.h b/libjava/include/s390-signal.h
index 4ca4c108864..9261b52be6e 100644
--- a/libjava/include/s390-signal.h
+++ b/libjava/include/s390-signal.h
@@ -51,7 +51,7 @@ do	\
   struct\
   { \
 unsigned long int uc_flags; \
-struct ucontext *uc_link;   \
+ucontext_t *uc_link;\
 stack_t uc_stack;   \
 mcontext_t uc_mcontext; \
 unsigned long sigmask[2];   \
diff --git a/libjava/include/x86_64-signal.h b/libjava/include/x86_64-signal.h
index 12383b5485a..a463ee3b980 100644
--- a/libjava/include/x86_64-signal.h
+++ b/libjava/include/x86_64-signal.h
@@ -28,7 +28,7 @@ static void _Jv_##_name (int, siginfo_t *,			\
 #define HANDLE_DIVIDE_OVERFLOW		\
 do	\
 {	\
-  struct ucontext *_uc = (struct ucontext *)_p;\
+  ucontext_t *_uc = (ucontext_t *)_p;\
   gregset_t &_gregs = _uc->uc_mcontext.gregs;\
   unsigned char *_rip = (unsigned char *)_gregs[REG_RIP];		\
 	\
-- 
2.38.1



[PATCH 55/56] classpath: Mark generate-locale-list.sh as executable.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 6812eff2161bb08560549fe7b8c309d83af47142 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 25 Nov 2022 16:41:21 +1100
Subject: [PATCH 55/56] classpath: Mark generate-locale-list.sh as executable.

libjava/classpath/ChangeLog:

	* scripts/generate-locale-list.sh: Mark as executable.
---
 libjava/classpath/scripts/generate-locale-list.sh | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 mode change 100644 => 100755 libjava/classpath/scripts/generate-locale-list.sh

diff --git a/libjava/classpath/scripts/generate-locale-list.sh b/libjava/classpath/scripts/generate-locale-list.sh
old mode 100644
new mode 100755
-- 
2.38.1



[PATCH 41/56] java: Replace struct deps with struct mkdeps and set phoniness of dependencies via bool argument to deps_write.

2022-11-25 Thread Zopolis0 via Gcc-patches

From ddb4f48708722a2343e104cc27d094ce70235362 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 19:03:06 +1100
Subject: [PATCH 41/56] java: Replace struct deps with struct mkdeps and set
 phoniness of dependencies via bool argument to deps_write.

gcc/java/ChangeLog:

	* jcf-depend.cc (struct deps): Rename to ...
	(struct mkdeps): ... this.
	(jcf_dependency_write): Set phoniness of dependencies via bool argument to deps_write.
---
 gcc/java/jcf-depend.cc | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/gcc/java/jcf-depend.cc b/gcc/java/jcf-depend.cc
index b5e850dfecc..f46189233d3 100644
--- a/gcc/java/jcf-depend.cc
+++ b/gcc/java/jcf-depend.cc
@@ -34,7 +34,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc.  */
 
 
 /* The dependency structure used for this invocation.  */
-struct deps *dependencies;
+struct mkdeps *dependencies;
 
 /* The output file, or NULL if we aren't doing dependency tracking.  */
 static FILE *dep_out = NULL;
@@ -133,8 +133,10 @@ jcf_dependency_write (void)
 
   gcc_assert (dependencies);
 
-  deps_write (dependencies, dep_out, 72);
   if (print_dummies)
-deps_phony_targets (dependencies, dep_out);
+deps_write (dependencies, dep_out, 1, 72);
+  else
+deps_write (dependencies, dep_out, 0, 72);
+
   fflush (dep_out);
 }
-- 
2.38.1



[PATCH 44/56] java: Add FUNCTION_DECL_CHECK in METHOD_DUMMY.

2022-11-25 Thread Zopolis0 via Gcc-patches

From f833395379572ae8d153edab0d9e14bb8182e3dc Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 19:06:32 +1100
Subject: [PATCH 44/56] java: Add FUNCTION_DECL_CHECK in METHOD_DUMMY.

gcc/java/ChangeLog:

	* java-tree.h (METHOD_DUMMY): Check for FUNCTION_DECL.
---
 gcc/java/java-tree.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h
index 813bc3237e1..d2e08f294f2 100644
--- a/gcc/java/java-tree.h
+++ b/gcc/java/java-tree.h
@@ -1197,7 +1197,7 @@ int cxx_keyword_p (const char *name, int length);
 
 /* Access flags etc for a method (a FUNCTION_DECL): */
 
-#define METHOD_DUMMY(DECL) (DECL_LANG_SPECIFIC (DECL)->u.f.dummy)
+#define METHOD_DUMMY(DECL) (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (DECL))->u.f.dummy)
 
 #define METHOD_PUBLIC(DECL) DECL_LANG_FLAG_1 (FUNCTION_DECL_CHECK (DECL))
 #define METHOD_PRIVATE(DECL) TREE_PRIVATE (FUNCTION_DECL_CHECK (DECL))
-- 
2.38.1



[PATCH 54/56] classpath: Use info-in-builddir.

2022-11-25 Thread Zopolis0 via Gcc-patches

From f212f36a69de5a84b2f66951c97ad454e03fb646 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 25 Nov 2022 16:40:15 +1100
Subject: [PATCH 54/56] classpath: Use info-in-builddir.

libjava/classpath/ChangeLog:

	* doc/Makefile.am: Add info-in-builddir.
	* doc/Makefile.in: Reconfigure.
---
 libjava/classpath/doc/Makefile.am | 2 ++
 libjava/classpath/doc/Makefile.in | 1 +
 2 files changed, 3 insertions(+)

diff --git a/libjava/classpath/doc/Makefile.am b/libjava/classpath/doc/Makefile.am
index 27ea7c00a95..9f532890df0 100644
--- a/libjava/classpath/doc/Makefile.am
+++ b/libjava/classpath/doc/Makefile.am
@@ -1,3 +1,5 @@
+AUTOMAKE_OPTIONS = info-in-builddir
+
 SUBDIRS = api
 
 EXTRA_DIST = README.jaxp texi2pod.pl $(man_MANS)
diff --git a/libjava/classpath/doc/Makefile.in b/libjava/classpath/doc/Makefile.in
index ea6681f8cf3..66bdc594a09 100644
--- a/libjava/classpath/doc/Makefile.in
+++ b/libjava/classpath/doc/Makefile.in
@@ -459,6 +459,7 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 uudecode = @uudecode@
 vm_classes = @vm_classes@
+AUTOMAKE_OPTIONS = info-in-builddir
 SUBDIRS = api
 EXTRA_DIST = README.jaxp texi2pod.pl $(man_MANS)
 TEXINFO_TEX = ../../gcc/doc/include/texinfo.tex
-- 
2.38.1



[PATCH 37/56] java: Build SWITCH_EXPR using build2 instead of build3.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 94f41c513be007f380e2c18771ab9d8fd33ecd76 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 18:58:44 +1100
Subject: [PATCH 37/56] java: Build SWITCH_EXPR using build2 instead of build3.

gcc/java/ChangeLog:

	* expr.cc (expand_java_switch): Build SWITCH_EXPR using build2 instead of build3.
---
 gcc/java/expr.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/java/expr.cc b/gcc/java/expr.cc
index 80bff58d727..4e212e7ed21 100644
--- a/gcc/java/expr.cc
+++ b/gcc/java/expr.cc
@@ -1887,8 +1887,8 @@ expand_java_switch (tree selector, int default_pc)
   tree switch_expr, x;
 
   flush_quick_stack ();
-  switch_expr = build3 (SWITCH_EXPR, TREE_TYPE (selector), selector,
-			NULL_TREE, NULL_TREE);
+  switch_expr = build2 (SWITCH_EXPR, TREE_TYPE (selector), selector,
+			NULL_TREE);
   java_add_stmt (switch_expr);
 
   x = build_case_label (NULL_TREE, NULL_TREE,
-- 
2.38.1



[PATCH 42/56] java: Include memmodel.h in builtins.cc.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 455027503890dabd31947f45ca8ac6c78a1360e5 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 19:04:36 +1100
Subject: [PATCH 42/56] java: Include memmodel.h in builtins.cc.

gcc/java/ChangeLog:

	* builtins.cc: Include memmodel.h.
---
 gcc/java/builtins.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/java/builtins.cc b/gcc/java/builtins.cc
index 45d736a0d7b..0482bbd830d 100644
--- a/gcc/java/builtins.cc
+++ b/gcc/java/builtins.cc
@@ -34,6 +34,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc.  */
 #include "tree.h"
 #include "stringpool.h"
 #include "expmed.h"
+#include "memmodel.h"
 #include "optabs.h"
 #include "fold-const.h"
 #include "stor-layout.h"
-- 
2.38.1



[PATCH 28/56] java: Replace TYPE_MINVAL with TYPE_MIN_VALUE_RAW.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 47048f95e0fd265badb53dc373e6bdc91f7ac39c Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 14:31:50 +1100
Subject: [PATCH 28/56] java: Replace TYPE_MINVAL with TYPE_MIN_VALUE_RAW.

gcc/java/ChangeLog:

	* java-tree.h (TYPE_ARGUMENT_SIGNATURE): Replace TYPE_MINVAL with TYPE_MIN_VALUE_RAW.
---
 gcc/java/java-tree.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h
index 6f286ecf666..813bc3237e1 100644
--- a/gcc/java/java-tree.h
+++ b/gcc/java/java-tree.h
@@ -1339,7 +1339,7 @@ extern tree *type_map;
 
 /* If FUNCTION_TYPE or METHOD_TYPE: cache for build_java_argument_signature. */
 #define TYPE_ARGUMENT_SIGNATURE(TYPE) \
-  (TYPE_MINVAL (TREE_CHECK2 (TYPE, FUNCTION_TYPE, METHOD_TYPE)))
+  (TYPE_MIN_VALUE_RAW (TREE_CHECK2 (TYPE, FUNCTION_TYPE, METHOD_TYPE)))
 
 /* Given an array type, give the type of the elements. */
 /* FIXME this use of TREE_TYPE conflicts with something or other. */
-- 
2.38.1



[PATCH 51/56] libjava: Check for libz_convenience.la instead of libzgcj_convenience.la.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 64685f25317b541ff9a677e34a2df01d136665e4 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 19:43:14 +1100
Subject: [PATCH 51/56] libjava: Check for libz_convenience.la instead of
 libzgcj_convenience.la.

libjava/ChangeLog:

	* configure.ac: Check for libz_convenience.la instead of libzgcj_convenience.la.
	* configure: Regenerate.
---
 libjava/configure| 2 +-
 libjava/configure.ac | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libjava/configure b/libjava/configure
index 1ae56784d5f..ce96a9a8911 100755
--- a/libjava/configure
+++ b/libjava/configure
@@ -24077,7 +24077,7 @@ ZINCS=
 if test -z "$ZLIBSPEC"; then
# Use zlib from the GCC tree.
ZINCS='-I$(top_srcdir)/../zlib'
-   ZLIBS=../zlib/libzgcj_convenience.la
+   ZLIBS=../zlib/libz_convenience.la
 else
# System's zlib.
SYS_ZLIBS="$ZLIBSPEC"
diff --git a/libjava/configure.ac b/libjava/configure.ac
index 8fb16765e05..b3d667a7da3 100644
--- a/libjava/configure.ac
+++ b/libjava/configure.ac
@@ -1490,7 +1490,7 @@ ZINCS=
 if test -z "$ZLIBSPEC"; then
# Use zlib from the GCC tree.
ZINCS='-I$(top_srcdir)/../zlib'
-   ZLIBS=../zlib/libzgcj_convenience.la
+   ZLIBS=../zlib/libz_convenience.la
 else
# System's zlib.
SYS_ZLIBS="$ZLIBSPEC"
-- 
2.38.1



[PATCH 36/56] java: Don't check the value of dump_switch_p.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 93865231f5e5b2217ac9709b95a3eff2b068a6c4 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 18:55:56 +1100
Subject: [PATCH 36/56] java: Don't check the value of dump_switch_p.

gcc/java/ChangeLog:

	* lang.cc (java_handle_option): Don't check the value of dump_switch_p.
---
 gcc/java/lang.cc | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gcc/java/lang.cc b/gcc/java/lang.cc
index f79c89ab418..8a5bff8d7c8 100644
--- a/gcc/java/lang.cc
+++ b/gcc/java/lang.cc
@@ -262,8 +262,7 @@ java_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
   break;
 
 case OPT_fdump_:
-  if (!g->get_dumps ()->dump_switch_p (arg))
-	return false;
+  g->get_dumps ()->dump_switch_p (arg);
   break;
 
 case OPT_fencoding_:
-- 
2.38.1



[PATCH 39/56] java: Check that type is array or integer before checking string flag.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 03914cb1b32656b3d54a7c838666d32c8d2c1c4e Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 19:00:01 +1100
Subject: [PATCH 39/56] java: Check that type is array or integer before
 checking string flag.

gcc/java/ChangeLog:

	* decl.cc (push_promoted_type): Check that type is array or integer before checking string flag.
---
 gcc/java/decl.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/java/decl.cc b/gcc/java/decl.cc
index 6319d1ce18a..6d7a4ae37bf 100644
--- a/gcc/java/decl.cc
+++ b/gcc/java/decl.cc
@@ -481,7 +481,8 @@ push_promoted_type (const char *name, tree actual_type)
   TYPE_MAX_VALUE (type) = copy_node (in_max);
   TREE_TYPE (TYPE_MAX_VALUE (type)) = type;
   TYPE_PRECISION (type) = TYPE_PRECISION (int_type_node);
-  TYPE_STRING_FLAG (type) = TYPE_STRING_FLAG (actual_type);
+  if (TREE_CODE (type) == ARRAY_TYPE || TREE_CODE (type) == INTEGER_TYPE)
+TYPE_STRING_FLAG (type) = TYPE_STRING_FLAG (actual_type);
   layout_type (type);
   pushdecl (build_decl (input_location,
 			TYPE_DECL, get_identifier (name), type));
-- 
2.38.1



[PATCH 23/56] java: Don't build by default.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 9cc1761bef480ab6833b499a4293d4f60b6ac756 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 14:27:17 +1100
Subject: [PATCH 23/56] java: Don't build by default.

gcc/java/ChangeLog:

	* config-lang.in: Don't build Java by default.
---
 gcc/java/config-lang.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/java/config-lang.in b/gcc/java/config-lang.in
index 2cec3736655..cf46ce0a250 100644
--- a/gcc/java/config-lang.in
+++ b/gcc/java/config-lang.in
@@ -36,5 +36,5 @@ gtfiles="\$(srcdir)/java/java-tree.h \$(srcdir)/java/jcf.h \$(srcdir)/java/parse
 
 target_libs="target-libjava target-libffi target-zlib"
 lang_dirs="fastjar"
-#build_by_default=no
+build_by_default=no
 lang_requires=c++
-- 
2.38.1



[PATCH 45/56] libjava: Remove unnecessary register keyword.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 6f8caea61b454cfa8fd55ad2ae17cd613f39e77e Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 19:07:03 +1100
Subject: [PATCH 45/56] libjava: Remove unnecessary register keyword.

libjava/ChangeLog:

	* java/lang/natString.cc (_Jv_FormatInt): Remove unnecessary register keyword.
---
 libjava/java/lang/natString.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libjava/java/lang/natString.cc b/libjava/java/lang/natString.cc
index 75006a7c9a7..dc32757541a 100644
--- a/libjava/java/lang/natString.cc
+++ b/libjava/java/lang/natString.cc
@@ -368,7 +368,7 @@ _Jv_GetStringUTFRegion (jstring str, jsize start, jsize len, char *buf)
 jint
 _Jv_FormatInt (jchar* bufend, jint num)
 {
-  register jchar* ptr = bufend;
+  jchar* ptr = bufend;
   jboolean isNeg;
   if (num < 0)
 {
-- 
2.38.1



[PATCH 35/56] java: Use checking forms of DECL_FUNCTION_CODE.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 9b2de9f1573a12674ab30e4dc7b5ccbf5b5d5921 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 18:54:38 +1100
Subject: [PATCH 35/56] java: Use checking forms of DECL_FUNCTION_CODE.

gcc/java/ChangeLog:

	* builtins.cc (define_builtin): Use set_decl_built_in_function.
---
 gcc/java/builtins.cc | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gcc/java/builtins.cc b/gcc/java/builtins.cc
index 09f6c159aa5..45d736a0d7b 100644
--- a/gcc/java/builtins.cc
+++ b/gcc/java/builtins.cc
@@ -472,8 +472,7 @@ define_builtin (enum built_in_function val,
   TREE_PUBLIC (decl) = 1;
   SET_DECL_ASSEMBLER_NAME (decl, get_identifier (libname));
   pushdecl (decl);
-  DECL_BUILT_IN_CLASS (decl) = BUILT_IN_NORMAL;
-  DECL_FUNCTION_CODE (decl) = val;
+  set_decl_built_in_function (decl, BUILT_IN_NORMAL, val);
   set_call_expr_flags (decl, flags);
 
   set_builtin_decl (val, decl, true);
-- 
2.38.1



[PATCH 38/56] java: Use dump_flags_t.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 06d15f71846a82e92ac842d5df30f6cac6fed523 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 18:59:38 +1100
Subject: [PATCH 38/56] java: Use dump_flags_t.

gcc/java/ChangeLog:

	* java-gimplify.cc (dump_java_tree): Use dump_flags_t.
---
 gcc/java/java-gimplify.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/java/java-gimplify.cc b/gcc/java/java-gimplify.cc
index c723cb665ce..8c490ab832e 100644
--- a/gcc/java/java-gimplify.cc
+++ b/gcc/java/java-gimplify.cc
@@ -160,7 +160,7 @@ static void
 dump_java_tree (enum tree_dump_index phase, tree t)
 {
   FILE *stream;
-  int flags;
+  dump_flags_t flags;
 
   stream = dump_begin (phase, );
   flags |= TDF_SLIM;
-- 
2.38.1



[PATCH 21/56] Rename gcc/java/*.c to *.cc.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 03f1795edba9ec9c8cb64031ddfe61a67e6167ff Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 09:53:31 +1100
Subject: [PATCH 21/56] Rename gcc/java/*.c to *.cc.

gcc/java/ChangeLog:

	* Make-lang.in: Rename .c names to .cc.
	* boehm.c: Moved to...
	* boehm.cc: ...here.
	* builtins.c: Moved to...
	* builtins.cc: ...here.
	* class.c: Moved to...
	* class.cc: ...here.
	* config-lang.in:
	* constants.c: Moved to...
	* constants.cc: ...here.
	* decl.c: Moved to...
	* decl.cc: ...here.
	* except.c: Moved to...
	* except.cc: ...here.
	* expr.c: Moved to...
	* expr.cc: ...here.
	* java-gimplify.c: Moved to...
	* java-gimplify.cc: ...here.
	* jcf-depend.c: Moved to...
	* jcf-depend.cc: ...here.
	* jcf-dump.c: Moved to...
	* jcf-dump.cc: ...here.
	* jcf-io.c: Moved to...
	* jcf-io.cc: ...here.
	* jcf-parse.c: Moved to...
	* jcf-parse.cc: ...here.
	* jcf-path.c: Moved to...
	* jcf-path.cc: ...here.
	* jcf-reader.c: Moved to...
	* jcf-reader.cc: ...here.
	* jvgenmain.c: Moved to...
	* jvgenmain.cc: ...here.
	* jvspec.c: Moved to...
	* jvspec.cc: ...here.
	* lang.c: Moved to...
	* lang.cc: ...here.
	* mangle.c: Moved to...
	* mangle.cc: ...here.
	* mangle_name.c: Moved to...
	* mangle_name.cc: ...here.
	* resource.c: Moved to...
	* resource.cc: ...here.
	* typeck.c: Moved to...
	* typeck.cc: ...here.
	* verify-glue.c: Moved to...
	* verify-glue.cc: ...here.
	* verify-impl.c: Moved to...
	* verify-impl.cc: ...here.
	* win32-host.c: Moved to...
	* win32-host.cc: ...here.
	* zextract.c: Moved to...
	* zextract.cc: ...here.
---
 gcc/java/Make-lang.in  | 2 +-
 gcc/java/{boehm.c => boehm.cc} | 0
 gcc/java/{builtins.c => builtins.cc}   | 0
 gcc/java/{class.c => class.cc} | 0
 gcc/java/config-lang.in| 2 +-
 gcc/java/{constants.c => constants.cc} | 0
 gcc/java/{decl.c => decl.cc}   | 0
 gcc/java/{except.c => except.cc}   | 0
 gcc/java/{expr.c => expr.cc}   | 0
 gcc/java/{java-gimplify.c => java-gimplify.cc} | 0
 gcc/java/{jcf-depend.c => jcf-depend.cc}   | 0
 gcc/java/{jcf-dump.c => jcf-dump.cc}   | 2 +-
 gcc/java/{jcf-io.c => jcf-io.cc}   | 0
 gcc/java/{jcf-parse.c => jcf-parse.cc} | 2 +-
 gcc/java/{jcf-path.c => jcf-path.cc}   | 0
 gcc/java/{jcf-reader.c => jcf-reader.cc}   | 0
 gcc/java/{jvgenmain.c => jvgenmain.cc} | 0
 gcc/java/{jvspec.c => jvspec.cc}   | 0
 gcc/java/{lang.c => lang.cc}   | 0
 gcc/java/{mangle.c => mangle.cc}   | 0
 gcc/java/{mangle_name.c => mangle_name.cc} | 0
 gcc/java/{resource.c => resource.cc}   | 0
 gcc/java/{typeck.c => typeck.cc}   | 0
 gcc/java/{verify-glue.c => verify-glue.cc} | 0
 gcc/java/{verify-impl.c => verify-impl.cc} | 0
 gcc/java/{win32-host.c => win32-host.cc}   | 0
 gcc/java/{zextract.c => zextract.cc}   | 0
 27 files changed, 4 insertions(+), 4 deletions(-)
 rename gcc/java/{boehm.c => boehm.cc} (100%)
 rename gcc/java/{builtins.c => builtins.cc} (100%)
 rename gcc/java/{class.c => class.cc} (100%)
 rename gcc/java/{constants.c => constants.cc} (100%)
 rename gcc/java/{decl.c => decl.cc} (100%)
 rename gcc/java/{except.c => except.cc} (100%)
 rename gcc/java/{expr.c => expr.cc} (100%)
 rename gcc/java/{java-gimplify.c => java-gimplify.cc} (100%)
 rename gcc/java/{jcf-depend.c => jcf-depend.cc} (100%)
 rename gcc/java/{jcf-dump.c => jcf-dump.cc} (99%)
 rename gcc/java/{jcf-io.c => jcf-io.cc} (100%)
 rename gcc/java/{jcf-parse.c => jcf-parse.cc} (99%)
 rename gcc/java/{jcf-path.c => jcf-path.cc} (100%)
 rename gcc/java/{jcf-reader.c => jcf-reader.cc} (100%)
 rename gcc/java/{jvgenmain.c => jvgenmain.cc} (100%)
 rename gcc/java/{jvspec.c => jvspec.cc} (100%)
 rename gcc/java/{lang.c => lang.cc} (100%)
 rename gcc/java/{mangle.c => mangle.cc} (100%)
 rename gcc/java/{mangle_name.c => mangle_name.cc} (100%)
 rename gcc/java/{resource.c => resource.cc} (100%)
 rename gcc/java/{typeck.c => typeck.cc} (100%)
 rename gcc/java/{verify-glue.c => verify-glue.cc} (100%)
 rename gcc/java/{verify-impl.c => verify-impl.cc} (100%)
 rename gcc/java/{win32-host.c => win32-host.cc} (100%)
 rename gcc/java/{zextract.c => zextract.cc} (100%)

diff --git a/gcc/java/Make-lang.in b/gcc/java/Make-lang.in
index cbfd479a3dd..80e221b30a7 100644
--- a/gcc/java/Make-lang.in
+++ b/gcc/java/Make-lang.in
@@ -117,7 +117,7 @@ java.rest.encap:
 
 
 java.tags: force
-	cd $(srcdir)/java; etags -o TAGS.sub *.c *.h --language=none \
+	cd $(srcdir)/java; etags -o TAGS.sub *.cc *.h --language=none \
 	  --regex='/DEFTREECODE [(]\([A-Z_]+\)/\1/' java-tree.def; \
 	etags --include TAGS.sub --include ../TAGS.sub
 
diff --git a/gcc/java/boehm.c b/gcc/java/boehm.cc
similarity index 100%
rename from gcc/java/boehm.c
rename to gcc/java/boehm.cc
diff --git a/gcc/java/builtins.c b/gcc/java/builtins.cc
similarity index 100%
rename 

[PATCH 43/56] java: Include opt-suggestions.h in jvspec.cc.

2022-11-25 Thread Zopolis0 via Gcc-patches

From cdeae5ba5f541b14ad50efc16f4d17f24998e115 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 19:05:03 +1100
Subject: [PATCH 43/56] java: Include opt-suggestions.h in jvspec.cc.

gcc/java/ChangeLog:

	* jvspec.cc: Include opt-suggestions.h.
---
 gcc/java/jvspec.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/java/jvspec.cc b/gcc/java/jvspec.cc
index a2010db4c97..58142368621 100644
--- a/gcc/java/jvspec.cc
+++ b/gcc/java/jvspec.cc
@@ -26,6 +26,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc.  */
 #include "system.h"
 #include "coretypes.h"
 #include "tm.h"
+#include "opt-suggestions.h"
 #include "gcc.h"
 #include "jcf.h"
 #include "opts.h"
-- 
2.38.1



[PATCH 34/56] java: Replace flag_excess_precision_cmdline with flag_excess_precision.

2022-11-25 Thread Zopolis0 via Gcc-patches

From a6dd3bf6fbd57289dee1a73bc8b24b3de33374b6 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 14:38:01 +1100
Subject: [PATCH 34/56] java: Replace flag_excess_precision_cmdline with
 flag_excess_precision.

gcc/java/ChangeLog:

	* lang.cc (java_post_options): Replace flag_excess_precision_cmdline with flag_excess_precision.
---
 gcc/java/lang.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/java/lang.cc b/gcc/java/lang.cc
index 742a772bae1..f79c89ab418 100644
--- a/gcc/java/lang.cc
+++ b/gcc/java/lang.cc
@@ -570,9 +570,9 @@ java_post_options (const char **pfilename)
 
   /* Excess precision other than "fast" requires front-end
  support.  */
-  if (flag_excess_precision_cmdline == EXCESS_PRECISION_STANDARD)
+  if (flag_excess_precision == EXCESS_PRECISION_STANDARD)
 sorry ("%<-fexcess-precision=standard%> for Java");
-  flag_excess_precision_cmdline = EXCESS_PRECISION_FAST;
+  flag_excess_precision = EXCESS_PRECISION_FAST;
 
   /* An absolute requirement: if we're not using indirect dispatch, we
  must always verify everything.  */
-- 
2.38.1



[PATCH 17/56] gcc: Add binfo value to tree_type_non_common and make TYPE_BINFO use it.

2022-11-25 Thread Zopolis0 via Gcc-patches

From eb12f8c4c87314779ae35842f7a833eb4ad89b62 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 09:22:36 +1100
Subject: [PATCH 17/56] gcc: Add binfo value to tree_type_non_common and make
 TYPE_BINFO use it.

gcc/ChangeLog:

	* tree-core.h (struct tree_type_non_common): Re-add binfo.
	* tree.h (TYPE_BINFO): Use type_non_common.binfo.
---
 gcc/tree-core.h | 1 +
 gcc/tree.h  | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/tree-core.h b/gcc/tree-core.h
index e146b133dbd..90b0cac7f90 100644
--- a/gcc/tree-core.h
+++ b/gcc/tree-core.h
@@ -1745,6 +1745,7 @@ struct GTY(()) tree_type_non_common {
   tree values;
   tree minval;
   tree maxval;
+  tree binfo;
   tree lang_1;
 };
 
diff --git a/gcc/tree.h b/gcc/tree.h
index 56409bfad13..9ad86307a72 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -2468,7 +2468,7 @@ extern tree vector_element_bits_tree (const_tree);
 #define TYPE_MAX_VALUE_RAW(NODE) (TYPE_CHECK (NODE)->type_non_common.maxval)
 /* For record and union types, information about this type, as a base type
for itself.  */
-#define TYPE_BINFO(NODE) (RECORD_OR_UNION_CHECK (NODE)->type_non_common.maxval)
+#define TYPE_BINFO(NODE) (RECORD_OR_UNION_CHECK (NODE)->type_non_common.binfo)
 
 /* For types, used in a language-dependent way.  */
 #define TYPE_LANG_SLOT_1(NODE) \
-- 
2.38.1



[PATCH 31/56] java: Use HOST_WIDE_INT.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 3fdb672e06dc91ec22bfb56ec3b441fdbc343fdd Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 14:34:07 +1100
Subject: [PATCH 31/56] java: Use HOST_WIDE_INT.

gcc/java/ChangeLog:

	* lang.cc (java_handle_option): Replace 'int value' with 'HOST_WIDE_INT value'.
---
 gcc/java/lang.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/java/lang.cc b/gcc/java/lang.cc
index 0353f6f3b95..ab204f9531f 100644
--- a/gcc/java/lang.cc
+++ b/gcc/java/lang.cc
@@ -44,7 +44,7 @@ static void java_init_options_struct (struct gcc_options *);
 static void java_init_options (unsigned int, struct cl_decoded_option *);
 static bool java_post_options (const char **);
 
-static bool java_handle_option (size_t, const char *, int, int, location_t,
+static bool java_handle_option (size_t, const char *, HOST_WIDE_INT, int, location_t,
 const struct cl_option_handlers *);
 static void put_decl_string (const char *, int);
 static void put_decl_node (tree, int);
@@ -171,7 +171,7 @@ struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
  * return false, but do not complain if the option is not recognized.
  */
 static bool
-java_handle_option (size_t scode, const char *arg, int value,
+java_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
 		int kind ATTRIBUTE_UNUSED, location_t loc ATTRIBUTE_UNUSED,
 		const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED)
 {
-- 
2.38.1



[PATCH 40/56] java: Fix Wstringop-* warnings.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 704b4df7d1965090d27e76eba9257e2a29b34595 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 19:01:56 +1100
Subject: [PATCH 40/56] java: Fix Wstringop-* warnings.

gcc/java/ChangeLog:

	* jcf-parse.cc (compute_class_name): Fix Wstringop-* warnings.

Co-authored-by: 277r 
---
 gcc/java/jcf-parse.cc | 23 ++-
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/gcc/java/jcf-parse.cc b/gcc/java/jcf-parse.cc
index 683f7211085..a4ee9af51d2 100644
--- a/gcc/java/jcf-parse.cc
+++ b/gcc/java/jcf-parse.cc
@@ -1992,8 +1992,8 @@ compute_class_name (struct ZipDirectory *zdir)
 {
   char *class_name_in_zip_dir = ZIPDIR_FILENAME (zdir);
   char *class_name;
-  int i;
-  int filename_length = zdir->filename_length;
+  size_t i;
+  size_t filename_length = zdir->filename_length;
 
   while (filename_length > 2 && strncmp (class_name_in_zip_dir, "./", 2) == 0)
 {
@@ -2002,15 +2002,20 @@ compute_class_name (struct ZipDirectory *zdir)
 }
 
   filename_length -= strlen (".class");
-  class_name = XNEWVEC (char, filename_length + 1);
-  memcpy (class_name, class_name_in_zip_dir, filename_length);
-  class_name [filename_length] = '\0';
+  if (filename_length > 0)
+  {
+class_name = XNEWVEC (char, size_t(filename_length + 1));
+memcpy (class_name, class_name_in_zip_dir, filename_length);
+class_name [filename_length] = '\0';
 
-  for (i = 0; i < filename_length; i++)
-if (class_name[i] == '/')
-  class_name[i] = '.';
+for (i = 0; i < filename_length; i++)
+  if (class_name[i] == '/')
+class_name[i] = '.';
 
-  return class_name;
+return class_name;
+  }
+
+  return 0;
 }
 
 /* Return 0 if we should skip this entry, 1 if it is a .class file, 2
-- 
2.38.1



[PATCH 33/56] java: Fix -Wformat-diag warnings.

2022-11-25 Thread Zopolis0 via Gcc-patches

From d240e44f078badbaff23b7dc73c17f82c3b791d0 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 14:36:52 +1100
Subject: [PATCH 33/56] java: Fix -Wformat-diag warnings.

gcc/java/ChangeLog:

	* decl.cc (force_poplevels): Fix -Wformat-diag warning.
	* except.cc (doing_eh): Likewise.
	* jcf-parse.cc (handle_constant): Likewise.
	(jcf_parse): Likewise.
	(java_parse_file): Likewise.
	* jvspec.cc (lang_specific_driver): Likewise.
	* lang.cc (java_post_options): Likewise.
	* verify-glue.cc (verify_jvm_instructions_new): Likewise.
---
 gcc/java/decl.cc|  2 +-
 gcc/java/except.cc  |  2 +-
 gcc/java/jcf-parse.cc   | 14 +++---
 gcc/java/jvspec.cc  |  8 
 gcc/java/lang.cc| 10 +-
 gcc/java/verify-glue.cc |  2 +-
 6 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/gcc/java/decl.cc b/gcc/java/decl.cc
index 4fdfaaaf8c1..6319d1ce18a 100644
--- a/gcc/java/decl.cc
+++ b/gcc/java/decl.cc
@@ -1617,7 +1617,7 @@ force_poplevels (int start_pc)
   while (current_binding_level->start_pc > start_pc)
 {
   if (pedantic && current_binding_level->start_pc > start_pc)
-	warning (0, "In %+D: overlapped variable and exception ranges at %d",
+	warning (0, "In %<%+D:%> overlapped variable and exception ranges at %d",
  current_function_decl,
 		 current_binding_level->start_pc);
   poplevel (1, 0, 0);
diff --git a/gcc/java/except.cc b/gcc/java/except.cc
index c5e2326..7d936d379bd 100644
--- a/gcc/java/except.cc
+++ b/gcc/java/except.cc
@@ -577,7 +577,7 @@ doing_eh (void)
   static int warned = 0;
   if (! warned)
 	{
-	  error ("exception handling disabled, use -fexceptions to enable");
+	  error ("exception handling disabled, use %<-fexceptions%> to enable");
 	  warned = 1;
 	}
   return 0;
diff --git a/gcc/java/jcf-parse.cc b/gcc/java/jcf-parse.cc
index b5e39fd5a5c..683f7211085 100644
--- a/gcc/java/jcf-parse.cc
+++ b/gcc/java/jcf-parse.cc
@@ -499,7 +499,7 @@ handle_constant (JCF *jcf, int index, enum cpool_tag purpose)
 return 0;
 
   if (! CPOOL_INDEX_IN_RANGE (>cpool, index))
-error ("", index);
+error ("constant pool index %d not in range", index);
   
   kind = JPOOL_TAG (jcf, index);
 
@@ -509,7 +509,7 @@ handle_constant (JCF *jcf, int index, enum cpool_tag purpose)
 	  && kind == CONSTANT_Utf8)
 	;
   else
-	error (" file");
   code = jcf_parse_constant_pool (jcf);
   if (code != 0)
 fatal_error (input_location, "error while parsing constant pool");
   code = verify_constant_pool (jcf);
   if (code > 0)
-fatal_error (input_location, "error in constant pool entry #%d\n", code);
+fatal_error (input_location, "error in constant pool entry %d", code);
 
   jcf_parse_class (jcf);
   if (main_class == NULL_TREE)
@@ -1749,7 +1749,7 @@ java_parse_file (void)
   finput = fopen (main_input_filename, "r");
   if (finput == NULL)
 	fatal_error (input_location,
-		 "can%'t open %s: %m", LOCATION_FILE (input_location));
+		 "cannot open %s: %m", LOCATION_FILE (input_location));
   list = XNEWVEC (char, avail);
   next = list;
   for (;;)
@@ -1884,11 +1884,11 @@ java_parse_file (void)
   /* Close previous descriptor, if any */
   if (finput && fclose (finput))
 	fatal_error (input_location,
-		 "can%'t close input file %s: %m", main_input_filename);
+		 "cannot close input file %s: %m", main_input_filename);
   
   finput = fopen (filename, "rb");
   if (finput == NULL)
-	fatal_error (input_location, "can%'t open %s: %m", filename);
+	fatal_error (input_location, "cannot open %s: %m", filename);
 
 #ifdef IO_BUFFER_SIZE
   setvbuf (finput, xmalloc (IO_BUFFER_SIZE),
diff --git a/gcc/java/jvspec.cc b/gcc/java/jvspec.cc
index 73985751c86..a2010db4c97 100644
--- a/gcc/java/jvspec.cc
+++ b/gcc/java/jvspec.cc
@@ -392,7 +392,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
 }
 
   if (saw_D && ! main_class_name)
-fatal_error (input_location, "can%'t specify %<-D%> without %<--main%>");
+fatal_error (input_location, "cannot specify %<-D%> without %<--main%>");
 
   if (main_class_name && ! verify_class_name (main_class_name))
 fatal_error (input_location,
@@ -402,21 +402,21 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
   if (saw_resource)
 {
   if (! saw_o)
-	fatal_error (input_location, "--resource requires -o");
+	fatal_error (input_location, "%<--resource%> requires %<-o%>");
 }
   if (saw_C)
 {
   num_args += 3;
   if (class_files_count + zip_files_count > 0)
 	{
-	  warning (0, "already-compiled .class files ignored with -C"); 
+	  warning (0, "already-compiled %<.class%> files ignored with %<-C%>"); 
 	  num_args -= class_files_count + zip_files_count;
 	  class_files_count = 0;
 	  zip_files_count = 0;
 	}
   num_args += 2;  /* For -o NONE. */
   if (saw_o)
-	fatal_error (input_location, "cannot specify both -C and -o");
+	

[PATCH 30/56] java: Add handle_nonnull_attribute function.

2022-11-25 Thread Zopolis0 via Gcc-patches

From d512d93b50ce31537b2d05615b5c553c07a6ebdb Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 14:33:35 +1100
Subject: [PATCH 30/56] java: Add handle_nonnull_attribute function.

gcc/java/ChangeLog:

	* lang.cc (handle_nonnull_attribute): Add.
	(java_eh_personality): Adjust.
---
 gcc/java/lang.cc | 18 +++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/gcc/java/lang.cc b/gcc/java/lang.cc
index 65025eeeb72..0353f6f3b95 100644
--- a/gcc/java/lang.cc
+++ b/gcc/java/lang.cc
@@ -57,6 +57,7 @@ static bool java_decl_ok_for_sibcall (const_tree);
 static enum classify_record java_classify_record (tree type);
 
 static tree java_eh_personality (void);
+static tree handle_nonnull_attribute (tree *, tree, tree, int, bool *);
 
 #ifndef TARGET_OBJECT_SUFFIX
 # define TARGET_OBJECT_SUFFIX ".o"
@@ -65,9 +66,9 @@ static tree java_eh_personality (void);
 /* Table of machine-independent attributes.  */
 const struct attribute_spec java_attribute_table[] =
 {
- { "nonnull",0, -1, false, true, true,
-			  NULL, false },
-  { NULL, 0, 0, false, false, false, NULL, false }
+ { "nonnull",0, -1, false, true, true, false,
+			  handle_nonnull_attribute, NULL },
+  { NULL, 0, 0, false, false, false, false, NULL, NULL }
 };
 
 /* Used to avoid printing error messages with bogus function
@@ -909,4 +910,15 @@ java_eh_personality (void)
   return java_eh_personality_decl;
 }
 
+/* Handle the "nonnull" attribute.
+   FIXME: Implement an actual function here. */
+
+static tree
+handle_nonnull_attribute
+  (tree ARG_UNUSED (*node), tree ARG_UNUSED (name), tree ARG_UNUSED (args),
+  int ARG_UNUSED (flags), bool ARG_UNUSED (*no_add_attrs))
+{
+  return NULL_TREE;
+}
+
 #include "gt-java-lang.h"
-- 
2.38.1



[PATCH 16/56] gcc: Re-add TYPE_METHODS.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 19c63dd04c55e0954e181b8b6cd06e435024df70 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 09:21:50 +1100
Subject: [PATCH 16/56] gcc: Re-add TYPE_METHODS.

gcc/ChangeLog:

	* tree.h (TYPE_METHODS): Re-add.
---
 gcc/tree.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/tree.h b/gcc/tree.h
index a863d2e50e5..56409bfad13 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -2454,6 +2454,8 @@ extern tree vector_element_bits_tree (const_tree);
 
 #define TYPE_MAX_VALUE(NODE) \
   (NUMERICAL_TYPE_CHECK (NODE)->type_non_common.maxval)
+#define TYPE_METHODS(NODE)\
+  (RECORD_OR_UNION_CHECK (NODE)->type_non_common.maxval)
 #define TYPE_METHOD_BASETYPE(NODE)			\
   (FUNC_OR_METHOD_CHECK (NODE)->type_non_common.maxval)
 #define TYPE_OFFSET_BASETYPE(NODE)			\
-- 
2.38.1



[PATCH 32/56] java: Replace pfatal_with_name with fatal_error.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 757dda1de05e322415f3cf26078527626a1c7da5 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 14:35:41 +1100
Subject: [PATCH 32/56] java: Replace pfatal_with_name with fatal_error.

gcc/java/ChangeLog:

	* jvspec.cc (lang_specific_driver): Replace pfatal_with_name with fatal_error.
---
 gcc/java/jvspec.cc | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gcc/java/jvspec.cc b/gcc/java/jvspec.cc
index 6b138d4cce8..73985751c86 100644
--- a/gcc/java/jvspec.cc
+++ b/gcc/java/jvspec.cc
@@ -432,7 +432,8 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
   record_temp_file (filelist_filename, ! saw_save_temps, 0);
   filelist_file = fopen (filelist_filename, "w");
   if (filelist_file == NULL)
-	pfatal_with_name (filelist_filename);
+	fatal_error (input_location, "cannot read spec file %qs: %m", 
+ filelist_filename);
   num_args -= java_files_count + class_files_count + zip_files_count;
   num_args += 3;  /* for the combined arg "-xjava", and "-xnone" */
 }
@@ -577,7 +578,8 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
   if (combine_inputs)
 {
   if (fclose (filelist_file))
-	pfatal_with_name (filelist_filename);
+	fatal_error (input_location, "cannot read spec file %qs: %m", 
+ filelist_filename);
 }
 
   /* If we saw no -O or -g option, default to -g1, for javac compatibility. */
-- 
2.38.1



[PATCH 29/56] java: Properly handle GET_MODE_SIZE as a poly_uint16.

2022-11-25 Thread Zopolis0 via Gcc-patches

From be336e025f92b7ce30143380f8d1d50a7f02d282 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 14:32:58 +1100
Subject: [PATCH 29/56] java: Properly handle GET_MODE_SIZE as a poly_uint16.

gcc/java/ChangeLog:

	* builtins.cc (compareAndSwapLong_builtin): Treat GET_MODE_SIZE as polynomial.
	* expr.cc (expand_java_return): Likewise.
---
 gcc/java/builtins.cc | 2 +-
 gcc/java/expr.cc | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/java/builtins.cc b/gcc/java/builtins.cc
index f27831d51c2..09f6c159aa5 100644
--- a/gcc/java/builtins.cc
+++ b/gcc/java/builtins.cc
@@ -348,7 +348,7 @@ compareAndSwapLong_builtin (tree method_return_type ATTRIBUTE_UNUSED,
  versions.  */
   if (can_compare_and_swap_p (mode,
 			  (flag_use_atomic_builtins
-			   && GET_MODE_SIZE (mode) <= UNITS_PER_WORD)))
+			   && known_le (GET_MODE_SIZE (mode), UNITS_PER_WORD
 {
   tree addr, stmt;
   enum built_in_function fncode = BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_8;
diff --git a/gcc/java/expr.cc b/gcc/java/expr.cc
index 8d897550a59..80bff58d727 100644
--- a/gcc/java/expr.cc
+++ b/gcc/java/expr.cc
@@ -1299,8 +1299,8 @@ expand_java_return (tree type)
 	 The whole if expression just goes away if INT_TYPE_SIZE < 32
 	 is false. */
   if (INT_TYPE_SIZE < 32
-	  && (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (res)))
-	  < GET_MODE_SIZE (TYPE_MODE (type
+	  && known_lt (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (res))),
+	   GET_MODE_SIZE (TYPE_MODE (type
 	retval = build1 (NOP_EXPR, TREE_TYPE (res), retval);
   
   TREE_SIDE_EFFECTS (retval) = 1;
-- 
2.38.1



[PATCH 27/56] java: Replace source_location with location_t.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 3642e1652800078ab126a6d1575a370076d476e0 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 14:31:22 +1100
Subject: [PATCH 27/56] java: Replace source_location with location_t.

gcc/java/ChangeLog:

	* decl.cc (java_replace_references): Replace source_location with location_t.
	(struct GTY): Likewise.
	* java-tree.h (struct lang_decl_func): Likewise.
---
 gcc/java/decl.cc | 4 ++--
 gcc/java/java-tree.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/java/decl.cc b/gcc/java/decl.cc
index 70eac315113..4fdfaaaf8c1 100644
--- a/gcc/java/decl.cc
+++ b/gcc/java/decl.cc
@@ -341,7 +341,7 @@ java_replace_references (tree *tp, int *walk_subtrees,
 {
   if (TREE_CODE (*tp) == MODIFY_EXPR)
 {
-  source_location loc = EXPR_LOCATION (*tp);
+  location_t loc = EXPR_LOCATION (*tp);
   tree lhs = TREE_OPERAND (*tp, 0);
   /* This is specific to the bytecode compiler.  If a variable has
 	 LOCAL_SLOT_P set, replace an assignment to it with an assignment
@@ -416,7 +416,7 @@ struct GTY(())
 unsigned binding_depth;
 
 /* The location at which this level began.  */
-source_location loc;
+location_t loc;
   };
 
 #define NULL_BINDING_LEVEL (struct binding_level *) NULL
diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h
index d7ccbbe8768..6f286ecf666 100644
--- a/gcc/java/java-tree.h
+++ b/gcc/java/java-tree.h
@@ -739,7 +739,7 @@ struct GTY(()) lang_decl_func {
   int max_locals;
   int max_stack;
   int arg_slot_count;
-  source_location last_line;	/* End line number for a function decl */
+  location_t last_line;	/* End line number for a function decl */
   vec *throws_list;	/* Exception specified by `throws' */
   tree exc_obj;			/* Decl holding the exception object.  */
 
-- 
2.38.1



[PATCH 15/56] libcpp: Change deps_write and make_write to take class mkdeps instead of const cpp_reader and to learn about the the dependency phoniness via a bool argument.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 4ad8c0daab866f3d811006846a8040c9f05c0384 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 09:19:34 +1100
Subject: [PATCH 15/56] libcpp: Change deps_write and make_write to take class
 mkdeps instead of const cpp_reader and to learn about the the dependency
 phoniness via a bool argument.

libcpp/ChangeLog:

	* include/mkdeps.h (deps_write): Adjust first parm type, re-add phony argument.
	* init.cc (cpp_finish): Adjust accordingly.
	* mkdeps.cc (make_write): Adjust first parm type, re-add phony argument.
	(deps_write): Likewise.
---
 libcpp/include/mkdeps.h |  2 +-
 libcpp/init.cc  |  2 +-
 libcpp/mkdeps.cc| 15 +--
 3 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/libcpp/include/mkdeps.h b/libcpp/include/mkdeps.h
index 96d64641b1a..1eb96d3e8af 100644
--- a/libcpp/include/mkdeps.h
+++ b/libcpp/include/mkdeps.h
@@ -66,7 +66,7 @@ extern void deps_add_dep (class mkdeps *, const char *);
 
 /* Write out a deps buffer to a specified file.  The last argument
is the number of columns to word-wrap at (0 means don't wrap).  */
-extern void deps_write (const cpp_reader *, FILE *, unsigned int);
+extern void deps_write (class mkdeps *, FILE *, bool, unsigned int);
 
 /* Write out a deps buffer to a file, in a form that can be read back
with deps_restore.  Returns nonzero on error, in which case the
diff --git a/libcpp/init.cc b/libcpp/init.cc
index 5f34e3515d2..fb379dcc0cd 100644
--- a/libcpp/init.cc
+++ b/libcpp/init.cc
@@ -870,7 +870,7 @@ cpp_finish (cpp_reader *pfile, FILE *deps_stream)
 _cpp_pop_buffer (pfile);
 
   if (deps_stream)
-deps_write (pfile, deps_stream, 72);
+deps_write (pfile->deps, deps_stream, CPP_OPTION (pfile, deps.phony_targets), 72);
 
   /* Report on headers that could use multiple include guards.  */
   if (CPP_OPTION (pfile, print_include_names))
diff --git a/libcpp/mkdeps.cc b/libcpp/mkdeps.cc
index 30e87d8b4d7..1921017622f 100644
--- a/libcpp/mkdeps.cc
+++ b/libcpp/mkdeps.cc
@@ -387,10 +387,8 @@ make_write_vec (const mkdeps::vec , FILE *fp,
.PHONY targets for all the dependencies too.  */
 
 static void
-make_write (const cpp_reader *pfile, FILE *fp, unsigned int colmax)
+make_write (class mkdeps *d, FILE *fp, bool phony, unsigned int colmax)
 {
-  const mkdeps *d = pfile->deps;
-
   unsigned column = 0;
   if (colmax && colmax < 34)
 colmax = 34;
@@ -398,20 +396,17 @@ make_write (const cpp_reader *pfile, FILE *fp, unsigned int colmax)
   if (d->deps.size ())
 {
   column = make_write_vec (d->targets, fp, 0, colmax, d->quote_lwm);
-  if (CPP_OPTION (pfile, deps.modules) && d->cmi_name)
+  if ((d->module_name) && (d->cmi_name))
 	column = make_write_name (d->cmi_name, fp, column, colmax);
   fputs (":", fp);
   column++;
   make_write_vec (d->deps, fp, column, colmax);
   fputs ("\n", fp);
-  if (CPP_OPTION (pfile, deps.phony_targets))
+  if (phony)
 	for (unsigned i = 1; i < d->deps.size (); i++)
 	  fprintf (fp, "%s:\n", munge (d->deps[i]));
 }
 
-  if (!CPP_OPTION (pfile, deps.modules))
-return;
-
   if (d->modules.size ())
 {
   column = make_write_vec (d->targets, fp, 0, colmax, d->quote_lwm);
@@ -468,9 +463,9 @@ make_write (const cpp_reader *pfile, FILE *fp, unsigned int colmax)
 /* Really we should be opening fp here.  */
 
 void
-deps_write (const cpp_reader *pfile, FILE *fp, unsigned int colmax)
+deps_write (class mkdeps *d, FILE *fp, bool phony, unsigned int colmax)
 {
-  make_write (pfile, fp, colmax);
+  make_write (d, fp, phony, colmax);
 }
 
 /* Write out a deps buffer to a file, in a form that can be read back
-- 
2.38.1



[PATCH 18/56] Fix regression around friend declarations in local classes [PR69410].

2022-11-25 Thread Zopolis0 via Gcc-patches

From 56b722459a756a283e97c8508c8e187a1c81 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 09:23:33 +1100
Subject: [PATCH 18/56] Fix regression around friend declarations in local
 classes [PR69410].

gcc/cp/ChangeLog:

	* name-lookup.cc (pop_local_binding): Remove checking assert.
	(pushdecl): Remove overzealous check for friend declarations finding a matching declaration in a nearby scope.
---
 gcc/cp/name-lookup.cc | 20 +---
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc
index dfa6fb40675..b5f6e84cad9 100644
--- a/gcc/cp/name-lookup.cc
+++ b/gcc/cp/name-lookup.cc
@@ -2481,7 +2481,6 @@ pop_local_binding (tree id, tree decl)
 binding->value = NULL_TREE;
   else
 {
-  gcc_checking_assert (binding->type == decl);
   binding->type = NULL_TREE;
 }
 
@@ -3746,24 +3745,7 @@ pushdecl (tree decl, bool hiding)
   check_template_shadow (decl);
 
   if (DECL_DECLARES_FUNCTION_P (decl))
-	{
-	  check_default_args (decl);
-
-	  if (hiding)
-	{
-	  if (level->kind != sk_namespace)
-		{
-		  /* In a local class, a friend function declaration must
-		 find a matching decl in the innermost non-class scope.
-		 [class.friend/11] */
-		  error_at (DECL_SOURCE_LOCATION (decl),
-			"friend declaration %qD in local class without "
-			"prior local declaration", decl);
-		  /* Don't attempt to push it.  */
-		  return error_mark_node;
-		}
-	}
-	}
+	check_default_args (decl);
 
   if (level->kind != sk_namespace)
 	{
-- 
2.38.1



[PATCH 25/56] java: Replace PTR with 'void *'.

2022-11-25 Thread Zopolis0 via Gcc-patches

From c4e928a8f9d194a45ac4fd1b638c9978da790dea Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 14:29:21 +1100
Subject: [PATCH 25/56] java: Replace PTR with 'void *'.

gcc/java/ChangeLog:

	* expr.cc (pop_arguments): Use void * instead of PTR.
	* jcf.h (GTY): Likewise.
---
 gcc/java/expr.cc | 2 +-
 gcc/java/jcf.h   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/java/expr.cc b/gcc/java/expr.cc
index ba798ca3165..8d897550a59 100644
--- a/gcc/java/expr.cc
+++ b/gcc/java/expr.cc
@@ -1956,7 +1956,7 @@ pop_arguments (tree method_type)
   return args;
 }
 
-/* Attach to PTR (a block) the declaration found in ENTRY. */
+/* Attach to void * (a block) the declaration found in ENTRY. */
 
 int
 attach_init_test_initialization_flags (treetreehash_entry **slot, tree block)
diff --git a/gcc/java/jcf.h b/gcc/java/jcf.h
index f14b2388db0..87531edc13c 100644
--- a/gcc/java/jcf.h
+++ b/gcc/java/jcf.h
@@ -110,7 +110,7 @@ typedef struct GTY(()) JCF {
   unsigned int right_zip : 1;
   unsigned int finished : 1;
   jcf_filbuf_t filbuf;
-  PTR GTY ((skip)) read_state;
+  void * GTY ((skip)) read_state;
   const char *filename;
   const char *classname;
   /* Directory entry where it was found.  */
-- 
2.38.1



[PATCH 26/56] java: Remove 'FREE' macro.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 186b17cf869fa906761987e2d34ecbc4c8adb514 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 14:30:19 +1100
Subject: [PATCH 26/56] java: Remove 'FREE' macro.

gcc/java/ChangeLog:

	* jcf-parse.cc (parse_zip_file_entries): Use free instead of FREE.
	* jcf.h (FREE): Remove.
---
 gcc/java/jcf-parse.cc | 2 +-
 gcc/java/jcf.h| 3 ---
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/gcc/java/jcf-parse.cc b/gcc/java/jcf-parse.cc
index 7fb734215c2..b5e39fd5a5c 100644
--- a/gcc/java/jcf-parse.cc
+++ b/gcc/java/jcf-parse.cc
@@ -2060,7 +2060,7 @@ parse_zip_file_entries (void)
 	char *class_name = compute_class_name (zdir);
 	int previous_alias_set = -1;
 	klass = lookup_class (get_identifier (class_name));
-	FREE (class_name);
+	free (class_name);
 	current_jcf = TYPE_JCF (klass);
 	output_class = current_class = klass;
 
diff --git a/gcc/java/jcf.h b/gcc/java/jcf.h
index 87531edc13c..5ad906d9e81 100644
--- a/gcc/java/jcf.h
+++ b/gcc/java/jcf.h
@@ -36,9 +36,6 @@ The Free Software Foundation is independent of Sun Microsystems, Inc.  */
 
 #define ALLOC xmalloc
 #define REALLOC xrealloc
-#ifndef FREE
-#define FREE(PTR) free(PTR)
-#endif
 
 #ifdef JCF_word
 #define JCF_word JCF_u4
-- 
2.38.1



[PATCH 13/56] Re-add flag_evaluation_order, reorder_operands_p, and add reorder bool argument to tree_swap_operands_p.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 4a60186570defebed7d811b37c46092267407a96 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 09:05:50 +1100
Subject: [PATCH 13/56] Re-add flag_evaluation_order, reorder_operands_p, and
 add reorder bool argument to tree_swap_operands_p.

gcc/ChangeLog:

	* common.opt (flag_evaluation_order): Re-add.
	* expr.cc (expand_operands): Re-add code guarded by flag_evaluation_order.
	* fold-const.cc (reorder_operands_p): Re-add.
	(negate_expr_p): Handle reorder_operands_p.
	(fold_negate_expr_1): Likewise.
	(tree_swap_operands_p): Re-add reorder argument.
	(fold_binary_loc): Likewise.
	(fold_ternary_loc): Likewise
	* fold-const.h (tree_swap_operands_p): Likewise.
	* genmatch.cc (dt_operand::gen_gimple_expr): Likewise.
	* gimple-fold.cc (fold_stmt_1): Likewise.
	* gimple-match-head.cc (gimple_resimplify2): Likewise.
	(gimple_resimplify3): Likewise.
	(gimple_resimplify4): Likewise.
	(gimple_resimplify5): Likewise.
	(gimple_simplify): Likewise.
	* match.pd: Likewise.
	* tree-ssa-dom.cc (record_equality): Likewise.
	* tree-ssa-reassoc.cc (optimize_range_tests_var_bound): Likewise.
	* tree-ssa-sccvn.cc (vn_nary_op_compute_hash): Likewise.
	* tree-ssa-threadedge.cc: Likewise.
---
 gcc/common.opt |  4 +++
 gcc/expr.cc|  4 +++
 gcc/fold-const.cc  | 51 ++
 gcc/fold-const.h   |  2 +-
 gcc/genmatch.cc|  2 +-
 gcc/gimple-fold.cc |  8 +++---
 gcc/gimple-match-head.cc   | 20 +--
 gcc/match.pd   |  2 +-
 gcc/tree-ssa-dom.cc|  2 +-
 gcc/tree-ssa-reassoc.cc|  2 +-
 gcc/tree-ssa-sccvn.cc  |  4 +--
 gcc/tree-ssa-threadedge.cc |  2 +-
 12 files changed, 74 insertions(+), 29 deletions(-)

diff --git a/gcc/common.opt b/gcc/common.opt
index 26e9d1cc4e7..318eafc2e8c 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -62,6 +62,10 @@ int flag_complex_method = 1
 Variable
 int flag_default_complex_method = 1
 
+; Nonzero if subexpressions must be evaluated from left-to-right.
+Variable
+int flag_evaluation_order = 0
+
 ; Language specific warning pass for unused results.
 Variable
 bool flag_warn_unused_result = false
diff --git a/gcc/expr.cc b/gcc/expr.cc
index d9407432ea5..2e770ab090d 100644
--- a/gcc/expr.cc
+++ b/gcc/expr.cc
@@ -8576,6 +8576,10 @@ expand_operands (tree exp0, tree exp1, rtx target, rtx *op0, rtx *op1,
 }
   else
 {
+  /* If we need to preserve evaluation order, copy exp0 into its own
+	 temporary variable so that it can't be clobbered by exp1.  */
+  if (flag_evaluation_order && TREE_SIDE_EFFECTS (exp1))
+	exp0 = save_expr (exp0);
   *op0 = expand_expr (exp0, target, VOIDmode, modifier);
   *op1 = expand_expr (exp1, NULL_RTX, VOIDmode, modifier);
 }
diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc
index b89cac91cae..374878b31a4 100644
--- a/gcc/fold-const.cc
+++ b/gcc/fold-const.cc
@@ -139,6 +139,7 @@ static tree fold_cond_expr_with_comparison (location_t, tree, enum tree_code,
 static tree unextend (tree, int, int, tree);
 static tree extract_muldiv (tree, tree, enum tree_code, tree, bool *);
 static tree extract_muldiv_1 (tree, tree, enum tree_code, tree, bool *);
+static bool reorder_operands_p (const_tree, const_tree);
 static tree fold_binary_op_with_conditional_arg (location_t,
 		 enum tree_code, tree,
 		 tree, tree,
@@ -472,7 +473,9 @@ negate_expr_p (tree t)
 	  && ! TYPE_OVERFLOW_WRAPS (type)))
 	return false;
   /* -(A + B) -> (-B) - A.  */
-  if (negate_expr_p (TREE_OPERAND (t, 1)))
+  if (negate_expr_p (TREE_OPERAND (t, 1))
+	  && reorder_operands_p (TREE_OPERAND (t, 0),
+ TREE_OPERAND (t, 1)))
 	return true;
   /* -(A + B) -> (-A) - B.  */
   return negate_expr_p (TREE_OPERAND (t, 0));
@@ -482,7 +485,9 @@ negate_expr_p (tree t)
   return !HONOR_SIGN_DEPENDENT_ROUNDING (type)
 	 && !HONOR_SIGNED_ZEROS (type)
 	 && (! ANY_INTEGRAL_TYPE_P (type)
-		 || TYPE_OVERFLOW_WRAPS (type));
+		 || TYPE_OVERFLOW_WRAPS (type))
+	 && reorder_operands_p (TREE_OPERAND (t, 0),
+TREE_OPERAND (t, 1));
 
 case MULT_EXPR:
   if (TYPE_UNSIGNED (type))
@@ -643,7 +648,9 @@ fold_negate_expr_1 (location_t loc, tree t)
 	  && !HONOR_SIGNED_ZEROS (type))
 	{
 	  /* -(A + B) -> (-B) - A.  */
-	  if (negate_expr_p (TREE_OPERAND (t, 1)))
+	  if (negate_expr_p (TREE_OPERAND (t, 1))
+	  && reorder_operands_p (TREE_OPERAND (t, 0),
+ TREE_OPERAND (t, 1)))
 	{
 	  tem = negate_expr (TREE_OPERAND (t, 1));
 	  return fold_build2_loc (loc, MINUS_EXPR, type,
@@ -663,7 +670,8 @@ fold_negate_expr_1 (location_t loc, tree t)
 case MINUS_EXPR:
   /* - (A - B) -> B - A  */
   if (!HONOR_SIGN_DEPENDENT_ROUNDING (type)
-	  && !HONOR_SIGNED_ZEROS (type))
+	  && !HONOR_SIGNED_ZEROS (element_mode (type))
+	  && reorder_operands_p (TREE_OPERAND (t, 0), TREE_OPERAND (t, 1)))
 	return fold_build2_loc (loc, MINUS_EXPR, type,
 TREE_OPERAND (t, 1), 

[PATCH 12/56] Re-add Java (to) comments.

2022-11-25 Thread Zopolis0 via Gcc-patches

From d686e07a2900e8fe2c13b58b0a00021ce932e507 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 09:03:34 +1100
Subject: [PATCH 12/56] Re-add Java (to) comments.

gcc/ChangeLog:

	* cfgexpand.cc (expand_gimple_basic_block): Re-add Java comment.
	* gimplify.cc (gimplify_save_expr): Re-add Java to comment.
	* ipa-utils.h (polymorphic_type_binfo_p): Re-add Java comment.
	* langhooks.h (struct lang_hooks): Re-add Java to comment.
	* tree-cfg.cc (verify_gimple_call): Re-add Java comment.
	* tree-eh.cc (lower_try_finally_switch): Likewise.
	(lower_resx): Re-add Java to comment.
	* tree.cc (build_common_builtin_nodes): Likewise.
	* varasm.cc (assemble_external): Likewise.
---
 gcc/cfgexpand.cc | 2 ++
 gcc/gimplify.cc  | 3 ++-
 gcc/ipa-utils.h  | 3 +++
 gcc/langhooks.h  | 2 +-
 gcc/tree-cfg.cc  | 2 ++
 gcc/tree-eh.cc   | 8 +++-
 gcc/tree.cc  | 2 +-
 gcc/varasm.cc| 2 +-
 8 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/gcc/cfgexpand.cc b/gcc/cfgexpand.cc
index dd29c03..b85934c511a 100644
--- a/gcc/cfgexpand.cc
+++ b/gcc/cfgexpand.cc
@@ -5824,6 +5824,8 @@ expand_gimple_basic_block (basic_block bb, bool disable_tail_calls)
   if (elt)
 	emit_label (*elt);
 
+  /* Java emits line number notes in the top of labels.
+	 ??? Make this go away once line number notes are obsoleted.  */
   BB_HEAD (bb) = NEXT_INSN (last);
   if (NOTE_P (BB_HEAD (bb)))
 	BB_HEAD (bb) = NEXT_INSN (BB_HEAD (bb));
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 02415cb1b5c..eb562c3a313 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -6447,7 +6447,8 @@ gimplify_save_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
   /* If the SAVE_EXPR has not been resolved, then evaluate it once.  */
   if (!SAVE_EXPR_RESOLVED_P (*expr_p))
 {
-  /* The operand may be a void-valued expression.  It is
+  /* The operand may be a void-valued expression such as SAVE_EXPRs
+	 generated by the Java frontend for class initialization.  It is
 	 being executed only for its side-effects.  */
   if (TREE_TYPE (val) == void_type_node)
 	{
diff --git a/gcc/ipa-utils.h b/gcc/ipa-utils.h
index 3ca058c0b56..89245263141 100644
--- a/gcc/ipa-utils.h
+++ b/gcc/ipa-utils.h
@@ -186,6 +186,9 @@ possible_polymorphic_call_target_p (struct cgraph_edge *e,
 inline bool
 polymorphic_type_binfo_p (const_tree binfo)
 {
+  /* See if BINFO's type has an virtual table associtated with it.
+ Check is defensive because of Java FE produces BINFOs
+ without BINFO_TYPE set.   */
   return (BINFO_TYPE (binfo) && TYPE_BINFO (BINFO_TYPE (binfo))
 	  && BINFO_VTABLE (TYPE_BINFO (BINFO_TYPE (binfo;
 }
diff --git a/gcc/langhooks.h b/gcc/langhooks.h
index b1b2b0e10f0..c8f5136d840 100644
--- a/gcc/langhooks.h
+++ b/gcc/langhooks.h
@@ -359,7 +359,7 @@ struct lang_hooks_for_lto
 struct lang_hooks
 {
   /* String identifying the front end and optionally language standard
- version, e.g. "GNU C++98".  */
+ version, e.g. "GNU C++98" or "GNU Java".  */
   const char *name;
 
   /* sizeof (struct lang_identifier), so make_node () creates
diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc
index d982988048f..aa0cd454aa3 100644
--- a/gcc/tree-cfg.cc
+++ b/gcc/tree-cfg.cc
@@ -3470,6 +3470,8 @@ verify_gimple_call (gcall *stmt)
   && !useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (fntype))
   /* ???  At least C++ misses conversions at assignments from
 	 void * call results.
+	 ???  Java is completely off.  Especially with functions
+	 returning java.lang.Object.
 	 For now simply allow arbitrary pointer type conversions.  */
   && !(POINTER_TYPE_P (TREE_TYPE (lhs))
 	   && POINTER_TYPE_P (TREE_TYPE (fntype
diff --git a/gcc/tree-eh.cc b/gcc/tree-eh.cc
index ae8fa21d9a3..fd768913e76 100644
--- a/gcc/tree-eh.cc
+++ b/gcc/tree-eh.cc
@@ -1564,6 +1564,12 @@ lower_try_finally_switch (struct leh_state *state, struct leh_tf_state *tf)
 /* Decide whether or not we are going to duplicate the finally block.
There are several considerations.
 
+   First, if this is Java, then the finally block contains code
+   written by the user.  It has line numbers associated with it,
+   so duplicating the block means it's difficult to set a breakpoint.
+   Since controlling code generation via -g is verboten, we simply
+   never duplicate code without optimization.
+
Second, we'd like to prevent egregious code growth.  One way to
do this is to estimate the size of the finally block, multiply
that by the number of copies we'd need to make, and compare against
@@ -3433,7 +3439,7 @@ lower_resx (basic_block bb, gresx *stmt,
 	 _Unwind_Resume library function.  */
 
   /* The ARM EABI redefines _Unwind_Resume as __cxa_end_cleanup
-	 with no arguments for C++.  Check for that.  */
+	 with no arguments for C++ and Java.  Check for that.  */
   if (src_r->use_cxa_end_cleanup)
 	{
 	  fn = builtin_decl_implicit (BUILT_IN_CXA_END_CLEANUP);
diff --git a/gcc/tree.cc 

[PATCH 24/56] java: Add empty selftest hook.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 3972b6e455e33a9a03dbddfe05f4fb2110b47492 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 14:28:04 +1100
Subject: [PATCH 24/56] java: Add empty selftest hook.

gcc/java/ChangeLog:

	* Make-lang.in: Add empty selftest hook.
---
 gcc/java/Make-lang.in | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/java/Make-lang.in b/gcc/java/Make-lang.in
index 80e221b30a7..6e28ea3c9ad 100644
--- a/gcc/java/Make-lang.in
+++ b/gcc/java/Make-lang.in
@@ -150,6 +150,9 @@ java.srcman: $(JAVA_MANFILES)
 check-java :
 check-java-subtargets :
 
+# No Java-specific selftests.
+selftest-java:
+
 # Install hooks:
 # jc1, gcj, and jvgenmain are installed elsewhere as part
 # of $(COMPILERS).
-- 
2.38.1



[PATCH 20/56] Re-add Java handling to gcc and gcc/cp.

2022-11-25 Thread Zopolis0 via Gcc-patches

From a7801c18fac9b20ee47d09ed15380a83fabeeec9 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 09:34:30 +1100
Subject: [PATCH 20/56] Re-add Java handling to gcc and gcc/cp.

gcc/cp/ChangeLog:

	* call.cc (build_java_interface_fn_ref): Re-add.
	(build_over_call): Handle TYPE_JAVA_INTERFACE.
	(java_iface_lookup_fn): Re-add.
	* class.cc (add_method): Handle TYPE_FOR_JAVA.
	(add_implicitly_declared_members): Likewise.
	(determine_key_method): Likewise.
	(finish_struct_1): Likewise.
	(push_lang_context): Handle lang_name_java.
	* cp-lang.cc (cp_eh_personality): Handle pragma_java_exceptions.
	* cp-tree.h (enum cp_tree_index): Re-add CPTI_JAVA_*, CPTI_LANG_NAME_JAVA and CPTI_JCLASS.
	(java_byte_type_node): Re-add.
	(java_short_type_node): Likewise.
	(java_int_type_node): Likewise.
	(java_long_type_node): Likewise.
	(java_float_type_node): Likewise.
	(java_double_type_node): Likewise.
	(java_char_type_node): Likewise.
	(java_boolean_type_node): Likewise.
	(lang_name_java): Likewise.
	(jclass_node): Likewise.
	(cp_global_trees): Re-add TYPE_FOR_JAVA.
	(enum languages): Re-add lang_java.
	(TYPE_FOR_JAVA): Re-add.
	(struct lang_type): Re-add java_interface.
	(TYPE_JAVA_INTERFACE): Re-add.
	(struct lang_decl_base): Increase language by 1.
	(check_java_method): Re-add.
	(build_java_class_ref): Likewise.
	(pragma_java_exceptions): Likewise.
	* decl.cc (record_builtin_java_type): Re-add.
	(initialize_predefined_identifiers): Re-add Java.
	(cxx_init_decl_processing): Re-add java_*_type_node.
	(cp_finish_decl): Handle TYPE_FOR_JAVA.
	(grokfndecl): Likewise.
	(check_special_function_return_type): Likewise.
	(grokdeclarator): Set TYPE_FOR_JAVA.
	(grokparms): Handle TYPE_FOR_JAVA.
	(xref_basetypes): Likewise.
	(check_function_type): Likewise.
	(maybe_return_this): Likewise.
	* decl2.cc (acceptable_java_type): Re-add.
	(check_java_method): Likewise.
	(import_export_decl): Handle TYPE_FOR_JAVA.
	(build_java_method_aliases): Re-add.
	(c_parse_final_cleanups): Call build_java_method_aliases.
	(possibly_inlined_p): Test pragma_java_exceptions.
	* error.cc (language_to_string): Handle lang_java.
	* except.cc (decl_is_java_type): Re-add.
	(eh_type_info): Re-add java type handling.
	(choose_personality_routine): Re-add.
	(initialize_handler_parm): Call choose_personality_routine.
	(expand_start_catch_block): Handle java types.
	(build_throw): Likewise.
	* init.cc (build_new_1): Handle TYPE_FOR_JAVA.
	(build_java_class_ref): Likewise.
	* lex.cc (handle_pragma_java_exceptions): Re-add.
	(init_cp_pragma): Register GCC java_exceptions pragma.
	(set_decl_linkage): Handle lang_name_java.
	* mangle.cc (write_java_integer_type_codes): Re-add.
	(write_builtin_type): Handle TYPE_FOR_JAVA.
	(write_bare_function_type): Handle java_*_type_node.
	* method.cc (implicitly_declare_fn): Handle TYPE_FOR_JAVA.
	* name-lookup.cc (pushtag): Set TYPE_FOR_JAVA.
	* pt.cc (maybe_new_partial_specialization): Copy TYPE_FOR_JAVA.
	(lookup_template_class): Likewise.
	(instantiate_class_template): Likewise.
	* tree.cc (handle_java_interface_attribute): Re-add.
	* typeck.cc (structural_comptypes): Compare TYPE_FOR_JAVA.

gcc/ChangeLog:

	* dwarf2out.cc (is_java): Re-add.
	(output_pubname): Handle is_java.
	(lower_bound_default): Handle DW_LANG_Java.
	(gen_compile_unit_die): Likewise.
	* gimplify.cc (mostly_copy_tree_r): Re-add Java-special part.
	* ipa-free-lang-data.cc (free_lang_data_in_type): Handle Java's usage of TYPE_MIN_VALUE.
	(find_decls_types_r): Handle Java's usage of TYPE_BINFO.
	* tree.cc (verify_type): Handle Java's usage of TYPE_MIN_VALUE, TYPE_BINFO, and TYPE_STRING_FLAG.
---
 gcc/cp/call.cc|  66 -
 gcc/cp/class.cc   |  50 -
 gcc/cp/cp-lang.cc |   5 +-
 gcc/cp/cp-tree.h  |  45 ++-
 gcc/cp/decl.cc| 124 +--
 gcc/cp/decl2.cc   | 122 +-
 gcc/cp/error.cc   |   3 +
 gcc/cp/except.cc  | 152 +-
 gcc/cp/init.cc| 128 +---
 gcc/cp/lex.cc |  18 +
 gcc/cp/mangle.cc  |  62 +++-
 gcc/cp/method.cc  |   2 +-
 gcc/cp/name-lookup.cc |   3 +
 gcc/cp/pt.cc  |   3 +
 gcc/cp/tree.cc|  28 +++
 gcc/cp/typeck.cc  |   2 +
 gcc/dwarf2out.cc  |  17 -
 gcc/gimplify.cc   |   7 +-
 gcc/ipa-free-lang-data.cc |  16 +++-
 gcc/tree.cc   |  30 +++-
 20 files changed, 839 insertions(+), 44 deletions(-)

diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
index 459e86b5f09..32ead577737 100644
--- a/gcc/cp/call.cc
+++ b/gcc/cp/call.cc
@@ -167,6 +167,7 @@ static int compare_ics (conversion *, conversion *);
 static void maybe_warn_class_memaccess (location_t, tree,
 	const vec *);
 static tree build_over_call (struct z_candidate *, int, tsubst_flags_t);
+static tree build_java_interface_fn_ref (tree, tree);

[PATCH 11/56] Re-add handling of Java file extensions (.java, .class, .zip, .jar).

2022-11-25 Thread Zopolis0 via Gcc-patches

From 72b2446899b30213647de3d504f3f9058f49b027 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 17 Nov 2022 14:16:08 +1100
Subject: [PATCH 11/56] Re-add handling of Java file extensions (.java, .class,
 .zip, .jar).

gcc/ChangeLog:

	* gcc.cc: Re-add compiler defaults for .java and .zip files.
	* gimple-expr.cc (remove_suffix): Change as there is now a longer extension than 4 letters.
	* opts.cc (strip_off_ending): Change as there is now a longer extension than 4 letters.
---
 gcc/gcc.cc | 2 ++
 gcc/gimple-expr.cc | 4 ++--
 gcc/opts.cc| 4 ++--
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index ca1c9e27a94..4f596c63773 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -1421,6 +1421,8 @@ static const struct compiler default_compilers[] =
   {".f03", "#Fortran", 0, 0, 0}, {".F03", "#Fortran", 0, 0, 0},
   {".f08", "#Fortran", 0, 0, 0}, {".F08", "#Fortran", 0, 0, 0},
   {".r", "#Ratfor", 0, 0, 0},
+  {".java", "#Java", 0, 0, 0}, {".class", "#Java", 0, 0, 0},
+  {".zip", "#Java", 0, 0, 0}, {".jar", "#Java", 0, 0, 0},
   {".go", "#Go", 0, 1, 0},
   {".d", "#D", 0, 1, 0}, {".dd", "#D", 0, 1, 0}, {".di", "#D", 0, 1, 0},
   /* Next come the entries for C.  */
diff --git a/gcc/gimple-expr.cc b/gcc/gimple-expr.cc
index 4fbce9369c7..c25d8ee4750 100644
--- a/gcc/gimple-expr.cc
+++ b/gcc/gimple-expr.cc
@@ -393,14 +393,14 @@ copy_var_decl (tree var, tree name, tree type)
 /* Strip off a legitimate source ending from the input string NAME of
length LEN.  Rather than having to know the names used by all of
our front ends, we strip off an ending of a period followed by
-   up to four characters.  (like ".cpp".)  */
+   up to five characters.  (Java uses ".class".)  */
 
 static inline void
 remove_suffix (char *name, int len)
 {
   int i;
 
-  for (i = 2;  i < 7 && len > i;  i++)
+  for (i = 2;  i < 8 && len > i;  i++)
 {
   if (name[len - i] == '.')
 	{
diff --git a/gcc/opts.cc b/gcc/opts.cc
index 3797784c865..5df153cc2cb 100644
--- a/gcc/opts.cc
+++ b/gcc/opts.cc
@@ -275,13 +275,13 @@ set_struct_debug_option (struct gcc_options *opts, location_t loc,
 /* Strip off a legitimate source ending from the input string NAME of
length LEN.  Rather than having to know the names used by all of
our front ends, we strip off an ending of a period followed by
-   up to fource characters.  (C++ uses ".cpp".)  */
+   up to five characters.  (Java uses ".class".)  */
 
 void
 strip_off_ending (char *name, int len)
 {
   int i;
-  for (i = 2; i < 5 && len > i; i++)
+  for (i = 2; i < 6 && len > i; i++)
 {
   if (name[len - i] == '.')
 	{
-- 
2.38.1



[PATCH 10/56] Re-add JCR_SECTION_NAME, TARGET_USE_JCR_SECTION, __LIBGCC_JCR_SECTION_NAME__, _Jv_RegisterClasses, __JCR_LIST__, __JCR_END__.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 82fa9c7851beeb448fc6977f92297fb123c9f1de Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 18:44:19 +1100
Subject: [PATCH 10/56] Re-add JCR_SECTION_NAME, TARGET_USE_JCR_SECTION,
 __LIBGCC_JCR_SECTION_NAME__, _Jv_RegisterClasses, __JCR_LIST__, __JCR_END__.

gcc/c-family/ChangeLog:

	* c-cppbuiltin.cc (c_cpp_builtins): Define __LIBGCC_JCR_SECTION_NAME__.

gcc/ChangeLog:

	* config/darwin.h (JCR_SECTION_NAME): Define.
	* config/i386/cygming.h (TARGET_USE_JCR_SECTION): Likewise.
	* config/i386/mingw32.h (TARGET_USE_JCR_SECTION): Undefine.
	* config/pa/pa64-hpux.h (JCR_SECTION_NAME): Re-add.
	* config/rs6000/aix71.h (TARGET_USE_JCR_SECTION): Define.
	* defaults.h (JCR_SECTION_NAME): Define.
	(TARGET_USE_JCR_SECTION): Define.
	* doc/tm.texi.in (TARGET_USE_JCR_SECTION): Document.
	* doc/tm.texi: Regenerate.
	* system.h (fancy_abort): Do not poison TARGET_USE_JCR_SECTION nor JCR_SECTION_NAME.

libgcc/ChangeLog:

	* config/i386/cygming-crtbegin.c (_Jv_RegisterClasses): Re-add.
	(__JCR_LIST__): Likewise.
	(__gcc_register_frame): Attempt to _Jv_RegisterClasses.
	* config/i386/cygming-crtend.c (__JCR_END__): Re-add.
	* config/ia64/crtbegin.S (__JCR_LIST__): Likewise.
	* config/ia64/crtend.S (__JCR_END__): Likewise.
	* config/pa/pa64-hpux-lib.h (defined):
	* crtstuff.c: Re-add __LIBGCC_JCR_SECTION_NAME__ to preprocessor conditionals.
	(__JCR_LIST__, __JCR_END__): Re-add.
	(frame_dummy): Attempt to _Jv_RegisterClasses.
	(__do_global_ctors_1): Likewise.
---
 gcc/c-family/c-cppbuiltin.cc  |  4 ++
 gcc/config/darwin.h   |  3 ++
 gcc/config/i386/cygming.h |  5 +++
 gcc/config/i386/mingw32.h |  3 ++
 gcc/config/pa/pa64-hpux.h |  2 +
 gcc/config/rs6000/aix71.h |  2 +
 gcc/defaults.h| 21 ++
 gcc/doc/tm.texi   |  6 +++
 gcc/doc/tm.texi.in|  6 +++
 gcc/system.h  |  3 +-
 libgcc/config/i386/cygming-crtbegin.c | 12 ++
 libgcc/config/i386/cygming-crtend.c   |  8 
 libgcc/config/ia64/crtbegin.S |  4 ++
 libgcc/config/ia64/crtend.S   |  5 +++
 libgcc/config/pa/pa64-hpux-lib.h  |  4 +-
 libgcc/crtstuff.c | 57 ---
 16 files changed, 136 insertions(+), 9 deletions(-)

diff --git a/gcc/c-family/c-cppbuiltin.cc b/gcc/c-family/c-cppbuiltin.cc
index 333f3e138d6..bdc834afbb8 100644
--- a/gcc/c-family/c-cppbuiltin.cc
+++ b/gcc/c-family/c-cppbuiltin.cc
@@ -1480,6 +1480,10 @@ c_cpp_builtins (cpp_reader *pfile)
   builtin_define_with_value ("__LIBGCC_EH_FRAME_SECTION_NAME__",
  EH_FRAME_SECTION_NAME, 1);
 #endif
+#ifdef JCR_SECTION_NAME
+  builtin_define_with_value ("__LIBGCC_JCR_SECTION_NAME__",
+ JCR_SECTION_NAME, 1);
+#endif
 #ifdef CTORS_SECTION_ASM_OP
   builtin_define_with_value ("__LIBGCC_CTORS_SECTION_ASM_OP__",
  CTORS_SECTION_ASM_OP, 1);
diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index d1b4f277c2e..3cea1f7a36e 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -1067,6 +1067,9 @@ enum machopic_addr_class {
 #define EH_FRAME_SECTION_NAME   "__TEXT"
 #define EH_FRAME_SECTION_ATTR ",coalesced,no_toc+strip_static_syms+live_support"
 
+/* Java runtime class list.  */
+#define JCR_SECTION_NAME "__DATA,jcr,regular,no_dead_strip"
+
 #undef ASM_PREFERRED_EH_DATA_FORMAT
 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL)  \
   (((CODE) == 2 && (GLOBAL) == 1) \
diff --git a/gcc/config/i386/cygming.h b/gcc/config/i386/cygming.h
index 867ac5bf181..921279b9837 100644
--- a/gcc/config/i386/cygming.h
+++ b/gcc/config/i386/cygming.h
@@ -444,6 +444,11 @@ do {		\
 
 #endif /* HAVE_GAS_WEAK */
 
+/* FIXME: SUPPORTS_WEAK && TARGET_HAVE_NAMED_SECTIONS is true,
+   but for .jcr section to work we also need crtbegin and crtend
+   objects.  */
+#define TARGET_USE_JCR_SECTION 1
+
 /* Decide whether it is safe to use a local alias for a virtual function
when constructing thunks.  */
 #undef TARGET_USE_LOCAL_THUNK_ALIAS_P
diff --git a/gcc/config/i386/mingw32.h b/gcc/config/i386/mingw32.h
index c1ab489c377..d3a1dd3292e 100644
--- a/gcc/config/i386/mingw32.h
+++ b/gcc/config/i386/mingw32.h
@@ -281,6 +281,9 @@ do {		 \
 #undef TARGET_N_FORMAT_TYPES
 #define TARGET_N_FORMAT_TYPES 3
 
+/* Let defaults.h definition of TARGET_USE_JCR_SECTION apply. */
+#undef TARGET_USE_JCR_SECTION
+
 #define HAVE_ENABLE_EXECUTE_STACK
 #undef  CHECK_EXECUTE_STACK_ENABLED
 #define CHECK_EXECUTE_STACK_ENABLED flag_setstackexecutable
diff --git a/gcc/config/pa/pa64-hpux.h b/gcc/config/pa/pa64-hpux.h
index a35f428bb44..8cb9bef520f 100644
--- a/gcc/config/pa/pa64-hpux.h
+++ b/gcc/config/pa/pa64-hpux.h
@@ -164,6 +164,8 @@ along with GCC; see the file COPYING3.  If not see
 #define DATA_SECTION_ASM_OP	"\t.data"
 #define BSS_SECTION_ASM_OP	"\t.section\t.bss"
 
+#define JCR_SECTION_NAME ".jcr"
+
 #define HP_INIT_ARRAY_SECTION_ASM_OP	"\t.section\t.init"
 

[PATCH 22/56] java: Comment out -fassert documentation.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 802da4df1d0fba08ab3e14529f10942ed87d4eef Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 09:54:55 +1100
Subject: [PATCH 22/56] java: Comment out -fassert documentation.

gcc/java/ChangeLog:

	* lang.opt: Comment out -fassert documentation.
---
 gcc/java/lang.opt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/java/lang.opt b/gcc/java/lang.opt
index c077b6a97f8..a6596d55a9c 100644
--- a/gcc/java/lang.opt
+++ b/gcc/java/lang.opt
@@ -154,7 +154,7 @@ Java Separate RejectNegative Undocumented
 
 fassert
 Java Var(flag_assert) Init(1)
-Permit the use of the assert keyword.
+; Permit the use of the assert keyword.
 
 fassume-compiled
 Java
-- 
2.38.1



[PATCH 09/56] Re-add LIBGCJ_SONAME.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 724c8fd361781a31f2899876e28ccd783805b599 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 18:48:12 +1100
Subject: [PATCH 09/56] Re-add LIBGCJ_SONAME.

gcc/ChangeLog:

	* config/i386/cygwin.h (LIBGCJ_SONAME): Define.
	* config/i386/mingw32.h (LIBGCJ_SONAME): Likewise.

libgcc/ChangeLog:

	* config/i386/cygming-crtbegin.c (LIBGCJ_SONAME): Define.
---
 gcc/config/i386/cygwin.h  | 3 +++
 gcc/config/i386/mingw32.h | 2 ++
 libgcc/config/i386/cygming-crtbegin.c | 4 
 3 files changed, 9 insertions(+)

diff --git a/gcc/config/i386/cygwin.h b/gcc/config/i386/cygwin.h
index 0a604d65b32..4544b738df1 100644
--- a/gcc/config/i386/cygwin.h
+++ b/gcc/config/i386/cygwin.h
@@ -153,6 +153,9 @@ along with GCC; see the file COPYING3.  If not see
 #endif
 #define LIBGCC_SONAME "cyggcc_s" LIBGCC_EH_EXTN "-1.dll"
 
+/* We should find a way to not have to update this manually.  */
+#define LIBGCJ_SONAME "cyggcj" /*LIBGCC_EH_EXTN*/ "-16.dll"
+
 /* Make stack executable to avoid DEP problems with trampolines.  */
 #define HAVE_ENABLE_EXECUTE_STACK
 #undef  CHECK_EXECUTE_STACK_ENABLED
diff --git a/gcc/config/i386/mingw32.h b/gcc/config/i386/mingw32.h
index 19a98c3d995..c1ab489c377 100644
--- a/gcc/config/i386/mingw32.h
+++ b/gcc/config/i386/mingw32.h
@@ -294,3 +294,5 @@ do {		 \
 #endif
 #define LIBGCC_SONAME "libgcc_s" LIBGCC_EH_EXTN "-1.dll"
 
+/* We should find a way to not have to update this manually.  */
+#define LIBGCJ_SONAME "cyggcj" /*LIBGCC_EH_EXTN*/ "-16.dll"
diff --git a/libgcc/config/i386/cygming-crtbegin.c b/libgcc/config/i386/cygming-crtbegin.c
index ed97b073819..43096c7813f 100644
--- a/libgcc/config/i386/cygming-crtbegin.c
+++ b/libgcc/config/i386/cygming-crtbegin.c
@@ -42,6 +42,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #define LIBGCC_SONAME "libgcc_s.dll"
 #endif
 
+#ifndef LIBGCJ_SONAME
+#define LIBGCJ_SONAME "libgcj_s.dll"
+#endif
+
 #if DWARF2_UNWIND_INFO
 /* Make the declarations weak.  This is critical for
_Jv_RegisterClasses because it lives in libgcj.a  */
-- 
2.38.1



[PATCH 19/56] Revert "Move void_list_node init to common code". (8ff2a92a0450243e52d3299a13b30f208bafa7e0)

2022-11-25 Thread Zopolis0 via Gcc-patches

From c173c5771008522c13792bf89a27f6c95989dce5 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 09:26:42 +1100
Subject: [PATCH 19/56] Revert "Move void_list_node init to common code".
 (8ff2a92a0450243e52d3299a13b30f208bafa7e0)

gcc/ada/ChangeLog:

	* gcc-interface/trans.cc (gigi): Initialize void_list_node.

gcc/c-family/ChangeLog:

	* c-common.cc (c_common_nodes_and_builtins): Initialize void_list_node.
	* c-common.h (build_void_list_node): Re-add.

gcc/c/ChangeLog:

	* c-decl.cc (build_void_list_node): Re-add.

gcc/cp/ChangeLog:

	* decl.cc (cxx_init_decl_processing): No longer inline last build_void_list_node call.
	(build_void_list_node): Re-add.

gcc/d/ChangeLog:

	* d-builtins.cc (d_build_c_type_nodes): Initialize void_list_node.

gcc/fortran/ChangeLog:

	* f95-lang.cc (gfc_init_decl_processing): Initialize void_list_node.

gcc/go/ChangeLog:

	* go-lang.cc (go_langhook_init): Initialize void_list_node.

gcc/jit/ChangeLog:

	* dummy-frontend.cc (jit_langhook_init): Initialize void_list_node.

gcc/lto/ChangeLog:

	* lto-lang.cc (lto_build_c_type_nodes): Initialize void_list_node.

gcc/ChangeLog:

	* tree.cc (build_common_tree_nodes): Do not initialize void_list_node here.
---
 gcc/ada/gcc-interface/trans.cc |  1 +
 gcc/c-family/c-common.cc   |  2 ++
 gcc/c-family/c-common.h|  1 +
 gcc/c/c-decl.cc|  8 
 gcc/cp/decl.cc | 10 +-
 gcc/d/d-builtins.cc|  1 +
 gcc/fortran/f95-lang.cc|  2 ++
 gcc/go/go-lang.cc  |  3 +++
 gcc/jit/dummy-frontend.cc  |  3 +++
 gcc/lto/lto-lang.cc|  1 +
 gcc/tree.cc|  2 --
 11 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc
index 1cd621a9377..da18a4dd49b 100644
--- a/gcc/ada/gcc-interface/trans.cc
+++ b/gcc/ada/gcc-interface/trans.cc
@@ -413,6 +413,7 @@ gigi (Node_Id gnat_root,
   save_gnu_tree (gnat_literal, t, false);
 
   /* Declare the building blocks of function nodes.  */
+  void_list_node = build_tree_list (NULL_TREE, void_type_node);
   void_ftype = build_function_type_list (void_type_node, NULL_TREE);
   ptr_void_ftype = build_pointer_type (void_ftype);
 
diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc
index 6f1f21bc4c1..fe7bbcbc13b 100644
--- a/gcc/c-family/c-common.cc
+++ b/gcc/c-family/c-common.cc
@@ -4490,6 +4490,8 @@ c_common_nodes_and_builtins (void)
 TYPE_NAME (void_type_node) = void_name;
   }
 
+  void_list_node = build_void_list_node ();
+
   /* Make a type to be the domain of a few array types
  whose domains don't really matter.
  200 is small enough that it always fits in size_t
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index f9d0d2945a5..52962c0f19f 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -840,6 +840,7 @@ extern tree identifier_global_tag (tree);
 extern bool names_builtin_p (const char *);
 extern tree c_linkage_bindings (tree);
 extern void record_builtin_type (enum rid, const char *, tree);
+extern tree build_void_list_node (void);
 extern void start_fname_decls (void);
 extern void finish_fname_decls (void);
 extern const char *fname_as_string (int);
diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc
index 098e475f65d..6d81c37ca38 100644
--- a/gcc/c/c-decl.cc
+++ b/gcc/c/c-decl.cc
@@ -11236,6 +11236,14 @@ record_builtin_type (enum rid rid_index, const char *name, tree type)
 debug_hooks->type_decl (decl, false);
 }
 
+/* Build the void_list_node (void_type_node having been created).  */
+tree
+build_void_list_node (void)
+{
+  tree t = build_tree_list (NULL_TREE, void_type_node);
+  return t;
+}
+
 /* Return a c_parm structure with the given SPECS, ATTRS and DECLARATOR.  */
 
 struct c_parm *
diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index 544efdc9914..06740d420d9 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -4750,7 +4750,7 @@ cxx_init_decl_processing (void)
   record_unknown_type (init_list_type_node, "init list");
 
   /* Used when parsing to distinguish parameter-lists () and (void).  */
-  explicit_void_list_node = build_tree_list (NULL_TREE, void_type_node);
+  explicit_void_list_node = build_void_list_node ();
 
   {
 /* Make sure we get a unique function type, so we can give
@@ -18659,6 +18659,14 @@ cp_tree_node_structure (union lang_tree_node * t)
 }
 }
 
+/* Build the void_list_node (void_type_node having been created).  */
+tree
+build_void_list_node (void)
+{
+  tree t = build_tree_list (NULL_TREE, void_type_node);
+  return t;
+}
+
 bool
 cp_missing_noreturn_ok_p (tree decl)
 {
diff --git a/gcc/d/d-builtins.cc b/gcc/d/d-builtins.cc
index 51e562a96c1..6533c7e205f 100644
--- a/gcc/d/d-builtins.cc
+++ b/gcc/d/d-builtins.cc
@@ -892,6 +892,7 @@ static GTY(()) tree signed_size_type_node;
 static void
 d_build_c_type_nodes (void)
 {
+  void_list_node = build_tree_list (NULL_TREE, void_type_node);
   string_type_node = 

[PATCH 08/56] Re-add MODIFY_JNI_METHOD_CALL.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 558ba6feeeb75bafdbcadd05a8e708b567b3bfc0 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 17 Nov 2022 14:08:04 +1100
Subject: [PATCH 08/56] Re-add MODIFY_JNI_METHOD_CALL.

gcc/ChangeLog:

	* config/i386/cygming.h (MODIFY_JNI_METHOD_CALL): Define.
	* doc/tm.texi: Rebuild.
	* doc/tm.texi.in (Misc): Document MODIFY_JNI_METHOD_CALL.
---
 gcc/config/i386/cygming.h |  8 
 gcc/doc/tm.texi   | 16 
 gcc/doc/tm.texi.in| 16 
 3 files changed, 40 insertions(+)

diff --git a/gcc/config/i386/cygming.h b/gcc/config/i386/cygming.h
index 4007fd96eac..867ac5bf181 100644
--- a/gcc/config/i386/cygming.h
+++ b/gcc/config/i386/cygming.h
@@ -376,6 +376,14 @@ do {		\
 	const0_rtx));			\
 }
 
+/* Java Native Interface (JNI) methods on Win32 are invoked using the
+   stdcall calling convention.  */
+#undef MODIFY_JNI_METHOD_CALL
+#define MODIFY_JNI_METHOD_CALL(MDECL)	  \
+  build_type_attribute_variant ((MDECL),  \
+			   build_tree_list (get_identifier ("stdcall"),   \
+		NULL))
+
 /* For Win32 ABI compatibility */
 #undef DEFAULT_PCC_STRUCT_RETURN
 #define DEFAULT_PCC_STRUCT_RETURN 0
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index af77d16030c..c370c34b584 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -11954,6 +11954,22 @@ object files that are not referenced from @code{main} and uses export
 lists.
 @end defmac
 
+@defmac MODIFY_JNI_METHOD_CALL (@var{mdecl})
+Define this macro to a C expression representing a variant of the
+method call @var{mdecl}, if Java Native Interface (JNI) methods
+must be invoked differently from other methods on your target.
+For example, on 32-bit Microsoft Windows, JNI methods must be invoked using
+the @code{stdcall} calling convention and this macro is then
+defined as this expression:
+
+@smallexample
+build_type_attribute_variant (@var{mdecl},
+  build_tree_list
+  (get_identifier ("stdcall"),
+   NULL))
+@end smallexample
+@end defmac
+
 @deftypefn {Target Hook} bool TARGET_CANNOT_MODIFY_JUMPS_P (void)
 This target hook returns @code{true} past the point in which new jump
 instructions could be created.  On machines that require a register for
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index 62c49ac46de..1ec14c27b40 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -,6 +,22 @@ object files that are not referenced from @code{main} and uses export
 lists.
 @end defmac
 
+@defmac MODIFY_JNI_METHOD_CALL (@var{mdecl})
+Define this macro to a C expression representing a variant of the
+method call @var{mdecl}, if Java Native Interface (JNI) methods
+must be invoked differently from other methods on your target.
+For example, on 32-bit Microsoft Windows, JNI methods must be invoked using
+the @code{stdcall} calling convention and this macro is then
+defined as this expression:
+
+@smallexample
+build_type_attribute_variant (@var{mdecl},
+  build_tree_list
+  (get_identifier ("stdcall"),
+   NULL))
+@end smallexample
+@end defmac
+
 @hook TARGET_CANNOT_MODIFY_JUMPS_P
 
 @hook TARGET_HAVE_CONDITIONAL_EXECUTION
-- 
2.38.1



[PATCH 14/56] middle-end: Set TREE_ADDRESSABLE in folding debug stmts.

2022-11-25 Thread Zopolis0 via Gcc-patches

From c38422135e51852cdfe3236176afd0e2e3c53707 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 09:16:15 +1100
Subject: [PATCH 14/56] middle-end: Set TREE_ADDRESSABLE in folding debug
 stmts.

gcc/ChangeLog:

	* gimple-fold.cc (canonicalize_constructor_val): Set TREE_ADDRESSABLE.

gcc/testsuite/ChangeLog:

	* g++.dg/tree-ssa/array-temp1.C: Adjust.
---
 gcc/gimple-fold.cc  | 4 +---
 gcc/testsuite/g++.dg/tree-ssa/array-temp1.C | 6 ++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index efc0354566e..e788d4a79db 100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -248,9 +248,7 @@ canonicalize_constructor_val (tree cval, tree from_decl)
   if (TREE_TYPE (base) == error_mark_node)
 	return NULL_TREE;
   if (VAR_P (base))
-	/* ???  We should be able to assert that TREE_ADDRESSABLE is set,
-	   but since the use can be in a debug stmt we can't.  */
-	;
+	TREE_ADDRESSABLE (base) = 1;
   else if (TREE_CODE (base) == FUNCTION_DECL)
 	{
 	  /* Make sure we create a cgraph node for functions we'll reference.
diff --git a/gcc/testsuite/g++.dg/tree-ssa/array-temp1.C b/gcc/testsuite/g++.dg/tree-ssa/array-temp1.C
index 3df7aadd30a..97c2e0521c9 100644
--- a/gcc/testsuite/g++.dg/tree-ssa/array-temp1.C
+++ b/gcc/testsuite/g++.dg/tree-ssa/array-temp1.C
@@ -13,3 +13,9 @@ int f()
   using AR = const int[];
   return AR{ 1,42,3,4,5,6,7,8,9,0 }[5];
 }
+
+int g()
+{
+  std::initializer_list a = {1,42,3};
+  return a.begin()[0];
+}
-- 
2.38.1



[PATCH 07/56] Darwin: Re-add Java workaround constraint about putting small items into data/static data.

2022-11-25 Thread Zopolis0 via Gcc-patches

From aa73ec10a5b2503760042bcfd031d3f17af64c87 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 17 Nov 2022 14:05:59 +1100
Subject: [PATCH 07/56] Darwin: Re-add Java workaround constraint about putting
 small items into data/static data.

gcc/ChangeLog:

	* config/darwin.cc (darwin_emit_local_bss): Re-add Java workaround constraint about putting small items into data/static data.
	(fprintf): Likewise.
---
 gcc/config/darwin.cc | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc
index 1b3de338926..8986e878709 100644
--- a/gcc/config/darwin.cc
+++ b/gcc/config/darwin.cc
@@ -2482,7 +2482,11 @@ darwin_emit_local_bss (FILE *fp, tree decl, const char *name,
 			unsigned HOST_WIDE_INT size,
 			unsigned int l2align)
 {
-   if (DARWIN_SECTION_ANCHORS && flag_section_anchors && size < BYTES_ZFILL)
+   /* FIXME: We have a fudge to make this work with Java even when the target does
+   not use sections anchors -- Java seems to need at least one small item in a
+   non-zerofill segment.   */
+   if ((DARWIN_SECTION_ANCHORS && flag_section_anchors && size < BYTES_ZFILL)
+   || (size && size <= 2))
 {
   /* Put smaller objects in _static_data, where the section anchors system
 	 can get them.
@@ -2649,8 +2653,9 @@ fprintf (fp, "# albss: %s (%lld,%d) ro %d cst %d stat %d com %d"
   return;
 }
 
-  /* So we have a public symbol.  */
-  if (DARWIN_SECTION_ANCHORS && flag_section_anchors && size < BYTES_ZFILL)
+  /* So we have a public symbol (small item fudge for Java, see above).  */
+  if ((DARWIN_SECTION_ANCHORS && flag_section_anchors && size < BYTES_ZFILL)
+   || (size && size <= 2))
 {
   /* Put smaller objects in data, where the section anchors system can get
 	 them.  However, if they are zero-sized punt them to yet a different
-- 
2.38.1



[PATCH 06/56] Re-add tests for Java.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 260c6b8b5a0706151e304a53c347cbd2c8c68fe1 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 17 Nov 2022 13:56:46 +1100
Subject: [PATCH 06/56] Re-add tests for Java.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/java-1.C: Re-add test.
	* g++.dg/ext/java-2.C: Likewise.
	* g++.dg/ext/java-3.C: Likewise.
	* g++.dg/ext/pr34829.C: Likewise.
	* g++.dg/lookup/java1.C: Likewise.
	* g++.dg/lookup/java2.C: Likewise.
	* g++.dg/other/error12.C: Likewise.
	* g++.dg/other/java1.C: Likewise.
	* g++.dg/other/java2.C: Likewise.
	* g++.dg/other/java3.C: Likewise.
	* g++.dg/warn/Wnvdtor.C: Likewise.
	* g++.old-deja/g++.oliva/dwarf2.C: Likewise.
---
 gcc/testsuite/g++.dg/ext/java-1.C | 26 ++
 gcc/testsuite/g++.dg/ext/java-2.C | 79 +++
 gcc/testsuite/g++.dg/ext/java-3.C | 39 +
 gcc/testsuite/g++.dg/ext/pr34829.C| 22 ++
 gcc/testsuite/g++.dg/lookup/java1.C   | 68 
 gcc/testsuite/g++.dg/lookup/java2.C   | 47 +++
 gcc/testsuite/g++.dg/other/error12.C  |  9 +++
 gcc/testsuite/g++.dg/other/java1.C| 22 ++
 gcc/testsuite/g++.dg/other/java2.C| 11 +++
 gcc/testsuite/g++.dg/other/java3.C|  7 ++
 gcc/testsuite/g++.dg/warn/Wnvdtor.C   | 11 +++
 gcc/testsuite/g++.old-deja/g++.oliva/dwarf2.C | 10 +++
 12 files changed, 351 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/ext/java-1.C
 create mode 100644 gcc/testsuite/g++.dg/ext/java-2.C
 create mode 100644 gcc/testsuite/g++.dg/ext/java-3.C
 create mode 100644 gcc/testsuite/g++.dg/ext/pr34829.C
 create mode 100644 gcc/testsuite/g++.dg/lookup/java1.C
 create mode 100644 gcc/testsuite/g++.dg/lookup/java2.C
 create mode 100644 gcc/testsuite/g++.dg/other/error12.C
 create mode 100644 gcc/testsuite/g++.dg/other/java1.C
 create mode 100644 gcc/testsuite/g++.dg/other/java2.C
 create mode 100644 gcc/testsuite/g++.dg/other/java3.C
 create mode 100644 gcc/testsuite/g++.dg/warn/Wnvdtor.C
 create mode 100644 gcc/testsuite/g++.old-deja/g++.oliva/dwarf2.C

diff --git a/gcc/testsuite/g++.dg/ext/java-1.C b/gcc/testsuite/g++.dg/ext/java-1.C
new file mode 100644
index 000..f88e1fcab5d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/java-1.C
@@ -0,0 +1,26 @@
+// { dg-do compile { target { ! { powerpc-ibm-aix* } } } }
+// { dg-options "" }
+// Test extern "java" and some throwing of the objects.
+
+extern "Java"
+  namespace java
+  {
+namespace lang
+{
+  class Throwable;
+  class Class;
+  }
+}
+typedef class java::lang::Throwable* jthrowable;
+typedef class java::lang::Class* jclass;
+class java::lang::Throwable {
+public:
+  static jclass class$;
+};
+int
+_Jv_FindClassFromSignature ( )
+  try 
+{
+}
+  catch (java::lang::Throwable *ncdfe) {} 
+
diff --git a/gcc/testsuite/g++.dg/ext/java-2.C b/gcc/testsuite/g++.dg/ext/java-2.C
new file mode 100644
index 000..8114517b942
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/java-2.C
@@ -0,0 +1,79 @@
+// PR c++/30293
+// PR c++/30294
+// { dg-do compile { target { ! { powerpc-ibm-aix* } } } }
+// { dg-options "" }
+
+extern "Java" {
+typedef __java_byte jbyte;
+namespace java {
+namespace lang {
+  class Object {};
+  class Class {};
+}
+}
+typedef struct java::lang::Object* jobject;
+typedef java::lang::Class *jclass;
+}
+extern "C" jobject _Jv_AllocObject (jclass);
+
+extern "Java" {
+  struct A { static java::lang::Class class$; };
+}
+
+struct B {
+  A a;		// { dg-error "has Java class type" }
+};
+
+void* operator new (__SIZE_TYPE__, void*) throw();
+char buf[1024];
+
+A a;		// { dg-error "not allocated with" }
+A b = A ();	// { dg-error "not allocated with" }
+A *c = new ((void *) buf) A ();	// { dg-error "using placement new" }
+A *d = new A ();
+jbyte e = 6;
+
+const A fn1 ()	// { dg-error "return type has Java class type" }
+{
+  A a;		// { dg-error "not allocated with" }
+  return a;
+}
+
+A fn2 ()	// { dg-error "return type has Java class type" }
+{
+  A a;		// { dg-error "not allocated with" }
+  return a;
+}
+
+A *fn3 ()
+{
+  return new A ();
+}
+
+A  ()
+{
+  return *c;
+}
+
+jbyte fn5 ()
+{
+  return 7;
+}
+
+void fn6 (A x)	// { dg-error "has Java class type" }
+{
+}
+
+void fn7 (const A x)	// { dg-error "has Java class type" }
+{
+}
+
+void fn8 (A *x)
+{
+  (void) x;
+}
+
+void fn9 (jbyte x)
+{
+  (void) x;
+}
diff --git a/gcc/testsuite/g++.dg/ext/java-3.C b/gcc/testsuite/g++.dg/ext/java-3.C
new file mode 100644
index 000..128db653116
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/java-3.C
@@ -0,0 +1,39 @@
+// PR c++/70267
+// { dg-do compile { target { ! { powerpc-ibm-aix* } } } }
+// { dg-options "-O2" }
+
+extern "Java"
+{
+  typedef __java_int jint;
+  namespace java
+  {
+namespace lang
+{
+  class Class;
+  class Object;
+  class Throwable {};
+  class Foo;
+}
+  }
+} 
+
+typedef struct java::lang::Object * jobject;
+typedef struct java::lang::Throwable * jthrowable;
+typedef 

[PATCH 05/56] contrib: Re-add Java entries.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 1449424816c8f4df725c15498d1d7dc72f031e97 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 17 Nov 2022 13:54:51 +1100
Subject: [PATCH 05/56] contrib: Re-add Java entries.

contrib/ChangeLog:

	* gcc-changelog/git_commit.py: Re-add gcc/java and libjava.
	* gcc_update: Likewise.
	* patch_tester.sh: Re-add libjava.
	* update-copyright.py: Likewise.
	* warn_summary: Re-add gcc/java.
---
 contrib/gcc-changelog/git_commit.py |  2 ++
 contrib/gcc_update  |  8 
 contrib/patch_tester.sh |  1 +
 contrib/update-copyright.py | 25 +
 contrib/warn_summary|  4 ++--
 5 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/contrib/gcc-changelog/git_commit.py b/contrib/gcc-changelog/git_commit.py
index 3bd671011f2..dd671f720fc 100755
--- a/contrib/gcc-changelog/git_commit.py
+++ b/contrib/gcc-changelog/git_commit.py
@@ -39,6 +39,7 @@ default_changelog_locations = {
 'gcc/d',
 'gcc/fortran',
 'gcc/go',
+'gcc/java',
 'gcc/jit',
 'gcc/lto',
 'gcc/objc',
@@ -66,6 +67,7 @@ default_changelog_locations = {
 'libhsail-rt',
 'libiberty',
 'libitm',
+'libjava',
 'libobjc',
 'libphobos',
 'libquadmath',
diff --git a/contrib/gcc_update b/contrib/gcc_update
index c5630df6c4c..cf55b88dafb 100755
--- a/contrib/gcc_update
+++ b/contrib/gcc_update
@@ -96,6 +96,7 @@ gcc/config/rs6000/fusion.md: gcc/config/rs6000/genfusion.pl
 gcc/cp/cfns.h: gcc/cp/cfns.gperf
 gcc/cp/std-name-hint.h: gcc/cp/std-name-hint.gperf
 gcc/cp/std-name-hint.gperf: gcc/cp/cxxapi-data.csv
+gcc/java/keyword.h: gcc/java/keyword.gperf
 # testsuite
 # Without this, _Pragma3.c can have a false negative.
 gcc/testsuite/gcc.dg/cpp/_Pragma3.c: gcc/testsuite/gcc.dg/cpp/mi1c.h
@@ -132,6 +133,13 @@ libquadmath/configure: libquadmath/configure.ac libquadmath/aclocal.m4
 libquadmath/aclocal.m4: libquadmath/configure.ac libquadmath/acinclude.m4
 libquadmath/Makefile.in: libquadmath/Makefile.am libquadmath/configure.ac libgfortran/aclocal.m4
 libgfortran/configure: libgfortran/configure.ac libgfortran/aclocal.m4
+libjava/aclocal.m4: libjava/configure.ac
+libjava/Makefile.in: libjava/Makefile.am libjava/configure.ac libjava/aclocal.m4
+libjava/configure: libjava/configure.ac libjava/aclocal.m4
+libjava/libltdl/aclocal.m4: libjava/libltdl/configure.ac libjava/libltdl/acinclude.m4
+libjava/libltdl/Makefile.in: libjava/libltdl/Makefile.am libjava/libltdl/configure.ac libjava/libltdl/aclocal.m4
+libjava/libltdl/configure: libjava/libltdl/configure.ac libjava/libltdl/aclocal.m4
+libjava/libltdl/config-h.in: libjava/libltdl/configure.ac libjava/libltdl/aclocal.m4
 libcody/configure: libcody/configure.ac libcody/config.m4
 libcpp/aclocal.m4: libcpp/configure.ac
 libcpp/Makefile.in: libcpp/configure.ac libcpp/aclocal.m4
diff --git a/contrib/patch_tester.sh b/contrib/patch_tester.sh
index 56bb1ebf9b7..74b8e9e8ce1 100755
--- a/contrib/patch_tester.sh
+++ b/contrib/patch_tester.sh
@@ -191,6 +191,7 @@ gcc/testsuite/g++/g++.sum
 gcc/testsuite/objc/objc.sum
 $TARGET/libstdc++-v3/testsuite/libstdc++.sum
 $TARGET/libffi/testsuite/libffi.sum
+$TARGET/libjava/testsuite/libjava.sum
 $TARGET/libgomp/testsuite/libgomp.sum
 $TARGET/libmudflap/testsuite/libmudflap.sum"
 COMPILERS="gcc/cc1
diff --git a/contrib/update-copyright.py b/contrib/update-copyright.py
index 76614ffc4ea..09e3d12d763 100755
--- a/contrib/update-copyright.py
+++ b/contrib/update-copyright.py
@@ -631,6 +631,29 @@ class LibGCCFilter (GenericFilter):
 'soft-fp',
 ])
 
+class LibJavaFilter (GenericFilter):
+def __init__ (self):
+GenericFilter.__init__ (self)
+
+self.skip_dirs |= set ([
+# Handled separately.
+'testsuite',
+
+# Not really part of the library
+'contrib',
+
+# Imported from upstream
+'classpath',
+'libltdl',
+])
+
+def get_line_filter (self, dir, filename):
+if filename == 'NameDecoder.h':
+return re.compile ('.*NAME_COPYRIGHT')
+if filename == 'ICC_Profile.h':
+return re.compile ('.*icSigCopyrightTag')
+return GenericFilter.get_line_filter (self, dir, filename)
+
 class LibPhobosFilter (GenericFilter):
 def __init__ (self):
 GenericFilter.__init__ (self)
@@ -759,6 +782,8 @@ class GCCCmdLine (CmdLine):
 self.add_dir ('libgomp')
 self.add_dir ('libiberty')
 self.add_dir ('libitm')
+self.add_dir ('libjava', LibJavaFilter())
+self.add_dir (os.path.join ('libjava', 'testsuite'), TestsuiteFilter())
 self.add_dir ('libobjc')
 self.add_dir ('libphobos', LibPhobosFilter())
 self.add_dir ('libquadmath')
diff --git a/contrib/warn_summary b/contrib/warn_summary
index d4c8b6cdb19..0cfa969dafd 100755
--- a/contrib/warn_summary
+++ b/contrib/warn_summary
@@ -3,7 +3,7 @@
 

[PATCH 04/56] Re-add autotools glue for Java front-end and library.

2022-11-25 Thread Zopolis0 via Gcc-patches

From cf898ad31a103be8686c557d134dbcdc468adb9e Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 17 Nov 2022 13:51:26 +1100
Subject: [PATCH 04/56] Re-add autotools glue for Java front-end and library.

ChangeLog:

	* Makefile.def: Re-add GCJ and libjava.
	* Makefile.in: Regenerate.
	* Makefile.tpl: Re-add GCJ and libjava.
	* config-ml.in: Re-add GCJ.
	* configure: Regenerate.
	* configure.ac: Re-add GCJ and libjava, and add Java to the languages that require bdw-gc.

config/ChangeLog:

	* multi.m4: Re-add GCJ.

gcc/java/ChangeLog:

	* config-lang.in: Explicitly state target libraries rather than using removed libgcj_saved
---
 Makefile.def|  12 +
 Makefile.in | 534 
 Makefile.tpl|   9 +
 config-ml.in|  16 +-
 config/multi.m4 |   1 +
 configure   | 247 ++-
 configure.ac|  34 ++-
 gcc/java/config-lang.in |   2 +-
 8 files changed, 851 insertions(+), 4 deletions(-)

diff --git a/Makefile.def b/Makefile.def
index 02e63c57177..fbb907d1c7c 100644
--- a/Makefile.def
+++ b/Makefile.def
@@ -180,6 +180,8 @@ target_modules = { module= libtermcap; no_check=true;
 target_modules = { module= winsup; };
 target_modules = { module= libgloss; no_check=true; };
 target_modules = { module= libffi; no_install=true; };
+target_modules = { module= libjava; raw_cxx=true;
+		   extra_configure_flags="$(EXTRA_CONFIGARGS_LIBJAVA)"; };
 target_modules = { module= zlib; bootstrap=true; };
 target_modules = { module= rda; };
 target_modules = { module= libada; };
@@ -300,6 +302,7 @@ flags_to_pass = { flag= CXXFLAGS_FOR_TARGET ; };
 flags_to_pass = { flag= DLLTOOL_FOR_TARGET ; };
 flags_to_pass = { flag= DSYMUTIL_FOR_TARGET ; };
 flags_to_pass = { flag= FLAGS_FOR_TARGET ; };
+flags_to_pass = { flag= GCJ_FOR_TARGET ; };
 flags_to_pass = { flag= GFORTRAN_FOR_TARGET ; };
 flags_to_pass = { flag= GOC_FOR_TARGET ; };
 flags_to_pass = { flag= GOCFLAGS_FOR_TARGET ; };
@@ -598,6 +601,7 @@ dependencies = { module=all-m4; on=all-build-texinfo; };
 // Target modules.  These can also have dependencies on the language
 // environment (e.g. on libstdc++).  By default target modules depend
 // on libgcc and newlib/libgloss.
+lang_env_dependencies = { module=libjava; cxx=true; };
 lang_env_dependencies = { module=libitm; cxx=true; };
 lang_env_dependencies = { module=libffi; cxx=true; };
 lang_env_dependencies = { module=newlib; no_c=true; };
@@ -615,6 +619,11 @@ dependencies = { module=configure-target-libgo; on=all-target-libstdc++-v3; };
 dependencies = { module=all-target-libgo; on=all-target-libbacktrace; };
 dependencies = { module=all-target-libgo; on=all-target-libffi; };
 dependencies = { module=all-target-libgo; on=all-target-libatomic; };
+dependencies = { module=configure-target-libjava; on=configure-target-zlib; };
+dependencies = { module=configure-target-libjava; on=configure-target-libffi; };
+dependencies = { module=all-target-libjava; on=all-fastjar; };
+dependencies = { module=all-target-libjava; on=all-target-zlib; };
+dependencies = { module=all-target-libjava; on=all-target-libffi; };
 dependencies = { module=configure-target-libphobos; on=configure-target-libbacktrace; };
 dependencies = { module=configure-target-libphobos; on=configure-target-zlib; };
 dependencies = { module=all-target-libphobos; on=all-target-libbacktrace; };
@@ -636,6 +645,7 @@ dependencies = { module=install-target-libsanitizer; on=install-target-libstdc++
 dependencies = { module=install-target-libsanitizer; on=install-target-libgcc; };
 dependencies = { module=install-target-libvtv; on=install-target-libstdc++-v3; };
 dependencies = { module=install-target-libvtv; on=install-target-libgcc; };
+dependencies = { module=install-target-libjava; on=install-target-libgcc; };
 dependencies = { module=install-target-libitm; on=install-target-libgcc; };
 dependencies = { module=install-target-libobjc; on=install-target-libgcc; };
 dependencies = { module=install-target-libstdc++-v3; on=install-target-libgcc; };
@@ -662,6 +672,8 @@ languages = { language=fortran;	gcc-check-target=check-fortran;
 lib-check-target=check-target-libquadmath;
 lib-check-target=check-target-libgfortran;
 lib-check-target=check-target-libgomp-fortran; };
+languages = { language=java;	gcc-check-target=check-java;
+lib-check-target=check-target-libjava; };
 languages = { language=ada;	gcc-check-target=check-ada;
 lib-check-target=check-target-libada; };
 languages = { language=objc;	gcc-check-target=check-objc;
diff --git a/Makefile.in b/Makefile.in
index 6ffa9660c25..ebadff7cea3 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -158,6 +158,7 @@ BUILD_EXPORTS = \
 	CPPFLAGS="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS; \
 	CXX="$(CXX_FOR_BUILD)"; export CXX; \
 	CXXFLAGS="$(CXXFLAGS_FOR_BUILD)"; export CXXFLAGS; \
+	GCJ="$(GCJ_FOR_BUILD)"; export GCJ; \
 	GFORTRAN="$(GFORTRAN_FOR_BUILD)"; export GFORTRAN; \
 	

[PATCH 03/56] Re-add documentation for Java front-end and library.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 9dc7fa2aab60decf4abad15a66d26c50f67b9510 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 25 Nov 2022 18:28:09 +1100
Subject: [PATCH 03/56] Re-add documentation for Java front-end and library.

gcc/ChangeLog:

	* doc/cfg.texi: Re-add references to Java front-end and library.
	* doc/extend.texi: Likewise.
	* doc/frontends.texi: Likewise.
	* doc/generic.texi: Likewise.
	* doc/install.texi: Likewise.
	* doc/invoke.texi: Likewise.
	* doc/md.texi: Likewise.
	* doc/sourcebuild.texi: Likewise.
	* doc/standards.texi: Likewise.
---
 gcc/doc/cfg.texi |   5 +-
 gcc/doc/extend.texi  |  44 ++
 gcc/doc/frontends.texi   |   3 +-
 gcc/doc/generic.texi |   5 +
 gcc/doc/install.texi | 319 +--
 gcc/doc/invoke.texi  |  17 ++-
 gcc/doc/md.texi  |   3 +-
 gcc/doc/sourcebuild.texi |  34 -
 gcc/doc/standards.texi   |   3 +
 9 files changed, 406 insertions(+), 27 deletions(-)

diff --git a/gcc/doc/cfg.texi b/gcc/doc/cfg.texi
index 32aacdd0aa8..2c341b3cef2 100644
--- a/gcc/doc/cfg.texi
+++ b/gcc/doc/cfg.texi
@@ -285,7 +285,7 @@ is needed.  Note that this may require creation of a new basic block.
 Exception handling edges represent possible control transfers from a
 trapping instruction to an exception handler.  The definition of
 ``trapping'' varies.  In C++, only function calls can throw, but for
-Ada exceptions like division by zero or segmentation fault are
+Java and Ada, exceptions like division by zero or segmentation fault are
 defined and thus each instruction possibly throwing this kind of
 exception needs to be handled as control flow instruction.  Exception
 edges have the @code{EDGE_ABNORMAL} and @code{EDGE_EH} flags set.
@@ -594,7 +594,8 @@ can just use @code{NEXT_INSN} and @code{PREV_INSN} instead.  @xref{Insns}.
 Usually a code manipulating pass simplifies the instruction stream and
 the flow of control, possibly eliminating some edges.  This may for
 example happen when a conditional jump is replaced with an
-unconditional jump.  Updating of edges
+unconditional jump, but also when simplifying possibly trapping
+instruction to non-trapping while compiling Java.  Updating of edges
 is not transparent and each optimization pass is required to do so
 manually.  However only few cases occur in practice.  The pass may
 call @code{purge_dead_edges} on a given basic block to remove
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index b1dd39e64b8..fa1c00c16b2 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -24457,6 +24457,7 @@ Predefined Macros,cpp,The GNU C Preprocessor}).
 * Function Multiversioning::   Declaring multiple function versions.
 * Type Traits:: Compiler support for type traits.
 * C++ Concepts::Improved support for generic programming.
+* Java Exceptions:: Tweaking exception handling to work with Java.
 * Deprecated Features:: Things will disappear from G++.
 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
 @end menu
@@ -24976,6 +24977,14 @@ Some_Class  B  __attribute__ ((init_priority (543)));
 Note that the particular values of @var{priority} do not matter; only their
 relative ordering.
 
+@item java_interface
+@cindex @code{java_interface} type attribute
+
+This type attribute informs C++ that the class is a Java interface.  It may
+only be applied to classes declared within an @code{extern "Java"} block.
+Calls to methods declared in this interface are dispatched using GCJ's
+interface table mechanism, instead of regular virtual table dispatch.
+
 @item warn_unused
 @cindex @code{warn_unused} type attribute
 
@@ -25261,6 +25270,41 @@ A binary type trait: @code{true} whenever the type arguments are the same.
 @end table
 
 
+@node Java Exceptions
+@section Java Exceptions
+
+The Java language uses a slightly different exception handling model
+from C++.  Normally, GNU C++ automatically detects when you are
+writing C++ code that uses Java exceptions, and handle them
+appropriately.  However, if C++ code only needs to execute destructors
+when Java exceptions are thrown through it, GCC guesses incorrectly.
+Sample problematic code is:
+
+@smallexample
+  struct S @{ ~S(); @};
+  extern void bar();// @r{is written in Java, and may throw exceptions}
+  void foo()
+  @{
+S s;
+bar();
+  @}
+@end smallexample
+
+@noindent
+The usual effect of an incorrect guess is a link failure, complaining of
+a missing routine called @samp{__gxx_personality_v0}.
+
+You can inform the compiler that Java exceptions are to be used in a
+translation unit, irrespective of what it might think, by writing
+@samp{@w{#pragma GCC java_exceptions}} at the head of the file.  This
+@samp{#pragma} must appear before any functions that throw or catch
+exceptions, or run destructors when exceptions are thrown through them.
+
+You cannot mix Java and C++ exceptions in the same translation unit.  It
+is believed to be safe to throw a C++ exception from one file 

Java front-end and library patches.

2022-11-25 Thread Zopolis0 via Gcc-patches
Disclaimer: this does not currently work.

The front-end and library compile successfully, but fail to link at
the very end.
This is due to a regression caused by
1dedc12d186a110854537e1279b4e6c29f2df35a, which I have been unable to
solve.

Nevertheless, I am posting this patch series for two reasons.

Firstly, to get feedback and reviews on the 56 already existing
patches, even though most are just re-adding code or making idiomatic
changes, so that when the final issue is solved everything has already
been approved (hopefully) and the merge is good to go.

Secondly, to get assistance with the final issue, because it is simply
beyond me, and history has shown that asking for help via gcc-patches
will yield nothing.

You'll need libtool 2.4.7 and a bleeding-edge version of bdwgc to
build it, in case anyone planned to do some testing.

I have compressed the larger patches with bzip3, and attached the
rest, hopefully as plaintext.


Patch structure and timing for re-adding gcj

2022-05-19 Thread Zopolis0 via Gcc-patches
Over the past few months I have been working on re-adding gcj to gcc (
https://github.com/Zopolis4/gcj/tree/mster). It is now at the point where
all of the code in gcc/java and the related additions to other gcc files
compiles successfully, although libjava still breaks.

Given that I do not know how long it will be before it compiles
successfully, nor the remaining issues preventing it from compiling it
successfully, I was wondering if it would make sense to submit the gcc/java
(and the related additions) code now, as to have it receive treewide
changes rather than mysteriously breaking when I rebase and further slowing
down development.

This would also allow me to test files in libjava with the system gcc,
among other things, as they make use of several types declared in gcc/java.

Regardless of this, when all the code works, how should I submit it?

My current plan is to have an initial commit re-adding the gcc/java and
libjava directories in the exact state that they were removed, as so to
have a clean history, and also adding the java-related code in other gcc
files in a modern state. Then, a second commit modernising the code in
gcc/java and libjava.


Options for re-adding gcj

2022-04-17 Thread Zopolis0 via Gcc-patches
Over the past few months I have been working on re-adding gcj back into
gcc, as the fundamental issue holding it back (the need to create an
open-source implementation of java from the ground up) has since been
solved by the opening of the JDK.

Unfortunately, as the old gcj code is several years old, it does not work
nicely with the current code and is largely incomplete. I have gotten it
into a state where gcc will compile with default options, unless you
forcibly enable java.

The issues I am now encountering are far beyond my skill level, and would
require someone with much more familiarity with the gcc tree than me and
general coding experience.

This leaves a few options for creating a functional Java compiler using the
OpenJDK.

1. Add the code in its current state to the current gcc tree, and have it
gradually get repaired to a state of feature parity with when it was
removed, then replace the Classpath with the OpenJDK. (There are a variety
of options for this as well, but I aim to implement it in a way similar to
C/C++ standards.)

2. Try and identify the breaking changes, speak to the people who made them
(or other people familiar with the relevant areas of the gcc tree) and get
their assistance in extending those changes to the gcj source files.

3. Replace Classpath with OpenJDK in GCC 6, (following the same C/C++
standards idea as above), as this would not require any changes to source
files and would work seamlessly. However, this is obviously not optimal,
and I would prefer to avoid it.

Which option do people think is the best?