[LLVMbugs] [Bug 2092] New: DeclRefExpr and EnumConstantDecl have different signedness

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Mon Feb 25 13:47:01 PST 2008


           Summary: DeclRefExpr and EnumConstantDecl have different
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: parser
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: kremenek at cs.stanford.edu
                CC: llvmbugs at cs.uiuc.edu, snaroff at apple.com

Consider the following code:


  int assemble () {
    int j = 0;
    return j < MAXPREFIX;

In the return statement, the AST node for MAXPREFIX is a DeclRefExpr that
references an EnumConstantDecl for MAXPREFIX.  This DeclRefExpr has type 'int',
which represents a signed integer.  The EnumConstantDecl for MAXPREFIX
constants an APSInt object that represents an integer constant; this APSInt
object, however, is marked "unsigned"  (i.e., the method APSINT::isUnsigned()
returns true).  Here is the AST dump:

  int assemble()
  (CompoundStmt 0x9065e0 <assemble.i:7:17, line:10:1>
    (DeclStmt 0x906350 <:0:0>
      0x906520 "int j =
        (IntegerLiteral 0x906550 <assemble.i:8:11> 'int' 0)"
    (ReturnStmt 0x9065d0 <line:9:3, col:14>
      (BinaryOperator 0x9065b0 <col:10, col:14> 'int' '<'
        (DeclRefExpr 0x906570 <col:10> 'int' BlockVar='j' 0x906520)
        (DeclRefExpr 0x906590 <col:14> 'int' EnumConstant='MAXPREFIX'

The bug is that either the DeclRefExpr that wraps the EnumConstant should have
an unsigned type (and thus we should have an implicit cast somewhere) or that
the internal APSInt value of the EnumConstant should be marked signed.

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list