This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Differences in c and c++ anon typedefs
- From: Brendon Costa <brendon at christian dot net>
- To: Andrew Pinski <pinskia at physics dot uc dot edu>
- Cc: Gabriel Dos Reis <gdr at integrable-solutions dot net>, Brendon Costa <bcosta at avdat dot com dot au>, gcc at gcc dot gnu dot org
- Date: Tue, 28 Nov 2006 08:27:33 +1100
- Subject: Re: Differences in c and c++ anon typedefs
- References: <200611272056.kARKuMxW024281@localhost.localdomain>
Andrew Pinski wrote:
> Again C has different rules from C++.
> In C, the following two TUs combined together are still valid code while in C++,
> they are invalid.
>
> tu1.c:
>
> struct a
> {
> int t;
> };
> void f(struct a);
>
> ---------------- cut ---------------------
> tu2.c:
>
> typedef struct
> {
> int t;
> }b;
> void f(b a);
> ---------------- cut ---------------------
>
I think I am going to have to use a non-optimal solution for function
pointer type matches. I am creating a pessimistic/over-expanded
callgraph by saying that a function pointer call MAY call any function
whose function pointer type matches the call and whose address has been
taken somewhere in the source code. So maybe I can make it even more
pessimistic in the C case and match all structs/unions as being the
"same" for the purposes of testing function pointer equality.
Maybe it is also possible to somehow generate a "type string" based on
the contents of the struct/union in C, however I am not sure how I would
get that to inter-operate with C++ since C++ may treat two structures
with the same contents as different types. I might just go for the
pessimistic match first and look at improving things later on once the
rest of it is all up and going.
Thanks for the input,
Brendon.