source: src/Parser/ExpressionNode.cc @ da9d79b

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumwith_gc
Last change on this file since da9d79b was 9a705dc8, checked in by Rob Schluntz <rschlunt@…>, 6 years ago

Implement concurrency keyword casts

  • Property mode set to 100644
File size: 20.7 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// ExpressionNode.cc --
8//
9// Author           : Peter A. Buhr
10// Created On       : Sat May 16 13:17:07 2015
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Thu Mar 22 11:57:39 2018
13// Update Count     : 801
14//
15
16#include <cassert>                 // for assert
17#include <stdio.h>                 // for sscanf, size_t
18#include <climits>                 // for LLONG_MAX, LONG_MAX, INT_MAX, UINT...
19#include <list>                    // for list
20#include <sstream>                 // for basic_istream::operator>>, basic_i...
21#include <string>                  // for string, operator+, operator==
22
23#include "Common/SemanticError.h"  // for SemanticError
24#include "Common/utility.h"        // for maybeMoveBuild, maybeBuild, CodeLo...
25#include "ParseNode.h"             // for ExpressionNode, maybeMoveBuildType
26#include "SynTree/Constant.h"      // for Constant
27#include "SynTree/Declaration.h"   // for EnumDecl, StructDecl, UnionDecl
28#include "SynTree/Expression.h"    // for Expression, ConstantExpr, NameExpr
29#include "SynTree/Statement.h"     // for CompoundStmt, Statement
30#include "SynTree/Type.h"          // for BasicType, Type, Type::Qualifiers
31#include "parserutility.h"         // for notZeroExpr
32
33class Initializer;
34
35using namespace std;
36
37//##############################################################################
38
39// Difficult to separate extra parts of constants during lexing because actions are not allow in the middle of patterns:
40//
41//              prefix action constant action suffix
42//
43// Alternatively, breaking a pattern using BEGIN does not work if the following pattern can be empty:
44//
45//              constant BEGIN CONT ...
46//              <CONT>(...)? BEGIN 0 ... // possible empty suffix
47//
48// because the CONT rule is NOT triggered if the pattern is empty. Hence, constants are reparsed here to determine their
49// type.
50
51extern const Type::Qualifiers noQualifiers;                             // no qualifiers on constants
52
53static inline bool checkH( char c ) { return c == 'h' || c == 'H'; }
54static inline bool checkL( char c ) { return c == 'l' || c == 'L'; }
55static inline bool checkZ( char c ) { return c == 'z' || c == 'Z'; }
56static inline bool checkU( char c ) { return c == 'u' || c == 'U'; }
57static inline bool checkF( char c ) { return c == 'f' || c == 'F'; }
58static inline bool checkD( char c ) { return c == 'd' || c == 'D'; }
59static inline bool checkI( char c ) { return c == 'i' || c == 'I'; }
60static inline bool checkB( char c ) { return c == 'b' || c == 'B'; }
61static inline bool checkX( char c ) { return c == 'x' || c == 'X'; }
62
63static const char * lnthsInt[2][6] = {
64        { "int8_t", "int16_t", "int32_t", "int64_t", "size_t", },
65        { "uint8_t", "uint16_t", "uint32_t", "uint64_t", "size_t", }
66}; // lnthsInt
67
68static inline void checkLNInt( string & str, int & lnth, int & size ) {
69        string::size_type posn = str.find_first_of( "lL" ), start = posn;
70  if ( posn == string::npos ) return;
71        size = 4;                                                                                       // assume largest size
72        posn += 1;                                                                                      // advance to size
73        if ( str[posn] == '8' ) {                                                       // 8
74                lnth = 0;
75        } else if ( str[posn] == '1' ) {
76                posn += 1;
77                if ( str[posn] == '6' ) {                                               // 16
78                        lnth = 1;
79                } else {                                                                                // 128
80                        posn += 1;
81                        lnth = 5;
82                } // if
83        } else {
84                if ( str[posn] == '3' ) {                                               // 32
85                        lnth = 2;
86                } else if ( str[posn] == '6' ) {                                // 64
87                        lnth = 3;
88                } else {
89                        assertf( false, "internal error, bad integral length %s", str.c_str() );
90                } // if
91                posn += 1;
92        } // if
93        str.erase( start, posn - start + 1 );                           // remove length suffix
94} // checkLNInt
95
96Expression * build_constantInteger( string & str ) {
97        static const BasicType::Kind kind[2][6] = {
98                // short (h) must be before char (hh)
99                { BasicType::ShortSignedInt, BasicType::SignedChar, BasicType::SignedInt, BasicType::LongSignedInt, BasicType::LongLongSignedInt, BasicType::SignedInt128, },
100                { BasicType::ShortUnsignedInt, BasicType::UnsignedChar, BasicType::UnsignedInt, BasicType::LongUnsignedInt, BasicType::LongLongUnsignedInt, BasicType::UnsignedInt128, },
101        };
102
103        bool dec = true, Unsigned = false;                                      // decimal, unsigned constant
104        int size;                                                                                       // 0 => short, 1 => char, 2 => int, 3 => long int, 4 => long long int, 5 => int128
105        int lnth = -1;                                                                          // literal length
106
107        unsigned long long int v;                                                       // converted integral value
108        size_t last = str.length() - 1;                                         // last subscript of constant
109        Expression * ret;
110
111        // special constants
112        if ( str == "0" ) {
113                ret = new ConstantExpr( Constant( (Type *)new ZeroType( noQualifiers ), str, (unsigned long long int)0 ) );
114                goto CLEANUP;
115        } // if
116        if ( str == "1" ) {
117                ret = new ConstantExpr( Constant( (Type *)new OneType( noQualifiers ), str, (unsigned long long int)1 ) );
118                goto CLEANUP;
119        } // if
120
121        // Cannot be "0"
122
123        if ( str[0] == '0' ) {                                                          // radix character ?
124                dec = false;
125                if ( checkX( str[1] ) ) {                                               // hex constant ?
126                        sscanf( (char *)str.c_str(), "%llx", &v );
127                        //printf( "%llx %llu\n", v, v );
128                } else if ( checkB( str[1] ) ) {                                // binary constant ?
129                        v = 0;
130                        for ( unsigned int i = 2;; i += 1 ) {           // compute value
131                                if ( str[i] == '1' ) v |= 1;
132                          if ( i == last ) break;
133                                v <<= 1;
134                        } // for
135                        //printf( "%llx %llu\n", v, v );
136                } else {                                                                                // octal constant
137                        sscanf( (char *)str.c_str(), "%llo", &v );
138                        //printf( "%llo %llu\n", v, v );
139                } // if
140        } else {                                                                                        // decimal constant ?
141                sscanf( (char *)str.c_str(), "%llu", &v );
142                //printf( "%llu %llu\n", v, v );
143        } // if
144
145        if ( v <= INT_MAX ) {                                                           // signed int
146                size = 2;
147        } else if ( v <= UINT_MAX && ! dec ) {                          // unsigned int
148                size = 2;
149                Unsigned = true;                                                                // unsigned
150        } else if ( v <= LONG_MAX ) {                                           // signed long int
151                size = 3;
152        } else if ( v <= ULONG_MAX && ( ! dec || LONG_MAX == LLONG_MAX ) ) { // signed long int
153                size = 3;
154                Unsigned = true;                                                                // unsigned long int
155        } else if ( v <= LLONG_MAX ) {                                          // signed long long int
156                size = 4;
157        } else {                                                                                        // unsigned long long int
158                size = 4;
159                Unsigned = true;                                                                // unsigned long long int
160        } // if
161
162        // At least one digit in integer constant, so safe to backup while looking for suffix.
163
164        if ( checkU( str[last] ) ) {                                            // suffix 'u' ?
165                Unsigned = true;
166                if ( checkL( str[last - 1] ) ) {                                // suffix 'l' ?
167                        size = 3;
168                        if ( checkL( str[last - 2] ) ) {                        // suffix "ll" ?
169                                size = 4;
170                        } // if
171                } else if ( checkH( str[last - 1] ) ) {                 // suffix 'h' ?
172                        size = 0;
173                        if ( checkH( str[last - 2] ) ) {                        // suffix "hh" ?
174                                size = 1;
175                        } // if
176                        str.erase( last - size - 1, size + 1 );         // remove 'h'/"hh"
177                } else {                                                                                // suffix "ln" ?
178                        checkLNInt( str, lnth, size );
179                } // if
180        } else if ( checkL( str[ last ] ) ) {                           // suffix 'l' ?
181                size = 3;
182                if ( checkL( str[last - 1] ) ) {                                // suffix 'll' ?
183                        size = 4;
184                        if ( checkU( str[last - 2] ) ) {                        // suffix 'u' ?
185                                Unsigned = true;
186                        } // if
187                } else if ( checkU( str[last - 1] ) ) {                 // suffix 'u' ?
188                        Unsigned = true;
189                } // if
190        } else if ( checkH( str[ last ] ) ) {                           // suffix 'h' ?
191                size = 0;
192                if ( checkH( str[last - 1] ) ) {                                // suffix "hh" ?
193                        size = 1;
194                        if ( checkU( str[last - 2] ) ) {                        // suffix 'u' ?
195                                Unsigned = true;
196                        } // if
197                } else if ( checkU( str[last - 1] ) ) {                 // suffix 'u' ?
198                        Unsigned = true;
199                } // if
200                str.erase( last - size, size + 1 );                             // remove 'h'/"hh"
201        } else if ( checkZ( str[last] ) ) {                                     // suffix 'z' ?
202                lnth = 4;
203                str.erase( last, 1 );                                                   // remove 'z'
204        } else {                                                                                        // suffix "ln" ?
205                checkLNInt( str, lnth, size );
206        } // if
207
208        assert( 0 <= size && size < 6 );
209        // Constant type is correct for overload resolving.
210        ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[Unsigned][size] ), str, v ) );
211        if ( Unsigned && size < 2 ) {                                           // hh or h, less than int ?
212                // int i = -1uh => 65535 not -1, so cast is necessary for unsigned, which unfortunately eliminates warnings for large values.
213                ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][size] ), false );
214        } else if ( lnth != -1 ) {                                                      // explicit length ?
215                if ( lnth == 5 ) {                                                              // int128 ?
216                        size = 5;
217                        ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][size] ), false );
218                } else {
219                        ret = new CastExpr( ret, new TypeInstType( Type::Qualifiers(), lnthsInt[Unsigned][lnth], false ), false );
220                } // if
221        } // if
222  CLEANUP:
223
224        delete &str;                                                                            // created by lex
225        return ret;
226} // build_constantInteger
227
228
229static inline void checkLNFloat( string & str, int & lnth, int & size ) {
230        string::size_type posn = str.find_first_of( "lL" ), start = posn;
231  if ( posn == string::npos ) return;
232        size = 2;                                                                                       // assume largest size
233        lnth = 0;
234        posn += 1;                                                                                      // advance to size
235        if ( str[posn] == '3' ) {                                                       // 32
236                size = 0;
237        } else if ( str[posn] == '6' ) {                                        // 64
238                size = 1;
239        } else if ( str[posn] == '8' || str[posn] == '1' ) { // 80, 128
240                size = 2;
241                if ( str[posn] == '1' ) posn += 1;
242        } else {
243                assertf( false, "internal error, bad floating point length %s", str.c_str() );
244        } // if
245        posn += 1;
246        str.erase( start, posn - start + 1 );                           // remove length suffix
247} // checkLNFloat
248
249
250Expression * build_constantFloat( string & str ) {
251        static const BasicType::Kind kind[2][3] = {
252                { BasicType::Float, BasicType::Double, BasicType::LongDouble },
253                { BasicType::FloatComplex, BasicType::DoubleComplex, BasicType::LongDoubleComplex },
254        };
255
256        bool complx = false;                                                            // real, complex
257        int size = 1;                                                                           // 0 => float, 1 => double, 2 => long double
258        int lnth = -1;                                                                          // literal length
259        // floating-point constant has minimum of 2 characters: 1. or .1
260        size_t last = str.length() - 1;
261        double v;
262
263        sscanf( str.c_str(), "%lg", &v );
264
265        if ( checkI( str[last] ) ) {                                            // imaginary ?
266                complx = true;
267                last -= 1;                                                                              // backup one character
268        } // if
269
270        if ( checkF( str[last] ) ) {                                            // float ?
271                size = 0;
272        } else if ( checkD( str[last] ) ) {                                     // double ?
273                size = 1;
274        } else if ( checkL( str[last] ) ) {                                     // long double ?
275                size = 2;
276        } else {
277                size = 1;                                                                               // double (default)
278                checkLNFloat( str, lnth, size );
279        } // if
280        if ( ! complx && checkI( str[last - 1] ) ) {            // imaginary ?
281                complx = true;
282        } // if
283
284        assert( 0 <= size && size < 3 );
285        Expression * ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[complx][size] ), str, v ) );
286        if ( lnth != -1 ) {                                                                     // explicit length ?
287                ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[complx][size] ), false );
288        } // if
289
290        delete &str;                                                                            // created by lex
291        return ret;
292} // build_constantFloat
293
294static void sepString( string & str, string & units, char delimit ) {
295        string::size_type posn = str.find_last_of( delimit ) + 1;
296        if ( posn != str.length() ) {
297                units = "?" + str.substr( posn );                               // extract units
298                str.erase( posn );                                                              // remove units
299        } // if
300} // sepString
301
302Expression * build_constantChar( string & str ) {
303        string units;                                                                           // units
304        sepString( str, units, '\'' );                                          // separate constant from units
305
306        Expression * ret = new ConstantExpr( Constant( new BasicType( noQualifiers, BasicType::Char ), str, (unsigned long long int)(unsigned char)str[1] ) );
307        if ( units.length() != 0 ) {
308                ret = new UntypedExpr( new NameExpr( units ), { ret } );
309        } // if
310
311        delete &str;                                                                            // created by lex
312        return ret;
313} // build_constantChar
314
315Expression * build_constantStr( string & str ) {
316        string units;                                                                           // units
317        sepString( str, units, '"' );                                           // separate constant from units
318
319        Type * strtype;
320        switch ( str[0] ) {                                                                     // str has >= 2 characters, i.e, null string "" => safe to look at subscripts 0/1
321          case 'u':
322                if ( str[1] == '8' ) goto Default;                              // utf-8 characters => array of char
323                // lookup type of associated typedef
324                strtype = new TypeInstType( Type::Qualifiers( Type::Const ), "char16_t", false );
325                break;
326          case 'U':
327                strtype = new TypeInstType( Type::Qualifiers( Type::Const ), "char32_t", false );
328                break;
329          case 'L':
330                strtype = new TypeInstType( Type::Qualifiers( Type::Const ), "wchar_t", false );
331                break;
332          Default:                                                                                      // char default string type
333          default:
334                strtype = new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char );
335        } // switch
336        ArrayType * at = new ArrayType( noQualifiers, strtype,
337                                                                        new ConstantExpr( Constant::from_ulong( str.size() + 1 - 2 ) ), // +1 for '\0' and -2 for '"'
338                                                                        false, false );
339        Expression * ret = new ConstantExpr( Constant( at, str, (unsigned long long int)0 ) ); // constant 0 is ignored for pure string value
340        if ( units.length() != 0 ) {
341                ret = new UntypedExpr( new NameExpr( units ), { ret } );
342        } // if
343
344        delete &str;                                                                            // created by lex
345        return ret;
346} // build_constantStr
347
348Expression * build_field_name_FLOATING_FRACTIONconstant( const string & str ) {
349        if ( str.find_first_not_of( "0123456789", 1 ) != string::npos ) SemanticError( yylloc, "invalid tuple index " + str );
350        Expression * ret = build_constantInteger( *new string( str.substr(1) ) );
351        delete &str;
352        return ret;
353} // build_field_name_FLOATING_FRACTIONconstant
354
355Expression * build_field_name_FLOATING_DECIMALconstant( const string & str ) {
356        if ( str[str.size()-1] != '.' ) SemanticError( yylloc, "invalid tuple index " + str );
357        Expression * ret = build_constantInteger( *new string( str.substr( 0, str.size()-1 ) ) );
358        delete &str;
359        return ret;
360} // build_field_name_FLOATING_DECIMALconstant
361
362Expression * build_field_name_FLOATINGconstant( const string & str ) {
363        // str is of the form A.B -> separate at the . and return member expression
364        int a, b;
365        char dot;
366        stringstream ss( str );
367        ss >> a >> dot >> b;
368        UntypedMemberExpr * ret = new UntypedMemberExpr( new ConstantExpr( Constant::from_int( b ) ), new ConstantExpr( Constant::from_int( a ) ) );
369        delete &str;
370        return ret;
371} // build_field_name_FLOATINGconstant
372
373Expression * make_field_name_fraction_constants( Expression * fieldName, Expression * fracts ) {
374        if ( fracts ) {
375                if ( UntypedMemberExpr * memberExpr = dynamic_cast< UntypedMemberExpr * >( fracts ) ) {
376                        memberExpr->set_member( make_field_name_fraction_constants( fieldName, memberExpr->get_aggregate() ) );
377                        return memberExpr;
378                } else {
379                        return new UntypedMemberExpr( fracts, fieldName );
380                } // if
381        } // if
382        return fieldName;
383} // make_field_name_fraction_constants
384
385Expression * build_field_name_fraction_constants( Expression * fieldName, ExpressionNode * fracts ) {
386        return make_field_name_fraction_constants( fieldName, maybeMoveBuild< Expression >( fracts ) );
387} // build_field_name_fraction_constants
388
389NameExpr * build_varref( const string * name ) {
390        NameExpr * expr = new NameExpr( *name );
391        delete name;
392        return expr;
393} // build_varref
394
395// TODO: get rid of this and OperKinds and reuse code from OperatorTable
396static const char * OperName[] = {                                              // must harmonize with OperKinds
397        // diadic
398        "SizeOf", "AlignOf", "OffsetOf", "?+?", "?-?", "?\\?", "?*?", "?/?", "?%?", "||", "&&",
399        "?|?", "?&?", "?^?", "Cast", "?<<?", "?>>?", "?<?", "?>?", "?<=?", "?>=?", "?==?", "?!=?",
400        "?=?", "?@=?", "?\\=?", "?*=?", "?/=?", "?%=?", "?+=?", "?-=?", "?<<=?", "?>>=?", "?&=?", "?^=?", "?|=?",
401        "?[?]", "...",
402        // monadic
403        "+?", "-?", "AddressOf", "*?", "!?", "~?", "++?", "?++", "--?", "?--",
404}; // OperName
405
406Expression * build_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ) {
407        Type * targetType = maybeMoveBuildType( decl_node );
408        if ( dynamic_cast< VoidType * >( targetType ) ) {
409                delete targetType;
410                return new CastExpr( maybeMoveBuild< Expression >(expr_node), false );
411        } else {
412                return new CastExpr( maybeMoveBuild< Expression >(expr_node), targetType, false );
413        } // if
414} // build_cast
415
416Expression * build_keyword_cast( KeywordCastExpr::Target target, ExpressionNode * expr_node ) {
417        return new KeywordCastExpr( maybeMoveBuild< Expression >(expr_node), target );
418}
419
420Expression * build_virtual_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ) {
421        return new VirtualCastExpr( maybeMoveBuild< Expression >( expr_node ), maybeMoveBuildType( decl_node ) );
422} // build_virtual_cast
423
424Expression * build_fieldSel( ExpressionNode * expr_node, Expression * member ) {
425        return new UntypedMemberExpr( member, maybeMoveBuild< Expression >(expr_node) );
426} // build_fieldSel
427
428Expression * build_pfieldSel( ExpressionNode * expr_node, Expression * member ) {
429        UntypedExpr * deref = new UntypedExpr( new NameExpr( "*?" ) );
430        deref->location = expr_node->location;
431        deref->get_args().push_back( maybeMoveBuild< Expression >(expr_node) );
432        UntypedMemberExpr * ret = new UntypedMemberExpr( member, deref );
433        return ret;
434} // build_pfieldSel
435
436Expression * build_offsetOf( DeclarationNode * decl_node, NameExpr * member ) {
437        Expression * ret = new UntypedOffsetofExpr( maybeMoveBuildType( decl_node ), member->get_name() );
438        delete member;
439        return ret;
440} // build_offsetOf
441
442Expression * build_and_or( ExpressionNode * expr_node1, ExpressionNode * expr_node2, bool kind ) {
443        return new LogicalExpr( notZeroExpr( maybeMoveBuild< Expression >(expr_node1) ), notZeroExpr( maybeMoveBuild< Expression >(expr_node2) ), kind );
444} // build_and_or
445
446Expression * build_unary_val( OperKinds op, ExpressionNode * expr_node ) {
447        list< Expression * > args;
448        args.push_back( maybeMoveBuild< Expression >(expr_node) );
449        return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args );
450} // build_unary_val
451
452Expression * build_unary_ptr( OperKinds op, ExpressionNode * expr_node ) {
453        list< Expression * > args;
454        args.push_back(  maybeMoveBuild< Expression >(expr_node) ); // xxx -- this is exactly the same as the val case now, refactor this code.
455        return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args );
456} // build_unary_ptr
457
458Expression * build_binary_val( OperKinds op, ExpressionNode * expr_node1, ExpressionNode * expr_node2 ) {
459        list< Expression * > args;
460        args.push_back( maybeMoveBuild< Expression >(expr_node1) );
461        args.push_back( maybeMoveBuild< Expression >(expr_node2) );
462        return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args );
463} // build_binary_val
464
465Expression * build_binary_ptr( OperKinds op, ExpressionNode * expr_node1, ExpressionNode * expr_node2 ) {
466        list< Expression * > args;
467        args.push_back( maybeMoveBuild< Expression >(expr_node1) );
468        args.push_back( maybeMoveBuild< Expression >(expr_node2) );
469        return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args );
470} // build_binary_ptr
471
472Expression * build_cond( ExpressionNode * expr_node1, ExpressionNode * expr_node2, ExpressionNode * expr_node3 ) {
473        return new ConditionalExpr( notZeroExpr( maybeMoveBuild< Expression >(expr_node1) ), maybeMoveBuild< Expression >(expr_node2), maybeMoveBuild< Expression >(expr_node3) );
474} // build_cond
475
476Expression * build_tuple( ExpressionNode * expr_node ) {
477        list< Expression * > exprs;
478        buildMoveList( expr_node, exprs );
479        return new UntypedTupleExpr( exprs );;
480} // build_tuple
481
482Expression * build_func( ExpressionNode * function, ExpressionNode * expr_node ) {
483        list< Expression * > args;
484        buildMoveList( expr_node, args );
485        return new UntypedExpr( maybeMoveBuild< Expression >(function), args );
486} // build_func
487
488Expression * build_compoundLiteral( DeclarationNode * decl_node, InitializerNode * kids ) {
489        Declaration * newDecl = maybeBuild< Declaration >(decl_node); // compound literal type
490        if ( DeclarationWithType * newDeclWithType = dynamic_cast< DeclarationWithType * >( newDecl ) ) { // non-sue compound-literal type
491                return new CompoundLiteralExpr( newDeclWithType->get_type(), maybeMoveBuild< Initializer >(kids) );
492        // these types do not have associated type information
493        } else if ( StructDecl * newDeclStructDecl = dynamic_cast< StructDecl * >( newDecl )  ) {
494                if ( newDeclStructDecl->has_body() ) {
495                        return new CompoundLiteralExpr( new StructInstType( Type::Qualifiers(), newDeclStructDecl ), maybeMoveBuild< Initializer >(kids) );
496                } else {
497                        return new CompoundLiteralExpr( new StructInstType( Type::Qualifiers(), newDeclStructDecl->get_name() ), maybeMoveBuild< Initializer >(kids) );
498                } // if
499        } else if ( UnionDecl * newDeclUnionDecl = dynamic_cast< UnionDecl * >( newDecl )  ) {
500                if ( newDeclUnionDecl->has_body() ) {
501                        return new CompoundLiteralExpr( new UnionInstType( Type::Qualifiers(), newDeclUnionDecl ), maybeMoveBuild< Initializer >(kids) );
502                } else {
503                        return new CompoundLiteralExpr( new UnionInstType( Type::Qualifiers(), newDeclUnionDecl->get_name() ), maybeMoveBuild< Initializer >(kids) );
504                } // if
505        } else if ( EnumDecl * newDeclEnumDecl = dynamic_cast< EnumDecl * >( newDecl )  ) {
506                if ( newDeclEnumDecl->has_body() ) {
507                        return new CompoundLiteralExpr( new EnumInstType( Type::Qualifiers(), newDeclEnumDecl ), maybeMoveBuild< Initializer >(kids) );
508                } else {
509                        return new CompoundLiteralExpr( new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() ), maybeMoveBuild< Initializer >(kids) );
510                } // if
511        } else {
512                assert( false );
513        } // if
514} // build_compoundLiteral
515
516// Local Variables: //
517// tab-width: 4 //
518// mode: c++ //
519// compile-command: "make install" //
520// End: //
Note: See TracBrowser for help on using the repository browser.