PR c++/89831 - error with qualified-id in const member function.
Since the fix for 15272 we were remembering the wrong function to use at instantiation time, because the type of the SCOPE_REF didn't reflect the cv-quals of 'this'. Conveniently, we can fix this by simplifying the code. * semantics.c (finish_non_static_data_member): Use object cv-quals in scoped case, too. From-SVN: r269977
This commit is contained in:
parent
fad170232c
commit
dd03c093bc
3 changed files with 30 additions and 10 deletions
|
@ -1,5 +1,9 @@
|
|||
2019-03-27 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/89831 - error with qualified-id in const member function.
|
||||
* semantics.c (finish_non_static_data_member): Use object cv-quals
|
||||
in scoped case, too.
|
||||
|
||||
PR c++/89421 - ICE with lambda in template parameter list.
|
||||
* parser.c (cp_parser_lambda_expression): Also reject a lambda in a
|
||||
template parameter list before C++20.
|
||||
|
|
|
@ -1861,7 +1861,7 @@ finish_non_static_data_member (tree decl, tree object, tree qualifying_scope)
|
|||
|
||||
if (current_class_ptr)
|
||||
TREE_USED (current_class_ptr) = 1;
|
||||
if (processing_template_decl && !qualifying_scope)
|
||||
if (processing_template_decl)
|
||||
{
|
||||
tree type = TREE_TYPE (decl);
|
||||
|
||||
|
@ -1882,17 +1882,16 @@ finish_non_static_data_member (tree decl, tree object, tree qualifying_scope)
|
|||
type = cp_build_qualified_type (type, quals);
|
||||
}
|
||||
|
||||
ret = (convert_from_reference
|
||||
(build_min (COMPONENT_REF, type, object, decl, NULL_TREE)));
|
||||
if (qualifying_scope)
|
||||
/* Wrap this in a SCOPE_REF for now. */
|
||||
ret = build_qualified_name (type, qualifying_scope, decl,
|
||||
/*template_p=*/false);
|
||||
else
|
||||
ret = (convert_from_reference
|
||||
(build_min (COMPONENT_REF, type, object, decl, NULL_TREE)));
|
||||
}
|
||||
/* If PROCESSING_TEMPLATE_DECL is nonzero here, then
|
||||
QUALIFYING_SCOPE is also non-null. Wrap this in a SCOPE_REF
|
||||
for now. */
|
||||
else if (processing_template_decl)
|
||||
ret = build_qualified_name (TREE_TYPE (decl),
|
||||
qualifying_scope,
|
||||
decl,
|
||||
/*template_p=*/false);
|
||||
QUALIFYING_SCOPE is also non-null. */
|
||||
else
|
||||
{
|
||||
tree access_type = TREE_TYPE (object);
|
||||
|
|
17
gcc/testsuite/g++.dg/template/scope6.C
Normal file
17
gcc/testsuite/g++.dg/template/scope6.C
Normal file
|
@ -0,0 +1,17 @@
|
|||
// PR c++/89831
|
||||
|
||||
struct Q {
|
||||
int operator[](int i) { return 0; }
|
||||
int operator[](int i) const { return 0; }
|
||||
};
|
||||
|
||||
struct Base {
|
||||
Q x;
|
||||
};
|
||||
struct X : public Base {
|
||||
template <typename T>
|
||||
void f(T) const {
|
||||
int q = Base::x[0];
|
||||
}
|
||||
};
|
||||
int main() { X().f(3); }
|
Loading…
Add table
Reference in a new issue