Changeset de8d7fb1


Ignore:
Timestamp:
Oct 19, 2019, 11:58:30 PM (5 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
16a18f3
Parents:
ecc0fec
Message:

do not generate anonymous name for bit field with empty declarator

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    recc0fec rde8d7fb1  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Thr May  2 10:47:00 2019
    13 // Update Count     : 497
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sat Oct 19 19:30:38 2019
     13// Update Count     : 506
    1414//
    1515#include "CodeGenerator.h"
     
    198198                // deleted decls should never be used, so don't print them
    199199                if ( objectDecl->isDeleted && options.genC ) return;
    200                 if (objectDecl->get_name().empty() && options.genC ) {
     200
     201                // gcc allows an empty declarator (no name) for bit-fields and C states: 6.7.2.1 Structure and union specifiers,
     202                // point 4, page 113: If the (bit field) value is zero, the declaration shall have no declarator.  For anything
     203                // else, the anonymous name refers to the anonymous object for plan9 inheritance.
     204                if ( objectDecl->get_name().empty() && options.genC && ! objectDecl->get_bitfieldWidth() ) {
    201205                        // only generate an anonymous name when generating C code, otherwise it clutters the output too much
    202206                        static UniqueName name = { "__anonymous_object" };
    203207                        objectDecl->set_name( name.newName() );
    204             // Stops unused parameter warnings.
    205             if ( options.anonymousUnused ) {
    206                 objectDecl->attributes.push_back( new Attribute( "unused" ) );
    207             }
     208                        // Stops unused parameter warnings.
     209                        if ( options.anonymousUnused ) {
     210                                objectDecl->attributes.push_back( new Attribute( "unused" ) );
     211                        }
    208212                }
    209213
Note: See TracChangeset for help on using the changeset viewer.