From: Marek Polacek Date: Tue, 8 Jun 2021 21:44:13 +0000 (-0400) Subject: c++: Failure to delay noexcept parsing with ptr-operator [PR100752] X-Git-Tag: upstream/12.2.0~6875 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f9c80eb12c58126a94ad869380af5b88b752c06f;p=platform%2Fupstream%2Fgcc.git c++: Failure to delay noexcept parsing with ptr-operator [PR100752] We weren't passing 'flags' to the recursive call to cp_parser_declarator in the ptr-operator case and as an effect, delayed parsing of noexcept didn't work as advertised. The following change passes more than just CP_PARSER_FLAGS_DELAY_NOEXCEPT but that doesn't seem to break anything. I'm now also passing member_p and static_p, as a consequence, two tests needed small tweaks. PR c++/100752 gcc/cp/ChangeLog: * parser.c (cp_parser_declarator): Pass flags down to cp_parser_declarator. Also pass static_p/member_p. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/noexcept69.C: New test. * g++.dg/parse/saved1.C: Adjust dg-error. * g++.dg/template/crash50.C: Likewise. --- diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 096580e..02daa7a 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -22170,12 +22170,10 @@ cp_parser_declarator (cp_parser* parser, cp_parser_parse_tentatively (parser); /* Parse the dependent declarator. */ - declarator = cp_parser_declarator (parser, dcl_kind, - CP_PARSER_FLAGS_NONE, + declarator = cp_parser_declarator (parser, dcl_kind, flags, /*ctor_dtor_or_conv_p=*/NULL, /*parenthesized_p=*/NULL, - /*member_p=*/false, - friend_p, /*static_p=*/false); + member_p, friend_p, static_p); /* If we are parsing an abstract-declarator, we must handle the case where the dependent declarator is absent. */ diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept69.C b/gcc/testsuite/g++.dg/cpp0x/noexcept69.C new file mode 100644 index 0000000..9b87ba0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept69.C @@ -0,0 +1,12 @@ +// PR c++/100752 +// { dg-do compile { target c++11 } } + +struct S { + void f() noexcept {} + S &g() noexcept(noexcept(f())) { f(); return *this; } +}; + +struct X { + int& f() noexcept(noexcept(i)); + int i; +}; diff --git a/gcc/testsuite/g++.dg/parse/saved1.C b/gcc/testsuite/g++.dg/parse/saved1.C index 979a056..1deaa93 100644 --- a/gcc/testsuite/g++.dg/parse/saved1.C +++ b/gcc/testsuite/g++.dg/parse/saved1.C @@ -1,7 +1,7 @@ // Test that the parser doesn't go into an infinite loop from ignoring the // PRE_PARSED_FUNCTION_DECL token. -class C { static void* operator new(size_t); }; // { dg-error "24:declaration of .operator new. as non-function" } -// { dg-error "expected|ISO C\\+\\+ forbids" "" { target *-*-* } .-1 } +class C { static void* operator new(size_t); }; // { dg-error "37:.size_t. has not been declared" } +// { dg-error ".operator new. takes type .size_t." "" { target *-*-* } .-1 } void* C::operator new(size_t) { return 0; } // { dg-error "" } class D { D(int i): integer(i){}}; // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/template/crash50.C b/gcc/testsuite/g++.dg/template/crash50.C index 286685a..4b846cd 100644 --- a/gcc/testsuite/g++.dg/template/crash50.C +++ b/gcc/testsuite/g++.dg/template/crash50.C @@ -3,5 +3,5 @@ struct A { - template void* foo(; // { dg-error "primary-expression|initialization|static|template" } + template void* foo(; // { dg-error "expected|initialization|static|template" } };