/usr/src/gcc-4.4/debian/patches/gdc-hg-updates.diff is in gcc-4.4-source 4.4.7-8ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 | # DP: HG updates from the gdc branch up to 20100912.
--- a/src/gcc/d/d-codegen.cc
+++ b/src/gcc/d/d-codegen.cc
@@ -696,7 +696,10 @@
build2/*_binary_op*/ (MULT_EXPR, TREE_TYPE(size_exp), intop, // the type here may be wrong %%
convert (TREE_TYPE (intop), size_exp)));
intop = fold(intop);
- }
+ }
+
+ if (result_type_node == error_mark_node)
+ return result_type_node; // else we'll ICE.
if ( integer_zerop(intop) )
return ptr_node;
@@ -1673,6 +1676,9 @@
tree
IRState::darrayPtrRef(tree exp)
{
+ if (exp == error_mark_node)
+ return exp; // else we'll ICE.
+
// Get the backend type for the array and pick out the array data
// pointer field (assumed to be the second field.)
tree ptr_field = TREE_CHAIN( TYPE_FIELDS( TREE_TYPE( exp )));
@@ -1683,6 +1689,9 @@
tree
IRState::darrayLenRef(tree exp)
{
+ if (exp == error_mark_node)
+ return exp; // else we'll ICE.
+
// Get the backend type for the array and pick out the array length
// field (assumed to be the first field.)
tree len_field = TYPE_FIELDS( TREE_TYPE( exp ));
@@ -2462,7 +2471,8 @@
}
#else
# if HOST_BITS_PER_WIDE_INT == 32
- tree tree_value = build_int_cst_type(type, value & 0xffffffff);
+ tree tree_value = build_int_cst_wide_type(type, value & 0xffffffff,
+ (value >> 32) & 0xffffffff);
# elif HOST_BITS_PER_WIDE_INT == 64
tree tree_value = build_int_cst_type(type, value);
# else
@@ -2541,11 +2551,32 @@
if (func != outer_func)
{
+ Dsymbol * this_func = func;
+ Dsymbol * parent_sym = nested_sym->toParent2();
if (!func->vthis) // if no frame pointer for this function
{
nested_func->error("is a nested function and cannot be accessed from %s", func->toChars());
return d_null_pointer;
}
+ /* Search for frame pointer, make sure we can reach it,
+ else we'll ICE later in tree-ssa. */
+ while (nested_func != this_func)
+ {
+ FuncDeclaration * fndecl;
+ if ( (fndecl = this_func->isFuncDeclaration()) )
+ {
+ if (parent_sym == fndecl->toParent2())
+ break;
+ assert(fndecl->isNested() || fndecl->vthis);
+ }
+ else
+ {
+ func->error("cannot get frame pointer to %s", nested_sym->toChars());
+ return d_null_pointer;
+ }
+ this_func = this_func->toParent2();
+ assert(this_func);
+ }
}
}
else
@@ -3140,6 +3171,7 @@
{
Flow * f = beginFlow(stmt);
f->condition = t_cond;
+ f->kind = level_switch;
}
void
@@ -3188,12 +3220,14 @@
IRState::startTry(Statement * stmt)
{
beginFlow(stmt);
+ currentFlow()->kind = level_try;
}
void
IRState::startCatches()
{
currentFlow()->tryBody = popStatementList();
+ currentFlow()->kind = level_catch;
pushStatementList();
}
@@ -3229,6 +3263,7 @@
IRState::startFinally()
{
currentFlow()->tryBody = popStatementList();
+ currentFlow()->kind = level_finally;
pushStatementList();
}
@@ -3252,9 +3287,9 @@
IRState::doJump(Statement * stmt, tree t_label)
{
if (stmt)
- g.ofile->doLineNote( stmt->loc );
+ g.ofile->doLineNote(stmt->loc);
addExp(build1(GOTO_EXPR, void_type_node, t_label));
- TREE_USED(t_label) = 1;
+ D_LABEL_IS_USED(t_label) = 1;
}
tree
@@ -3285,6 +3320,104 @@
#endif
}
+
+void
+IRState::checkSwitchCase(Statement * stmt, int default_flag)
+{
+ Flow * flow = currentFlow();
+
+ assert(flow);
+ if (flow->kind != level_switch && flow->kind != level_block)
+ {
+ stmt->error("%s cannot be in different try block level from switch",
+ default_flag ? "default" : "case");
+ }
+}
+
+void
+IRState::checkGoto(Statement * stmt, LabelDsymbol * label)
+{
+ Statement * curBlock = NULL;
+ unsigned curLevel = loops.dim;
+ int found = 0;
+
+ if (curLevel)
+ curBlock = currentFlow()->statement;
+
+ for (unsigned i = 0; i < Labels.dim; i++)
+ {
+ Label * linfo = (Label *)Labels.data[i];
+ assert(linfo);
+
+ if (label == linfo->label)
+ {
+ // No need checking for finally, should have already been handled.
+ if (linfo->kind == level_try &&
+ curLevel <= linfo->level && curBlock != linfo->block)
+ {
+ stmt->error("cannot goto into try block");
+ }
+ // %% doc: It is illegal for goto to be used to skip initializations,
+ // %% so this should include all gotos into catches...
+ if (linfo->kind == level_catch && curBlock != linfo->block)
+ stmt->error("cannot goto into catch block");
+
+ found = 1;
+ break;
+ }
+ }
+#if V1
+ // Push forward referenced gotos.
+ if (! found)
+ {
+ if (! label->statement->fwdrefs)
+ label->statement->fwdrefs = new Array();
+ label->statement->fwdrefs->push(getLabelBlock(label, stmt));
+ }
+#endif
+}
+
+void
+IRState::checkPreviousGoto(Array * refs)
+{
+ Statement * stmt;
+
+ for (unsigned i = 0; i < refs->dim; i++)
+ {
+ Label * ref = (Label *)refs->data[i];
+ int found = 0;
+
+ assert(ref && ref->from);
+ stmt = ref->from;
+
+ for (unsigned i = 0; i < Labels.dim; i++)
+ {
+ Label * linfo = (Label *)Labels.data[i];
+ assert(linfo);
+
+ if (ref->label == linfo->label)
+ {
+ // No need checking for finally, should have already been handled.
+ if (linfo->kind == level_try &&
+ ref->level <= linfo->level && ref->block != linfo->block)
+ {
+ stmt->error("cannot goto into try block");
+ }
+ // %% doc: It is illegal for goto to be used to skip initializations,
+ // %% so this should include all gotos into catches...
+ if (linfo->kind == level_catch &&
+ (ref->block != linfo->block || ref->kind != linfo->kind))
+ stmt->error("cannot goto into catch block");
+
+ found = 1;
+ break;
+ }
+ }
+ assert(found);
+ }
+}
+
+
WrappedExp::WrappedExp(Loc loc, enum TOK op, tree exp_node, Type * type)
: Expression(loc, op, sizeof(WrappedExp))
{
--- a/src/gcc/d/d-codegen.h
+++ b/src/gcc/d/d-codegen.h
@@ -527,6 +527,13 @@
void doExp(Expression * e) { doExp(e->toElem(this)); } // %% should handle volatile...?
void doAsm(tree insn_tmpl, tree outputs, tree inputs, tree clobbers);
+ // ** Goto/Label statement evaluation
+
+ void pushLabel(LabelDsymbol * l) { Labels.push(getLabelBlock(l)); }
+ void checkSwitchCase(Statement * stmt, int default_flag = 0);
+ void checkGoto(Statement * stmt, LabelDsymbol * label);
+ void checkPreviousGoto(Array * refs);
+
// ** Callback statement evalutation
static Array stmtExprList;
--- a/src/gcc/d/d-glue.cc
+++ b/src/gcc/d/d-glue.cc
@@ -1557,7 +1557,7 @@
return irs->var(var_decl);
}
} else {
- // error below
+ error("%s is not a field, but a %s", var->toChars(), var->kind());
}
break;
default:
@@ -1960,17 +1960,20 @@
STATIC_CHAIN_EXPR created here will never be
translated. Use a null pointer for the link in
this case. */
- if (
+ if (fd_outer->vthis) {
#if V2
- fd_outer->closureVars.dim ||
- irs->getFrameInfo(fd_outer)->creates_closure
+ if (fd_outer->closureVars.dim ||
+ irs->getFrameInfo(fd_outer)->creates_closure)
#else
- fd_outer->nestedFrameRef
+ if(fd_outer->nestedFrameRef)
#endif
- )
- vthis_value = irs->getFrameForNestedClass(class_decl); // %% V2: rec_type->class_type
- else
+ vthis_value = irs->getFrameForNestedClass(class_decl); // %% V2: rec_type->class_type
+ else
+ vthis_value = irs->var(fd_outer->vthis);
+ }
+ else {
vthis_value = d_null_pointer;
+ }
} else {
assert(0);
}
@@ -3681,27 +3684,28 @@
LabelStatement::toIR(IRState* irs)
{
FuncDeclaration * func = irs->func;
-#if 0
- LabelDsymbol * label = fwdrefs ? func->returnLabel : func->searchLabel(ident);
-#else
- LabelDsymbol * label = isReturnLabel ? func->returnLabel : func->searchLabel(ident);
-#endif
- tree t = irs->getLabelTree( label );
+ LabelDsymbol * label = irs->isReturnLabel(ident) ? func->returnLabel : func->searchLabel(ident);
+ tree t_label;
- if (t) {
- TREE_USED(t) = 1;
- irs->doLabel(t);
+ if ( (t_label = irs->getLabelTree(label)) )
+ {
+ irs->pushLabel(label);
+ irs->doLabel(t_label);
if (label->asmLabelNum)
d_expand_priv_asm_label(irs, label->asmLabelNum);
-#if 0
- if (fwdrefs && func->fensure)
-#else
- if (isReturnLabel && func->fensure)
-#endif
+ if (irs->isReturnLabel(ident) && func->fensure)
func->fensure->toIR(irs);
else if (statement)
statement->toIR(irs);
+#if V1
+ if (fwdrefs)
+ {
+ irs->checkPreviousGoto(fwdrefs);
+ delete fwdrefs;
+ fwdrefs = NULL;
+ }
+#endif
}
// else, there was an error
}
@@ -3709,15 +3713,19 @@
void
GotoStatement::toIR(IRState* irs)
{
+ tree t_label;
+
g.ofile->setLoc(loc); /* This makes the 'undefined label' error show up on the correct line...
The extra doLineNote in doJump shouldn't cause a problem. */
-
- if (tf != label->statement->tf)
+ if (!label->statement)
+ error("label %s is undefined", label->toChars());
+ else if (tf != label->statement->tf)
error("cannot goto forward out of or into finally block");
+ else
+ irs->checkGoto(this, label);
- tree t = irs->getLabelTree( label );
- if (t)
- irs->doJump(this, t);
+ if ( (t_label = irs->getLabelTree(label)) )
+ irs->doJump(this, t_label);
// else, there was an error
}
@@ -3989,9 +3997,7 @@
void
DefaultStatement::toIR(IRState * irs)
{
- if(! irs->currentFlow()->condition )
- error("default cannot be in different try block level from switch");
-
+ irs->checkSwitchCase(this, 1);
irs->doCase(NULL_TREE, cblock);
if (statement)
statement->toIR( irs );
@@ -4001,13 +4007,13 @@
CaseStatement::toIR(IRState * irs)
{
tree case_value;
- if(! irs->currentFlow()->condition )
- error("case cannot be in different try block level from switch");
if ( exp->type->isscalar() )
case_value = exp->toElem(irs);
else
case_value = irs->integerConstant(index, Type::tint32);
+
+ irs->checkSwitchCase(this);
irs->doCase(case_value, cblock);
if (statement)
statement->toIR( irs );
--- a/src/gcc/d/d-irstate.cc
+++ b/src/gcc/d/d-irstate.cc
@@ -204,17 +204,17 @@
tree
IRBase::getLabelTree(LabelDsymbol * label)
{
- if (! label->statement) {
- error("undefined label %s", label->ident->string); // %% ident okay?
+ if (! label->statement)
return NULL_TREE;
- }
-
- if (! label->statement->lblock) {
+
+ if (! label->statement->lblock)
+ {
tree label_decl = build_decl (LABEL_DECL, get_identifier(label->ident->string), void_type_node);
- assert(func != 0);
+ assert(func != 0);
DECL_CONTEXT( label_decl ) = getLocalContext();
DECL_MODE( label_decl ) = VOIDmode; // Not sure why or if this is needed
+ D_LABEL_IS_USED( label_decl ) = 1;
// Not setting this doesn't seem to cause problems (unlike VAR_DECLs)
if (label->statement->loc.filename)
g.ofile->setDeclLoc( label_decl, label->statement->loc ); // %% label->loc okay?
@@ -223,6 +223,36 @@
return label->statement->lblock;
}
+IRBase::Label *
+IRBase::getLabelBlock(LabelDsymbol * label, Statement * from)
+{
+ Label * l = new Label;
+ l->block = NULL;
+ l->from = NULL;
+ l->kind = level_block;
+ l->level = 0;
+
+ for (int i = loops.dim - 1; i >= 0; i--)
+ {
+ Flow * flow = (Flow *)loops.data[i];
+
+ if (flow->kind != level_block &&
+ flow->kind != level_switch)
+ {
+ l->block = flow->statement;
+ l->kind = flow->kind;
+ l->level = i + 1;
+ break;
+ }
+ }
+ if (from)
+ l->from = from;
+
+ l->label = label;
+ return l;
+}
+
+
IRBase::Flow *
IRBase::getLoopForLabel(Identifier * ident, bool want_continue)
{
@@ -266,6 +296,7 @@
flow->statement = stmt;
flow->loop = loop;
+ flow->kind = level_block;
flow->exitLabel = NULL;
flow->overrideContinueLabel = NULL;
@@ -301,6 +332,7 @@
Flow * flow = new Flow;
flow->statement = stmt;
+ flow->kind = level_block;
flow->exitLabel = NULL_TREE;
flow->condition = NULL_TREE;
flow->trueBranch = NULL_TREE;
@@ -332,9 +364,8 @@
This makes auto-vectorization possible in conditional loops.
The only excemption to this is in LabelStatement::toIR, in which
all computed labels are marked regardless. */
- if(TREE_USED(t_label)) {
+ if(D_LABEL_IS_USED(t_label))
addExp(build1(LABEL_EXPR, void_type_node, t_label));
- }
}
#endif
--- a/src/gcc/d/d-irstate.h
+++ b/src/gcc/d/d-irstate.h
@@ -71,37 +71,55 @@
tree popStatementList();
#endif
+ // ** Scope kinds.
+
+ /* The kinds of levels we recognize. */
+ typedef enum LevelKind {
+ level_block = 0, /* An ordinary block scope. */
+ level_switch, /* A switch-block */
+ level_try, /* A try-block. */
+ level_catch, /* A catch-block. */
+ level_finally, /* A finally-block. */
+ } LevelKind;
+
// ** Labels
+ typedef struct
+ {
+ LabelDsymbol * label;
+ Statement * block;
+ Statement * from;
+ LevelKind kind;
+ unsigned level;
+ } Label;
+
+ Array Labels; // of Label.
+
// It is only valid to call this while the function in which the label is defined
// is being compiled.
- tree getLabelTree(LabelDsymbol * label);
-
+ tree getLabelTree(LabelDsymbol * label);
+ Label * getLabelBlock(LabelDsymbol * label, Statement * from = NULL);
+ bool isReturnLabel(Identifier * ident) {
+ return func->returnLabel ? ident == func->returnLabel->ident : 0;
+ }
// ** Loops (and case statements)
#if D_GCC_VER < 40
typedef struct
{
Statement * statement;
+ LevelKind kind;
// expand_start_case doesn't return a nesting structure, so
// we have to generate our own label for 'break'
nesting * loop;
tree exitLabel;
tree overrideContinueLabel;
- // Copied for information purposes. Not actually used.
- union {
- struct {
- tree continueLabel;
- };
- struct {
- tree condition;
- };
- };
} Flow;
#else
typedef struct
{
Statement * statement;
+ LevelKind kind;
tree exitLabel;
union {
struct {
--- a/src/gcc/d/d-lang.h
+++ b/src/gcc/d/d-lang.h
@@ -91,6 +91,9 @@
/* True if the function has been marked "naked". */
#define D_DECL_NO_FRAME_POINTER(NODE) (DECL_LANG_FLAG_2(NODE))
+/* True if the label has been computed, or used by the frontend. */
+#define D_LABEL_IS_USED(NODE) (DECL_LANG_FLAG_3(NODE))
+
/* The D front-end does not use the 'binding level' system for a symbol table,
It is only needed to get debugging information for local variables and
otherwise support the backend. */
--- a/src/gcc/d/dmd/func.c
+++ b/src/gcc/d/dmd/func.c
@@ -1047,7 +1047,6 @@
if (fensure)
{ returnLabel = new LabelDsymbol(Id::returnLabel);
LabelStatement *ls = new LabelStatement(0, Id::returnLabel, fensure);
- ls->isReturnLabel = 1; //Temporary, see Issue #54
returnLabel->statement = ls;
}
sc2 = sc2->pop();
--- a/src/gcc/d/dmd/impcnvgen.c
+++ b/src/gcc/d/dmd/impcnvgen.c
@@ -388,8 +388,8 @@
Y(Tint64, Tdchar)
Y(Tuns64, Tdchar)
- Y(Tint64, Tuns64)
- Y(Tuns64, Tint64)
+// Y(Tint64, Tuns64)
+// Y(Tuns64, Tint64)
for (i = 0; i < TMAX; i++)
for (j = 0; j < TMAX; j++)
--- a/src/gcc/d/dmd/statement.c
+++ b/src/gcc/d/dmd/statement.c
@@ -3912,11 +3912,12 @@
error("catch at %s hides catch at %s", sj, si);
}
}
-
+#ifndef IN_GCC
if (!body || body->isEmpty())
{
return NULL;
}
+#endif
return this;
}
@@ -4352,8 +4353,7 @@
this->statement = statement;
this->tf = NULL;
this->lblock = NULL;
- //this->fwdrefs = NULL; //See Issue #54
- this->isReturnLabel = 0;
+ this->fwdrefs = NULL;
}
Statement *LabelStatement::syntaxCopy()
--- a/src/gcc/d/dmd/statement.h
+++ b/src/gcc/d/dmd/statement.h
@@ -792,8 +792,7 @@
TryFinallyStatement *tf;
block *lblock; // back end
- //Array *fwdrefs; // forward references to this LabelStatement //See Issue #54
- int isReturnLabel;
+ Array *fwdrefs; // forward references to this LabelStatement
LabelStatement(Loc loc, Identifier *ident, Statement *statement);
Statement *syntaxCopy();
|