Changeset 367e082 for src/SymTab


Ignore:
Timestamp:
May 25, 2015, 3:15:21 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
49205cf
Parents:
53a2e97
Message:

generated assignment routine will not attempt to assign to a const array field

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Validate.cc

    r53a2e97 r367e082  
    1010// Created On       : Sun May 17 21:50:04 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri May 22 15:29:16 2015
    13 // Update Count     : 9
     12// Last Modified On : Mon May 25 14:27:15 2015
     13// Update Count     : 21
    1414//
    1515
     
    560560                for ( std::list< Declaration * >::const_iterator member = aggregateDecl->get_members().begin(); member != aggregateDecl->get_members().end(); ++member ) {
    561561                        if ( DeclarationWithType *dwt = dynamic_cast< DeclarationWithType * >( *member ) ) {
    562                                 Type::Qualifiers & qualifiers = dwt->get_type()->get_qualifiers();
    563                                 if ( qualifiers.isConst ) {
     562                                // query the type qualifiers of this field and skip assigning it if it is marked const.
     563                                // If it is an array type, we need to strip off the array layers to find its qualifiers.
     564                                Type * type = dwt->get_type();
     565                                while ( ArrayType * at = dynamic_cast< ArrayType * >( type ) ) {
     566                                        type = at->get_base();
     567                                }
     568
     569                                if ( type->get_qualifiers().isConst ) {
    564570                                        // don't assign const members
    565571                                        continue;
Note: See TracChangeset for help on using the changeset viewer.