saved_in_unbraced_linkage_specification_p
= parser->in_unbraced_linkage_specification_p;
parser->in_unbraced_linkage_specification_p = false;
+ /* 'this' from an enclosing non-static member function is unavailable. */
+ tree saved_ccp = current_class_ptr;
+ tree saved_ccr = current_class_ref;
+ current_class_ptr = NULL_TREE;
+ current_class_ref = NULL_TREE;
/* Start the class. */
if (nested_name_specifier_p)
/* If there are noexcept-specifiers that have not yet been processed,
take care of them now. Do this before processing NSDMIs as they
may depend on noexcept-specifiers already having been processed. */
- tree save_ccp = current_class_ptr;
- tree save_ccr = current_class_ref;
FOR_EACH_VEC_SAFE_ELT (unparsed_noexcepts, ix, decl)
{
tree ctx = DECL_CONTEXT (decl);
}
vec_safe_truncate (unparsed_contracts, 0);
- current_class_ptr = save_ccp;
- current_class_ref = save_ccr;
+ current_class_ptr = NULL_TREE;
+ current_class_ref = NULL_TREE;
if (pushed_scope)
pop_scope (pushed_scope);
= saved_num_template_parameter_lists;
parser->in_unbraced_linkage_specification_p
= saved_in_unbraced_linkage_specification_p;
+ current_class_ptr = saved_ccp;
+ current_class_ref = saved_ccr;
return type;
}
--- /dev/null
+// PR c++/106969
+// { dg-do compile { target c++11 } }
+
+struct Context
+{
+ void
+ action() const
+ {
+ struct Foo
+ {
+ int wrapped;
+ decltype(&wrapped) get() { return &wrapped; }
+ } t;
+
+ *t.get()= 42; // OK, get() returns int* not const int*
+
+ struct Bar
+ {
+ using type = decltype(this); // { dg-error "invalid use of 'this'" }
+ };
+ }
+};