[cfe-dev] calling convention for function pointers
Eli Friedman
eli.friedman at gmail.com
Sat Apr 4 02:51:24 PDT 2009
On Sat, Apr 4, 2009 at 12:55 AM, Xi Wang <xi.wang at gmail.com> wrote:
> Attached is a new patch with test code. 1) I am not sure if I used
> `TargetDecl' in an appropriate way. 2) Though I tried to collect
> usages in the attached test.c, some corner cases may be missing. 3)
> The patch does not support member function pointers.
The current approach used for calling conventions isn't really
correct; we really ought to follow gcc and make the calling convention
part of the type. Otherwise, we can't handle the general case like
the following without some extremely ugly code; for example, take the
following:
__attribute((fastcall)) int a(int), b(int); void c(int x) { (cond ? a : b)(x); }
Not that this patch is necessarily unacceptable as a stopgap...
> p.s. Currently Clang does not check incompatible pointer casts with
> such attributes (e.g., from fastcall to cdecl). Should it report a
> warning or something?
Are you talking about the assignment case, or explicit casts? The
assignment case would be covered by encoding the convention into the
type, and using it in compatibility checking. For explicit casts, I
don't think warning is a particularly good idea; the are legitimate
uses for such casts.
-Eli
More information about the cfe-dev
mailing list