Skip to content

Commit

Permalink
Fix Issue 17074: extern(C++, keyword) crashes compiler
Browse files Browse the repository at this point in the history
This change unsets 'idents' if an error occurred parsing the C++
namespace, so that the later check for 'assert(idents.dim)' never fires.

https://issues.dlang.org/show_bug.cgi?id=17074
  • Loading branch information
ibuclaw committed Jan 11, 2017
1 parent d3187d6 commit e451607
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/parse.d
Original file line number Diff line number Diff line change
Expand Up @@ -2185,7 +2185,10 @@ final class Parser : Lexer
}
}
else
{
error("identifier expected for C++ namespace");
idents = null; // error occurred, invalidate list of elements.
}
break;
}
}
Expand Down
39 changes: 39 additions & 0 deletions test/fail_compilation/ice17074.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
TEST_OUTPUT:
---
fail_compilation/ice17074.d(9): Error: identifier expected for C++ namespace
fail_compilation/ice17074.d(9): Error: found 'cast' when expecting ')'
fail_compilation/ice17074.d(9): Error: declaration expected, not ')'
---
*/
extern(C++, cast) void ice_keyword();

/*
TEST_OUTPUT:
---
fail_compilation/ice17074.d(19): Error: identifier expected for C++ namespace
fail_compilation/ice17074.d(19): Error: found '__overloadset' when expecting ')'
fail_compilation/ice17074.d(19): Error: declaration expected, not ')'
---
*/
extern(C++, std.__overloadset) void ice_std_keyword();

/*
TEST_OUTPUT:
---
fail_compilation/ice17074.d(29): Error: identifier expected for C++ namespace
fail_compilation/ice17074.d(29): Error: found '...' when expecting ')'
fail_compilation/ice17074.d(29): Error: declaration expected, not ')'
---
*/
extern(C++, ...) void ice_token();

/*
TEST_OUTPUT:
---
fail_compilation/ice17074.d(39): Error: identifier expected for C++ namespace
fail_compilation/ice17074.d(39): Error: found '*' when expecting ')'
fail_compilation/ice17074.d(39): Error: declaration expected, not ')'
---
*/
extern(C++, std.*) void ice_std_token();

0 comments on commit e451607

Please sign in to comment.