return parm;
}
+/* DECL is a static member function. Complain if it was declared
+ with function-cv-quals. */
+
+static void
+check_static_quals (tree decl, cp_cv_quals quals)
+{
+ if (quals != TYPE_UNQUALIFIED)
+ error ("static member function %q#D declared with type qualifiers",
+ decl);
+}
+
/* CTYPE is class type, or null if non-class.
TYPE is type this FUNCTION_DECL should have, either FUNCTION_TYPE
or METHOD_TYPE.
if (decl == error_mark_node)
return NULL_TREE;
+ if (DECL_STATIC_FUNCTION_P (decl))
+ check_static_quals (decl, quals);
+
if (attrlist)
{
cplus_decl_attributes (&decl, *attrlist, 0);
if (DECL_STATIC_FUNCTION_P (old_decl)
&& TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE)
- /* Remove the `this' parm added by grokclassfn.
- XXX Isn't this done in start_function, too? */
- revert_static_member_fn (decl);
+ {
+ /* Remove the `this' parm added by grokclassfn. */
+ revert_static_member_fn (decl);
+ check_static_quals (decl, quals);
+ }
if (DECL_ARTIFICIAL (old_decl))
{
error ("definition of implicitly-declared %qD", old_decl);
if (ctype == NULL_TREE && decl_context == FIELD && friendp == 0)
ctype = current_class_type;
- /* A constexpr non-static member function is implicitly const. */
- if (constexpr_p && ctype && staticp == 0
- && TREE_CODE (type) == FUNCTION_TYPE
- && sfk != sfk_constructor && sfk != sfk_destructor)
- memfn_quals |= TYPE_QUAL_CONST;
-
/* Now TYPE has the actual type. */
if (returned_attrs)
if (ctype && TREE_CODE (type) == FUNCTION_TYPE && staticp < 2
&& !NEW_DELETE_OPNAME_P (unqualified_id))
- type = build_memfn_type (type, ctype, memfn_quals);
+ {
+ cp_cv_quals real_quals = memfn_quals;
+ if (constexpr_p && sfk != sfk_constructor && sfk != sfk_destructor)
+ real_quals |= TYPE_QUAL_CONST;
+ type = build_memfn_type (type, ctype, real_quals);
+ }
{
tree decl;
/* Sometimes we don't notice that a function is a static member, and
build a METHOD_TYPE for it. Fix that up now. */
- if (ctype != NULL_TREE && DECL_STATIC_FUNCTION_P (decl1)
- && TREE_CODE (TREE_TYPE (decl1)) == METHOD_TYPE)
- {
- revert_static_member_fn (decl1);
- ctype = NULL_TREE;
- }
+ gcc_assert (!(ctype != NULL_TREE && DECL_STATIC_FUNCTION_P (decl1)
+ && TREE_CODE (TREE_TYPE (decl1)) == METHOD_TYPE));
/* Set up current_class_type, and enter the scope of the class, if
appropriate. */
cp_cv_quals quals = type_memfn_quals (stype);
if (quals != TYPE_UNQUALIFIED)
- {
- if (quals == TYPE_QUAL_CONST && DECL_DECLARED_CONSTEXPR_P (decl))
- /* The const was implicit, don't complain. */;
- else
- error ("static member function %q#D declared with type qualifiers",
- decl);
- stype = apply_memfn_quals (stype, TYPE_UNQUALIFIED);
- }
+ stype = apply_memfn_quals (stype, TYPE_UNQUALIFIED);
+
TREE_TYPE (decl) = stype;
if (DECL_ARGUMENTS (decl))