From cf465ccdc5140a13d676c987dc5f8fdab88e5e79 Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 16 Nov 2018 21:55:00 +0000 Subject: [PATCH] PR c++/52869 DR 1207 * parser.c (cp_parser_noexcept_specification_opt): Call inject_this_parameter. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@266224 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/parser.c | 9 +++++++++ gcc/testsuite/g++.dg/DRs/dr1207-1.C | 23 +++++++++++++++++++++++ gcc/testsuite/g++.dg/DRs/dr1207-2.C | 12 ++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 gcc/testsuite/g++.dg/DRs/dr1207-1.C create mode 100644 gcc/testsuite/g++.dg/DRs/dr1207-2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d0a344eadca..6d99d6a5d79 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2018-11-16 Kamlesh Kumar + + DR 1207 + PR c++/52869 + * parser.c (cp_parser_noexcept_specification_opt): Call + inject_this_parameter. + 2018-11-16 Jason Merrill Implement P0479R5, [[likely]] and [[unlikely]]. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 215c5fb9983..88fc426102b 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -24668,6 +24668,12 @@ cp_parser_noexcept_specification_opt (cp_parser* parser, matching_parens parens; parens.consume_open (parser); + tree save_ccp = current_class_ptr; + tree save_ccr = current_class_ref; + + if (current_class_type) + inject_this_parameter (current_class_type, TYPE_UNQUALIFIED); + if (require_constexpr) { /* Types may not be defined in an exception-specification. */ @@ -24687,6 +24693,9 @@ cp_parser_noexcept_specification_opt (cp_parser* parser, } parens.require_close (parser); + + current_class_ptr = save_ccp; + current_class_ref = save_ccr; } else { diff --git a/gcc/testsuite/g++.dg/DRs/dr1207-1.C b/gcc/testsuite/g++.dg/DRs/dr1207-1.C new file mode 100644 index 00000000000..16fce84427c --- /dev/null +++ b/gcc/testsuite/g++.dg/DRs/dr1207-1.C @@ -0,0 +1,23 @@ +// DR 1207 +// PR c++/52869 +// { dg-do compile { target c++11 } } + +struct S { + void f() { } + void g() noexcept(noexcept(f())) { } + void h() noexcept(noexcept(this->f())) { } +}; + +struct Nyan { + Nyan &operator++() noexcept { return *this; } + void omg() noexcept(noexcept(++*this)) {} +}; + +template +class Test{ + T count; + Test (T arg) {count=arg;} + void fetch() { } + T inc () noexcept(noexcept(this->fetch())) {return ++count;} + T dec () noexcept(noexcept(fetch())) { return --count;} +}; diff --git a/gcc/testsuite/g++.dg/DRs/dr1207-2.C b/gcc/testsuite/g++.dg/DRs/dr1207-2.C new file mode 100644 index 00000000000..2d54748bdad --- /dev/null +++ b/gcc/testsuite/g++.dg/DRs/dr1207-2.C @@ -0,0 +1,12 @@ +// DR 1207 +// PR c++/52869 +// { dg-do compile { target c++11 } } + +void +fn () +{ + struct S { + bool operator!() noexcept(false); + } s; + S t = s; +} -- 2.11.4.GIT