[LLVMbugs] [Bug 125] [llvmg++] Enum types are incorrectly shrunk to smaller than 'int' size
bugzilla-daemon at zion.cs.uiuc.edu
bugzilla-daemon at zion.cs.uiuc.edu
Tue Nov 18 12:56:49 PST 2003
http://llvm.cs.uiuc.edu/bugs/show_bug.cgi?id=125
sabre at nondot.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Summary|The xpdf program causes |[llvmg++] Enum types are
|llvm-g++ to hit assertion |incorrectly shrunk to
| |smaller than 'int' size
------- Additional Comments From sabre at nondot.org 2003-11-18 14:56 -------
Fixed. This was due to me misunderstanding the difference between
TYPE_PRECISION and TYPE_SIZE.
Testcase here: Regression/C++Frontend/2003-11-18-EnumArray.cpp
Patch is:
$ diff llvm-types.c~ llvm-types.c -u
--- llvm-types.c~ 2003-11-09 10:37:09.000000000 -0600
+++ llvm-types.c 2003-11-18 14:53:23.000000000 -0600
@@ -1240,22 +1240,11 @@
case VOID_TYPE: return VoidTy;
case BOOLEAN_TYPE: return BoolTy;
- case ENUMERAL_TYPE: /* Treat the same as integral type, but round up */
- case INTEGER_TYPE: {
- unsigned Size = TYPE_PRECISION(type);
- if (Size == 0)
- Size = TREE_INT_CST_LOW(TYPE_SIZE(type));
+ case ENUMERAL_TYPE:
+ case INTEGER_TYPE:
+ return llvm_type_get_integer(TREE_INT_CST_LOW(TYPE_SIZE(type)),
+ TREE_UNSIGNED(type));
- if (TREE_CODE(type) == ENUMERAL_TYPE) {
- /* Round enumeration size to a specified type */
- if (Size > 0 && Size < 8) Size = 8;
- if (Size > 8 && Size < 16) Size = 16;
- if (Size > 16 && Size < 32) Size = 32;
- if (Size > 32 && Size < 64) Size = 64;
- }
-
- return llvm_type_get_integer(Size, TREE_UNSIGNED(type));
- }
case REAL_TYPE:
switch(TYPE_PRECISION(type)) {
case 32: return FloatTy;
FWIW, this might also fix a large number of C++ warnings when linking programs,
and I wouldn't be suprised if this wasn't causing some C++ miscompilations as
well...
-Chris
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
More information about the llvm-bugs
mailing list