PetScan::extract_argument: allow multiple implicit casts on arguments
commit0e129c437f0d9c8185c61517ab6b5fa52e196218
authorSven Verdoolaege <skimo@kotnet.org>
Sat, 28 Mar 2015 09:44:10 +0000 (28 10:44 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Mon, 30 Mar 2015 11:36:28 +0000 (30 13:36 +0200)
treeae4775309d06708dda91bb6027c57d096b563b66
parent82cacb710c1ab7cbc6c83be1b09885e7b6e031b6
PetScan::extract_argument: allow multiple implicit casts on arguments

PetScan::extract_argument would only strip off a single implicit cast,
making it fail to recognize some arguments that may be used for writing.
In particular, the second argument of

    foo(n, A)

from

    void bar(int n, float A[static const restrict n][n])

to

    void foo(int n, float A[static const restrict n][n]);

is of the form

    ImplicitCastExpr 0x65dc80 'float (*)[*]' <BitCast>
    `-ImplicitCastExpr 0x65dc68 'float (*)[n]' <LValueToRValue>
      `-DeclRefExpr 0x65db10 'float (*const restrict)[n]':'float (*const restrict)[n]' lvalue ParmVar 0x65d890 'A' 'float (*const restrict)[n]':'float (*const restrict)[n]'

such that two implicit casts would need to be stripped off.
Strip off all outer implicit casts.

Reported-by: Michael Kruse <MichaelKruse@meinersbur.de>
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
scan.cc
tests/write.c [new file with mode: 0644]
tests/write.scop [new file with mode: 0644]