Squashed 'dmd2/' changes from fc63fd3..82e6a91

82e6a91 Resolve rvalue reference on template function arguments
3708457 Implement rvalue reference for struct literal & construction
530a59f Revert "struct literals are lvalues again"
f199933 struct literals are lvalues again
5f181da better error message for Issue 7815 - Mixin template forward reference (?) regression
e5452d5 fix Issue 7888 - derivedMembers forward reference error with nested imports
b77ae4f merge with D1
5fed58d fix Issue 7886 - derivedMembers infinite recursion
0cf5ecd Merge pull request #872 from 9rnsr/fix7873
744f102 fix Issue 7695 - Regression(2.058): ICE(mtype.c) on associative array with keys of struct type with const members
80fc228 fix Issue 7873 - IFTI with inout does not properly match template parameter if called from inout function for pointers
4a5d365 fix CTFE bugs reported in beta
df22942 add kind()
d36a3b4 Merge pull request #871 from 9rnsr/fix7871
66d1302 fix Issue 7871 - RangeViolation with findSplitBefore
020ab91 fix Issue 7811 - "not a property" error instead of real error on UFCS array template property
c349458 fix Issue 7862 - Accepts-invalid template forward reference bug related to derivedMembers
00d8ec8 fix Issue 7861 - Segfault during __error propagation with self-referencing module
4c9652d fix fwd ref bug
477c357 fix Issue 7859 - Crash on invalid alias template parameter type
c35f67a fix Issue 7858 - __traits(getOverloads) returns incorrect symbol
bc840e8 fix Issue 7815 - Mixin template forward reference (?) regression
18a1485 fix auto test break
ceef368 fix Issue 7826 - [D2 Beta] Cannot use getHash in toHash without a warning
d747fd6 fix Issue 7820 - regression(DMD 2.059head) Wrong error on forward reference to 'front' with -property switch
1094601 fix Issue 7823 - Can't use a struct initializer to initialize a nested enum used as a default function argument initializer

git-subtree-dir: dmd2
git-subtree-split: 82e6a91f234843be7f660b242f8b8819c1eae20c
This commit is contained in:
Alexey Prokhin
2012-04-22 09:41:54 +04:00
parent bfad290036
commit eadd5fb645
16 changed files with 297 additions and 56 deletions

29
cond.c
View File

@@ -1,6 +1,6 @@
// Compiler implementation of the D programming language
// Copyright (c) 1999-2011 by Digital Mars
// Copyright (c) 1999-2012 by Digital Mars
// All Rights Reserved
// written by Walter Bright
// http://www.digitalmars.com
@@ -22,6 +22,7 @@
#include "lexer.h"
#include "mtype.h"
#include "scope.h"
#include "arraytypes.h"
int findCondition(Strings *ids, Identifier *ident)
{
@@ -29,7 +30,7 @@ int findCondition(Strings *ids, Identifier *ident)
{
for (size_t i = 0; i < ids->dim; i++)
{
const char *id = ids->tdata()[i];
const char *id = (*ids)[i];
if (strcmp(id, ident->toChars()) == 0)
return TRUE;
@@ -218,6 +219,7 @@ StaticIfCondition::StaticIfCondition(Loc loc, Expression *exp)
: Condition(loc)
{
this->exp = exp;
this->nest = 0;
}
Condition *StaticIfCondition::syntaxCopy()
@@ -228,7 +230,7 @@ Condition *StaticIfCondition::syntaxCopy()
int StaticIfCondition::include(Scope *sc, ScopeDsymbol *s)
{
#if 0
printf("StaticIfCondition::include(sc = %p, s = %p)\n", sc, s);
printf("StaticIfCondition::include(sc = %p, s = %p) this=%p inc = %d\n", sc, s, this, inc);
if (s)
{
printf("\ts = '%s', kind = %s\n", s->toChars(), s->kind());
@@ -236,6 +238,15 @@ int StaticIfCondition::include(Scope *sc, ScopeDsymbol *s)
#endif
if (inc == 0)
{
if (exp->op == TOKerror || nest > 100)
{
error(loc, (nest > 1000) ? "unresolvable circular static if expression"
: "error evaluating static if expression");
if (!global.gag)
inc = 2; // so we don't see the error message again
return 0;
}
if (!sc)
{
error(loc, "static if conditional cannot be at global scope");
@@ -243,13 +254,19 @@ int StaticIfCondition::include(Scope *sc, ScopeDsymbol *s)
return 0;
}
++nest;
sc = sc->push(sc->scopesym);
sc->sd = s; // s gets any addMember()
sc->flags |= SCOPEstaticif;
Expression *e = exp->semantic(sc);
sc->pop();
e = e->optimize(WANTvalue | WANTinterpret);
if (e->isBool(TRUE))
--nest;
if (e->op == TOKerror)
{ exp = e;
inc = 0;
}
else if (e->isBool(TRUE))
inc = 1;
else if (e->isBool(FALSE))
inc = 2;
@@ -321,7 +338,7 @@ int IftypeCondition::include(Scope *sc, ScopeDsymbol *sd)
TemplateParameters parameters;
parameters.setDim(1);
parameters.tdata()[0] = &tp;
parameters[0] = &tp;
Objects dedtypes;
dedtypes.setDim(1);
@@ -333,7 +350,7 @@ int IftypeCondition::include(Scope *sc, ScopeDsymbol *sd)
else
{
inc = 1;
Type *tded = (Type *)dedtypes.tdata()[0];
Type *tded = (Type *)dedtypes[0];
if (!tded)
tded = targ;
Dsymbol *s = new AliasDeclaration(loc, id, tded);