Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

D: set template members parent name #3707

Merged
merged 1 commit into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -56,19 +56,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;

private:
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 @@ -2843,9 +2843,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 @@ -2857,7 +2855,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