public inbox for java-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug java/21540] New: switch stmt problem
@ 2005-05-12 20:02 green at redhat dot com
  2005-05-12 20:03 ` [Bug java/21540] " green at redhat dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 11+ messages in thread
From: green at redhat dot com @ 2005-05-12 20:02 UTC (permalink / raw)
  To: java-prs

Compiling the attached results in:

[green@to-dhcp28 tmp]$ gcj -C bug.java
bug.java: In class 'bug':
bug.java: In method 'bug.fn(int)':
bug.java:9: error: Constant expression required.
            case ((int) xxx >>> 32):
               ^
1 error

-- 
           Summary: switch stmt problem
           Product: gcc
           Version: 4.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: java
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: green at redhat dot com
                CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu
                    dot org
  GCC host triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21540


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

* [Bug java/21540] switch stmt problem
  2005-05-12 20:02 [Bug java/21540] New: switch stmt problem green at redhat dot com
@ 2005-05-12 20:03 ` green at redhat dot com
  2005-05-12 21:50 ` pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: green at redhat dot com @ 2005-05-12 20:03 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From green at redhat dot com  2005-05-12 20:03 -------
Created an attachment (id=8880)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=8880&action=view)
Test case


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21540


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

* [Bug java/21540] switch stmt problem
  2005-05-12 20:02 [Bug java/21540] New: switch stmt problem green at redhat dot com
  2005-05-12 20:03 ` [Bug java/21540] " green at redhat dot com
@ 2005-05-12 21:50 ` pinskia at gcc dot gnu dot org
  2005-05-19 15:09 ` hchapman-gcc-bugs at 3gfp dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-12 21:50 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-05-12 21:49 -------
Confirmed, here is another example:
public class bug
{
    public static final long xxx = 555;
    public static final int xxx1 = (int)(xxx >>> 32);
    public int fn (int v)
    {
	switch (v)
	{
	case (xxx1):
	    return 1;
	}
       return 0;
    }
}

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |rejects-valid
      Known to fail|                            |3.0.4 3.2.3 3.2.2 3.3.3
                   |                            |3.4.0 4.0.0 4.1.0
   Last reconfirmed|0000-00-00 00:00:00         |2005-05-12 21:49:59
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21540


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

* [Bug java/21540] switch stmt problem
  2005-05-12 20:02 [Bug java/21540] New: switch stmt problem green at redhat dot com
  2005-05-12 20:03 ` [Bug java/21540] " green at redhat dot com
  2005-05-12 21:50 ` pinskia at gcc dot gnu dot org
@ 2005-05-19 15:09 ` hchapman-gcc-bugs at 3gfp dot com
  2005-05-19 15:27 ` falk at debian dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: hchapman-gcc-bugs at 3gfp dot com @ 2005-05-19 15:09 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From hchapman-gcc-bugs at 3gfp dot com  2005-05-19 15:09 -------
gcc has this problem as well. Although, it will let you have an expression using
only constants like

case 'A' + ('B'<<8):

but not

case *((uint16_t *)"AB"):

A gcc example:

#include <stdio.h>

int main()
{
  unsigned int xxx = 0x3456;

  switch(0x34)
  {
  case ((int)(xxx >> 16)):
    printf("Shift\n");
    break;
  default:
    printf("No shift\n");
    break;
  }

  return(0);
}

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21540


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

* [Bug java/21540] switch stmt problem
  2005-05-12 20:02 [Bug java/21540] New: switch stmt problem green at redhat dot com
                   ` (2 preceding siblings ...)
  2005-05-19 15:09 ` hchapman-gcc-bugs at 3gfp dot com
@ 2005-05-19 15:27 ` falk at debian dot org
  2005-06-21 18:36 ` tromey at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: falk at debian dot org @ 2005-05-19 15:27 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From falk at debian dot org  2005-05-19 15:27 -------
