Changes in / [e93f1d2:bd5cf7c]
- Location:
- src
- Files:
-
- 2 added
- 2 deleted
- 35 edited
-
CodeGen/CodeGenerator.cc (modified) (3 diffs)
-
CodeGen/CodeGenerator.h (modified) (1 diff)
-
CodeGen/OperatorTable.cc (modified) (2 diffs)
-
CodeGen/OperatorTable.h (modified) (1 diff)
-
Common/Debug.h (modified) (2 diffs)
-
Common/ErrorObjects.h (modified) (1 diff)
-
Common/PassVisitor.h (modified) (2 diffs)
-
Common/PassVisitor.impl.h (modified) (3 diffs)
-
ControlStruct/ExceptTranslate.cc (modified) (2 diffs)
-
GenPoly/Lvalue.cc (modified) (3 diffs)
-
Makefile.in (modified) (6 diffs)
-
Parser/DeclarationNode.cc (modified) (5 diffs)
-
Parser/ParseNode.h (modified) (2 diffs)
-
Parser/parser.yy (modified) (1 diff)
-
ResolvExpr/CommonType.cc (modified) (5 diffs)
-
ResolvExpr/ConversionCost.cc (modified) (2 diffs)
-
ResolvExpr/Resolver.cc (modified) (2 diffs)
-
SymTab/Validate.cc (modified) (6 diffs)
-
SynTree/CompoundStmt.cc (modified) (3 diffs)
-
SynTree/DeclReplacer.cc (deleted)
-
SynTree/DeclReplacer.h (deleted)
-
SynTree/Declaration.cc (modified) (1 diff)
-
SynTree/Declaration.h (modified) (1 diff)
-
SynTree/FunctionDecl.cc (modified) (3 diffs)
-
SynTree/Mutator.h (modified) (1 diff)
-
SynTree/SynTree.h (modified) (1 diff)
-
SynTree/TypeSubstitution.cc (modified) (1 diff)
-
SynTree/TypeSubstitution.h (modified) (1 diff)
-
SynTree/VarExprReplacer.cc (added)
-
SynTree/VarExprReplacer.h (added)
-
SynTree/Visitor.h (modified) (1 diff)
-
SynTree/module.mk (modified) (1 diff)
-
libcfa/concurrency/kernel.c (modified) (1 diff)
-
libcfa/stdlib.c (modified) (3 diffs)
-
tests/.expect/attributes.x64.txt (modified) (4 diffs)
-
tests/.expect/attributes.x86.txt (modified) (4 diffs)
-
tests/.expect/references.txt (modified) (1 diff)
-
tests/operators.c (modified) (1 diff)
-
tests/references.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
re93f1d2 rbd5cf7c 203 203 204 204 void CodeGenerator::handleAggregate( AggregateDecl * aggDecl, const std::string & kind ) { 205 genAttributes( aggDecl->get_attributes() ); 206 205 207 if( ! aggDecl->get_parameters().empty() && ! genC ) { 206 208 // assertf( ! genC, "Aggregate type parameters should not reach code generation." ); … … 211 213 } 212 214 213 output << kind; 214 genAttributes( aggDecl->get_attributes() ); 215 output << aggDecl->get_name(); 215 output << kind << aggDecl->get_name(); 216 216 217 217 if ( aggDecl->has_body() ) { … … 298 298 output << " }"; 299 299 } 300 }301 302 void CodeGenerator::postvisit( StaticAssertDecl * assertDecl ) {303 output << "_Static_assert(";304 assertDecl->condition->accept( *visitor );305 output << ", ";306 assertDecl->message->accept( *visitor );307 output << ")";308 300 } 309 301 -
src/CodeGen/CodeGenerator.h
re93f1d2 rbd5cf7c 42 42 void postvisit( FunctionDecl * ); 43 43 void postvisit( ObjectDecl * ); 44 void postvisit( UnionDecl * aggregateDecl ); 45 void postvisit( EnumDecl * aggregateDecl ); 46 void postvisit( TraitDecl * aggregateDecl ); 47 void postvisit( TypedefDecl * typeDecl ); 48 void postvisit( TypeDecl * typeDecl ); 49 void postvisit( StaticAssertDecl * assertDecl ); 44 void postvisit( UnionDecl *aggregateDecl ); 45 void postvisit( EnumDecl *aggregateDecl ); 46 void postvisit( TraitDecl *aggregateDecl ); 47 void postvisit( TypedefDecl *typeDecl ); 48 void postvisit( TypeDecl *typeDecl ); 50 49 51 50 //*** Initializer -
src/CodeGen/OperatorTable.cc
re93f1d2 rbd5cf7c 79 79 } // namespace 80 80 81 bool operatorLookup( const std::string & funcName, OperatorInfo &info ) {81 bool operatorLookup( std::string funcName, OperatorInfo &info ) { 82 82 static bool init = false; 83 83 if ( ! init ) { … … 100 100 return true; 101 101 } // if 102 }103 104 bool isOperator( const std::string & funcName ) {105 OperatorInfo info;106 return operatorLookup( funcName, info );107 102 } 108 103 -
src/CodeGen/OperatorTable.h
re93f1d2 rbd5cf7c 41 41 }; 42 42 43 bool isOperator( const std::string & funcName ); 44 bool operatorLookup( const std::string & funcName, OperatorInfo & info ); 43 bool operatorLookup( std::string funcName, OperatorInfo &info ); 45 44 46 45 bool isConstructor( const std::string & ); -
src/Common/Debug.h
re93f1d2 rbd5cf7c 28 28 namespace Debug { 29 29 /// debug codegen a translation unit 30 static inline void codeGen( __attribute__((unused)) const std::list< Declaration * > & translationUnit, __attribute__((unused)) const std::string & label, __attribute__((unused))LinkageSpec::Spec linkageFilter = LinkageSpec::Compiler ) {30 static inline void codeGen( __attribute__((unused)) const std::list< Declaration * > & translationUnit, __attribute__((unused)) const std::string & label, LinkageSpec::Spec linkageFilter = LinkageSpec::Compiler ) { 31 31 #ifdef DEBUG 32 32 std::list< Declaration * > decls; … … 41 41 } // dump 42 42 43 static inline void treeDump( __attribute__((unused)) const std::list< Declaration * > & translationUnit, __attribute__((unused)) const std::string & label, __attribute__((unused))LinkageSpec::Spec linkageFilter = LinkageSpec::Compiler ) {43 static inline void treeDump( __attribute__((unused)) const std::list< Declaration * > & translationUnit, __attribute__((unused)) const std::string & label, LinkageSpec::Spec linkageFilter = LinkageSpec::Compiler ) { 44 44 #ifdef DEBUG 45 45 std::list< Declaration * > decls; -
src/Common/ErrorObjects.h
re93f1d2 rbd5cf7c 35 35 class SemanticErrorException : public std::exception { 36 36 public: 37 SemanticErrorException() = default;37 SemanticErrorException() = default; 38 38 SemanticErrorException( CodeLocation location, std::string error ); 39 39 ~SemanticErrorException() throw() {} -
src/Common/PassVisitor.h
re93f1d2 rbd5cf7c 66 66 virtual void visit( TypedefDecl * typeDecl ) override final; 67 67 virtual void visit( AsmDecl * asmDecl ) override final; 68 virtual void visit( StaticAssertDecl * assertDecl ) override final;69 68 70 69 virtual void visit( CompoundStmt * compoundStmt ) override final; … … 162 161 virtual Declaration * mutate( TypedefDecl * typeDecl ) override final; 163 162 virtual AsmDecl * mutate( AsmDecl * asmDecl ) override final; 164 virtual StaticAssertDecl * mutate( StaticAssertDecl * assertDecl ) override final;165 163 166 164 virtual CompoundStmt * mutate( CompoundStmt * compoundStmt ) override final; -
src/Common/PassVisitor.impl.h
re93f1d2 rbd5cf7c 685 685 686 686 //-------------------------------------------------------------------------- 687 // StaticAssertDecl688 template< typename pass_type >689 void PassVisitor< pass_type >::visit( StaticAssertDecl * node ) {690 VISIT_START( node );691 692 maybeAccept_impl( node->condition, *this );693 maybeAccept_impl( node->message , *this );694 695 VISIT_END( node );696 }697 698 template< typename pass_type >699 StaticAssertDecl * PassVisitor< pass_type >::mutate( StaticAssertDecl * node ) {700 MUTATE_START( node );701 702 maybeMutate_impl( node->condition, *this );703 maybeMutate_impl( node->message , *this );704 705 MUTATE_END( StaticAssertDecl, node );706 }707 708 //--------------------------------------------------------------------------709 687 // CompoundStmt 710 688 template< typename pass_type > … … 1512 1490 indexerScopedAccept( node->result, *this ); 1513 1491 maybeAccept_impl ( node->type , *this ); 1492 maybeAccept_impl ( node->member, *this ); 1514 1493 1515 1494 VISIT_END( node ); … … 1523 1502 indexerScopedMutate( node->result, *this ); 1524 1503 maybeMutate_impl ( node->type , *this ); 1504 maybeMutate_impl ( node->member, *this ); 1525 1505 1526 1506 MUTATE_END( Expression, node ); -
src/ControlStruct/ExceptTranslate.cc
re93f1d2 rbd5cf7c 34 34 #include "SynTree/Statement.h" // for CompoundStmt, CatchStmt, ThrowStmt 35 35 #include "SynTree/Type.h" // for FunctionType, Type, noQualifiers 36 #include "SynTree/ DeclReplacer.h" // for DeclReplacer36 #include "SynTree/VarExprReplacer.h" // for VarExprReplacer, VarExprReplace... 37 37 #include "SynTree/Visitor.h" // for acceptAll 38 38 … … 314 314 // Update variables in the body to point to this local copy. 315 315 { 316 DeclReplacer::DeclMap mapping;316 VarExprReplacer::DeclMap mapping; 317 317 mapping[ handler_decl ] = local_except; 318 DeclReplacer::replace( handler->body, mapping );318 VarExprReplacer::replace( handler->body, mapping ); 319 319 } 320 320 -
src/GenPoly/Lvalue.cc
re93f1d2 rbd5cf7c 45 45 Expression * mkDeref( Expression * arg ) { 46 46 if ( SymTab::dereferenceOperator ) { 47 // note: reference depth can be arbitrarily deep here, so peel off the outermost pointer/reference, not just pointer because they are effecitvely equivalent in this pass48 47 VariableExpr * deref = new VariableExpr( SymTab::dereferenceOperator ); 49 48 deref->result = new PointerType( Type::Qualifiers(), deref->result ); … … 198 197 PRINT( 199 198 std::cerr << "pair<0>: " << arg << std::endl; 200 std::cerr << " -- " << arg->result << std::endl;201 199 std::cerr << "pair<1>: " << formal << std::endl; 202 200 ) 203 201 if ( dynamic_cast<ReferenceType*>( formal ) ) { 204 PRINT( 205 std::cerr << "===formal is reference" << std::endl; 206 ) 207 // TODO: it's likely that the second condition should be ... && ! isIntrinsicReference( arg ), but this requires investigation. 208 if ( function->get_linkage() != LinkageSpec::Intrinsic && isIntrinsicReference( arg ) ) { 209 // if argument is dereference or array subscript, the result isn't REALLY a reference, but non-intrinsic functions expect a reference: take address 210 PRINT( 211 std::cerr << "===is intrinsic arg in non-intrinsic call - adding address" << std::endl; 212 ) 213 arg = new AddressExpr( arg ); 214 } else if ( function->get_linkage() == LinkageSpec::Intrinsic && arg->result->referenceDepth() != 0 ) { 215 // argument is a 'real' reference, but function expects a C lvalue: add a dereference to the reference-typed argument 216 PRINT( 217 std::cerr << "===is non-intrinsic arg in intrinsic call - adding deref to arg" << std::endl; 218 ) 202 if ( isIntrinsicReference( arg ) ) { // do not combine conditions, because that changes the meaning of the else if 203 if ( function->get_linkage() != LinkageSpec::Intrinsic ) { // intrinsic functions that turn pointers into references 204 // if argument is dereference or array subscript, the result isn't REALLY a reference, so it's not necessary to fix the argument 205 PRINT( 206 std::cerr << "===is intrinsic arg in non-intrinsic call - adding address" << std::endl; 207 ) 208 arg = new AddressExpr( arg ); 209 } 210 } else if ( function->get_linkage() == LinkageSpec::Intrinsic ) { 211 // std::cerr << "===adding deref to arg" << std::endl; 212 // if the parameter is a reference, add a dereference to the reference-typed argument. 219 213 Type * baseType = InitTweak::getPointerBase( arg->result ); 220 214 assertf( baseType, "parameter is reference, arg must be pointer or reference: %s", toString( arg->result ).c_str() ); … … 223 217 arg->set_result( ptrType ); 224 218 arg = mkDeref( arg ); 225 assertf( arg->result->referenceDepth() == 0, "Reference types should have been eliminated from intrinsic function calls, but weren't: %s", toCString( arg->result ) );226 219 } 227 220 } -
src/Makefile.in
re93f1d2 rbd5cf7c 249 249 SynTree/driver_cfa_cpp-TypeSubstitution.$(OBJEXT) \ 250 250 SynTree/driver_cfa_cpp-Attribute.$(OBJEXT) \ 251 SynTree/driver_cfa_cpp- DeclReplacer.$(OBJEXT) \251 SynTree/driver_cfa_cpp-VarExprReplacer.$(OBJEXT) \ 252 252 Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT) \ 253 253 Tuples/driver_cfa_cpp-TupleExpansion.$(OBJEXT) \ … … 526 526 SynTree/NamedTypeDecl.cc SynTree/TypeDecl.cc \ 527 527 SynTree/Initializer.cc SynTree/TypeSubstitution.cc \ 528 SynTree/Attribute.cc SynTree/ DeclReplacer.cc \528 SynTree/Attribute.cc SynTree/VarExprReplacer.cc \ 529 529 Tuples/TupleAssignment.cc Tuples/TupleExpansion.cc \ 530 530 Tuples/Explode.cc Virtual/ExpandCasts.cc … … 912 912 SynTree/driver_cfa_cpp-Attribute.$(OBJEXT): SynTree/$(am__dirstamp) \ 913 913 SynTree/$(DEPDIR)/$(am__dirstamp) 914 SynTree/driver_cfa_cpp- DeclReplacer.$(OBJEXT): \914 SynTree/driver_cfa_cpp-VarExprReplacer.$(OBJEXT): \ 915 915 SynTree/$(am__dirstamp) SynTree/$(DEPDIR)/$(am__dirstamp) 916 916 Tuples/$(am__dirstamp): … … 1039 1039 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-CompoundStmt.Po@am__quote@ 1040 1040 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-Constant.Po@am__quote@ 1041 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-DeclReplacer.Po@am__quote@1042 1041 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-DeclStmt.Po@am__quote@ 1043 1042 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-Declaration.Po@am__quote@ … … 1061 1060 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-TypeofType.Po@am__quote@ 1062 1061 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VarArgsType.Po@am__quote@ 1062 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VarExprReplacer.Po@am__quote@ 1063 1063 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VoidType.Po@am__quote@ 1064 1064 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Po@am__quote@ … … 2498 2498 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-Attribute.obj `if test -f 'SynTree/Attribute.cc'; then $(CYGPATH_W) 'SynTree/Attribute.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/Attribute.cc'; fi` 2499 2499 2500 SynTree/driver_cfa_cpp- DeclReplacer.o: SynTree/DeclReplacer.cc2501 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SynTree/driver_cfa_cpp- DeclReplacer.o -MD -MP -MF SynTree/$(DEPDIR)/driver_cfa_cpp-DeclReplacer.Tpo -c -o SynTree/driver_cfa_cpp-DeclReplacer.o `test -f 'SynTree/DeclReplacer.cc' || echo '$(srcdir)/'`SynTree/DeclReplacer.cc2502 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp- DeclReplacer.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-DeclReplacer.Po2503 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='SynTree/ DeclReplacer.cc' object='SynTree/driver_cfa_cpp-DeclReplacer.o' libtool=no @AMDEPBACKSLASH@2504 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2505 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp- DeclReplacer.o `test -f 'SynTree/DeclReplacer.cc' || echo '$(srcdir)/'`SynTree/DeclReplacer.cc2506 2507 SynTree/driver_cfa_cpp- DeclReplacer.obj: SynTree/DeclReplacer.cc2508 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SynTree/driver_cfa_cpp- DeclReplacer.obj -MD -MP -MF SynTree/$(DEPDIR)/driver_cfa_cpp-DeclReplacer.Tpo -c -o SynTree/driver_cfa_cpp-DeclReplacer.obj `if test -f 'SynTree/DeclReplacer.cc'; then $(CYGPATH_W) 'SynTree/DeclReplacer.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/DeclReplacer.cc'; fi`2509 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp- DeclReplacer.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-DeclReplacer.Po2510 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='SynTree/ DeclReplacer.cc' object='SynTree/driver_cfa_cpp-DeclReplacer.obj' libtool=no @AMDEPBACKSLASH@2511 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2512 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp- DeclReplacer.obj `if test -f 'SynTree/DeclReplacer.cc'; then $(CYGPATH_W) 'SynTree/DeclReplacer.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/DeclReplacer.cc'; fi`2500 SynTree/driver_cfa_cpp-VarExprReplacer.o: SynTree/VarExprReplacer.cc 2501 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SynTree/driver_cfa_cpp-VarExprReplacer.o -MD -MP -MF SynTree/$(DEPDIR)/driver_cfa_cpp-VarExprReplacer.Tpo -c -o SynTree/driver_cfa_cpp-VarExprReplacer.o `test -f 'SynTree/VarExprReplacer.cc' || echo '$(srcdir)/'`SynTree/VarExprReplacer.cc 2502 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-VarExprReplacer.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-VarExprReplacer.Po 2503 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='SynTree/VarExprReplacer.cc' object='SynTree/driver_cfa_cpp-VarExprReplacer.o' libtool=no @AMDEPBACKSLASH@ 2504 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2505 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-VarExprReplacer.o `test -f 'SynTree/VarExprReplacer.cc' || echo '$(srcdir)/'`SynTree/VarExprReplacer.cc 2506 2507 SynTree/driver_cfa_cpp-VarExprReplacer.obj: SynTree/VarExprReplacer.cc 2508 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SynTree/driver_cfa_cpp-VarExprReplacer.obj -MD -MP -MF SynTree/$(DEPDIR)/driver_cfa_cpp-VarExprReplacer.Tpo -c -o SynTree/driver_cfa_cpp-VarExprReplacer.obj `if test -f 'SynTree/VarExprReplacer.cc'; then $(CYGPATH_W) 'SynTree/VarExprReplacer.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/VarExprReplacer.cc'; fi` 2509 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-VarExprReplacer.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-VarExprReplacer.Po 2510 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='SynTree/VarExprReplacer.cc' object='SynTree/driver_cfa_cpp-VarExprReplacer.obj' libtool=no @AMDEPBACKSLASH@ 2511 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2512 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-VarExprReplacer.obj `if test -f 'SynTree/VarExprReplacer.cc'; then $(CYGPATH_W) 'SynTree/VarExprReplacer.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/VarExprReplacer.cc'; fi` 2513 2513 2514 2514 Tuples/driver_cfa_cpp-TupleAssignment.o: Tuples/TupleAssignment.cc -
src/Parser/DeclarationNode.cc
re93f1d2 rbd5cf7c 71 71 attr.expr = nullptr; 72 72 attr.type = nullptr; 73 74 assert.condition = nullptr;75 assert.message = nullptr;76 73 } 77 74 … … 91 88 // asmName, no delete, passed to next stage 92 89 delete initializer; 93 94 delete assert.condition;95 delete assert.message;96 90 } 97 91 … … 123 117 newnode->attr.expr = maybeClone( attr.expr ); 124 118 newnode->attr.type = maybeClone( attr.type ); 125 126 newnode->assert.condition = maybeClone( assert.condition );127 newnode->assert.message = maybeClone( assert.message );128 119 return newnode; 129 120 } // DeclarationNode::clone … … 443 434 return newnode; 444 435 } 445 446 DeclarationNode * DeclarationNode::newStaticAssert( ExpressionNode * condition, Expression * message ) {447 DeclarationNode * newnode = new DeclarationNode;448 newnode->assert.condition = condition;449 newnode->assert.message = message;450 return newnode;451 }452 453 436 454 437 void appendError( string & dst, const string & src ) { … … 1069 1052 } // if 1070 1053 1071 if ( assert.condition ) {1072 return new StaticAssertDecl( maybeBuild< Expression >( assert.condition ), strict_dynamic_cast< ConstantExpr * >( maybeClone( assert.message ) ) );1073 }1074 1075 1054 // SUE's cannot have function specifiers, either 1076 1055 // -
src/Parser/ParseNode.h
re93f1d2 rbd5cf7c 246 246 static DeclarationNode * newAttribute( std::string *, ExpressionNode * expr = nullptr ); // gcc attributes 247 247 static DeclarationNode * newAsmStmt( StatementNode * stmt ); // gcc external asm statement 248 static DeclarationNode * newStaticAssert( ExpressionNode * condition, Expression * message );249 248 250 249 DeclarationNode(); … … 314 313 Attr_t attr; 315 314 316 struct StaticAssert_t {317 ExpressionNode * condition;318 Expression * message;319 };320 StaticAssert_t assert;321 322 315 BuiltinType builtin; 323 316 -
src/Parser/parser.yy
re93f1d2 rbd5cf7c 1314 1314 static_assert: 1315 1315 STATICASSERT '(' constant_expression ',' string_literal ')' ';' // C11 1316 { $$ = DeclarationNode::newStaticAssert( $3, $5 ); }1316 { SemanticError( yylloc, "Static assert is currently unimplemented." ); $$ = nullptr; } 1317 1317 1318 1318 // C declaration syntax is notoriously confusing and error prone. Cforall provides its own type, variable and function -
src/ResolvExpr/CommonType.cc
re93f1d2 rbd5cf7c 28 28 29 29 // #define DEBUG 30 #ifdef DEBUG31 #define PRINT(x) x32 #else33 #define PRINT(x)34 #endif35 30 36 31 namespace ResolvExpr { … … 75 70 // need unify to bind type variables 76 71 if ( unify( t1, t2, env, have, need, newOpen, indexer, common ) ) { 77 PRINT( 78 std::cerr << "unify success: " << widenFirst << " " << widenSecond << std::endl; 79 ) 72 // std::cerr << "unify success: " << widenFirst << " " << widenSecond << std::endl; 80 73 if ( (widenFirst || t2->get_qualifiers() <= t1->get_qualifiers()) && (widenSecond || t1->get_qualifiers() <= t2->get_qualifiers()) ) { 81 PRINT( 82 std::cerr << "widen okay" << std::endl; 83 ) 74 // std::cerr << "widen okay" << std::endl; 84 75 common->get_qualifiers() |= t1->get_qualifiers(); 85 76 common->get_qualifiers() |= t2->get_qualifiers(); … … 87 78 } 88 79 } 89 PRINT( 90 std::cerr << "exact unify failed: " << t1 << " " << t2 << std::endl; 91 ) 80 // std::cerr << "exact unify failed: " << t1 << " " << t2 << std::endl; 92 81 return nullptr; 93 82 } … … 105 94 // special case where one type has a reference depth of 1 larger than the other 106 95 if ( diff > 0 || diff < 0 ) { 107 PRINT( 108 std::cerr << "reference depth diff: " << diff << std::endl; 109 ) 96 // std::cerr << "reference depth diff: " << diff << std::endl; 110 97 Type * result = nullptr; 111 98 ReferenceType * ref1 = dynamic_cast< ReferenceType * >( type1 ); … … 122 109 if ( result && ref1 ) { 123 110 // formal is reference, so result should be reference 124 PRINT( 125 std::cerr << "formal is reference; result should be reference" << std::endl; 126 ) 111 // std::cerr << "formal is reference; result should be reference" << std::endl; 127 112 result = new ReferenceType( ref1->get_qualifiers(), result ); 128 113 } 129 PRINT( 130 std::cerr << "common type of reference [" << type1 << "] and [" << type2 << "] is [" << result << "]" << std::endl; 131 ) 114 // std::cerr << "common type of reference [" << type1 << "] and [" << type2 << "] is [" << result << "]" << std::endl; 132 115 return result; 133 116 } -
src/ResolvExpr/ConversionCost.cc
re93f1d2 rbd5cf7c 275 275 // xxx - not positive this is correct, but appears to allow casting int => enum 276 276 cost = Cost::unsafe; 277 } // if 278 // no cases for zero_t/one_t because it should not be possible to convert int, etc. to zero_t/one_t. 277 } else if ( dynamic_cast< ZeroType* >( dest ) != nullptr || dynamic_cast< OneType* >( dest ) != nullptr ) { 278 cost = Cost::unsafe; 279 } // if 279 280 } 280 281 … … 308 309 // assignResult == 0 means Cost::Infinity 309 310 } // if 310 // case case for zero_t because it should not be possible to convert pointers to zero_t. 311 } else if ( dynamic_cast< ZeroType * >( dest ) ) { 312 cost = Cost::unsafe; 311 313 } // if 312 314 } -
src/ResolvExpr/Resolver.cc
re93f1d2 rbd5cf7c 59 59 void previsit( TypeDecl *typeDecl ); 60 60 void previsit( EnumDecl * enumDecl ); 61 void previsit( StaticAssertDecl * assertDecl );62 61 63 62 void previsit( ArrayType * at ); … … 362 361 GuardValue( inEnumDecl ); 363 362 inEnumDecl = true; 364 }365 366 void Resolver::previsit( StaticAssertDecl * assertDecl ) {367 findIntegralExpression( assertDecl->condition, indexer );368 363 } 369 364 -
src/SymTab/Validate.cc
re93f1d2 rbd5cf7c 89 89 void previsit( StructDecl * aggregateDecl ); 90 90 void previsit( UnionDecl * aggregateDecl ); 91 void previsit( StaticAssertDecl * assertDecl );92 91 93 92 private: … … 148 147 void previsit( ObjectDecl * object ); 149 148 void previsit( FunctionDecl * func ); 150 void previsit( FunctionType * ftype );151 149 void previsit( StructDecl * aggrDecl ); 152 150 void previsit( UnionDecl * aggrDecl ); … … 298 296 } 299 297 300 bool shouldHoist( Declaration *decl ) {301 return dynamic_cast< StructDecl * >( decl ) || dynamic_cast< UnionDecl * >( decl ) || dynamic_cast< StaticAssertDecl * >( decl );298 bool isStructOrUnion( Declaration *decl ) { 299 return dynamic_cast< StructDecl * >( decl ) || dynamic_cast< UnionDecl * >( decl ); 302 300 } 303 301 … … 312 310 } // if 313 311 // Always remove the hoisted aggregate from the inner structure. 314 GuardAction( [aggregateDecl]() { filter( aggregateDecl->members, shouldHoist, false ); } );312 GuardAction( [aggregateDecl]() { filter( aggregateDecl->members, isStructOrUnion, false ); } ); 315 313 } 316 314 … … 330 328 if ( inst->baseUnion ) { 331 329 declsToAddBefore.push_front( inst->baseUnion ); 332 }333 }334 335 void HoistStruct::previsit( StaticAssertDecl * assertDecl ) {336 if ( parentAggr ) {337 declsToAddBefore.push_back( assertDecl );338 330 } 339 331 } … … 634 626 635 627 void ForallPointerDecay::previsit( ObjectDecl *object ) { 636 // ensure that operator names only apply to functions or function pointers637 if ( CodeGen::isOperator( object->name ) && ! dynamic_cast< FunctionType * >( object->type->stripDeclarator()) ) {638 SemanticError( object->location, toCString( "operator ", object->name.c_str(), " is not a function or function pointer." ));639 } 628 forallFixer( object->type->forall, object ); 629 if ( PointerType *pointer = dynamic_cast< PointerType * >( object->type ) ) { 630 forallFixer( pointer->base->forall, object ); 631 } // if 640 632 object->fixUniqueId(); 641 633 } 642 634 643 635 void ForallPointerDecay::previsit( FunctionDecl *func ) { 636 forallFixer( func->type->forall, func ); 644 637 func->fixUniqueId(); 645 }646 647 void ForallPointerDecay::previsit( FunctionType * ftype ) {648 forallFixer( ftype->forall, ftype );649 638 } 650 639 -
src/SynTree/CompoundStmt.cc
re93f1d2 rbd5cf7c 23 23 #include "Statement.h" // for CompoundStmt, Statement, DeclStmt 24 24 #include "SynTree/Label.h" // for Label 25 #include "SynTree/ DeclReplacer.h" // for DeclReplacer25 #include "SynTree/VarExprReplacer.h" // for VarExprReplacer, VarExprReplace... 26 26 27 27 using std::string; … … 49 49 // recursively execute this routine. There may be more efficient ways of doing 50 50 // this. 51 DeclReplacer::DeclMap declMap;51 VarExprReplacer::DeclMap declMap; 52 52 std::list< Statement * >::const_iterator origit = other.kids.begin(); 53 53 for ( Statement * s : kids ) { … … 64 64 } 65 65 if ( ! declMap.empty() ) { 66 DeclReplacer::replace( this, declMap );66 VarExprReplacer::replace( this, declMap ); 67 67 } 68 68 } -
src/SynTree/Declaration.cc
re93f1d2 rbd5cf7c 81 81 82 82 83 StaticAssertDecl::StaticAssertDecl( Expression * condition, ConstantExpr * message ) : Declaration( "", Type::StorageClasses(), LinkageSpec::C ), condition( condition ), message( message ) {84 }85 86 StaticAssertDecl::StaticAssertDecl( const StaticAssertDecl & other ) : Declaration( other ), condition( maybeClone( other.condition ) ), message( maybeClone( other.message ) ) {87 }88 89 StaticAssertDecl::~StaticAssertDecl() {90 delete condition;91 delete message;92 }93 94 void StaticAssertDecl::print( std::ostream &os, Indenter indent ) const {95 os << "Static Assert with condition: ";96 condition->print( os, indent+1 );97 os << std::endl << indent << "and message: ";98 message->print( os, indent+1 );99 os << std::endl;100 }101 102 void StaticAssertDecl::printShort( std::ostream &os, Indenter indent ) const {103 print( os, indent );104 }105 106 83 // Local Variables: // 107 84 // tab-width: 4 // -
src/SynTree/Declaration.h
re93f1d2 rbd5cf7c 365 365 }; 366 366 367 class StaticAssertDecl : public Declaration {368 public:369 Expression * condition;370 ConstantExpr * message; // string literal371 372 StaticAssertDecl( Expression * condition, ConstantExpr * message );373 StaticAssertDecl( const StaticAssertDecl & other );374 virtual ~StaticAssertDecl();375 376 virtual StaticAssertDecl * clone() const override { return new StaticAssertDecl( *this ); }377 virtual void accept( Visitor &v ) override { v.visit( this ); }378 virtual StaticAssertDecl * acceptMutator( Mutator &m ) override { return m.mutate( this ); }379 virtual void print( std::ostream &os, Indenter indent = {} ) const override;380 virtual void printShort( std::ostream &os, Indenter indent = {} ) const override;381 };382 383 367 std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data ); 384 368 -
src/SynTree/FunctionDecl.cc
re93f1d2 rbd5cf7c 26 26 #include "Statement.h" // for CompoundStmt 27 27 #include "Type.h" // for Type, FunctionType, Type::FuncSpecif... 28 #include " DeclReplacer.h"28 #include "VarExprReplacer.h" 29 29 30 30 extern bool translation_unit_nomain; … … 41 41 : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ) { 42 42 43 DeclReplacer::DeclMap declMap;43 VarExprReplacer::DeclMap declMap; 44 44 for ( auto p : group_iterate( other.type->parameters, type->parameters ) ) { 45 45 declMap[ std::get<0>(p) ] = std::get<1>(p); … … 49 49 } 50 50 if ( ! declMap.empty() ) { 51 DeclReplacer::replace( this, declMap );51 VarExprReplacer::replace( this, declMap ); 52 52 } 53 53 cloneAll( other.withExprs, withExprs ); -
src/SynTree/Mutator.h
re93f1d2 rbd5cf7c 34 34 virtual Declaration * mutate( TypedefDecl * typeDecl ) = 0; 35 35 virtual AsmDecl * mutate( AsmDecl * asmDecl ) = 0; 36 virtual StaticAssertDecl * mutate( StaticAssertDecl * assertDecl ) = 0;37 36 38 37 virtual CompoundStmt * mutate( CompoundStmt * compoundStmt ) = 0; -
src/SynTree/SynTree.h
re93f1d2 rbd5cf7c 38 38 class TypedefDecl; 39 39 class AsmDecl; 40 class StaticAssertDecl;41 40 42 41 class Statement; -
src/SynTree/TypeSubstitution.cc
re93f1d2 rbd5cf7c 149 149 return inst; 150 150 } else { 151 // cut off infinite loop for the case where a type is bound to itself. 152 // Note: this does not prevent cycles in the general case, so it may be necessary to do something more sophisticated here. 153 // TODO: investigate preventing type variables from being bound to themselves in the first place. 154 if ( TypeInstType * replacement = dynamic_cast< TypeInstType * >( i->second ) ) { 155 if ( inst->name == replacement->name ) { 156 return inst; 157 } 158 } 159 // std::cerr << "found " << inst->name << ", replacing with " << i->second << std::endl; 151 /// std::cerr << "found " << inst->get_name() << ", replacing with "; 152 /// i->second->print( std::cerr ); 153 /// std::cerr << std::endl; 160 154 subCount++; 161 155 Type * newtype = i->second->clone(); 162 156 newtype->get_qualifiers() |= inst->get_qualifiers(); 163 157 delete inst; 164 // Note: need to recursively apply substitution to the new type because normalize does not substitute bound vars, but bound vars must be substituted when not in freeOnly mode. 165 return newtype->acceptMutator( *visitor ); 158 return newtype; 166 159 } // if 167 160 } -
src/SynTree/TypeSubstitution.h
re93f1d2 rbd5cf7c 129 129 130 130 // definitition must happen after PassVisitor is included so that WithGuards can be used 131 struct TypeSubstitution::Substituter : public WithGuards , public WithVisitorRef<Substituter>{131 struct TypeSubstitution::Substituter : public WithGuards { 132 132 Substituter( TypeSubstitution & sub, bool freeOnly ) : sub( sub ), freeOnly( freeOnly ) {} 133 133 -
src/SynTree/Visitor.h
re93f1d2 rbd5cf7c 36 36 virtual void visit( TypedefDecl * typeDecl ) = 0; 37 37 virtual void visit( AsmDecl * asmDecl ) = 0; 38 virtual void visit( StaticAssertDecl * assertDecl ) = 0;39 38 40 39 virtual void visit( CompoundStmt * compoundStmt ) = 0; -
src/SynTree/module.mk
re93f1d2 rbd5cf7c 48 48 SynTree/TypeSubstitution.cc \ 49 49 SynTree/Attribute.cc \ 50 SynTree/ DeclReplacer.cc50 SynTree/VarExprReplacer.cc 51 51 -
src/libcfa/concurrency/kernel.c
re93f1d2 rbd5cf7c 628 628 __cfaabi_dbg_bits_write( abort_text, len ); 629 629 630 if ( get_coroutine(thrd)!= TL_GET( this_coroutine ) ) {630 if ( thrd != TL_GET( this_coroutine ) ) { 631 631 len = snprintf( abort_text, abort_text_size, " in coroutine %.256s (%p).\n", TL_GET( this_coroutine )->name, TL_GET( this_coroutine ) ); 632 632 __cfaabi_dbg_bits_write( abort_text, len ); -
src/libcfa/stdlib.c
re93f1d2 rbd5cf7c 99 99 char * eeptr; 100 100 re = strtof( sptr, &eeptr ); 101 if ( sptr == eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0f + 0.0f * _Complex_I; }101 if ( sptr == *eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0f + 0.0f * _Complex_I; } 102 102 im = strtof( eeptr, &eeptr ); 103 if ( sptr == eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0f + 0.0f * _Complex_I; }103 if ( sptr == *eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0f + 0.0f * _Complex_I; } 104 104 if ( *eeptr != 'i' ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0f + 0.0f * _Complex_I; } 105 105 return re + im * _Complex_I; … … 110 110 char * eeptr; 111 111 re = strtod( sptr, &eeptr ); 112 if ( sptr == eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0 + 0.0 * _Complex_I; }112 if ( sptr == *eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0 + 0.0 * _Complex_I; } 113 113 im = strtod( eeptr, &eeptr ); 114 if ( sptr == eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0 + 0.0 * _Complex_I; }114 if ( sptr == *eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0 + 0.0 * _Complex_I; } 115 115 if ( *eeptr != 'i' ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0 + 0.0 * _Complex_I; } 116 116 return re + im * _Complex_I; … … 121 121 char * eeptr; 122 122 re = strtold( sptr, &eeptr ); 123 if ( sptr == eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0L + 0.0L * _Complex_I; }123 if ( sptr == *eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0L + 0.0L * _Complex_I; } 124 124 im = strtold( eeptr, &eeptr ); 125 if ( sptr == eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0L + 0.0L * _Complex_I; }125 if ( sptr == *eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0L + 0.0L * _Complex_I; } 126 126 if ( *eeptr != 'i' ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0L + 0.0L * _Complex_I; } 127 127 return re + im * _Complex_I; -
src/tests/.expect/attributes.x64.txt
re93f1d2 rbd5cf7c 3 3 L: __attribute__ ((unused)) ((void)1); 4 4 } 5 struct __attribute__ ((unused))__anonymous0 {5 __attribute__ ((unused)) struct __anonymous0 { 6 6 }; 7 7 static inline void ___constructor__F_R13s__anonymous0_autogen___1(struct __anonymous0 *___dst__R13s__anonymous0_1); … … 20 20 return ___ret__13s__anonymous0_1; 21 21 } 22 struct __attribute__ ((unused))Agn1;23 struct __attribute__ ((unused))Agn2 {22 __attribute__ ((unused)) struct Agn1; 23 __attribute__ ((unused)) struct Agn2 { 24 24 }; 25 25 static inline void ___constructor__F_R5sAgn2_autogen___1(struct Agn2 *___dst__R5sAgn2_1); … … 45 45 __E2__C5eAgn3_1, 46 46 }; 47 struct __attribute__ ((unused))__anonymous2;48 struct __attribute__ ((unused))__anonymous3;47 __attribute__ ((unused)) struct __anonymous2; 48 __attribute__ ((unused)) struct __anonymous3; 49 49 struct Fdl { 50 50 __attribute__ ((unused)) signed int __f1__i_1; … … 314 314 ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int (*)[10])); 315 315 ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int ())); 316 struct __attribute__ ((unused))__anonymous4 {316 __attribute__ ((unused)) struct __anonymous4 { 317 317 signed int __i__i_2; 318 318 }; -
src/tests/.expect/attributes.x86.txt
re93f1d2 rbd5cf7c 3 3 L: __attribute__ ((unused)) ((void)1); 4 4 } 5 struct __attribute__ ((unused))__anonymous0 {5 __attribute__ ((unused)) struct __anonymous0 { 6 6 }; 7 7 static inline void ___constructor__F_R13s__anonymous0_autogen___1(struct __anonymous0 *___dst__R13s__anonymous0_1); … … 20 20 return ___ret__13s__anonymous0_1; 21 21 } 22 struct __attribute__ ((unused))Agn1;23 struct __attribute__ ((unused))Agn2 {22 __attribute__ ((unused)) struct Agn1; 23 __attribute__ ((unused)) struct Agn2 { 24 24 }; 25 25 static inline void ___constructor__F_R5sAgn2_autogen___1(struct Agn2 *___dst__R5sAgn2_1); … … 45 45 __E2__C5eAgn3_1, 46 46 }; 47 struct __attribute__ ((unused))__anonymous2;48 struct __attribute__ ((unused))__anonymous3;47 __attribute__ ((unused)) struct __anonymous2; 48 __attribute__ ((unused)) struct __anonymous3; 49 49 struct Fdl { 50 50 __attribute__ ((unused)) signed int __f1__i_1; … … 314 314 ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int (*)[10])); 315 315 ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int ())); 316 struct __attribute__ ((unused))__anonymous4 {316 __attribute__ ((unused)) struct __anonymous4 { 317 317 signed int __i__i_2; 318 318 }; -
src/tests/.expect/references.txt
re93f1d2 rbd5cf7c 4 4 13 1 12 5 5 14 14 6 x = 6 ; x2 = 7897 x = 6 ; x2 = 9998 x = 12345 ; x2 = 9999 x = 22222 ; x2 = 99910 6 Default constructing a Y 11 7 Copy constructing a Y -
src/tests/operators.c
re93f1d2 rbd5cf7c 27 27 a(b); 28 28 a + b; 29 struct accumulator ?+?; // why not, eh? 30 a + b; 29 31 } 30 32 -
src/tests/references.c
re93f1d2 rbd5cf7c 46 46 47 47 int main() { 48 int x = 123456, x2 = 789,*p1 = &x, **p2 = &p1, ***p3 = &p2,48 int x = 123456, *p1 = &x, **p2 = &p1, ***p3 = &p2, 49 49 &r1 = x, &&r2 = r1, &&&r3 = r2; 50 50 ***p3 = 3; // change x 51 // ((int&)r3 = 3; // change x, ***r3 51 52 **p3 = &x; // change p1 53 // ((int*&)&r3) = &x; // change r1, (&*)**r3 52 54 *p3 = &p1; // change p2 55 // ((int**&)&&r3) = &p2; // change r2, (&(&*)*)*r3 56 // ((int***&)&&&r3) = p3; // change r3 to p3, (&(&(&*)*)*)r3 53 57 int y = 0, z = 11, & ar[3] = { x, y, z }; // initialize array of references 54 58 // &ar[1] = &z; // change reference array element … … 58 62 // sizeof( &ar[1] ) == sizeof( int *); // is true, i.e., the size of a reference 59 63 60 ((int*&)&r3) = &x; // change r1, (&*)**r361 x = 3;62 64 // test that basic reference properties are true - r1 should be an alias for x 63 65 printf("%d %d %d\n", x, r1, &x == &r1); … … 74 76 changeRef( r1 ); 75 77 printf("%d %d\n", r1, x); 76 77 ((int&)r3) = 6; // change x, ***r378 printf("x = %d ; x2 = %d\n", x, x2); // check that x was changed79 ((int*&)&r3) = &x2; // change r1 to refer to x2, (&*)**r380 ((int&)r3) = 999; // modify x281 printf("x = %d ; x2 = %d\n", x, x2); // check that x2 was changed82 ((int**&)&&r3) = p2; // change r2, (&(&*)*)*r383 ((int&)r3) = 12345; // modify x84 printf("x = %d ; x2 = %d\n", x, x2); // check that x was changed85 ((int***&)&&&r3) = p3; // change r3 to p3, (&(&(&*)*)*)r386 ((int&)r3) = 22222; // modify x87 printf("x = %d ; x2 = %d\n", x, x2); // check that x was changed88 78 89 79 // test that reference members are not implicitly constructed/destructed/assigned
Note:
See TracChangeset
for help on using the changeset viewer.