@@ -575,31 +575,16 @@ Target::supportsLinkerDirective (void) const
}
/* Decides whether an `in' parameter of the specified POD type PARAM_TYPE is to
- be passed by reference or by valie. This is used only when compiling with
+ be passed by reference or by value. This is used only when compiling with
`-fpreview=in' enabled. */
bool
Target::preferPassByRef (Type *param_type)
{
- if (param_type->size () == SIZE_INVALID)
+ /* See note in Target::isReturnOnStack. */
+ Type *tb = param_type->toBasetype ();
+ if (tb->size () == SIZE_INVALID)
return false;
- tree type = build_ctype (param_type);
-
- /* Prefer a `ref' if the type is an aggregate, and its size is greater than
- its alignment. */
- if (AGGREGATE_TYPE_P (type)
- && (!valid_constant_size_p (TYPE_SIZE_UNIT (type))
- || compare_tree_int (TYPE_SIZE_UNIT (type), TYPE_ALIGN (type)) > 0))
- return true;
-
- /* If the back-end is always going to pass this by invisible reference. */
- if (pass_by_reference (NULL, function_arg_info (type, true)))
- return true;
-
- /* If returning the parameter means the caller will do RVO. */
- if (targetm.calls.return_in_memory (type, NULL_TREE))
- return true;
-
- return false;
+ return (tb->ty == TY::Tstruct || tb->ty == TY::Tsarray);
}
new file mode 100644
@@ -0,0 +1,13 @@
+// { dg-do compile }
+// { dg-additional-options "-fpreview=in" }
+struct S112285
+{
+}
+
+class C112285
+{
+ S112285 s;
+ void f112285(in C112285)
+ {
+ }
+}
new file mode 100644
@@ -0,0 +1,15 @@
+// { dg-do compile }
+// { dg-additional-options "-fpreview=in" }
+struct S112290a
+{
+ S112290b* p;
+ bool opEquals(in S112290a)
+ {
+ return p == p;
+ }
+}
+
+struct S112290b
+{
+ string s;
+}