Formatted gcc patch
This commit is contained in:
parent
f0f800d1c4
commit
7ef422b824
@ -1,20 +1,20 @@
|
||||
From 4c2d49dcf5e9a1090313cd9d922b63e280fc4d54 Mon Sep 17 00:00:00 2001
|
||||
From ab8884cbf3712f939556fc7789bbf32132c7ff1a Mon Sep 17 00:00:00 2001
|
||||
From: York Jasper Niebuhr <yjnworkstation@gmail.com>
|
||||
Date: Fri, 17 Oct 2025 21:17:30 +0200
|
||||
Subject: [PATCH] unformatted component ref callback
|
||||
Date: Fri, 17 Oct 2025 22:04:41 +0200
|
||||
Subject: [PATCH] PLUGIN_BUILD_COMPONENT_REF callback
|
||||
|
||||
---
|
||||
gcc/c-family/c-common.cc | 48 +++++++++++++++++++++++++++++++---------
|
||||
gcc/c-family/c-common.h | 3 ++-
|
||||
gcc/c/c-parser.cc | 2 +-
|
||||
gcc/c/c-typeck.cc | 9 ++++++++
|
||||
gcc/c/c-typeck.cc | 12 ++++++++++
|
||||
gcc/doc/plugins.texi | 6 +++++
|
||||
gcc/plugin.cc | 2 ++
|
||||
gcc/plugin.def | 6 +++++
|
||||
7 files changed, 63 insertions(+), 13 deletions(-)
|
||||
7 files changed, 66 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc
|
||||
index 587d76461e9..f23093f5a66 100644
|
||||
index 587d76461e9..d34edfaa688 100644
|
||||
--- a/gcc/c-family/c-common.cc
|
||||
+++ b/gcc/c-family/c-common.cc
|
||||
@@ -7076,43 +7076,48 @@ c_common_to_target_charset (HOST_WIDE_INT c)
|
||||
@ -110,7 +110,7 @@ index 587d76461e9..f23093f5a66 100644
|
||||
+tree
|
||||
+fold_offsetof_maybe (tree expr, tree type)
|
||||
+{
|
||||
+ /* expr might not have the correct structure, thus folding may fail */
|
||||
+ /* expr might not have the correct structure, thus folding may fail. */
|
||||
+ tree maybe_folded = fold_offsetof (expr, type, ERROR_MARK, true);
|
||||
+ if (maybe_folded != error_mark_node)
|
||||
+ return maybe_folded;
|
||||
@ -152,7 +152,7 @@ index 22ec0f849b7..6a8a5d58e6d 100644
|
||||
}
|
||||
break;
|
||||
diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc
|
||||
index 55d896e02df..e76002151bd 100644
|
||||
index 55d896e02df..aff6dce36fb 100644
|
||||
--- a/gcc/c/c-typeck.cc
|
||||
+++ b/gcc/c/c-typeck.cc
|
||||
@@ -55,6 +55,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
@ -171,30 +171,33 @@ index 55d896e02df..e76002151bd 100644
|
||||
|
||||
/* Return true if EXP is a null pointer constant, false otherwise. */
|
||||
|
||||
@@ -3174,6 +3176,13 @@ build_component_ref (location_t loc, tree datum, tree component,
|
||||
@@ -3174,6 +3176,16 @@ build_component_ref (location_t loc, tree datum, tree component,
|
||||
else if (TREE_DEPRECATED (subdatum))
|
||||
warn_deprecated_use (subdatum, NULL_TREE);
|
||||
|
||||
+ tree pre_cb_type = TREE_TYPE (ref);
|
||||
+ if (invoke_plugin_callbacks (PLUGIN_BUILD_COMPONENT_REF, &ref) == PLUGEVT_SUCCESS &&
|
||||
+ !comptypes (TREE_TYPE (ref), pre_cb_type))
|
||||
+ if (invoke_plugin_callbacks (PLUGIN_BUILD_COMPONENT_REF, &ref)
|
||||
+ == PLUGEVT_SUCCESS
|
||||
+ && !comptypes (TREE_TYPE (ref), pre_cb_type))
|
||||
+ {
|
||||
+ error_at (EXPR_LOCATION (ref), "PLUGIN_BUILD_COMPONENT_REF callback returned expression of incompatible type");
|
||||
+ error_at (EXPR_LOCATION (ref),
|
||||
+ "PLUGIN_BUILD_COMPONENT_REF callback returned"
|
||||
+ " expression of incompatible type");
|
||||
+ }
|
||||
+
|
||||
datum = ref;
|
||||
|
||||
field = TREE_CHAIN (field);
|
||||
diff --git a/gcc/doc/plugins.texi b/gcc/doc/plugins.texi
|
||||
index c11167a34ef..942e2e41b90 100644
|
||||
index c11167a34ef..312f178fab4 100644
|
||||
--- a/gcc/doc/plugins.texi
|
||||
+++ b/gcc/doc/plugins.texi
|
||||
@@ -222,6 +222,12 @@ enum plugin_event
|
||||
ana::plugin_analyzer_init_iface *. */
|
||||
PLUGIN_ANALYZER_INIT,
|
||||
|
||||
+ /* Called by the C front end when a COMPONENT_REF node is built.
|
||||
+ The callback receives a pointer to the COMPONENT_REF tree (of type 'tree *').
|
||||
+ /* Called by the C front end when a COMPONENT_REF node is built. The
|
||||
+ callback receives a pointer to the COMPONENT_REF tree (of type 'tree *').
|
||||
+ Plugins may replace the node by assigning through the pointer, but any
|
||||
+ replacement must be type-compatible with the original node. */
|
||||
+ PLUGIN_BUILD_COMPONENT_REF,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user