[llvm-commits] [llvm-gcc-4.2] r40053 - /llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
Duncan Sands
baldrick at free.fr
Thu Jul 19 05:56:39 PDT 2007
Author: baldrick
Date: Thu Jul 19 07:56:39 2007
New Revision: 40053
URL: http://llvm.org/viewvc/llvm-project?rev=40053&view=rev
Log:
It seems that you can take a COMPONENT_REF of a
transparent union field in gcc-4.2, so set field
indices in the transparent case. I don't know
about gcc-4.0.
Modified:
llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=40053&r1=40052&r2=40053&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Thu Jul 19 07:56:39 2007
@@ -1769,12 +1769,21 @@
if (TYPE_TRANSPARENT_UNION(type)) {
tree Field = TYPE_FIELDS(type);
assert(Field && "Transparent union must have some elements!");
- while (TREE_CODE(Field) != FIELD_DECL) {
+ tree FirstFieldDecl = NULL_TREE;
+ while (Field) {
+ if (TREE_CODE(Field) == FIELD_DECL) {
+ if (FirstFieldDecl == NULL_TREE)
+ FirstFieldDecl = Field;
+ // Set the field idx to zero for all fields.
+ SetFieldIndex(Field, 0);
+ }
+
Field = TREE_CHAIN(Field);
- assert(Field && "Transparent union must have some elements!");
}
-
- return TypeDB.setType(type, ConvertType(TREE_TYPE(Field)));
+ assert(FirstFieldDecl != NULL_TREE
+ && "Transparent union must have some elements!");
+
+ return TypeDB.setType(type, ConvertType(TREE_TYPE(FirstFieldDecl)));
}
// Note that we are compiling a struct now.
More information about the llvm-commits
mailing list