Changeset 81e768d for tests/array.cfa


Ignore:
Timestamp:
Nov 28, 2024, 4:34:08 PM (3 weeks ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
master
Children:
46c4dea
Parents:
f5e37a4
Message:

Fix #276; add support for c-array parameters using dependent lengths.

Without this fix, declarations like

void f( int m, int n, float[m][n] );

would either

  • generate bad C code, with unmangled variable names appearing in the function definition, or
  • refuse to resolve a valid-c call of such a function.

tests/array-collections/c-dependent: add direct tests of such cases
tests/tuplearray: activate and expand cases which were blocked on #276
tests/array: activate case fm5y, which was blocked on #276; [noise] adjust source line numbers in .expect
tests/typedefRedef: expand coverage of "error, an array detail is different" cases; [noise] adjust source line numbers in .expect
tests/functions: [noise] adjust .expect to have resolved array sizes (extra casts) in the diffed code dump

The fix is:

  • (ResolvExpr/ResolveTypeof?, ResolvExpr/Resolver?) Resolve the dimension expressions, where they were missed.
  • (ResolvExpr/Resolver?) Prevent dimension expressions that are bound to other parameters from escaping in the function's type, to where they are out of scope. In the f example above, redact the type shown to callers from void (*)(int, int, float[m][n]) to void (*)(int, int, float[][*]).
  • (ResolvExpr/Unify?) Relax the matching rules for such a type, when used at a call site, letting the patameters wildcard type match with the concrete type in scope at the caller's side.
  • (Validate/ReplaceTypedef?) Apply the former, stricter matching rules to the one place where they are still needed: detecting inconsistent typedefs.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/array.cfa

    rf5e37a4 r81e768d  
    5757    }
    5858
     59    int fred2(int n,
     60        int a1[],
     61E1(     int a2[*],   )
     62        int a4[3],
     63        int T[3],
     64        int a5[n]
     65    ) {}
     66
    5967    int mary( int T[3],                                 // same as: int *T
    6068              int p1[const 3],                          // same as: int const *p1
     
    110118E3( int fm4( int r, int c, int m[][] );            )    // m's immediate element type is incomplete
    111119    int fm5x( int, int, int[*][*] );                    // same as fm1 decl
    112                                                         #ifndef __cforall
    113     int fm5y( int r, int c, int m[r][c] ) {}            // BUG 276: CFA chokes but should accept
    114                                                         // C: same as fm1 defn
    115                                                         #endif
     120    int fm5y( int r, int c, int m[r][c] ) {}            // same as fm1 defn
     121
    116122
    117123
Note: See TracChangeset for help on using the changeset viewer.