Hi! +gcc_jit_type * +gcc_jit_type_unqualified (gcc_jit_type *type) +{ + RETURN_NULL_IF_FAIL (type, NULL, NULL, "NULL type"); + + return (gcc_jit_type *)type->unqualified (); +}
I think there is a problem with the current implementation of unqualified() that might be kinda surprising to users, since it only removes one qualifier and also not "pointed to" qualifiers. Unrelated to this patch that behavior should probably be documented, since it effects many entry-points and makes cast to base type kinda mandatory when qualified types are mixed. Casts uses a recursive check of types and is happy to cast any pointer to any pointer (no matter the level of pointerness) so they work. I guess the casts should get some shortcircuit for casts between same base types really, to not bloat the GENERIC tree. I made a utility function in another patch for comparing types that do full stripping (see bellow). Maybe something like that could be usefull? jit-recording.h: +/* Strip all qualifiers and count pointer depth, returning true + if the types and pointer depth are the same, otherwise false. */ +static inline bool +types_kinda_same (recording::type *a, recording::type *b) +{ + /* Handle trivial case here, to allow for inlining. */ + return a == b || types_kinda_same_internal (a, b); +} jit-recording.c: +/* Strip qualifiers and count pointer depth, returning true + if the types' base type and pointer depth are + the same, otherwise false. + + Do not call this directly. Call 'types_kinda_same' */ +bool +types_kinda_same_internal (recording::type *a, recording::type *b) +{ + int ptr_depth[2] = {}; + recording::type *base_types[2]; + recording::type *types[2] = {a, b}; + + /* Strip qualifiers and count pointerness */ + for (int i = 0; i < 2; i++) + { + recording::type *t = types[i]; + while (true) + { + if (!t) + return false; /* Should only happen on bad input */ + + recording::type *pointed_to_type = t->is_pointer(); + if (pointed_to_type != NULL) + { + ptr_depth[i]++; + t = pointed_to_type; + continue; + } + + /* unqualified() returns 'this' on base types */ + recording::type *next = t->unqualified (); + if (next == t) + { + base_types[i] = t; + break; + } + t = next; + } + } + + return base_types[0] == base_types[1] && + (ptr_depth[0] == ptr_depth[1]); +} Från: Jit <jit-bounces+tomner=kth...@gcc.gnu.org> för Antoni Boucher via Jit <j...@gcc.gnu.org> Skickat: den 13 oktober 2021 04:09 Till: David Malcolm Kopia: Antoni Boucher via Jit; gcc-patches@gcc.gnu.org Ämne: Re: [PATCH] libgccjit: add some reflection functions in the jit C api David: PING Le lundi 27 septembre 2021 à 20:53 -0400, Antoni Boucher a écrit : > I fixed an issue (it would show an error message when > gcc_jit_type_dyncast_function_ptr_type was called on a type different > than a function pointer type). > > Here's the updated patch. > > Le vendredi 18 juin 2021 à 16:37 -0400, David Malcolm a écrit : > > On Fri, 2021-06-18 at 15:41 -0400, Antoni Boucher wrote: > > > I have write access now. > > > > Great. > > > > > I'm not sure how I'm supposed to send my patches: > > > should I put it in personal branches and you'll merge them? > > > > Please send them to this mailing list for review; once they're > > approved > > you can merge them. > > > > > > > > And for the MAINTAINERS file, should I just push to master right > > > away, > > > after sending it to the mailing list? > > > > I think people just push the MAINTAINERS change and then let the > > list > > know, since it makes a good test that write access is working > > correctly. > > > > Dave > > > > > > > > Thanks for your help! > > > > > > Le vendredi 18 juin 2021 à 12:09 -0400, David Malcolm a écrit : > > > > On Fri, 2021-06-18 at 11:55 -0400, Antoni Boucher wrote: > > > > > Le vendredi 11 juin 2021 à 14:00 -0400, David Malcolm a > > > > > écrit : > > > > > > On Fri, 2021-06-11 at 08:15 -0400, Antoni Boucher wrote: > > > > > > > Thank you for your answer. > > > > > > > I attached the updated patch. > > > > > > > > > > > > BTW you (or possibly me) dropped the mailing lists; was > > > > > > that > > > > > > deliberate? > > > > > > > > > > Oh, my bad. > > > > > > > > > > > > > [...] > > > > > > > > > > > > > > > > > > > > > > > > > > > I have signed the FSF copyright attribution. > > > > > > > > > > > > I can push changes on your behalf, but I'd prefer it if you > > > > > > did > > > > > > it, > > > > > > especially given that you have various other patches you > > > > > > want > > > > > > to > > > > > > get > > > > > > in. > > > > > > > > > > > > Instructions on how to get push rights to the git repo are > > > > > > here: > > > > > > https://gcc.gnu.org/gitwrite.html > > > > > > > > > > > > I can sponsor you. > > > > > > > > > > Thanks. > > > > > I did sign up to get push rights. > > > > > Have you accepted my request to get those? > > > > > > > > I did, but I didn't see any kind of notification. Did you get > > > > an > > > > email > > > > about it? > > > > > > > > > > > > Dave > > > > > > > > > > > > > > >