diff --git a/Units/parser-d.r/simple.d.d/expected.tags b/Units/parser-d.r/simple.d.d/expected.tags index 7e0eae6de6..64d83349c6 100644 --- a/Units/parser-d.r/simple.d.d/expected.tags +++ b/Units/parser-d.r/simple.d.d/expected.tags @@ -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 diff --git a/Units/parser-d.r/simple.d.d/input.d b/Units/parser-d.r/simple.d.d/input.d index baa0eef396..55644df191 100644 --- a/Units/parser-d.r/simple.d.d/input.d +++ b/Units/parser-d.r/simple.d.d/input.d @@ -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: diff --git a/Units/parser-d.r/templates.d/args.ctags b/Units/parser-d.r/templates.d/args.ctags new file mode 100644 index 0000000000..5ee5f79f70 --- /dev/null +++ b/Units/parser-d.r/templates.d/args.ctags @@ -0,0 +1 @@ +--sort=no diff --git a/Units/parser-d.r/templates.d/expected.tags b/Units/parser-d.r/templates.d/expected.tags new file mode 100644 index 0000000000..9fb01ec250 --- /dev/null +++ b/Units/parser-d.r/templates.d/expected.tags @@ -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: diff --git a/Units/parser-d.r/templates.d/input.d b/Units/parser-d.r/templates.d/input.d new file mode 100644 index 0000000000..1f4063dd07 --- /dev/null +++ b/Units/parser-d.r/templates.d/input.d @@ -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){} diff --git a/parsers/c-based.c b/parsers/c-based.c index 41f52b1703..4bf37e99e2 100644 --- a/parsers/c-based.c +++ b/parsers/c-based.c @@ -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); } @@ -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 {