Commit 5e9a5385 by David Malcolm Committed by David Malcolm

PR c++/71184: Fix NULL dereference in cp_parser_operator

The source-range handling for the array form of operator
new/delete erroneously assumed that the "]" was present,
leading to a dereference of NULL when it's absent.

Fix it thusly.

gcc/cp/ChangeLog:
	PR c++/71184
	* parser.c (cp_parser_operator): For array new/delete, check that
	cp_parser_require returned a non-NULL token before dereferencing
	it.

gcc/testsuite/ChangeLog:
	PR c++/71184
	* g++.dg/pr71184.C: New test case.

From-SVN: r236483
parent 1478c897
2016-05-19 David Malcolm <dmalcolm@redhat.com>
PR c++/71184
* parser.c (cp_parser_operator): For array new/delete, check that
cp_parser_require returned a non-NULL token before dereferencing
it.
2016-05-19 Bernd Edlinger <bernd.edlinger@hotmail.de>
* decl.c (finish_enum_value_list): Use the specified mode.
......
......@@ -13791,8 +13791,9 @@ cp_parser_operator (cp_parser* parser)
/* Consume the `[' token. */
cp_lexer_consume_token (parser->lexer);
/* Look for the `]' token. */
end_loc = cp_parser_require (parser, CPP_CLOSE_SQUARE,
RT_CLOSE_SQUARE)->location;
if (cp_token *close_token
= cp_parser_require (parser, CPP_CLOSE_SQUARE, RT_CLOSE_SQUARE))
end_loc = close_token->location;
id = ansi_opname (op == NEW_EXPR
? VEC_NEW_EXPR : VEC_DELETE_EXPR);
}
2016-05-19 David Malcolm <dmalcolm@redhat.com>
PR c++/71184
* g++.dg/pr71184.C: New test case.
2016-05-19 Kelvin Nilsen <kelvin@gcc.gnu.org>
* gcc.target/powerpc/darn-0.c: New test.
......
operator new[ // { dg-error "expected type-specifier before 'new'" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment