aboutsummaryrefslogtreecommitdiff
path: root/libcc1
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2024-02-22 19:34:23 -0700
committerTom Tromey <tom@tromey.com>2024-02-29 08:50:06 -0700
commitfd846abc2d0b9d7c9d4d2965a63b80ddc300b870 (patch)
tree3cb62fc7ea1c93b62e07e8573a87a6b01ca5adef /libcc1
parent46666b9bde5903d80ad8a30f5e7ecb6fc4208290 (diff)
downloadgcc-fd846abc2d0b9d7c9d4d2965a63b80ddc300b870.zip
gcc-fd846abc2d0b9d7c9d4d2965a63b80ddc300b870.tar.gz
gcc-fd846abc2d0b9d7c9d4d2965a63b80ddc300b870.tar.bz2
Change 'v1' float and int code to fall back to v0
While working on another patch, I discovered that the libcc1 plugin code never did version negotiation correctly. So, the patches to introduce v1 never did anything -- the new code, as far as I know, has never been run. Making version negotiation work shows that the existing code causes crashes. For example, safe_lookup_builtin_type might return error_mark_node in some cases, which the callers aren't prepared to accept. Looking into it some more, I couldn't find any justification for this v1 code for the C compiler plugin. Since it's not run at all, it's also clear that removing it doesn't cause any regressions in gdb. However, rather than remove it, this patch changes it to handle ERROR_MARK better, and then to fall back to the v0 code if the new code fails to find the type it's looking for. libcc1 * libcc1plugin.cc (safe_lookup_builtin_type): Handle ERROR_MARK. (plugin_int_type): Fall back to plugin_int_type_v0. (plugin_float_type): Fall back to plugin_float_type_v0.
Diffstat (limited to 'libcc1')
-rw-r--r--libcc1/libcc1plugin.cc19
1 files changed, 10 insertions, 9 deletions
diff --git a/libcc1/libcc1plugin.cc b/libcc1/libcc1plugin.cc
index 00d3963..f1082d8 100644
--- a/libcc1/libcc1plugin.cc
+++ b/libcc1/libcc1plugin.cc
@@ -555,7 +555,7 @@ safe_lookup_builtin_type (const char *builtin_name)
gcc_assert (TREE_CODE (result) == TYPE_DECL);
result = TREE_TYPE (result);
- return result;
+ return TREE_CODE (result) == ERROR_MARK ? nullptr : result;
}
static gcc_type
@@ -592,13 +592,14 @@ plugin_int_type (cc1_plugin::connection *self,
int is_unsigned, unsigned long size_in_bytes,
const char *builtin_name)
{
- if (!builtin_name)
- return plugin_int_type_v0 (self, is_unsigned, size_in_bytes);
-
- tree result = safe_lookup_builtin_type (builtin_name);
- gcc_assert (!result || TREE_CODE (result) == INTEGER_TYPE);
-
- return plugin_int_check (self, is_unsigned, size_in_bytes, result);
+ if (builtin_name != nullptr)
+ {
+ tree result = safe_lookup_builtin_type (builtin_name);
+ gcc_assert (!result || TREE_CODE (result) == INTEGER_TYPE);
+ if (result != nullptr)
+ return plugin_int_check (self, is_unsigned, size_in_bytes, result);
+ }
+ return plugin_int_type_v0 (self, is_unsigned, size_in_bytes);
}
gcc_type
@@ -631,7 +632,7 @@ plugin_float_type (cc1_plugin::connection *self,
tree result = safe_lookup_builtin_type (builtin_name);
if (!result)
- return convert_out (error_mark_node);
+ return plugin_float_type_v0 (self, size_in_bytes);
gcc_assert (SCALAR_FLOAT_TYPE_P (result));
gcc_assert (BITS_PER_UNIT * size_in_bytes == TYPE_PRECISION (result));