Commit 205d542a by Kamlesh Kumar Committed by Jason Merrill

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
parent 2674fa47
2018-11-16 Kamlesh Kumar <kamleshbhalui@gmail.com>
DR 1207
PR c++/52869
* parser.c (cp_parser_noexcept_specification_opt): Call
inject_this_parameter.
2018-11-16 Jason Merrill <jason@redhat.com> 2018-11-16 Jason Merrill <jason@redhat.com>
Implement P0479R5, [[likely]] and [[unlikely]]. Implement P0479R5, [[likely]] and [[unlikely]].
......
...@@ -24668,6 +24668,12 @@ cp_parser_noexcept_specification_opt (cp_parser* parser, ...@@ -24668,6 +24668,12 @@ cp_parser_noexcept_specification_opt (cp_parser* parser,
matching_parens parens; matching_parens parens;
parens.consume_open (parser); 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) if (require_constexpr)
{ {
/* Types may not be defined in an exception-specification. */ /* Types may not be defined in an exception-specification. */
...@@ -24687,6 +24693,9 @@ cp_parser_noexcept_specification_opt (cp_parser* parser, ...@@ -24687,6 +24693,9 @@ cp_parser_noexcept_specification_opt (cp_parser* parser,
} }
parens.require_close (parser); parens.require_close (parser);
current_class_ptr = save_ccp;
current_class_ref = save_ccr;
} }
else else
{ {
// 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 T>
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;}
};
// DR 1207
// PR c++/52869
// { dg-do compile { target c++11 } }
void
fn ()
{
struct S {
bool operator!() noexcept(false);
} s;
S t = s;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment