On 3/5/26 2:07 PM, Marek Polacek wrote:
On Wed, Mar 04, 2026 at 07:13:33PM +0000, Boris Staletic wrote:
Bootstrapped and tested on x86_64-pc-linux-gnu.
I have only ran g++.dg/reflect/* tests.
If needed/wanted, I can run the entire `make check`, though
that will take me the rest of the night.
-- >8 --
With an annotation like [[=func]] gcc ends up calling
handle_annotation_attribute with TREE_VALUE (args) being a
VIEW_CONVERT_EXPR, whose type is a FUNCTION_TYPE.
That kind of annotation value should be decayed before checking
if the type is structural.
Signed-off-by: Boris Staletic <[email protected]>
PR c++/124177
gcc/cp/ChangeLog:
* tree.cc (handle_annotation_attribute): Decay annotation
values.
This can fit on one line (80 is the limit).
I prefer to wrap at 76 in commit messages because git log adds 4 spaces
at the beginning.
gcc/testsuite/ChangeLog:
* g++.dg/reflect/annotations11.C: New test.
---
gcc/cp/tree.cc | 1 +
gcc/testsuite/g++.dg/reflect/annotations11.C | 17 +++++++++++++++++
2 files changed, 18 insertions(+)
create mode 100644 gcc/testsuite/g++.dg/reflect/annotations11.C
diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
index 20288ed04e..5c7df0a1d9 100644
--- a/gcc/cp/tree.cc
+++ b/gcc/cp/tree.cc
@@ -5912,6 +5912,7 @@ handle_annotation_attribute (tree *node, tree ARG_UNUSED
(name),
*no_add_attrs = true;
return NULL_TREE;
}
+ TREE_VALUE (args) = decay_conversion (TREE_VALUE (args),
tf_warning_or_error);
I'm not sure if it's reasonable to call decay_conversion on something
type-dependent, so perhaps this should be moved inside of the following
block.
Good point.
But annotations are treated as late attributes so I'm not sure
how we'd get here with anything type-dependent, and I couldn't construct
such a test. Maybe the !t_d_e_p check could be dropped?
Or turned into an assert.
We're supposed to treat the expression as reflect_constant(arg) but
doing the whole convert_reflect_constant_arg thing here seems unpleasant.
Hmm, why unpleasant? It seems straightforward and might be needed to
get some messy cases right.
But that can be separate, and we need to add the decay_conversion either
way.
Jason