Opened 7 years ago
Closed 7 years ago
#19 closed defect (fixed)
Functions taking array types and taking pointer types are conflicting overloads
Reported by: | Rob Schluntz | Owned by: | |
---|---|---|---|
Priority: | major | Component: | cfa-cc |
Version: | 1.0 | Keywords: | include conflicting overload extern C linkage |
Cc: |
Description
extern "C" { void fred(int __env[1]); void fred(int *__env); } cfa test3.c CFA Version 1.0.0 (debug) test3.c:3 error: conflicting overload of C function fred: C function with parameters __env: C pointer to signed int returning _retval_fred: Attribute with name: unused void
Change History (2)
comment:1 Changed 7 years ago by
comment:2 Changed 7 years ago by
Owner: | set to Rob Schluntz <rschlunt@…> |
---|---|
Resolution: | → fixed |
Status: | new → closed |
In 8e0147a:
Note: See
TracTickets for help on using
tickets.
This is only true of the outermost layer though. If you add just one level, they cease to be equivalent, i.e.,
int **
is equivalent toint *[10]
, but not the same asint (*)[10]
orint [10][10]
). So you should be careful to only make the outermost array level mangle the same way as a pointer, if you go down this route.And actually, we already do this transformation (but improperly mangle every such array type as a pointer):
It might be that it’s happening too late though. This transformation happens in
FixFunction
, which is called fromEnumAndPointerDecay
andForallPointerDecay
inValidate.cc
, butLinkReferenceToTypes
is anIndexer
that is run before either of those.As a side note, a while back I added recursion to the
ArrayType
cases inAdjustExprType
andFixFunction
to make this transformation happen deeply, because multiple subscript operators did not work on multi-dimensional arrays. I could be convinced that this was the wrong thing to do, and that instead,adjustExprType
was not happening in all of the right places. An alternative would be to just makeMangler
smarter about how it handles pointer types that are really array types (and likewise, makeAdjustExprType
andFixFunction
recursive onPointerType
).The first bar is correctly mangled because
FixFunction
isn’t recursive onPointerType
, but as such multiple subscripts do not work: