Ignore:
Timestamp:
Jul 27, 2017, 12:38:55 PM (4 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
fcd17b2f
Parents:
6165ce7
Message:

add additional designator tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/designations.c

    r6165ce7 ra04ce4d  
    99// Author           : Rob Schluntz
    1010// Created On       : Thu Jun 29 15:26:36 2017
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Thu Jun 29 15:27:05 2017
    13 // Update Count     : 2
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Jul 27 11:46:35 2017
     13// Update Count     : 3
    1414//
    1515
     
    8989};
    9090
     91struct Fred {
     92    double i[3];
     93    int j;
     94    struct Mary {
     95        struct Jane {
     96            double j;
     97        } j;
     98        double i;
     99    } m;
     100};
     101struct Fred s1 @= { .m.j : 3 };
     102struct Fred s2 @= { .i : { [2] : 2 } };
     103
    91104int main() {
    92105        // simple designation case - starting from beginning of structure, leaves ptr default-initialized (zero)
     
    199212        };
    200213#endif
    201 
     214        // array designation
     215        int i[2] = { [1] : 3 };
    202216        // allowed to have 'too many' initialized lists - essentially they are ignored.
    203217        int i1 = { 3 };
     
    240254        const char * str0 = "hello";
    241255        char str1[] = "hello";
     256        const char c1[] = "abc";
     257        const char c2[] = { 'a', 'b', 'c' };
     258        const char c3[][2] = { { 'a', 'b' }, { 'c', 'd'}, { 'c', 'd'} };
    242259}
    243260
Note: See TracChangeset for help on using the changeset viewer.