Skip to content

Commit 20c45ce

Browse files
authored
Merge pull request #3707 from ntrel/d-template
D: set template members parent name
2 parents c04f837 + 690d8b3 commit 20c45ce

File tree

6 files changed

+50
-22
lines changed

6 files changed

+50
-22
lines changed

Units/parser-d.r/simple.d.d/expected.tags

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,8 @@ AliasInt input.d /^alias AliasInt = int;$/;" a file:
22
CT input.d /^ class CT(T)$/;" c class:Class file:
33
Class input.d /^class Class : Interface$/;" c file:
44
Enum input.d /^enum Enum : int$/;" g file:
5-
IT input.d /^interface IT(T){}$/;" i file:
65
Interface input.d /^interface Interface$/;" i file:
7-
ST input.d /^struct ST(T){}$/;" s file:
86
Struct input.d /^struct Struct$/;" s file:
9-
Template input.d /^template Template(alias a, T...)$/;" T file:
10-
TemplateAlias input.d /^ alias TemplateAlias = a!T;$/;" a file:
11-
UT input.d /^union UT(T){}$/;" u file:
127
Union input.d /^ union Union$/;" u struct:Struct file:
138
_bar input.d /^ private AliasInt _bar;$/;" m class:Class file:
149
attr_anon input.d /^@(obj) T attr_anon;$/;" v

Units/parser-d.r/simple.d.d/input.d

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,6 @@ public
5858
int modulevar;
5959
}
6060

61-
// declaration templates
62-
interface IT(T){}
63-
struct ST(T){}
64-
union UT(T){}
65-
// FIXME - parsed as 'T'
66-
//alias AT(T) = T;
67-
//enum ET(T) = T.init;
68-
69-
template Template(alias a, T...)
70-
{
71-
alias TemplateAlias = a!T;
72-
}
73-
7461
Object obj;
7562

7663
const(int)* type_con;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--sort=no
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Template input.d /^template Template(alias a, T...)$/;" T file:
2+
TemplateAlias input.d /^ alias TemplateAlias = a!T;$/;" a template:Template file:
3+
memb input.d /^ int memb;$/;" m template:Template file:
4+
b input.d /^Foo!x b;$/;" v
5+
each input.d /^template each(alias fun = "a")$/;" T file:
6+
child input.d /^ template child(){}$/;" T template:each file:
7+
tmethod input.d /^ void tmethod()(){}$/;" f template:each
8+
ImplementLength input.d /^mixin ImplementLength!source; \/\/ FIXME source too!$/;" X
9+
source input.d /^mixin ImplementLength!source; \/\/ FIXME source too!$/;" X
10+
IT input.d /^interface IT(T){}$/;" i file:
11+
ST input.d /^struct ST(T){}$/;" s file:
12+
UT input.d /^union UT(T){}$/;" u file:
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
template Template(alias a, T...)
2+
if (is(typeof(a)))
3+
{
4+
private:
5+
// no parent:
6+
alias TemplateAlias = a!T;
7+
int memb;
8+
}
9+
10+
Foo!x b;
11+
Foo!(x) c; // FIXME
12+
Foo!(x < 2) d; // FIXME
13+
void f(Foo!x); // FIXME
14+
15+
template each(alias fun = "a")
16+
{
17+
template child(){}
18+
void tmethod()(){}
19+
}
20+
21+
// FIXME
22+
/+
23+
int vt(alias a) = 0; // not parsed
24+
// parsed as T:
25+
alias AT(T) = T;
26+
enum ET(T) = T.init;
27+
+/
28+
29+
mixin ImplementLength!source; // FIXME source too!
30+
31+
// declaration templates
32+
interface IT(T){}
33+
struct ST(T){}
34+
union UT(T){}

parsers/c-based.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2866,9 +2866,7 @@ static int tagCheck (statementInfo *const st)
28662866
case TOKEN_BRACE_OPEN:
28672867
if (isType (prev, TOKEN_ARGS))
28682868
{
2869-
if (st->declaration == DECL_TEMPLATE)
2870-
corkIndex = qualifyBlockTag (st, prev2);
2871-
else if (st->declaration == DECL_FUNCTION_TEMPLATE)
2869+
if (st->declaration == DECL_FUNCTION_TEMPLATE)
28722870
{
28732871
corkIndex = qualifyFunctionTag (st, st->blockName);
28742872
}
@@ -2880,7 +2878,8 @@ static int tagCheck (statementInfo *const st)
28802878
/* D declaration templates */
28812879
if (isInputLanguage (Lang_d) &&
28822880
(st->declaration == DECL_CLASS || st->declaration == DECL_STRUCT ||
2883-
st->declaration == DECL_INTERFACE || st->declaration == DECL_UNION))
2881+
st->declaration == DECL_INTERFACE || st->declaration == DECL_UNION ||
2882+
st->declaration == DECL_TEMPLATE))
28842883
corkIndex = qualifyBlockTag (st, prev2);
28852884
else
28862885
{

0 commit comments

Comments
 (0)