mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-02-20 05:33:13 +01:00
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:
28
init.c
28
init.c
@@ -21,6 +21,7 @@
|
||||
#include "scope.h"
|
||||
#include "mtype.h"
|
||||
#include "hdrgen.h"
|
||||
#include "template.h"
|
||||
|
||||
/********************************** Initializer *******************************/
|
||||
|
||||
@@ -157,8 +158,18 @@ Initializer *StructInitializer::semantic(Scope *sc, Type *t, int needInterpret)
|
||||
if (ad->ctor)
|
||||
error(loc, "%s %s has constructors, cannot use { initializers }, use %s( initializers ) instead",
|
||||
ad->kind(), ad->toChars(), ad->toChars());
|
||||
size_t nfields = ad->fields.dim;
|
||||
if (((StructDeclaration *)ad)->isnested) nfields--;
|
||||
StructDeclaration *sd = ad->isStructDeclaration();
|
||||
assert(sd);
|
||||
sd->size(loc);
|
||||
if (sd->sizeok != SIZEOKdone)
|
||||
{
|
||||
error(loc, "struct %s is forward referenced", sd->toChars());
|
||||
errors = 1;
|
||||
goto Lerror;
|
||||
}
|
||||
size_t nfields = sd->fields.dim;
|
||||
if (sd->isnested)
|
||||
nfields--;
|
||||
for (size_t i = 0; i < field.dim; i++)
|
||||
{
|
||||
Identifier *id = field[i];
|
||||
@@ -241,6 +252,7 @@ Initializer *StructInitializer::semantic(Scope *sc, Type *t, int needInterpret)
|
||||
error(loc, "a struct is not a valid initializer for a %s", t->toChars());
|
||||
errors = 1;
|
||||
}
|
||||
Lerror:
|
||||
if (errors)
|
||||
{
|
||||
field.setDim(0);
|
||||
@@ -261,12 +273,11 @@ Expression *StructInitializer::toExpression()
|
||||
|
||||
//printf("StructInitializer::toExpression() %s\n", toChars());
|
||||
if (!ad) // if fwd referenced
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
StructDeclaration *sd = ad->isStructDeclaration();
|
||||
if (!sd)
|
||||
return NULL;
|
||||
|
||||
Expressions *elements = new Expressions();
|
||||
size_t nfields = ad->fields.dim;
|
||||
#if DMDV2
|
||||
@@ -856,6 +867,15 @@ Type *ExpInitializer::inferType(Scope *sc)
|
||||
//printf("ExpInitializer::inferType() %s\n", toChars());
|
||||
exp = exp->semantic(sc);
|
||||
exp = resolveProperties(sc, exp);
|
||||
if (exp->op == TOKimport)
|
||||
{ ScopeExp *se = (ScopeExp *)exp;
|
||||
TemplateInstance *ti = se->sds->isTemplateInstance();
|
||||
if (ti && ti->semanticRun == PASSsemantic && !ti->aliasdecl)
|
||||
se->error("cannot infer type from %s %s, possible circular dependency", se->sds->kind(), se->toChars());
|
||||
else
|
||||
se->error("cannot infer type from %s %s", se->sds->kind(), se->toChars());
|
||||
return Type::terror;
|
||||
}
|
||||
|
||||
// Give error for overloaded function addresses
|
||||
if (exp->op == TOKsymoff)
|
||||
|
||||
Reference in New Issue
Block a user