From 7089879351354e33189f79e15279d7f21e89ea0a Mon Sep 17 00:00:00 2001 From: Hara Kenji Date: Tue, 27 Jan 2015 23:35:32 +0900 Subject: [PATCH] Revert "accept @pure @nothrow @return attributes" --- src/parse.c | 85 +++++++++++++++++++------------------------ test/runnable/mars1.d | 9 ----- 2 files changed, 37 insertions(+), 57 deletions(-) diff --git a/src/parse.c b/src/parse.c index 7a6bb2a383fa..50dbec43418e 100644 --- a/src/parse.c +++ b/src/parse.c @@ -138,9 +138,8 @@ Dsymbols *Parser::parseModule() Expressions *exps = NULL; StorageClass stc = parseAttribute(&exps); - if (stc & (STCproperty | STCnogc | STCdisable | - STCsafe | STCtrusted | STCsystem | - STCpure | STCnothrow | STCreturn)) + if (stc == STCproperty || stc == STCnogc || stc == STCdisable || + stc == STCsafe || stc == STCtrusted || stc == STCsystem) { error("@%s attribute for module declaration is not supported", token.toChars()); } @@ -987,51 +986,45 @@ StorageClass Parser::parseAttribute(Expressions **pudas) nextToken(); Expressions *udas = NULL; StorageClass stc = 0; - switch (token.value) + if (token.value == TOKidentifier) { - case TOKidentifier: - if (token.ident == Id::property) - stc = STCproperty; - else if (token.ident == Id::nogc) - stc = STCnogc; - else if (token.ident == Id::safe) - stc = STCsafe; - else if (token.ident == Id::trusted) - stc = STCtrusted; - else if (token.ident == Id::system) - stc = STCsystem; - else if (token.ident == Id::disable) - stc = STCdisable; - else + if (token.ident == Id::property) + stc = STCproperty; + else if (token.ident == Id::nogc) + stc = STCnogc; + else if (token.ident == Id::safe) + stc = STCsafe; + else if (token.ident == Id::trusted) + stc = STCtrusted; + else if (token.ident == Id::system) + stc = STCsystem; + else if (token.ident == Id::disable) + stc = STCdisable; + else + { + // Allow identifier, template instantiation, or function call + Expression *exp = parsePrimaryExp(); + if (token.value == TOKlparen) { - // Allow identifier, template instantiation, or function call - Expression *exp = parsePrimaryExp(); - if (token.value == TOKlparen) - { - Loc loc = token.loc; - exp = new CallExp(loc, exp, parseArguments()); - } - - udas = new Expressions(); - udas->push(exp); + Loc loc = token.loc; + exp = new CallExp(loc, exp, parseArguments()); } - break; - case TOKlparen: - // @( ArgumentList ) - // Concatenate with existing - if (peekNext() == TOKrparen) - error("empty attribute list is not allowed"); - udas = parseArguments(); - break; - - case TOKpure: stc = STCpure; break; - case TOKnothrow: stc = STCnothrow; break; - case TOKreturn: stc = STCreturn; break; - - default: - error("@identifier or @(ArgumentList) expected, not @%s", token.toChars()); - break; + udas = new Expressions(); + udas->push(exp); + } + } + else if (token.value == TOKlparen) + { + // @( ArgumentList ) + // Concatenate with existing + if (peekNext() == TOKrparen) + error("empty attribute list is not allowed"); + udas = parseArguments(); + } + else + { + error("@identifier or @(ArgumentList) expected, not @%s", token.toChars()); } if (stc) @@ -6209,10 +6202,6 @@ bool Parser::skipAttributes(Token *t, Token **pt) break; case TOKat: t = peek(t); - if (t->value == TOKpure || - t->value == TOKnothrow || - t->value == TOKreturn) - break; if (t->value == TOKidentifier) { /* @identifier diff --git a/test/runnable/mars1.d b/test/runnable/mars1.d index cac74bec435d..0cc05ca34479 100644 --- a/test/runnable/mars1.d +++ b/test/runnable/mars1.d @@ -1252,15 +1252,6 @@ void test13784() } -//////////////////////////////////////////////////////////////////////// - -struct At -{ - @property auto info() @safe @nothrow @pure @return const { return this; } - - @pure @nothrow @return ref int info2(ref int x) { return x; } -} - //////////////////////////////////////////////////////////////////////// int main()