]> git.pld-linux.org Git - packages/cilk.git/blame - cilk-update.patch
- pl desc
[packages/cilk.git] / cilk-update.patch
CommitLineData
03b097f7 1diff -Nur 5.4.2.2/Makefile.am current.Bug188/Makefile.am
2--- 5.4.2.2/Makefile.am 2004-10-23 03:26:49.000000000 +0000
3+++ current.Bug188/Makefile.am 2005-09-27 03:59:00.000000000 +0000
4@@ -1,3 +1,4 @@
5+ACLOCAL_AMFLAGS = -I m4dir
6 SUBDIRS = cilk2c runtime support examples doc FAQ
7 EXTRA_DIST = THANKS bootstrap.sh
8
9diff -Nur 5.4.2.2/Makefile.in current.Bug188/Makefile.in
10--- 5.4.2.2/Makefile.in 2004-10-23 03:26:12.000000000 +0000
11+++ current.Bug188/Makefile.in 2005-10-05 16:47:46.000000000 +0000
12@@ -104,6 +104,7 @@
13 am__include = @am__include@
14 am__quote = @am__quote@
15 install_sh = @install_sh@
16+ACLOCAL_AMFLAGS = -I m4dir
17 SUBDIRS = cilk2c runtime support examples doc FAQ
18 EXTRA_DIST = THANKS bootstrap.sh
19
20@@ -144,7 +145,7 @@
21 $(srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(srcdir)/configure.ac $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
22 cd $(srcdir) && $(AUTOCONF)
23
24-$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ configure.ac acinclude.m4
25+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ configure.ac acinclude.m4 m4dir/acx_pthread.m4
26 cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
27
28 config.h: stamp-h1
29diff -Nur 5.4.2.2/SVN_VERSION current.Bug188/SVN_VERSION
30--- 5.4.2.2/SVN_VERSION 2004-10-23 03:27:43.000000000 +0000
31+++ current.Bug188/SVN_VERSION 2005-10-25 01:30:04.000000000 +0000
32@@ -1 +1 @@
33-1708
34+2560
35diff -Nur 5.4.2.2/cilk2c/ANSI-C.y current.Bug188/cilk2c/ANSI-C.y
36--- 5.4.2.2/cilk2c/ANSI-C.y 2004-10-23 03:26:43.000000000 +0000
37+++ current.Bug188/cilk2c/ANSI-C.y 2005-10-25 01:28:54.000000000 +0000
38@@ -104,11 +104,9 @@
39 #include "stringParse.h"
40
41 FILE_IDENTITY(ident_ansi_c_y,
42- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/cilk2c/ANSI-C.y $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
43+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/cilk2c/ANSI-C.y $ $LastChangedBy: bradley $ $Rev: 2561 $ $Date$");
44
45-#ifndef YYDEBUG
46 int yydebug=0;
47-#endif
48
49 extern int yylex(void);
50 PRIVATE void WarnAboutPrecedence(OpType op, Node *node);
51@@ -191,7 +189,7 @@
52 ...
53
54 */
55-
56+/* %debug */
57
58 %union {
59 Node *n;
60@@ -318,10 +316,10 @@
61 %type <n> logical.AND.expression logical.OR.expression conditional.expression
62 %type <n> assignment.expression constant.expression expression.opt
63 %type <L> attributes.opt attributes attribute attribute.list
64-%type <n> attrib any.word asm.opt
65+%type <n> attrib any.word asm.opt asm
66
67 %type <n> initializer.opt initializer basic.initializer initializer.list bracketed.initializer.list
68-%type <n> bit.field.size.opt bit.field.size enumerator.value.opt
69+%type <n> bit.field.size enumerator.value.opt
70
71 %type <n> statement labeled.statement expression.statement
72 %type <n> selection.statement iteration.statement jump.statement
73@@ -334,7 +332,7 @@
74 %type <n> postfixing.abstract.declarator array.abstract.declarator
75 %type <n> postfix.abstract.declarator old.function.declarator
76 %type <n> struct.or.union.specifier struct.or.union elaborated.type.name
77-%type <n> sue.type.specifier sue.declaration.specifier enum.specifier
78+%type <n> sue.type.specifier sue.type.specifier.noatt sue.declaration.specifier enum.specifier
79
80 %type <n> parameter.declaration
81 %type <n> identifier.declarator parameter.typedef.declarator
82@@ -357,10 +355,10 @@
83 %type <n> identifier.or.typedef.name
84
85 %type <tq> type.qualifier type.qualifier.list declaration.qualifier.list
86-%type <tq> declaration.qualifier storage.class
87+%type <tq> declaration.qualifier storage.class storage.class.noatt
88 %type <tq> pointer.type.qualifier pointer.type.qualifier.list
89
90-%type <n> basic.type.name
91+%type <n> basic.type.name basic.type.name.noatt
92
93 /* GCC extensions */
94 %token <tok> ASM
95@@ -728,12 +726,16 @@
96 * These rules were just moved from the function.definition: rule. -KHR
97 */
98 | declaration.specifier identifier.declarator
99- { $2 = DefineProc(FALSE, SetDeclType($2, $1, Redecl)); }
100+ {
101+ Node *decl = SetDeclType($2, $1, Redecl);
102+ $2 = DefineProc(FALSE, decl);
103+ }
104 compound.statement.no.new.scope
105 { $$ = MakeNewList(SetProcBody($2, $4)); }
106 | type.specifier identifier.declarator
107 {
108- $2 = DefineProc(FALSE, SetDeclType($2, $1, Redecl));
109+ Node *decl = SetDeclType($2, $1, Redecl);
110+ $2 = DefineProc(FALSE, decl);
111 $2->pragmas_before = GrabPragmas(0);
112 }
113 compound.statement.no.new.scope
114@@ -751,19 +753,49 @@
115 {
116 SetDeclType($2, $1, Redecl);
117 }
118- asm.opt { SetDeclAsm($2, $4); }
119- attributes.opt { AppendDeclAttribs($2, $6); }
120+ asm { SetDeclAsm($2, $4); }
121+ attributes.opt { SetDeclAttribs($2, $6); }
122 initializer.opt
123 {
124 $$ = MakeNewList(SetDeclInit($2, $8));
125 }
126+ | declaration.specifier
127+ declarator
128+ {
129+ SetDeclType($2, $1, Redecl);
130+ }
131+ attributes.opt
132+ {
133+ SetDeclAttribs($2, $4);
134+ }
135+ initializer.opt
136+ {
137+ //SetDeclAttribs($2, $4);
138+ $$ = MakeNewList(SetDeclInit($2, $6));
139+ }
140+ | type.specifier
141+ declarator
142+ {
143+ //printf("%s:%d ", __FILE__, __LINE__); DPN($2);
144+ SetDeclType($2, $1, Redecl);
145+ //printf("%s:%d ", __FILE__, __LINE__); DPN($2);
146+ }
147+ attributes.opt
148+ initializer.opt
149+ {
150+ //printf("%s:%d ", __FILE__, __LINE__); DPN($2);
151+ SetDeclAttribs($2, $4);
152+ //printf("%s:%d ", __FILE__, __LINE__); DPN($2);
153+ $$ = MakeNewList(SetDeclInit($2, $5));
154+ //printf("%s:%d ", __FILE__, __LINE__); DPL($$);
155+ }
156 | type.specifier
157 declarator
158 {
159 SetDeclType($2, $1, Redecl);
160 }
161- asm.opt { SetDeclAsm($2, $4); }
162- attributes.opt { AppendDeclAttribs($2, $6); }
163+ asm { SetDeclAsm($2, $4); }
164+ attributes.opt { SetDeclAttribs($2, $6); }
165 initializer.opt
166 {
167 $$ = MakeNewList(SetDeclInit($2, $8));
168@@ -773,10 +805,14 @@
169 $$ = AppendDecl($1, $3, Redecl);
170 }
171 asm.opt { SetDeclAsm($3, $5); }
172- attributes.opt { AppendDeclAttribs($3, $7); }
173+ attributes.opt { SetDeclAttribs($3, $7); }
174 initializer.opt
175 {
176 SetDeclInit($3, $9);
177+ if (yydebug) {
178+ printf("%s:%d ", __FILE__, __LINE__); DPL($7);
179+ printf("%s:%d ", __FILE__, __LINE__); DPN($3);
180+ }
181 }
182
183 /******** ERROR PRODUCTIONS ********/
184@@ -813,7 +849,9 @@
185 {
186 SetDeclType($2, MakeDefaultPrimType($1.tq, $1.coord), NoRedecl);
187 }
188- attributes.opt { SetDeclAttribs($2, $4); }
189+ attributes.opt {
190+ SetDeclAttribs($2, $4);
191+ }
192 initializer.opt
193 {
194 $$ = MakeNewList(SetDeclInit($2, $6));
195@@ -822,7 +860,9 @@
196 {
197 SetDeclType($2, MakeDefaultPrimType($1.tq, $1.coord), NoRedecl);
198 }
199- attributes.opt { SetDeclAttribs($2, $4); }
200+ attributes.opt {
201+ SetDeclAttribs($2, $4);
202+ }
203 initializer.opt
204 {
205 $$ = MakeNewList(SetDeclInit($2, $6));
206@@ -889,8 +929,8 @@
207 sue.declaration.specifier: /*P*/
208 sue.type.specifier storage.class
209 { $$ = TypeQualifyNode($1, $2.tq, & $2.coord); }
210- | declaration.qualifier.list elaborated.type.name
211- { $$ = TypeQualifyNode($2, $1.tq, & $1.coord); }
212+ | declaration.qualifier.list elaborated.type.name attributes.opt
213+ { $$ = TypeQualifyNode($2, tq_union($1.tq, tq_attribute($3)), & $1.coord); }
214 | sue.declaration.specifier declaration.qualifier
215 { $$ = TypeQualifyNode($1, $2.tq, & $2.coord); }
216 ;
217@@ -900,8 +940,11 @@
218 typedef.declaration.specifier: /*P*/
219 typedef.type.specifier storage.class
220 { $$ = TypeQualifyNode($1, $2.tq, & $2.coord); }
221- | declaration.qualifier.list TYPEDEFname
222- { $$ = ConvertIdToTdef($2, $1.tq, GetTypedefType($2)); $$->coord = $1.coord; }
223+ | declaration.qualifier.list TYPEDEFname attributes.opt
224+ { $$ = ConvertIdToTdef($2, $1.tq, GetTypedefType($2));
225+ $$->coord = $1.coord;
226+ NodeUpdateTq2($$, tq_union, tq_attribute($3));
227+ }
228 | typedef.declaration.specifier declaration.qualifier
229 { $$ = TypeQualifyNode($1, $2.tq, & $2.coord); }
230 ;
231@@ -914,14 +957,21 @@
232 { $$.tq = MergeTypeQuals($1.tq, $2.tq, $2.coord);
233 $$.coord = $1.coord; }
234 | declaration.qualifier.list declaration.qualifier
235- { $$.tq = MergeTypeQuals($1.tq, $2.tq, $2.coord);
236- $$.coord = $1.coord; }
237+ {
238+ $$.tq = MergeTypeQuals($1.tq, $2.tq, $2.coord);
239+ $$.coord = $1.coord;
240+ }
241+/*
242+ | declaration.qualifier.list attribute
243+ { $$.tq = tq_union($1.tq, tq_attribute($2));
244+ $$.coord = $1.coord; }
245+*/
246 ;
247
248 /* */ /* ? */ /* ?.?.? */
249 declaration.qualifier: /*P*/
250 type.qualifier
251- | storage.class
252+ | storage.class
253 ;
254
255 typeof.expression:
256@@ -931,11 +981,19 @@
257
258 /* */ /* ? */ /* ?.?.? */
259 type.specifier: /*P*/
260- basic.type.specifier /* Arithmetic or void */
261- { $$ = FinishPrimType($1); }
262+ basic.type.specifier attributes.opt /* Arithmetic or void */
263+ { $$ = FinishPrimType($1);
264+ $$ = TypeQualifyNode($$, tq_attribute($2), NULL);
265+ }
266 | sue.type.specifier /* Struct/Union/Enum */
267- | typedef.type.specifier /* Typedef */
268- | typeof.type.specifier /* This is really a gcc extension */
269+ | typedef.type.specifier attributes.opt /* Typedef */
270+ {
271+ $$ = TypeQualifyNode($1, tq_attribute($2), NULL);
272+ }
273+ | typeof.type.specifier attributes.opt /* This is really a gcc extension */
274+ {
275+ $$ = TypeQualifyNode($1, tq_attribute($2), NULL);
276+ }
277 ;
278
279 typeof.type.specifier:
280@@ -948,7 +1006,7 @@
281 {
282 $$ = NodeCopy(NodeDataType(SemCheckNode($3)), Subtree); /* copy the node so we can remove type qualifiers without hurting the code */
283 SetCoords($$, $1, Subtree);
284- NodeRemoveTq($$, -1); /* Take off all the type qualifiers */
285+ NodeUpdateTq($$, tq_remove_everything); /* Take off all the type qualifiers */
286 }
287 | type.qualifier.list TYPEOF '(' typeof.expression ')' /* gcc extension */
288 /*
289@@ -959,7 +1017,7 @@
290 {
291 /* we have to copy the node because we don't want the type qualifiers to modify the original node. */
292 Node *thetype=SetCoords(NodeCopy(NodeDataType(SemCheckNode($4)), Subtree), $2, Subtree);
293- NodeRemoveTq(thetype, -1); /* Take off all the type qualifiers */
294+ NodeUpdateTq(thetype, tq_remove_everything); /* Take off all the type qualifiers */
295 $$ = TypeQualifyNode(thetype, $1.tq, & $1.coord); /* Add on the new type qualifiers */
296 }
297 ;
298@@ -976,7 +1034,11 @@
299 ;
300
301 /* */ /* ? */ /* ?.?.? */
302-sue.type.specifier: /*P*/
303+sue.type.specifier:
304+ sue.type.specifier.noatt attributes.opt
305+ { $$ = TypeQualifyNode($1, tq_attribute($2), 0); }
306+;
307+sue.type.specifier.noatt: /*P*/
308 elaborated.type.name /* struct/union/enum */
309 | type.qualifier.list elaborated.type.name
310 { $$ = TypeQualifyNode($2, $1.tq, & $1.coord); }
311@@ -997,7 +1059,9 @@
312
313 /* */ /* ? */ /* ?.?.? */
314 type.qualifier.list: /*P*/
315- type.qualifier
316+ type.qualifier attributes.opt
317+ { $$.tq = tq_union($1.tq, tq_attribute($2));
318+ $$.coord = $1.coord; }
319 | type.qualifier.list type.qualifier
320 { $$.tq = MergeTypeQuals($1.tq, $2.tq, $2.coord);
321 $$.coord = $1.coord; }
322@@ -1033,17 +1097,17 @@
323 /* Redundant '(' placed immediately to the left of the TYPEDEFname */
324 paren.typedef.declarator: /*P*/
325 paren.postfix.typedef.declarator
326- | '*' paren.typedef.declarator
327- { $$ = SetDeclType($2, MakePtrCoord(EMPTY_TQ, NULL, $1), Redecl);
328+ | '*' attributes.opt paren.typedef.declarator /* UNUSED attributes.opt */
329+ { $$ = SetDeclType($3, MakePtrCoord(EMPTY_TQ, NULL, $1), Redecl);
330 }
331- | '*' '(' simple.paren.typedef.declarator ')'
332- { $$ = SetDeclType($3, MakePtrCoord(EMPTY_TQ, NULL, $1), Redecl);
333+ | '*' attributes.opt '(' simple.paren.typedef.declarator ')' /* UNUSED attributes.opt */
334+ { $$ = SetDeclType($4, MakePtrCoord(EMPTY_TQ, NULL, $1), Redecl);
335 }
336- | '*' pointer.type.qualifier.list '(' simple.paren.typedef.declarator ')'
337- { $$ = SetDeclType($4, MakePtrCoord( $2.tq, NULL, $1), Redecl);
338+ | '*' attributes.opt pointer.type.qualifier.list '(' simple.paren.typedef.declarator ')' /* UNUSED attributes.opt */
339+ { $$ = SetDeclType($5, MakePtrCoord( $3.tq, NULL, $1), Redecl);
340 }
341- | '*' pointer.type.qualifier.list paren.typedef.declarator
342- { $$ = SetDeclType($3, MakePtrCoord( $2.tq, NULL, $1), Redecl);
343+ | '*' attributes.opt pointer.type.qualifier.list paren.typedef.declarator /* UNUSED attributes.opt */
344+ { $$ = SetDeclType($4, MakePtrCoord( $3.tq, NULL, $1), Redecl);
345 }
346 ;
347
348@@ -1086,11 +1150,11 @@
349 /* */ /* ? */ /* ?.?.? */
350 clean.typedef.declarator: /*P*/
351 clean.postfix.typedef.declarator
352- | '*' parameter.typedef.declarator
353- { $$ = SetDeclType($2, MakePtrCoord(EMPTY_TQ, NULL, $1), Redecl);
354+ | '*' attributes.opt parameter.typedef.declarator /* UNUSED attributes.opt */
355+ { $$ = SetDeclType($3, MakePtrCoord(EMPTY_TQ, NULL, $1), Redecl);
356 }
357- | '*' pointer.type.qualifier.list parameter.typedef.declarator
358- { $$ = SetDeclType($3, MakePtrCoord($2.tq, NULL, $1), Redecl);
359+ | '*' attributes.opt pointer.type.qualifier.list parameter.typedef.declarator /* UNUSED attributes.opt */
360+ { $$ = SetDeclType($4, MakePtrCoord($3.tq, NULL, $1), Redecl);
361 }
362 ;
363
364@@ -1113,15 +1177,15 @@
365
366 /* */ /* ? */ /* ?.?.? */
367 unary.abstract.declarator: /*P*/
368- '*'
369+ '*' attributes.opt /* UNUSED attributes.opt */
370 { $$ = MakePtrCoord(EMPTY_TQ, NULL, $1); }
371- | '*' pointer.type.qualifier.list
372- { $$ = MakePtrCoord($2.tq, NULL, $1); }
373- | '*' abstract.declarator
374- { $$ = SetBaseType($2, MakePtrCoord(EMPTY_TQ, NULL, $1));
375+ | '*' attributes.opt pointer.type.qualifier.list /* UNUSED attributes.opt */
376+ { $$ = MakePtrCoord($3.tq, NULL, $1); }
377+ | '*' attributes.opt abstract.declarator /* UNUSED attributes.opt */
378+ { $$ = SetBaseType($3, MakePtrCoord(EMPTY_TQ, NULL, $1));
379 }
380- | '*' pointer.type.qualifier.list abstract.declarator
381- { $$ = SetBaseType($3, MakePtrCoord($2.tq, NULL, $1));
382+ | '*' attributes.opt pointer.type.qualifier.list abstract.declarator /* UNUSED attributes.opt */
383+ { $$ = SetBaseType($4, MakePtrCoord($3.tq, NULL, $1));
384 }
385 ;
386
387@@ -1158,11 +1222,13 @@
388 /* */ /* ? */ /* ?.?.? */
389 unary.identifier.declarator: /*P293*/
390 postfix.identifier.declarator
391- | '*' identifier.declarator
392- { $$ = ModifyDeclType($2, MakePtrCoord(EMPTY_TQ, NULL, $1));
393- }
394- | '*' pointer.type.qualifier.list identifier.declarator
395- { $$ = ModifyDeclType($3, MakePtrCoord( $2.tq, NULL, $1));
396+ | '*' attributes.opt identifier.declarator
397+ { //printf("%s:%d ", __FILE__, __LINE__); DPL($2);
398+ SetDeclAttribs($3, $2);
399+ $$ = ModifyDeclType($3, MakePtrCoord(EMPTY_TQ, NULL, $1));
400+ }
401+ | '*' attributes.opt pointer.type.qualifier.list identifier.declarator
402+ { $$ = ModifyDeclType($4, MakePtrCoord(tq_union(tq_attribute($2), $3.tq), NULL, $1));
403 }
404 ;
405
406@@ -1200,11 +1266,11 @@
407 {
408 $$ = $1;
409 }
410- | '*' old.function.declarator
411- { $$ = SetDeclType($2, MakePtrCoord(EMPTY_TQ, NULL, $1), SU);
412+ | '*' attributes.opt old.function.declarator /* UNUSED attributes.opt */
413+ { $$ = SetDeclType($3, MakePtrCoord(EMPTY_TQ, NULL, $1), SU);
414 }
415- | '*' pointer.type.qualifier.list old.function.declarator
416- { $$ = SetDeclType($3, MakePtrCoord($2.tq, NULL, $1), SU);
417+ | '*' attributes.opt pointer.type.qualifier.list old.function.declarator /* UNUSED attributes.opt */
418+ { $$ = SetDeclType($4, MakePtrCoord($3.tq, NULL, $1), SU);
419 }
420 ;
421
422@@ -1306,7 +1372,9 @@
423 * aligned(8) (that is this last rule)
424 * packed (that is the first rule)
425 * section("shared") (that is this last rule)
426- * I think the other rules are needed for the format attributes. -Bradley
427+ * The problem is that the IDENTIFIER, if parsed as an expression, will
428+ * be parsed as an undeclared variable. (It could even be a type name
429+ * which will be parsed badly too.
430 */
431 | any.word '(' nonnull.expression.list ')'
432 { $$ = ConvertIdToAttrib($1, $3); }
433@@ -1321,9 +1389,12 @@
434 asm.opt:
435 /* empty */
436 { $$ = NULL; }
437- | ASM '(' string.literal.list ')'
438- { $$ = MakeAsmCoord(EMPTY_TQ, $3, NULL, NULL, NULL, $1); }
439+ | asm
440 ;
441+asm:
442+ ASM '(' string.literal.list ')'
443+ { $$ = MakeAsmCoord(EMPTY_TQ, $3, NULL, NULL, NULL, $1); }
444+;
445
446 any.word:
447 IDENTIFIER
448@@ -1407,42 +1478,41 @@
449
450 /* */ /* ? */ /* ?.?.? */
451 parameter.declaration: /*P*/
452- declaration.specifier
453- { $$ = $1; }
454- | declaration.specifier abstract.declarator
455- { $$ = SetBaseType($2, $1);
456+ attributes.opt declaration.specifier
457+ { $$ = $2; }
458+ | attributes.opt declaration.specifier abstract.declarator
459+ { $$ = SetBaseType($3, $2);
460 }
461- | declaration.specifier identifier.declarator
462- { $$ = SetDeclType($2, $1, Formal);
463+ | attributes.opt declaration.specifier identifier.declarator
464+ { $$ = SetDeclType($3, $2, Formal);
465 }
466- | declaration.specifier parameter.typedef.declarator
467- { $$ = SetDeclType($2, $1, Formal);
468+ | attributes.opt declaration.specifier parameter.typedef.declarator
469+ { $$ = SetDeclType($3, $2, Formal);
470 }
471- | declaration.qualifier.list /* DEFAULT_INT */
472- { $$ = MakeDefaultPrimType($1.tq, $1.coord); }
473- | declaration.qualifier.list /* DEFAULT_INT */ abstract.declarator
474- { $$ = SetBaseType($2, MakeDefaultPrimType($1.tq, $1.coord)); }
475- | declaration.qualifier.list /* DEFAULT_INT */ identifier.declarator
476- { $$ = SetDeclType($2, MakeDefaultPrimType($1.tq, $1.coord), Formal); }
477- | type.specifier
478- { $$ = $1; }
479- | type.specifier abstract.declarator
480- { $$ = SetBaseType($2, $1);
481+ | attributes.opt declaration.qualifier.list /* DEFAULT_INT */
482+ { $$ = MakeDefaultPrimType($2.tq, $2.coord); }
483+ | attributes.opt declaration.qualifier.list /* DEFAULT_INT */ abstract.declarator
484+ { $$ = SetBaseType($3, MakeDefaultPrimType($2.tq, $2.coord)); }
485+ | attributes.opt declaration.qualifier.list /* DEFAULT_INT */ identifier.declarator
486+ { $$ = SetDeclType($3, MakeDefaultPrimType($2.tq, $2.coord), Formal); }
487+ | attributes.opt type.specifier
488+ { $$ = $2; }
489+ | attributes.opt type.specifier abstract.declarator
490+ { $$ = SetBaseType($3, $2);
491 }
492- | type.specifier identifier.declarator attributes.opt
493+ | attributes.opt type.specifier identifier.declarator attributes.opt
494 {
495- SetDeclAttribs($2, $3);
496- $$ = SetDeclType($2, $1, Formal);
497- }
498- | type.specifier parameter.typedef.declarator
499- { $$ = SetDeclType($2, $1, Formal);
500+ $$ = SetDeclType($3, TypeQualifyNode($2, tq_attribute(JoinLists($1,$4)), NULL), Formal)
501+ }
502+ | attributes.opt type.specifier parameter.typedef.declarator
503+ { $$ = SetDeclType($3, $2, Formal);
504 }
505- | type.qualifier.list /* DEFAULT_INT */
506- { $$ = MakeDefaultPrimType($1.tq, $1.coord); }
507- | type.qualifier.list /* DEFAULT_INT */ abstract.declarator
508- { $$ = SetBaseType($2, MakeDefaultPrimType($1.tq, $1.coord)); }
509- | type.qualifier.list /* DEFAULT_INT */ identifier.declarator
510- { $$ = SetDeclType($2, MakeDefaultPrimType($1.tq, $1.coord), Formal); }
511+ | attributes.opt type.qualifier.list /* DEFAULT_INT */
512+ { $$ = MakeDefaultPrimType($2.tq, $2.coord); }
513+ | attributes.opt type.qualifier.list /* DEFAULT_INT */ abstract.declarator
514+ { $$ = SetBaseType($3, MakeDefaultPrimType($2.tq, $2.coord)); }
515+ | attributes.opt type.qualifier.list /* DEFAULT_INT */ identifier.declarator
516+ { $$ = SetDeclType($3, MakeDefaultPrimType(tq_union(tq_attribute($1),$2.tq), $2.coord), Formal); }
517 ;
518
519 /* */ /* ? */ /* ?.?.? */
520@@ -1475,31 +1545,31 @@
521
522 /* */ /* ? */ /* ?.?.? */
523 struct.or.union.specifier: /*P*/
524- struct.or.union '{' struct.declaration.list '}' attributes.opt
525+ struct.or.union '{' struct.declaration.list '}'
526 {
527- $$ = SetSUdclNameFields($1, NULL, $3, $2, $4, $5);
528+ $$ = SetSUdclNameFields($1, NULL, $3, $2, $4, NULL);
529 }
530 | struct.or.union identifier.or.typedef.name
531- '{' struct.declaration.list '}' attributes.opt
532+ '{' struct.declaration.list '}'
533 {
534- $$ = SetSUdclNameFields($1, $2, $4, $3, $5, $6);
535+ $$ = SetSUdclNameFields($1, $2, $4, $3, $5, NULL);
536 }
537 | struct.or.union identifier.or.typedef.name
538 {
539 $$ = SetSUdclName($1, $2, $1->coord);
540 }
541 /* EAB: create rules for empty structure declarations */
542- | struct.or.union '{' '}' attributes.opt
543+ | struct.or.union '{' '}'
544 {
545 if (ANSIOnly)
546 Warning(1, "empty structure declaration");
547- $$ = SetSUdclNameFields($1, NULL, NULL, $2, $3, $4);
548+ $$ = SetSUdclNameFields($1, NULL, NULL, $2, $3, NULL);
549 }
550- | struct.or.union identifier.or.typedef.name '{' '}' attributes.opt
551+ | struct.or.union identifier.or.typedef.name '{' '}'
552 {
553 if (ANSIOnly)
554 Warning(1, "empty structure declaration");
555- $$ = SetSUdclNameFields($1, $2, NULL, $3, $4, $5);
556+ $$ = SetSUdclNameFields($1, $2, NULL, $3, $4, NULL);
557 }
558 ;
559
560@@ -1520,7 +1590,7 @@
561 struct.declaration: /*P*/
562 struct.declaring.list ';'
563 | struct.default.declaring.list ';'
564- | gcc.extension struct.declaration { $$ = $2; NodeAddTq((Node*)(FirstItem($$)), T_EXTENSION); ((Node*)(FirstItem($$)))->coord = $1; }
565+ | gcc.extension struct.declaration { $$ = $2; NodeUpdateTq((Node*)(FirstItem($$)), tq_add_extension); ((Node*)(FirstItem($$)))->coord = $1; }
566 ;
567
568 /* doesn't redeclare typedef */
569@@ -1547,7 +1617,10 @@
570
571 /* */ /* ? */ /* ?.?.? */
572 struct.declarator: /*P*/
573- declarator bit.field.size.opt attributes.opt
574+ declarator attributes.opt
575+ { SetDeclAttribs($1,$2);
576+ $$ = $1; }
577+ | declarator bit.field.size attributes.opt
578 { SetDeclAttribs($1, $3);
579 $$ = SetDeclBitSize($1, $2); }
580 | bit.field.size attributes.opt
581@@ -1557,7 +1630,8 @@
582
583 /* */ /* ? */ /* ?.?.? */
584 struct.identifier.declarator: /*P*/
585- identifier.declarator bit.field.size.opt attributes.opt
586+ identifier.declarator
587+ | identifier.declarator bit.field.size attributes.opt
588 { $$ = SetDeclBitSize($1, $2);
589 SetDeclAttribs($1, $3); }
590 | bit.field.size attributes.opt
591@@ -1565,11 +1639,6 @@
592 SetDeclAttribs($$, $2); }
593 ;
594
595-/* */ /* ? */ /* ?.?.? */
596-bit.field.size.opt: /*P*/
597- /* nothing */ { $$ = NULL; }
598- | bit.field.size
599- ;
600
601 /* */ /* ? */ /* ?.?.? */
602 bit.field.size: /*P*/
603@@ -1834,7 +1903,7 @@
604 if (yydebug)
605 {
606 printf("external.definition # declaration\n");
607- PrintNode(stdout, FirstItem($1), 0);
608+ fPrintNode(stdout, FirstItem($1), 0);
609 printf("\n\n\n");
610 }
611 $$ = $1;
612@@ -1844,7 +1913,7 @@
613 if (yydebug)
614 {
615 printf("external.definition # function.definition\n");
616- PrintNode(stdout, $1, 0);
617+ fPrintNode(stdout, $1, 0);
618 printf("\n\n\n");
619 }
620 $$ = MakeNewList($1);
621@@ -1880,19 +1949,19 @@
622 */
623 | declaration.qualifier.list identifier.declarator
624 {
625- $2 = DefineProc(FALSE,
626- SetDeclType($2,
627- MakeDefaultPrimType($1.tq, $1.coord),
628- Redecl));
629+ Node *decl = SetDeclType($2,
630+ MakeDefaultPrimType($1.tq, $1.coord),
631+ Redecl);
632+ $2 = DefineProc(FALSE, decl);
633 }
634 compound.statement.no.new.scope
635 { $$ = SetProcBody($2, $4); }
636 | type.qualifier.list identifier.declarator
637 {
638- $2 = DefineProc(FALSE,
639- SetDeclType($2,
640- MakeDefaultPrimType($1.tq, $1.coord),
641- Redecl));
642+ Node *decl = SetDeclType($2,
643+ MakeDefaultPrimType($1.tq, $1.coord),
644+ Redecl);
645+ $2 = DefineProc(FALSE, decl);
646 }
647 compound.statement.no.new.scope
648 { $$ = SetProcBody($2, $4); }
649@@ -2033,39 +2102,55 @@
650 ;
651
652 type.qualifier: /*P*/
653- CONST { $$.tq = T_CONST; $$.coord = $1; }
654- | VOLATILE { $$.tq = T_VOLATILE; $$.coord = $1; }
655- | INLINE { $$.tq = T_INLINE; $$.coord = $1; } /* gcc extension */
656- | RESTRICT { $$.tq = T_RESTRICT; $$.coord = $1; } /* C9X extension */
657- | COMPLEX { $$.tq = T_COMPLEX; $$.coord = $1; } /* c9x extension */
658- | PROCEDURE { $$.tq = T_PROCEDURE;$$.coord = $1; } /* Cilk extension */
659- | INLET { $$.tq = T_INLET; $$.coord = $1; } /* Cilk extension */
660- | SHAREDVAR { $$.tq = T_SHARED; $$.coord = $1; } /* Cilk extension */
661- | PRIVATEVAR{ $$.tq = T_PRIVATE; $$.coord = $1; } /* Cilk extension */
662- | NOOUTPUT { $$.tq = T_NOOUTPUT; $$.coord = $1; } /* cilk2c extension */
663- | CILKONLY { $$.tq = T_CILKONLY; $$.coord = $1; } /* cilk2c extension */
664- | CILKSAFE { $$.tq = T_CILKSAFE; $$.coord = $1; } /* cilk2c extension */
665+ CONST { $$.tq = TQ_CONST; $$.coord = $1; }
666+ | VOLATILE { $$.tq = TQ_VOLATILE; $$.coord = $1; }
667+ | INLINE { $$.tq = TQ_INLINE; $$.coord = $1; } /* gcc extension */
668+ | RESTRICT { $$.tq = TQ_RESTRICT; $$.coord = $1; } /* C9X extension */
669+ | COMPLEX { $$.tq = TQ_COMPLEX; $$.coord = $1; } /* c9x extension */
670+ | PROCEDURE { $$.tq = TQ_PROCEDURE;$$.coord = $1; } /* Cilk extension */
671+ | INLET { $$.tq = TQ_INLET; $$.coord = $1; } /* Cilk extension */
672+ | SHAREDVAR { $$.tq = TQ_SHARED; $$.coord = $1; } /* Cilk extension */
673+ | PRIVATEVAR{ $$.tq = TQ_PRIVATE; $$.coord = $1; } /* Cilk extension */
674+ | NOOUTPUT { $$.tq = TQ_NOOUTPUT; $$.coord = $1; } /* cilk2c extension */
675+ | CILKONLY { $$.tq = TQ_CILKONLY; $$.coord = $1; } /* cilk2c extension */
676+ | CILKSAFE { $$.tq = TQ_CILKSAFE; $$.coord = $1; } /* cilk2c extension */
677 ;
678
679 pointer.type.qualifier: /*P*/
680- CONST { $$.tq = T_CONST; $$.coord = $1; }
681- | VOLATILE { $$.tq = T_VOLATILE; $$.coord = $1; }
682- | RESTRICT { $$.tq = T_RESTRICT; $$.coord = $1; } /* C9X extension */
683- | PROCEDURE { $$.tq = T_PROCEDURE;$$.coord = $1; } /* Cilk extension */
684- | INLET { $$.tq = T_INLET; $$.coord = $1; } /* Cilk extension */
685- | CILKONLY { $$.tq = T_CILKONLY; $$.coord = $1; } /* cilk2c extension */
686- | CILKSAFE { $$.tq = T_CILKSAFE; $$.coord = $1; } /* cilk2c extension */
687+ CONST { $$.tq = TQ_CONST; $$.coord = $1; }
688+ | VOLATILE { $$.tq = TQ_VOLATILE; $$.coord = $1; }
689+ | RESTRICT { $$.tq = TQ_RESTRICT; $$.coord = $1; } /* C9X extension */
690+ | PROCEDURE { $$.tq = TQ_PROCEDURE;$$.coord = $1; } /* Cilk extension */
691+ | INLET { $$.tq = TQ_INLET; $$.coord = $1; } /* Cilk extension */
692+ | CILKONLY { $$.tq = TQ_CILKONLY; $$.coord = $1; } /* cilk2c extension */
693+ | CILKSAFE { $$.tq = TQ_CILKSAFE; $$.coord = $1; } /* cilk2c extension */
694 ;
695
696 storage.class: /*P*/
697- TYPEDEF { $$.tq = T_TYPEDEF; $$.coord = $1; }
698- | EXTERN { $$.tq = T_EXTERN; $$.coord = $1; }
699- | STATIC { $$.tq = T_STATIC; $$.coord = $1; }
700- | AUTO { $$.tq = T_AUTO; $$.coord = $1; }
701- | REGISTER { $$.tq = T_REGISTER; $$.coord = $1; }
702+ storage.class.noatt attributes.opt
703+ {
704+ $$ = $1;
705+ $$.tq = tq_union($1.tq, tq_attribute($2));
706+ }
707+;
708+
709+storage.class.noatt:
710+ TYPEDEF { $$.tq = TQ_TYPEDEF; $$.coord = $1; }
711+ | EXTERN { $$.tq = TQ_EXTERN; $$.coord = $1; }
712+ | STATIC { $$.tq = TQ_STATIC; $$.coord = $1; }
713+ | AUTO { $$.tq = TQ_AUTO; $$.coord = $1; }
714+ | REGISTER { $$.tq = TQ_REGISTER; $$.coord = $1; }
715 ;
716
717 basic.type.name: /*P*/
718+ basic.type.name.noatt attributes.opt
719+ {
720+ $$ = $1;
721+ NodeUpdateTq2($$, tq_union, tq_attribute($2));
722+ }
723+;
724+
725+basic.type.name.noatt: /*P*/
726 VOID { $$ = StartPrimType(Void, $1); }
727 | CHAR { $$ = StartPrimType(Char, $1); }
728 | INT { $$ = StartPrimType(Int_ParseOnly, $1); }
729diff -Nur 5.4.2.2/cilk2c/Makefile.am current.Bug188/cilk2c/Makefile.am
730--- 5.4.2.2/cilk2c/Makefile.am 2004-10-23 03:26:46.000000000 +0000
731+++ current.Bug188/cilk2c/Makefile.am 2005-10-22 02:52:38.000000000 +0000
732@@ -9,11 +9,14 @@
733 simplify.c \
734 sideeffects.c \
735 sem-check.c strings.c \
736-sue.c symbol.c transform.c type.c type2.c verify-parse.c warning.c \
737+sue.c symbol.c transform.c type.c type2.c typequal.c verify-parse.c \
738+warning.c \
739+gbuf.h gbuf.c \
740 ast.h basics.h config.h conversions.h dataflow.h heap.h initializer.h \
741-list.h operators.h symbol.h type.h ANSI-C.c ANSI-C.h c4.l hint.c \
742+list.h operators.h symbol.h type.h typequal.h ANSI-C.c ANSI-C.h c4.l \
743+hint.c \
744 astModify.h astModify.c stringParse.h stringParse.c wildcard.h wildcard.c \
745-astEquals.h astEquals.c wildcardTable.h wildcardTable.c testEquals.h \
746+astEquals.h astEquals.c wildcardTable.h wildcardTable.c testEquals.h \
747 testEquals.c atmTransform.h atmTransform.c
748
749 YFLAGS = -d
750diff -Nur 5.4.2.2/cilk2c/Makefile.in current.Bug188/cilk2c/Makefile.in
751--- 5.4.2.2/cilk2c/Makefile.in 2004-10-23 03:26:19.000000000 +0000
752+++ current.Bug188/cilk2c/Makefile.in 2005-10-22 02:52:37.000000000 +0000
753@@ -115,11 +115,14 @@
754 simplify.c \
755 sideeffects.c \
756 sem-check.c strings.c \
757-sue.c symbol.c transform.c type.c type2.c verify-parse.c warning.c \
758+sue.c symbol.c transform.c type.c type2.c typequal.c verify-parse.c \
759+warning.c \
760+gbuf.h gbuf.c \
761 ast.h basics.h config.h conversions.h dataflow.h heap.h initializer.h \
762-list.h operators.h symbol.h type.h ANSI-C.c ANSI-C.h c4.l hint.c \
763+list.h operators.h symbol.h type.h typequal.h ANSI-C.c ANSI-C.h c4.l \
764+hint.c \
765 astModify.h astModify.c stringParse.h stringParse.c wildcard.h wildcard.c \
766-astEquals.h astEquals.c wildcardTable.h wildcardTable.c testEquals.h \
767+astEquals.h astEquals.c wildcardTable.h wildcardTable.c testEquals.h \
768 testEquals.c atmTransform.h atmTransform.c
769
770
771@@ -149,8 +152,9 @@
772 procedure.$(OBJEXT) profile.$(OBJEXT) simplify.$(OBJEXT) \
773 sideeffects.$(OBJEXT) sem-check.$(OBJEXT) strings.$(OBJEXT) \
774 sue.$(OBJEXT) symbol.$(OBJEXT) transform.$(OBJEXT) \
775- type.$(OBJEXT) type2.$(OBJEXT) verify-parse.$(OBJEXT) \
776- warning.$(OBJEXT) ANSI-C.$(OBJEXT) c4.$(OBJEXT) hint.$(OBJEXT) \
777+ type.$(OBJEXT) type2.$(OBJEXT) typequal.$(OBJEXT) \
778+ verify-parse.$(OBJEXT) warning.$(OBJEXT) gbuf.$(OBJEXT) \
779+ ANSI-C.$(OBJEXT) c4.$(OBJEXT) hint.$(OBJEXT) \
780 astModify.$(OBJEXT) stringParse.$(OBJEXT) wildcard.$(OBJEXT) \
781 astEquals.$(OBJEXT) wildcardTable.$(OBJEXT) \
782 testEquals.$(OBJEXT) atmTransform.$(OBJEXT)
783@@ -173,17 +177,18 @@
784 @AMDEP_TRUE@ ./$(DEPDIR)/complex-types.Po \
785 @AMDEP_TRUE@ ./$(DEPDIR)/constexpr.Po ./$(DEPDIR)/container.Po \
786 @AMDEP_TRUE@ ./$(DEPDIR)/conversions.Po ./$(DEPDIR)/dataflow.Po \
787-@AMDEP_TRUE@ ./$(DEPDIR)/elide.Po ./$(DEPDIR)/hint.Po \
788-@AMDEP_TRUE@ ./$(DEPDIR)/initializer.Po ./$(DEPDIR)/list.Po \
789-@AMDEP_TRUE@ ./$(DEPDIR)/main.Po ./$(DEPDIR)/operators.Po \
790-@AMDEP_TRUE@ ./$(DEPDIR)/output.Po ./$(DEPDIR)/print-ast.Po \
791-@AMDEP_TRUE@ ./$(DEPDIR)/procedure.Po ./$(DEPDIR)/profile.Po \
792-@AMDEP_TRUE@ ./$(DEPDIR)/sem-check.Po ./$(DEPDIR)/sideeffects.Po \
793-@AMDEP_TRUE@ ./$(DEPDIR)/simplify.Po ./$(DEPDIR)/stringParse.Po \
794-@AMDEP_TRUE@ ./$(DEPDIR)/strings.Po ./$(DEPDIR)/sue.Po \
795-@AMDEP_TRUE@ ./$(DEPDIR)/symbol.Po ./$(DEPDIR)/testEquals.Po \
796-@AMDEP_TRUE@ ./$(DEPDIR)/transform.Po ./$(DEPDIR)/type.Po \
797-@AMDEP_TRUE@ ./$(DEPDIR)/type2.Po ./$(DEPDIR)/verify-parse.Po \
798+@AMDEP_TRUE@ ./$(DEPDIR)/elide.Po ./$(DEPDIR)/gbuf.Po \
799+@AMDEP_TRUE@ ./$(DEPDIR)/hint.Po ./$(DEPDIR)/initializer.Po \
800+@AMDEP_TRUE@ ./$(DEPDIR)/list.Po ./$(DEPDIR)/main.Po \
801+@AMDEP_TRUE@ ./$(DEPDIR)/operators.Po ./$(DEPDIR)/output.Po \
802+@AMDEP_TRUE@ ./$(DEPDIR)/print-ast.Po ./$(DEPDIR)/procedure.Po \
803+@AMDEP_TRUE@ ./$(DEPDIR)/profile.Po ./$(DEPDIR)/sem-check.Po \
804+@AMDEP_TRUE@ ./$(DEPDIR)/sideeffects.Po ./$(DEPDIR)/simplify.Po \
805+@AMDEP_TRUE@ ./$(DEPDIR)/stringParse.Po ./$(DEPDIR)/strings.Po \
806+@AMDEP_TRUE@ ./$(DEPDIR)/sue.Po ./$(DEPDIR)/symbol.Po \
807+@AMDEP_TRUE@ ./$(DEPDIR)/testEquals.Po ./$(DEPDIR)/transform.Po \
808+@AMDEP_TRUE@ ./$(DEPDIR)/type.Po ./$(DEPDIR)/type2.Po \
809+@AMDEP_TRUE@ ./$(DEPDIR)/typequal.Po ./$(DEPDIR)/verify-parse.Po \
810 @AMDEP_TRUE@ ./$(DEPDIR)/warning.Po ./$(DEPDIR)/wildcard.Po \
811 @AMDEP_TRUE@ ./$(DEPDIR)/wildcardTable.Po
812 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
813@@ -262,6 +267,7 @@
814 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conversions.Po@am__quote@
815 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dataflow.Po@am__quote@
816 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elide.Po@am__quote@
817+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gbuf.Po@am__quote@
818 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hint.Po@am__quote@
819 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/initializer.Po@am__quote@
820 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Po@am__quote@
821@@ -282,6 +288,7 @@
822 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/transform.Po@am__quote@
823 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/type.Po@am__quote@
824 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/type2.Po@am__quote@
825+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/typequal.Po@am__quote@
826 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/verify-parse.Po@am__quote@
827 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/warning.Po@am__quote@
828 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wildcard.Po@am__quote@
829diff -Nur 5.4.2.2/cilk2c/analyze.c current.Bug188/cilk2c/analyze.c
830--- 5.4.2.2/cilk2c/analyze.c 2004-10-23 03:26:19.000000000 +0000
831+++ current.Bug188/cilk2c/analyze.c 2005-10-22 02:52:37.000000000 +0000
832@@ -28,7 +28,7 @@
833 #include "ast.h"
834
835 FILE_IDENTITY(ident,
836- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/cilk2c/analyze.c $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
837+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/cilk2c/analyze.c $ $LastChangedBy: bradley $ $Rev: 2483 $ $Date$");
838
839
840 #define Gen(n) ((n)->analysis.gen)
841@@ -404,7 +404,9 @@
842 end_coord = node->u.proc.body->u.Block.right_coord;
843
844 if (!IsVoidType(type) &&
845- (!TypeIsSint(type) || TYPE_QUALS(node->u.proc.decl->u.decl.type->u.fdcl.tq) & (T_PROCEDURE | T_INLET)) &&
846+ (!TypeIsSint(type) ||
847+ tq_has_procedure(node->u.proc.decl->u.decl.type->u.fdcl.tq) ||
848+ tq_has_inlet (node->u.proc.decl->u.decl.type->u.fdcl.tq)) &&
849 IsBitSet(v, REACHABLE)) {
850 WarningCoord(3, end_coord,
851 "control reaches end of non-void function");
852@@ -661,7 +663,7 @@
853 * conservative for slow version). */
854 IterateList(&marker, vars);
855 while (NextOnList(&marker, (GenericREF) & var)) {
856- if (NodeDeclLocation(var) == T_FORMAL_DECL)
857+ if (tq_has_formal_decl(NodeDeclLocation(var)))
858 formals = SetUnion(formals, ListFind(vars, var));
859 }
860
861@@ -698,12 +700,15 @@
862
863 GLOBAL void PV(List *vars)
864 {
865- PrintVariables(stdout, vars);
866- putchar('\n');
867- fflush(stdout);
868+ GBUF *gb = make_file_gbuf(stdout);
869+ PrintVariables(gb, vars);
870+
871+ putchar('\n');
872+ fflush(stdout);
873+ free_gbuf(gb);
874 }
875
876-GLOBAL int PrintVariables(FILE *out, List *vars)
877+GLOBAL int PrintVariables(GBUF *gb, List *vars)
878 {
879 ListMarker m;
880 Node *var;
881@@ -711,18 +716,18 @@
882
883 IterateList(&m, vars);
884 while (NextOnList(&m, (GenericREF) & var))
885- len += fprintf(out, "%s ", var->u.decl.name);
886+ len += gbprintf(gb, "%s ", var->u.decl.name);
887 return len;
888 }
889
890-GLOBAL int PrintAnalysis(FILE *out, Node *node)
891+GLOBAL int PrintAnalysis(GBUF *gb, Node *node)
892 {
893 int len = 0;
894
895- len += fprintf(out, "Live: ");
896- len += PrintVariables(out, LiveVars(node));
897- len += fprintf(out, "Dirty: ");
898- len += PrintVariables(out, DirtyVars(node));
899+ len += gbprintf(gb, "Live: ");
900+ len += PrintVariables(gb, LiveVars(node));
901+ len += gbprintf(gb, "Dirty: ");
902+ len += PrintVariables(gb, DirtyVars(node));
903 return len;
904 }
905
906@@ -748,8 +753,8 @@
907 TypeQual dl = NodeDeclLocation(node);
908 TypeQual sc = NodeStorageClass(node);
909
910- if ((dl == T_BLOCK_DECL || dl == T_FORMAL_DECL) &&
911- (sc != T_TYPEDEF && sc != T_EXTERN && sc != T_STATIC) &&
912+ if ((tq_has_block_decl(dl) || tq_has_formal_decl(dl)) &&
913+ (!tq_has_typedef(sc) && !tq_has_extern(sc) && !tq_has_static(sc)) &&
914 (IsScalarType(NodeDataType(node)) ||
915 IsPointerType(NodeDataType(node))))
916 vars = ConsItem(node, vars);
917@@ -774,7 +779,8 @@
918 /* if ((node->typ != Proc) || strcmp(PhaseName, "Transform")) { KHR */
919
920 /* don't look inside local procedures for register variables */
921- if (node->typ == Proc && DECL_LOCATION(node->u.proc.decl->u.decl.tq) != T_TOP_DECL)
922+ if ((node->typ == Proc) &&
923+ !tq_has_top_decl(node->u.proc.decl->u.decl.tq))
924 return vars;
925
926 #define CODE(n) vars = RegisterVariables(n, vars)
927@@ -1021,7 +1027,7 @@
928 node->nondeterminator = node->u.id.decl ?
929 ((DeclIsExternal(node->u.id.decl) ||
930 DeclIsStatic(node->u.id.decl)) &&
931- (!(NodeDeclQuals(node->u.id.decl) & T_PRIVATE)) &&
932+ (!tq_has_private(NodeDeclTq(node->u.id.decl))) &&
933 (!IsFunctionType(node->u.id.decl->u.decl.type)) &&
934 (!HasNoCheckAttrib(node->u.id.decl->u.decl.attribs))) :
935 FALSE;
936@@ -1082,8 +1088,8 @@
937 switch (node->typ) {
938 case Array:
939 if (!((node->u.array.name->typ == Id) &&
940- ((NodeDeclLocation(node->u.array.name->u.id.decl) == T_BLOCK_DECL) ||
941- (NodeDeclQuals(node->u.array.name->u.id.decl) & T_PRIVATE)) &&
942+ (tq_has_block_decl(NodeDeclLocation(node->u.array.name->u.id.decl)) ||
943+ tq_has_private(NodeDeclTq(node->u.array.name->u.id.decl))) &&
944 (IsArrayType(NodeDataType(node->u.array.name))))) {
945 node->nondeterminator = TRUE;
946 node->u.array.name->nondeterminator = FALSE;
947@@ -1116,8 +1122,8 @@
948 }
949 else if (node->u.unary.op == INDIR) {
950 if (!((node->u.unary.expr->typ == Id) &&
951- ((NodeDeclLocation(node->u.unary.expr->u.id.decl) == T_BLOCK_DECL) ||
952- (NodeDeclQuals(node->u.unary.expr->u.id.decl) & T_PRIVATE)) &&
953+ (tq_has_block_decl(NodeDeclLocation(node->u.unary.expr->u.id.decl)) ||
954+ tq_has_private(NodeDeclTq(node->u.unary.expr->u.id.decl))) &&
955 (NodeDataType(node->u.unary.expr)->typ == Adcl))) {
956 node->nondeterminator = TRUE;
957 /* may need check expression
958diff -Nur 5.4.2.2/cilk2c/ast.c current.Bug188/cilk2c/ast.c
959--- 5.4.2.2/cilk2c/ast.c 2004-10-23 03:26:45.000000000 +0000
960+++ current.Bug188/cilk2c/ast.c 2005-10-22 02:54:14.000000000 +0000
961@@ -32,13 +32,18 @@
962 #include "ast.h"
963
964 FILE_IDENTITY(ident,
965- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/cilk2c/ast.c $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
966+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/cilk2c/ast.c $ $LastChangedBy: bradley $ $Rev: 2538 $ $Date$");
967
968 Coord UnknownCoord = {
969 /* line: */ 0,
970 /* offset: */ 0,
971 /* file: */ 0
972 };
973+Coord DontPrintCoord = {
974+ /* line: */ -2,
975+ /* offset: */ -2,
976+ /* file: */ -2,
977+ };
978
979 /* use HeapNew() (defined in ast.h) to allocate whole objects */
980 GLOBAL void *HeapAllocate(unsigned int number, unsigned int size)
981@@ -1374,7 +1379,7 @@
982 /* if from elaborated a struct/union's fields, new should not,
983 since it's sharing */
984 if (d == NodeOnly || d == Subtree)
985- NodeRemoveTq(new, T_SUE_ELABORATED);
986+ NodeUpdateTq(new, tq_remove_sue_elaborated);
987 break;
988 case Spawn: new->u.spawn.args = ListCopy(new->u.spawn.args); break;
989 case Asm: new->u.Asm.output = ListCopy(new->u.Asm.output); new->u.Asm.input = ListCopy(new->u.Asm.input); new->u.Asm.clobbered = ListCopy(new->u.Asm.clobbered); break;
990@@ -1417,19 +1422,19 @@
991 node->u.Block.right_coord = *c;
992 break;
993 case Sdcl:
994- if (SUE_ELABORATED(node->u.sdcl.tq)) {
995+ if (tq_has_sue_elaborated(node->u.sdcl.tq)) {
996 node->u.sdcl.type->coord = *c;
997 node->u.sdcl.type->right_coord = *c;
998 }
999 break;
1000 case Udcl:
1001- if (SUE_ELABORATED(node->u.udcl.tq)) {
1002+ if (tq_has_sue_elaborated(node->u.udcl.tq)) {
1003 node->u.udcl.type->coord = *c;
1004 node->u.udcl.type->right_coord = *c;
1005 }
1006 break;
1007 case Edcl:
1008- if (SUE_ELABORATED(node->u.edcl.tq)) {
1009+ if (tq_has_sue_elaborated(node->u.edcl.tq)) {
1010 node->u.edcl.type->coord = *c;
1011 node->u.edcl.type->right_coord = *c;
1012 }
1013diff -Nur 5.4.2.2/cilk2c/ast.h current.Bug188/cilk2c/ast.h
1014--- 5.4.2.2/cilk2c/ast.h 2004-10-23 03:26:46.000000000 +0000
1015+++ current.Bug188/cilk2c/ast.h 2005-10-22 02:52:37.000000000 +0000
1016@@ -36,9 +36,10 @@
1017 #include "basics.h"
1018 #include "dataflow.h"
1019 #include "wildcard.h"
1020+#include "typequal.h"
1021
1022 FILE_IDENTITY(ast_ident,
1023- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/cilk2c/ast.h $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
1024+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/cilk2c/ast.h $ $LastChangedBy: bradley $ $Rev: 2483 $ $Date$");
1025
1026 /* definition of Node data structure */
1027
1028@@ -86,142 +87,7 @@
1029 /* */
1030 /*************************************************************************/
1031
1032-/* TypeQual: storage classes, type qualifiers, and additional attributes */
1033-
1034-typedef enum {
1035-
1036- EMPTY_TQ = 0,
1037-/*
1038- Declaration qualifiers. A declaration can have multiple qualifiers,
1039- though some are mutually exclusive (like storage classes).
1040- During the parsing of a declaration, decl qualifiers are kept in
1041- the tq field of its primitive type. After the decl has been parsed,
1042- SetDeclType then moves the qualifiers to their proper place, the
1043- Decl node.
1044-
1045- To add a new decl qualifier:
1046- 1. Define a new symbol below, being careful that its bits do
1047- not conflict with existing decl and type qualifiers,
1048- since they can coexist in the same TypeQual variable.
1049- 2. Insert the symbol in T_DECL_QUALS (below).
1050- 3. If the qualifier is parsed in the source (rather than calculated),
1051- add a lexical token (c4.l) and a new production to storage.classes
1052- (ANSI-C.y).
1053- 4. Add code to print out its name in TQtoText (type.c).
1054- 5. Add merging logic to MergeTypeQuals (type.c), if necessary.
1055-*/
1056-
1057- T_AUTO = 0x00001,
1058- T_EXTERN = 0x00002,
1059- T_REGISTER = 0x00003,
1060- T_STATIC = 0x00004,
1061- T_TYPEDEF = 0x00005,
1062- /* Insert new storage classes here */
1063-
1064- T_STORAGE_CLASSES = (T_AUTO | T_EXTERN | T_REGISTER | T_STATIC | T_TYPEDEF),
1065-#define STORAGE_CLASS(tq) ((tq) & T_STORAGE_CLASSES)
1066-
1067- /* the following qualifiers are all mutually exclusive,
1068- so they can share bits */
1069- T_TOP_DECL = 0x00010, /* top-level decl */
1070- T_BLOCK_DECL = 0x00020, /* local decl in a block */
1071- T_FORMAL_DECL = 0x00030, /* formal parameter decl */
1072- T_SU_DECL = 0x00040, /* struct/union field decl */
1073- T_ENUM_DECL = 0x00050, /* enumerated constant decl */
1074- /* Insert new decl locations here */
1075-
1076- T_DECL_LOCATIONS = (T_TOP_DECL | T_BLOCK_DECL | T_FORMAL_DECL |
1077- T_SU_DECL | T_ENUM_DECL),
1078-#define DECL_LOCATION(tq) ((tq) & T_DECL_LOCATIONS)
1079-
1080- /* Flag for redundant external declaration, which is defined as
1081- * an external declaration (NOT a definition, so it must have no
1082- * initializer or function body) of a name previously declared external
1083- * in the same scope. A trivial example:
1084- * extern int x;
1085- * extern int x; <-- redundant
1086- * But:
1087- * { extern int x; }
1088- * { extern int x; } <-- not redundant
1089- * because the two declarations have different scopes.
1090- */
1091- T_REDUNDANT_EXTERNAL_DECL = 0x00100,
1092-
1093- /* Insert new decl qualifiers here */
1094- T_SHARED = 0x00200,
1095- T_PRIVATE = 0x00400,
1096- T_NOOUTPUT = 0x00800,
1097- T_CILKONLY = 0x01000, /* variable can only be used in cilk code */
1098- T_CILKSAFE = 0x02000, /* promise that this variable is safe to access in parallel */
1099-
1100- /* the following tq's are used to generate CILK_WHERE_AM_I directives */
1101- T_FAST_PROCEDURE = 0x04000,
1102- T_SLOW_PROCEDURE = 0x08000,
1103- T_FAST_INLET = 0x10000,
1104- T_SLOW_INLET = 0x20000,
1105- T_STANDALONE_INLET = 0x40000,
1106- T_C_CODE = 0x80000,
1107-
1108- T_CILK_WHERE_AM_I_DECL_QUALS = (T_FAST_PROCEDURE | T_SLOW_PROCEDURE | T_FAST_INLET | T_SLOW_INLET | T_STANDALONE_INLET | T_C_CODE),
1109-
1110- T_DECL_QUALS = (T_STORAGE_CLASSES | T_DECL_LOCATIONS
1111- | T_REDUNDANT_EXTERNAL_DECL
1112- | T_SHARED | T_PRIVATE | T_NOOUTPUT
1113- | T_CILKONLY | T_CILKSAFE
1114- | T_CILK_WHERE_AM_I_DECL_QUALS
1115- ),
1116-
1117-#define DECL_QUALS(tq) ((tq) & T_DECL_QUALS)
1118-
1119-
1120-/*
1121- Type qualifiers. Multiple type qualifiers may apply to a type.
1122- They may be associated with any primitive or complex type.
1123- Some type qualifiers may be moved after parsing -- for instance,
1124- T_INLINE is moved to the top-level Fdcl it is describing.
1125-
1126- To add a new type qualifier:
1127- 1. Define a new symbol below, being careful that its bits do
1128- not conflict with existing storage classes and type qualifiers,
1129- since they can coexist in the same TypeQual variable.
1130- 2. Insert the symbol in T_TYPE_QUALS (below).
1131- 3. Add a lexical token (c4.l) and a new production to either
1132- type.qualifiers or pointer.type.qualifiers (ANSI-C.y), depending
1133- on whether the type qualifier is allowed only at the beginning
1134- of a type, or can appear after '*' like const and volatile.
1135- 4. Add code to print out its name in TQtoText (type.c).
1136- 5. Add its symbol to TQ_ALWAYS_COMPATIBLE (below) if an object with
1137- the type qualifier is always assignment-compatible with an object
1138- without the type qualifier.
1139- 6. Add merging logic to MergeTypeQuals (type.c), if necessary.
1140- */
1141-
1142- T_RESTRICT = 0x100000,
1143- T_COMPLEX = 0x200000,
1144-
1145- T_CONST = 0x400000, /* leave some room for new decl qualifiers */
1146- T_VOLATILE = 0x800000,
1147- T_INLINE = 0x1000000,
1148- T_SUE_ELABORATED = 0x2000000, /* on an Sdcl/Udcl/Edcl, indicates
1149- whether SUE's field list appeared
1150- at that point in the source */
1151-#define SUE_ELABORATED(tq) (((tq) & T_SUE_ELABORATED) != 0)
1152- /* Insert new type qualifiers here */
1153- T_PROCEDURE = 0x4000000,
1154-
1155- T_INLET = 0x8000000,
1156-
1157- T_EXTENSION = 0x10000000, /* used for gcc __extension__ keyword. Not exactly a TYPE_QUAL */
1158-
1159- T_TYPE_QUALS = (T_RESTRICT | T_COMPLEX | T_CONST | T_VOLATILE | T_INLINE | T_SUE_ELABORATED | T_PROCEDURE | T_INLET ),
1160-#define TYPE_QUALS(tq) ((tq) & T_TYPE_QUALS)
1161-
1162-/* Type qualifiers listed in TQ_COMPATIBLE are ignored
1163- * when checking two types for compatibility (weaker than strict equality). */
1164- TQ_COMPATIBLE = (T_CONST | T_VOLATILE | T_INLINE | T_SUE_ELABORATED | T_RESTRICT | T_EXTENSION)
1165-
1166-} TypeQual;
1167-
1168+/* Type qualifiers, storage classes, and additional attributes now are found in typequal.h and typequal.c */
1169
1170
1171 /* BasicType covers all of the different fundamental types.
1172@@ -1009,9 +875,9 @@
1173 case Ptr: if ((n)->u.ptr.type) {CODE((n)->u.ptr.type);} break; \
1174 case Adcl: if ((n)->u.adcl.type) {CODE((n)->u.adcl.type);} if ((n)->u.adcl.dimp->dim) {CODE((n)->u.adcl.dimp->dim);} break; \
1175 case Fdcl: if ((n)->u.fdcl.args) {LISTWALK((n)->u.fdcl.args, CODE);} if ((n)->u.fdcl.returns) {CODE((n)->u.fdcl.returns);} break; \
1176- case Sdcl: if (SUE_ELABORATED((n)->u.sdcl.tq)) { if ((n)->u.sdcl.type->fields) {LISTWALK((n)->u.sdcl.type->fields, CODE);} if ((n)->u.sdcl.type->attributes) {LISTWALK((n)->u.sdcl.type->attributes, CODE);}} break; \
1177- case Udcl: if (SUE_ELABORATED((n)->u.udcl.tq)) { if ((n)->u.udcl.type->fields) {LISTWALK((n)->u.udcl.type->fields, CODE);} if ((n)->u.udcl.type->attributes) {LISTWALK((n)->u.udcl.type->attributes, CODE);}} break; \
1178- case Edcl: if (SUE_ELABORATED((n)->u.edcl.tq)) { if ((n)->u.edcl.type->fields) {LISTWALK((n)->u.edcl.type->fields, CODE);} if ((n)->u.edcl.type->attributes) {LISTWALK((n)->u.edcl.type->attributes, CODE);}} break; \
1179+ case Sdcl: if (tq_has_sue_elaborated((n)->u.sdcl.tq)) { if ((n)->u.sdcl.type->fields) {LISTWALK((n)->u.sdcl.type->fields, CODE);} if ((n)->u.sdcl.type->attributes) {LISTWALK((n)->u.sdcl.type->attributes, CODE);}} break; \
1180+ case Udcl: if (tq_has_sue_elaborated((n)->u.udcl.tq)) { if ((n)->u.udcl.type->fields) {LISTWALK((n)->u.udcl.type->fields, CODE);} if ((n)->u.udcl.type->attributes) {LISTWALK((n)->u.udcl.type->attributes, CODE);}} break; \
1181+ case Edcl: if (tq_has_sue_elaborated((n)->u.edcl.tq)) { if ((n)->u.edcl.type->fields) {LISTWALK((n)->u.edcl.type->fields, CODE);} if ((n)->u.edcl.type->attributes) {LISTWALK((n)->u.edcl.type->attributes, CODE);}} break; \
1182 case Asm: if ((n)->u.Asm.template) {CODE((n)->u.Asm.template);} if ((n)->u.Asm.output) {LISTWALK((n)->u.Asm.output, CODE);} if ((n)->u.Asm.input) {LISTWALK((n)->u.Asm.input, CODE);} if ((n)->u.Asm.clobbered) {LISTWALK((n)->u.Asm.clobbered, CODE);} break; \
1183 case AsmArg: if ((n)->u.AsmArg.constraint) {CODE((n)->u.AsmArg.constraint);} if ((n)->u.AsmArg.expr) {CODE((n)->u.AsmArg.expr);} break; \
1184 /* GCC builtin stdarg.h support */ \
1185@@ -1208,7 +1074,7 @@
1186 GLOBAL Node *NodeCopy(Node *from, TreeOpDepth d);
1187 GLOBAL Node *SetCoords(Node *tree, Coord c, TreeOpDepth d); /* Returns the modified node. */
1188 GLOBAL void WalkTree(Node *tree, WalkProc proc, void *ptr, WalkOrder order);
1189-GLOBAL void PrintCoord (FILE *out, Coord *c);
1190+GLOBAL void PrintCoord (GBUF *out, Coord *c);
1191
1192 /* copy a list of nodes, using the TreeOpDepth to determine how to copy each node. */
1193 GLOBAL List *ListCopyNodes(List*, TreeOpDepth d);
1194diff -Nur 5.4.2.2/cilk2c/astEquals.c current.Bug188/cilk2c/astEquals.c
1195--- 5.4.2.2/cilk2c/astEquals.c 2004-10-23 03:26:44.000000000 +0000
1196+++ current.Bug188/cilk2c/astEquals.c 2005-10-22 02:52:37.000000000 +0000
1197@@ -275,44 +275,44 @@
1198
1199
1200 Bool EqualPrim(primNode *u1, primNode *u2) {
1201- return ((u1->tq == u2->tq) && (u1->basic == u2->basic));
1202+ return (tq_equal(u1->tq, u2->tq) && (u1->basic == u2->basic));
1203 }
1204
1205
1206
1207 Bool EqualTdef(tdefNode *u1, tdefNode *u2) {
1208 return ( EqualStrings(u1->name, u2->name)
1209- && (u1->tq == u2->tq));
1210+ && tq_equal(u1->tq, u2->tq));
1211 }
1212
1213 Bool EqualPtr(ptrNode *u1, ptrNode *u2) {
1214- return (u1->tq == u2->tq);
1215+ return tq_equal(u1->tq, u2->tq);
1216 }
1217
1218
1219 Bool EqualAdcl(adclNode *u1, adclNode *u2) {
1220- return (u1->tq == u2->tq);
1221+ return tq_equal(u1->tq, u2->tq);
1222 }
1223
1224 Bool EqualFdcl(fdclNode *u1, fdclNode *u2) {
1225- return (u1->tq == u2->tq);
1226+ return tq_equal(u1->tq, u2->tq);
1227 }
1228
1229 Bool EqualSdcl(sdclNode *u1, sdclNode *u2) {
1230- return (u1->tq == u2->tq);
1231+ return tq_equal(u1->tq, u2->tq);
1232 }
1233
1234 Bool EqualUdcl(udclNode *u1, udclNode *u2) {
1235- return (u1->tq == u2->tq);
1236+ return tq_equal(u1->tq, u2->tq);
1237 }
1238
1239 Bool EqualEdcl(edclNode *u1, edclNode *u2) {
1240- return (u1->tq == u2->tq);
1241+ return tq_equal(u1->tq, u2->tq);
1242 }
1243
1244
1245 Bool EqualDecl(declNode *u1, declNode *u2) {
1246- return ((u1->tq == u2->tq)
1247+ return (tq_equal(u1->tq, u2->tq)
1248 && (EqualStrings(u1->name, u2->name)));
1249 }
1250
1251@@ -333,7 +333,7 @@
1252 }
1253
1254 Bool EqualAsm(asmNode *u1, asmNode *u2) {
1255- return (u1->tq == u2->tq);
1256+ return tq_equal(u1->tq, u2->tq);
1257 }
1258
1259 Bool EqualAsmArg(asmargNode *UNUSED(u1),
1260diff -Nur 5.4.2.2/cilk2c/astModify.h current.Bug188/cilk2c/astModify.h
1261--- 5.4.2.2/cilk2c/astModify.h 2004-10-23 03:26:19.000000000 +0000
1262+++ current.Bug188/cilk2c/astModify.h 2005-10-22 02:52:37.000000000 +0000
1263@@ -321,15 +321,15 @@
1264 {CODE((n1)->u.fdcl.returns, (n2)->u.fdcl.returns, answer);} \
1265 break; \
1266 case Sdcl: if (DUALWALKDEBUG) printf("Taking Sdcl branch... \n"); \
1267- if (SUE_ELABORATED((n1)->u.sdcl.tq) && SUE_ELABORATED((n2)->u.sdcl.tq)) \
1268+ if (tq_has_sue_elaborated((n1)->u.sdcl.tq) && tq_has_sue_elaborated((n2)->u.sdcl.tq)) \
1269 {DUAL_LIST_WALK((n1)->u.sdcl.type->fields, (n2)->u.sdcl.type->fields, answer, CODE, CONTINUE, FAILCODE);} \
1270 break; \
1271 case Udcl: if (DUALWALKDEBUG) printf("Taking Udcl branch... \n"); \
1272- if (SUE_ELABORATED((n1)->u.udcl.tq) && SUE_ELABORATED((n2)->u.udcl.tq)) \
1273+ if (tq_has_sue_elaborated((n1)->u.udcl.tq) && tq_has_sue_elaborated((n2)->u.udcl.tq)) \
1274 {DUAL_LIST_WALK((n1)->u.udcl.type->fields, (n2)->u.udcl.type->fields, answer, CODE, CONTINUE, FAILCODE);} \
1275 break; \
1276 case Edcl: if (DUALWALKDEBUG) printf("Taking Edcl branch... \n"); \
1277- if (SUE_ELABORATED((n1)->u.edcl.tq) && SUE_ELABORATED((n2)->u.edcl.tq)) \
1278+ if (tq_has_sue_elaborated((n1)->u.edcl.tq) && tq_has_sue_elaborated((n2)->u.edcl.tq)) \
1279 {DUAL_LIST_WALK((n1)->u.edcl.type->fields, (n2)->u.edcl.type->fields, answer, CODE, CONTINUE, FAILCODE);} \
1280 break; \
1281 case Asm: {CODE((n1)->u.Asm.template, (n2)->u.Asm.template, answer);} \
1282@@ -504,13 +504,13 @@
1283 case Fdcl: {LISTWALKTWO((n1)->u.fdcl.args, (n2), answer, CODE, CONTINUE, FAILCODE);} \
1284 {CODE((n1)->u.fdcl.returns, (n2), answer);} \
1285 break; \
1286- case Sdcl: if (SUE_ELABORATED((n1)->u.sdcl.tq)) \
1287+ case Sdcl: if (tq_has_sue_elaborated((n1)->u.sdcl.tq)) \
1288 {LISTWALKTWO((n1)->u.sdcl.type->fields, (n2), answer, CODE, CONTINUE, FAILCODE);} \
1289 break; \
1290- case Udcl: if (SUE_ELABORATED((n1)->u.udcl.tq)) \
1291+ case Udcl: if (tq_has_sue_elaborated((n1)->u.udcl.tq)) \
1292 {LISTWALKTWO((n1)->u.udcl.type->fields, (n2), answer, CODE, CONTINUE, FAILCODE);} \
1293 break; \
1294- case Edcl: if (SUE_ELABORATED((n1)->u.edcl.tq)) \
1295+ case Edcl: if (tq_has_sue_elaborated((n1)->u.edcl.tq)) \
1296 {LISTWALKTWO((n1)->u.edcl.type->fields, (n2), answer, CODE, CONTINUE, FAILCODE);} \
1297 break; \
1298 case Asm: {CODE((n1)->u.Asm.template, (n2), answer);} \
1299diff -Nur 5.4.2.2/cilk2c/atmTransform.c current.Bug188/cilk2c/atmTransform.c
1300--- 5.4.2.2/cilk2c/atmTransform.c 2004-10-23 03:26:20.000000000 +0000
1301+++ current.Bug188/cilk2c/atmTransform.c 2005-10-22 02:52:37.000000000 +0000
1302@@ -568,7 +568,7 @@
1303 AtomicStartDepth = CurrentTableDepth+1;
1304 /*PrintNode(stdout, theDecl->u.decl.type, 0);*/
1305 if (theDecl != NULL) {
1306- PrintNode(stdout, theDecl->u.decl.type, 0);
1307+ fPrintNode(stdout, theDecl->u.decl.type, 0);
1308 AddDeclsToTable(theDecl->u.decl.type->u.fdcl.args, CurrentTableDepth+1);
1309 }
1310 PrintSymbolTable(stdout, currentTable);
1311@@ -594,7 +594,7 @@
1312
1313 if (copyType == NULL) {
1314 printf("Node is: \n");
1315- PrintNode(stdout, node, 0);
1316+ fPrintNode(stdout, node, 0);
1317 printf("\n");
1318 FAIL("Binop node does not have type field filled in;");
1319 }
1320@@ -688,7 +688,7 @@
1321
1322 if (node->u.id.decl == NULL) {
1323 printf("Node is: \n");
1324- PrintNode(stdout, node, 0);
1325+ fPrintNode(stdout, node, 0);
1326 FAIL("Id node has no decl field. \n");
1327 }
1328
1329diff -Nur 5.4.2.2/cilk2c/basics.h current.Bug188/cilk2c/basics.h
1330--- 5.4.2.2/cilk2c/basics.h 2004-10-23 03:26:20.000000000 +0000
1331+++ current.Bug188/cilk2c/basics.h 2005-10-22 02:54:14.000000000 +0000
1332@@ -32,7 +32,7 @@
1333 #define _BASICS_H_
1334 #include "../runtime/cilk-sysdep.h"
1335 FILE_IDENTITY(basics_ident,
1336- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/cilk2c/basics.h $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
1337+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/cilk2c/basics.h $ $LastChangedBy: bradley $ $Rev: 2538 $ $Date$");
1338
1339 #include <stdio.h>
1340 #include <stdlib.h>
1341@@ -101,8 +101,9 @@
1342 short file;
1343 } Coord;
1344
1345-GLOBAL extern Coord UnknownCoord;
1346+GLOBAL extern Coord UnknownCoord,DontPrintCoord;
1347 #define IsUnknownCoord(coord) ((coord).file == UnknownCoord.file)
1348+#define IsDontPrintCoord(coord) ((coord).file == DontPrintCoord.file)
1349
1350 #define PRINT_COORD(out, c) \
1351 { if (PrintLineOffset) \
1352@@ -127,6 +128,7 @@
1353 #include "heap.h"
1354 #include "list.h"
1355 #include "symbol.h"
1356+#include "gbuf.h"
1357
1358 /* Basic Global Variables */
1359
1360@@ -172,15 +174,18 @@
1361 /* pretty-printing */
1362 GLOBAL void DPN(Node *n);
1363 GLOBAL void DPL(List *list);
1364-GLOBAL void PrintNode(FILE *out, Node *node, int tab_depth);
1365-GLOBAL int PrintConstant(FILE *out, Node *c, Bool with_name);
1366-GLOBAL void PrintCRSpaces(FILE *out, int spaces);
1367-GLOBAL void PrintSpaces(FILE *out, int spaces);
1368-GLOBAL void PrintList(FILE *out, List *list, int tab_depth);
1369-GLOBAL int PrintOp(FILE *out, OpType op); /* operators.c */
1370+GLOBAL void PrintNode(GBUF *out, Node *node, int tab_depth);
1371+#define fPrintNode(file,node,tab_depth) WITH_FILE_GBUF(gb,file,PrintNode(gb,node,tab_depth))
1372+GLOBAL int print_float(GBUF *, float);
1373+GLOBAL int print_double(GBUF *, double);
1374+GLOBAL void PrintCRSpaces(GBUF *out, int spaces);
1375+GLOBAL void PrintSpaces(GBUF *out, int spaces);
1376+GLOBAL void PrintList(GBUF *out, List *list, int tab_depth);
1377+#define fPrintList(file,l,tab_depth) WITH_FILE_GBUF(gb,file,PrintList(gb,l,tab_depth))
1378+GLOBAL int PrintOp(GBUF *, OpType op); /* operators.c */
1379 GLOBAL void CharToText(char *array, unsigned char value);
1380-GLOBAL inline int PrintChar(FILE *out, int c); /* print.c */
1381-GLOBAL int PrintString(FILE *out, const char *string); /* print.c */
1382+GLOBAL inline int PrintChar(GBUF *out, int c); /* print.c */
1383+GLOBAL int PrintString(GBUF *out, const char *string); /* print.c */
1384
1385 /* warning.c */
1386 GLOBAL NoReturn(Fail(const char *file, int line, const char *msg));
1387@@ -226,4 +231,6 @@
1388
1389 GLOBAL void OutputStmtList(FILE *outfile, List *myStmtList);
1390
1391+GLOBAL void output_constant_to_GBUF(GBUF *, Node *, Bool /*with_name*/);
1392+GLOBAL void output_prim_type_to_GBUF(GBUF *gb, Node *type, char *lastc);
1393 #endif /* ifndef _BASICS_H_ */
1394diff -Nur 5.4.2.2/cilk2c/c4.l current.Bug188/cilk2c/c4.l
1395--- 5.4.2.2/cilk2c/c4.l 2004-10-23 03:26:21.000000000 +0000
1396+++ current.Bug188/cilk2c/c4.l 2005-10-22 02:52:37.000000000 +0000
1397@@ -168,7 +168,7 @@
1398 #include "ast.h"
1399
1400 FILE_IDENTITY(ident,
1401- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/cilk2c/c4.l $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
1402+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/cilk2c/c4.l $ $LastChangedBy: bradley $ $Rev: 1880 $ $Date$");
1403
1404 PRIVATE inline void GetCoord(Coord *pcoord);
1405 PRIVATE Node *char_constant(const char *);
1406@@ -906,7 +906,7 @@
1407 if (input_language) {
1408 return strcmp(input_language, "cilk")==0;
1409 } else {
1410- return HasSuffix(name, ".cilk") || HasSuffix(name, ".cilkh") || HasSuffix(name, "cilki");
1411+ return HasSuffix(name, ".cilk") || HasSuffix(name, ".cilkp") || HasSuffix(name, ".cilkh") || HasSuffix(name, "cilki");
1412 }
1413 }
1414
1415@@ -953,7 +953,7 @@
1416 * non-includable file included from includable
1417 * file. Issue a warning.
1418 */
1419- printf("%s hash_cilk_suffix=%d\n", name, Has_Cilk_Suffix(name, input_language));
1420+ printf("%s:%d %s Has_Cilk_Suffix=%d\n", __FILE__, __LINE__, name, Has_Cilk_Suffix(name, input_language));
1421 Warning(1,
1422 "Non-includable file %s included from includable"
1423 " file %s.", name, FileNames[CurrentFile]);
1424diff -Nur 5.4.2.2/cilk2c/complex-types.c current.Bug188/cilk2c/complex-types.c
1425--- 5.4.2.2/cilk2c/complex-types.c 2004-10-23 03:26:20.000000000 +0000
1426+++ current.Bug188/cilk2c/complex-types.c 2005-10-22 02:54:14.000000000 +0000
1427@@ -31,7 +31,7 @@
1428 #include "ast.h"
1429
1430 FILE_IDENTITY(ident,
1431- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/cilk2c/complex-types.c $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
1432+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/cilk2c/complex-types.c $ $LastChangedBy: bradley $ $Rev: 2540 $ $Date$");
1433
1434 /* From ANSI-C.y */
1435 GLOBAL Bool OmitLookups();
1436@@ -87,7 +87,7 @@
1437 continue;
1438 default:
1439 Warning(1, "Internal Error!: invalid `complex' arg\n");
1440- PrintNode(stderr, complex, 0);
1441+ DPN(complex);
1442 fprintf(stderr, "\n");
1443 exit(1);
1444 return(complex); /* unreachable */
1445@@ -238,9 +238,9 @@
1446 Node *var;
1447
1448 #if 0
1449- printf("\nSetDeclType(decl, type, %d)\n", redeclare);
1450- PrintNode(stdout, decl, 0); printf("\n");
1451- PrintNode(stdout, type, 0); printf("\n");
1452+ printf("\n%s:%d SetDeclType(decl, type, %d)\n", __FILE__, __LINE__, redeclare);
1453+ DPN(decl);
1454+ DPN(type);
1455 #endif
1456
1457 assert(decl != NULL && decl->typ == Decl);
1458@@ -266,9 +266,12 @@
1459 storage classes to Decl node, and inserting it in the
1460 symbol table.
1461
1462+ Also move attributes up to the decl.
1463+
1464 ********************************************************/
1465
1466 decl = FinishDecl(decl);
1467+ //printf("%s:%d ", __FILE__, __LINE__); DPN(decl);
1468 sc = NodeStorageClass(decl);
1469
1470 if (OldStyleFunctionDefinition) {
1471@@ -277,7 +280,7 @@
1472 if (redeclare != SU) redeclare = Formal;
1473 }
1474
1475- if (sc == T_TYPEDEF) {
1476+ if (tq_has_typedef(sc)) {
1477 var = decl;
1478 } else if (decl->u.decl.type->typ == Fdcl && (redeclare != Formal)) {
1479
1480@@ -308,7 +311,7 @@
1481 decl,
1482 (ConflictProc) FunctionConflict));
1483
1484- } else if (sc == T_EXTERN ||
1485+ } else if (tq_has_extern(sc) ||
1486 (Level == 0 && redeclare == Redecl)) {
1487 /* top-level variable, check for consistency with Externals */
1488 var = (OmitLookups() ? decl : InsertSymbol(Externals,
1489@@ -330,7 +333,7 @@
1490 /* decl could be redundant, but we don't know if it's a
1491 definition or declaration yet. Mark it, and let SetDeclInit
1492 decide. */
1493- NodeAddTq(decl, T_REDUNDANT_EXTERNAL_DECL);
1494+ NodeUpdateTq(decl, tq_add_redundant_external_decl);
1495 }
1496
1497 switch (redeclare) {
1498@@ -342,7 +345,7 @@
1499 }
1500 /* falls through to Redecl */
1501 case Redecl:
1502- NodeSetDeclLocation(decl, Level == 0 ? T_TOP_DECL : T_BLOCK_DECL);
1503+ NodeSetDeclLocation(decl, Level == 0 ? TQ_TOP_DECL : TQ_BLOCK_DECL);
1504
1505 /* add to current scope */
1506 if (!OmitLookups()) {
1507@@ -351,20 +354,20 @@
1508 }
1509 break;
1510 case SU:
1511- NodeSetDeclLocation(decl, T_SU_DECL);
1512+ NodeSetDeclLocation(decl, TQ_SU_DECL);
1513
1514 /* each struct/union has it own namespace for fields */
1515 break;
1516 case Formal:
1517- NodeSetDeclLocation(decl, T_FORMAL_DECL);
1518+ NodeSetDeclLocation(decl, TQ_FORMAL_DECL);
1519
1520- if (sc != 0 && sc != T_REGISTER) {
1521+ if (tq_has_anything(sc) && !tq_has_register(sc)) {
1522 SyntaxErrorCoord(decl->coord,
1523 "illegal storage class for parameter `%s'",
1524 decl->u.decl.name);
1525- if (sc == T_TYPEDEF) break;
1526+ if (tq_has_typedef(sc)) break;
1527 /* reset storage class for body */
1528- NodeSetStorageClass(decl, 0);
1529+ NodeSetStorageClass(decl, EMPTY_TQ);
1530 }
1531
1532 /* convert Adcl to pointer */
1533@@ -386,6 +389,10 @@
1534 before the body is parsed. */
1535 break;
1536 }
1537+#if 0
1538+ printf("\n%s:%d SetDeclType returns\n", __FILE__, __LINE__);
1539+ DPN(decl);
1540+#endif
1541 return(decl);
1542 }
1543
1544@@ -396,13 +403,11 @@
1545 assert(decl->u.decl.init == NULL);
1546 decl->u.decl.init = init;
1547
1548-
1549 if (init) {
1550- if (NodeTq(decl) & T_REDUNDANT_EXTERNAL_DECL)
1551+ if (tq_has_redundant_external_decl(NodeTq(decl)))
1552 /* fix up misprediction made in SetDeclType.
1553 decl has an initializer, so it isn't redundant. */
1554- NodeRemoveTq(decl, T_REDUNDANT_EXTERNAL_DECL);
1555-
1556+ NodeUpdateTq(decl, tq_remove_redundant_external_decl);
1557 }
1558
1559 return(decl);
1560@@ -419,8 +424,11 @@
1561 GLOBAL Node *SetDeclAttribs(Node *decl, List *attribs)
1562 {
1563 assert(decl != NULL && decl->typ == Decl);
1564- assert(decl->u.decl.attribs == NULL);
1565- decl->u.decl.attribs = attribs;
1566+ assert(decl->u.decl.tq.attributes==NULL); // We don't store any attributes in the tq at this point. */
1567+ //printf("%s:%d: ", __FILE__, __LINE__); DPN(decl);
1568+ decl->u.decl.attribs = JoinLists(decl->u.decl.attribs, attribs);
1569+ //printf("%s:%d: ", __FILE__, __LINE__); DPN(decl);
1570+ //printf("%s:%d: ", __FILE__, __LINE__); DPL(decl->u.decl.attribs);
1571 return (decl);
1572 }
1573
1574@@ -447,6 +455,8 @@
1575
1576 WARNING: FinishDecl may be run more than once on a decl, so it
1577 should not blindly make unnecessary changes.
1578+
1579+ Move attributes up as well as storage class.
1580 */
1581 GLOBAL Node *FinishDecl(Node *decl)
1582 {
1583@@ -460,14 +470,18 @@
1584
1585 /* move decl qualifiers to decl */
1586 tq = NodeTq(deepbasetype);
1587- NodeRemoveTq(deepbasetype, T_DECL_QUALS);
1588- NodeAddTq(decl, DECL_QUALS(tq));
1589+ //printf("%s:%d deepbasetype is (are attributes there?)", __FILE__, __LINE__); DPN(deepbasetype);
1590+ NodeUpdateTq(deepbasetype, tq_remove_all_decl_quals);
1591+ //printf("%s:%d deepbasetype is (are attributes there?)", __FILE__, __LINE__); DPN(deepbasetype);
1592+ NodeUpdateTq2(decl, tq_union, (TypeQual){tq_decl_quals(tq).tq,0});
1593+ decl->u.decl.attribs = JoinLists(decl->u.decl.attribs, tq_decl_quals(tq).attributes);
1594+ //printf("%s:%d decl is (are attributes there?)", __FILE__, __LINE__); DPN(decl);
1595 minf_coord(&decl->coord, &deepbasetype->coord); /* when we move type qualifers around, we also need to note that the position of the declaration may have moved to an earlier spot. */
1596
1597 /* check for incomplete struct/union/enum -- only if not typedef and
1598 not definition */
1599 sc = NodeStorageClass(decl);
1600- if (sc != T_TYPEDEF && !(sc == T_EXTERN && !decl->u.decl.init))
1601+ if (!tq_has_typedef(sc) && !(tq_has_extern(sc) && !decl->u.decl.init))
1602 VerifySUEcomplete(decl->u.decl.type);
1603
1604 return decl;
1605@@ -489,41 +503,41 @@
1606 Node *deepbasetype = GetDeepBaseType(type);
1607 TypeQual basetq = NodeTq(deepbasetype);
1608
1609- if (basetq & T_INLINE) {
1610+ if (tq_has_inline(basetq)) {
1611 if (ANSIOnly)
1612 SyntaxError("inline keyword not allowed with -ansi switch");
1613 else if (!IsFunctionType(type))
1614 WarningCoord(1, type->coord,
1615 "inline qualifier applies only to functions");
1616- else NodeAddTq(type, T_INLINE);
1617- NodeRemoveTq(deepbasetype, T_INLINE);
1618+ else NodeUpdateTq(type, tq_add_inline);
1619+ NodeUpdateTq(deepbasetype, tq_remove_inline);
1620 minf_coord(&type->coord, &deepbasetype->coord); /* when we move type qualifers around, we also need to note that the position of the declaration may have moved to an earlier spot. */
1621 }
1622
1623 /* Insert your extensions here */
1624- if (basetq & T_PROCEDURE) {
1625+ if (tq_has_procedure(basetq)) {
1626 if (!IsFunctionType(type))
1627 {
1628 if (!IsPtrToFunction(type))
1629 SyntaxErrorCoord(deepbasetype->coord,
1630 "cilk keyword applies only to functions");
1631 else
1632- NodeAddTq(type->u.ptr.type, T_PROCEDURE);
1633+ NodeUpdateTq(type->u.ptr.type, tq_add_procedure);
1634 }
1635- else NodeAddTq(type, T_PROCEDURE);
1636- NodeRemoveTq(deepbasetype, T_PROCEDURE);
1637+ else NodeUpdateTq(type, tq_add_procedure);
1638+ NodeUpdateTq(deepbasetype, tq_remove_procedure);
1639 }
1640- if (basetq & T_INLET) {
1641+ if (tq_has_inlet(basetq)) {
1642 if (!IsFunctionType(type))
1643 {
1644 if (!IsPtrToFunction(type))
1645 SyntaxErrorCoord(deepbasetype->coord,
1646 "inlet keyword applies only to functions");
1647 else
1648- NodeAddTq(type->u.ptr.type, T_INLET);
1649+ NodeUpdateTq(type->u.ptr.type, tq_add_inlet);
1650 }
1651- else NodeAddTq(type, T_INLET);
1652- NodeRemoveTq(deepbasetype, T_INLET);
1653+ else NodeUpdateTq(type, tq_add_inlet);
1654+ NodeUpdateTq(deepbasetype, tq_remove_inlet);
1655 }
1656
1657 return type;
1658@@ -550,18 +564,8 @@
1659
1660 type = NodeCopy(GetDeepBaseType(firstdecl->u.decl.type), NodeOnly);
1661
1662- decl->u.decl.tq |= firstdecl->u.decl.tq;
1663+ decl->u.decl.tq = tq_union(decl->u.decl.tq, firstdecl->u.decl.tq);
1664 AppendItem(list, SetDeclType(decl, type, redeclare));
1665
1666 return(list);
1667 }
1668-
1669-
1670-
1671-
1672-
1673-
1674-
1675-
1676-
1677-
1678diff -Nur 5.4.2.2/cilk2c/config.h current.Bug188/cilk2c/config.h
1679--- 5.4.2.2/cilk2c/config.h 2004-10-23 03:26:20.000000000 +0000
1680+++ current.Bug188/cilk2c/config.h 2005-10-22 02:52:37.000000000 +0000
1681@@ -27,7 +27,7 @@
1682 #define _CONFIG_H_
1683
1684 FILE_IDENTITY(config_ident,
1685- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/cilk2c/config.h $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
1686+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/cilk2c/config.h $ $LastChangedBy: bradley $ $Rev: 1341 $ $Date$");
1687
1688 #include <limits.h>
1689
1690diff -Nur 5.4.2.2/cilk2c/constexpr.c current.Bug188/cilk2c/constexpr.c
1691--- 5.4.2.2/cilk2c/constexpr.c 2004-10-23 03:26:42.000000000 +0000
1692+++ current.Bug188/cilk2c/constexpr.c 2005-10-22 02:52:37.000000000 +0000
1693@@ -29,7 +29,7 @@
1694 #include "ast.h"
1695
1696 FILE_IDENTITY(ident,
1697- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/cilk2c/constexpr.c $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
1698+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/cilk2c/constexpr.c $ $LastChangedBy: bradley $ $Rev: 1341 $ $Date$");
1699
1700
1701 PRIVATE BasicType BasicTypeOfConstantValue(Node *type);
1702diff -Nur 5.4.2.2/cilk2c/container.c current.Bug188/cilk2c/container.c
1703--- 5.4.2.2/cilk2c/container.c 2004-10-23 03:26:45.000000000 +0000
1704+++ current.Bug188/cilk2c/container.c 2005-10-22 02:52:38.000000000 +0000
1705@@ -29,7 +29,7 @@
1706
1707 #include "ast.h"
1708 FILE_IDENTITY(ident,
1709- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/cilk2c/container.c $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
1710+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/cilk2c/container.c $ $LastChangedBy: bradley $ $Rev: 1341 $ $Date$");
1711
1712 typedef struct {
1713 NodeType typ;
1714diff -Nur 5.4.2.2/cilk2c/conversions.c current.Bug188/cilk2c/conversions.c
1715--- 5.4.2.2/cilk2c/conversions.c 2004-10-23 03:26:19.000000000 +0000
1716+++ current.Bug188/cilk2c/conversions.c 2005-10-22 02:52:37.000000000 +0000
1717@@ -31,7 +31,7 @@
1718 #include "ast.h"
1719
1720 FILE_IDENTITY(ident,
1721- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/cilk2c/conversions.c $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
1722+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/cilk2c/conversions.c $ $LastChangedBy: bradley $ $Rev: 2483 $ $Date$");
1723
1724 #include "conversions.h"
1725
1726@@ -476,9 +476,9 @@
1727 return;
1728 default:
1729 printf("Unrecognized to type\n");
1730- PrintNode(stdout, *node2p, 0);
1731+ DPN(*node2p);
1732 printf("\n");
1733- PrintNode(stdout, type2, 0);
1734+ DPN(type2);
1735 printf("\n");
1736 assert(FALSE);
1737 }
1738@@ -512,17 +512,17 @@
1739 return;
1740 default:
1741 printf("Unrecognized to type\n");
1742- PrintNode(stdout, *node2p, 0);
1743+ DPN(*node2p);
1744 printf("\n");
1745- PrintNode(stdout, type2, 0);
1746+ DPN(type2);
1747 printf("\n");
1748 assert(FALSE);
1749 }
1750 default:
1751 printf("Unrecognized from type\n");
1752- PrintNode(stdout, *node1p, 0);
1753+ DPN(*node1p);
1754 printf("\n");
1755- PrintNode(stdout, type1, 0);
1756+ DPN(type1);
1757 printf("\n");
1758 assert(FALSE);
1759 }
1760@@ -884,11 +884,16 @@
1761 * absence of const or volatile in the right operand." So
1762 * qualifiers on left must include all qualifiers on right.
1763 */
1764- TypeQual lcv = NodeTypeQuals(ltype) & (T_CONST | T_VOLATILE | T_RESTRICT),
1765- rcv = NodeTypeQuals(rtype) & (T_CONST | T_VOLATILE | T_RESTRICT);
1766-
1767- if ((lcv | rcv) != lcv)
1768- return FALSE;
1769+ if ((!tq_has_const(NodeTq(ltype))) && tq_has_const(NodeTq(rtype))) return FALSE;
1770+ if ((!tq_has_volatile(NodeTq(ltype))) && tq_has_volatile(NodeTq(rtype))) return FALSE;
1771+ if ((!tq_has_restrict(NodeTq(ltype))) && tq_has_restrict(NodeTq(rtype))) return FALSE;
1772+/* OLD CODE TO DO THAT: I Personally find the new code (above) to be much easier to read. -Bradley
1773+ * TypeQual lcv = NodeTypeQuals(ltype) & (T_CONST | T_VOLATILE | T_RESTRICT),
1774+ * rcv = NodeTypeQuals(rtype) & (T_CONST | T_VOLATILE | T_RESTRICT);
1775+ *
1776+ * if ((lcv | rcv) != lcv)
1777+ * return FALSE;
1778+*/
1779
1780 /*
1781 * type qualifiers okay at top-level; remove them and test
1782diff -Nur 5.4.2.2/cilk2c/conversions.h current.Bug188/cilk2c/conversions.h
1783--- 5.4.2.2/cilk2c/conversions.h 2004-10-23 03:26:20.000000000 +0000
1784+++ current.Bug188/cilk2c/conversions.h 2005-10-22 02:52:37.000000000 +0000
1785@@ -30,7 +30,7 @@
1786 #ifndef _CONVERSIONS_H_
1787 #define _CONVERSIONS_H_
1788 FILE_IDENTITY(conversions_h_ident,
1789- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/cilk2c/conversions.h $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
1790+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/cilk2c/conversions.h $ $LastChangedBy: bradley $ $Rev: 1341 $ $Date$");
1791
1792
1793 GLOBAL Node *UsualUnaryConversions(Node *node, Bool f_to_d);
1794diff -Nur 5.4.2.2/cilk2c/dataflow.h current.Bug188/cilk2c/dataflow.h
1795--- 5.4.2.2/cilk2c/dataflow.h 2004-10-23 03:26:19.000000000 +0000
1796+++ current.Bug188/cilk2c/dataflow.h 2005-10-22 02:52:37.000000000 +0000
1797@@ -30,7 +30,7 @@
1798 #define _DATAFLOW_H_
1799
1800 FILE_IDENTITY(dataflow_h_ident,
1801- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/cilk2c/dataflow.h $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
1802+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/cilk2c/dataflow.h $ $LastChangedBy: bradley $ $Rev: 2483 $ $Date$");
1803
1804 typedef unsigned long BitVector;
1805 #define MAX_BITVECTOR_LENGTH (sizeof(BitVector) * CHAR_BIT)
1806@@ -81,8 +81,8 @@
1807 GLOBAL List *RegisterVariables(Node *node, List *vars);
1808
1809 GLOBAL void PV(List *vars);
1810-GLOBAL int PrintVariables(FILE *out, List *vars);
1811-GLOBAL int PrintAnalysis(FILE *out, Node *node);
1812+GLOBAL int PrintVariables(GBUF *,List *vars);
1813+GLOBAL int PrintAnalysis(GBUF *,Node *node);
1814
1815 GLOBAL void AnalyzeLiveVariables(Node *root, List *vars);
1816 GLOBAL void AnalyzeReturnFlow(Node *root);
1817diff -Nur 5.4.2.2/cilk2c/elide.c current.Bug188/cilk2c/elide.c
1818--- 5.4.2.2/cilk2c/elide.c 2004-10-23 03:26:42.000000000 +0000
1819+++ current.Bug188/cilk2c/elide.c 2005-10-22 02:52:38.000000000 +0000
1820@@ -21,7 +21,7 @@
1821 #include <ast.h>
1822
1823 FILE_IDENTITY(ident,
1824- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/cilk2c/elide.c $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
1825+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/cilk2c/elide.c $ $LastChangedBy: bradley $ $Rev: 2448 $ $Date$");
1826
1827
1828 PRIVATE Node *ElideNode(Node *node);
1829@@ -245,9 +245,7 @@
1830 u->args = ElideList(u->args);
1831 u->returns = ElideNode(u->returns);
1832
1833- if (u->tq & T_PROCEDURE) {
1834- u->tq &= ~T_PROCEDURE; /* Get rid of the cilk keyword*/
1835- }
1836+ u->tq = tq_remove_procedure(u->tq); /* Get rid of the cilk keyword*/
1837
1838 return node;
1839 }
1840@@ -375,7 +373,7 @@
1841 assert(decl->typ == Decl);
1842 fdcl = decl->u.decl.type;
1843 assert(fdcl->typ == Fdcl);
1844- fdcl->u.fdcl.tq &= ~(T_INLET | T_PROCEDURE | T_CILK_WHERE_AM_I_DECL_QUALS);
1845+ fdcl->u.fdcl.tq = tq_remove_inlet(tq_remove_procedure(tq_remove_cilk_where_am_i_decl_quals(fdcl->u.fdcl.tq)));
1846
1847 u->decl = ElideNode(u->decl);
1848 u->body = ElideNode(u->body);
1849@@ -406,10 +404,10 @@
1850 if (!node)
1851 return NULL;
1852
1853+ /* Get rid of cilk keyword. */
1854 if (node->typ == Proc &&
1855- node->u.proc.decl->u.decl.type->typ == Fdcl &&
1856- node->u.proc.decl->u.decl.type->u.fdcl.tq & T_PROCEDURE) {
1857- node->u.proc.decl->u.decl.type->u.fdcl.tq &= ~T_PROCEDURE;
1858+ node->u.proc.decl->u.decl.type->typ == Fdcl) {
1859+ node->u.proc.decl->u.decl.type->u.fdcl.tq = tq_remove_procedure(node->u.proc.decl->u.decl.type->u.fdcl.tq);
1860 }
1861 result = List1(ElideNode(node));
1862
1863diff -Nur 5.4.2.2/cilk2c/gbuf.c current.Bug188/cilk2c/gbuf.c
1864--- 5.4.2.2/cilk2c/gbuf.c 1970-01-01 00:00:00.000000000 +0000
1865+++ current.Bug188/cilk2c/gbuf.c 2005-10-22 02:52:37.000000000 +0000
1866@@ -0,0 +1,103 @@
1867+#include <basics.h>
1868+//#include <assert.h>
1869+//#include <stdio.h>
1870+//#include <stdlib.h>
1871+//#include <string.h>
1872+
1873+GLOBAL int gbprintf(GBUF *gb, const char *format, ...) {
1874+ int r;
1875+ va_list ap;
1876+ va_start(ap, format);
1877+ r=gb->vfprintf_fun(gb->state, format, ap);
1878+ va_end(ap);
1879+ return r;
1880+}
1881+GLOBAL int gbputs (const char *string, GBUF *gb) {
1882+ return gb->fputs_fun(string, gb->state);
1883+}
1884+
1885+/*********************************************
1886+ * functions for creating output to a string.
1887+ *********************************************/
1888+
1889+struct mbuffer {
1890+ char *string;
1891+ char *tail;
1892+ int n_chars_left; /* Number of characters left in the buffer (including the tailing \0) */
1893+};
1894+
1895+PRIVATE void init_mbuffer (char *array, int arraysize, struct mbuffer *b) {
1896+ b->string=array;
1897+ b->tail =array;
1898+ assert(arraysize>0);
1899+ b->n_chars_left=arraysize;
1900+ array[0]=0;
1901+}
1902+
1903+/* Act like fputs. */
1904+PRIVATE int add_string_to_mbuffer(const char *string, void *state) {
1905+ struct mbuffer *b=state;
1906+ int l = strlen(string);
1907+ if (l+1>b->n_chars_left) return -1;
1908+ strcpy(b->tail, string); /* Don't use strncpy, because that fills in the whole tail of the dest with nulls. Slow and error prone. */
1909+ b->tail+=l;
1910+ b->n_chars_left-=l;
1911+ return l;
1912+}
1913+
1914+PRIVATE void free_mbuffer (void *s) {
1915+ free(s);
1916+}
1917+
1918+GLOBAL int vfprintf_to_mbuffer (void *state, const char *format, va_list ap) {
1919+ struct mbuffer *mb = state;
1920+ int oldavail = mb->n_chars_left;
1921+ int n_written = vsnprintf(mb->tail, oldavail, format, ap);
1922+ if (n_written>=oldavail || n_written<0) {
1923+ mb->tail[oldavail-1]=0;
1924+ mb->tail+=oldavail;
1925+ mb->n_chars_left=0;
1926+ return -1;
1927+ } else {
1928+ mb->tail+=n_written;
1929+ mb->n_chars_left-=n_written;
1930+ return n_written;
1931+ }
1932+}
1933+
1934+
1935+GLOBAL GBUF* make_string_gbuf (char *array, int arraysize) {
1936+ GBUF *result = malloc(sizeof(*result));
1937+ struct mbuffer *mb = malloc(sizeof(*mb));
1938+ result->state = mb;
1939+ result->fputs_fun = add_string_to_mbuffer;
1940+ result->vfprintf_fun = vfprintf_to_mbuffer;
1941+ result->free_state_fun = free_mbuffer;
1942+ init_mbuffer(array, arraysize, mb);
1943+ return result;
1944+}
1945+
1946+PRIVATE int add_string_to_file (const char *string, void *state) {
1947+ FILE *f=state;
1948+ return fputs(string, f);
1949+}
1950+
1951+PRIVATE int vfprintf_to_file (void *state, const char *format, va_list ap) {
1952+ FILE *stream=state;
1953+ return vfprintf(stream, format, ap);
1954+}
1955+
1956+GLOBAL GBUF* make_file_gbuf (FILE *f) {
1957+ GBUF *result = malloc(sizeof(*result));
1958+ result->state = f;
1959+ result->fputs_fun = add_string_to_file;
1960+ result->vfprintf_fun = vfprintf_to_file;
1961+ result->free_state_fun = 0;
1962+ return result;
1963+}
1964+
1965+GLOBAL void free_gbuf (GBUF *gb) {
1966+ if (gb->free_state_fun) gb->free_state_fun(gb->state);
1967+ free(gb);
1968+}
1969+
1970diff -Nur 5.4.2.2/cilk2c/gbuf.h current.Bug188/cilk2c/gbuf.h
1971--- 5.4.2.2/cilk2c/gbuf.h 1970-01-01 00:00:00.000000000 +0000
1972+++ current.Bug188/cilk2c/gbuf.h 2005-10-22 02:52:37.000000000 +0000
1973@@ -0,0 +1,18 @@
1974+#include <stdarg.h>
1975+#include <stdio.h>
1976+
1977+typedef struct generalized_buffer {
1978+ void *state;
1979+ int (*fputs_fun)(const char *string, void *state);
1980+ int (*vfprintf_fun)(void *state, const char *format, va_list);
1981+ void (*free_state_fun)(void*);
1982+} GBUF;
1983+
1984+GLOBAL int gbprintf(GBUF *gb, const char *format, ...) __attribute__((format (printf, 2, 3)));
1985+GLOBAL int gbputs (const char *string, GBUF *gb);
1986+
1987+GLOBAL GBUF* make_string_gbuf (char *array, int arraysize);
1988+GLOBAL GBUF* make_file_gbuf (FILE *f);
1989+GLOBAL void free_gbuf(GBUF*);
1990+
1991+#define WITH_FILE_GBUF(gb,file,stmt) ({ GBUF *gb = make_file_gbuf(file); stmt; free_gbuf(gb); })
1992diff -Nur 5.4.2.2/cilk2c/hint.c current.Bug188/cilk2c/hint.c
1993--- 5.4.2.2/cilk2c/hint.c 2004-10-23 03:26:19.000000000 +0000
1994+++ current.Bug188/cilk2c/hint.c 2005-10-22 02:52:37.000000000 +0000
1995@@ -38,7 +38,7 @@
1996 #include "ast.h"
1997
1998 FILE_IDENTITY(ident,
1999- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/cilk2c/hint.c $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
2000+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/cilk2c/hint.c $ $LastChangedBy: bradley $ $Rev: 2454 $ $Date$");
2001
2002
2003 PRIVATE Node *HintNode(Node *node);
2004@@ -349,7 +349,7 @@
2005 u->asmdecl = HintNode(u->asmdecl);
2006
2007 /* global variables are a bad idea, especially in Cilk */
2008- if (!(NodeStorageClass(node) == T_EXTERN) &&
2009+ if (!tq_has_extern(NodeStorageClass(node)) &&
2010 IsTroublesomeDeclaration(node)) {
2011 HintCoord(node->coord,
2012 "declaration of global variable `%s'", u->name);
2013@@ -418,10 +418,10 @@
2014 assert(node->typ = Decl);
2015
2016 type = NodeDataTypeSuperior(node);
2017- return (((NodeDeclLocation(node) == T_TOP_DECL)
2018- || (NodeTq(node) == T_STATIC))
2019+ return ((tq_has_top_decl(NodeDeclLocation(node))
2020+ || tq_has_static(NodeTq(node)))
2021 &&
2022- !(NodeTq(node) & T_CILKSAFE) &&
2023+ !tq_has_cilksafe(NodeTq(node)) &&
2024 !(NodeIsConstQual(type)) &&
2025 !(NodeIsConstQual(GetShallowBaseType(type))) &&
2026 !DeclIsTypedef(node) &&
2027diff -Nur 5.4.2.2/cilk2c/initializer.c current.Bug188/cilk2c/initializer.c
2028--- 5.4.2.2/cilk2c/initializer.c 2004-10-23 03:26:42.000000000 +0000
2029+++ current.Bug188/cilk2c/initializer.c 2005-10-22 02:52:38.000000000 +0000
2030@@ -30,7 +30,7 @@
2031 #include "ast.h"
2032
2033 FILE_IDENTITY(ident,
2034- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/cilk2c/initializer.c $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
2035+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/cilk2c/initializer.c $ $LastChangedBy: bradley $ $Rev: 2483 $ $Date$");
2036
2037 #include "conversions.h"
2038 #include "initializer.h"
2039@@ -327,7 +327,7 @@
2040 SyntaxErrorCoord(decl->coord,
2041 "Expression cannot have an initializer \"%s\"",
2042 decl->u.decl.name);
2043- PrintNode(stdout, dtype, 0);
2044+ DPN(dtype);
2045 printf("\n");
2046 return NULL;
2047 }
2048diff -Nur 5.4.2.2/cilk2c/main.c current.Bug188/cilk2c/main.c
2049--- 5.4.2.2/cilk2c/main.c 2004-10-23 03:26:45.000000000 +0000
2050+++ current.Bug188/cilk2c/main.c 2005-10-22 02:52:38.000000000 +0000
2051@@ -31,7 +31,7 @@
2052 #include "ast.h"
2053
2054 FILE_IDENTITY(ident,
2055- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/cilk2c/main.c $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
2056+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/cilk2c/main.c $ $LastChangedBy: bradley $ $Rev: 2483 $ $Date$");
2057
2058 #include <errno.h>
2059 #include "stringParse.h"
2060@@ -614,7 +614,7 @@
2061 PLURAL(Warnings));
2062 }
2063 if (PrintAST) {
2064- PrintList(stdout, Program, -1);
2065+ fPrintList(stdout, Program, -1);
2066 fprintf(stdout, "\n");
2067 }
2068 /* cleanup */
2069diff -Nur 5.4.2.2/cilk2c/operators.c current.Bug188/cilk2c/operators.c
2070--- 5.4.2.2/cilk2c/operators.c 2004-10-23 03:26:45.000000000 +0000
2071+++ current.Bug188/cilk2c/operators.c 2005-10-22 02:52:38.000000000 +0000
2072@@ -29,7 +29,7 @@
2073 #include "ast.h"
2074
2075 FILE_IDENTITY(ident,
2076- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/cilk2c/operators.c $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
2077+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/cilk2c/operators.c $ $LastChangedBy: bradley $ $Rev: 2483 $ $Date$");
2078
2079
2080 GLOBAL OpEntry Operator[MAX_OPERATORS];
2081@@ -158,7 +158,7 @@
2082 return Operator[op].text;
2083 }
2084
2085-GLOBAL int PrintOp(FILE *out, OpType op)
2086+GLOBAL int PrintOp(GBUF *gb, OpType op)
2087 {
2088 OpEntry *operator = &Operator[op];
2089
2090@@ -168,8 +168,9 @@
2091 fprintf(stderr, "unknown operator %d\n", op);
2092 FAIL("");
2093 }
2094- fputs(operator->text, out);
2095+ gbputs(operator->text, gb);
2096 return strlen(operator->text);
2097+
2098 }
2099
2100 GLOBAL int OpPrecedence(NodeType typ, OpType op, Bool *left_assoc)
2101diff -Nur 5.4.2.2/cilk2c/output.c current.Bug188/cilk2c/output.c
2102--- 5.4.2.2/cilk2c/output.c 2004-10-23 03:26:18.000000000 +0000
2103+++ current.Bug188/cilk2c/output.c 2005-10-22 02:54:14.000000000 +0000
2104@@ -187,7 +187,7 @@
2105 #include "ast.h"
2106
2107 FILE_IDENTITY(ident,
2108- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/cilk2c/output.c $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
2109+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/cilk2c/output.c $ $LastChangedBy: bradley $ $Rev: 2540 $ $Date$");
2110
2111 #include <ctype.h>
2112
2113@@ -207,10 +207,10 @@
2114
2115 typedef struct {
2116 char prev_char; /* what is the previous character written? Use this to determine if whitespace may need to be added. */
2117- FILE *f;
2118 Coord curr;
2119 int block;
2120 int block_indents[MAX_NESTED_SCOPES];
2121+ GBUF *gb;
2122 } OutputContext;
2123
2124 PRIVATE void SetOutputCoord(OutputContext *out, Coord *pcoord);
2125@@ -229,6 +229,9 @@
2126 PRIVATE Bool IsSourceExpression(Node *node);
2127 PRIVATE int Precedence(Node *node, Bool *left_assoc);
2128
2129+PRIVATE void output_prim_type (OutputContext *out, Node *type, char *lastc, Bool print_coords);
2130+PRIVATE void OutputTQ (OutputContext *out, TypeQual tq, Coord *coord);
2131+
2132 PRIVATE void OutputExpr(OutputContext *out, Node *node);
2133 PRIVATE void OutputInnerExpr(OutputContext *out, Node *node, int enclosing_precedence, Context context);
2134 PRIVATE void OutputPartialType(OutputContext *out, Context context,
2135@@ -240,14 +243,14 @@
2136 PRIVATE void OutputAsmDecl(OutputContext *out, Node *a);
2137 PRIVATE int OutputDecl(OutputContext *out, DeclKind k, Node *node);
2138 PRIVATE void OutputDeclList(OutputContext *out, DeclKind k, List *lst);
2139-PRIVATE void OutputSUE(OutputContext *out, SUEtype *sue, Bool elaboratedp);
2140+PRIVATE void OutputSUE(OutputContext *out, SUEtype *sue, Bool elaboratedp, List *attributes);
2141 PRIVATE void OutputTextNode(OutputContext *out, Node *node);
2142
2143 GLOBAL void OutputProgram(FILE *outfile, List *program)
2144 {
2145 OutputContext out;
2146
2147- out.f = outfile;
2148+ out.gb = make_file_gbuf(outfile);
2149 out.curr = UnknownCoord;
2150 out.block = 0;
2151 out.block_indents[0] = 0;
2152@@ -255,6 +258,7 @@
2153
2154 OutputDeclList(&out, TopDecl, program);
2155 OutCh(&out, '\n');
2156+ free_gbuf(out.gb);
2157 }
2158
2159 /** This was added to work with parsing from a string.
2160@@ -263,7 +267,7 @@
2161 GLOBAL void OutputStmtList(FILE *outfile, List *myStmtList)
2162 {
2163 OutputContext out;
2164- out.f = outfile;
2165+ out.gb = make_file_gbuf(outfile);
2166 out.curr = UnknownCoord;
2167 out.block = 0;
2168 out.block_indents[0] = 0;
2169@@ -281,7 +285,7 @@
2170
2171 PRIVATE void SetOutputCoord(OutputContext *out, Coord *pcoord)
2172 {
2173- if (IsUnknownCoord(*pcoord))
2174+ if (IsUnknownCoord(*pcoord) || IsDontPrintCoord(out->curr))
2175 return; /* *pcoord == UnknownCoord, so ignore */
2176
2177 /* First, set line */
2178@@ -289,8 +293,8 @@
2179 if (out->curr.offset != 0)
2180 OutNewLine(out);
2181 if (!FormatReadably)
2182- fprintf(out->f, "# %d \"%s\"\n", pcoord->line,
2183- FileNames[pcoord->file]);
2184+ gbprintf(out->gb, "# %d \"%s\"\n", pcoord->line,
2185+ FileNames[pcoord->file]);
2186 out->curr.file = pcoord->file;
2187 out->curr.line = pcoord->line;
2188 out->curr.offset = 0;
2189@@ -304,7 +308,7 @@
2190 if (out->curr.offset != 0)
2191 OutNewLine(out);
2192 if (!FormatReadably)
2193- fprintf(out->f, "# %d\n", pcoord->line);
2194+ gbprintf(out->gb, "# %d\n", pcoord->line);
2195 out->curr.line = pcoord->line;
2196 out->curr.offset = 0;
2197 }
2198@@ -341,7 +345,7 @@
2199 }
2200
2201 PRIVATE inline void OutNewLine(OutputContext *out) {
2202- fputc('\n', out->f);
2203+ gbputs("\n", out->gb);
2204 ++out->curr.line;
2205 out->curr.offset=0;
2206 out->prev_char = '\n';
2207@@ -349,7 +353,7 @@
2208
2209 PRIVATE inline void OutCh(OutputContext *out, int ch)
2210 {
2211- fputc(ch, out->f);
2212+ gbprintf(out->gb, "%c", ch);
2213 ++out->curr.offset;
2214 out->prev_char = ch;
2215 }
2216@@ -357,7 +361,8 @@
2217 PRIVATE inline void OutS(OutputContext *out, const char *s)
2218 {
2219 int len = strlen(s);
2220- fputs(s, out->f);
2221+ int r = gbputs(s, out->gb);
2222+ assert(r>=0);
2223 out->curr.offset += len;
2224 out->prev_char = s[len-1];
2225 }
2226@@ -462,18 +467,18 @@
2227 /* Hacks to deal with the designated initializer and array initializer syntax */
2228 if (node->u.binop.op == DESIGNATED_INITIALIZER) {
2229 SetOutputCoord(out, &node->coord);
2230- fputs(".", out->f);
2231+ gbputs(".", out->gb);
2232 OutOffset(out, 1);
2233 } else if (node->u.binop.op == ARRAY_LABELED_INITIALIZER) {
2234 SetOutputCoord(out, &node->coord);
2235- fputs("[", out->f);
2236+ gbputs("[", out->gb);
2237 OutOffset(out, 1);
2238 }
2239
2240 OutputInnerExpr(out, node->u.binop.left, my_precedence, Left);
2241
2242 SetOutputCoord(out, &node->coord);
2243- OutOffset(out, PrintOp(out->f, node->u.binop.op));
2244+ OutOffset(out, PrintOp(out->gb, node->u.binop.op));
2245
2246 OutputInnerExpr(out, node->u.binop.right, my_precedence, Right);
2247 }
2248@@ -500,7 +505,7 @@
2249 case PREDEC:
2250 case PREINC:
2251 SetOutputCoord(out, &node->coord);
2252- OutOffset(out, PrintOp(out->f, node->u.unary.op));
2253+ OutOffset(out, PrintOp(out->gb, node->u.unary.op));
2254 OutputInnerExpr(out, node->u.unary.expr, my_precedence, Right);
2255 break;
2256
2257@@ -508,12 +513,12 @@
2258 case POSTINC:
2259 OutputInnerExpr(out, node->u.unary.expr, my_precedence, Left);
2260 SetOutputCoord(out, &node->coord);
2261- OutOffset(out, PrintOp(out->f, node->u.unary.op));
2262+ OutOffset(out, PrintOp(out->gb, node->u.unary.op));
2263 break;
2264
2265 default:
2266 SetOutputCoord(out, &node->coord);
2267- OutOffset(out, PrintOp(out->f, node->u.unary.op));
2268+ OutOffset(out, PrintOp(out->gb, node->u.unary.op));
2269 OutputInnerExpr(out, node->u.unary.expr, my_precedence, Right);
2270 break;
2271 }
2272@@ -575,6 +580,110 @@
2273 OutCh(out, ')');
2274 }
2275
2276+PRIVATE void output_constant(OutputContext *out, Node *c, Bool with_name)
2277+{
2278+ if (with_name)
2279+ switch (c->u.Const.type->typ) {
2280+ case Prim:
2281+ output_prim_type(out, c->u.Const.type, NULL, TRUE);
2282+ OutS(out, " ");
2283+ OutOffset(out, 1);
2284+ break;
2285+ /* Used for strings */
2286+ case Adcl:
2287+ assert(c->u.Const.type->u.adcl.type->typ == Prim);
2288+ OutS(out, "array of ");
2289+ OutOffset(out, 9);
2290+ output_prim_type(out, c->u.Const.type->u.adcl.type, 0, TRUE);
2291+ OutS(out, " ");
2292+ OutOffset(out, 1);
2293+ break;
2294+ default:
2295+ OutS(out, "??? ");
2296+ }
2297+ switch (c->u.Const.type->typ) {
2298+ case Prim:
2299+ switch (c->u.Const.type->u.prim.basic) {
2300+ case Sint:
2301+ OutOffset(out, gbprintf(out->gb, "%d", c->u.Const.value.i));
2302+ return;
2303+ /*Manish 2/3 hack to print pointer constants */
2304+ case Uint:
2305+ OutOffset(out, gbprintf(out->gb, "%uU", c->u.Const.value.u));
2306+ return;
2307+ case Slong:
2308+ OutOffset(out, gbprintf(out->gb, "%ldL", c->u.Const.value.l));
2309+ return;
2310+ case Ulong:
2311+ OutOffset(out, gbprintf(out->gb, "%luUL", c->u.Const.value.ul));
2312+ return;
2313+ case Float:
2314+ OutOffset(out, print_float(out->gb, c->u.Const.value.f));
2315+ return;
2316+ case Double:
2317+ OutOffset(out, print_double(out->gb, c->u.Const.value.d));
2318+ return;
2319+ case Char:
2320+ case Schar:
2321+ case Uchar:
2322+ OutOffset(out, PrintChar(out->gb, c->u.Const.value.i));
2323+ return;
2324+ default:
2325+ Fail(__FILE__, __LINE__, "");
2326+ return;
2327+ }
2328+
2329+ /* Manish 2/3 Print Constant Pointers */
2330+ case Ptr:
2331+ OutOffset(out, gbprintf(out->gb, "%u", c->u.Const.value.u));
2332+ return;
2333+ /* Used for strings */
2334+ case Adcl:
2335+ OutOffset(out, PrintString(out->gb, c->u.Const.value.s));
2336+ return;
2337+
2338+ default:
2339+ FAIL("Unrecognized constant type");
2340+ }
2341+}
2342+
2343+PRIVATE void output_prim_type (OutputContext *out, Node *type, char *lastc, Bool print_coords)
2344+{
2345+ const char *tn=TypeName(type->u.prim.basic);
2346+ int tn_len=strlen(tn);
2347+ assert(type);
2348+ assert(type->typ == Prim);
2349+ OutputTQ(out, tq_remove_sue_elaborated(type->u.prim.tq), print_coords? &type->coord : 0); /* Don't print sue_elaborated */
2350+ if (print_coords) SetOutputCoord(out, &type->coord);
2351+ OutS(out, tn);
2352+ if (lastc)
2353+ *lastc = tn[tn_len-1];
2354+ return;
2355+}
2356+
2357+GLOBAL void output_prim_type_to_GBUF(GBUF *gb, Node *type, char *lastc) {
2358+ OutputContext out;
2359+ out.prev_char=' ';
2360+ out.curr=DontPrintCoord;
2361+ out.block = 0;
2362+ out.block_indents[0]=0;
2363+ out.gb = gb;
2364+ return output_prim_type(&out, type, lastc, FALSE);
2365+}
2366+
2367+GLOBAL void output_constant_to_GBUF(GBUF * gb, Node *node, Bool with_name) {
2368+ /* Make a dummy outputcontext. This function is only called through the print_ast methods (and possibly for error messages)
2369+ * so the exact coordinate is not very important. */
2370+ OutputContext out;
2371+ out.prev_char=' ';
2372+ out.curr=UnknownCoord;
2373+ out.block = 0;
2374+ out.block_indents[0]=0;
2375+ out.gb = gb;
2376+ output_constant(&out, node, with_name);
2377+}
2378+
2379+
2380 PRIVATE void OutputInnerExpr(OutputContext *out, Node *node,
2381 int enclosing_precedence, Context context)
2382 {
2383@@ -636,7 +745,7 @@
2384 if (node->u.Const.text)
2385 OutS(out, node->u.Const.text);
2386 else
2387- OutOffset(out, PrintConstant(out->f, node, FALSE));
2388+ output_constant(out, node, FALSE);
2389 break;
2390 case Binop:
2391 OutputBinop(out, node, my_precedence);
2392@@ -706,7 +815,7 @@
2393 break;
2394 default:
2395 fprintf(stderr, "Internal error: unexpected node (%s:%d)\n", __FILE__, __LINE__);
2396- PrintNode(stderr, node, 2);
2397+ fPrintNode(stderr, node, 2);
2398 UNREACHABLE;
2399 }
2400
2401@@ -719,18 +828,131 @@
2402 OutputInnerExpr(out, node, 0, Left);
2403 }
2404
2405+GLOBAL int add_string_to_OutputContext (const char *string, void *output_context_v) {
2406+ OutputContext *out = output_context_v;
2407+ OutS(out, string);
2408+ return 1;
2409+}
2410+
2411+GLOBAL void TQtoGBUF (GBUF *gb, TypeQual tq) {
2412+ OutputContext out;
2413+ out.prev_char=' ';
2414+ out.curr=DontPrintCoord;
2415+ out.block = 0;
2416+ out.block_indents[0]=0;
2417+ out.gb = gb;
2418+ OutputTQ (&out, tq, 0);
2419+}
2420+
2421 PRIVATE void OutputTQ (OutputContext *out, TypeQual tq, Coord *coord)
2422 /* Print the type qualifier at coord. If the type qualifier is empty, then nothing is printed. */
2423 {
2424- char tmp[256];
2425- int len;
2426- TQtoText(tmp, tq);
2427- len = strlen(tmp);
2428- if (len>0) {
2429- if (coord)
2430- SetOutputCoord(out, coord);
2431- OutS(out, tmp);
2432+ if (tq_has_anything(tq) && coord) {
2433+ SetOutputCoord(out, coord);
2434+ }
2435+#define ASF(_string) OutS(out, _string)
2436+ if (tq_has_extension(tq)) {
2437+ ASF("__extension__ ");
2438+ }
2439+
2440+ /* storage class */
2441+ if (tq_has_typedef(tq))
2442+ ASF("typedef ");
2443+ else if (tq_has_extern(tq))
2444+ ASF("extern ");
2445+ else if (tq_has_static(tq))
2446+ ASF("static ");
2447+ else if (tq_has_auto(tq))
2448+ ASF("auto ");
2449+ else if (tq_has_register(tq))
2450+ ASF("register ");
2451+ else {
2452+ ; /* no explicit storage class */
2453+ }
2454+
2455+ /* location */
2456+ if (tq_has_top_decl(tq))
2457+ ASF("top_decl ");
2458+ else if (tq_has_block_decl(tq))
2459+ ASF("block_decl ");
2460+ else if (tq_has_formal_decl(tq))
2461+ ASF("formal_decl ");
2462+ else if (tq_has_su_decl(tq))
2463+ ASF("su_decl ");
2464+ else if (tq_has_enum_decl(tq))
2465+ ASF("enum_decl ");
2466+ else {
2467+ ; /* no explicit location */
2468+ }
2469+
2470+ if (tq_has_redundant_external_decl(tq))
2471+ ASF("redundant_extern ");
2472+
2473+ if (tq_has_shared(tq))
2474+ ASF("shared ");
2475+ if (tq_has_private(tq))
2476+ ASF("private ");
2477+
2478+ if (tq_has_inline(tq)) {
2479+ #ifdef inline
2480+/* This hacking is the standard CPP idiom for stringifying the result of a macro expansion.
2481+ * In this case, the macro inline might be defined in ../config.h as
2482+ * #define inline __inline
2483+ * and we want to get the string "__inline"
2484+ * Suppose we did
2485+ * STR(inline)
2486+ * that would expand to
2487+ * #inline
2488+ * which would expand to
2489+ * "inline"
2490+ * which is not what we want. If we do
2491+ * XSTR(inline)
2492+ * that expands to
2493+ * STR(inline)
2494+ * and then the args are expanded to give
2495+ * STR(__inline)
2496+ * and then the STR macro is expanded to give
2497+ * #__inline
2498+ * finally yielding
2499+ * "__inline"
2500+ * The whole point of this hack is to produce a string for "inline" that will work with the
2501+ * C compiler we are using,as determined by ../configure and stored in ../config.h
2502+ */
2503+#define STR(S) #S
2504+#define XSTR(S) STR(S)
2505+ ASF(XSTR(inline) " "); /* Use the system-specific inline from config.h */
2506+ #else
2507+ ASF("inline ");
2508+ #endif
2509+ }
2510+ if (tq_has_const(tq))
2511+ ASF("const ");
2512+ if (tq_has_volatile(tq))
2513+ ASF("volatile ");
2514+ if (tq_has_restrict(tq))
2515+ ASF("__restrict ");
2516+ if (tq_has_complex(tq))
2517+ ASF("__complex__ ");
2518+ if (tq_has_nooutput(tq)) {
2519+ ASF("__nooutput__ ");
2520+ }
2521+ if (tq_has_cilkonly(tq)) {
2522+ ASF("__cilkonly__ ");
2523+ }
2524+ if (tq_has_cilksafe(tq)) {
2525+ ASF("__cilksafe__ ");
2526+ }
2527+ if (tq_has_sue_elaborated(tq))
2528+ ASF("sue_elaborated ");
2529+ if (tq_has_procedure(tq))
2530+ ASF("cilk ");
2531+ if (tq_has_inlet(tq))
2532+ ASF("inlet ");
2533+
2534+ if (tq.attributes) {
2535+ OutputAttribs(out, tq.attributes);
2536 }
2537+
2538 }
2539
2540 /*
2541@@ -752,9 +974,8 @@
2542 */
2543 case Prim:
2544 if (context == Left) {
2545- SetOutputCoord(out, &node->coord);
2546- OutputTQ(out, sc, 0);
2547- OutOffset(out, PrintPrimType(out->f, node, &out->prev_char));
2548+ OutputTQ(out, sc, &node->coord);
2549+ output_prim_type(out, node, &out->prev_char, TRUE);
2550 }
2551 /* no action in Right context */
2552 break;
2553@@ -775,8 +996,8 @@
2554 if (context == Left) {
2555 SetOutputCoord(out, &node->coord);
2556 OutputTQ(out, sc, 0);
2557- OutputTQ(out, node->u.sdcl.tq & (unsigned int) ~T_SUE_ELABORATED, 0);
2558- OutputSUE(out, node->u.sdcl.type, SUE_ELABORATED(node->u.sdcl.tq));
2559+ OutputTQ(out, (TypeQual){tq_remove_sue_elaborated(node->u.sdcl.tq).tq, 0}, 0); /* Don't print the attributes here. or sue_elaborated at all */
2560+ OutputSUE(out, node->u.sdcl.type, tq_has_sue_elaborated(node->u.sdcl.tq), node->u.sdcl.tq.attributes);
2561 }
2562 /* no action in Right context */
2563 break;
2564@@ -796,8 +1017,8 @@
2565 SetOutputCoord(out, &node->coord);
2566 OutCh(out, '*');
2567 /* don't output "cilk" or "inlet" as keyword */
2568- NodeRemoveTq(node, T_PROCEDURE);
2569- NodeRemoveTq(node, T_INLET);
2570+ NodeUpdateTq(node, tq_remove_procedure);
2571+ NodeUpdateTq(node, tq_remove_inlet);
2572 OutputTQ(out, node->u.ptr.tq, 0);
2573 } else {
2574 if (IS_ARRAY_OR_FUNC(node->u.ptr.type))
2575@@ -823,8 +1044,8 @@
2576 case Fdcl:
2577 if (context == Left) {
2578 /* don't output "cilk" or "inlet" as keyword */
2579- NodeRemoveTq(node, T_PROCEDURE);
2580- NodeRemoveTq(node, T_INLET);
2581+ NodeUpdateTq(node, tq_remove_procedure);
2582+ NodeUpdateTq(node, tq_remove_inlet);
2583 OutputTQ(out, node->u.fdcl.tq, &node->coord);
2584 OutputPartialType(out, context, node->u.fdcl.returns, sc);
2585 } else {
2586@@ -839,12 +1060,12 @@
2587
2588 default:
2589 fprintf(stderr, "Internal error: unexpected node (%s:%d)\n", __FILE__, __LINE__);
2590- PrintNode(stderr, node, 2);
2591+ fPrintNode(stderr, node, 2);
2592 UNREACHABLE;
2593 }
2594 }
2595
2596-PRIVATE void OutputSUE(OutputContext *out, SUEtype *sue, Bool elaboratedp)
2597+PRIVATE void OutputSUE(OutputContext *out, SUEtype *sue, Bool elaboratedp, List *attributes)
2598 {
2599
2600 assert(sue != NULL);
2601@@ -863,6 +1084,9 @@
2602 UNREACHABLE;
2603 }
2604
2605+ if (attributes) OutputAttribs(out, attributes);
2606+
2607+
2608 if (sue->name) {
2609 OutCh(out, ' ');
2610 OutS(out, sue->name);
2611@@ -913,17 +1137,24 @@
2612 assert(node->typ == Decl);
2613
2614 /* do not output __nooutput__ declarations */
2615- if (node->u.decl.tq & T_NOOUTPUT)
2616+ if (tq_has_nooutput(node->u.decl.tq))
2617 return 0;
2618
2619- if (node->u.decl.tq & T_EXTENSION) {
2620- SetOutputCoord(out, &node->coord);
2621+ SetOutputCoord(out, &node->coord);
2622+
2623+ if (tq_has_extension(node->u.decl.tq)) {
2624 OutS(out, "__extension__");
2625 }
2626
2627 if (k != EnumConstDecl) {
2628- int sc = NodeStorageClass(node);
2629- OutputPartialType(out, Left, node->u.decl.type, sc);
2630+ TypeQual sc = NodeStorageClass(node);
2631+ List *attribs = NodeDeclTq(node).attributes;
2632+ OutputTQ(out, sc, &node->coord);
2633+ if (attribs) OutputAttribs(out, attribs);
2634+ OutputPartialType(out, Left, node->u.decl.type, EMPTY_TQ);
2635+
2636+ if (node->u.decl.attribs)
2637+ OutputAttribs(out, node->u.decl.attribs);
2638
2639 if (node->u.decl.name) {
2640 SetOutputCoord(out, &node->coord);
2641@@ -931,12 +1162,14 @@
2642 OutCh(out, ' ');
2643 OutS(out, node->u.decl.name);
2644 }
2645- OutputPartialType(out, Right, node->u.decl.type, sc);
2646+
2647+ OutputPartialType(out, Right, node->u.decl.type, EMPTY_TQ);
2648 } else {
2649 SetOutputCoord(out, &node->coord);
2650 OutS(out, node->u.decl.name);
2651+ if (node->u.decl.attribs)
2652+ OutputAttribs(out, node->u.decl.attribs);
2653 }
2654-
2655 switch (k) {
2656 case SUFieldDecl:
2657 if (node->u.decl.bitsize != NULL) {
2658@@ -945,8 +1178,6 @@
2659 }
2660 if (node->u.decl.asmdecl)
2661 OutputAsmDecl(out, node->u.decl.asmdecl);
2662- if (node->u.decl.attribs)
2663- OutputAttribs(out, node->u.decl.attribs);
2664 break;
2665
2666 case TopDecl:
2667@@ -954,8 +1185,6 @@
2668 case EnumConstDecl:
2669 if (node->u.decl.asmdecl)
2670 OutputAsmDecl(out, node->u.decl.asmdecl);
2671- if (node->u.decl.attribs)
2672- OutputAttribs(out, node->u.decl.attribs);
2673 if (IsSourceExpression(node->u.decl.init)) {
2674 OutCh(out, '=');
2675 OutputExpr(out, node->u.decl.init);
2676@@ -965,8 +1194,6 @@
2677 case FormalDecl:
2678 if (node->u.decl.asmdecl)
2679 OutputAsmDecl(out, node->u.decl.asmdecl);
2680- if (node->u.decl.attribs)
2681- OutputAttribs(out, node->u.decl.attribs);
2682 break;
2683 }
2684 return 1;
2685@@ -974,7 +1201,8 @@
2686
2687 PRIVATE void OutputAttribs(OutputContext *out, List *attribs)
2688 {
2689- OutS(out, " __attribute__((");
2690+ if (out->prev_char!=' ') OutCh(out, ' ');
2691+ OutS(out, "__attribute__((");
2692 while (attribs != NULL) {
2693 Node *attrib = FirstItem(attribs);
2694
2695@@ -1151,7 +1379,7 @@
2696 case Asm:
2697 SetOutputCoordStmt(out, &node->coord);
2698 OutS(out, "__asm__");
2699- if (node->u.Asm.tq) {
2700+ if (tq_has_anything(node->u.Asm.tq)) {
2701 OutCh(out, ' ');
2702 OutputTQ(out, node->u.Asm.tq, 0);
2703 }
2704@@ -1188,13 +1416,13 @@
2705 break;
2706 default:
2707 fprintf(stderr, "Internal error: unexpected node (%s:%d)\n", __FILE__, __LINE__);
2708- PrintNode(stderr, node, 2);
2709+ fPrintNode(stderr, node, 2);
2710 UNREACHABLE;
2711 }
2712
2713 if (PrintLiveVars && node->analysis.livevars) {
2714 OutS(out, " /* ");
2715- OutOffset(out, PrintAnalysis(out->f, node));
2716+ OutOffset(out, PrintAnalysis(out->gb, node));
2717 OutS(out, " */");
2718 }
2719 }
2720@@ -1250,31 +1478,35 @@
2721 TypeQual tq = node->u.proc.decl->u.decl.tq;;
2722 if (Transform) {
2723
2724- fputs("\n#undef CILK_WHERE_AM_I", out->f);
2725- fputs("\n#define CILK_WHERE_AM_I ", out->f);
2726+ gbputs("\n#undef CILK_WHERE_AM_I", out->gb);
2727+ gbputs("\n#define CILK_WHERE_AM_I ", out->gb);
2728
2729- if (tq & T_FAST_PROCEDURE)
2730- fputs("IN_FAST_PROCEDURE\n", out->f);
2731- else if (tq & T_SLOW_PROCEDURE)
2732- fputs("IN_SLOW_PROCEDURE\n", out->f);
2733- else if (tq & T_FAST_INLET)
2734- fputs("IN_FAST_INLET\n", out->f);
2735- else if (tq & T_SLOW_INLET)
2736- fputs("IN_SLOW_INLET\n", out->f);
2737- else if (tq & T_STANDALONE_INLET)
2738- fputs("IN_STANDALONE_INLET\n", out->f);
2739- else if (tq & T_C_CODE)
2740- fputs("IN_C_CODE\n", out->f);
2741+ if (tq_has_fast_procedure(tq))
2742+ gbputs("IN_FAST_PROCEDURE\n", out->gb);
2743+ else if (tq_has_slow_procedure(tq))
2744+ gbputs("IN_SLOW_PROCEDURE\n", out->gb);
2745+ else if (tq_has_fast_inlet(tq))
2746+ gbputs("IN_FAST_INLET\n", out->gb);
2747+ else if (tq_has_slow_inlet(tq))
2748+ gbputs("IN_SLOW_INLET\n", out->gb);
2749+ else if (tq_has_standalone_inlet(tq))
2750+ gbputs("IN_STANDALONE_INLET\n", out->gb);
2751+ else if (tq_has_c_code(tq))
2752+ gbputs("IN_C_CODE\n", out->gb);
2753 else {
2754 fprintf(stderr, "unknown type of procedure\n");
2755- PrintTQ(stderr, tq);
2756- PrintNode(stderr, node, 2);
2757+ {
2758+ GBUF *gb=make_file_gbuf(stderr);
2759+ PrintTQ(gb, tq, 0, 0);
2760+ PrintNode(gb, node, 2);
2761+ free_gbuf(gb);
2762+ }
2763 UNREACHABLE;
2764 }
2765 out->curr.line += 3;
2766 out->curr.offset = 0;
2767 } else {
2768- assert(0 == (tq & T_CILK_WHERE_AM_I_DECL_QUALS));
2769+ assert(!tq_has_cilk_where_am_i_decl_quals(tq));
2770 }
2771 }
2772
2773@@ -1315,7 +1547,7 @@
2774
2775 default:
2776 fprintf(stderr, "Internal error: unexpected node (%s:%d)\n", __FILE__, __LINE__);
2777- PrintNode(stderr, node, 2);
2778+ fPrintNode(stderr, node, 2);
2779 UNREACHABLE;
2780 }
2781 }
2782diff -Nur 5.4.2.2/cilk2c/print-ast.c current.Bug188/cilk2c/print-ast.c
2783--- 5.4.2.2/cilk2c/print-ast.c 2004-10-23 03:26:45.000000000 +0000
2784+++ current.Bug188/cilk2c/print-ast.c 2005-10-22 02:52:37.000000000 +0000
2785@@ -30,7 +30,7 @@
2786 #include "ast.h"
2787
2788 FILE_IDENTITY(ident,
2789- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/cilk2c/print-ast.c $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
2790+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/cilk2c/print-ast.c $ $LastChangedBy: bradley $ $Rev: 2484 $ $Date$");
2791
2792 #include <ctype.h>
2793
2794@@ -38,29 +38,29 @@
2795
2796 GLOBAL void DPN(Node *n)
2797 {
2798- PrintNode(stdout, n, 0);
2799+ fPrintNode(stdout, n, 0);
2800 putchar('\n');
2801 fflush(stdout);
2802 }
2803
2804 GLOBAL void DPL(List *list)
2805 {
2806- PrintList(stdout, list, 0);
2807+ fPrintList(stdout, list, 0);
2808 putchar('\n');
2809 fflush(stdout);
2810 }
2811
2812-GLOBAL void PrintCoord (FILE *out, Coord *c) {
2813+GLOBAL void PrintCoord (GBUF *out, Coord *c) {
2814 #if 0
2815 static int prevfilenum=-1;
2816- fprintf(out, "<");
2817+ gbprintf(out, "<");
2818 if (prevfilenum!=c->file) {
2819- fprintf(out, "%s:", FileNames[c->file]);
2820+ gbprintf(out, "%s:", FileNames[c->file]);
2821 prevfilenum=c->file;
2822 }
2823 #endif
2824 if (PrintASTcoords)
2825- fprintf(out, " <%d.%d>", c->line, c->offset);
2826+ gbprintf(out, " <%d.%d>", c->line, c->offset);
2827 }
2828
2829
2830@@ -70,32 +70,32 @@
2831 /* */
2832 /*************************************************************************/
2833
2834-PRIVATE inline void PrintConst(FILE *out, Node *node, UNUSED(ConstNode *u), UNUSED(int offset), UNUSED(Bool norecurse))
2835+PRIVATE inline void PrintConst(GBUF *gb, Node *node, UNUSED(ConstNode *u), UNUSED(int offset), UNUSED(Bool norecurse))
2836 {
2837- fprintf(out, "Const: ");
2838- PrintConstant(out, node, TRUE);
2839+ gbprintf(gb, "Const: ");
2840+ output_constant_to_GBUF(gb, node, TRUE);
2841 }
2842
2843-PRIVATE inline void PrintId(FILE *out, Node *node, idNode *u, int offset, UNUSED(Bool norecurse))
2844+PRIVATE inline void PrintId(GBUF *out, Node *node, idNode *u, int offset, UNUSED(Bool norecurse))
2845 {
2846- fprintf(out, "Id: %s", u->text);
2847+ gbprintf(out, "Id: %s", u->text);
2848 PrintCoord(out, &node->coord);
2849 if (u->value) {
2850 PrintCRSpaces(out, offset + 2);
2851- fputs("Value: ", out);
2852+ gbputs("Value: ", out);
2853 PrintCRSpaces(out, offset + 4);
2854 PrintNode(out, u->value, offset + 4);
2855 }
2856 PrintCRSpaces(out, offset + 2);
2857- fputs("decl: ", out);
2858+ gbputs("decl: ", out);
2859 PrintNode(out, u->decl, offset+4);
2860 /* PrintCRSpaces(out, offset + 2);*/
2861 /* PrintNode(out, u->decl, offset + 2); KHR */
2862 }
2863
2864-PRIVATE inline void PrintBinop(FILE *out, Node *node, binopNode *u, int offset, UNUSED(Bool norecurse))
2865+PRIVATE inline void PrintBinop(GBUF *out, Node *node, binopNode *u, int offset, UNUSED(Bool norecurse))
2866 {
2867- fprintf(out, "Binop: ");
2868+ gbprintf(out, "Binop: ");
2869 PrintOp(out, u->op);
2870 PrintCoord(out, &node->coord);
2871 if (u->type) {
2872@@ -104,7 +104,7 @@
2873 }
2874 if (u->value) {
2875 PrintCRSpaces(out, offset + 2);
2876- fputs("Value: ", out);
2877+ gbputs("Value: ", out);
2878 PrintCRSpaces(out, offset + 4);
2879 PrintNode(out, u->value, offset + 4);
2880 }
2881@@ -114,9 +114,9 @@
2882 PrintNode(out, u->right, offset + 2);
2883 }
2884
2885-PRIVATE inline void PrintUnary(FILE *out, Node *node, unaryNode *u, int offset, UNUSED(Bool norecurse))
2886+PRIVATE inline void PrintUnary(GBUF *out, Node *node, unaryNode *u, int offset, UNUSED(Bool norecurse))
2887 {
2888- fprintf(out, "Unary: ");
2889+ gbprintf(out, "Unary: ");
2890 PrintOp(out, u->op);
2891 PrintCoord(out, &node->coord);
2892 if (u->type) {
2893@@ -125,7 +125,7 @@
2894 }
2895 if (u->value) {
2896 PrintCRSpaces(out, offset + 2);
2897- fputs("Value: ", out);
2898+ gbputs("Value: ", out);
2899 PrintCRSpaces(out, offset + 4);
2900 PrintNode(out, u->value, offset + 4);
2901 }
2902@@ -133,13 +133,13 @@
2903 PrintNode(out, u->expr, offset + 2);
2904 }
2905
2906-PRIVATE inline void PrintCast(FILE *out, UNUSED(Node *node), castNode *u, int offset, UNUSED(Bool norecurse))
2907+PRIVATE inline void PrintCast(GBUF *out, UNUSED(Node *node), castNode *u, int offset, UNUSED(Bool norecurse))
2908 {
2909- fputs("Cast: ", out);
2910+ gbputs("Cast: ", out);
2911 PrintCoord(out, &node->coord);
2912 if (u->value) {
2913 PrintCRSpaces(out, offset + 2);
2914- fputs("Value: ", out);
2915+ gbputs("Value: ", out);
2916 PrintCRSpaces(out, offset + 4);
2917 PrintNode(out, u->value, offset + 4);
2918 }
2919@@ -149,29 +149,29 @@
2920 PrintNode(out, u->expr, offset + 2);
2921 }
2922
2923-PRIVATE inline void PrintComma(FILE *out, Node *node, commaNode *u, int offset, UNUSED(Bool norecurse))
2924+PRIVATE inline void PrintComma(GBUF *out, Node *node, commaNode *u, int offset, UNUSED(Bool norecurse))
2925 {
2926- fprintf(out, "Comma: List: exprs <%d.%d>", node->coord.line, node->coord.offset);
2927- if (node->parenthesized) fprintf(out, " parenthesized");
2928+ gbprintf(out, "Comma: List: exprs <%d.%d>", node->coord.line, node->coord.offset);
2929+ if (node->parenthesized) gbprintf(out, " parenthesized");
2930 PrintCRSpaces(out, offset + 2);
2931 PrintList(out, u->exprs, offset + 2);
2932 }
2933
2934-PRIVATE inline void PrintConstructor(FILE *out, UNUSED(Node *node), constructorNode *u, int offset, UNUSED(Bool norecurse))
2935+PRIVATE inline void PrintConstructor(GBUF *out, UNUSED(Node *node), constructorNode *u, int offset, UNUSED(Bool norecurse))
2936 {
2937- fprintf(out, "Constructor: List: exprs");
2938+ gbprintf(out, "Constructor: List: exprs");
2939 PrintCRSpaces(out, offset + 2);
2940 PrintNode(out, u->type, offset + 2);
2941 PrintCRSpaces(out, offset + 2);
2942 PrintNode(out, u->initializerlist, offset + 2);
2943 }
2944
2945-PRIVATE inline void PrintTernary(FILE *out, UNUSED(Node *node), ternaryNode *u, int offset, UNUSED(Bool norecurse))
2946+PRIVATE inline void PrintTernary(GBUF *out, UNUSED(Node *node), ternaryNode *u, int offset, UNUSED(Bool norecurse))
2947 {
2948- fputs("Ternary: ", out);
2949+ gbputs("Ternary: ", out);
2950 if (u->value) {
2951 PrintCRSpaces(out, offset + 2);
2952- fputs("Value: ", out);
2953+ gbputs("Value: ", out);
2954 PrintCRSpaces(out, offset + 4);
2955 PrintNode(out, u->value, offset + 4);
2956 }
2957@@ -183,9 +183,9 @@
2958 PrintNode(out, u->false, offset + 2);
2959 }
2960
2961-PRIVATE inline void PrintArray(FILE *out, UNUSED(Node *node), arrayNode *u, int offset, UNUSED(Bool norecurse))
2962+PRIVATE inline void PrintArray(GBUF *out, UNUSED(Node *node), arrayNode *u, int offset, UNUSED(Bool norecurse))
2963 {
2964- fputs("Array: ", out);
2965+ gbputs("Array: ", out);
2966 if (u->type) {
2967 PrintCRSpaces(out, offset + 2);
2968 PrintNode(out, u->type, offset + 2);
2969@@ -193,41 +193,41 @@
2970 PrintCRSpaces(out, offset + 2);
2971 PrintNode(out, u->name, offset + 2);
2972 PrintCRSpaces(out, offset + 2);
2973- fputs("List: dims", out);
2974+ gbputs("List: dims", out);
2975 PrintCRSpaces(out, offset + 4);
2976 PrintList(out, u->dims, offset + 4);
2977 }
2978
2979-PRIVATE inline void PrintCall(FILE *out, UNUSED(Node *node), callNode *u, int offset, UNUSED(Bool norecurse))
2980+PRIVATE inline void PrintCall(GBUF *out, UNUSED(Node *node), callNode *u, int offset, UNUSED(Bool norecurse))
2981 {
2982- fputs("Call: ", out);
2983+ gbputs("Call: ", out);
2984 PrintCRSpaces(out, offset + 2);
2985 PrintNode(out, u->name, offset + 2);
2986 PrintCRSpaces(out, offset + 2);
2987- fputs("List: args", out);
2988+ gbputs("List: args", out);
2989 PrintCRSpaces(out, offset + 4);
2990 PrintList(out, u->args, offset + 4);
2991 }
2992
2993-PRIVATE inline void PrintInitializer(FILE *out, UNUSED(Node *node), initializerNode *u, int offset, UNUSED(Bool norecurse))
2994+PRIVATE inline void PrintInitializer(GBUF *out, UNUSED(Node *node), initializerNode *u, int offset, UNUSED(Bool norecurse))
2995 {
2996- fprintf(out, "Initializer: List: exprs");
2997+ gbprintf(out, "Initializer: List: exprs");
2998 PrintCRSpaces(out, offset + 2);
2999 PrintList(out, u->exprs, offset + 2);
3000 }
3001
3002-PRIVATE inline void PrintImplicitCast(FILE *out, UNUSED(Node *node), implicitcastNode *u, int offset, UNUSED(Bool norecurse))
3003+PRIVATE inline void PrintImplicitCast(GBUF *out, UNUSED(Node *node), implicitcastNode *u, int offset, UNUSED(Bool norecurse))
3004 {
3005- fputs("ImplicitCast: ", out);
3006+ gbputs("ImplicitCast: ", out);
3007 if (u->type) {
3008 PrintCRSpaces(out, offset + 2);
3009- fputs("Type:", out);
3010+ gbputs("Type:", out);
3011 PrintCRSpaces(out, offset + 4);
3012 PrintNode(out, u->type, offset + 2);
3013 }
3014 if (u->value) {
3015 PrintCRSpaces(out, offset + 2);
3016- fputs("Value: ", out);
3017+ gbputs("Value: ", out);
3018 PrintCRSpaces(out, offset + 4);
3019 PrintNode(out, u->value, offset + 4);
3020 }
3021@@ -241,20 +241,20 @@
3022 /* */
3023 /*************************************************************************/
3024
3025-PRIVATE inline void PrintLabel(FILE *out, Node *node, labelNode *u, UNUSED(int offset), UNUSED(Bool norecurse))
3026+PRIVATE inline void PrintLabel(GBUF *out, Node *node, labelNode *u, UNUSED(int offset), UNUSED(Bool norecurse))
3027 {
3028- fprintf(out, "Label: %s (%d)", u->name, node->print_uid);
3029+ gbprintf(out, "Label: %s (%d)", u->name, node->print_uid);
3030 #if 0
3031- fprintf(out, "Label: %s", u->name);
3032+ gbprintf(out, "Label: %s", u->name);
3033 #endif
3034 }
3035
3036-PRIVATE inline void PrintSwitch(FILE *out, Node *node, SwitchNode *u, int offset, UNUSED(Bool norecurse))
3037+PRIVATE inline void PrintSwitch(GBUF *out, Node *node, SwitchNode *u, int offset, UNUSED(Bool norecurse))
3038 {
3039 ListMarker marker;
3040 Node *cse;
3041
3042- fprintf(out, "Switch: (%d)", node->print_uid);
3043+ gbprintf(out, "Switch: (%d)", node->print_uid);
3044 PrintCRSpaces(out, offset + 2);
3045 PrintNode(out, u->expr, offset + 2);
3046 PrintCRSpaces(out, offset + 2);
3047@@ -262,41 +262,41 @@
3048 PrintCRSpaces(out, offset + 2);
3049
3050 IterateList(&marker, u->cases);
3051- fprintf(out, "Cases:");
3052+ gbprintf(out, "Cases:");
3053 while (NextOnList(&marker, (GenericREF) & cse)) {
3054- fprintf(out, " %d", cse->coord.line);
3055+ gbprintf(out, " %d", cse->coord.line);
3056 }
3057 }
3058
3059-PRIVATE inline void PrintCase(FILE *out, UNUSED(Node *node), CaseNode *u, int offset, UNUSED(Bool norecurse))
3060+PRIVATE inline void PrintCase(GBUF *out, UNUSED(Node *node), CaseNode *u, int offset, UNUSED(Bool norecurse))
3061 {
3062- fprintf(out, "Case: (container = %d)", u->container->print_uid);
3063+ gbprintf(out, "Case: (container = %d)", u->container->print_uid);
3064 #if 0
3065- fprintf(out, "Case: ");
3066+ gbprintf(out, "Case: ");
3067 #endif
3068 PrintCRSpaces(out, offset + 2);
3069 PrintNode(out, u->expr, offset + 2);
3070 PrintCRSpaces(out, offset + 2);
3071 }
3072
3073-PRIVATE inline void PrintDefault(FILE *out, UNUSED(Node *node), DefaultNode *u, int offset, UNUSED(Bool norecurse))
3074+PRIVATE inline void PrintDefault(GBUF *out, UNUSED(Node *node), DefaultNode *u, int offset, UNUSED(Bool norecurse))
3075 {
3076- fprintf(out, "Default: (container = %d)", u->container->print_uid);
3077+ gbprintf(out, "Default: (container = %d)", u->container->print_uid);
3078 PrintCRSpaces(out, offset + 2);
3079 }
3080
3081-PRIVATE inline void PrintIf(FILE *out, UNUSED(Node *node), IfNode *u, int offset, UNUSED(Bool norecurse))
3082+PRIVATE inline void PrintIf(GBUF *out, UNUSED(Node *node), IfNode *u, int offset, UNUSED(Bool norecurse))
3083 {
3084- fputs("If: ", out);
3085+ gbputs("If: ", out);
3086 PrintCRSpaces(out, offset + 2);
3087 PrintNode(out, u->expr, offset + 2);
3088 PrintCRSpaces(out, offset + 2);
3089 PrintNode(out, u->stmt, offset + 2);
3090 }
3091
3092-PRIVATE inline void PrintIfElse(FILE *out, UNUSED(Node *node), IfElseNode *u, int offset, UNUSED(Bool norecurse))
3093+PRIVATE inline void PrintIfElse(GBUF *out, UNUSED(Node *node), IfElseNode *u, int offset, UNUSED(Bool norecurse))
3094 {
3095- fputs("IfElse: ", out);
3096+ gbputs("IfElse: ", out);
3097 PrintCRSpaces(out, offset + 2);
3098 PrintNode(out, u->expr, offset + 2);
3099 PrintCRSpaces(out, offset + 2);
3100@@ -305,27 +305,27 @@
3101 PrintNode(out, u->false, offset + 2);
3102 }
3103
3104-PRIVATE inline void PrintWhile(FILE *out, Node *node, WhileNode *u, int offset, UNUSED(Bool norecurse))
3105+PRIVATE inline void PrintWhile(GBUF *out, Node *node, WhileNode *u, int offset, UNUSED(Bool norecurse))
3106 {
3107- fprintf(out, "While: (%d) ", node->print_uid);
3108+ gbprintf(out, "While: (%d) ", node->print_uid);
3109 PrintCRSpaces(out, offset + 2);
3110 PrintNode(out, u->expr, offset + 2);
3111 PrintCRSpaces(out, offset + 2);
3112 PrintNode(out, u->stmt, offset + 2);
3113 }
3114
3115-PRIVATE inline void PrintDo(FILE *out, Node *node, DoNode *u, int offset, UNUSED(Bool norecurse))
3116+PRIVATE inline void PrintDo(GBUF *out, Node *node, DoNode *u, int offset, UNUSED(Bool norecurse))
3117 {
3118- fprintf(out, "Do: (%d) ", node->print_uid);
3119+ gbprintf(out, "Do: (%d) ", node->print_uid);
3120 PrintCRSpaces(out, offset + 2);
3121 PrintNode(out, u->stmt, offset + 2);
3122 PrintCRSpaces(out, offset + 2);
3123 PrintNode(out, u->expr, offset + 2);
3124 }
3125
3126-PRIVATE inline void PrintFor(FILE *out, Node *node, ForNode *u, int offset, UNUSED(Bool norecurse))
3127+PRIVATE inline void PrintFor(GBUF *out, Node *node, ForNode *u, int offset, UNUSED(Bool norecurse))
3128 {
3129- fprintf(out, "For: (%d) ", node->print_uid);
3130+ gbprintf(out, "For: (%d) ", node->print_uid);
3131 PrintCRSpaces(out, offset + 2);
3132 PrintNode(out, u->init, offset + 2);
3133 PrintCRSpaces(out, offset + 2);
3134@@ -336,31 +336,31 @@
3135 PrintNode(out, u->stmt, offset + 2);
3136 }
3137
3138-PRIVATE inline void PrintGoto(FILE *out, UNUSED(Node *node), GotoNode *u, UNUSED(int offset), UNUSED(Bool norecurse))
3139+PRIVATE inline void PrintGoto(GBUF *out, UNUSED(Node *node), GotoNode *u, UNUSED(int offset), UNUSED(Bool norecurse))
3140 {
3141- fprintf(out, "Goto: %s",
3142+ gbprintf(out, "Goto: %s",
3143 (u->label ? u->label->u.label.name : "nil"));
3144 }
3145
3146-PRIVATE inline void PrintContinue(FILE *out, UNUSED(Node *node), ContinueNode *u, UNUSED(int offset), UNUSED(Bool norecurse))
3147+PRIVATE inline void PrintContinue(GBUF *out, UNUSED(Node *node), ContinueNode *u, UNUSED(int offset), UNUSED(Bool norecurse))
3148 {
3149- fprintf(out, "Continue: (container = %d)", u->container->print_uid);
3150+ gbprintf(out, "Continue: (container = %d)", u->container->print_uid);
3151 #if 0
3152- fprintf(out, "Continue: ");
3153+ gbprintf(out, "Continue: ");
3154 #endif
3155 }
3156
3157-PRIVATE inline void PrintBreak(FILE *out, UNUSED(Node *node), BreakNode *u, UNUSED(int offset), UNUSED(Bool norecurse))
3158+PRIVATE inline void PrintBreak(GBUF *out, UNUSED(Node *node), BreakNode *u, UNUSED(int offset), UNUSED(Bool norecurse))
3159 {
3160- fprintf(out, "Break: (container = %d)", u->container->print_uid);
3161+ gbprintf(out, "Break: (container = %d)", u->container->print_uid);
3162 #if 0
3163- fprintf(out, "Break: ");
3164+ gbprintf(out, "Break: ");
3165 #endif
3166 }
3167
3168-PRIVATE inline void PrintReturn(FILE *out, UNUSED(Node *node), ReturnNode *u, int offset, Bool UNUSED(norecurse))
3169+PRIVATE inline void PrintReturn(GBUF *out, UNUSED(Node *node), ReturnNode *u, int offset, Bool UNUSED(norecurse))
3170 {
3171- fputs("Return: ", out);
3172+ gbputs("Return: ", out);
3173 #if 0
3174 if (u->expr) {
3175 PrintCRSpaces(out, offset + 2);
3176@@ -371,28 +371,28 @@
3177 PrintNode(out, u->expr, offset + 2);
3178 }
3179
3180-PRIVATE inline void PrintBlock(FILE *out, UNUSED(Node *node), BlockNode *u, int offset, UNUSED(Bool norecurse))
3181+PRIVATE inline void PrintBlock(GBUF *out, UNUSED(Node *node), BlockNode *u, int offset, UNUSED(Bool norecurse))
3182 {
3183- fputs("Block:", out);
3184- if (node->parenthesized) fprintf(out, " parenthesized");
3185+ gbputs("Block:", out);
3186+ if (node->parenthesized) gbprintf(out, " parenthesized");
3187 PrintCRSpaces(out, offset + 2);
3188 if (u->type) {
3189- fprintf(out, "Type: (%d)", u->type->print_uid);
3190+ gbprintf(out, "Type: (%d)", u->type->print_uid);
3191 } else {
3192- fprintf(out, "Type: nil");
3193+ gbprintf(out, "Type: nil");
3194 }
3195 #if 0
3196- fputs("Type:", out);
3197+ gbputs("Type:", out);
3198 #endif
3199 PrintCRSpaces(out, offset + 4);
3200 PrintNode(out, u->type, offset + 4);
3201 PrintCRSpaces(out, offset + 2);
3202- fputs("List: decl", out);
3203+ gbputs("List: decl", out);
3204 PrintCRSpaces(out, offset + 4);
3205 PrintList(out, u->decl, offset + 4);
3206
3207 PrintCRSpaces(out, offset + 2);
3208- fputs("List: stmts", out);
3209+ gbputs("List: stmts", out);
3210 PrintCRSpaces(out, offset + 4);
3211 PrintList(out, u->stmts, offset + 4);
3212 }
3213@@ -404,22 +404,22 @@
3214 /* */
3215 /*************************************************************************/
3216
3217-PRIVATE inline void PrintPrim(FILE *out, Node *node, UNUSED(primNode *u), UNUSED(int offset), UNUSED(Bool norecurse))
3218+PRIVATE inline void PrintPrim(GBUF *out, Node *node, UNUSED(primNode *u), UNUSED(int offset), UNUSED(Bool norecurse))
3219 {
3220- fprintf(out, "Prim: ");
3221- PrintPrimType(out, node, 0);
3222+ gbprintf(out, "Prim: ");
3223+ output_prim_type_to_GBUF(out, node, 0);
3224 PrintCoord(out, &node->coord);
3225 }
3226
3227-PRIVATE inline void PrintTdef(FILE *out, Node *node, tdefNode *u, UNUSED(int offset), UNUSED(Bool norecurse))
3228+PRIVATE inline void PrintTdef(GBUF *out, Node *node, tdefNode *u, UNUSED(int offset), UNUSED(Bool norecurse))
3229 {
3230 /* temp fix for core dump when printing ast -Angelina */
3231 if( u->type == NULL )
3232- fprintf(out, "Tdef: %s (%d) (type=NULL) ", u->name, node->print_uid);
3233+ gbprintf(out, "Tdef: %s (%d) (type=NULL) ", u->name, node->print_uid);
3234 else
3235- fprintf(out, "Tdef: %s (%d) (type=%d) ", u->name, node->print_uid, u->type->print_uid);
3236+ gbprintf(out, "Tdef: %s (%d) (type=%d) ", u->name, node->print_uid, u->type->print_uid);
3237 PrintCoord(out, &node->coord);
3238- PrintTQ(out, u->tq);
3239+ PrintTQ(out, u->tq, offset, norecurse);
3240 #if 0
3241 if (!norecurse) {
3242 PrintCRSpaces(out, offset + 2);
3243@@ -428,79 +428,79 @@
3244 #endif
3245 }
3246
3247-PRIVATE inline void PrintPtr(FILE *out, UNUSED(Node *node), ptrNode *u, int offset, UNUSED(Bool norecurse))
3248+PRIVATE inline void PrintPtr(GBUF *out, UNUSED(Node *node), ptrNode *u, int offset, UNUSED(Bool norecurse))
3249 {
3250- fprintf(out, "Ptr: ");
3251- PrintTQ(out, u->tq);
3252+ gbprintf(out, "Ptr: ");
3253+ PrintTQ(out, u->tq, offset, norecurse);
3254 PrintCRSpaces(out, offset + 2);
3255 PrintNode(out, u->type, offset + 2);
3256 }
3257
3258-PRIVATE inline void PrintAdcl(FILE *out, Node *node, adclNode *u, int offset, UNUSED(Bool norecurse))
3259+PRIVATE inline void PrintAdcl(GBUF *out, Node *node, adclNode *u, int offset, UNUSED(Bool norecurse))
3260 {
3261- fprintf(out, "Adcl: (%d)", node->print_uid);
3262- PrintTQ(out, u->tq);
3263+ gbprintf(out, "Adcl: (%d)", node->print_uid);
3264+ PrintTQ(out, u->tq, offset, norecurse);
3265 PrintCRSpaces(out, offset + 2);
3266 PrintNode(out, u->type, offset + 2);
3267 PrintCRSpaces(out, offset + 2);
3268 PrintNode(out, u->dimp->dim, offset + 2);
3269 if (u->dimp->size > 0) {
3270 PrintCRSpaces(out, offset + 2);
3271- fprintf(out, "%d", u->dimp->size);
3272+ gbprintf(out, "%d", u->dimp->size);
3273 }
3274 }
3275
3276-PRIVATE inline void PrintFdcl(FILE *out, Node *node, fdclNode *u, int offset, UNUSED(Bool norecurse))
3277+PRIVATE inline void PrintFdcl(GBUF *out, Node *node, fdclNode *u, int offset, UNUSED(Bool norecurse))
3278 {
3279- fprintf(out, "Fdcl:");
3280+ gbprintf(out, "Fdcl:");
3281 PrintCoord(out, &node->coord);
3282- fprintf(out, " ");
3283- PrintTQ(out, u->tq);
3284+ gbprintf(out, " ");
3285+ PrintTQ(out, u->tq, offset, norecurse);
3286 PrintCRSpaces(out, offset + 2);
3287- fputs("List: Args: ", out);
3288+ gbputs("List: Args: ", out);
3289 PrintCRSpaces(out, offset + 4);
3290 PrintList(out, u->args, offset + 4);
3291 PrintCRSpaces(out, offset + 2);
3292- fputs("Returns: ", out);
3293+ gbputs("Returns: ", out);
3294 PrintCRSpaces(out, offset + 4);
3295 PrintNode(out, u->returns, offset + 4);
3296 }
3297
3298-PRIVATE inline void PrintSdcl(FILE *out, Node *node, sdclNode *u, int offset, Bool norecurse)
3299+PRIVATE inline void PrintSdcl(GBUF *out, Node *node, sdclNode *u, int offset, Bool norecurse)
3300 {
3301- fprintf(out, "Sdcl: (%d) ", node->print_uid);
3302+ gbprintf(out, "Sdcl: (%d) ", node->print_uid);
3303
3304 if (norecurse)
3305- fprintf(out, "%s\n", u->type->name);
3306+ gbprintf(out, "%s\n", u->type->name);
3307 else {
3308 PrintCRSpaces(out, offset + 2);
3309- PrintTQ(out, u->tq);
3310+ PrintTQ(out, u->tq, offset+2, norecurse);
3311 PrintSUE(out, u->type, offset + 4, TRUE);
3312 }
3313 }
3314
3315-PRIVATE inline void PrintUdcl(FILE *out, Node *node, udclNode *u, int offset, Bool norecurse)
3316+PRIVATE inline void PrintUdcl(GBUF *out, Node *node, udclNode *u, int offset, Bool norecurse)
3317 {
3318- fprintf(out, "Udcl: (%d) ", node->print_uid);
3319+ gbprintf(out, "Udcl: (%d) ", node->print_uid);
3320
3321 if (norecurse)
3322- fprintf(out, "%s\n", u->type->name);
3323+ gbprintf(out, "%s\n", u->type->name);
3324 else {
3325 PrintCRSpaces(out, offset + 2);
3326- PrintTQ(out, u->tq);
3327+ PrintTQ(out, u->tq, offset+2, norecurse);
3328 PrintSUE(out, u->type, offset + 4, TRUE);
3329 }
3330 }
3331
3332-PRIVATE inline void PrintEdcl(FILE *out, Node *node, edclNode *u, int offset, Bool norecurse)
3333+PRIVATE inline void PrintEdcl(GBUF *out, Node *node, edclNode *u, int offset, Bool norecurse)
3334 {
3335- fprintf(out, "Edcl: (%d) ", node->print_uid);
3336+ gbprintf(out, "Edcl: (%d) ", node->print_uid);
3337
3338 if (norecurse)
3339- fprintf(out, "%s\n", u->type->name);
3340+ gbprintf(out, "%s\n", u->type->name);
3341 else {
3342 PrintCRSpaces(out, offset + 2);
3343- PrintTQ(out, u->tq);
3344+ PrintTQ(out, u->tq, offset+2, norecurse);
3345 PrintSUE(out, u->type, offset + 4, TRUE);
3346 }
3347 }
3348@@ -511,15 +511,15 @@
3349 /* */
3350 /*************************************************************************/
3351
3352-PRIVATE inline void PrintDecl(FILE *out, Node *node, declNode *u, int offset, Bool norecurse)
3353+PRIVATE inline void PrintDecl(GBUF *out, Node *node, declNode *u, int offset, Bool norecurse)
3354 {
3355- fprintf(out, "Decl: %s (%d)", u->name ? u->name : "", node->print_uid);
3356+ gbprintf(out, "Decl: %s (%d)", u->name ? u->name : "", node->print_uid);
3357 PrintCoord(out, &node->coord);
3358- fprintf(out, " ");
3359- PrintTQ(out, u->tq);
3360+ gbprintf(out, " ");
3361+ PrintTQ(out, u->tq, offset+2, norecurse);
3362
3363 if (norecurse)
3364- fprintf(out, "\n");
3365+ gbprintf(out, "\n");
3366 else {
3367 PrintCRSpaces(out, offset + 2);
3368 PrintNode(out, u->type, offset + 2);
3369@@ -534,28 +534,28 @@
3370 }
3371 }
3372
3373-PRIVATE inline void PrintAttrib(FILE *out, UNUSED(Node *node), attribNode *u,
3374+PRIVATE inline void PrintAttrib(GBUF *out, UNUSED(Node *node), attribNode *u,
3375 int offset, UNUSED(Bool norecurse))
3376 {
3377- fprintf(out, "Attrib: %s", u->name);
3378+ gbprintf(out, "Attrib: %s", u->name);
3379
3380 PrintCRSpaces(out, offset + 2);
3381 PrintList(out, u->arglist, offset + 2);
3382 }
3383
3384-PRIVATE inline void PrintProc(FILE *out, UNUSED(Node *node), procNode *u, UNUSED(int offset), UNUSED(Bool norecurse))
3385+PRIVATE inline void PrintProc(GBUF *out, UNUSED(Node *node), procNode *u, UNUSED(int offset), UNUSED(Bool norecurse))
3386 {
3387- fputs("Proc:\n ", out);
3388+ gbputs("Proc:\n ", out);
3389 PrintNode(out, u->decl, 2);
3390- fputs("\n ", out);
3391+ gbputs("\n ", out);
3392 PrintNode(out, u->body, 2);
3393 }
3394
3395-PRIVATE inline void PrintText(FILE *out, UNUSED(Node *node), textNode *u, UNUSED(int offset), UNUSED(Bool norecurse))
3396+PRIVATE inline void PrintText(GBUF *out, UNUSED(Node *node), textNode *u, UNUSED(int offset), UNUSED(Bool norecurse))
3397 {
3398- fputs("Text: ", out);
3399+ gbputs("Text: ", out);
3400 if (u->start_new_line)
3401- fputs("(new line) ", out);
3402+ gbputs("(new line) ", out);
3403 PrintString(out, u->text);
3404 }
3405
3406@@ -565,40 +565,40 @@
3407 /* */
3408 /*************************************************************************/
3409
3410-PRIVATE inline void PrintAsm(FILE *out, UNUSED(Node *node), asmNode *u, int offset, UNUSED(Bool norecurse))
3411+PRIVATE inline void PrintAsm(GBUF *out, UNUSED(Node *node), asmNode *u, int offset, UNUSED(Bool norecurse))
3412 {
3413- fprintf(out, "Asm: ");
3414+ gbprintf(out, "Asm: ");
3415
3416- if (u->tq) {
3417+ if (tq_has_anything(u->tq)) {
3418 PrintCRSpaces(out, offset + 2);
3419- PrintTQ(out, u->tq);
3420+ PrintTQ(out, u->tq, offset, norecurse);
3421 }
3422 PrintCRSpaces(out, offset + 2);
3423 PrintNode(out, u->template, offset + 2);
3424
3425 PrintCRSpaces(out, offset + 2);
3426- fputs("List: output operands", out);
3427+ gbputs("List: output operands", out);
3428 PrintCRSpaces(out, offset + 4);
3429 PrintList(out, u->output, offset + 4);
3430
3431 PrintCRSpaces(out, offset + 2);
3432- fputs("List: input operands", out);
3433+ gbputs("List: input operands", out);
3434 PrintCRSpaces(out, offset + 4);
3435 PrintList(out, u->input, offset + 4);
3436
3437 PrintCRSpaces(out, offset + 2);
3438- fputs("List: clobbered registers", out);
3439+ gbputs("List: clobbered registers", out);
3440 PrintCRSpaces(out, offset + 4);
3441 PrintList(out, u->clobbered, offset + 4);
3442 }
3443-PRIVATE inline void PrintAsmArg(FILE *out, UNUSED(Node *node), asmargNode *u, int offset, UNUSED(Bool norecurse))
3444+PRIVATE inline void PrintAsmArg(GBUF *out, UNUSED(Node *node), asmargNode *u, int offset, UNUSED(Bool norecurse))
3445 {
3446- fprintf(out, "AsmArg: ");
3447+ gbprintf(out, "AsmArg: ");
3448 PrintCRSpaces(out, offset + 2);
3449- fputs("Constraint:", out);
3450+ gbputs("Constraint:", out);
3451 PrintNode(out, u->constraint, offset + 2);
3452 PrintCRSpaces(out, offset + 2);
3453- fputs("Expr:", out);
3454+ gbputs("Expr:", out);
3455 PrintNode(out, u->expr, offset + 2);
3456 }
3457
3458@@ -607,14 +607,14 @@
3459 /* GCC stdarg.h support */
3460 /* */
3461 /*************************************************************************/
3462-PRIVATE inline void PrintBuiltinVaArg(FILE *out, UNUSED(Node *node), builtinvaargNode *u, int offset, UNUSED(Bool norecurse))
3463+PRIVATE inline void PrintBuiltinVaArg(GBUF *out, UNUSED(Node *node), builtinvaargNode *u, int offset, UNUSED(Bool norecurse))
3464 {
3465- fprintf(out, "builtinvaarg: ");
3466+ gbprintf(out, "builtinvaarg: ");
3467 PrintCRSpaces(out, offset + 2);
3468- fputs("Expr:", out);
3469+ gbputs("Expr:", out);
3470 PrintNode(out, u->expr, offset + 2);
3471 PrintCRSpaces(out, offset + 2);
3472- fputs("Type:", out);
3473+ gbputs("Type:", out);
3474 PrintNode(out, u->type, offset + 2);
3475 }
3476
3477@@ -624,9 +624,9 @@
3478 /* */
3479 /*************************************************************************/
3480
3481-PRIVATE inline void PrintSpawn(FILE *out, UNUSED(Node *node), spawnNode *u, int offset, UNUSED(Bool norecurse))
3482+PRIVATE inline void PrintSpawn(GBUF *out, UNUSED(Node *node), spawnNode *u, int offset, UNUSED(Bool norecurse))
3483 {
3484- fprintf(out, "Spawn: ");
3485+ gbprintf(out, "Spawn: ");
3486
3487 PrintCRSpaces(out, offset + 2);
3488 PrintNode(out, u->receiver, offset + 2);
3489@@ -635,62 +635,62 @@
3490 PrintNode(out, u->name, offset + 2);
3491
3492 PrintCRSpaces(out, offset + 2);
3493- fputs("List: args", out);
3494+ gbputs("List: args", out);
3495 PrintCRSpaces(out, offset + 4);
3496 PrintList(out, u->args, offset + 4);
3497 }
3498
3499-PRIVATE inline void PrintSync(FILE *out, UNUSED(Node *node), UNUSED(syncNode *u), UNUSED(int offset), UNUSED(Bool norecurse))
3500+PRIVATE inline void PrintSync(GBUF *out, UNUSED(Node *node), UNUSED(syncNode *u), UNUSED(int offset), UNUSED(Bool norecurse))
3501 {
3502- fprintf(out, "Sync");
3503+ gbprintf(out, "Sync");
3504 }
3505
3506-PRIVATE inline void PrintInletCall(FILE *out, UNUSED(Node *node), inletcallNode *u, int offset, UNUSED(Bool norecurse))
3507+PRIVATE inline void PrintInletCall(GBUF *out, UNUSED(Node *node), inletcallNode *u, int offset, UNUSED(Bool norecurse))
3508 {
3509- fprintf(out, "InletCall: ");
3510+ gbprintf(out, "InletCall: ");
3511
3512 PrintCRSpaces(out, offset + 2);
3513 PrintNode(out, u->name, offset + 2);
3514
3515 PrintCRSpaces(out, offset + 2);
3516- fputs("List: args", out);
3517+ gbputs("List: args", out);
3518 PrintCRSpaces(out, offset + 4);
3519 PrintList(out, u->args, offset + 4);
3520 }
3521
3522-PRIVATE inline void PrintAbort(FILE *out, UNUSED(Node *node), UNUSED(abortNode *u), UNUSED(int offset), UNUSED(Bool norecurse))
3523+PRIVATE inline void PrintAbort(GBUF *out, UNUSED(Node *node), UNUSED(abortNode *u), UNUSED(int offset), UNUSED(Bool norecurse))
3524 {
3525- fprintf(out, "Abort");
3526+ gbprintf(out, "Abort");
3527 }
3528
3529-PRIVATE inline void PrintSynched(FILE *out, UNUSED(Node *node), UNUSED(synchedNode *u), UNUSED(int offset), UNUSED(Bool norecurse))
3530+PRIVATE inline void PrintSynched(GBUF *out, UNUSED(Node *node), UNUSED(synchedNode *u), UNUSED(int offset), UNUSED(Bool norecurse))
3531 {
3532- fprintf(out, "Synched");
3533+ gbprintf(out, "Synched");
3534 }
3535
3536
3537-PRIVATE inline void PrintXBlock(FILE *out, UNUSED(Node *node), XBlockNode *u, int offset, UNUSED(Bool norecurse))
3538+PRIVATE inline void PrintXBlock(GBUF *out, UNUSED(Node *node), XBlockNode *u, int offset, UNUSED(Bool norecurse))
3539 {
3540- fputs("XBlock:", out);
3541- if (node->parenthesized) fprintf(out, " parenthesized");
3542+ gbputs("XBlock:", out);
3543+ if (node->parenthesized) gbprintf(out, " parenthesized");
3544 PrintCRSpaces(out, offset + 2);
3545 if (u->type) {
3546- fprintf(out, "Type: (%d)", u->type->print_uid);
3547+ gbprintf(out, "Type: (%d)", u->type->print_uid);
3548 } else {
3549- fprintf(out, "Type: nil");
3550+ gbprintf(out, "Type: nil");
3551 }
3552 #if 0
3553- fputs("Type:", out);
3554+ gbputs("Type:", out);
3555 #endif
3556 PrintCRSpaces(out, offset + 4);
3557 PrintNode(out, u->type, offset + 4);
3558 PrintCRSpaces(out, offset + 2);
3559- fputs("List: decl", out);
3560+ gbputs("List: decl", out);
3561 PrintCRSpaces(out, offset + 4);
3562 PrintList(out, u->decl, offset + 4);
3563
3564 PrintCRSpaces(out, offset + 2);
3565- fputs("List: stmts", out);
3566+ gbputs("List: stmts", out);
3567 PrintCRSpaces(out, offset + 4);
3568 PrintList(out, u->stmts, offset + 4);
3569 }
3570@@ -720,32 +720,32 @@
3571 }
3572
3573
3574-GLOBAL void PrintWildcard(FILE *out, Node *node, int offset) {
3575+GLOBAL void PrintWildcard(GBUF *out, Node *node, int offset) {
3576
3577 PrintCRSpaces(out, offset);
3578 switch (node->wTyp) {
3579 case WildcardE:
3580- fprintf(out, "WildcardE: ");
3581+ gbprintf(out, "WildcardE: ");
3582 break;
3583 case WildcardD:
3584- fprintf(out, "WildcardD: ");
3585+ gbprintf(out, "WildcardD: ");
3586 break;
3587 case WildcardT:
3588- fprintf(out, "WildcardT: ");
3589+ gbprintf(out, "WildcardT: ");
3590 break;
3591 default:
3592- fprintf(out, "Unknown wildcard.");
3593+ gbprintf(out, "Unknown wildcard.");
3594 }
3595 }
3596
3597
3598
3599-GLOBAL void PrintNode(FILE *out, Node *node, int offset)
3600+GLOBAL void PrintNode(GBUF *out, Node *node, int offset)
3601 {
3602 Bool norecurse;
3603
3604 if (node == NULL) {
3605- fprintf(out, "nil");
3606+ gbprintf(out, "nil");
3607 return;
3608 }
3609 if (PrintInvocations++ == 0) {
3610@@ -773,7 +773,7 @@
3611 --PrintInvocations;
3612 }
3613
3614-GLOBAL void PrintList(FILE *out, List *list, int offset)
3615+GLOBAL void PrintList(GBUF *out, List *list, int offset)
3616 {
3617 ListMarker marker;
3618 Node *item;
3619@@ -791,7 +791,7 @@
3620 if (firstp == TRUE)
3621 firstp = FALSE;
3622 else if (offset < 0)
3623- fputs("\n\n", out);
3624+ gbputs("\n\n", out);
3625 else
3626 PrintCRSpaces(out, offset);
3627
3628@@ -799,7 +799,7 @@
3629 }
3630
3631 if (firstp == TRUE)
3632- fputs("nil", out);
3633+ gbputs("nil", out);
3634
3635 --PrintInvocations;
3636 }
3637@@ -810,7 +810,7 @@
3638 /* */
3639 /*************************************************************************/
3640
3641-int print_float(FILE *fd, float val)
3642+GLOBAL int print_float(GBUF *fd, float val)
3643 {
3644 int i;
3645 char fmt[8];
3646@@ -828,10 +828,10 @@
3647 assert(i < 20);
3648 }
3649
3650- return fprintf(fd, "%s", buf);
3651+ return gbprintf(fd, "%s", buf);
3652 }
3653
3654-int print_double(FILE *fd, double val)
3655+GLOBAL int print_double(GBUF *fd, double val)
3656 {
3657 int i;
3658 char fmt[8];
3659@@ -849,79 +849,19 @@
3660 assert(i < 20);
3661 }
3662
3663- return fprintf(fd, "%s", buf);
3664+ return gbprintf(fd, "%s", buf);
3665 }
3666
3667-GLOBAL int PrintConstant(FILE *out, Node *c, Bool with_name)
3668+void PrintCRSpaces(GBUF *out, int spaces)
3669 {
3670- int len = 0;
3671-
3672- if (with_name)
3673- switch (c->u.Const.type->typ) {
3674- case Prim:
3675- len = PrintPrimType(out, c->u.Const.type, 0) + 1;
3676- fputc(' ', out);
3677- break;
3678- /* Used for strings */
3679- case Adcl:
3680- assert(c->u.Const.type->u.adcl.type->typ == Prim);
3681- fprintf(out, "array of ");
3682- len = PrintPrimType(out, c->u.Const.type->u.adcl.type, 0) + 10;
3683- fputc(' ', out);
3684- break;
3685- default:
3686- len = fprintf(out, "??? ");
3687- }
3688- switch (c->u.Const.type->typ) {
3689- case Prim:
3690- switch (c->u.Const.type->u.prim.basic) {
3691- case Sint:
3692- return len + fprintf(out, "%d", c->u.Const.value.i);
3693-
3694- /*Manish 2/3 hack to print pointer constants */
3695- case Uint:
3696- return len + fprintf(out, "%uU", c->u.Const.value.u);
3697- case Slong:
3698- return len + fprintf(out, "%ldL", c->u.Const.value.l);
3699- case Ulong:
3700- return len + fprintf(out, "%luUL", c->u.Const.value.ul);
3701- case Float:
3702- return len + print_float(out, c->u.Const.value.f);
3703- case Double:
3704- return len + print_double(out, c->u.Const.value.d);
3705- case Char:
3706- case Schar:
3707- case Uchar:
3708- return len + PrintChar(out, c->u.Const.value.i);
3709-
3710- default:
3711- Fail(__FILE__, __LINE__, "");
3712- return 0;
3713- }
3714-
3715- /* Manish 2/3 Print Constant Pointers */
3716- case Ptr:
3717- return len + fprintf(out, "%u", c->u.Const.value.u);
3718- /* Used for strings */
3719- case Adcl:
3720- return len + PrintString(out, c->u.Const.value.s);
3721-
3722- default:
3723- FAIL("Unrecognized constant type");
3724- }
3725-}
3726-
3727-void PrintCRSpaces(FILE *out, int spaces)
3728-{
3729- fputc('\n', out);
3730- while (spaces--)
3731- fputc(' ', out);
3732+ gbputs("\n", out);
3733+ PrintSpaces(out, spaces);
3734 }
3735
3736-void PrintSpaces(FILE *out, int spaces)
3737+void PrintSpaces(GBUF *out, int spaces)
3738 {
3739 while (spaces--)
3740- fputc(' ', out);
3741+ gbputs(" ", out);
3742 }
3743
3744 GLOBAL void CharToText(char *array, unsigned char value)
3745@@ -943,50 +883,50 @@
3746 }
3747 }
3748
3749-GLOBAL inline int PrintChar(FILE *out, int value)
3750+GLOBAL inline int PrintChar(GBUF *out, int value)
3751 {
3752 switch (value) {
3753 case '\n':
3754- return fprintf(out, "\\n");
3755+ return gbprintf(out, "\\n");
3756 case '\t':
3757- return fprintf(out, "\\t");
3758+ return gbprintf(out, "\\t");
3759 case '\v':
3760- return fprintf(out, "\\v");
3761+ return gbprintf(out, "\\v");
3762 case '\b':
3763- return fprintf(out, "\\b");
3764+ return gbprintf(out, "\\b");
3765 case '\r':
3766- return fprintf(out, "\\r");
3767+ return gbprintf(out, "\\r");
3768 case '\f':
3769- return fprintf(out, "\\f");
3770+ return gbprintf(out, "\\f");
3771 case '\a':
3772- return fprintf(out, "\\a");
3773+ return gbprintf(out, "\\a");
3774 case '\\':
3775- return fprintf(out, "\\\\");
3776+ return gbprintf(out, "\\\\");
3777 case '\?':
3778- return fprintf(out, "\\\?");
3779+ return gbprintf(out, "\\\?");
3780 case '\"':
3781- return fprintf(out, "\\\"");
3782+ return gbprintf(out, "\\\"");
3783 case '\'':
3784- return fprintf(out, "\\\'");
3785+ return gbprintf(out, "\\\'");
3786 default:
3787 if (isprint(value)) {
3788- fputc(value, out);
3789+ gbprintf(out, "%c", value);
3790 return 1;
3791 } else {
3792- return fprintf(out, "\\%o", value);
3793+ return gbprintf(out, "\\%o", value);
3794 }
3795 }
3796 }
3797
3798-GLOBAL int PrintString(FILE *out, const char *s)
3799+GLOBAL int PrintString(GBUF *out, const char *s)
3800 {
3801 int len = 0;
3802
3803- fputc('\"', out);
3804+ gbputs("\"", out);
3805 while (*s != 0) {
3806 len += PrintChar(out, *s++);
3807 }
3808- fputc('\"', out);
3809+ gbputs("\"", out);
3810
3811 return len + 2;
3812 }
3813diff -Nur 5.4.2.2/cilk2c/procedure.c current.Bug188/cilk2c/procedure.c
3814--- 5.4.2.2/cilk2c/procedure.c 2004-10-23 03:26:46.000000000 +0000
3815+++ current.Bug188/cilk2c/procedure.c 2005-10-22 02:52:37.000000000 +0000
3816@@ -31,7 +31,7 @@
3817 #include "ast.h"
3818
3819 FILE_IDENTITY(ident,
3820- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/cilk2c/procedure.c $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
3821+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/cilk2c/procedure.c $ $LastChangedBy: bradley $ $Rev: 2450 $ $Date$");
3822
3823 #include "conversions.h" /* for UsualUnaryConversionsType */
3824
3825@@ -101,8 +101,11 @@
3826 * 'cilk int' ! - athena
3827 *
3828 * BTW, the following line is a hack :-)
3829+ * ((ofdcl->u.fdcl.tq ^ nfdcl->u.fdcl.tq) & (T_PROCEDURE | T_INLET))
3830+ * Bradley rewrote it has follows:
3831 */
3832- if ((ofdcl->u.fdcl.tq ^ nfdcl->u.fdcl.tq) & (T_PROCEDURE | T_INLET))
3833+ if ((tq_has_procedure(ofdcl->u.fdcl.tq) != tq_has_procedure(nfdcl->u.fdcl.tq))
3834+ || (tq_has_inlet(ofdcl->u.fdcl.tq) != tq_has_inlet(nfdcl->u.fdcl.tq)))
3835 goto Mismatch;
3836
3837 /* The Result Type must be equal */
3838@@ -337,9 +340,9 @@
3839
3840 decl = FinishDecl(decl);
3841 if (Level == 0)
3842- NodeSetDeclLocation(decl, T_TOP_DECL);
3843+ NodeSetDeclLocation(decl, TQ_TOP_DECL);
3844 else
3845- NodeSetDeclLocation(decl, T_BLOCK_DECL);
3846+ NodeSetDeclLocation(decl, TQ_BLOCK_DECL);
3847
3848 /*
3849 * We know that this is a function definition, rather than merely a
3850@@ -365,8 +368,8 @@
3851 IterateList(&marker, fdcl->u.fdcl.args);
3852 while (NextOnList(&marker, (GenericREF) & arg))
3853 if (arg->typ == Id)
3854- ConvertIdToDecl(arg, T_FORMAL_DECL,
3855- MakeDefaultPrimType(EMPTY_TQ, arg->coord),
3856+ ConvertIdToDecl(arg, TQ_FORMAL_DECL,
3857+ MakeDefaultPrimType(EMPTY_TQ, arg->coord),
3858 NULL, NULL);
3859
3860
3861@@ -527,7 +530,7 @@
3862 WarningCoord(2, id->coord,
3863 "parameter `%s' defaults to signed int",
3864 id->u.id.text);
3865- ConvertIdToDecl(id, T_FORMAL_DECL,
3866+ ConvertIdToDecl(id, TQ_FORMAL_DECL,
3867 MakeDefaultPrimType(EMPTY_TQ, id->coord),
3868 NULL, NULL);
3869 }
3870@@ -556,8 +559,8 @@
3871 /* Set the type */
3872 IterateList(&il, ids);
3873 while (NextOnList(&il, (GenericREF) & id))
3874- ConvertIdToDecl(id, T_FORMAL_DECL,
3875- MakeDefaultPrimType(EMPTY_TQ, id->coord), NULL, NULL);
3876+ ConvertIdToDecl(id, TQ_FORMAL_DECL,
3877+ MakeDefaultPrimType(EMPTY_TQ, id->coord), NULL, NULL);
3878
3879 return decl;
3880 }
3881diff -Nur 5.4.2.2/cilk2c/profile.c current.Bug188/cilk2c/profile.c
3882--- 5.4.2.2/cilk2c/profile.c 2004-10-23 03:26:18.000000000 +0000
3883+++ current.Bug188/cilk2c/profile.c 2005-10-22 02:52:37.000000000 +0000
3884@@ -20,7 +20,7 @@
3885 #include "ast.h"
3886
3887 FILE_IDENTITY(ident,
3888- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/cilk2c/profile.c $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
3889+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/cilk2c/profile.c $ $LastChangedBy: bradley $ $Rev: 2483 $ $Date$");
3890
3891 /* ProfileProgram should convert a type-checked C (or Cilk) tree into a tree with profiling added.
3892 *
3893@@ -69,7 +69,7 @@
3894
3895 PRIVATE Node *BuildProfileRead(Node *addressnode, Node *node_to_take_sizeof, Coord coord) {
3896 return MakeCall(MakeId(ProfileReadName),
3897- List4(MakeCast(MakePtr(T_CONST, MakePrim(T_CONST, Void)),
3898+ List4(MakeCast(MakePtr(TQ_CONST, MakePrim(TQ_CONST, Void)),
3899 addressnode),
3900 MakeUnary(SIZEOF, node_to_take_sizeof),
3901 MakeImplicitCast(MakePtr(EMPTY_TQ, MakePrim(EMPTY_TQ, Char)),
3902@@ -79,7 +79,7 @@
3903
3904 PRIVATE Node *BuildProfileWrite(Node *addressnode, Node *node_to_take_sizeof, Coord coord) {
3905 return MakeCall(MakeId(ProfileWriteName),
3906- List4(MakeCast(MakePtr(T_CONST, MakePrim(T_CONST, Void)),
3907+ List4(MakeCast(MakePtr(TQ_CONST, MakePrim(TQ_CONST, Void)),
3908 addressnode),
3909 MakeUnary(SIZEOF, node_to_take_sizeof),
3910 MakeImplicitCast(MakePtr(EMPTY_TQ, MakePrim(EMPTY_TQ, Char)),
3911@@ -94,9 +94,9 @@
3912 }
3913
3914
3915-PRIVATE void MyNodeAddTq(Node *node, TypeQual tq) {
3916- NodeAddTq(node, tq & ~T_SUE_ELABORATED); /* Never stick SUE_ELABORATED on anything.*/
3917-}
3918+//PRIVATE void MyNodeAddTq(Node *node, TypeQual tq) {
3919+// NodeUpdateTq2(node, tq_union, tq_remove_sue_elaborated(tq)); /* Never stick SUE_ELABORATED on anything.*/
3920+//}
3921
3922
3923 PRIVATE const char *create_unique_identifier (Node *var, const char *root) {
3924@@ -388,7 +388,7 @@
3925 /* Tested*/
3926 Node *decl = MakeDecl(NULL, EMPTY_TQ, SetCoords(NodeCopy(NodeDataType(u->left), Subtree), UnknownCoord, Subtree), u->left, NULL);
3927 Node *newid = MakeId(create_unique_identifier(decl, "__addressCC"));
3928- MyNodeAddTq(decl->u.decl.type, T_CONST);
3929+ NodeUpdateTq(decl->u.decl.type, tq_add_const);
3930 return MakeBlock(NodeCopy(u->type, Subtree),
3931 List1(decl),
3932 List2(BuildProfileRead(newid,
3933@@ -413,11 +413,12 @@
3934 Node *idbasetype = SetCoords(NodeCopy(NodeDataType(node), Subtree), UnknownCoord, Subtree);
3935 Node *decl = MakeDecl(NULL,
3936 EMPTY_TQ,
3937- MakePtr(T_CONST, idbasetype),
3938+ MakePtr(TQ_CONST, idbasetype),
3939 MakeUnary(ADDRESS, node),
3940 NULL);
3941 Node *newid = MakeId(create_unique_identifier(decl, "__addressBB"));
3942- MyNodeAddTq(idbasetype, NodeTypeQuals(leftbasetype));
3943+ NodeUpdateTq2(idbasetype, tq_union,
3944+ tq_remove_sue_elaborated(NodeTypeQuals(leftbasetype))); /* Never stick SUE_ELABORATED on anything. */
3945 return MakeBlock(NodeCopy(u->type, Subtree),
3946 List1(decl),
3947 List2(BuildProfileRead(newid,
3948@@ -524,7 +525,7 @@
3949 case INDIR:
3950 u->expr=ProfileNode(u->expr, TRUE);
3951 if (readvalue) {
3952- Node *decl = MakeDecl(NULL, EMPTY_TQ, MakePtr(T_CONST, SetCoords(NodeCopy(u->type, Subtree), UnknownCoord, Subtree)), NULL, NULL);
3953+ Node *decl = MakeDecl(NULL, EMPTY_TQ, MakePtr(TQ_CONST, SetCoords(NodeCopy(u->type, Subtree), UnknownCoord, Subtree)), NULL, NULL);
3954 const char *addr_var = create_unique_identifier(decl, "__addressAA");
3955 Node *newid = MakeId(addr_var);
3956 newid->u.id.decl = decl;
3957@@ -560,7 +561,7 @@
3958 case POSTDEC:
3959 if (!lvalue_is_memory(u->expr)) return node;
3960 else {
3961- Node *decl = MakeDecl(NULL, EMPTY_TQ, MakePtr(T_CONST, SetCoords(NodeCopy(u->type, Subtree), UnknownCoord, Subtree)), NULL, NULL);
3962+ Node *decl = MakeDecl(NULL, EMPTY_TQ, MakePtr(TQ_CONST, SetCoords(NodeCopy(u->type, Subtree), UnknownCoord, Subtree)), NULL, NULL);
3963 const char *addr_var = create_unique_identifier(decl, "__addressFF");
3964 Node *newid = MakeId(addr_var);
3965 newid->u.id.decl = decl;
3966@@ -837,7 +838,7 @@
3967 }
3968
3969 PRIVATE Node *ProfileDecl(Node *node, declNode *u, UNUSED(Bool readvalue)) {
3970- if (NodeDeclLocation(node)==T_TOP_DECL
3971+ if (tq_has_top_decl(NodeDeclLocation(node))
3972 || DeclIsStatic(node))
3973 return node;
3974 /*u->type=ProfileNode(u->type);*/
3975@@ -860,7 +861,7 @@
3976 break;
3977 default:
3978 fprintf(stderr, "What is this decl (%s:%d)\n", __FILE__, __LINE__);
3979- PrintNode(stderr, item, 0);
3980+ fPrintNode(stderr, item, 0);
3981 abort();
3982 }
3983 }
3984@@ -879,18 +880,18 @@
3985 return JoinLists(List2(MakeDecl(ProfileReadName,
3986 EMPTY_TQ,
3987 MakeFdcl(EMPTY_TQ,
3988- List4(MakePtr(T_CONST, MakePrim(T_CONST, Void)),
3989+ List4(MakePtr(TQ_CONST, MakePrim(TQ_CONST, Void)),
3990 MakePrim(EMPTY_TQ, Uint),
3991- MakePtr(EMPTY_TQ, MakePrim(T_CONST, Char)),
3992+ MakePtr(EMPTY_TQ, MakePrim(TQ_CONST, Char)),
3993 MakePrim(EMPTY_TQ, Uint)),
3994 MakePrim(EMPTY_TQ, Void)),
3995 NULL, NULL),
3996 MakeDecl(ProfileWriteName,
3997 EMPTY_TQ,
3998 MakeFdcl(EMPTY_TQ,
3999- List4(MakePtr(T_CONST, MakePrim(T_CONST, Void)),
4000+ List4(MakePtr(TQ_CONST, MakePrim(TQ_CONST, Void)),
4001 MakePrim(EMPTY_TQ, Uint),
4002- MakePtr(EMPTY_TQ, MakePrim(T_CONST, Char)),
4003+ MakePtr(EMPTY_TQ, MakePrim(TQ_CONST, Char)),
4004 MakePrim(EMPTY_TQ, Uint)),
4005 MakePrim(EMPTY_TQ, Void)),
4006 NULL, NULL)),
4007diff -Nur 5.4.2.2/cilk2c/sem-check.c current.Bug188/cilk2c/sem-check.c
4008--- 5.4.2.2/cilk2c/sem-check.c 2004-10-23 03:26:43.000000000 +0000
4009+++ current.Bug188/cilk2c/sem-check.c 2005-10-22 02:52:37.000000000 +0000
4010@@ -31,7 +31,7 @@
4011 #include "ast.h"
4012
4013 FILE_IDENTITY(ident,
4014- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/cilk2c/sem-check.c $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
4015+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/cilk2c/sem-check.c $ $LastChangedBy: bradley $ $Rev: 2483 $ $Date$");
4016
4017 #include "conversions.h"
4018 #include "initializer.h"
4019@@ -112,7 +112,7 @@
4020 NodeSetConstantValue(node, NodeGetConstantValue(decl->u.decl.init));
4021 }
4022
4023- if (tq & T_CILKONLY) {
4024+ if (tq_has_cilkonly(tq)) {
4025 if (in_procedure || in_inlet) {
4026 /* ok */
4027 } else {
4028@@ -293,7 +293,7 @@
4029 case REAL:
4030 u->type = NodeCopy(NodeDataType(u->expr), NodeOnly);
4031 /* Now would be a good time to make sure that it actually is a number of some sort. */
4032- NodeRemoveTq(u->type, T_COMPLEX);
4033+ NodeUpdateTq(u->type, tq_remove_complex);
4034 break;
4035
4036 /* Function or object lvalue. Returns PTR to T */
4037@@ -442,9 +442,9 @@
4038 {
4039 if (call_type->typ == Fdcl) {
4040 SemCheckCallArgs(node, call_type->u.fdcl.args, u->args);
4041- if (call_type->u.fdcl.tq & T_PROCEDURE)
4042+ if (tq_has_procedure(call_type->u.fdcl.tq))
4043 SyntaxErrorCoord(node->coord, "use spawn to call a cilk procedure");
4044- else if (call_type->u.fdcl.tq & T_INLET)
4045+ else if (tq_has_inlet(call_type->u.fdcl.tq))
4046 SyntaxErrorCoord(node->coord, "inlets must have a spawned argument");
4047 } else if (call_type->typ == Ptr) {
4048 return SemCheckCall1(node, u, NodeDataType(call_type->u.ptr.type));
4049@@ -753,21 +753,21 @@
4050
4051 PRIVATE Node *SemCheckSdcl(Node *node, sdclNode *u)
4052 {
4053- if (SUE_ELABORATED(u->tq))
4054+ if (tq_has_sue_elaborated(u->tq))
4055 StructCheckFields(u->type);
4056 return node;
4057 }
4058
4059 PRIVATE Node *SemCheckUdcl(Node *node, udclNode *u)
4060 {
4061- if (SUE_ELABORATED(u->tq))
4062+ if (tq_has_sue_elaborated(u->tq))
4063 UnionCheckFields(u->type);
4064 return node;
4065 }
4066
4067 PRIVATE Node *SemCheckEdcl(Node *node, edclNode *u)
4068 {
4069- if (SUE_ELABORATED(u->tq))
4070+ if (tq_has_sue_elaborated(u->tq))
4071 AssignEnumValues(u->type);
4072 return node;
4073 }
4074@@ -785,7 +785,7 @@
4075 u->bitsize = SemCheckNode(u->bitsize);
4076
4077 if (u->init)
4078- SemCheckDeclInit(node, NodeDeclLocation(node) == T_BLOCK_DECL);
4079+ SemCheckDeclInit(node, tq_has_block_decl(NodeDeclLocation(node)));
4080 else {
4081 /* catch unsized arrays in blocks */
4082 if (DeclIsBlock(node)
4083@@ -793,18 +793,18 @@
4084 NodeSizeof(node, u->type, FALSE);
4085 }
4086
4087- if (u->tq & T_SHARED) {
4088- if (u->tq & T_PRIVATE)
4089+ if (tq_has_shared(u->tq)) {
4090+ if (tq_has_private(u->tq))
4091 SyntaxErrorCoord(node->coord,
4092 "variable `%s' cannot be both shared and private", u->name);
4093- if (NodeDeclLocation(node) != T_TOP_DECL)
4094+ if (!tq_has_top_decl(NodeDeclLocation(node)))
4095 SyntaxErrorCoord(node->coord,
4096 "only global variables can be shared");
4097 if (u->type->typ == Fdcl)
4098 SyntaxErrorCoord(node->coord,
4099 "functions cannot be declared shared", u->name);
4100- } else if (u->tq & T_PRIVATE) {
4101- if (NodeDeclLocation(node) != T_TOP_DECL)
4102+ } else if (tq_has_private(u->tq)) {
4103+ if (!tq_has_top_decl(NodeDeclLocation(node)))
4104 SyntaxErrorCoord(node->coord,
4105 "only global variables can be private");
4106 if (u->type->typ == Fdcl)
4107@@ -851,7 +851,7 @@
4108 } else if (IsEllipsis(item));
4109 else {
4110 fprintf(stderr, "Unrecognized parameter\n");
4111- PrintNode(stderr, item, 0);
4112+ fPrintNode(stderr, item, 0);
4113 fprintf(stderr, "\n");
4114 assert(FALSE);
4115 }
4116@@ -861,13 +861,13 @@
4117 save_in_procedure = in_procedure;
4118 save_in_inlet = in_inlet;
4119
4120- if (TYPE_QUALS(u->decl->u.decl.type->u.fdcl.tq) & T_PROCEDURE) {
4121- if (DECL_LOCATION(u->decl->u.decl.tq) != T_TOP_DECL)
4122+ if (tq_has_procedure(tq_type_quals(u->decl->u.decl.type->u.fdcl.tq))) {
4123+ if (!tq_has_top_decl(tq_decl_location(u->decl->u.decl.tq)))
4124 SyntaxErrorCoord(node->coord, "cilk procedure must be defined at top level");
4125- if (TYPE_QUALS(u->decl->u.decl.type->u.fdcl.tq) & T_INLET)
4126+ if (tq_has_inlet(tq_type_quals(u->decl->u.decl.type->u.fdcl.tq)))
4127 SyntaxErrorCoord(node->coord, "cilk procedure cannot be an inlet");
4128 in_procedure = 1;
4129- } else if (TYPE_QUALS(u->decl->u.decl.type->u.fdcl.tq) & T_INLET) {
4130+ } else if (tq_has_inlet(tq_type_quals(u->decl->u.decl.type->u.fdcl.tq))) {
4131 if (!in_procedure)
4132 SyntaxErrorCoord(node->coord,
4133 "inlet must be defined inside a cilk procedure");
4134@@ -942,7 +942,7 @@
4135 type = NodeDataType(type);
4136 if (type->typ == Fdcl) {
4137 TypeQual tq = NodeTq(type);
4138- return (tq & T_PROCEDURE) != 0;
4139+ return tq_has_procedure(tq);
4140 } else
4141 return FALSE;
4142 }
4143@@ -953,7 +953,7 @@
4144 type = NodeDataType(type);
4145 if (type->typ == Fdcl) {
4146 TypeQual tq = NodeTq(type);
4147- return (tq & T_INLET) != 0;
4148+ return tq_has_inlet(tq);
4149 } else
4150 return FALSE;
4151 }
4152@@ -1783,7 +1783,7 @@
4153 rtype = NodeDataType(right);
4154
4155 if (ltype == NULL) {
4156- PrintNode(stdout, left, 0);
4157+ fPrintNode(stdout, left, 0);
4158 printf("\n");
4159 }
4160 assert(left);
4161diff -Nur 5.4.2.2/cilk2c/simplify.c current.Bug188/cilk2c/simplify.c
4162--- 5.4.2.2/cilk2c/simplify.c 2004-10-23 03:26:46.000000000 +0000
4163+++ current.Bug188/cilk2c/simplify.c 2005-10-22 02:52:38.000000000 +0000
4164@@ -20,7 +20,7 @@
4165 #include "ast.h"
4166
4167 FILE_IDENTITY(ident,
4168- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/cilk2c/simplify.c $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
4169+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/cilk2c/simplify.c $ $LastChangedBy: bradley $ $Rev: 2483 $ $Date$");
4170
4171 /* The simplifications we do are as follows
4172 * Get rid of casts on lvalues. Thus
4173@@ -189,9 +189,9 @@
4174 u->left->u.array.type = ltype->u.adcl.type;
4175 } else {
4176 fprintf(stderr, "Failing because I have an arrow from a nonpointer type: \n");
4177- PrintNode(stderr, ltype, 0);
4178+ fPrintNode(stderr, ltype, 0);
4179 fprintf(stderr, "\nin this expression:\n");
4180- PrintNode(stderr, node, 0);
4181+ fPrintNode(stderr, node, 0);
4182 }
4183 }
4184 break;
4185diff -Nur 5.4.2.2/cilk2c/sue.c current.Bug188/cilk2c/sue.c
4186--- 5.4.2.2/cilk2c/sue.c 2004-10-23 03:26:46.000000000 +0000
4187+++ current.Bug188/cilk2c/sue.c 2005-10-22 02:52:37.000000000 +0000
4188@@ -31,7 +31,7 @@
4189 #include "ast.h"
4190
4191 FILE_IDENTITY(ident,
4192- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/cilk2c/sue.c $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
4193+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/cilk2c/sue.c $ $LastChangedBy: bradley $ $Rev: 2483 $ $Date$");
4194
4195
4196
4197@@ -59,30 +59,30 @@
4198 return (create);
4199 }
4200
4201-GLOBAL void PrintSUE(FILE *out, SUEtype *sue, int offset, Bool recursep)
4202+GLOBAL void PrintSUE(GBUF *out, SUEtype *sue, int offset, Bool recursep)
4203 {
4204 ListMarker marker;
4205 Node *decl;
4206 const char *name;
4207
4208 if (sue == NULL) {
4209- fprintf(out, "Null SUE");
4210+ gbprintf(out, "Null SUE");
4211 return;
4212 }
4213 name = (sue->name) ? sue->name : "nil";
4214
4215 switch (sue->typ) {
4216 case Sdcl:
4217- fprintf(out, "struct %s (%d)", name, sue->size);
4218+ gbprintf(out, "struct %s (%d)", name, sue->size);
4219 break;
4220 case Udcl:
4221- fprintf(out, "union %s", name);
4222+ gbprintf(out, "union %s", name);
4223 break;
4224 case Edcl:
4225- fprintf(out, "enum %s", name);
4226+ gbprintf(out, "enum %s", name);
4227 break;
4228 default:
4229- fprintf(out, "unexpected SUE type %d", sue->typ);
4230+ gbprintf(out, "unexpected SUE type %d", sue->typ);
4231 }
4232
4233 if (recursep) {
4234@@ -176,7 +176,7 @@
4235 sue->name = (OmitLookups() ? "___unnamed_sue_from_string" : InsertUniqueSymbol(Tags, sue, "___sue"));
4236 }
4237
4238- sudcl->u.sdcl.tq |= T_SUE_ELABORATED;
4239+ sudcl->u.sdcl.tq = tq_add_sue_elaborated(sudcl->u.sdcl.tq);
4240 sudcl->u.sdcl.type = sue;
4241
4242 assert(sue->attributes==0);
4243@@ -216,7 +216,7 @@
4244
4245 }
4246
4247- sudcl->u.sdcl.tq &= ~T_SUE_ELABORATED;
4248+ sudcl->u.sdcl.tq = tq_remove_sue_elaborated(sudcl->u.sdcl.tq);
4249 sudcl->u.sdcl.type = sue;
4250 return (sudcl);
4251 }
4252@@ -301,9 +301,9 @@
4253
4254 new = MakeEdclCoord(EMPTY_TQ, sue, enum_coord);
4255 if (values)
4256- new->u.edcl.tq |= T_SUE_ELABORATED;
4257+ new->u.edcl.tq = tq_add_sue_elaborated(new->u.edcl.tq);
4258 else
4259- new->u.edcl.tq &= ~T_SUE_ELABORATED;
4260+ new->u.edcl.tq = tq_remove_sue_elaborated(new->u.edcl.tq);
4261
4262 return new;
4263 }
4264@@ -360,8 +360,8 @@
4265
4266 GLOBAL Node *BuildEnumConst(Node *name, Node *value)
4267 {
4268- Node *decl = ConvertIdToDecl(name, T_ENUM_DECL,
4269- MakeDefaultPrimType(T_CONST, name->coord),
4270+ Node *decl = ConvertIdToDecl(name, TQ_ENUM_DECL,
4271+ MakeDefaultPrimType(TQ_CONST, name->coord),
4272 value, NULL);
4273 if (!OmitLookups()) {
4274 InsertSymbol(Identifiers, decl->u.decl.name, decl,
4275diff -Nur 5.4.2.2/cilk2c/testEquals.c current.Bug188/cilk2c/testEquals.c
4276--- 5.4.2.2/cilk2c/testEquals.c 2004-10-23 03:26:43.000000000 +0000
4277+++ current.Bug188/cilk2c/testEquals.c 2005-10-22 02:52:37.000000000 +0000
4278@@ -98,7 +98,7 @@
4279 /* n2 = ParseStringIntoASTNode(input2);*/
4280
4281 printf("The node: \n");
4282- PrintNode(stdout, n1, 0);
4283+ fPrintNode(stdout, n1, 0);
4284 printf("\n\n");
4285 }
4286
4287@@ -639,7 +639,7 @@
4288 printf("Error: ReplaceSyntaxSubtree TestCase %i: (%s, %s, %s) replace not %s. \n", i,
4289 testCases[4*i], testCases[4*i+1], testCases[4*i+2], testCases[4*i+3]);
4290 printf("The answer node we got back: \n");
4291- PrintNode(stdout, testResult, 0);
4292+ fPrintNode(stdout, testResult, 0);
4293 }
4294 }
4295
4296@@ -729,11 +729,11 @@
4297 numErrors++;
4298 printf("Error in CopyAST TestCase %d: copying %s \n", i, testCases[2*i]);
4299 printf("The copied result: \n");
4300- PrintNode(stdout, copyTree, 0);
4301+ fPrintNode(stdout, copyTree, 0);
4302 printf("\n");
4303
4304 printf("The correct result: \n");
4305- PrintNode(stdout, correctResult, 0);
4306+ fPrintNode(stdout, correctResult, 0);
4307 printf("\n");
4308 }
4309 }
4310@@ -1142,28 +1142,8 @@
4311
4312 if (n != NULL) {
4313 printf("The list: \n");
4314- PrintList(stdout, n, 0);
4315+ fPrintList(stdout, n, 0);
4316 printf("\n");
4317 }
4318
4319 }
4320-
4321-
4322-
4323-
4324-
4325-
4326-
4327-
4328-
4329-
4330-
4331-
4332-
4333-
4334-
4335-
4336-
4337-
4338-
4339-
4340diff -Nur 5.4.2.2/cilk2c/transform.c current.Bug188/cilk2c/transform.c
4341--- 5.4.2.2/cilk2c/transform.c 2004-10-23 03:26:44.000000000 +0000
4342+++ current.Bug188/cilk2c/transform.c 2005-10-22 02:52:37.000000000 +0000
4343@@ -30,7 +30,7 @@
4344 #include "ast.h"
4345
4346 FILE_IDENTITY(ident,
4347- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/cilk2c/transform.c $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
4348+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/cilk2c/transform.c $ $LastChangedBy: bradley $ $Rev: 2462 $ $Date$");
4349
4350 #include <ctype.h>
4351 #include "astEquals.h"
4352@@ -346,7 +346,7 @@
4353 assert(decl->typ == Decl);
4354 fdcl = decl->u.decl.type;
4355 assert(fdcl->typ == Fdcl);
4356- return (TYPE_QUALS(fdcl->u.fdcl.tq) & T_INLET) ? 1 : 0;
4357+ return tq_has_inlet(fdcl->u.fdcl.tq);
4358 }
4359
4360 /*
4361@@ -1294,21 +1294,21 @@
4362 NULL,
4363 NULL);
4364 worker_state = MakeDecl(WorkerStateName,
4365- T_FORMAL_DECL,
4366- MakePtr(T_CONST, MakeWorkerStateType()),
4367+ TQ_FORMAL_DECL,
4368+ MakePtr(TQ_CONST, MakeWorkerStateType()),
4369 NULL,
4370 NULL);
4371 AppendItem(u->args, frame);
4372 AppendItem(u->args, worker_state);
4373 }
4374
4375- if (u->tq & T_PROCEDURE) {
4376+ if (tq_has_procedure(u->tq)) {
4377 List *args;
4378 Node *n;
4379 args = u->args;
4380 n = MakeDecl(WorkerStateName,
4381- T_FORMAL_DECL,
4382- MakePtr(T_CONST, MakeWorkerStateType()),
4383+ TQ_FORMAL_DECL,
4384+ MakePtr(TQ_CONST, MakeWorkerStateType()),
4385 NULL,
4386 NULL);
4387
4388@@ -1451,7 +1451,7 @@
4389 }
4390 }
4391 /* delete static declarations (they have been globalized) -KHR */
4392- if (in_procedure && NodeStorageClass(node) == T_STATIC)
4393+ if (in_procedure && tq_has_static(NodeStorageClass(node)))
4394 return NULL;
4395
4396 /*
4397@@ -1459,12 +1459,12 @@
4398 * frame)
4399 */
4400 if (in_procedure && version == Slow)
4401- NodeRemoveTq(node->u.decl.type, T_CONST);
4402+ NodeUpdateTq(node->u.decl.type, tq_remove_const);
4403
4404 /*
4405 * Generate attribute for T_SHARED and T_PRIVATE variables
4406 */
4407- if (NodeDeclQuals(node) & T_PRIVATE) {
4408+ if (tq_has_private(NodeDeclTq(node))) {
4409 if (GenerateSegments) {
4410 if (!HasConstQual(node))
4411 u->attribs =
4412@@ -1476,14 +1476,14 @@
4413 } else
4414 WarningCoord(2, node->coord,
4415 "`private' qualifier not supported on this target\n");
4416- } else if (NodeDeclQuals(node) & T_SHARED ||
4417+ } else if (tq_has_shared(NodeDeclTq(node)) ||
4418 (GenerateSegments &&
4419- NodeDeclLocation(node) == T_TOP_DECL &&
4420- NodeStorageClass(node) != T_EXTERN &&
4421- NodeStorageClass(node) != T_REGISTER &&
4422- NodeStorageClass(node) != T_TYPEDEF &&
4423+ tq_has_top_decl(NodeDeclLocation(node)) &&
4424+ !tq_has_extern(NodeStorageClass(node)) &&
4425+ !tq_has_register(NodeStorageClass(node)) &&
4426+ !tq_has_typedef(NodeStorageClass(node)) &&
4427 NodeDataType(node)->typ != Fdcl)) {
4428- if ((NodeDeclQuals(node) & T_SHARED) && !GenerateSegments) {
4429+ if (tq_has_shared(NodeDeclTq(node)) && !GenerateSegments) {
4430 #if 0
4431 WarningCoord(2, node->coord,
4432 "`shared' qualifier not supported on this target\n");
4433@@ -1618,7 +1618,7 @@
4434 Node *inlet;
4435
4436 if (!IsVoidType(FirstItem(decl->u.decl.type->u.fdcl.args))) {
4437- args_decl = MakeSdcl(EMPTY_TQ | T_SUE_ELABORATED,
4438+ args_decl = MakeSdcl(TQ_SUE_ELABORATED,
4439 make_SUE(Sdcl,
4440 MakeInletArgsTypeName(name),
4441 decl->u.decl.type->u.fdcl.args));
4442@@ -1666,13 +1666,11 @@
4443
4444 inlet_decl = ParseWildcardStringNode("static void %d(%t %d, %t *%d, %t *%d, %t *%d);",
4445 name,
4446- MakePtr(T_CONST, MakeWorkerStateType()), WorkerStateName,
4447+ MakePtr(TQ_CONST, MakeWorkerStateType()), WorkerStateName,
4448 MakeFrameType(proc_name), FrameName,
4449 args_type, InletArgsName,
4450 NodeCopy(decl->u.decl.type->u.fdcl.returns, Subtree), InletResultName);
4451- NodeAddTq(inlet_decl, T_SLOW_INLET);
4452-
4453-
4454+ NodeUpdateTq(inlet_decl, tq_add_slow_inlet);
4455
4456 if (args_decl)
4457 SetCoords(args_decl, node->coord, Subtree);
4458@@ -1701,7 +1699,7 @@
4459 Node *inlet;
4460
4461 if (!IsVoidType(FirstItem(decl->u.decl.type->u.fdcl.args))) {
4462- args_decl = MakeSdcl(EMPTY_TQ | T_SUE_ELABORATED,
4463+ args_decl = MakeSdcl(TQ_SUE_ELABORATED,
4464 make_SUE(Sdcl,
4465 MakeInletArgsTypeName(name),
4466 decl->u.decl.type->u.fdcl.args));
4467@@ -1713,8 +1711,8 @@
4468
4469 inlet_type = MakeFdcl(EMPTY_TQ,
4470 List4(MakeDecl(WorkerStateName,
4471- T_FORMAL_DECL,
4472- MakePtr(T_CONST,
4473+ TQ_FORMAL_DECL,
4474+ MakePtr(TQ_CONST,
4475 MakeWorkerStateType()),
4476 NULL,
4477 NULL),
4478@@ -1740,7 +1738,7 @@
4479 MakePrim(EMPTY_TQ, Void));
4480
4481 inlet_decl = MakeDecl(name,
4482- T_STATIC | T_SLOW_INLET,
4483+ tq_add_static(TQ_SLOW_INLET),
4484 inlet_type,
4485 NULL,
4486 NULL);
4487@@ -1783,8 +1781,8 @@
4488
4489 inlet_type = MakeFdcl(EMPTY_TQ,
4490 List4(MakeDecl(WorkerStateName,
4491- T_FORMAL_DECL,
4492- MakePtr(T_CONST,
4493+ TQ_FORMAL_DECL,
4494+ MakePtr(TQ_CONST,
4495 MakeWorkerStateType()),
4496 NULL,
4497 NULL),
4498@@ -1809,7 +1807,7 @@
4499 MakePrim(EMPTY_TQ, Void));
4500
4501 inlet_decl = MakeDecl(name,
4502- T_STATIC | T_SLOW_INLET,
4503+ tq_add_static(TQ_SLOW_INLET),
4504 inlet_type,
4505 NULL,
4506 NULL);
4507@@ -1840,7 +1838,7 @@
4508 }
4509 else {
4510 /* indicate this starts C code for CILK_WHERE_AM_I */
4511- NodeAddTq(u->decl, T_C_CODE);
4512+ NodeUpdateTq(u->decl, tq_add_c_code);
4513 curr_inlet = NULL;
4514 inlet_name = NULL;
4515 }
4516@@ -1853,9 +1851,9 @@
4517
4518 /* Change the type qualifier into T_SLOW_INLET for CILK_WHERE_AM_I */
4519 if (version == Fast)
4520- NodeAddTq(u->decl, T_FAST_INLET);
4521+ NodeUpdateTq(u->decl, tq_add_fast_inlet);
4522 if (version == Slow)
4523- NodeAddTq(u->decl, T_SLOW_INLET);
4524+ NodeUpdateTq(u->decl, tq_add_slow_inlet);
4525
4526 /* make standalone inlet */
4527 if (version == Slow)
4528@@ -2781,7 +2779,7 @@
4529 const char *tmp = MakeTempName();
4530 Node *returntype = node->u.Return.proc->u.proc.decl->u.decl.type->u.fdcl.returns;
4531 Node *decl = MakeDecl(tmp,
4532- T_BLOCK_DECL,
4533+ TQ_BLOCK_DECL,
4534 NodeCopy(returntype, Subtree),
4535 node->u.Return.expr,
4536 NULL);
4537@@ -2809,20 +2807,20 @@
4538 PRIVATE Node *MakeSlowDecl(const char *name)
4539 {
4540 Node *arg = MakeDecl(FrameName,
4541- T_FORMAL_DECL,
4542+ TQ_FORMAL_DECL,
4543 MakePtr(EMPTY_TQ, MakeFrameType(name)),
4544 NULL,
4545 NULL);
4546
4547 Node *ws = MakeDecl(WorkerStateName,
4548- T_FORMAL_DECL,
4549- MakePtr(T_CONST, MakeWorkerStateType()),
4550+ TQ_FORMAL_DECL,
4551+ MakePtr(TQ_CONST, MakeWorkerStateType()),
4552 NULL,
4553 NULL);
4554
4555 Node *n =
4556 MakeDecl(MakeSlowProcName(name),
4557- T_STATIC | T_TOP_DECL | T_SLOW_PROCEDURE,
4558+ tq_add_static(tq_add_top_decl(TQ_SLOW_PROCEDURE)),
4559 MakeFdcl(EMPTY_TQ, List2(ws, arg),
4560 MakePrim(EMPTY_TQ, Void)),
4561 NULL,
4562@@ -2838,12 +2836,12 @@
4563
4564 n = NodeCopy(u->decl, Subtree);
4565 n->u.decl.name = MakeExportProcName(n->u.decl.name);
4566- n->u.decl.tq = n->u.decl.tq | T_TOP_DECL | T_C_CODE;
4567+ n->u.decl.tq = tq_add_top_decl(tq_add_c_code(n->u.decl.tq));
4568 args = TransformList(n->u.decl.type->u.fdcl.args);
4569 /*printf("MakeExportDecl -name=%s\n", name);*/
4570 context = MakeDecl(ContextName,
4571- T_FORMAL_DECL,
4572- MakePtr(T_CONST, MakeContextType()),
4573+ TQ_FORMAL_DECL,
4574+ MakePtr(TQ_CONST, MakeContextType()),
4575 NULL,
4576 NULL);
4577
4578@@ -2870,19 +2868,19 @@
4579
4580 n = NodeCopy(u->decl, Subtree);
4581 n->u.decl.name = MakeImportProcName(n->u.decl.name);
4582- n->u.decl.tq = T_STATIC | T_TOP_DECL | T_C_CODE;
4583+ n->u.decl.tq = tq_add_static(tq_add_top_decl(TQ_C_CODE));
4584 n->u.decl.type->u.fdcl.returns = MakePrim(EMPTY_TQ, Void);
4585 args = TransformList(n->u.decl.type->u.fdcl.args);
4586 returns = u->decl->u.decl.type->u.fdcl.returns;
4587
4588 ws = MakeDecl(WorkerStateName,
4589- T_FORMAL_DECL,
4590- MakePtr(T_CONST, MakeWorkerStateType()),
4591+ TQ_FORMAL_DECL,
4592+ MakePtr(TQ_CONST, MakeWorkerStateType()),
4593 NULL,
4594 NULL);
4595
4596 arg_struct = MakeDecl(ProcArgsName_v,
4597- T_FORMAL_DECL,
4598+ TQ_FORMAL_DECL,
4599 MakePtr(EMPTY_TQ, NodeCopy(PrimVoid, Subtree)), /*MakeProcArgsType(u->decl->u.decl.name)),*/
4600 NULL,
4601 NULL);
4602@@ -2904,11 +2902,11 @@
4603 int scope_count)
4604 {
4605 TypeQual sc = NodeStorageClass(decl);
4606- if (sc == T_EXTERN || sc == T_STATIC || sc == T_TYPEDEF ||
4607+ if (tq_has_extern(sc) || tq_has_static(sc) || tq_has_typedef(sc) ||
4608 decl->u.decl.type->typ == Fdcl)
4609 return; /* leave as kind 0 */
4610
4611- if (scope_count > 0 && DECL_LOCATION(decl->u.decl.tq) == T_FORMAL_DECL) {
4612+ if (scope_count > 0 && tq_has_formal_decl(decl->u.decl.tq)) {
4613 /* inlet argument variable */
4614 decl->u.decl.kind = 4;
4615 } else if (FindItem(register_vars, decl)) {
4616@@ -3040,7 +3038,7 @@
4617 if (new->typ == Tdef) {
4618 if (LookupSymbol(Identifiers, new->u.tdef.name,
4619 (GenericREF) & junk)) {
4620- if (NodeStorageClass(junk) == T_TYPEDEF &&
4621+ if (tq_has_typedef(NodeStorageClass(junk)) &&
4622 junk->u.decl.type == new->u.tdef.type)
4623 return new; /* external declaration is OK */
4624 }
4625@@ -3058,7 +3056,7 @@
4626 * is this the right thing to do with tdef's type qualifiers? -
4627 * KHR
4628 */
4629- NodeAddTq(new->u.tdef.type, new->u.tdef.tq);
4630+ NodeUpdateTq2(new->u.tdef.type, tq_union, new->u.tdef.tq);
4631 return new->u.tdef.type;
4632 } else
4633 return new;
4634@@ -3108,7 +3106,7 @@
4635 * scopes in a oneof because only one is being used at a time.
4636 */
4637 fields = List1(MakeDecl(HeaderName,
4638- EMPTY_TQ | T_SU_DECL,
4639+ TQ_SU_DECL,
4640 MakeGenericFrameType(),
4641 NULL,
4642 NULL));
4643@@ -3118,7 +3116,7 @@
4644 if (!IsVoidType(type) && !IsScalarType(type)) {
4645 fields = AppendItem(fields,
4646 MakeDecl(DummyReturnName,
4647- EMPTY_TQ | T_SU_DECL,
4648+ TQ_SU_DECL,
4649 NodeCopy(type, Subtree),
4650 NULL,
4651 NULL));
4652@@ -3140,8 +3138,10 @@
4653 if (decl->u.decl.kind == 0)
4654 continue;
4655 SetCurrentOnList(&marker2, NodeCopy(decl, Subtree));
4656- NodeRemoveTq(decl, T_REGISTER);
4657- NodeRemoveTq(decl->u.decl.type, T_CONST);
4658+ if (tq_has_register(decl->u.decl.tq)) {
4659+ decl->u.decl.tq = tq_remove_all_storage_classes(decl->u.decl.tq);
4660+ }
4661+ NodeUpdateTq(decl->u.decl.type, tq_remove_const);
4662 remove_unused_attribute(decl);
4663 decl->u.decl.type = ExpandTypedefs(decl->u.decl.type);
4664 decl->u.decl.init = NULL;
4665@@ -3152,9 +3152,9 @@
4666 if (scopefields)
4667 fields = AppendItem(fields,
4668 MakeDecl(MakeScopeName(scope_count),
4669- EMPTY_TQ | T_SU_DECL,
4670- MakeSdcl(EMPTY_TQ | T_SUE_ELABORATED,
4671- make_SUE(Sdcl, NULL, scopefields)),
4672+ TQ_SU_DECL,
4673+ MakeSdcl(TQ_SUE_ELABORATED,
4674+ make_SUE(Sdcl, NULL, scopefields)),
4675 NULL,
4676 NULL));
4677 scope_count++;
4678@@ -3162,8 +3162,8 @@
4679
4680 /* finally, make struct declaration for frame */
4681 result = MakeDecl(NULL,
4682- EMPTY_TQ | T_TOP_DECL,
4683- MakeSdcl(EMPTY_TQ | T_SUE_ELABORATED,
4684+ TQ_TOP_DECL,
4685+ MakeSdcl(TQ_SUE_ELABORATED,
4686 make_SUE(Sdcl, MakeFrameTypeName(u->decl->u.decl.name), fields)),
4687 NULL,
4688 NULL);
4689@@ -3194,7 +3194,7 @@
4690 returns = NodeCopy(fdcl->u.fdcl.returns, Subtree);
4691
4692 fields = ConsItem( MakeDecl(ProcResultName,
4693- T_FORMAL_DECL,
4694+ TQ_FORMAL_DECL,
4695 returns,
4696 NULL,
4697 NULL),
4698@@ -3203,7 +3203,7 @@
4699
4700 /* Create the structure */
4701 if ( fields ) {
4702- args_decl = MakeSdcl(EMPTY_TQ | T_SUE_ELABORATED,
4703+ args_decl = MakeSdcl(TQ_SUE_ELABORATED,
4704 make_SUE(Sdcl,
4705 MakeProcArgsTypeName(decl->u.decl.name),
4706 fields));
4707@@ -3225,7 +3225,7 @@
4708 USE_UNUSED(node);
4709 /* make CilkProcInfo declaration */
4710 linkage = MakeDecl(MakeLinkName(proc_name),
4711- T_STATIC,
4712+ TQ_STATIC,
4713 MakeAdcl(EMPTY_TQ,
4714 MakeTdef(EMPTY_TQ,
4715 UniqueString("CilkProcInfo")),
4716@@ -3289,7 +3289,7 @@
4717
4718 return MakeBlock(NULL,
4719 List1(MakeDecl(FrameName,
4720- EMPTY_TQ | T_BLOCK_DECL,
4721+ TQ_BLOCK_DECL,
4722 MakePtr(EMPTY_TQ,
4723 MakeFrameType(proc_name)),
4724 NULL,
4725@@ -3517,11 +3517,11 @@
4726 }
4727 switch (type->typ) {
4728 case Sdcl:
4729- return MakeSdcl(T_SUE_ELABORATED, type);
4730+ return MakeSdcl(TQ_SUE_ELABORATED, type);
4731 case Udcl:
4732- return MakeUdcl(T_SUE_ELABORATED, type);
4733+ return MakeUdcl(TQ_SUE_ELABORATED, type);
4734 case Edcl:
4735- return MakeEdcl(T_SUE_ELABORATED, type);
4736+ return MakeEdcl(TQ_SUE_ELABORATED, type);
4737 default:
4738 FAIL("bad type in GlobalizeSUE");
4739 return NULL;
4740@@ -3538,26 +3538,26 @@
4741
4742 switch (node->typ) {
4743 case Sdcl:
4744- if (SUE_ELABORATED(node->u.sdcl.tq)) {
4745+ if (tq_has_sue_elaborated(node->u.sdcl.tq)) {
4746 new = GlobalizeSUE(node->u.sdcl.type);
4747- NodeRemoveTq(node, T_SUE_ELABORATED);
4748+ NodeUpdateTq(node, tq_remove_sue_elaborated);
4749 }
4750 break;
4751 case Udcl:
4752- if (SUE_ELABORATED(node->u.udcl.tq)) {
4753+ if (tq_has_sue_elaborated(node->u.udcl.tq)) {
4754 new = GlobalizeSUE(node->u.udcl.type);
4755- NodeRemoveTq(node, T_SUE_ELABORATED);
4756+ NodeUpdateTq(node, tq_remove_sue_elaborated);
4757 }
4758 break;
4759 case Edcl:
4760- if (SUE_ELABORATED(node->u.edcl.tq)) {
4761+ if (tq_has_sue_elaborated(node->u.edcl.tq)) {
4762 new = GlobalizeSUE(node->u.edcl.type);
4763- NodeRemoveTq(node, T_SUE_ELABORATED);
4764+ NodeUpdateTq(node, tq_remove_sue_elaborated);
4765 }
4766 break;
4767 case Decl:
4768- if (NodeStorageClass(node) == T_STATIC &&
4769- NodeDeclLocation(node) == T_BLOCK_DECL) {
4770+ if (tq_has_static(NodeStorageClass(node)) &&
4771+ tq_has_block_decl(NodeDeclLocation(node))) {
4772 Node *junk;
4773 /* choose a globally unique name for this static *
4774 * variable */
4775@@ -3567,7 +3567,7 @@
4776 InsertSymbol(Identifiers, node->u.decl.name, node, NULL);
4777 }
4778 new = node;
4779- NodeSetDeclLocation(new, T_TOP_DECL);
4780+ NodeSetDeclLocation(new, TQ_TOP_DECL);
4781 new = TransformDecl(new, &new->u.decl);
4782
4783 /*
4784@@ -3631,7 +3631,8 @@
4785 * later as a top level function.
4786 */
4787 if ((node->typ == Proc) &&
4788- (node->u.proc.decl->u.decl.tq & (T_SLOW_INLET | T_FAST_INLET))) {
4789+ (tq_has_slow_inlet(node->u.proc.decl->u.decl.tq) ||
4790+ tq_has_fast_inlet(node->u.proc.decl->u.decl.tq))) {
4791 const char* this_inlet_name = MakeInnerInletName(node->u.proc.decl->u.decl.name);
4792 const char* short_name;
4793
4794@@ -3890,7 +3891,7 @@
4795 fastnode->u.proc.decl->u.decl.name = MakeFastProcName( fastnode->u.proc.decl->u.decl.name );
4796
4797 /* set fast decl flag */
4798- NodeAddTq(fastnode->u.proc.decl, T_FAST_PROCEDURE);
4799+ NodeUpdateTq(fastnode->u.proc.decl, tq_add_fast_procedure);
4800
4801 /* make slow procedure declaration */
4802 result = AppendItem(result,
4803@@ -3938,7 +3939,7 @@
4804
4805 if (node->typ == Proc &&
4806 node->u.proc.decl->u.decl.type->typ == Fdcl &&
4807- node->u.proc.decl->u.decl.type->u.fdcl.tq & T_PROCEDURE) {
4808+ tq_has_procedure(node->u.proc.decl->u.decl.type->u.fdcl.tq)) {
4809 /* cilk procedure */
4810 result = TransformCilkProc(node, &node->u.proc);
4811 } else
4812diff -Nur 5.4.2.2/cilk2c/type.c current.Bug188/cilk2c/type.c
4813--- 5.4.2.2/cilk2c/type.c 2004-10-23 03:26:21.000000000 +0000
4814+++ current.Bug188/cilk2c/type.c 2005-10-22 02:54:14.000000000 +0000
4815@@ -31,7 +31,7 @@
4816 #include "ast.h"
4817
4818 FILE_IDENTITY(ident,
4819- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/cilk2c/type.c $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
4820+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/cilk2c/type.c $ $LastChangedBy: bradley $ $Rev: 2506 $ $Date$");
4821
4822
4823 PRIVATE Bool IsLvalue_Local(Node *node, Bool modifiablep);
4824@@ -97,7 +97,7 @@
4825 PrimFloat = MakePrim(EMPTY_TQ, Float);
4826 PrimDouble = MakePrim(EMPTY_TQ, Double);
4827 PrimLongdouble = MakePrim(EMPTY_TQ, Longdouble);
4828- StaticString = MakePtr(EMPTY_TQ, MakePrim(T_STATIC, Char));
4829+ StaticString = MakePtr(EMPTY_TQ, MakePrim(TQ_STATIC, Char));
4830
4831 /* Make some standard zeros */
4832 SintZero = MakeConstSint(0);
4833@@ -125,189 +125,77 @@
4834 /* */
4835 /*************************************************************************/
4836
4837-GLOBAL int TQtoText(char array[], TypeQual tq)
4838+GLOBAL void TQtoText(char array[], int arraysize, TypeQual tq)
4839+/* TQtoText is used only to produce diagnostics. Hence there is no need for a full OutputContext. */
4840 {
4841- array[0] = '\0';
4842-
4843- if (tq & T_EXTENSION) {
4844- strcat(array, "__extension__ ");
4845- }
4846- switch (STORAGE_CLASS(tq)) {
4847- case T_TYPEDEF:
4848- strcat(array, "typedef ");
4849- break;
4850- case T_EXTERN:
4851- strcat(array, "extern ");
4852- break;
4853- case T_STATIC:
4854- strcat(array, "static ");
4855- break;
4856- case T_AUTO:
4857- strcat(array, "auto ");
4858- break;
4859- case T_REGISTER:
4860- strcat(array, "register ");
4861- break;
4862- case 0: /* no explicit storage class */
4863- break;
4864- default:
4865- UNREACHABLE;
4866- }
4867-
4868- switch (DECL_LOCATION(tq)) {
4869- case T_TOP_DECL:
4870- strcat(array, "top_decl ");
4871- break;
4872- case T_BLOCK_DECL:
4873- strcat(array, "block_decl ");
4874- break;
4875- case T_FORMAL_DECL:
4876- strcat(array, "formal_decl ");
4877- break;
4878- case T_SU_DECL:
4879- strcat(array, "su_decl ");
4880- break;
4881- case T_ENUM_DECL:
4882- strcat(array, "enum_decl ");
4883- break;
4884- case 0:
4885- break;
4886- default:
4887- UNREACHABLE;
4888- }
4889-
4890- if (tq & T_REDUNDANT_EXTERNAL_DECL)
4891- strcat(array, "redundant_extern ");
4892+ GBUF *gb=make_string_gbuf(array,arraysize);
4893+ TQtoGBUF(gb, tq);
4894+}
4895
4896- if (tq & T_SHARED)
4897- strcat(array, "shared ");
4898- if (tq & T_PRIVATE)
4899- strcat(array, "private ");
4900-
4901- if (tq & T_INLINE) {
4902- #ifdef inline
4903-/* This hacking is the standard CPP idiom for stringifying the result of a macro expansion.
4904- * In this case, the macro inline might be defined in ../config.h as
4905- * #define inline __inline
4906- * and we want to get the string "__inline"
4907- * Suppose we did
4908- * STR(inline)
4909- * that would expand to
4910- * #inline
4911- * which would expand to
4912- * "inline"
4913- * which is not what we want. If we do
4914- * XSTR(inline)
4915- * that expands to
4916- * STR(inline)
4917- * and then the args are expanded to give
4918- * STR(__inline)
4919- * and then the STR macro is expanded to give
4920- * #__inline
4921- * finally yielding
4922- * "__inline"
4923- * The whole point of this hack is to produce a string for "inline" that will work with the
4924- * C compiler we are using,as determined by ../configure and stored in ../config.h
4925- */
4926-#define STR(S) #S
4927-#define XSTR(S) STR(S)
4928- strcat(array, XSTR(inline) " "); /* Use the system-specific inline from config.h */
4929- #else
4930- strcat(array, "inline ");
4931- #endif
4932- }
4933- if (tq & T_CONST)
4934- strcat(array, "const ");
4935- if (tq & T_VOLATILE)
4936- strcat(array, "volatile ");
4937- if (tq & T_RESTRICT)
4938- strcat(array, "__restrict ");
4939- if (tq & T_COMPLEX)
4940- strcat(array, "__complex__ ");
4941- if (tq & T_NOOUTPUT) {
4942- strcat(array, "__nooutput__ ");
4943- }
4944- if (tq & T_CILKONLY) {
4945- strcat(array, "__cilkonly__ ");
4946- }
4947- if (tq & T_CILKSAFE) {
4948- strcat(array, "__cilksafe__ ");
4949- }
4950- if (tq & T_SUE_ELABORATED)
4951- strcat(array, "sue_elaborated ");
4952- if (tq & T_PROCEDURE)
4953- strcat(array, "cilk ");
4954- if (tq & T_INLET)
4955- strcat(array, "inlet ");
4956-
4957- return strlen(array);
4958-}
4959-
4960-GLOBAL int PrintTQ(FILE *out, TypeQual tq)
4961-{
4962- char tmp[256];
4963-
4964- TQtoText(tmp, tq);
4965- fputs(tmp, out);
4966- return strlen(tmp);
4967+GLOBAL void PrintTQ(GBUF *out, TypeQual tq, int offset, UNUSED(Bool norecurse))
4968+/* PrintTQ is used only to produce diagnostics. Hence there is no need for a full OutputContext. */
4969+{
4970+ TQtoGBUF(out, tq);
4971+ if (tq.attributes) PrintList(out, tq.attributes, offset);
4972 }
4973
4974 GLOBAL TypeQual MergeTypeQuals(TypeQual left, TypeQual right, Coord coord)
4975 {
4976 TypeQual scl, scr, dql, dqr, tql, tqr;
4977- TypeQual result = 0;
4978+ TypeQual result = tq_attribute(JoinLists(left.attributes,right.attributes));
4979
4980- scl = STORAGE_CLASS(left);
4981- scr = STORAGE_CLASS(right);
4982+ scl = tq_storage_class(left);
4983+ scr = tq_storage_class(right);
4984
4985- if (scl != 0 && scr != 0) {
4986- if (scl == scr) { /* scl == scr == single storage class */
4987+ if (tq_has_anything(scl) && tq_has_anything(scr)) {
4988+ if (tq_equal(scl, scr)) { /* scl == scr == single storage class */
4989 char name[20];
4990- TQtoText(name, scl);
4991+ TQtoText(name, 20, scl);
4992 name[strlen(name) - 1] = 0;
4993 WarningCoord(4, coord, "redundant storage class `%s'", name);
4994 } else {
4995 char namel[20], namer[20];
4996- TQtoText(namel, scl);
4997+ TQtoText(namel, 20, scl);
4998 namel[strlen(namel) - 1] = 0;
4999- TQtoText(namer, scr);
5000+ TQtoText(namer, 20, scr);
5001 namer[strlen(namer) - 1] = 0;
5002 SyntaxErrorCoord(coord, "conflicting storage classes `%s' and `%s'",
5003 namel, namer);
5004 }
5005- result |= scl;
5006+ result = tq_union(result, scl);
5007 } else {
5008- result |= scl | scr;
5009+ result = tq_union(result, tq_union(scl, scr));
5010 }
5011
5012- dql = DECL_QUALS(left) & ~scl;
5013- dqr = DECL_QUALS(right) & ~scr;
5014+ dql = tq_subtract(tq_decl_quals(left), scl);
5015+ dqr = tq_subtract(tq_decl_quals(right), scr);
5016
5017- if ((dql & dqr) != 0) {
5018+ if (tq_has_anything(tq_intersection(dql, dqr))) {
5019 char name[20];
5020- TQtoText(name, dql & dqr);
5021+ TQtoText(name, 20, tq_intersection(dql, dqr));
5022 name[strlen(name) - 1] = 0;
5023 WarningCoord(4, coord, "redundant declaration qualifier `%s'", name);
5024 }
5025- result |= (dql | dqr);
5026+ result = tq_union(result, tq_union(dql, dqr));
5027
5028- tql = TYPE_QUALS(left);
5029- tqr = TYPE_QUALS(right);
5030+ tql = tq_type_quals(left);
5031+ tqr = tq_type_quals(right);
5032
5033- if ((tql & tqr) != 0) {
5034+ if (tq_has_anything(tq_intersection(tql, tqr))) {
5035 char name[20];
5036- TQtoText(name, tql & tqr);
5037+ TQtoText(name, 20, tq_intersection(tql, tqr));
5038 name[strlen(name) - 1] = 0;
5039 WarningCoord(4, coord, "redundant type qualifier `%s'", name);
5040 }
5041- result |= (tql | tqr);
5042+ result = tq_union(result, tq_union(tql, tqr));
5043+
5044 return (result);
5045 }
5046
5047 /* The tq_coord is passed in and the resulting coord is the min of the original coord and the new coord.
5048 * That is because in the process of parsing, you can actually have a terminal X that appears after terminal Y and
5049 * yet terminal X's coordinate is before terminal Y's coord, and we end up with nonidempotent parsing.
5050- * How can this happen? Line directives can make it happne.
5051+ * How can this happen? Line directives can make it happen.
5052 */
5053 GLOBAL Node *TypeQualifyNode(Node *node, TypeQual tq, Coord *tq_coord)
5054 {
5055@@ -339,13 +227,13 @@
5056 node->u.fdcl.tq = MergeTypeQuals(node->u.fdcl.tq, tq, node->coord);
5057 break;
5058 default:
5059- PrintNode(stdout, node, 0);
5060+ fPrintNode(stdout, node, 0);
5061 printf("\n");
5062
5063 /* this assertion always fails */
5064 FAIL("Unexpected node type");
5065 }
5066- minf_coord(&node->coord, tq_coord);
5067+ if (tq_coord) minf_coord(&node->coord, tq_coord);
5068 return (node);
5069 }
5070
5071@@ -380,69 +268,92 @@
5072 return node->u.fdcl.tq;
5073 default:
5074 fprintf(stderr, "Internal Error! Unrecognized type\n");
5075- PrintNode(stderr, node, 0);
5076+ fPrintNode(stderr, node, 0);
5077 fprintf(stderr, "\n");
5078 assert(FALSE);
5079 }
5080 return (EMPTY_TQ); /* unreachable */
5081 }
5082
5083-GLOBAL void NodeSetTq(Node *node, TypeQual mask, TypeQual tq)
5084-{
5085- switch (node->typ) {
5086- case Prim:
5087- node->u.prim.tq &= ~mask;
5088- node->u.prim.tq |= tq;
5089- break;
5090- case Tdef:
5091- node->u.tdef.tq &= ~mask;
5092- node->u.tdef.tq |= tq;
5093- break;
5094- case Ptr:
5095- node->u.ptr.tq &= ~mask;
5096- node->u.ptr.tq |= tq;
5097- break;
5098- case Adcl:
5099- node->u.adcl.tq &= ~mask;
5100- node->u.adcl.tq |= tq;
5101- break;
5102- case Sdcl:
5103- node->u.sdcl.tq &= ~mask;
5104- node->u.sdcl.tq |= tq;
5105- break;
5106- case Udcl:
5107- node->u.udcl.tq &= ~mask;
5108- node->u.udcl.tq |= tq;
5109- break;
5110- case Edcl:
5111- node->u.edcl.tq &= ~mask;
5112- node->u.edcl.tq |= tq;
5113- break;
5114- case Decl:
5115- node->u.decl.tq &= ~mask;
5116- node->u.decl.tq |= tq;
5117- break;
5118- case Fdcl:
5119- node->u.fdcl.tq &= ~mask;
5120- node->u.fdcl.tq |= tq;
5121- break;
5122- default:
5123- fprintf(stderr, "Internal Error! Unrecognized type\n");
5124- PrintNode(stderr, node, 0);
5125- fprintf(stderr, "\n");
5126- assert(FALSE);
5127- }
5128-}
5129-
5130-GLOBAL void NodeAddTq(Node *node, TypeQual tq)
5131-{
5132- NodeSetTq(node, 0, tq);
5133-}
5134-
5135-GLOBAL void NodeRemoveTq(Node *node, TypeQual tq)
5136+#define UPDATEF(field) field = f(field)
5137+GLOBAL void NodeUpdateTq(Node *node, TypeQual(*f)(TypeQual))
5138 {
5139- NodeSetTq(node, tq, 0);
5140+ switch (node->typ) {
5141+ case Prim:
5142+ UPDATEF(node->u.prim.tq);
5143+ break;
5144+ case Tdef:
5145+ UPDATEF(node->u.tdef.tq);
5146+ break;
5147+ case Ptr:
5148+ UPDATEF(node->u.ptr.tq);
5149+ break;
5150+ case Adcl:
5151+ UPDATEF(node->u.adcl.tq);
5152+ break;
5153+ case Sdcl:
5154+ UPDATEF(node->u.sdcl.tq);
5155+ break;
5156+ case Udcl:
5157+ UPDATEF(node->u.udcl.tq);
5158+ break;
5159+ case Edcl:
5160+ UPDATEF(node->u.edcl.tq);
5161+ break;
5162+ case Decl:
5163+ UPDATEF(node->u.decl.tq);
5164+ break;
5165+ case Fdcl:
5166+ UPDATEF(node->u.fdcl.tq);
5167+ break;
5168+ default:
5169+ fprintf(stderr, "Internal Error! Unrecognized type\n");
5170+ fPrintNode(stderr, node, 0);
5171+ fprintf(stderr, "\n");
5172+ assert(FALSE);
5173+ }
5174+}
5175+#undef UPDATEF
5176+
5177+#define UPDATEF(field) field = f(field, tq2)
5178+GLOBAL void NodeUpdateTq2(Node *node, TypeQual(*f)(TypeQual, TypeQual), TypeQual tq2)
5179+{
5180+ switch (node->typ) {
5181+ case Prim:
5182+ UPDATEF(node->u.prim.tq);
5183+ break;
5184+ case Tdef:
5185+ UPDATEF(node->u.tdef.tq);
5186+ break;
5187+ case Ptr:
5188+ UPDATEF(node->u.ptr.tq);
5189+ break;
5190+ case Adcl:
5191+ UPDATEF(node->u.adcl.tq);
5192+ break;
5193+ case Sdcl:
5194+ UPDATEF(node->u.sdcl.tq);
5195+ break;
5196+ case Udcl:
5197+ UPDATEF(node->u.udcl.tq);
5198+ break;
5199+ case Edcl:
5200+ UPDATEF(node->u.edcl.tq);
5201+ break;
5202+ case Decl:
5203+ UPDATEF(node->u.decl.tq);
5204+ break;
5205+ case Fdcl:
5206+ UPDATEF(node->u.fdcl.tq);
5207+ break;
5208+ default:
5209+ fprintf(stderr, "Internal Error! Unrecognized type\n");
5210+ fPrintNode(stderr, node, 0);
5211+ fprintf(stderr, "\n");
5212+ assert(FALSE);
5213+ }
5214 }
5215+#undef UPDATEF
5216
5217 /*
5218 * NodeTypeQuals, NodeStorageClass, and NodeDeclQuals only work
5219@@ -451,37 +362,42 @@
5220 */
5221 GLOBAL TypeQual NodeTypeQuals(Node *node)
5222 {
5223- return TYPE_QUALS(NodeTq(node));
5224+ return tq_type_quals(NodeTq(node));
5225 }
5226
5227 GLOBAL TypeQual NodeStorageClass(Node *node)
5228 {
5229- assert(node->typ == Decl);
5230- assert(IsDecl(node));
5231- return STORAGE_CLASS(node->u.decl.tq);
5232+ return tq_storage_class(NodeDeclTq(node));
5233 }
5234
5235 GLOBAL void NodeSetStorageClass(Node *node, TypeQual sc)
5236 {
5237- NodeSetTq(node, T_STORAGE_CLASSES, sc);
5238+ NodeUpdateTq2(node, tq_set_storage_class_from, sc);
5239+}
5240+
5241+GLOBAL TypeQual NodeDeclTq (Node *node) {
5242+ assert(node->typ==Decl);
5243+ assert(IsDecl(node));
5244+ return node->u.decl.tq;
5245 }
5246
5247+/*
5248 GLOBAL TypeQual NodeDeclQuals(Node *node)
5249 {
5250- assert(node->typ == Decl);
5251- return DECL_QUALS(node->u.decl.tq);
5252+ return DECL_QUALS(NodeDeclTq(node));
5253 }
5254+*/
5255
5256 GLOBAL TypeQual NodeDeclLocation(Node *node)
5257 {
5258 assert(node->typ == Decl);
5259 assert(IsDecl(node));
5260- return DECL_LOCATION(node->u.decl.tq);
5261+ return tq_decl_location(node->u.decl.tq);
5262 }
5263
5264 GLOBAL void NodeSetDeclLocation(Node *node, TypeQual dl)
5265 {
5266- NodeSetTq(node, T_DECL_LOCATIONS, dl);
5267+ NodeUpdateTq2(node, tq_set_decl_location_from, dl);
5268 }
5269
5270 /*************************************************************************/
5271@@ -507,7 +423,7 @@
5272 /* note: memory leak of *n2 */
5273
5274 assert(node != NULL && node->typ == Prim);
5275- assert(node != NULL && n2->typ == Prim);
5276+ assert(n2 != NULL && n2->typ == Prim);
5277
5278 BASIC2EXPLODED(node->u.prim.basic, et1);
5279 BASIC2EXPLODED(n2->u.prim.basic, et2);
5280@@ -715,6 +631,11 @@
5281 return FinishPrimType(create);
5282 }
5283
5284+GLOBAL const char *TypeName(TypeSpecifier ts) {
5285+ assert(ts<MaxBasicType); // ts is an unsigned value
5286+ return TypeNames[ts];
5287+}
5288+
5289 PRIVATE const char *TypeSpecifierName(TypeSpecifier ts)
5290 {
5291 if ((ts & BasicTypeMask) != 0)
5292@@ -781,40 +702,13 @@
5293 return type;
5294 }
5295
5296- if ((tq = NodeTq(type)) != EMPTY_TQ) {
5297+ if (tq_has_anything(tq = NodeTq(type))) {
5298 new = NodeCopy(new, NodeOnly);
5299- NodeAddTq(new, tq);
5300+ NodeUpdateTq2(new, tq_union, tq);
5301 }
5302 return new;
5303 }
5304
5305-GLOBAL void PrimToText(char array[], Node *type)
5306-{
5307- char *ptr = array;
5308- int len;
5309-
5310- assert(type);
5311- assert(type->typ == Prim);
5312-
5313- len = TQtoText(ptr, type->u.prim.tq & (unsigned int)~T_SUE_ELABORATED); /* Don't print sue_elaborated */
5314- ptr += len;
5315-
5316- strcpy(ptr, TypeNames[type->u.prim.basic]);
5317-}
5318-
5319-GLOBAL int PrintPrimType(FILE *out, Node *type, char *lastc)
5320-{
5321- char tmp[256];
5322- int len;
5323-
5324- PrimToText(tmp, type);
5325- fputs(tmp, out);
5326- len = strlen(tmp);
5327- if (len>0 && lastc)
5328- *lastc = tmp[len-1];
5329- return len;
5330-}
5331-
5332 /*************************************************************************/
5333 /* */
5334 /* Resolving identifiers through the symbol table */
5335@@ -836,7 +730,7 @@
5336 REFERENCE(var);
5337 if (TrackIds) {
5338 fprintf(stderr, "=== `%s' = ", name);
5339- PrintNode(stderr, var, 0);
5340+ fPrintNode(stderr, var, 0);
5341 printf("\n");
5342 }
5343 }
5344@@ -874,7 +768,7 @@
5345 id->u.id.text);
5346
5347 var = MakeDeclCoord(id->u.id.text,
5348- T_TOP_DECL,
5349+ TQ_TOP_DECL,
5350 MakeFdclCoord(EMPTY_TQ, NULL, MakeDefaultPrimType(EMPTY_TQ, id->coord),
5351 id->coord),
5352 NULL,
5353@@ -894,7 +788,7 @@
5354 REFERENCE(var);
5355 if (TrackIds) {
5356 fprintf(stderr, "=== `%s' = ", id->u.id.text);
5357- PrintNode(stderr, var, 0);
5358+ fPrintNode(stderr, var, 0);
5359 }
5360 }
5361 return (call);
5362@@ -937,7 +831,7 @@
5363 Warning(1, "Internal Error!");
5364 fprintf(stderr, "\tLookupPostfixExpression: unexpected node:\n");
5365 PrintASTcoords=TRUE;
5366- PrintNode(stderr, post, 2);
5367+ fPrintNode(stderr, post, 2);
5368 FAIL("Unexpected node type");
5369 }
5370 return (post);
5371@@ -963,9 +857,9 @@
5372
5373 if (var->u.decl.references == 0 && type->typ != Fdcl) {
5374 /* give warning only if unused local variable */
5375- if (NodeDeclLocation(var) == T_BLOCK_DECL &&
5376- NodeStorageClass(var) != T_EXTERN)
5377- WarningCoord(2, var->coord, "unused variable `%s'", VAR_NAME(var));
5378+ if (tq_has_block_decl(NodeDeclLocation(var)) &&
5379+ !tq_has_extern(NodeStorageClass(var)))
5380+ WarningCoord(2, var->coord, "unused variable `%s'", VAR_NAME(var));
5381 }
5382 }
5383
5384@@ -1021,7 +915,7 @@
5385 WarningCoord(1, node->coord,
5386 "NodeSizeof(): Unrecognized primitive type %d",
5387 type->u.prim.basic);
5388- PrintNode(stderr, node, 0);
5389+ fPrintNode(stderr, node, 0);
5390 fputc('\n', stderr);
5391 return 1;
5392 }
5393@@ -1072,7 +966,7 @@
5394 WarningCoord(1, node->coord,
5395 "NodeSizeof(): Unrecognized node type %d",
5396 type->typ);
5397- PrintNode(stderr, node, 0);
5398+ fPrintNode(stderr, node, 0);
5399 fputc('\n', stderr);
5400 return 1;
5401 default:
5402@@ -1160,32 +1054,34 @@
5403
5404 GLOBAL Bool DeclIsExtern(Node *node)
5405 {
5406- return (NodeStorageClass(node) == T_EXTERN);
5407+ assert(node->typ == Decl);
5408+ return tq_has_extern(node->u.decl.tq);
5409 }
5410
5411 GLOBAL Bool NodeIsConstQual(Node *node)
5412 {
5413- return (NodeTypeQuals(node) & T_CONST) != 0;
5414+ return tq_has_const(NodeTq(node));
5415 }
5416
5417 GLOBAL Bool NodeIsCilkProcedure(Node *node)
5418 {
5419- return (NodeTypeQuals(node) & T_PROCEDURE) != 0;
5420+ return tq_has_procedure(NodeTq(node));
5421 }
5422
5423 GLOBAL Bool DeclIsEnumConst(Node *node)
5424 {
5425- return NodeDeclLocation(node) == T_ENUM_DECL;
5426+ assert(node->typ == Decl);
5427+ return tq_has_enum_decl(node->u.decl.tq);
5428 }
5429
5430 GLOBAL Bool DeclIsTypedef(Node *node)
5431 {
5432- return (NodeStorageClass(node) == T_TYPEDEF);
5433+ return tq_has_typedef(NodeStorageClass(node));
5434 }
5435
5436 GLOBAL Bool DeclIsStatic(Node *node)
5437 {
5438- return (NodeStorageClass(node) == T_STATIC);
5439+ return tq_has_static(NodeStorageClass(node));
5440 }
5441
5442 GLOBAL Bool DeclIsExternal(Node *node)
5443@@ -1193,12 +1089,12 @@
5444 TypeQual sc = NodeStorageClass(node);
5445 TypeQual dl = NodeDeclLocation(node);
5446
5447- return sc == T_EXTERN || dl == T_TOP_DECL;
5448+ return tq_has_extern(sc) || tq_has_top_decl(dl);
5449 }
5450
5451 GLOBAL Bool DeclIsBlock(Node *node)
5452 {
5453- return (NodeDeclLocation(node) == T_BLOCK_DECL);
5454+ return tq_has_block_decl(NodeDeclLocation(node));
5455 }
5456
5457 GLOBAL Node *PtrSubtype(Node *ptr)
5458@@ -1387,7 +1283,7 @@
5459 UnwindTdefs(&type, &tq);
5460
5461 /* test first for modifiability, if required by caller */
5462- if (modifiablep && (tq & T_CONST) != 0)
5463+ if (modifiablep && tq_has_const(tq))
5464 return FALSE;
5465
5466 /* now test whether node is an lvalue */
5467@@ -1404,7 +1300,7 @@
5468 return TRUE;
5469 case Adcl:
5470 case Fdcl:
5471- if (NodeDeclLocation(node->u.id.decl) == T_FORMAL_DECL)
5472+ if (tq_has_formal_decl(NodeDeclLocation(node->u.id.decl)))
5473 /* formals of type array or function are treated as pointers to same,
5474 * thus lvalues */
5475 return TRUE;
5476@@ -1792,7 +1688,7 @@
5477 *ptq = NodeTypeQuals(*pnode);
5478 while ((*pnode)->typ == Tdef) {
5479 *pnode = (*pnode)->u.tdef.type;
5480- *ptq |= NodeTypeQuals(*pnode);
5481+ *ptq = tq_union(*ptq, NodeTypeQuals(*pnode));
5482 }
5483 }
5484
5485@@ -1824,13 +1720,13 @@
5486 UnwindTdefs(&node1, &tq1);
5487 UnwindTdefs(&node2, &tq2);
5488
5489- tq1 &= ~T_SUE_ELABORATED;
5490- tq2 &= ~T_SUE_ELABORATED;
5491+ tq1 = tq_remove_sue_elaborated(tq1);
5492+ tq2 = tq_remove_sue_elaborated(tq2);
5493 if (!strict_toplevel) {
5494- tq1 &= ~TQ_COMPATIBLE;
5495- tq2 &= ~TQ_COMPATIBLE;
5496+ tq1 = tq_remove_compatible(tq1);
5497+ tq2 = tq_remove_compatible(tq2);
5498 }
5499- if (tq1 != tq2)
5500+ if (!tq_equal(tq1, tq2))
5501 return FALSE;
5502
5503 if (node1->typ != node2->typ)
5504@@ -1930,5 +1826,3 @@
5505 }
5506 return FALSE; /* eliminates warning */
5507 }
5508-
5509-
5510diff -Nur 5.4.2.2/cilk2c/type.h current.Bug188/cilk2c/type.h
5511--- 5.4.2.2/cilk2c/type.h 2004-10-23 03:26:42.000000000 +0000
5512+++ current.Bug188/cilk2c/type.h 2005-10-22 02:52:38.000000000 +0000
5513@@ -31,7 +31,7 @@
5514 #ifndef _TYPE_H_
5515 #define _TYPE_H_
5516 FILE_IDENTITY(type_ident,
5517- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/cilk2c/type.h $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
5518+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/cilk2c/type.h $ $LastChangedBy: bradley $ $Rev: 2484 $ $Date$");
5519
5520 GLOBAL extern Node *EllipsisNode; /* represents '...' primitive type */
5521
5522@@ -91,25 +91,27 @@
5523 GLOBAL TypeQual MergeTypeQuals(TypeQual left, TypeQual right, Coord coord);
5524 GLOBAL Node *MakeMergedType(Node *type1, Node *qual1);
5525 GLOBAL TypeQual NodeTq(Node *node);
5526-GLOBAL void NodeSetTq(Node *node, TypeQual mask, TypeQual tq);
5527-GLOBAL void NodeAddTq(Node *node, TypeQual tq);
5528-GLOBAL void NodeRemoveTq(Node *node, TypeQual tq);
5529+GLOBAL void NodeUpdateTq(Node *node, TypeQual(*f)(TypeQual));
5530+GLOBAL void NodeUpdateTq2(Node *node, TypeQual(*f)(TypeQual, TypeQual), TypeQual tq2);
5531 GLOBAL TypeQual NodeTypeQuals(Node *node);
5532-GLOBAL TypeQual NodeDeclQuals(Node *node);
5533+GLOBAL TypeQual NodeDeclTq (Node *node); /* Return all the typequals on a decl (error if it is not a decl) */
5534+/*GLOBAL TypeQual NodeDeclQuals(Node *node);*/
5535 GLOBAL TypeQual NodeStorageClass(Node *node);
5536 GLOBAL void NodeSetStorageClass(Node *node, TypeQual sc);
5537 GLOBAL TypeQual NodeDeclLocation(Node *node);
5538 GLOBAL void NodeSetDeclLocation(Node *node, TypeQual dl);
5539-GLOBAL int TQtoText(char array[], TypeQual tq);
5540-GLOBAL int PrintTQ(FILE *out, TypeQual tq);
5541+GLOBAL void TQtoText(char array[], int arraysize, TypeQual tq); /* TQtoText is only used to produce error messages. Hence no need for a full OutputContext. */
5542+GLOBAL void PrintTQ(GBUF *out, TypeQual tq, int offset, Bool norecurse); /* PrintTQ is only used to produce diagnostics, and we don't really need a full OutputContext */
5543
5544 GLOBAL Node *StartPrimType(BasicType basic, Coord coord);
5545 GLOBAL Node *MergePrimTypes(Node *node, Node *node2);
5546 GLOBAL Node *FinishPrimType(Node *PrimNode);
5547 GLOBAL Node *MakeDefaultPrimType(TypeQual tq, Coord coord);
5548 GLOBAL Node *SansSign(Node *type);
5549-GLOBAL void PrimToText(char array[], Node *type);
5550-GLOBAL int PrintPrimType(FILE *out, Node *type, char *lastc); /* return the number of characters printed, and if any are printed and lastc!=NULL, set *lastc to the last character sent. */
5551+
5552+/* return the number of characters printed, and if any are printed and lastc!=NULL, set *lastc to the last character sent. */
5553+GLOBAL int PrintPrimType(GBUF *gb, Node *type, char *lastc);
5554+
5555
5556 GLOBAL Node *LookupFunction(Node *call);
5557 GLOBAL Node *LookupPostfixExpression(Node *post);
5558@@ -214,7 +216,7 @@
5559
5560 /* Global procedures from sue.c */
5561
5562-GLOBAL void PrintSUE(FILE *out, SUEtype *sue, int offset, Bool norecurse);
5563+GLOBAL void PrintSUE(GBUF *out, SUEtype *sue, int offset, Bool norecurse);
5564 GLOBAL Node *SetSUdclNameFields(Node *sudcl, Node *id, List *fields, Coord left_coord, Coord right_coord, List *attributes);
5565 GLOBAL Node *SetSUdclName(Node *sudcl, Node *id, Coord coord);
5566 GLOBAL Node *BuildEnum(Node *id, List *values, Coord enum_coord, Coord left_coord, Coord right_coord);
5567@@ -248,6 +250,7 @@
5568 GLOBAL Node *NodeDataTypeSuperior(Node *node);
5569 GLOBAL void SetNodeDataType(Node *node, Node *type);
5570 GLOBAL Node *SdclFindField(Node *sdcl, Node *field_name);
5571+GLOBAL const char*TypeName(TypeSpecifier);
5572
5573 /* From operators.c */
5574 GLOBAL const char *OperatorName(OpType op);
5575diff -Nur 5.4.2.2/cilk2c/type2.c current.Bug188/cilk2c/type2.c
5576--- 5.4.2.2/cilk2c/type2.c 2004-10-23 03:26:19.000000000 +0000
5577+++ current.Bug188/cilk2c/type2.c 2005-10-22 02:52:37.000000000 +0000
5578@@ -31,7 +31,7 @@
5579 #include "ast.h"
5580
5581 FILE_IDENTITY(ident,
5582- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/cilk2c/type2.c $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
5583+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/cilk2c/type2.c $ $LastChangedBy: bradley $ $Rev: 2483 $ $Date$");
5584
5585
5586 PRIVATE Node *NodeDataTypeBase(Node *node, Bool TdefIndir);
5587@@ -55,7 +55,7 @@
5588
5589 if (result == NULL) {
5590 printf("NodeDataType(). Trying to return NULL\n");
5591- PrintNode(stdout, node, 0);
5592+ fPrintNode(stdout, node, 0);
5593 printf("\n");
5594 assert(FALSE);
5595 }
5596@@ -72,7 +72,7 @@
5597
5598 if (result == NULL) {
5599 printf("NodeDataTypeSuperior(). Trying to return NULL\n");
5600- PrintNode(stdout, node, 0);
5601+ fPrintNode(stdout, node, 0);
5602 printf("\n");
5603 assert(FALSE);
5604 }
5605@@ -207,7 +207,7 @@
5606
5607 default:
5608 fprintf(stderr, "Internal Error! NodeDataType: Unknown node type\n");
5609- PrintNode(stderr, node, 0);
5610+ fPrintNode(stderr, node, 0);
5611 fprintf(stderr, "\n");
5612 return node;
5613 }
5614@@ -279,7 +279,7 @@
5615 fprintf(stderr, "ArrayType: Node at ");
5616 PRINT_COORD(stderr, array->coord);
5617 fputc('\n', stderr);
5618- PrintNode(stderr, array, 0);
5619+ fPrintNode(stderr, array, 0);
5620 fprintf(stderr, "\n");
5621 assert(FALSE);
5622 return (NULL);
5623@@ -300,16 +300,16 @@
5624 return (SdclFindField(sdcl->u.binop.type, field_name));
5625 else {
5626 printf("SdclFindField(): not a supported binop\n");
5627- PrintNode(stdout, sdcl, 0);
5628+ fPrintNode(stdout, sdcl, 0);
5629 printf("\n");
5630- PrintNode(stdout, field_name, 0);
5631+ fPrintNode(stdout, field_name, 0);
5632 printf("\n");
5633 assert(FALSE);
5634 } else {
5635 printf("SdclFindField(): not a recognized type\n");
5636- PrintNode(stdout, sdcl, 0);
5637+ fPrintNode(stdout, sdcl, 0);
5638 printf("\n");
5639- PrintNode(stdout, field_name, 0);
5640+ fPrintNode(stdout, field_name, 0);
5641 printf("\n");
5642 assert(FALSE);
5643 }
5644diff -Nur 5.4.2.2/cilk2c/typequal.c current.Bug188/cilk2c/typequal.c
5645--- 5.4.2.2/cilk2c/typequal.c 1970-01-01 00:00:00.000000000 +0000
5646+++ current.Bug188/cilk2c/typequal.c 2005-10-22 02:54:14.000000000 +0000
5647@@ -0,0 +1,285 @@
5648+#include "ast.h"
5649+
5650+typedef enum {
5651+
5652+ EMPTY_TQ_enum = 0,
5653+/*
5654+ Declaration qualifiers. A declaration can have multiple qualifiers,
5655+ though some are mutually exclusive (like storage classes).
5656+ During the parsing of a declaration, decl qualifiers are kept in
5657+ the tq field of its primitive type. After the decl has been parsed,
5658+ SetDeclType then moves the qualifiers to their proper place, the
5659+ Decl node.
5660+
5661+ To add a new decl qualifier:
5662+ 1. Define a new symbol below, being careful that its bits do
5663+ not conflict with existing decl and type qualifiers,
5664+ since they can coexist in the same TypeQual variable.
5665+ 2. Insert the symbol in T_DECL_QUALS (below).
5666+ 3. If the qualifier is parsed in the source (rather than calculated),
5667+ add a lexical token (c4.l) and a new production to storage.classes
5668+ (ANSI-C.y).
5669+ 4. Add code to print out its name in TQtoText (type.c).
5670+ 5. Add merging logic to MergeTypeQuals (type.c), if necessary.
5671+*/
5672+
5673+ T_AUTO = 0x00001,
5674+ T_EXTERN = 0x00002,
5675+ T_REGISTER = 0x00003,
5676+ T_STATIC = 0x00004,
5677+ T_TYPEDEF = 0x00005,
5678+ /* Insert new storage classes here */
5679+
5680+ T_STORAGE_CLASSES = (T_AUTO | T_EXTERN | T_REGISTER | T_STATIC | T_TYPEDEF),
5681+#define STORAGE_CLASS(tq) ((tq) & T_STORAGE_CLASSES)
5682+
5683+ /* the following qualifiers are all mutually exclusive,
5684+ so they can share bits */
5685+ T_TOP_DECL = 0x00010, /* top-level decl */
5686+ T_BLOCK_DECL = 0x00020, /* local decl in a block */
5687+ T_FORMAL_DECL = 0x00030, /* formal parameter decl */
5688+ T_SU_DECL = 0x00040, /* struct/union field decl */
5689+ T_ENUM_DECL = 0x00050, /* enumerated constant decl */
5690+ /* Insert new decl locations here */
5691+
5692+ T_DECL_LOCATIONS = (T_TOP_DECL | T_BLOCK_DECL | T_FORMAL_DECL |
5693+ T_SU_DECL | T_ENUM_DECL),
5694+#define DECL_LOCATION(tq) ((tq) & T_DECL_LOCATIONS)
5695+
5696+ /* Flag for redundant external declaration, which is defined as
5697+ * an external declaration (NOT a definition, so it must have no
5698+ * initializer or function body) of a name previously declared external
5699+ * in the same scope. A trivial example:
5700+ * extern int x;
5701+ * extern int x; <-- redundant
5702+ * But:
5703+ * { extern int x; }
5704+ * { extern int x; } <-- not redundant
5705+ * because the two declarations have different scopes.
5706+ */
5707+ T_REDUNDANT_EXTERNAL_DECL = 0x00100,
5708+
5709+ /* Insert new decl qualifiers here */
5710+ T_SHARED = 0x00200,
5711+ T_PRIVATE = 0x00400,
5712+ T_NOOUTPUT = 0x00800,
5713+ T_CILKONLY = 0x01000, /* variable can only be used in cilk code */
5714+ T_CILKSAFE = 0x02000, /* promise that this variable is safe to access in parallel */
5715+
5716+ /* the following tq's are used to generate CILK_WHERE_AM_I directives */
5717+ T_FAST_PROCEDURE = 0x04000,
5718+ T_SLOW_PROCEDURE = 0x08000,
5719+ T_FAST_INLET = 0x10000,
5720+ T_SLOW_INLET = 0x20000,
5721+ T_STANDALONE_INLET = 0x40000,
5722+ T_C_CODE = 0x80000,
5723+
5724+ T_CILK_WHERE_AM_I_DECL_QUALS = (T_FAST_PROCEDURE | T_SLOW_PROCEDURE | T_FAST_INLET | T_SLOW_INLET | T_STANDALONE_INLET | T_C_CODE),
5725+
5726+ T_DECL_QUALS = (T_STORAGE_CLASSES | T_DECL_LOCATIONS
5727+ | T_REDUNDANT_EXTERNAL_DECL
5728+ | T_SHARED | T_PRIVATE | T_NOOUTPUT
5729+ | T_CILKONLY | T_CILKSAFE
5730+ | T_CILK_WHERE_AM_I_DECL_QUALS
5731+ ),
5732+
5733+#define DECL_QUALS(tq) ((tq) & T_DECL_QUALS)
5734+
5735+
5736+/*
5737+ Type qualifiers. Multiple type qualifiers may apply to a type.
5738+ They may be associated with any primitive or complex type.
5739+ Some type qualifiers may be moved after parsing -- for instance,
5740+ T_INLINE is moved to the top-level Fdcl it is describing.
5741+
5742+ To add a new type qualifier:
5743+ 1. Define a new symbol below, being careful that its bits do
5744+ not conflict with existing storage classes and type qualifiers,
5745+ since they can coexist in the same TypeQual variable.
5746+ 2. Insert the symbol in T_TYPE_QUALS (below).
5747+ 3. Add a lexical token (c4.l) and a new production to either
5748+ type.qualifiers or pointer.type.qualifiers (ANSI-C.y), depending
5749+ on whether the type qualifier is allowed only at the beginning
5750+ of a type, or can appear after '*' like const and volatile.
5751+ 4. Add code to print out its name in TQtoText (type.c).
5752+ 5. Add its symbol to TQ_ALWAYS_COMPATIBLE (below) if an object with
5753+ the type qualifier is always assignment-compatible with an object
5754+ without the type qualifier.
5755+ 6. Add merging logic to MergeTypeQuals (type.c), if necessary.
5756+ */
5757+
5758+ T_RESTRICT = 0x100000,
5759+ T_COMPLEX = 0x200000,
5760+
5761+ T_CONST = 0x400000, /* leave some room for new decl qualifiers */
5762+ T_VOLATILE = 0x800000,
5763+ T_INLINE = 0x1000000,
5764+ T_SUE_ELABORATED = 0x2000000, /* on an Sdcl/Udcl/Edcl, indicates
5765+ whether SUE's field list appeared
5766+ at that point in the source */
5767+#define SUE_ELABORATED(tq) (((tq) & T_SUE_ELABORATED) != 0)
5768+ /* Insert new type qualifiers here */
5769+ T_PROCEDURE = 0x4000000,
5770+
5771+ T_INLET = 0x8000000,
5772+
5773+ T_EXTENSION = 0x10000000, /* used for gcc __extension__ keyword. Not exactly a TYPE_QUAL */
5774+
5775+ T_TYPE_QUALS = (T_RESTRICT | T_COMPLEX | T_CONST | T_VOLATILE | T_INLINE | T_SUE_ELABORATED | T_PROCEDURE | T_INLET ),
5776+#define TYPE_QUALS(tq) ((tq) & T_TYPE_QUALS)
5777+
5778+/* Type qualifiers listed in TQ_COMPATIBLE are ignored
5779+ * when checking two types for compatibility (weaker than strict equality). */
5780+ TQ_COMPATIBLE = (T_CONST | T_VOLATILE | T_INLINE | T_SUE_ELABORATED | T_RESTRICT | T_EXTENSION)
5781+
5782+}
5783+ TypeQual_enum;
5784+
5785+PRIVATE inline int bit_is_set(TypeQual tq, TypeQual_enum bit) {
5786+ return (tq.tq&bit)==bit;
5787+}
5788+PRIVATE inline TypeQual TQ (TypeQual_enum e) {
5789+ return (TypeQual){e,0};
5790+}
5791+GLOBAL TypeQual tq_attribute (List *attrib) {
5792+ return (TypeQual){0,attrib};
5793+}
5794+PRIVATE inline TypeQual TQsetbit(TypeQual tq, TypeQual_enum bits) {
5795+ return (TypeQual){tq.tq|bits, tq.attributes};
5796+}
5797+PRIVATE inline TypeQual TQclearbit(TypeQual tq, TypeQual_enum bits) {
5798+ return (TypeQual){tq.tq&~bits, tq.attributes};
5799+}
5800+
5801+GLOBAL int tq_has_auto (TypeQual tq) { return STORAGE_CLASS(tq.tq)==T_AUTO; }
5802+GLOBAL int tq_has_extern (TypeQual tq) { return STORAGE_CLASS(tq.tq)==T_EXTERN; }
5803+GLOBAL int tq_has_register (TypeQual tq) { return STORAGE_CLASS(tq.tq)==T_REGISTER; }
5804+GLOBAL int tq_has_static (TypeQual tq) { return STORAGE_CLASS(tq.tq)==T_STATIC; }
5805+GLOBAL int tq_has_typedef (TypeQual tq) { return STORAGE_CLASS(tq.tq)==T_TYPEDEF; }
5806+GLOBAL int tq_has_some_storageclass (TypeQual tq) { return STORAGE_CLASS(tq.tq)!=0; }
5807+
5808+GLOBAL TypeQual tq_add_auto (TypeQual tq) { return TQsetbit(tq,T_AUTO); }
5809+GLOBAL TypeQual tq_add_extern (TypeQual tq) { return TQsetbit(tq,T_EXTERN); }
5810+GLOBAL TypeQual tq_add_register (TypeQual tq) { return TQsetbit(tq,T_REGISTER); }
5811+GLOBAL TypeQual tq_add_static (TypeQual tq) { return TQsetbit(tq,T_STATIC); }
5812+GLOBAL TypeQual tq_add_typedef (TypeQual tq) { return TQsetbit(tq,T_TYPEDEF); }
5813+
5814+GLOBAL TypeQual tq_storage_class (TypeQual tq) { return TQ(STORAGE_CLASS(tq.tq)); }
5815+GLOBAL TypeQual tq_remove_all_storage_classes (TypeQual tq) { return TQ(tq.tq&~T_STORAGE_CLASSES); }
5816+GLOBAL TypeQual tq_set_storage_class_from (TypeQual dest, TypeQual source) { return tq_union(tq_remove_all_storage_classes(dest),tq_storage_class(source)); }
5817+
5818+
5819+GLOBAL int tq_has_top_decl (TypeQual tq) { return DECL_LOCATION(tq.tq)==T_TOP_DECL; }
5820+GLOBAL int tq_has_block_decl (TypeQual tq) { return DECL_LOCATION(tq.tq)==T_BLOCK_DECL; }
5821+GLOBAL int tq_has_formal_decl (TypeQual tq) { return DECL_LOCATION(tq.tq)==T_FORMAL_DECL; }
5822+GLOBAL int tq_has_su_decl (TypeQual tq) { return DECL_LOCATION(tq.tq)==T_SU_DECL; }
5823+GLOBAL int tq_has_enum_decl (TypeQual tq) { return DECL_LOCATION(tq.tq)==T_ENUM_DECL; }
5824+
5825+/* These are mutually exlusive, so take care to zero out the old data before oring in the new data. */
5826+GLOBAL TypeQual tq_add_top_decl (TypeQual tq) { return (TypeQual){(tq.tq&~T_DECL_LOCATIONS)|T_TOP_DECL, tq.attributes}; }
5827+GLOBAL TypeQual tq_add_block_decl (TypeQual tq) { return (TypeQual){(tq.tq&~T_DECL_LOCATIONS)|T_BLOCK_DECL, tq.attributes}; }
5828+GLOBAL TypeQual tq_add_formal_decl (TypeQual tq) { return (TypeQual){(tq.tq&~T_DECL_LOCATIONS)|T_FORMAL_DECL, tq.attributes}; }
5829+GLOBAL TypeQual tq_add_su_decl (TypeQual tq) { return (TypeQual){(tq.tq&~T_DECL_LOCATIONS)|T_SU_DECL, tq.attributes}; }
5830+GLOBAL TypeQual tq_add_enum_decl (TypeQual tq) { return (TypeQual){(tq.tq&~T_DECL_LOCATIONS)|T_ENUM_DECL, tq.attributes}; }
5831+
5832+GLOBAL TypeQual tq_decl_location (TypeQual tq) { return TQ(DECL_LOCATION(tq.tq)); }
5833+GLOBAL TypeQual tq_set_decl_location_from (TypeQual tq, TypeQual source) { return (TypeQual){(tq.tq&~T_DECL_LOCATIONS)|DECL_LOCATION(source.tq), tq.attributes}; }
5834+
5835+GLOBAL int tq_has_redundant_external_decl (TypeQual tq) { return bit_is_set(tq,T_REDUNDANT_EXTERNAL_DECL); }
5836+GLOBAL TypeQual tq_add_redundant_external_decl(TypeQual tq) { return TQsetbit(tq,T_REDUNDANT_EXTERNAL_DECL); }
5837+GLOBAL TypeQual tq_remove_redundant_external_decl(TypeQual tq) { return TQclearbit(tq, T_REDUNDANT_EXTERNAL_DECL); }
5838+
5839+
5840+GLOBAL int tq_has_shared (TypeQual tq) { return bit_is_set(tq,T_SHARED); }
5841+GLOBAL int tq_has_private (TypeQual tq) { return bit_is_set(tq,T_PRIVATE); }
5842+GLOBAL int tq_has_nooutput (TypeQual tq) { return bit_is_set(tq,T_NOOUTPUT); }
5843+GLOBAL int tq_has_cilkonly (TypeQual tq) { return bit_is_set(tq,T_CILKONLY); }
5844+GLOBAL int tq_has_cilksafe (TypeQual tq) { return bit_is_set(tq,T_CILKSAFE); }
5845+
5846+GLOBAL TypeQual tq_add_shared (TypeQual tq) { return TQsetbit(tq,T_SHARED); }
5847+GLOBAL TypeQual tq_add_private (TypeQual tq) { return TQsetbit(tq,T_PRIVATE); }
5848+GLOBAL TypeQual tq_add_nooutput (TypeQual tq) { return TQsetbit(tq,T_NOOUTPUT); }
5849+GLOBAL TypeQual tq_add_cilkonly (TypeQual tq) { return TQsetbit(tq,T_CILKONLY); }
5850+GLOBAL TypeQual tq_add_cilksafe (TypeQual tq) { return TQsetbit(tq,T_CILKSAFE); }
5851+
5852+/* Consider decl_quals to include attributes. */
5853+GLOBAL TypeQual tq_remove_all_decl_quals (TypeQual tq) { return (TypeQual){tq.tq&~T_DECL_QUALS,0}; }
5854+
5855+GLOBAL int tq_has_fast_procedure (TypeQual tq) { return bit_is_set(tq, T_FAST_PROCEDURE); }
5856+GLOBAL int tq_has_slow_procedure (TypeQual tq) { return bit_is_set(tq, T_SLOW_PROCEDURE); }
5857+GLOBAL int tq_has_fast_inlet (TypeQual tq) { return bit_is_set(tq, T_FAST_INLET); }
5858+GLOBAL int tq_has_slow_inlet (TypeQual tq) { return bit_is_set(tq, T_SLOW_INLET); }
5859+GLOBAL int tq_has_standalone_inlet (TypeQual tq) { return bit_is_set(tq, T_STANDALONE_INLET); }
5860+GLOBAL int tq_has_c_code (TypeQual tq) { return bit_is_set(tq, T_C_CODE); }
5861+
5862+GLOBAL TypeQual tq_add_fast_procedure (TypeQual tq) { return TQsetbit(tq,T_FAST_PROCEDURE); }
5863+GLOBAL TypeQual tq_add_slow_procedure (TypeQual tq) { return TQsetbit(tq,T_SLOW_PROCEDURE); }
5864+GLOBAL TypeQual tq_add_fast_inlet (TypeQual tq) { return TQsetbit(tq,T_FAST_INLET); }
5865+GLOBAL TypeQual tq_add_slow_inlet (TypeQual tq) { return TQsetbit(tq,T_SLOW_INLET); }
5866+GLOBAL TypeQual tq_add_standalone_inlet (TypeQual tq) { return TQsetbit(tq,T_STANDALONE_INLET); }
5867+GLOBAL TypeQual tq_add_c_code (TypeQual tq) { return TQsetbit(tq,T_C_CODE); }
5868+
5869+GLOBAL int tq_has_cilk_where_am_i_decl_quals(TypeQual tq) {
5870+ return (tq.tq & T_CILK_WHERE_AM_I_DECL_QUALS )!=0;
5871+}
5872+GLOBAL TypeQual tq_remove_cilk_where_am_i_decl_quals(TypeQual tq) {
5873+ /* Remove the cilk "where-am-i" declaration qualifiers */
5874+ return TQclearbit(tq, ~T_CILK_WHERE_AM_I_DECL_QUALS );
5875+}
5876+
5877+GLOBAL TypeQual TQ_DECL_QUALS(void) {
5878+ return TQ(T_DECL_QUALS);
5879+}
5880+
5881+GLOBAL TypeQual tq_decl_quals(TypeQual tq) {
5882+ return (TypeQual){DECL_QUALS(tq.tq), tq.attributes};
5883+}
5884+
5885+GLOBAL int tq_has_restrict (TypeQual tq) { return bit_is_set(tq,T_RESTRICT); }
5886+GLOBAL int tq_has_complex (TypeQual tq) { return bit_is_set(tq,T_COMPLEX); }
5887+GLOBAL int tq_has_const (TypeQual tq) { return bit_is_set(tq,T_CONST); }
5888+GLOBAL int tq_has_volatile (TypeQual tq) { return bit_is_set(tq,T_VOLATILE); }
5889+GLOBAL int tq_has_inline(TypeQual tq) { return bit_is_set(tq,T_INLINE); }
5890+GLOBAL int tq_has_sue_elaborated (TypeQual tq) { return bit_is_set(tq,T_SUE_ELABORATED); }
5891+GLOBAL int tq_has_procedure(TypeQual tq) { return bit_is_set(tq,T_PROCEDURE); }
5892+GLOBAL int tq_has_inlet(TypeQual tq) { return bit_is_set(tq,T_INLET); }
5893+GLOBAL int tq_has_extension (TypeQual tq) { return bit_is_set(tq,T_EXTENSION); }
5894+
5895+GLOBAL TypeQual tq_add_restrict (TypeQual tq) { return TQsetbit(tq,T_RESTRICT); }
5896+GLOBAL TypeQual tq_add_complex (TypeQual tq) { return TQsetbit(tq,T_COMPLEX); }
5897+GLOBAL TypeQual tq_add_const (TypeQual tq) { return TQsetbit(tq,T_CONST); }
5898+GLOBAL TypeQual tq_add_volatile(TypeQual tq) { return TQsetbit(tq,T_VOLATILE); }
5899+GLOBAL TypeQual tq_add_inline (TypeQual tq) { return TQsetbit(tq,T_INLINE); }
5900+GLOBAL TypeQual tq_add_sue_elaborated (TypeQual tq) { return TQsetbit(tq,T_SUE_ELABORATED); }
5901+GLOBAL TypeQual tq_add_procedure (TypeQual tq) { return TQsetbit(tq,T_PROCEDURE); }
5902+GLOBAL TypeQual tq_add_inlet (TypeQual tq) { return TQsetbit(tq,T_INLET); }
5903+GLOBAL TypeQual tq_add_extension (TypeQual tq) { return TQsetbit(tq,T_EXTENSION); }
5904+
5905+GLOBAL TypeQual tq_remove_complex(TypeQual tq) { return TQclearbit(tq, T_COMPLEX); }
5906+GLOBAL TypeQual tq_remove_const (TypeQual tq) { return TQclearbit(tq, T_CONST); }
5907+GLOBAL TypeQual tq_remove_inline (TypeQual tq) { return TQclearbit(tq, T_INLINE); }
5908+GLOBAL TypeQual tq_remove_sue_elaborated (TypeQual tq) { return TQclearbit(tq, T_SUE_ELABORATED); }
5909+GLOBAL TypeQual tq_remove_procedure (TypeQual tq) { return TQclearbit(tq, T_PROCEDURE); }
5910+GLOBAL TypeQual tq_remove_inlet (TypeQual tq) { return TQclearbit(tq, T_INLET); }
5911+
5912+GLOBAL TypeQual tq_type_quals (TypeQual tq) { return TQ(TYPE_QUALS(tq.tq)); }
5913+GLOBAL TypeQual tq_remove_compatible (TypeQual tq) { return TQclearbit(tq, TQ_COMPATIBLE); }
5914+
5915+PRIVATE List* UnionLists(List *a, List *b) {
5916+ if (a==NULL) return b;
5917+ if (b==NULL) return a;
5918+ if (a==b) return a;
5919+ if (FindItem(b, FirstItem(a))) return UnionLists (Rest(a), b);
5920+ return ConsItem(FirstItem(a), UnionLists(Rest(a), b));
5921+}
5922+
5923+GLOBAL TypeQual tq_union (TypeQual a, TypeQual b) { /* Produce a type qualifier which is the union of two others. */
5924+ return (TypeQual){a.tq|b.tq, UnionLists(a.attributes, b.attributes)};
5925+}
5926+GLOBAL TypeQual tq_intersection (TypeQual a, TypeQual b) { return TQ(a.tq&b.tq); }
5927+GLOBAL TypeQual tq_subtract (TypeQual a, TypeQual b) { return (TypeQual){a.tq & ~b.tq, a.attributes}; }
5928+
5929+GLOBAL int tq_has_anything (TypeQual tq) { return tq.tq!=0; }
5930+GLOBAL TypeQual tq_remove_everything (TypeQual tq __attribute__((__unused__))) { return EMPTY_TQ; }
5931+
5932+GLOBAL int tq_equal(TypeQual a, TypeQual b) { return a.tq==b.tq; }
5933diff -Nur 5.4.2.2/cilk2c/typequal.h current.Bug188/cilk2c/typequal.h
5934--- 5.4.2.2/cilk2c/typequal.h 1970-01-01 00:00:00.000000000 +0000
5935+++ current.Bug188/cilk2c/typequal.h 2005-10-22 02:52:37.000000000 +0000
5936@@ -0,0 +1,189 @@
5937+#include <stdarg.h>
5938+/* TypeQual: storage classes, type qualifiers, and additional attributes */
5939+
5940+/* First the old definition. Using the enumeration types directly is deprecated. */
5941+
5942+typedef struct typequal {
5943+ unsigned int tq;
5944+ List *attributes;
5945+} TypeQual;
5946+#define EMPTY_TQ ((TypeQual){0,0})
5947+
5948+GLOBAL TypeQual tq_attribute (List *attrib);
5949+
5950+/* These are the new typequal operations. Use these. */
5951+
5952+GLOBAL int tq_has_auto (TypeQual);
5953+GLOBAL int tq_has_extern (TypeQual);
5954+GLOBAL int tq_has_register (TypeQual);
5955+GLOBAL int tq_has_static (TypeQual);
5956+GLOBAL int tq_has_typedef (TypeQual);
5957+GLOBAL int tq_has_some_storageclass (TypeQual);
5958+
5959+GLOBAL TypeQual tq_add_auto (TypeQual);
5960+GLOBAL TypeQual tq_add_extern (TypeQual);
5961+GLOBAL TypeQual tq_add_register (TypeQual);
5962+GLOBAL TypeQual tq_add_static (TypeQual);
5963+GLOBAL TypeQual tq_add_typedef (TypeQual);
5964+
5965+GLOBAL TypeQual tq_storage_class (TypeQual);
5966+
5967+GLOBAL TypeQual tq_remove_register (TypeQual);
5968+GLOBAL TypeQual tq_remove_all_storage_classes (TypeQual);
5969+GLOBAL TypeQual tq_set_storage_class_from (TypeQual, TypeQual);
5970+
5971+#define TQ_AUTO (tq_add_auto(EMPTY_TQ))
5972+#define TQ_EXTERN (tq_add_extern(EMPTY_TQ))
5973+#define TQ_REGISTER (tq_add_register(EMPTY_TQ))
5974+#define TQ_STATIC (tq_add_static(EMPTY_TQ))
5975+#define TQ_TYPEDEF (tq_add_typedef(EMPTY_TQ))
5976+
5977+GLOBAL int tq_has_top_decl (TypeQual);
5978+GLOBAL int tq_has_block_decl (TypeQual);
5979+GLOBAL int tq_has_formal_decl (TypeQual);
5980+GLOBAL int tq_has_su_decl (TypeQual);
5981+GLOBAL int tq_has_enum_decl (TypeQual);
5982+
5983+GLOBAL TypeQual tq_add_top_decl (TypeQual);
5984+GLOBAL TypeQual tq_add_block_decl (TypeQual);
5985+GLOBAL TypeQual tq_add_formal_decl (TypeQual);
5986+GLOBAL TypeQual tq_add_su_decl (TypeQual);
5987+GLOBAL TypeQual tq_add_enum_decl (TypeQual);
5988+
5989+#define TQ_TOP_DECL (tq_add_top_decl(EMPTY_TQ))
5990+#define TQ_BLOCK_DECL (tq_add_block_decl(EMPTY_TQ))
5991+#define TQ_FORMAL_DECL (tq_add_formal_decl(EMPTY_TQ))
5992+#define TQ_SU_DECL (tq_add_su_decl(EMPTY_TQ))
5993+#define TQ_ENUM_DECL (tq_add_enum_decl(EMPTY_TQ))
5994+
5995+GLOBAL TypeQual tq_decl_location (TypeQual);
5996+GLOBAL TypeQual tq_set_decl_location_from (TypeQual tq, TypeQual source);
5997+
5998+/* Flag for redundant external declaration, which is defined as
5999+ * an external declaration (NOT a definition, so it must have no
6000+ * initializer or function body) of a name previously declared external
6001+ * in the same scope. A trivial example:
6002+ * extern int x;
6003+ * extern int x; <-- redundant
6004+ * But:
6005+ * { extern int x; }
6006+ * { extern int x; } <-- not redundant
6007+ * because the two declarations have different scopes.
6008+ */
6009+GLOBAL int tq_has_redundant_external_decl (TypeQual);
6010+GLOBAL TypeQual tq_add_redundant_external_decl(TypeQual);
6011+GLOBAL TypeQual tq_remove_redundant_external_decl(TypeQual);
6012+#define TQ_REDUNDANT_EXTERNAL_DECL (tq_add_redundant_external_decl(EMPTY_TQ))
6013+
6014+GLOBAL int tq_has_shared (TypeQual);
6015+GLOBAL int tq_has_private (TypeQual); /* does it have a private decl? */
6016+GLOBAL int tq_has_nooutput (TypeQual);
6017+GLOBAL int tq_has_cilkonly (TypeQual);
6018+GLOBAL int tq_has_cilksafe (TypeQual);
6019+
6020+GLOBAL TypeQual tq_add_shared (TypeQual);
6021+GLOBAL TypeQual tq_add_private (TypeQual);
6022+GLOBAL TypeQual tq_add_nooutput (TypeQual);
6023+GLOBAL TypeQual tq_add_cilkonly (TypeQual);
6024+GLOBAL TypeQual tq_add_cilksafe (TypeQual);
6025+
6026+#define TQ_SHARED (tq_add_shared(EMPTY_TQ))
6027+#define TQ_PRIVATE (tq_add_private(EMPTY_TQ))
6028+#define TQ_NOOUTPUT (tq_add_nooutput(EMPTY_TQ))
6029+#define TQ_CILKONLY (tq_add_cilkonly(EMPTY_TQ))
6030+#define TQ_CILKSAFE (tq_add_cilksafe(EMPTY_TQ))
6031+
6032+/* Cilk "where-am-i" declaration specifiers. */
6033+GLOBAL int tq_has_fast_procedure (TypeQual);
6034+GLOBAL int tq_has_slow_procedure (TypeQual);
6035+GLOBAL int tq_has_fast_inlet (TypeQual);
6036+GLOBAL int tq_has_slow_inlet (TypeQual);
6037+GLOBAL int tq_has_standalone_inlet (TypeQual);
6038+GLOBAL int tq_has_c_code (TypeQual);
6039+
6040+GLOBAL TypeQual tq_add_fast_procedure (TypeQual);
6041+GLOBAL TypeQual tq_add_slow_procedure (TypeQual);
6042+GLOBAL TypeQual tq_add_fast_inlet (TypeQual);
6043+GLOBAL TypeQual tq_add_slow_inlet (TypeQual);
6044+GLOBAL TypeQual tq_add_standalone_inlet (TypeQual);
6045+GLOBAL TypeQual tq_add_c_code (TypeQual);
6046+
6047+#define TQ_FAST_PROCEDURE (tq_add_fast_procedure(EMPTY_TQ))
6048+#define TQ_SLOW_PROCEDURE (tq_add_slow_procedure(EMPTY_TQ))
6049+#define TQ_FAST_INLET (tq_add_fast_inlet(EMPTY_TQ))
6050+#define TQ_SLOW_INLET (tq_add_slow_inlet(EMPTY_TQ))
6051+#define TQ_STANDALONE_INLET (tq_add_slow_inlet(EMPTY_TQ))
6052+#define TQ_C_CODE (tq_add_c_code(EMPTY_TQ))
6053+
6054+GLOBAL int tq_has_cilk_where_am_i_decl_quals(TypeQual);
6055+GLOBAL TypeQual tq_remove_cilk_where_am_i_decl_quals(TypeQual); /* Remove the cilk "where-am-i" declaration qualifiers */
6056+
6057+GLOBAL TypeQual TQ_DECL_QUALS(void);
6058+GLOBAL TypeQual tq_decl_quals(TypeQual); /* Get out the decl qualifiers */
6059+
6060+/* Type qualifiers. */
6061+GLOBAL TypeQual tq_add_restrict (TypeQual);
6062+GLOBAL TypeQual tq_add_complex (TypeQual);
6063+
6064+#define TQ_RESTRICT (tq_add_restrict(EMPTY_TQ))
6065+#define TQ_COMPLEX (tq_add_complex(EMPTY_TQ))
6066+
6067+#define TQ_CONST (tq_add_const(EMPTY_TQ))
6068+#define TQ_VOLATILE (tq_add_volatile(EMPTY_TQ))
6069+#define TQ_INLINE (tq_add_inline(EMPTY_TQ))
6070+#define TQ_SUE_ELABORATED (tq_add_sue_elaborated(EMPTY_TQ))
6071+
6072+#define TQ_PROCEDURE (tq_add_procedure(EMPTY_TQ))
6073+#define TQ_INLET (tq_add_inlet(EMPTY_TQ))
6074+#define TQ_EXTENSION (tq_add_extension(EMPTY_TQ))
6075+
6076+GLOBAL int tq_has_restrict (TypeQual);
6077+GLOBAL int tq_has_complex (TypeQual);
6078+GLOBAL int tq_has_const (TypeQual);
6079+GLOBAL int tq_has_volatile (TypeQual);
6080+GLOBAL int tq_has_inline(TypeQual);
6081+GLOBAL int tq_has_sue_elaborated (TypeQual); /* on an Sdcl/Udcl/Edcl, did the SUE's field list appear at that point in the source? */
6082+GLOBAL int tq_has_procedure(TypeQual);
6083+GLOBAL int tq_has_inlet(TypeQual);
6084+GLOBAL int tq_has_extension (TypeQual);
6085+
6086+GLOBAL TypeQual tq_add_restrict (TypeQual);
6087+GLOBAL TypeQual tq_add_complex (TypeQual);
6088+GLOBAL TypeQual tq_add_const (TypeQual);
6089+GLOBAL TypeQual tq_add_volatile(TypeQual);
6090+GLOBAL TypeQual tq_add_inline (TypeQual);
6091+GLOBAL TypeQual tq_add_sue_elaborated (TypeQual);
6092+GLOBAL TypeQual tq_add_procedure (TypeQual);
6093+GLOBAL TypeQual tq_add_inlet (TypeQual);
6094+GLOBAL TypeQual tq_add_extension (TypeQual);
6095+
6096+GLOBAL TypeQual tq_remove_complex(TypeQual);
6097+GLOBAL TypeQual tq_remove_const (TypeQual);
6098+GLOBAL TypeQual tq_remove_inline (TypeQual);
6099+GLOBAL TypeQual tq_remove_sue_elaborated (TypeQual);
6100+GLOBAL TypeQual tq_remove_procedure (TypeQual);
6101+GLOBAL TypeQual tq_remove_inlet (TypeQual);
6102+
6103+GLOBAL TypeQual tq_type_quals (TypeQual);
6104+GLOBAL TypeQual tq_remove_compatible (TypeQual);
6105+
6106+GLOBAL TypeQual tq_remove_all_decl_quals (TypeQual);
6107+//TypeQual tq_add_decl_quals_from (TypeQual, TypeQual);
6108+
6109+GLOBAL TypeQual tq_union (TypeQual, TypeQual); /* Produce a type qualifier which is the union of two others. */
6110+GLOBAL TypeQual tq_intersection (TypeQual, TypeQual);
6111+GLOBAL TypeQual tq_subtract (TypeQual, TypeQual);
6112+
6113+GLOBAL int tq_has_anything (TypeQual);
6114+GLOBAL TypeQual tq_remove_everything (TypeQual);
6115+
6116+//GLBOAL int tq_has_cilkonly (TypeQual);
6117+
6118+//#define EMPTY_TQ ((TypeQual){0,0})
6119+
6120+GLOBAL int tq_equal(TypeQual, TypeQual);
6121+
6122+// Always print a space at the end.
6123+GLOBAL void TQtoGBUF(GBUF *gb, TypeQual tq);
6124+
6125+
6126diff -Nur 5.4.2.2/cilk2c/verify-parse.c current.Bug188/cilk2c/verify-parse.c
6127--- 5.4.2.2/cilk2c/verify-parse.c 2004-10-23 03:26:20.000000000 +0000
6128+++ current.Bug188/cilk2c/verify-parse.c 2005-10-22 02:52:37.000000000 +0000
6129@@ -31,7 +31,7 @@
6130 #include "ast.h"
6131
6132 FILE_IDENTITY(ident,
6133- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/cilk2c/verify-parse.c $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
6134+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/cilk2c/verify-parse.c $ $LastChangedBy: bradley $ $Rev: 2455 $ $Date$");
6135
6136
6137 typedef enum verifycontext {
6138@@ -298,7 +298,7 @@
6139
6140 PRIVATE inline void VerifyAdcl(UNUSED(Node *node), adclNode *u, UNUSED(Context c))
6141 {
6142- assert(u->tq == EMPTY_TQ);
6143+ assert(!tq_has_anything(u->tq));
6144 VerifyType(u->type);
6145 if (u->dimp->dim)
6146 VerifyExpr(u->dimp->dim); /* can be null */
6147@@ -307,9 +307,9 @@
6148 PRIVATE inline void VerifyFdcl(UNUSED(Node *node), fdclNode *u, UNUSED(Context c))
6149 {
6150 /* allow inlet --- commented by fengmd */
6151- assert(u->tq == EMPTY_TQ || u->tq == T_INLINE || u->tq == T_PROCEDURE ||
6152- u->tq == (T_INLINE | T_PROCEDURE) || u->tq == T_INLET ||
6153- u->tq == (T_INLINE | T_INLET));
6154+ assert(!tq_has_anything(u->tq) || tq_equal(u->tq, TQ_INLINE) || tq_equal(u->tq, TQ_PROCEDURE) ||
6155+ tq_equal(u->tq, tq_add_inline(TQ_PROCEDURE)) || tq_equal(u->tq, TQ_INLET) ||
6156+ tq_equal(u->tq, tq_add_inline(TQ_INLET)));
6157 VerifyType(u->returns);
6158 VerifyDeclList(u->args, FormalParm);
6159 }
6160@@ -321,7 +321,7 @@
6161 assert(u->type->typ == Sdcl);
6162 /* u->type->name could be NULL */
6163
6164- if (SUE_ELABORATED(u->tq)) {
6165+ if (tq_has_sue_elaborated(u->tq)) {
6166 VerifyDeclList(u->type->fields, StructField);
6167 }
6168 }
6169@@ -333,7 +333,7 @@
6170 assert(u->type->typ == Udcl);
6171 /* u->type->name could be NULL */
6172
6173- if (SUE_ELABORATED(u->tq)) {
6174+ if (tq_has_sue_elaborated(u->tq)) {
6175 VerifyDeclList(u->type->fields, StructField);
6176 }
6177 }
6178@@ -535,18 +535,16 @@
6179
6180 PRIVATE void VerifyTq(TypeQual tq)
6181 {
6182- assert(tq == TYPE_QUALS(tq));
6183+ assert(tq_equal(tq, tq_type_quals(tq)));
6184 }
6185
6186 PRIVATE void VerifyScAndDq(TypeQual tq)
6187 {
6188- int sc = STORAGE_CLASS(tq);
6189- int dl = DECL_LOCATION(tq);
6190- assert(sc == 0 || sc == T_TYPEDEF || sc == T_EXTERN
6191- || sc == T_STATIC || sc == T_AUTO || sc == T_REGISTER);
6192- assert(dl == T_TOP_DECL || dl == T_BLOCK_DECL || dl == T_FORMAL_DECL ||
6193- dl == T_SU_DECL || dl == T_ENUM_DECL);
6194- assert(TYPE_QUALS(tq) == 0);
6195+ assert(!tq_has_some_storageclass(tq) || tq_has_typedef(tq) || tq_has_extern(tq)
6196+ || tq_has_static(tq) || tq_has_auto(tq) || tq_has_register(tq));
6197+ assert(tq_has_top_decl(tq) || tq_has_block_decl(tq) || tq_has_formal_decl(tq) ||
6198+ tq_has_su_decl(tq) || tq_has_enum_decl(tq));
6199+ assert(!tq_has_anything(tq_type_quals(tq)));
6200 }
6201
6202 PRIVATE void VerifyType(Node *type)
6203diff -Nur 5.4.2.2/runtime/cilk-sysdep.h.in current.Bug188/runtime/cilk-sysdep.h.in
6204--- 5.4.2.2/runtime/cilk-sysdep.h.in 2004-10-23 03:26:12.000000000 +0000
6205+++ current.Bug188/runtime/cilk-sysdep.h.in 2005-09-27 03:58:53.000000000 +0000
6206@@ -143,7 +143,7 @@
6207 /******************************************************/
6208
6209 FILE_IDENTITY(ident_cilk_sysdep_h,
6210- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/runtime/cilk-sysdep.h.in $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
6211+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/runtime/cilk-sysdep.h.in $ $LastChangedBy: bradley $ $Rev: 2311 $ $Date$");
6212
6213 /* The C compiler to use when compiling code for pthreads */
6214 #undef CILKC_PTHREAD_CC
6215@@ -198,20 +198,28 @@
6216 POWERPC
6217 ------------------------*/
6218 #if defined(__powerpc__) || defined(__ppc__)
6219+/* This version contributed by Matteo Frigo Wed Jul 13 2005. He wrote:
6220+ * lwsync is faster than eieio and has the desired store-barrier
6221+ * behavior. The isync in the lock is necessary because the processor is
6222+ * allowed to speculate on loads following the branch, which makes the
6223+ * program without isync incorrect (in theory at least---I have never
6224+ * observed such a speculation).
6225+ */
6226 # define CILK_CACHE_LINE 64
6227 # define CILK_MB() __asm__ __volatile__ ("sync" : : : "memory")
6228 # define CILK_RMB() __asm__ __volatile__ ("sync" : : : "memory")
6229-# define CILK_WMB() __asm__ __volatile__ ("eieio" : : : "memory")
6230+# define CILK_WMB() __asm__ __volatile__ ("lwsync" : : : "memory")
6231
6232 /* atomic swap operation */
6233- static inline int Cilk_xchg(volatile int *ptr, int x)
6234+ static __inline__ int Cilk_xchg(volatile int *ptr, int x)
6235 {
6236 int result;
6237 __asm__ __volatile__ (
6238- "0: lwarx %0,0,%1\n stwcx. %2,0,%1\n bne- 0b" :
6239- "=&r"(result) :
6240- "r"(ptr), "r"(x) :
6241- "cr0");
6242+ "0: lwarx %0,0,%1\n stwcx. %2,0,%1\n bne- 0b\n isync\n" :
6243+ "=&r"(result) :
6244+ "r"(ptr), "r"(x) :
6245+ "cr0");
6246+
6247 return result;
6248 }
6249 #endif
6250diff -Nur 5.4.2.2/runtime/cilkrt0.c current.Bug188/runtime/cilkrt0.c
6251--- 5.4.2.2/runtime/cilkrt0.c 2004-10-23 03:26:12.000000000 +0000
6252+++ current.Bug188/runtime/cilkrt0.c 2005-09-27 03:58:53.000000000 +0000
6253@@ -30,10 +30,17 @@
6254 */
6255
6256 #include <cilk-sysdep.h>
6257-#include <malloc.h>
6258
6259 FILE_IDENTITY(ident,
6260- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/runtime/cilkrt0.c $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
6261+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/runtime/cilkrt0.c $ $LastChangedBy: bradley $ $Rev: 1875 $ $Date$");
6262+
6263+#if HAVE_MALLOC_H
6264+#include <malloc.h>
6265+#endif
6266+
6267+#if HAVE_STDLIB_H
6268+#include <stdlib.h>
6269+#endif
6270
6271 /* Sivan and Ofra 19 June 2003:
6272 the code in the #else block tries to generate a main that calls the user's
6273diff -Nur 5.4.2.2/support/Makefile.am current.Bug188/support/Makefile.am
6274--- 5.4.2.2/support/Makefile.am 2004-10-23 03:26:50.000000000 +0000
6275+++ current.Bug188/support/Makefile.am 2005-10-05 16:47:03.000000000 +0000
6276@@ -21,7 +21,7 @@
6277 abs_top_builddir = $(shell (cd $(top_builddir); pwd))
6278
6279 cilkclocal$(EXEEXT): cilkc.c make-temp-file.o
6280- $(CC) -DCILKHEADER_DIR=$(abs_top_builddir)/runtime -DCILK2C_DIR=$(abs_top_builddir)/cilk2c -DLIBS_DIR=$(abs_top_builddir)/runtime/.libs -DLIBS2_DIR=$(abs_top_builddir)/runtime -DHAVE_RPATH=@HAVE_RPATH@ -DHAVE_RPATHARG=@HAVE_RPATHARG@ $^ -o $@ $(AM_CFLAGS) $(CFLAGS)
6281+ $(CC) -DCILKHEADER_DIR="$(abs_top_builddir)"/runtime -DCILK2C_DIR="$(abs_top_builddir)"/cilk2c -DLIBS_DIR="$(abs_top_builddir)"/runtime/.libs -DLIBS2_DIR="$(abs_top_builddir)"/runtime -DHAVE_RPATH=@HAVE_RPATH@ -DHAVE_RPATHARG=@HAVE_RPATHARG@ $^ -o $@ $(AM_CFLAGS) $(CFLAGS)
6282 cilkc$(EXEEXT): cilkc.c make-temp-file.o
6283 $(CC) -DCILKHEADER_DIR=$(prefix)/include/cilk -DCILK2C_DIR=$(prefix)/bin -DLIBS_DIR=$(libdir) -DLIBS2_DIR=$(libdir)/cilk $^ -o $@ $(AM_CFLAGS) $(CFLAGS)
6284
6285diff -Nur 5.4.2.2/support/Makefile.in current.Bug188/support/Makefile.in
6286--- 5.4.2.2/support/Makefile.in 2004-10-23 03:26:49.000000000 +0000
6287+++ current.Bug188/support/Makefile.in 2005-10-05 16:47:47.000000000 +0000
6288@@ -404,7 +404,7 @@
6289
6290
6291 cilkclocal$(EXEEXT): cilkc.c make-temp-file.o
6292- $(CC) -DCILKHEADER_DIR=$(abs_top_builddir)/runtime -DCILK2C_DIR=$(abs_top_builddir)/cilk2c -DLIBS_DIR=$(abs_top_builddir)/runtime/.libs -DLIBS2_DIR=$(abs_top_builddir)/runtime -DHAVE_RPATH=@HAVE_RPATH@ -DHAVE_RPATHARG=@HAVE_RPATHARG@ $^ -o $@ $(AM_CFLAGS) $(CFLAGS)
6293+ $(CC) -DCILKHEADER_DIR="$(abs_top_builddir)"/runtime -DCILK2C_DIR="$(abs_top_builddir)"/cilk2c -DLIBS_DIR="$(abs_top_builddir)"/runtime/.libs -DLIBS2_DIR="$(abs_top_builddir)"/runtime -DHAVE_RPATH=@HAVE_RPATH@ -DHAVE_RPATHARG=@HAVE_RPATHARG@ $^ -o $@ $(AM_CFLAGS) $(CFLAGS)
6294 cilkc$(EXEEXT): cilkc.c make-temp-file.o
6295 $(CC) -DCILKHEADER_DIR=$(prefix)/include/cilk -DCILK2C_DIR=$(prefix)/bin -DLIBS_DIR=$(libdir) -DLIBS2_DIR=$(libdir)/cilk $^ -o $@ $(AM_CFLAGS) $(CFLAGS)
6296 # Tell versions [3.59,3.63) of GNU make to not export all variables.
6297diff -Nur 5.4.2.2/support/cilkc.c current.Bug188/support/cilkc.c
6298--- 5.4.2.2/support/cilkc.c 2004-10-23 03:26:50.000000000 +0000
6299+++ current.Bug188/support/cilkc.c 2005-09-27 03:58:58.000000000 +0000
6300@@ -14,6 +14,7 @@
6301 *
6302 * Arguments
6303 * *.cilk treat as a cilk file
6304+ * *.cilkp treat a file that simply #includes the header file and the .cilk file (don't add the header to this one.)
6305 * *.cilki treat as a cilk file that has been preprocessed
6306 * *.cilkc treat as a C file that has been produced by cilk2c
6307 * *.c *.o *.i other files treat as the C compielr would
6308@@ -37,6 +38,7 @@
6309 * -O* optimize (e.g., -O2, just like gcc)
6310 * -f* optimization arguments (gcc-specific)
6311 * -m* machine-specific options (gcc-specific)
6312+ * --param <argument> Passed to the compiler (at Matteo's suggestion: Bug 183)
6313 * -woff <argument> turn off warnings (mipspro C specific)
6314 * -Wl,* -l* -L* -static linker options (passed without modification, e.g., including the "-Wl,".)
6315 * -Wp,* preprocessor options (works for gcc and mipspro)
6316@@ -72,7 +74,7 @@
6317 #include "make-temp-file.h"
6318
6319 FILE_IDENTITY(ident,
6320- "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/support/cilkc.c $ $LastChangedBy: bradley $ $Rev: 1708 $ $Date$");
6321+ "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/support/cilkc.c $ $LastChangedBy: bradley $ $Rev: 2311 $ $Date$");
6322
6323
6324 /* This macro hacking is what is needed to get RUNTIME_DIR to be expanded and then stringified */
6325@@ -167,7 +169,7 @@
6326 assert(ma->argv[ma->argc]==0);
6327 assert(ma->argc+1<=ma->limit);
6328 if (fout) {
6329- fprintf(f, " > %s\n", fout);
6330+ fprintf(f, " > %s", fout);
6331 }
6332 fprintf(f, "\n");
6333 }
6334@@ -211,7 +213,7 @@
6335
6336
6337 enum LANG {
6338- L_none, L_cilk, L_cilki, L_cilkc, L_c, L_m, L_cpp, L_h, L_i, L_ii, L_s, L_S
6339+ L_none, L_cilk, L_cilkp, L_cilki, L_cilkc, L_c, L_m, L_cpp, L_h, L_i, L_ii, L_s, L_S
6340 };
6341
6342 enum LANG language_of_xarg (const char *xarg) {
6343@@ -234,6 +236,7 @@
6344 switch (l) {
6345 case L_none: return "none";
6346 case L_cilk: return "cilk";
6347+ case L_cilkp: return "cilkp";
6348 case L_cilki: return "cilki";
6349 case L_cilkc: return "cilkc";
6350 case L_c: return "c";
6351@@ -252,6 +255,7 @@
6352 if (latest_xarg!=L_none) return latest_xarg;
6353 else if (tailmatch(fname, ".cilk")) return L_cilk;
6354 else if (tailmatch(fname, ".cilki")) return L_cilki;
6355+ else if (tailmatch(fname, ".cilkp")) return L_cilkp;
6356 else if (tailmatch(fname, ".cilkc")) return L_cilkc;
6357 else if (tailmatch(fname, ".c")) return L_c;
6358 else if (tailmatch(fname, ".m")) return L_m;
6359@@ -296,12 +300,13 @@
6360 MY_ARGV cc_args=0; /* All the arguments that will be passed to the big final call to cc */
6361 MY_ARGV cpp1_args=0; /* All the arguments, except for the name of the .cilk input file and the name of the output file, to be passed to the first preprocessor */
6362
6363-PAIRLIST i_files=0; /* These are only the .i files produced by the cilk->cilki->cilkc->i chain
6364+PAIRLIST i_files=0; /* These are only the .i files produced by the cilk->cilkp->cilki->cilkc->i chain
6365 * And only if we are producing an output
6366 * For the i_files the first elt is the .i file and the second is output file. */
6367 PAIRLIST cilkc_files=0; /* the first elt of each pair is the .cilkc file, the second (if any) is .i file */
6368 PAIRLIST cilki_files=0; /* the first elt of the pair is the .cilki file, the second (if any) is the .cilkc file */
6369-PAIRLIST cilk_files=0; /* the first elt of the pair is the .cilk file, the second (if any) is the .cilki file */
6370+PAIRLIST cilkp_files=0; /* the first elt of the pair is the .cilkp file, the second (if any) is the .cilki file */
6371+PAIRLIST cilk_files=0; /* the first elt of the pair is the .cilk file, the second (if any) is the .cilkp file */
6372
6373 int n_gcc_files=0; /* How many files are sent to gcc. */
6374 int n_input_files_that_can_make_one_output_file=0; /* How many input files produce a unique output file */
6375@@ -475,6 +480,22 @@
6376 }
6377 }
6378
6379+void note_cilkp_file (const char *fname, const char *org_fname) {
6380+ switch (stop_at) {
6381+ case STOP_AT_M:
6382+ pushpair(&cilkp_files, fname, 0);
6383+ return;
6384+ default:
6385+ {
6386+ const char *outfname = newtempfile(".cilki", fname);
6387+ //fprintf(stderr, "%s:%d pushpair(&cilkp_files, \"%s\", \"%s\");\n", __FILE__, __LINE__, fname, outfname);
6388+ pushpair(&cilkp_files, fname, outfname);
6389+ note_cilki_file(outfname, org_fname);
6390+ return;
6391+ }
6392+ }
6393+}
6394+
6395 void note_cilk_file (const char *fname, const char *org_fname) {
6396 switch (stop_at) {
6397 case STOP_AT_M:
6398@@ -482,9 +503,10 @@
6399 return;
6400 default:
6401 {
6402- const char *outfname = newtempfile(".cilki", fname);
6403+ const char *outfname = newtempfile(".cilkp", fname);
6404+ //fprintf(stderr, "%s:%d pushpair(&cilk_files, \"%s\", \"%s\");\n", __FILE__, __LINE__, fname, outfname);
6405 pushpair(&cilk_files, fname, outfname);
6406- note_cilki_file(outfname, org_fname);
6407+ note_cilkp_file(outfname, org_fname);
6408 }
6409 return;
6410 }
6411@@ -539,6 +561,7 @@
6412 argc--; argv++;
6413 pusharg(cpp1_args, *argv);
6414 pusharg(cc_args, *argv);
6415+
6416 } else if (headmatch(*argv,"-D") ||
6417 headmatch(*argv,"-A") || /* assertions for preprocessor */
6418 headmatch(*argv,"-include") ||
6419@@ -576,6 +599,12 @@
6420 pusharg(cc_early_args, *argv);
6421 pusharg(cc_args, *argv);
6422 pusharg(cpp1_args, *argv);
6423+ } else if (match(*argv, "--param")) {
6424+ /* Pass this and the next argument to the compiler. */
6425+ if (argc==1) barf("Missing arg to %s", *argv);
6426+ pusharg(cc_args, *argv);
6427+ argc--; argv++;
6428+ pusharg(cc_args, *argv);
6429 } else if (headmatch(*argv, "-Wc,")){ /* extra arguments to pass to the C compiler (works with any compiler by stripping of the -Wc, */
6430 pusharg(cc_early_args, (*argv)+4);
6431 pusharg(cc_args, (*argv)+4);
6432@@ -624,6 +653,7 @@
6433
6434 switch (lang_of_this_arg) {
6435 case L_cilk:
6436+ case L_cilkp:
6437 case L_cilki:
6438 case L_cilkc:
6439 case L_c:
6440@@ -631,8 +661,8 @@
6441 case L_cpp:
6442 case L_S:
6443 /*
6444- * cilk, cilki, cilkc, c, m, and cc files produce a separate output unless we finish
6445- * also assembler-with-cpp produces an output unless we finish
6446+ * cilk, cilki, cilkc, c, m, and cc files produce a separate output unless we finish.
6447+ * also assembler-with-cpp produces an output unless we finish.
6448 */
6449 if (!finish_up) n_input_files_that_can_make_one_output_file++; /* cilk files produce a separate output unless we finish */
6450 break;
6451@@ -654,6 +684,7 @@
6452 /**/;
6453 switch (lang_of_this_arg) {
6454 case L_cilk: note_cilk_file(*argv, *argv); break;
6455+ case L_cilkp: note_cilkp_file(*argv, *argv); break;
6456 case L_cilki: note_cilki_file(*argv, *argv); break;
6457 case L_cilkc: note_cilkc_file(*argv, *argv); break;
6458 case L_c:
6459@@ -749,27 +780,32 @@
6460 return !(WIFEXITED(status) && WEXITSTATUS(status)==0);
6461 }
6462
6463-const char * make_including_cilkh_file (const char *fname) {
6464- const char *tmpfname = make_temp_file(".cilk");
6465- FILE *f = fopen(tmpfname, "w");
6466+void make_cilkp_file (const char *included_fname, const char *including_fname) {
6467+ FILE *f;
6468+ assert(included_fname);
6469+ assert(including_fname);
6470+ f = fopen(including_fname, "w");
6471 fprintf(f, "#include \"%s\"\n", CILK_H_LOCATION);
6472- if (fname[0]=='/') {
6473- fprintf(f, "#include \"%s\"\n", fname);
6474+ VERBOSE(1, fprintf(stderr, "(echo \\#include \"%s\";", CILK_H_LOCATION));
6475+ if (included_fname[0]=='/') {
6476+ fprintf(f, "#include \"%s\"\n", included_fname);
6477+ VERBOSE(1, fprintf(stderr, "echo \\#include \"%s\")", included_fname));
6478 } else {
6479 /* If it is a relative pathname, make it absolute. */
6480 char cwd[PATH_MAX];
6481 getcwd(cwd, PATH_MAX);
6482- fprintf(f, "#include \"%s/%s\"\n", cwd, fname);
6483+ fprintf(f, "#include \"%s/%s\"\n", cwd, included_fname);
6484+ VERBOSE(1, fprintf(stderr, "echo \\#include \"%s/%s\")", cwd, included_fname));
6485 }
6486+ VERBOSE(1, fprintf(stderr, "> %s\n", including_fname));
6487 fclose(f);
6488- pushstring(&more_tempfiles_to_delete, tmpfname);
6489 /*{
6490 char foo[1000];
6491 printf("Created %s, which contains\n", tmpfname);
6492 snprintf(foo, 999, "cat %s", tmpfname);
6493 system(foo);
6494 }*/
6495- return tmpfname;
6496+ //printf("%s:%d %s\n", __FILE__, __LINE__, tmpfname);
6497 }
6498
6499 void do_M (void) {
6500@@ -787,8 +823,7 @@
6501 {
6502 PAIRLIST cf;
6503 for (cf=cilk_files; cf; cf=cf->rest) {
6504- assert(cf->b==0);
6505- pusharg(ma, make_including_cilkh_file(cf->a));
6506+ pusharg(ma, cf->a);
6507 }
6508 }
6509 pushargs(ma, cpp1_args);
6510@@ -819,6 +854,9 @@
6511 void do_cpp1(void) {
6512 PAIRLIST cf;
6513 for (cf=cilk_files; cf; cf=cf->rest) {
6514+ make_cilkp_file(cf->a, cf->b);
6515+ }
6516+ for (cf=cilkp_files; cf; cf=cf->rest) {
6517 MY_ARGV ma = make_my_argv();
6518 pusharg(ma, get_cc());
6519 pusharg(ma, "-E");
6520@@ -828,7 +866,7 @@
6521 } else {
6522 pusharg(ma, "-ignore_suffix");
6523 }
6524- pusharg(ma, make_including_cilkh_file(cf->a));
6525+ pusharg(ma, cf->a);
6526 assert(cf->b);
6527 pushargs(ma, cpp1_args);
6528 /*
6529@@ -1032,7 +1070,7 @@
6530 " c++cpp-output .ii files (preprocessed c++ files)\n",
6531 " assembler .s files\n",
6532 " assembler-with-cpp .S files\n",
6533- "Options to contro the C compiler:\n",
6534+ "Options to control the C compiler:\n",
6535 " -Wc,* pass the * argument to the C compiler. For example when using the mipspro compiler you could do\n",
6536 " -Wc,-use_readwrite_const to put constants into readwrite memory, or\n",
6537 " -Wc,-Wa,-foo which would pass -Wa,-foo to the C compiler, which in turn would pass -foo to the assembler.\n",
6538@@ -1049,7 +1087,7 @@
6539
6540 void do_operations (void) {
6541 if (verbose>=1 || do_print_version) {
6542- fprintf(stderr, "cilkc %s\n", "$Rev: 1708 $ $Date$");
6543+ fprintf(stderr, "cilkc %s\n", "$Rev: 2311 $ $Date$");
6544 }
6545 if (do_print_help) {
6546 print_help();
6547diff -Nur 5.4.2.2/support/cilkcB.c current.Bug188/support/cilkcB.c
6548--- 5.4.2.2/support/cilkcB.c 2004-10-23 03:26:50.000000000 +0000
6549+++ current.Bug188/support/cilkcB.c 2005-09-27 03:58:58.000000000 +0000
6550@@ -36,7 +36,7 @@
6551 * other gcc-style arguments to be added later
6552 */
6553 static const char *ident __attribute__((__unused__))
6554- = "$HeadURL: https://bradley.lcs.mit.edu/svn/repos/cilk/5.4.2.2/support/cilkcB.c $ $LastChangedBy: sukhaj $ $Rev: 1708 $ $Date$";
6555+ = "$HeadURL: https://bradley.csail.mit.edu/svn/repos/cilk/current.Bug188/support/cilkcB.c $ $LastChangedBy: sukhaj $ $Rev: 773 $ $Date$";
6556
6557 #include <assert.h>
6558 #include <stdarg.h>
6559@@ -462,7 +462,7 @@
6560 }
6561
6562 int do_operations(void) {
6563- VERBOSE(1, fprintf(stderr, "cilkc $Rev: 1708 $ $Date$\n"));
6564+ VERBOSE(1, fprintf(stderr, "cilkc $Rev: 773 $ $Date$\n"));
6565 pushstring(&cpp1_args, "-I" XSTR(CILKHEADER_DIR) );
6566 pushstring(&cpp1_args, "-D__CILK__");
6567 pushstring(&cpp1_args, "-D__CILK2C__");
6568diff -Nur 5.4.2.2/support/make-temp-file.c current.Bug188/support/make-temp-file.c
6569--- 5.4.2.2/support/make-temp-file.c 2004-10-23 03:26:50.000000000 +0000
6570+++ current.Bug188/support/make-temp-file.c 2005-09-27 03:58:58.000000000 +0000
6571@@ -51,11 +51,10 @@
6572 #endif
6573
6574 #include "make-temp-file.h"
6575-#define PARAMS(x) x
6576
6577 /* Call it mkstemps_local instead of mkstemps so that I don't get a conflict against the bsd mkstemps() (defined on some systems such as macos X)
6578 * The bsd mkstemps probably does the right thing, but I don't want to test it, so I'll just name rename this one. */
6579-static int mkstemps_local PARAMS ((char *, int));
6580+static int mkstemps_local (char *, int);
6581
6582 /* '/' works just fine on MS-DOS based systems. */
6583 #ifndef DIR_SEPARATOR
6584@@ -73,19 +72,20 @@
6585 If success, DIR is returned.
6586 Otherwise NULL is returned. */
6587
6588-static inline const char *try PARAMS ((const char *, const char *));
6589-
6590-static inline const char *
6591-try (dir, base)
6592- const char *dir, *base;
6593+static inline const char *TRY (const char *dir, const char *base, int line)
6594 {
6595- if (base != 0)
6596- return base;
6597- if (dir != 0
6598- && access (dir, R_OK | W_OK | X_OK) == 0)
6599- return dir;
6600- return 0;
6601+ line=line; /* get rid of unused variable warning) */
6602+ if (base != 0) {
6603+ return base;
6604+ }
6605+ if (dir != 0
6606+ && access (dir, R_OK | W_OK | X_OK) == 0) {
6607+ //printf("%s:%d in line %d: found %s\n", __FILE__, __LINE__, line, dir);
6608+ return dir;
6609+ }
6610+ return 0;
6611 }
6612+#define try(x,y) TRY(x,y,__LINE__)
6613
6614 static const char tmp[] = { DIR_SEPARATOR, 't', 'm', 'p', 0 };
6615 static const char usrtmp[] =
6616@@ -136,11 +136,16 @@
6617 /* Append DIR_SEPARATOR to the directory we've chosen
6618 and return it. */
6619 len = strlen (base);
6620- tmpdir = malloc (len + 2);
6621- assert(tmpdir);
6622- strcpy (tmpdir, base);
6623- tmpdir[len] = DIR_SEPARATOR;
6624- tmpdir[len+1] = '\0';
6625+ assert(len>0);
6626+ if (base[len-1]==DIR_SEPARATOR) {
6627+ tmpdir = strdup(base);
6628+ } else {
6629+ tmpdir = malloc (len + 2);
6630+ assert(tmpdir);
6631+ strcpy (tmpdir, base);
6632+ tmpdir[len] = DIR_SEPARATOR;
6633+ tmpdir[len+1] = '\0';
6634+ }
6635
6636 memoized_tmpdir = tmpdir;
6637 return tmpdir;
This page took 1.134103 seconds and 4 git commands to generate.