Changeset a465d751


Ignore:
Timestamp:
Jan 30, 2025, 10:50:41 AM (3 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
372d33c
Parents:
161b98e
Message:

In the 'designations': Instead of leaving some variables unused, print more of them for further checking. (All passed.)

Location:
tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified tests/.expect/designations.txt

    r161b98e ra465d751  
    4242=====C=====
    4343
     44====ARR====
     45[0, 3]
     463
     47====ARR====
     48
    4449=====E=====
    4550(A){ 2 3 (nil) }
     
    5257=====E=====
    5358
     59==STRINGS==
     60hello
     61hello
     62abc
     63[a, b, c]
     64[a, b]
     65[c, d]
     66[c, d]
     67a
     68==STRINGS==
     69
     70===EXTRA===
     71(point){ 7 5 }
     72(foo){ 4.000000 }
     73[0, 1, 2, 0, 4, 0]
     74[0 ... 1 ...]
     75[{ 36 0 }, { 0 0 }, { 35 34 } ...]
     76===EXTRA===
     77
  • TabularUnified tests/designations.cfa

    r161b98e ra465d751  
    1616// Note: this test case has been crafted so that it compiles with both cfa and with gcc without any modifications.
    1717#include <stdio.h>
     18
    1819#ifdef __cforall
    1920#define AT @
     
    2425#pragma GCC diagnostic ignored "-Wmissing-braces"
    2526#pragma GCC diagnostic ignored "-Woverride-init"
    26 #pragma GCC diagnostic ignored "-Wunused-variable"
    2727#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
    2828
     
    161161        // no initializer - legal C, but garbage values - don't print this one
    162162        struct B z4;
     163        // Mark this as unused since it can't be printed.
     164        (void)z4;
    163165
    164166        // no curly braces - initialize with object of same type
     
    220222        int i1 = { 3 };
    221223
     224        printf( "====ARR====\n" );
     225        printf( "[%d, %d]\n", i[0], i[1] );
     226        printf( "%d\n", i1 );
     227        printf( "====ARR====\n\n" );
     228
    222229        // doesn't work yet.
    223230        // designate unnamed object's members
     
    259266        const char c2[] = "abc";
    260267        const char c3[] = { 'a', 'b', 'c' };
    261         const char c4[][2] = { { 'a', 'b' }, { 'c', 'd'}, { 'c', 'd'} };
     268        const char c4[][2] = { { 'a', 'b' }, { 'c', 'd' }, { 'c', 'd' } };
    262269        const char ch = c4[0][0];
     270
     271        printf( "==STRINGS==\n" );
     272        printf( "%s\n", str0 );
     273        printf( "%s\n", str1 );
     274        printf( "%s\n", c2 );
     275        printf( "[%c, %c, %c]\n", c3[0], c3[1], c3[2] );
     276        for ( unsigned index = 0 ; index < 3 ; ++index ) {
     277                printf( "[%c, %c]\n", c4[index][0], c4[index][1] );
     278        }
     279        printf( "%c\n", ch );
     280        printf( "==STRINGS==\n\n" );
    263281
    264282        // more cases
     
    270288        union foo { int i; double d; };
    271289        union foo f = { .d = 4 };
    272         int v1 = 0, v2 = 0, v4 = 0;
     290        int v1 = 1, v2 = 2, v4 = 4;
    273291        int w[6] = { [1] = v1, v2, [4] = v4 };
    274292        int whitespace[256] = { [' '] = 1, ['\t'] = 1, ['\v'] = 1, ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 };
    275293        struct point ptarray[10] = { [2].y = 34, [2].x = 35, [0].x = 36 };
     294
     295        printf( "===EXTRA===\n" );
     296        printf( "(point){ %d %d }\n", p.x, p.y );
     297        printf( "(foo){ %f }\n", f.d );
     298        printf( "[%d, %d, %d, %d, %d, %d]\n", w[0], w[1], w[2], w[3], w[4], w[5] );
     299        printf( "[%d ... %d ...]\n", whitespace[0], whitespace[32] );
     300        printf( "[{ %d %d }, { %d %d }, { %d %d } ...]\n", ptarray[0].x, ptarray[0].y, ptarray[1].x, ptarray[1].y, ptarray[2].x, ptarray[2].y );
     301        printf( "===EXTRA===\n\n" );
    276302}
    277303
Note: See TracChangeset for help on using the changeset viewer.