[gcjx] Patch: FYI: fix constant unsigned right shift
Tom Tromey
tromey@redhat.com
Tue Dec 20 00:32:00 GMT 2005
I'm checking this in on the gcjx branch.
Mark found that gcjx didn't compile the current ecj. I tracked this
down to a bug in constant unsigned right shift handling. The test
case:
public class ushr {
public static final long VAL = 0x400000000L;
public static void main(String[] args) {
switch (args.length) {
case 0:
case (int) (VAL >>> 34):
}
}
}
I also changed the error location on switch blocks (which is where the
problem was originally found) to be better.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* model/primitive.hh (unsigned_right_shift): Use long long.
* model/switch.cc (resolve): Use better error locations.
Index: model/switch.cc
===================================================================
--- model/switch.cc (revision 107914)
+++ model/switch.cc (working copy)
@@ -63,7 +63,7 @@
else
(*i)->resolve (scope);
if (assignment_conversion (switch_type, (*i).get ()) == NULL)
- throw error ("case expression not assignable to switch type");
+ throw (*i)->error ("case expression not assignable to switch type");
jint val;
if (is_enum)
@@ -74,13 +74,13 @@
model_enum_constant *enumc = unwrap_enum_constant ((*i).get ());
if (enumc == NULL)
- throw error ("case expression not enum constant");
+ throw (*i)->error ("case expression not enum constant");
val = enumc->get_ordinal ();
}
else
{
if (! (*i)->constant_p ())
- throw error ("case expression must be constant");
+ throw (*i)->error ("case expression must be constant");
fold (*i);
jvalue conv = bt->convert ((*i)->type (), (*i)->value ());
@@ -91,7 +91,7 @@
seen.insert (std::make_pair (val, (*i).get ()));
else
{
- std::cerr << error ("duplicate case value");
+ std::cerr << (*i)->error ("duplicate case value");
std::cerr
<< seen.find (val)->second->error ("original instance is here");
}
Index: model/primitive.hh
===================================================================
--- model/primitive.hh (revision 107604)
+++ model/primitive.hh (working copy)
@@ -458,8 +458,8 @@
{
// Only 'long' and 'int' shifts are supported.
assert (sig_char == 'I' || sig_char == 'J');
- unsigned long lval = (unsigned long) (T) l;
- unsigned long rval = (unsigned long) (T) r;
+ unsigned long long lval = (unsigned long long) (T) l;
+ unsigned long long rval = (unsigned long long) (T) r;
// This is a little ugly -- there should be a way to compute the
// mask.
if (sig_char == 'I')
More information about the Java-patches
mailing list