Changeset 68b52b0


Ignore:
Timestamp:
Jun 23, 2021, 4:52:43 PM (3 years ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
6448f7d
Parents:
b680198
Message:

Implementing syntax forall( T * ) abbreviating forall( T & | sized(T) )

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    rb680198 r68b52b0  
    10761076        if ( variable.tyClass != TypeDecl::NUMBER_OF_KINDS ) {
    10771077                // otype is internally converted to dtype + otype parameters
    1078                 static const TypeDecl::Kind kindMap[] = { TypeDecl::Dtype, TypeDecl::DStype, TypeDecl::Dtype, TypeDecl::Ftype, TypeDecl::Ttype, TypeDecl::Dimension };
     1078                static const TypeDecl::Kind kindMap[] = { TypeDecl::Dtype, TypeDecl::Dtype, TypeDecl::Dtype, TypeDecl::Ftype, TypeDecl::Ttype, TypeDecl::Dimension };
    10791079                static_assert( sizeof(kindMap) / sizeof(kindMap[0]) == TypeDecl::NUMBER_OF_KINDS, "DeclarationNode::build: kindMap is out of sync." );
    10801080                assertf( variable.tyClass < sizeof(kindMap)/sizeof(kindMap[0]), "Variable's tyClass is out of bounds." );
    1081                 TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ], variable.tyClass == TypeDecl::Otype, variable.initializer ? variable.initializer->buildType() : nullptr );
     1081                TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ], variable.tyClass == TypeDecl::Otype || variable.tyClass == TypeDecl::DStype, variable.initializer ? variable.initializer->buildType() : nullptr );
    10821082                buildList( variable.assertions, ret->get_assertions() );
    10831083                return ret;
  • tests/.expect/forall.txt

    rb680198 r68b52b0  
    1 forall.cfa:216:25: warning: Compiled
     1forall.cfa:242:25: warning: Compiled
  • tests/forall.cfa

    rb680198 r68b52b0  
    199199}
    200200
     201forall( T ) void check_otype() {
     202        T & tr = *0p;
     203        T * tp = 0p;
     204
     205        &tr += 1;
     206        tp += 1;
     207        T & tx = tp[1];
     208
     209        T t;
     210        T t2 = t;
     211}
     212
     213forall( T * ) void check_dstype() {
     214        T & tr = *0p;
     215        T * tp = 0p;
     216
     217        &tr += 1;
     218        tp += 1;
     219        T & tx = tp[1];
     220}
     221
     222forall( T & ) void check_dtype() {
     223        T & tr = *0p;
     224        T * tp = 0p;
     225}
     226
    201227//otype T1 | { void xxx( T1 ); };
    202228
Note: See TracChangeset for help on using the changeset viewer.