Skip to content

Commit

Permalink
Merge pull request #3707 from ntrel/d-template
Browse files Browse the repository at this point in the history
D: set template members parent name
  • Loading branch information
masatake committed May 4, 2023
2 parents c04f837 + 690d8b3 commit 20c45ce
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 22 deletions.
5 changes: 0 additions & 5 deletions Units/parser-d.r/simple.d.d/expected.tags
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@ AliasInt input.d /^alias AliasInt = int;$/;" a file:
CT input.d /^ class CT(T)$/;" c class:Class file:
Class input.d /^class Class : Interface$/;" c file:
Enum input.d /^enum Enum : int$/;" g file:
IT input.d /^interface IT(T){}$/;" i file:
Interface input.d /^interface Interface$/;" i file:
ST input.d /^struct ST(T){}$/;" s file:
Struct input.d /^struct Struct$/;" s file:
Template input.d /^template Template(alias a, T...)$/;" T file:
TemplateAlias input.d /^ alias TemplateAlias = a!T;$/;" a file:
UT input.d /^union UT(T){}$/;" u file:
Union input.d /^ union Union$/;" u struct:Struct file:
_bar input.d /^ private AliasInt _bar;$/;" m class:Class file:
attr_anon input.d /^@(obj) T attr_anon;$/;" v
Expand Down
13 changes: 0 additions & 13 deletions Units/parser-d.r/simple.d.d/input.d
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,6 @@ public
int modulevar;
}

// declaration templates
interface IT(T){}
struct ST(T){}
union UT(T){}
// FIXME - parsed as 'T'
//alias AT(T) = T;
//enum ET(T) = T.init;

template Template(alias a, T...)
{
alias TemplateAlias = a!T;
}

Object obj;

const(int)* type_con;
Expand Down
1 change: 1 addition & 0 deletions Units/parser-d.r/templates.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--sort=no
12 changes: 12 additions & 0 deletions Units/parser-d.r/templates.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Template input.d /^template Template(alias a, T...)$/;" T file:
TemplateAlias input.d /^ alias TemplateAlias = a!T;$/;" a template:Template file:
memb input.d /^ int memb;$/;" m template:Template file:
b input.d /^Foo!x b;$/;" v
each input.d /^template each(alias fun = "a")$/;" T file:
child input.d /^ template child(){}$/;" T template:each file:
tmethod input.d /^ void tmethod()(){}$/;" f template:each
ImplementLength input.d /^mixin ImplementLength!source; \/\/ FIXME source too!$/;" X
source input.d /^mixin ImplementLength!source; \/\/ FIXME source too!$/;" X
IT input.d /^interface IT(T){}$/;" i file:
ST input.d /^struct ST(T){}$/;" s file:
UT input.d /^union UT(T){}$/;" u file:
34 changes: 34 additions & 0 deletions Units/parser-d.r/templates.d/input.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
template Template(alias a, T...)
if (is(typeof(a)))
{
private:
// no parent:
alias TemplateAlias = a!T;
int memb;
}

Foo!x b;
Foo!(x) c; // FIXME
Foo!(x < 2) d; // FIXME
void f(Foo!x); // FIXME

template each(alias fun = "a")
{
template child(){}
void tmethod()(){}
}

// FIXME
/+
int vt(alias a) = 0; // not parsed
// parsed as T:
alias AT(T) = T;
enum ET(T) = T.init;
+/

mixin ImplementLength!source; // FIXME source too!

// declaration templates
interface IT(T){}
struct ST(T){}
union UT(T){}
7 changes: 3 additions & 4 deletions parsers/c-based.c
Original file line number Diff line number Diff line change
Expand Up @@ -2866,9 +2866,7 @@ static int tagCheck (statementInfo *const st)
case TOKEN_BRACE_OPEN:
if (isType (prev, TOKEN_ARGS))
{
if (st->declaration == DECL_TEMPLATE)
corkIndex = qualifyBlockTag (st, prev2);
else if (st->declaration == DECL_FUNCTION_TEMPLATE)
if (st->declaration == DECL_FUNCTION_TEMPLATE)
{
corkIndex = qualifyFunctionTag (st, st->blockName);
}
Expand All @@ -2880,7 +2878,8 @@ static int tagCheck (statementInfo *const st)
/* D declaration templates */
if (isInputLanguage (Lang_d) &&
(st->declaration == DECL_CLASS || st->declaration == DECL_STRUCT ||
st->declaration == DECL_INTERFACE || st->declaration == DECL_UNION))
st->declaration == DECL_INTERFACE || st->declaration == DECL_UNION ||
st->declaration == DECL_TEMPLATE))
corkIndex = qualifyBlockTag (st, prev2);
else
{
Expand Down

0 comments on commit 20c45ce

Please sign in to comment.