From 9878d6b61a1ea7f0e839bdb040ac15bb490e26fc Mon Sep 17 00:00:00 2001 From: Daniel Murphy Date: Sun, 20 Mar 2016 15:28:28 +1100 Subject: [PATCH] Remove last traces of typedef --- src/expression.d | 4 +--- src/expression.h | 2 +- src/parse.d | 34 +++++++++----------------------- src/tokens.d | 3 --- src/tokens.h | 2 +- test/fail_compilation/fail108.d | 20 ------------------- test/fail_compilation/fail243t.d | 24 ---------------------- test/fail_compilation/fail6572.d | 18 ----------------- test/fail_compilation/fail8664.d | 13 ------------ 9 files changed, 12 insertions(+), 108 deletions(-) delete mode 100644 test/fail_compilation/fail108.d delete mode 100644 test/fail_compilation/fail243t.d delete mode 100644 test/fail_compilation/fail6572.d delete mode 100644 test/fail_compilation/fail8664.d diff --git a/src/expression.d b/src/expression.d index ce90ef2f174e..f3ae78de1022 100644 --- a/src/expression.d +++ b/src/expression.d @@ -7126,7 +7126,7 @@ public: Identifier id; // can be null TOK tok; // ':' or '==' Type tspec; // can be null - TOK tok2; // 'struct', 'union', 'typedef', etc. + TOK tok2; // 'struct', 'union', etc. TemplateParameters* parameters; extern (D) this(Loc loc, Type targ, Identifier id, TOK tok, Type tspec, TOK tok2, TemplateParameters* parameters) @@ -7181,8 +7181,6 @@ public: { switch (tok2) { - case TOKtypedef: - goto Lno; case TOKstruct: if (targ.ty != Tstruct) goto Lno; diff --git a/src/expression.h b/src/expression.h index d289fd4adad5..a521337ee7ac 100644 --- a/src/expression.h +++ b/src/expression.h @@ -720,7 +720,7 @@ class IsExp : public Expression Identifier *id; // can be NULL TOK tok; // ':' or '==' Type *tspec; // can be NULL - TOK tok2; // 'struct', 'union', 'typedef', etc. + TOK tok2; // 'struct', 'union', etc. TemplateParameters *parameters; IsExp(Loc loc, Type *targ, Identifier *id, TOK tok, Type *tspec, diff --git a/src/parse.d b/src/parse.d index ef8db6317007..b4b1b100ca66 100644 --- a/src/parse.d +++ b/src/parse.d @@ -484,7 +484,6 @@ public: case TOKcomplex80: case TOKvoid: case TOKalias: - case TOKtypedef: case TOKidentifier: case TOKsuper: case TOKtypeof: @@ -3958,12 +3957,6 @@ public: // alias StorageClasses type ident; } - else if (token.value == TOKtypedef) - { - error("use alias instead of typedef"); - tok = token.value; - nextToken(); - } parseStorageClasses(storage_class, link, structalign, udas); if (token.value == TOKstruct || token.value == TOKunion || token.value == TOKclass || token.value == TOKinterface) { @@ -4049,7 +4042,7 @@ public: checkCstyleTypeSyntax(loc, t, alt, ident); else if (!isThis) error("no identifier for declarator %s", t.toChars()); - if (tok == TOKtypedef || tok == TOKalias) + if (tok == TOKalias) { Declaration v; Initializer _init = null; @@ -4066,21 +4059,15 @@ public: nextToken(); _init = parseInitializer(); } - if (tok == TOKtypedef) - { - v = new AliasDeclaration(loc, ident, t); // dummy - } - else + if (_init) { - if (_init) - { - if (isThis) - error("cannot use syntax 'alias this = %s', use 'alias %s this' instead", _init.toChars(), _init.toChars()); - else - error("alias cannot have initializer"); - } - v = new AliasDeclaration(loc, ident, t); + if (isThis) + error("cannot use syntax 'alias this = %s', use 'alias %s this' instead", _init.toChars(), _init.toChars()); + else + error("alias cannot have initializer"); } + v = new AliasDeclaration(loc, ident, t); + v.storage_class = storage_class; if (pAttrs) { @@ -4631,7 +4618,6 @@ public: if (peekNext() == TOKlparen) goto Lexp; goto case; - case TOKtypedef: case TOKalias: case TOKconst: case TOKauto: @@ -6864,12 +6850,10 @@ public: { tok = token.value; nextToken(); - if (tok == TOKequal && (token.value == TOKtypedef || token.value == TOKstruct || token.value == TOKunion || token.value == TOKclass || token.value == TOKsuper || token.value == TOKenum || token.value == TOKinterface || token.value == TOKargTypes || token.value == TOKparameters || token.value == TOKconst && peek(&token).value == TOKrparen || token.value == TOKimmutable && peek(&token).value == TOKrparen || token.value == TOKshared && peek(&token).value == TOKrparen || token.value == TOKwild && peek(&token).value == TOKrparen || token.value == TOKfunction || token.value == TOKdelegate || token.value == TOKreturn)) + if (tok == TOKequal && (token.value == TOKstruct || token.value == TOKunion || token.value == TOKclass || token.value == TOKsuper || token.value == TOKenum || token.value == TOKinterface || token.value == TOKargTypes || token.value == TOKparameters || token.value == TOKconst && peek(&token).value == TOKrparen || token.value == TOKimmutable && peek(&token).value == TOKrparen || token.value == TOKshared && peek(&token).value == TOKrparen || token.value == TOKwild && peek(&token).value == TOKrparen || token.value == TOKfunction || token.value == TOKdelegate || token.value == TOKreturn)) { tok2 = token.value; nextToken(); - if (tok2 == TOKtypedef) - deprecation("typedef is removed"); } else { diff --git a/src/tokens.d b/src/tokens.d index b67565cf9fe7..7e391239776e 100644 --- a/src/tokens.d +++ b/src/tokens.d @@ -209,7 +209,6 @@ enum TOK : int TOKunion, TOKenum, TOKimport, - TOKtypedef, TOKalias, TOKoverride, TOKdelegate, @@ -466,7 +465,6 @@ alias TOKinterface = TOK.TOKinterface; alias TOKunion = TOK.TOKunion; alias TOKenum = TOK.TOKenum; alias TOKimport = TOK.TOKimport; -alias TOKtypedef = TOK.TOKtypedef; alias TOKalias = TOK.TOKalias; alias TOKoverride = TOK.TOKoverride; alias TOKdelegate = TOK.TOKdelegate; @@ -1006,7 +1004,6 @@ immutable Keyword[] keywords = Keyword("static", TOKstatic), Keyword("final", TOKfinal), Keyword("const", TOKconst), - Keyword("typedef", TOKtypedef), Keyword("alias", TOKalias), Keyword("override", TOKoverride), Keyword("abstract", TOKabstract), diff --git a/src/tokens.h b/src/tokens.h index edb4a81eced9..7d5eee95202b 100644 --- a/src/tokens.h +++ b/src/tokens.h @@ -135,7 +135,7 @@ enum TOK // 159 // Aggregates TOKstruct, TOKclass, TOKinterface, TOKunion, TOKenum, TOKimport, - TOKtypedef, TOKalias, TOKoverride, TOKdelegate, TOKfunction, + TOKalias, TOKoverride, TOKdelegate, TOKfunction, TOKmixin, TOKalign, TOKextern, TOKprivate, TOKprotected, TOKpublic, TOKexport, diff --git a/test/fail_compilation/fail108.d b/test/fail_compilation/fail108.d deleted file mode 100644 index 4bf8b036cbc0..000000000000 --- a/test/fail_compilation/fail108.d +++ /dev/null @@ -1,20 +0,0 @@ -// REQUIRED_ARGS: -d -/* -TEST_OUTPUT: ---- -fail_compilation/fail108.d(14): Error: use alias instead of typedef -fail_compilation/fail108.d(15): Error: use alias instead of typedef ---- -*/ - -// 249 - -module test1; - -typedef foo bar; -typedef bar foo; - -void main () -{ - foo blah; -} diff --git a/test/fail_compilation/fail243t.d b/test/fail_compilation/fail243t.d deleted file mode 100644 index fb6a524afd47..000000000000 --- a/test/fail_compilation/fail243t.d +++ /dev/null @@ -1,24 +0,0 @@ -// REQUIRED_ARGS: -de -/* -TEST_OUTPUT: ---- -fail_compilation/fail243t.d(16): Error: use alias instead of typedef ---- -*/ - -deprecated -{ - //class DepClass {} - //struct DepStruct {} - //union DepUnion {} - //enum DepEnum { A } - //alias int DepAlias; - typedef int DepTypedef; -} - -//void func(DepClass obj) {} -//void func(DepStruct obj) {} -//void func(DepUnion obj) {} -//void func(DepEnum obj) {} -//void func(DepAlias obj) {} -void func(DepTypedef obj) {} diff --git a/test/fail_compilation/fail6572.d b/test/fail_compilation/fail6572.d deleted file mode 100644 index ef952a2d0bd9..000000000000 --- a/test/fail_compilation/fail6572.d +++ /dev/null @@ -1,18 +0,0 @@ -// REQUIRED_ARGS: -de -/* -TEST_OUTPUT: ---- -fail_compilation/fail6572.d(9): Error: use alias instead of typedef ---- -*/ - -typedef int y; - -// 11424 -/* -TEST_OUTPUT: ---- -fail_compilation/fail6572.d(18): Error: use alias instead of typedef ---- -*/ -typedef struct S { } diff --git a/test/fail_compilation/fail8664.d b/test/fail_compilation/fail8664.d deleted file mode 100644 index ea5a16991101..000000000000 --- a/test/fail_compilation/fail8664.d +++ /dev/null @@ -1,13 +0,0 @@ -// 8664 -// REQUIRED_ARGS: -d -g -c -/* -TEST_OUTPUT: ---- -fail_compilation/fail8664.d(11): Error: use alias instead of typedef -fail_compilation/fail8664.d(12): Error: use alias instead of typedef ---- -*/ - -typedef foo bar; -typedef bar foo; -