Changeset 3d2b7bc


Ignore:
Timestamp:
Mar 28, 2018, 4:46:54 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
Children:
f6e3e34
Parents:
b5563e1
git-author:
Rob Schluntz <rschlunt@…> (03/28/18 10:35:21)
git-committer:
Rob Schluntz <rschlunt@…> (03/28/18 16:46:54)
Message:

Check for operator-as-object errors

Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/OperatorTable.cc

    rb5563e1 r3d2b7bc  
    7979        } // namespace
    8080
    81         bool operatorLookup( std::string funcName, OperatorInfo &info ) {
     81        bool operatorLookup( const std::string & funcName, OperatorInfo & info ) {
    8282                static bool init = false;
    8383                if ( ! init ) {
     
    100100                        return true;
    101101                } // if
     102        }
     103
     104        bool isOperator( const std::string & funcName ) {
     105                OperatorInfo info;
     106                return operatorLookup( funcName, info );
    102107        }
    103108
  • src/CodeGen/OperatorTable.h

    rb5563e1 r3d2b7bc  
    4141        };
    4242
    43         bool operatorLookup( std::string funcName, OperatorInfo &info );
     43        bool isOperator( const std::string & funcName );
     44        bool operatorLookup( const std::string & funcName, OperatorInfo & info );
    4445
    4546        bool isConstructor( const std::string & );
  • src/SymTab/Validate.cc

    rb5563e1 r3d2b7bc  
    630630                        forallFixer( pointer->base->forall, object );
    631631                } // if
     632                // ensure that operator names only apply to functions or function pointers
     633                if ( CodeGen::isOperator( object->name ) && ! dynamic_cast< FunctionType * >( object->type->stripDeclarator() ) ) {
     634                        SemanticError( object->location, toCString( "operator ", object->name.c_str(), " is not a function or function pointer." )  );
     635                }
    632636                object->fixUniqueId();
    633637        }
  • src/tests/operators.c

    rb5563e1 r3d2b7bc  
    2727        a(b);
    2828        a + b;
    29         struct accumulator ?+?; // why not, eh?
    30         a + b;
    3129}
    3230
Note: See TracChangeset for help on using the changeset viewer.