summaryrefslogtreecommitdiff
path: root/libcc1
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2015-07-03 07:26:12 -0300
committerAlexandre Oliva <aoliva@redhat.com>2016-02-19 19:55:06 -0200
commitc086fe9bc8e12fe2c19ce5b1e5d93227897e56c3 (patch)
tree1abbfee9d988918522eaf53607147a5dac4d11d3 /libcc1
parentea3446d7d52922e3ee974d25dab4a448364a142c (diff)
downloadgcc-c086fe9bc8e12fe2c19ce5b1e5d93227897e56c3.tar.gz
libcc1plugin: propagate record/union info to variants on finish and tagbind
Diffstat (limited to 'libcc1')
-rw-r--r--libcc1/libcc1plugin.cc26
1 files changed, 25 insertions, 1 deletions
diff --git a/libcc1/libcc1plugin.cc b/libcc1/libcc1plugin.cc
index 39aac4a4a2c..6f7b5272768 100644
--- a/libcc1/libcc1plugin.cc
+++ b/libcc1/libcc1plugin.cc
@@ -447,8 +447,15 @@ plugin_tagbind (cc1_plugin::connection *self,
const char *filename, unsigned int line_number)
{
plugin_context *ctx = static_cast<plugin_context *> (self);
+ tree t = convert_in (tagged_type), x;
c_pushtag (ctx->get_source_location (filename, line_number),
- get_identifier (name), convert_in (tagged_type));
+ get_identifier (name), t);
+
+ /* Propagate the newly-added type name so that previously-created
+ variant types are not disconnected from their main variants. */
+ for (x = TYPE_MAIN_VARIANT (t); x; x = TYPE_NEXT_VARIANT (x))
+ TYPE_NAME (x) = TYPE_NAME (t);
+
return 1;
}
@@ -568,6 +575,23 @@ plugin_finish_record_or_union (cc1_plugin::connection *,
// FIXME we have no idea about TYPE_PACKED
}
+ tree t = record_or_union_type, x;
+ for (x = TYPE_MAIN_VARIANT (t); x; x = TYPE_NEXT_VARIANT (x))
+ {
+ /* Like finish_struct, update the qualified variant types. */
+ TYPE_FIELDS (x) = TYPE_FIELDS (t);
+ TYPE_LANG_SPECIFIC (x) = TYPE_LANG_SPECIFIC (t);
+ C_TYPE_FIELDS_READONLY (x) = C_TYPE_FIELDS_READONLY (t);
+ C_TYPE_FIELDS_VOLATILE (x) = C_TYPE_FIELDS_VOLATILE (t);
+ C_TYPE_VARIABLE_SIZE (x) = C_TYPE_VARIABLE_SIZE (t);
+ /* We copy these fields too. */
+ TYPE_ALIGN (x) = TYPE_ALIGN (t);
+ TYPE_SIZE (x) = TYPE_SIZE (t);
+ TYPE_SIZE_UNIT (x) = TYPE_SIZE_UNIT (t);
+ if (x != record_or_union_type)
+ compute_record_mode (x);
+ }
+
return 1;
}