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
This commit is contained in:
parent
1478c897bf
commit
5e9a538594
4 changed files with 16 additions and 2 deletions
|
@ -1,3 +1,10 @@
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
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.
|
||||
|
|
1
gcc/testsuite/g++.dg/pr71184.C
Normal file
1
gcc/testsuite/g++.dg/pr71184.C
Normal file
|
@ -0,0 +1 @@
|
|||
operator new[ // { dg-error "expected type-specifier before 'new'" }
|
Loading…
Add table
Reference in a new issue