Skip to content

Commit

Permalink
Merge pull request #424 from dlang-community/issue-423
Browse files Browse the repository at this point in the history
Support 'throw' as a function attribute
  • Loading branch information
Hackerpilot authored Jul 30, 2020
2 parents ddafc62 + d8e3515 commit 1393ee4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/dparse/parser.d
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,7 @@ class Parser
* | $(LITERAL 'nothrow')
* | $(LITERAL 'pure')
* | $(LITERAL 'ref')
* | $(LITERAL 'throw')
* ;)
*/
Attribute parseAttribute()
Expand Down Expand Up @@ -1267,6 +1268,7 @@ class Parser
case tok!"nothrow":
case tok!"pure":
case tok!"ref":
case tok!"throw":
node.attribute = advance();
break;
default:
Expand Down Expand Up @@ -4638,10 +4640,11 @@ class Parser
case tok!"nothrow":
case tok!"return":
case tok!"scope":
case tok!"throw":
node.tokenType = advance().type;
break;
default:
error(`Member funtion attribute expected`);
error(`Member function attribute expected`);
}
node.tokens = tokens[startIndex .. index];
return node;
Expand Down Expand Up @@ -6113,6 +6116,7 @@ class Parser
* | $(LITERAL 'scope')
* | $(LITERAL 'static')
* | $(LITERAL 'synchronized')
* | $(LITERAL 'throw')
* ;)
*/
StorageClass parseStorageClass()
Expand Down Expand Up @@ -6155,6 +6159,7 @@ class Parser
case tok!"scope":
case tok!"static":
case tok!"synchronized":
case tok!"throw":
node.token = advance();
break;
default:
Expand Down Expand Up @@ -8255,6 +8260,7 @@ protected: final:
case tok!"ref":
case tok!"extern":
case tok!"align":
case tok!"throw":
return true;
default:
return false;
Expand All @@ -8274,6 +8280,7 @@ protected: final:
case tok!"nothrow":
case tok!"return":
case tok!"scope":
case tok!"throw":
return true;
default:
return false;
Expand Down
3 changes: 3 additions & 0 deletions test/fail_files/throwattribute.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
void doThings(throw int x)
{
}
10 changes: 10 additions & 0 deletions test/pass_files/throwattribute.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
void doStuff() throw {
throw void doThings()
{

}
throw new Exception("OH NO!");
}

throw:
extern void throwsSomething();

0 comments on commit 1393ee4

Please sign in to comment.