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.
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);
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);
--- /dev/null
+// 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); }