Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge remote-tracking branch 'upstream/master'
  • Loading branch information
Adam Wilson committed Feb 21, 2012
2 parents eacaf5f + 2cb061a commit d97b4ce
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 12 deletions.
9 changes: 7 additions & 2 deletions src/func.c
Expand Up @@ -609,9 +609,14 @@ void FuncDeclaration::semantic(Scope *sc)
}
if (ti)
{
if (tintro && !tintro->equals(ti))
if (tintro)
{
error("incompatible covariant types %s and %s", tintro->toChars(), ti->toChars());
if (!tintro->nextOf()->equals(ti->nextOf()) &&
!tintro->nextOf()->isBaseOf(ti->nextOf(), NULL) &&
!ti->nextOf()->isBaseOf(tintro->nextOf(), NULL))
{
error("incompatible covariant types %s and %s", tintro->toChars(), ti->toChars());
}
}
tintro = ti;
}
Expand Down
26 changes: 17 additions & 9 deletions src/lexer.c
Expand Up @@ -1224,9 +1224,21 @@ void Lexer::scan(Token *t)
#undef DOUBLE

case '#':
{
p++;
pragma();
continue;
Token *n = peek(&token);
if (n->value == TOKidentifier && n->ident == Id::line)
{
nextToken();
poundLine();
continue;
}
else
{
t->value = TOKpound;
return;
}
}

default:
{ unsigned c = *p;
Expand Down Expand Up @@ -2562,22 +2574,17 @@ __body
}

/*********************************************
* Do pragma.
* Currently, the only pragma supported is:
* parse:
* #line linnum [filespec]
*/

void Lexer::pragma()
void Lexer::poundLine()
{
Token tok;
int linnum;
char *filespec = NULL;
Loc loc = this->loc;

scan(&tok);
if (tok.value != TOKidentifier || tok.ident != Id::line)
goto Lerr;

scan(&tok);
if (tok.value == TOKint32v || tok.value == TOKint64v)
{ linnum = tok.uns64value - 1;
Expand Down Expand Up @@ -3160,6 +3167,7 @@ void Lexer::initKeywords()
Token::tochars[TOKpow] = "^^";
Token::tochars[TOKpowass] = "^^=";
Token::tochars[TOKgoesto] = "=>";
Token::tochars[TOKpound] = "#";
#endif

// For debugging
Expand Down
3 changes: 2 additions & 1 deletion src/lexer.h
Expand Up @@ -170,6 +170,7 @@ enum TOK
TOKpowass,
TOKgoesto,
TOKvector,
TOKpound,
#endif

TOKMAX
Expand Down Expand Up @@ -305,7 +306,7 @@ struct Lexer
void error(const char *format, ...);
void error(Loc loc, const char *format, ...);
void verror(Loc loc, const char *format, va_list ap);
void pragma();
void poundLine();
unsigned decodeUTF();
void getDocComment(Token *t, unsigned lineComment);

Expand Down
21 changes: 21 additions & 0 deletions test/compilable/line.d
@@ -0,0 +1,21 @@
module line;

static assert(__LINE__ == 3);

int #line 10
x;

static assert(__LINE__ == 12);
static assert(__FILE__ == "compilable/line.d");

#line 100 "newfile.d"

static assert(__LINE__ == 101);
static assert(__FILE__ == "newfile.d");

# line 200

static assert(__LINE__ == 201);
static assert(__FILE__ == "newfile.d");


21 changes: 21 additions & 0 deletions test/runnable/xtest46.d
Expand Up @@ -3383,6 +3383,26 @@ ref func2521_7() {
return val;
}

/***************************************************/

void test5554()
{
class MA { }
class MB : MA { }
class MC : MB { }

class A { abstract MA foo(); }
interface I { MB foo(); }
class B : A
{
MC foo() { return null; }
}
class C : B, I
{
override MC foo() { return null; }
}
}

/***************************************************/
// 5962

Expand Down Expand Up @@ -4730,6 +4750,7 @@ int main()
test85();
test86();
test87();
test5554();
test88();
test7545();
test89();
Expand Down

0 comments on commit d97b4ce

Please sign in to comment.