re PR c++/89875 (invalid typeof reference to a member of an incomplete struct accepted at function scope)

/cp
2019-05-29  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/89875
	* parser.c (cp_parser_sizeof_operand): When the type-id production
	did not work out commit to the tentative parse.

/testsuite
2019-05-29  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/89875
	* g++.dg/cpp0x/decltype-pr66548.C: Remove xfail.
	* g++.dg/template/sizeof-template-argument.C: Adjust expected error.

From-SVN: r271746
This commit is contained in:
Paolo Carlini 2019-05-29 17:30:36 +00:00
parent 65539b1ef3
commit 824e57cbf4
5 changed files with 27 additions and 9 deletions

View File

@ -1,3 +1,9 @@
2019-05-29 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/89875
* parser.c (cp_parser_sizeof_operand): When the type-id production
did not work out commit to the tentative parse.
2019-05-29 Jakub Jelinek <jakub@redhat.com>
P1091R3 - Extending structured bindings to be more like var decls

View File

@ -28942,6 +28942,8 @@ cp_parser_sizeof_operand (cp_parser* parser, enum rid keyword)
{
tree type = NULL_TREE;
tentative_firewall firewall (parser);
/* We can't be sure yet whether we're looking at a type-id or an
expression. */
cp_parser_parse_tentatively (parser);
@ -28969,11 +28971,15 @@ cp_parser_sizeof_operand (cp_parser* parser, enum rid keyword)
/* If all went well, then we're done. */
if (cp_parser_parse_definitely (parser))
expr = type;
}
else
{
/* Commit to the tentative_firewall so we get syntax errors. */
cp_parser_commit_to_tentative_parse (parser);
/* If the type-id production did not work out, then we must be
looking at the unary-expression production. */
if (!expr)
expr = cp_parser_unary_expression (parser);
}
}
else
expr = cp_parser_unary_expression (parser);
/* Go back to evaluating expressions. */

View File

@ -1,7 +1,13 @@
2019-05-29 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/89875
* g++.dg/cpp0x/decltype-pr66548.C: Remove xfail.
* g++.dg/template/sizeof-template-argument.C: Adjust expected error.
2019-05-29 Alejandro Martinez <alejandro.martinezvicente@arm.com>
* gcc.target/aarch64/sve2/aarch64-sve2.exp: New file, regression driver
for AArch64 SVE2.
* gcc.target/aarch64/sve2/aarch64-sve2.exp: New file, regression
driver for AArch64 SVE2.
* gcc.target/aarch64/sve2/average_1.c: New test.
* lib/target-supports.exp (check_effective_target_aarch64_sve2): New
helper.

View File

@ -11,7 +11,7 @@ struct Meow {};
void f ()
{
decltype (Meow.purr ()) d; // { dg-error "expected primary-expression" "pr89875" { xfail c++98_only } }
decltype (Meow.purr ()) d; // { dg-error "expected primary-expression" }
(void)&d;
}

View File

@ -3,9 +3,9 @@
template<int> struct A {};
template<typename> struct B : A <sizeof(=)> {}; /* { dg-error "template argument" } */
template<typename> struct B : A <sizeof(=)> {}; /* { dg-error "expected primary-expression" } */
template<typename> struct C : A <sizeof(=)> {}; /* { dg-error "template argument" } */
template<typename> struct C : A <sizeof(=)> {}; /* { dg-error "expected primary-expression" } */
int a;