From 060d7685c66efcd6d8e49ffb3d155a9fb8daf95d Mon Sep 17 00:00:00 2001 From: York Jasper Niebuhr Date: Thu, 30 Oct 2025 13:15:13 +0100 Subject: [PATCH] Updated GCC patch v2 to ensure visibility to plugins --- gcc_component_ref_v2.patch | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/gcc_component_ref_v2.patch b/gcc_component_ref_v2.patch index 8467db8..f98aa77 100644 --- a/gcc_component_ref_v2.patch +++ b/gcc_component_ref_v2.patch @@ -1,13 +1,13 @@ -From 474c2208836a447bb2452a45a0e76453b1d9c56c Mon Sep 17 00:00:00 2001 +From 0d2945f8e3c1b89b122fef0ded3973dfae2eb904 Mon Sep 17 00:00:00 2001 From: York Jasper Niebuhr -Date: Thu, 30 Oct 2025 13:04:18 +0100 +Date: Thu, 30 Oct 2025 13:12:24 +0100 Subject: [PATCH] c_parse_component_ref callback --- - gcc/c-family/c-common.cc | 48 ++++++++++++++++++++------- + gcc/c-family/c-common.cc | 48 +++++++++++++++++++++------ gcc/c-family/c-common.h | 3 +- - gcc/c/c-parser.cc | 70 +++++++++++++++++++++++++++++++++++++++- - 3 files changed, 108 insertions(+), 13 deletions(-) + gcc/c/c-parser.cc | 72 +++++++++++++++++++++++++++++++++++++++- + 3 files changed, 110 insertions(+), 13 deletions(-) diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc index 587d76461e9..d34edfaa688 100644 @@ -135,10 +135,10 @@ index ea6c2975056..70fcfeb6661 100644 extern int complete_array_type (tree *, tree, bool); extern void complete_flexible_array_elts (tree); diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc -index 22ec0f849b7..5410b9dc003 100644 +index 22ec0f849b7..08cf0d9839b 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc -@@ -11354,6 +11354,62 @@ get_counted_by_ref (tree array_ref) +@@ -11354,6 +11354,64 @@ get_counted_by_ref (tree array_ref) return NULL_TREE; } @@ -151,7 +151,8 @@ index 22ec0f849b7..5410b9dc003 100644 + the expression unchanged. + + This callback is intended for plugins that wish to observe or transform -+ member-access expressions (such as 'a.b' or 'a->b') or at parse time. */ ++ member-access expressions (such as 'a.b' or 'a->b') or offsetof expressions ++ at parse time. */ +using c_parse_component_ref_cb_t = tree (*)(tree ref); + +/* Plugin-registered callback for COMPONENT_REF parse notifications. @@ -162,6 +163,7 @@ index 22ec0f849b7..5410b9dc003 100644 + + Only a single callback is supported; registering a new one replaces + any previously registered callback. */ ++__attribute__ ((visibility ("default"))) +void +register_c_parse_component_ref_cb (c_parse_component_ref_cb_t cb) +{ @@ -201,7 +203,7 @@ index 22ec0f849b7..5410b9dc003 100644 /* Parse a postfix expression (C90 6.3.1-6.3.2, C99 6.5.1-6.5.2, C11 6.5.1-6.5.2). Compound literals aren't handled here; callers have to call c_parser_postfix_expression_after_paren_type on encountering them. -@@ -11766,6 +11822,9 @@ c_parser_postfix_expression (c_parser *parser) +@@ -11766,6 +11824,9 @@ c_parser_postfix_expression (c_parser *parser) = build_component_ref (loc, offsetof_ref, comp_tok->value, comp_tok->location, UNKNOWN_LOCATION, false); @@ -211,7 +213,7 @@ index 22ec0f849b7..5410b9dc003 100644 c_parser_consume_token (parser); while (c_parser_next_token_is (parser, CPP_DOT) || c_parser_next_token_is (parser, -@@ -11800,6 +11859,9 @@ c_parser_postfix_expression (c_parser *parser) +@@ -11800,6 +11861,9 @@ c_parser_postfix_expression (c_parser *parser) comp_tok->location, UNKNOWN_LOCATION, false); @@ -221,7 +223,7 @@ index 22ec0f849b7..5410b9dc003 100644 c_parser_consume_token (parser); } else -@@ -11823,7 +11885,7 @@ c_parser_postfix_expression (c_parser *parser) +@@ -11823,7 +11887,7 @@ c_parser_postfix_expression (c_parser *parser) location_t end_loc = c_parser_peek_token (parser)->get_finish (); c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); @@ -230,7 +232,7 @@ index 22ec0f849b7..5410b9dc003 100644 set_c_expr_source_range (&expr, loc, end_loc); } break; -@@ -13771,6 +13833,9 @@ c_parser_postfix_expression_after_primary (c_parser *parser, +@@ -13771,6 +13835,9 @@ c_parser_postfix_expression_after_primary (c_parser *parser, c_parser_consume_token (parser); expr.value = build_component_ref (op_loc, expr.value, ident, comp_loc, UNKNOWN_LOCATION); @@ -240,7 +242,7 @@ index 22ec0f849b7..5410b9dc003 100644 set_c_expr_source_range (&expr, start, finish); expr.original_code = ERROR_MARK; if (TREE_CODE (expr.value) != COMPONENT_REF) -@@ -13813,6 +13878,9 @@ c_parser_postfix_expression_after_primary (c_parser *parser, +@@ -13813,6 +13880,9 @@ c_parser_postfix_expression_after_primary (c_parser *parser, RO_ARROW), ident, comp_loc, expr.get_location ());