From: Kamlesh Kumar Date: Fri, 16 Nov 2018 21:55:00 +0000 (+0000) Subject: re PR c++/52869 ([DR 1207] "this" not being allowed in noexcept clauses) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=205d542ad55d8dee50acfe4f8ff6c2138dbad418;p=gcc.git re PR c++/52869 ([DR 1207] "this" not being allowed in noexcept clauses) PR c++/52869 DR 1207 * parser.c (cp_parser_noexcept_specification_opt): Call inject_this_parameter. From-SVN: r266224 --- 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; +}