return loc;
}
+/* Returns the smallest among the latter and locations[ds_type_spec]. */
+
+static location_t
+smallest_type_location (int type_quals, const location_t* locations)
+{
+ location_t loc = smallest_type_quals_location (type_quals, locations);
+ return min_location (loc, locations[ds_type_spec]);
+}
+
/* Check that it's OK to declare a function with the indicated TYPE
and TYPE_QUALS. SFK indicates the kind of special function (if any)
that this function is. OPTYPE is the type given in a conversion
{
case sfk_constructor:
if (type)
- error ("return type specification for constructor invalid");
+ error_at (smallest_type_location (type_quals, locations),
+ "return type specification for constructor invalid");
else if (type_quals != TYPE_UNQUALIFIED)
error_at (smallest_type_quals_location (type_quals, locations),
"qualifiers are not allowed on constructor declaration");
case sfk_destructor:
if (type)
- error ("return type specification for destructor invalid");
+ error_at (smallest_type_location (type_quals, locations),
+ "return type specification for destructor invalid");
else if (type_quals != TYPE_UNQUALIFIED)
error_at (smallest_type_quals_location (type_quals, locations),
"qualifiers are not allowed on destructor declaration");
case sfk_conversion:
if (type)
- error ("return type specified for %<operator %T%>", optype);
+ error_at (smallest_type_location (type_quals, locations),
+ "return type specified for %<operator %T%>", optype);
else if (type_quals != TYPE_UNQUALIFIED)
error_at (smallest_type_quals_location (type_quals, locations),
"qualifiers are not allowed on declaration of "
case sfk_deduction_guide:
if (type)
- error ("return type specified for deduction guide");
+ error_at (smallest_type_location (type_quals, locations),
+ "return type specified for deduction guide");
else if (type_quals != TYPE_UNQUALIFIED)
error_at (smallest_type_quals_location (type_quals, locations),
"qualifiers are not allowed on declaration of "
if (initialized > 1)
funcdef_flag = true;
- location_t typespec_loc = smallest_type_quals_location (type_quals,
- declspecs->locations);
- typespec_loc = min_location (typespec_loc,
- declspecs->locations[ds_type_spec]);
+ location_t typespec_loc = smallest_type_location (type_quals,
+ declspecs->locations);
if (typespec_loc == UNKNOWN_LOCATION)
typespec_loc = input_location;
{
if (friendp)
{
- permerror (input_location, "member functions are implicitly "
- "friends of their class");
+ permerror (declspecs->locations[ds_friend],
+ "member functions are implicitly "
+ "friends of their class");
friendp = 0;
}
else
--- /dev/null
+struct S1
+{
+ int S1(); // { dg-error "3:return type" }
+ int ~S1(); // { dg-error "3:return type" }
+ int operator int(); // { dg-error "3:return type" }
+};
+
+struct S2
+{
+ const int S2(); // { dg-error "3:return type" }
+ const int ~S2(); // { dg-error "3:return type" }
+ const int operator int(); // { dg-error "3:return type" }
+};
+
+struct S3
+{
+ volatile int S3(); // { dg-error "3:return type" }
+ volatile int ~S3(); // { dg-error "3:return type" }
+ volatile int operator int(); // { dg-error "3:return type" }
+};
+
+struct S4
+{
+ const volatile int S4(); // { dg-error "3:return type" }
+ const volatile int ~S4(); // { dg-error "3:return type" }
+ const volatile int operator int(); // { dg-error "3:return type" }
+};