(In reply to comment #3)
> gcc has this problem as well. Although, it will let you have an expression using
> only constants like
> 
> case 'A' + ('B'<<8):
> 
> but not
> 
> case *((uint16_t *)"AB"):

Since C requires case labels to be integer constant expressions, and this
isn't one, there's no problem here.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21540


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

* [Bug java/21540] switch stmt problem
  2005-05-12 20:02 [Bug java/21540] New: switch stmt problem green at redhat dot com
                   ` (3 preceding siblings ...)
  2005-05-19 15:27 ` falk at debian dot org
@ 2005-06-21 18:36 ` tromey at gcc dot gnu dot org
  2005-06-21 19:05 ` tromey at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: tromey at gcc dot gnu dot org @ 2005-06-21 18:36 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From tromey at gcc dot gnu dot org  2005-06-21 18:36 -------
The bug here is that the semantic analysis for a case expression,
in parse.y:java_complete_lhs(), just does this:

      /* First, the case expression must be constant. Values of final
         fields are accepted. */
      cn = fold (cn);

However, fold() does not know about final fields and the like.

fold_constant_for_init doesn't seem to be factored properly to be
useful here, either.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21540


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

* [Bug java/21540] switch stmt problem
  2005-05-12 20:02 [Bug java/21540] New: switch stmt problem green at redhat dot com
                   ` (4 preceding siblings ...)
  2005-06-21 18:36 ` tromey at gcc dot gnu dot org
@ 2005-06-21 19:05 ` tromey at gcc dot gnu dot org
  2005-06-27 18:40 ` cvs-commit at gcc dot gnu dot org
  2005-06-27 18:41 ` tromey at gcc dot gnu dot org
  7 siblings, 0 replies; 11+ messages in thread
From: tromey at gcc dot gnu dot org @ 2005-06-21 19:05 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From tromey at gcc dot gnu dot org  2005-06-21 19:05 -------
I'm testing a patch.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |tromey at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2005-05-12 21:49:59         |2005-06-21 19:05:19
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21540


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

* [Bug java/21540] switch stmt problem
  2005-05-12 20:02 [Bug java/21540] New: switch stmt problem green at redhat dot com
                   ` (5 preceding siblings ...)
  2005-06-21 19:05 ` tromey at gcc dot gnu dot org
@ 2005-06-27 18:40 ` cvs-commit at gcc dot gnu dot org
  2005-06-27 18:41 ` tromey at gcc dot gnu dot org
  7 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-06-27 18:40 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-06-27 18:40 -------
Subject: Bug 21540

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	tromey@gcc.gnu.org	2005-06-27 18:40:17

Modified files:
	libjava        : ChangeLog 
	gcc/java       : ChangeLog parse.y 
	libjava/testsuite/libjava.jacks: jacks.xfail 
Added files:
	libjava/testsuite/libjava.compile: pr13788.java pr21540.java 

Log message:
	gcc/java/:
	PR java/21540, PR java/13788:
	* parse.y (java_complete_lhs) <CASE_EXPR>: Use
	fold_constant_for_init.
	(patch_binop): Added 'folding' argument.  Updated all callers.
	(patch_unaryop) <NOP_EXPR>: New case.
	(fold_constant_for_init) <NOP_EXPR>: Likewise.
	(fold_constant_for_init) <COND_EXPR>: Fix sense of test.
	libjava/:
	PR java/21540, PR java/13788:
	* testsuite/libjava.compile/pr21540.java: New file.
	* testsuite/libjava.compile/pr13788.java: New file.
	* testsuite/libjava.jacks/jacks.xfail: Updated.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/ChangeLog.diff?cvsroot=gcc&r1=1.3679&r2=1.3680
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/ChangeLog.diff?cvsroot=gcc&r1=1.1634&r2=1.1635
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/parse.y.diff?cvsroot=gcc&r1=1.541&r2=1.542
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/testsuite/libjava.compile/pr13788.java.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/testsuite/libjava.compile/pr21540.java.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/testsuite/libjava.jacks/jacks.xfail.diff?cvsroot=gcc&r1=1.24&r2=1.25



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21540


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

* [Bug java/21540] switch stmt problem
  2005-05-12 20:02 [Bug java/21540] New: switch stmt problem green at redhat dot com
                   ` (6 preceding siblings ...)
  2005-06-27 18:40 ` cvs-commit at gcc dot gnu dot org
@ 2005-06-27 18:41 ` tromey at gcc dot gnu dot org
  7 siblings, 0 replies; 11+ messages in thread
From: tromey at gcc dot gnu dot org @ 2005-06-27 18:41 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From tromey at gcc dot gnu dot org  2005-06-27 18:41 -------
I checked in the fix on cvs trunk.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21540


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

* [Bug java/21540] switch stmt problem
       [not found] <bug-21540-83@http.gcc.gnu.org/bugzilla/>
  2005-10-13  1:11 ` cvs-commit at gcc dot gnu dot org
@ 2005-10-13  1:13 ` mckinlay at redhat dot com
  1 sibling, 0 replies; 11+ messages in thread
From: mckinlay at redhat dot com @ 2005-10-13  1:13 UTC (permalink / raw)
  To: java-prs



------- Comment #10 from mckinlay at redhat dot com  2005-10-13 01:12 -------
Fixed checked in to 4.0 branch.


-- 

mckinlay at redhat dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|3.0.4 3.2.3 3.2.2 3.3.3     |3.0.4 3.2.3 3.2.2 3.3.3
                   |3.4.0 4.0.0 4.1.0           |3.4.0 4.0.0
   Target Milestone|---                         |4.0.3


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21540


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

* [Bug java/21540] switch stmt problem
       [not found] <bug-21540-83@http.gcc.gnu.org/bugzilla/>
@ 2005-10-13  1:11 ` cvs-commit at gcc dot gnu dot org
  2005-10-13  1:13 ` mckinlay at redhat dot com
  1 sibling, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-10-13  1:11 UTC (permalink / raw)
  To: java-prs



------- Comment #9 from cvs-commit at gcc dot gnu dot org  2005-10-13 01:11 -------
Subject: Bug 21540

CVSROOT:        /cvs/gcc
Module name:    gcc
Branch:         gcc-4_0-branch
Changes by:     bryce@gcc.gnu.org       2005-10-13 01:11:27

Modified files:
        gcc/java       : ChangeLog parse.y 
        libjava        : ChangeLog 
        libjava/testsuite/libjava.jacks: jacks.xfail 
Added files:
        libjava/testsuite/libjava.compile: pr13788.java pr21540.java 

Log message:
        gcc/java:
        2005-10-12  Tom Tromey  <tromey@redhat.com>

        PR java/21540, PR java/13788:
        * parse.y (java_complete_lhs) <CASE_EXPR>: Use
        fold_constant_for_init.
        (patch_binop): Added 'folding' argument.  Updated all callers.
        (patch_unaryop) <NOP_EXPR>: New case.
        (fold_constant_for_init) <NOP_EXPR>: Likewise.
        (fold_constant_for_init) <COND_EXPR>: Fix sense of test.

        libjava:
        2005-10-12  Andreas Tobler  <a.tobler@schweiz.ch>

        * testsuite/libjava.jacks/jacks.xfail: Remove 15.21-assoc-7,
        15.21-assoc-8, 15.21-equal-3, 15.28-string-11.

        2005-10-12  Tom Tromey  <tromey@redhat.com>

        PR java/21540, PR java/13788:
        * testsuite/libjava.compile/pr21540.java: New file.
        * testsuite/libjava.compile/pr13788.java: New file.
        * testsuite/libjava.jacks/jacks.xfail: Updated.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.1556.2.35&r2=1.1556.2.36
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/parse.y.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.528.6.5&r2=1.528.6.6
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.3391.2.105&r2=1.3391.2.106
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/testsuite/libjava.compile/pr13788.java.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.22.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/testsuite/libjava.compile/pr21540.java.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.22.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/testsuite/libjava.jacks/jacks.xfail.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.19.8.3&r2=1.19.8.4


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21540


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

end of thread, other threads:[~2005-10-13  1:13 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-12 20:02 [Bug java/21540] New: switch stmt problem green at redhat dot com
2005-05-12 20:03 ` [Bug java/21540] " green at redhat dot com
2005-05-12 21:50 ` pinskia at gcc dot gnu dot org
2005-05-19 15:09 ` hchapman-gcc-bugs at 3gfp dot com
2005-05-19 15:27 ` falk at debian dot org
2005-06-21 18:36 ` tromey at gcc dot gnu dot org
2005-06-21 19:05 ` tromey at gcc dot gnu dot org
2005-06-27 18:40 ` cvs-commit at gcc dot gnu dot org
2005-06-27 18:41 ` tromey at gcc dot gnu dot org
     [not found] <bug-21540-83@http.gcc.gnu.org/bugzilla/>
2005-10-13  1:11 ` cvs-commit at gcc dot gnu dot org
2005-10-13  1:13 ` mckinlay at redhat dot com

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