source: src/ResolvExpr/Resolver.cc@ 29e8bf5

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors ctor deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox memory new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since 29e8bf5 was 40e636a, checked in by Rob Schluntz <rschlunt@…>, 9 years ago

only generate array dimension constant inside of functions, recursively mutate array types into pointer types in function parameter lists, fix bug where global compound literal object is lost

  • Property mode set to 100644
File size: 21.0 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// Resolver.cc --
8//
9// Author : Richard C. Bilson
10// Created On : Sun May 17 12:17:01 2015
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Tue Jul 12 17:45:42 2016
13// Update Count : 204
14//
15
16#include "Resolver.h"
17#include "AlternativeFinder.h"
18#include "Alternative.h"
19#include "RenameVars.h"
20#include "ResolveTypeof.h"
21#include "SynTree/Statement.h"
22#include "SynTree/Type.h"
23#include "SynTree/Expression.h"
24#include "SynTree/Initializer.h"
25#include "SymTab/Indexer.h"
26#include "SymTab/Autogen.h"
27#include "Common/utility.h"
28#include "InitTweak/InitTweak.h"
29
30#include <iostream>
31using namespace std;
32
33namespace ResolvExpr {
34 class Resolver : public SymTab::Indexer {
35 public:
36 Resolver() : SymTab::Indexer( false ), switchType( 0 ) {}
37
38 virtual void visit( FunctionDecl *functionDecl );
39 virtual void visit( ObjectDecl *functionDecl );
40 virtual void visit( TypeDecl *typeDecl );
41 virtual void visit( EnumDecl * enumDecl );
42
43 virtual void visit( ArrayType * at );
44 virtual void visit( PointerType * at );
45
46 virtual void visit( ExprStmt *exprStmt );
47 virtual void visit( AsmExpr *asmExpr );
48 virtual void visit( AsmStmt *asmStmt );
49 virtual void visit( IfStmt *ifStmt );
50 virtual void visit( WhileStmt *whileStmt );
51 virtual void visit( ForStmt *forStmt );
52 virtual void visit( SwitchStmt *switchStmt );
53 virtual void visit( CaseStmt *caseStmt );
54 virtual void visit( BranchStmt *branchStmt );
55 virtual void visit( ReturnStmt *returnStmt );
56 virtual void visit( ImplicitCtorDtorStmt * impCtorDtorStmt );
57
58 virtual void visit( SingleInit *singleInit );
59 virtual void visit( ListInit *listInit );
60 virtual void visit( ConstructorInit *ctorInit );
61 private:
62 typedef std::list< Initializer * >::iterator InitIterator;
63
64 template< typename PtrType >
65 void handlePtrType( PtrType * type );
66
67 void resolveAggrInit( AggregateDecl *, InitIterator &, InitIterator & );
68 void resolveSingleAggrInit( Declaration *, InitIterator &, InitIterator & );
69 void fallbackInit( ConstructorInit * ctorInit );
70 std::list< Type * > functionReturn;
71 Type *initContext;
72 Type *switchType;
73 bool inEnumDecl = false;
74 };
75
76 void resolve( std::list< Declaration * > translationUnit ) {
77 Resolver resolver;
78 acceptAll( translationUnit, resolver );
79#if 0
80 resolver.print( cerr );
81 for ( std::list< Declaration * >::iterator i = translationUnit.begin(); i != translationUnit.end(); ++i ) {
82 (*i)->print( std::cerr );
83 (*i)->accept( resolver );
84 } // for
85#endif
86 }
87
88 Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer ) {
89 TypeEnvironment env;
90 return resolveInVoidContext( expr, indexer, env );
91 }
92
93
94 namespace {
95 void finishExpr( Expression *expr, const TypeEnvironment &env ) {
96 expr->set_env( new TypeSubstitution );
97 env.makeSubstitution( *expr->get_env() );
98 }
99 } // namespace
100
101 Expression *findVoidExpression( Expression *untyped, const SymTab::Indexer &indexer ) {
102 global_renamer.reset();
103 TypeEnvironment env;
104 Expression *newExpr = resolveInVoidContext( untyped, indexer, env );
105 finishExpr( newExpr, env );
106 return newExpr;
107 }
108
109 namespace {
110 Expression *findSingleExpression( Expression *untyped, const SymTab::Indexer &indexer ) {
111 TypeEnvironment env;
112 AlternativeFinder finder( indexer, env );
113 finder.find( untyped );
114#if 0
115 if ( finder.get_alternatives().size() != 1 ) {
116 std::cout << "untyped expr is ";
117 untyped->print( std::cout );
118 std::cout << std::endl << "alternatives are:";
119 for ( std::list< Alternative >::const_iterator i = finder.get_alternatives().begin(); i != finder.get_alternatives().end(); ++i ) {
120 i->print( std::cout );
121 } // for
122 } // if
123#endif
124 assert( finder.get_alternatives().size() == 1 );
125 Alternative &choice = finder.get_alternatives().front();
126 Expression *newExpr = choice.expr->clone();
127 finishExpr( newExpr, choice.env );
128 return newExpr;
129 }
130
131 bool isIntegralType( Type *type ) {
132 if ( dynamic_cast< EnumInstType * >( type ) ) {
133 return true;
134 } else if ( BasicType *bt = dynamic_cast< BasicType * >( type ) ) {
135 return bt->isInteger();
136 } else {
137 return false;
138 } // if
139 }
140
141 Expression *findIntegralExpression( Expression *untyped, const SymTab::Indexer &indexer ) {
142 TypeEnvironment env;
143 AlternativeFinder finder( indexer, env );
144 finder.find( untyped );
145#if 0
146 if ( finder.get_alternatives().size() != 1 ) {
147 std::cout << "untyped expr is ";
148 untyped->print( std::cout );
149 std::cout << std::endl << "alternatives are:";
150 for ( std::list< Alternative >::const_iterator i = finder.get_alternatives().begin(); i != finder.get_alternatives().end(); ++i ) {
151 i->print( std::cout );
152 } // for
153 } // if
154#endif
155 Expression *newExpr = 0;
156 const TypeEnvironment *newEnv = 0;
157 for ( AltList::const_iterator i = finder.get_alternatives().begin(); i != finder.get_alternatives().end(); ++i ) {
158 if ( i->expr->get_results().size() == 1 && isIntegralType( i->expr->get_results().front() ) ) {
159 if ( newExpr ) {
160 throw SemanticError( "Too many interpretations for case control expression", untyped );
161 } else {
162 newExpr = i->expr->clone();
163 newEnv = &i->env;
164 } // if
165 } // if
166 } // for
167 if ( ! newExpr ) {
168 throw SemanticError( "No interpretations for case control expression", untyped );
169 } // if
170 finishExpr( newExpr, *newEnv );
171 return newExpr;
172 }
173
174 }
175
176 void Resolver::visit( ObjectDecl *objectDecl ) {
177 Type *new_type = resolveTypeof( objectDecl->get_type(), *this );
178 objectDecl->set_type( new_type );
179 // To handle initialization of routine pointers, e.g., int (*fp)(int) = foo(), means that class-variable
180 // initContext is changed multiple time because the LHS is analysed twice. The second analysis changes
181 // initContext because of a function type can contain object declarations in the return and parameter types. So
182 // each value of initContext is retained, so the type on the first analysis is preserved and used for selecting
183 // the RHS.
184 Type *temp = initContext;
185 initContext = new_type;
186 if ( inEnumDecl && dynamic_cast< EnumInstType * >( initContext ) ) {
187 // enumerator initializers should not use the enum type to initialize, since
188 // the enum type is still incomplete at this point. Use signed int instead.
189 initContext = new BasicType( Type::Qualifiers(), BasicType::SignedInt );
190 }
191 SymTab::Indexer::visit( objectDecl );
192 if ( inEnumDecl && dynamic_cast< EnumInstType * >( initContext ) ) {
193 // delete newly created signed int type
194 delete initContext;
195 }
196 initContext = temp;
197 }
198
199 template< typename PtrType >
200 void Resolver::handlePtrType( PtrType * type ) {
201 if ( type->get_dimension() ) {
202 CastExpr *castExpr = new CastExpr( type->get_dimension(), SymTab::SizeType->clone() );
203 Expression *newExpr = findSingleExpression( castExpr, *this );
204 delete type->get_dimension();
205 type->set_dimension( newExpr );
206 }
207 }
208
209 void Resolver::visit( ArrayType * at ) {
210 handlePtrType( at );
211 Visitor::visit( at );
212 }
213
214 void Resolver::visit( PointerType * pt ) {
215 handlePtrType( pt );
216 Visitor::visit( pt );
217 }
218
219 void Resolver::visit( TypeDecl *typeDecl ) {
220 if ( typeDecl->get_base() ) {
221 Type *new_type = resolveTypeof( typeDecl->get_base(), *this );
222 typeDecl->set_base( new_type );
223 } // if
224 SymTab::Indexer::visit( typeDecl );
225 }
226
227 void Resolver::visit( FunctionDecl *functionDecl ) {
228#if 0
229 std::cout << "resolver visiting functiondecl ";
230 functionDecl->print( std::cout );
231 std::cout << std::endl;
232#endif
233 Type *new_type = resolveTypeof( functionDecl->get_type(), *this );
234 functionDecl->set_type( new_type );
235 std::list< Type * > oldFunctionReturn = functionReturn;
236 functionReturn.clear();
237 for ( std::list< DeclarationWithType * >::const_iterator i = functionDecl->get_functionType()->get_returnVals().begin(); i != functionDecl->get_functionType()->get_returnVals().end(); ++i ) {
238 functionReturn.push_back( (*i)->get_type() );
239 } // for
240 SymTab::Indexer::visit( functionDecl );
241 functionReturn = oldFunctionReturn;
242 }
243
244 void Resolver::visit( EnumDecl * enumDecl ) {
245 // in case we decide to allow nested enums
246 bool oldInEnumDecl = inEnumDecl;
247 inEnumDecl = true;
248 SymTab::Indexer::visit( enumDecl );
249 inEnumDecl = oldInEnumDecl;
250 }
251
252 void Resolver::visit( ExprStmt *exprStmt ) {
253 if ( exprStmt->get_expr() ) {
254 Expression *newExpr = findVoidExpression( exprStmt->get_expr(), *this );
255 delete exprStmt->get_expr();
256 exprStmt->set_expr( newExpr );
257 } // if
258 }
259
260 void Resolver::visit( AsmExpr *asmExpr ) {
261 Expression *newExpr = findVoidExpression( asmExpr->get_operand(), *this );
262 delete asmExpr->get_operand();
263 asmExpr->set_operand( newExpr );
264 if ( asmExpr->get_inout() ) {
265 newExpr = findVoidExpression( asmExpr->get_inout(), *this );
266 delete asmExpr->get_inout();
267 asmExpr->set_inout( newExpr );
268 } // if
269 }
270
271 void Resolver::visit( AsmStmt *asmStmt ) {
272 acceptAll( asmStmt->get_input(), *this);
273 acceptAll( asmStmt->get_output(), *this);
274 }
275
276 void Resolver::visit( IfStmt *ifStmt ) {
277 Expression *newExpr = findSingleExpression( ifStmt->get_condition(), *this );
278 delete ifStmt->get_condition();
279 ifStmt->set_condition( newExpr );
280 Visitor::visit( ifStmt );
281 }
282
283 void Resolver::visit( WhileStmt *whileStmt ) {
284 Expression *newExpr = findSingleExpression( whileStmt->get_condition(), *this );
285 delete whileStmt->get_condition();
286 whileStmt->set_condition( newExpr );
287 Visitor::visit( whileStmt );
288 }
289
290 void Resolver::visit( ForStmt *forStmt ) {
291 SymTab::Indexer::visit( forStmt );
292
293 if ( forStmt->get_condition() ) {
294 Expression * newExpr = findSingleExpression( forStmt->get_condition(), *this );
295 delete forStmt->get_condition();
296 forStmt->set_condition( newExpr );
297 } // if
298
299 if ( forStmt->get_increment() ) {
300 Expression * newExpr = findVoidExpression( forStmt->get_increment(), *this );
301 delete forStmt->get_increment();
302 forStmt->set_increment( newExpr );
303 } // if
304 }
305
306 template< typename SwitchClass >
307 void handleSwitchStmt( SwitchClass *switchStmt, SymTab::Indexer &visitor ) {
308 Expression *newExpr;
309 newExpr = findIntegralExpression( switchStmt->get_condition(), visitor );
310 delete switchStmt->get_condition();
311 switchStmt->set_condition( newExpr );
312
313 visitor.Visitor::visit( switchStmt );
314 }
315
316 void Resolver::visit( SwitchStmt *switchStmt ) {
317 handleSwitchStmt( switchStmt, *this );
318 }
319
320 void Resolver::visit( CaseStmt *caseStmt ) {
321 Visitor::visit( caseStmt );
322 }
323
324 void Resolver::visit( BranchStmt *branchStmt ) {
325 // must resolve the argument for a computed goto
326 if ( branchStmt->get_type() == BranchStmt::Goto ) { // check for computed goto statement
327 if ( Expression * arg = branchStmt->get_computedTarget() ) {
328 VoidType v = Type::Qualifiers(); // cast to void * for the alternative finder
329 PointerType pt( Type::Qualifiers(), v.clone() );
330 CastExpr * castExpr = new CastExpr( arg, pt.clone() );
331 Expression * newExpr = findSingleExpression( castExpr, *this ); // find best expression
332 branchStmt->set_target( newExpr );
333 } // if
334 } // if
335 }
336
337 void Resolver::visit( ReturnStmt *returnStmt ) {
338 if ( returnStmt->get_expr() ) {
339 CastExpr *castExpr = new CastExpr( returnStmt->get_expr() );
340 cloneAll( functionReturn, castExpr->get_results() );
341 Expression *newExpr = findSingleExpression( castExpr, *this );
342 delete castExpr;
343 returnStmt->set_expr( newExpr );
344 } // if
345 }
346
347 template< typename T >
348 bool isCharType( T t ) {
349 if ( BasicType * bt = dynamic_cast< BasicType * >( t ) ) {
350 return bt->get_kind() == BasicType::Char || bt->get_kind() == BasicType::SignedChar ||
351 bt->get_kind() == BasicType::UnsignedChar;
352 }
353 return false;
354 }
355
356 void Resolver::visit( SingleInit *singleInit ) {
357 if ( singleInit->get_value() ) {
358#if 0
359 if (NameExpr * ne = dynamic_cast<NameExpr*>(singleInit->get_value())) {
360 string n = ne->get_name();
361 if (n == "0") {
362 initContext = new BasicType(Type::Qualifiers(),
363 BasicType::SignedInt);
364 } else {
365 DeclarationWithType * decl = lookupId( n );
366 initContext = decl->get_type();
367 }
368 } else if (ConstantExpr * e =
369 dynamic_cast<ConstantExpr*>(singleInit->get_value())) {
370 Constant *c = e->get_constant();
371 initContext = c->get_type();
372 } else {
373 assert(0);
374 }
375#endif
376 CastExpr *castExpr = new CastExpr( singleInit->get_value(), initContext->clone() );
377 Expression *newExpr = findSingleExpression( castExpr, *this );
378 delete castExpr;
379 singleInit->set_value( newExpr );
380
381 // check if initializing type is char[]
382 if ( ArrayType * at = dynamic_cast< ArrayType * >( initContext ) ) {
383 if ( isCharType( at->get_base() ) ) {
384 // check if the resolved type is char *
385 if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_results().front() ) ) {
386 if ( isCharType( pt->get_base() ) ) {
387 // strip cast if we're initializing a char[] with a char *, e.g. char x[] = "hello";
388 CastExpr *ce = dynamic_cast< CastExpr * >( newExpr );
389 singleInit->set_value( ce->get_arg() );
390 ce->set_arg( NULL );
391 delete ce;
392 }
393 }
394 }
395 }
396 } // if
397// singleInit->get_value()->accept( *this );
398 }
399
400 void Resolver::resolveSingleAggrInit( Declaration * dcl, InitIterator & init, InitIterator & initEnd ) {
401 DeclarationWithType * dt = dynamic_cast< DeclarationWithType * >( dcl );
402 assert( dt );
403 initContext = dt->get_type();
404 try {
405 if ( init == initEnd ) return; // stop when there are no more initializers
406 (*init)->accept( *this );
407 ++init; // made it past an initializer
408 } catch( SemanticError & ) {
409 // need to delve deeper, if you can
410 if ( StructInstType * sit = dynamic_cast< StructInstType * >( dt->get_type() ) ) {
411 resolveAggrInit( sit->get_baseStruct(), init, initEnd );
412 } else if ( UnionInstType * uit = dynamic_cast< UnionInstType * >( dt->get_type() ) ) {
413 resolveAggrInit( uit->get_baseUnion(), init, initEnd );
414 } else {
415 // member is not an aggregate type, so can't go any deeper
416
417 // might need to rethink what is being thrown
418 throw;
419 } // if
420 }
421 }
422
423 void Resolver::resolveAggrInit( AggregateDecl * aggr, InitIterator & init, InitIterator & initEnd ) {
424 if ( StructDecl * st = dynamic_cast< StructDecl * >( aggr ) ) {
425 // want to resolve each initializer to the members of the struct,
426 // but if there are more initializers than members we should stop
427 list< Declaration * >::iterator it = st->get_members().begin();
428 for ( ; it != st->get_members().end(); ++it) {
429 resolveSingleAggrInit( *it, init, initEnd );
430 }
431 } else if ( UnionDecl * un = dynamic_cast< UnionDecl * >( aggr ) ) {
432 // only resolve to the first member of a union
433 resolveSingleAggrInit( *un->get_members().begin(), init, initEnd );
434 } // if
435 }
436
437 void Resolver::visit( ListInit * listInit ) {
438 InitIterator iter = listInit->begin_initializers();
439 InitIterator end = listInit->end_initializers();
440
441 if ( ArrayType * at = dynamic_cast< ArrayType * >( initContext ) ) {
442 // resolve each member to the base type of the array
443 for ( ; iter != end; ++iter ) {
444 initContext = at->get_base();
445 (*iter)->accept( *this );
446 } // for
447 } else if ( StructInstType * st = dynamic_cast< StructInstType * >( initContext ) ) {
448 resolveAggrInit( st->get_baseStruct(), iter, end );
449 } else if ( UnionInstType *st = dynamic_cast< UnionInstType * >( initContext ) ) {
450 resolveAggrInit( st->get_baseUnion(), iter, end );
451 } else {
452 // basic types are handled here
453 Visitor::visit( listInit );
454 }
455
456#if 0
457 if ( ArrayType *at = dynamic_cast<ArrayType*>(initContext) ) {
458 std::list<Initializer *>::iterator iter( listInit->begin_initializers() );
459 for ( ; iter != listInit->end_initializers(); ++iter ) {
460 initContext = at->get_base();
461 (*iter)->accept( *this );
462 } // for
463 } else if ( StructInstType *st = dynamic_cast<StructInstType*>(initContext) ) {
464 StructDecl *baseStruct = st->get_baseStruct();
465 std::list<Declaration *>::iterator iter1( baseStruct->get_members().begin() );
466 std::list<Initializer *>::iterator iter2( listInit->begin_initializers() );
467 for ( ; iter1 != baseStruct->get_members().end() && iter2 != listInit->end_initializers(); ++iter2 ) {
468 if ( (*iter2)->get_designators().empty() ) {
469 DeclarationWithType *dt = dynamic_cast<DeclarationWithType *>( *iter1 );
470 initContext = dt->get_type();
471 (*iter2)->accept( *this );
472 ++iter1;
473 } else {
474 StructDecl *st = baseStruct;
475 iter1 = st->get_members().begin();
476 std::list<Expression *>::iterator iter3( (*iter2)->get_designators().begin() );
477 for ( ; iter3 != (*iter2)->get_designators().end(); ++iter3 ) {
478 NameExpr *key = dynamic_cast<NameExpr *>( *iter3 );
479 assert( key );
480 for ( ; iter1 != st->get_members().end(); ++iter1 ) {
481 if ( key->get_name() == (*iter1)->get_name() ) {
482 (*iter1)->print( cout );
483 cout << key->get_name() << endl;
484 ObjectDecl *fred = dynamic_cast<ObjectDecl *>( *iter1 );
485 assert( fred );
486 StructInstType *mary = dynamic_cast<StructInstType*>( fred->get_type() );
487 assert( mary );
488 st = mary->get_baseStruct();
489 iter1 = st->get_members().begin();
490 break;
491 } // if
492 } // for
493 } // for
494 ObjectDecl *fred = dynamic_cast<ObjectDecl *>( *iter1 );
495 assert( fred );
496 initContext = fred->get_type();
497 (*listInit->begin_initializers())->accept( *this );
498 } // if
499 } // for
500 } else if ( UnionInstType *st = dynamic_cast<UnionInstType*>(initContext) ) {
501 DeclarationWithType *dt = dynamic_cast<DeclarationWithType *>( *st->get_baseUnion()->get_members().begin() );
502 initContext = dt->get_type();
503 (*listInit->begin_initializers())->accept( *this );
504 } // if
505#endif
506 }
507
508 // ConstructorInit - fall back on C-style initializer
509 void Resolver::fallbackInit( ConstructorInit * ctorInit ) {
510 // could not find valid constructor, or found an intrinsic constructor
511 // fall back on C-style initializer
512 delete ctorInit->get_ctor();
513 ctorInit->set_ctor( NULL );
514 delete ctorInit->get_dtor();
515 ctorInit->set_dtor( NULL );
516 maybeAccept( ctorInit->get_init(), *this );
517 }
518
519 void Resolver::visit( ConstructorInit *ctorInit ) {
520 try {
521 maybeAccept( ctorInit->get_ctor(), *this );
522 maybeAccept( ctorInit->get_dtor(), *this );
523 } catch ( SemanticError ) {
524 // no alternatives for the constructor initializer - fallback on C-style initializer
525 // xxx - not sure if this makes a ton of sense - should maybe never be able to have this situation?
526 fallbackInit( ctorInit );
527 return;
528 }
529
530 // found a constructor - can get rid of C-style initializer
531 delete ctorInit->get_init();
532 ctorInit->set_init( NULL );
533
534 // intrinsic single parameter constructors and destructors do nothing. Since this was
535 // implicitly generated, there's no way for it to have side effects, so get rid of it
536 // to clean up generated code.
537 if ( InitTweak::isInstrinsicSingleArgCallStmt( ctorInit->get_ctor() ) ) {
538 delete ctorInit->get_ctor();
539 ctorInit->set_ctor( NULL );
540 }
541 if ( InitTweak::isInstrinsicSingleArgCallStmt( ctorInit->get_ctor() ) ) {
542 delete ctorInit->get_dtor();
543 ctorInit->set_dtor( NULL );
544 }
545 }
546
547 void Resolver::visit( ImplicitCtorDtorStmt * impCtorDtorStmt ) {
548 // before resolving ctor/dtor, need to remove type qualifiers from the first argument (the object being constructed).
549 // Do this through a cast expression to greatly simplify the code.
550 Expression * callExpr = InitTweak::getCtorDtorCall( impCtorDtorStmt );
551 assert( callExpr );
552 Expression *& constructee = InitTweak::getCallArg( callExpr, 0 );
553
554 // the first argument will always be &<expr>
555 AddressExpr * addrExpr = dynamic_cast< AddressExpr * > ( constructee );
556 assert( addrExpr );
557
558 // need to find the type of the first argument. In the case of an array,
559 // need to remove one ArrayType layer from the type for each subscript expression.
560 Expression * addressee = addrExpr->get_arg();
561 int numLayers = 0;
562 while ( UntypedExpr * untypedExpr = dynamic_cast< UntypedExpr * >( addressee ) ) {
563 assert( InitTweak::getFunctionName( untypedExpr ) == "?[?]" );
564 addressee = InitTweak::getCallArg( untypedExpr, 0 );
565 numLayers++;
566 }
567 assert( addressee->get_results().size() == 1 );
568 Type * type = addressee->get_results().front();
569 for ( int i = 0; i < numLayers; i++ ) {
570 type = InitTweak::getPointerBase( type );
571 assert( type && "Expected pointer or array type. May have generated too many ?[?] calls." );
572 }
573
574 // cast to T* with qualifiers removed.
575 // unfortunately, lvalue is considered a qualifier. For AddressExpr to resolve, its argument
576 // must have an lvalue qualified type, so remove all qualifiers except lvalue. If we ever
577 // remove lvalue as a qualifier, this can change to
578 // type->get_qualifiers() = Type::Qualifiers();
579 assert( type );
580 type = type->clone();
581 type->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true, true);
582 type = new PointerType( Type::Qualifiers(), type );
583 constructee = new CastExpr( constructee, type );
584
585 // finally, resolve the ctor/dtor
586 impCtorDtorStmt->get_callStmt()->accept( *this );
587 }
588} // namespace ResolvExpr
589
590// Local Variables: //
591// tab-width: 4 //
592// mode: c++ //
593// compile-command: "make install" //
594// End: //
Note: See TracBrowser for help on using the repository browser.