[llvm-branch-commits] [llvm-gcc-branch] r127791 - in /llvm-gcc-4.2/branches/Apple/Morbo: ./ gcc/llvm-convert.cpp

Stuart Hastings stuart at apple.com
Wed Mar 16 19:55:07 PDT 2011


Author: stuart
Date: Wed Mar 16 21:55:06 2011
New Revision: 127791

URL: http://llvm.org/viewvc/llvm-project?rev=127791&view=rev
Log:
Merge r127309 from trunk into Morbo.  <rdar://problem/9055247>

Modified:
    llvm-gcc-4.2/branches/Apple/Morbo/   (props changed)
    llvm-gcc-4.2/branches/Apple/Morbo/gcc/llvm-convert.cpp

Propchange: llvm-gcc-4.2/branches/Apple/Morbo/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Mar 16 21:55:06 2011
@@ -1,2 +1,2 @@
 /llvm/trunk:100565
-/llvm-gcc-4.2/trunk:98728,98841,98893,99196,99262,99305,99412,99592-99593,99629,99670,99982,99984-99986,99988,99992-99993,99995,99997-99999,100035,100149,100303,100565,100624-100626,100712,100721,101090-101091,101199,101216,101304,101333,101614,101804,101959,102139,102148,102433,102444,102506-102507,102511,102532,102561,102589,102636,102648,102745,103361,103366-103367,103394,103414,103644,103800,103918,104181,104384,104420,104423,104523,104726,105504,105828-105829,105902,105948-105949,106005,106243-106244,106270,106352,106564,106611-106612,106681,106690,106711,107062,107439,107843,108784-108786,109556-109557,109702,110043,110250,110405,110459,110501,110689,110727,113248,114961,118368,118749,127261-127262
+/llvm-gcc-4.2/trunk:98728,98841,98893,99196,99262,99305,99412,99592-99593,99629,99670,99982,99984-99986,99988,99992-99993,99995,99997-99999,100035,100149,100303,100565,100624-100626,100712,100721,101090-101091,101199,101216,101304,101333,101614,101804,101959,102139,102148,102433,102444,102506-102507,102511,102532,102561,102589,102636,102648,102745,103361,103366-103367,103394,103414,103644,103800,103918,104181,104384,104420,104423,104523,104726,105504,105828-105829,105902,105948-105949,106005,106243-106244,106270,106352,106564,106611-106612,106681,106690,106711,107062,107439,107843,108784-108786,109556-109557,109702,110043,110250,110405,110459,110501,110689,110727,113248,114961,118368,118749,127261-127262,127309

Modified: llvm-gcc-4.2/branches/Apple/Morbo/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Morbo/gcc/llvm-convert.cpp?rev=127791&r1=127790&r2=127791&view=diff
==============================================================================
--- llvm-gcc-4.2/branches/Apple/Morbo/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/branches/Apple/Morbo/gcc/llvm-convert.cpp Wed Mar 16 21:55:06 2011
@@ -8529,13 +8529,27 @@
   // Convert the constant itself.
   Constant *Val = Convert(VEC_index(constructor_elt, elt, 0)->value);
 
-  // Unions are initialized using the first member field.  Find it.
+  // Unions are initialized using the first non-anonymous member field.  Find it.
   tree Field = TYPE_FIELDS(TREE_TYPE(exp));
+  tree namedField = Field;
+  tree first_field_decl = 0;
   assert(Field && "cannot initialize union with no fields");
-  while (TREE_CODE(Field) != FIELD_DECL) {
-    Field = TREE_CHAIN(Field);
-    assert(Field && "cannot initialize union with no fields");
+  while (namedField && (TREE_CODE(namedField) != FIELD_DECL ||
+                        DECL_NAME(namedField) == NULL_TREE)) {
+    // Remember the first field_decl we encounter.
+    if (!first_field_decl && TREE_CODE(namedField) == FIELD_DECL)
+      first_field_decl = namedField;
+    namedField = TREE_CHAIN(namedField);
   }
+  // If we located a legitimate, named field, prefer it;
+  // failing that, use the first_field_decl we found...
+  if (namedField)
+    Field = namedField;
+  else if (first_field_decl)
+    Field = first_field_decl;
+  // ...else, failing all of the above, use whatever we found at the top.
+
+  assert(Field && "cannot initialize union with no fields");
 
   // If this is a non-bitfield value, just slap it onto the end of the struct
   // with the appropriate padding etc.  If it is a bitfield, we have more





More information about the llvm-branch-commits mailing list