On Thu, 28 Aug 2025, [email protected] wrote:

> @@ -3373,6 +3406,56 @@ pushdecl (tree x)
>               TREE_TYPE (b_use->decl) = b_use->u.type;
>           }
>       }
> +
> +      /* Check if x is part of a FMV set with b_use.  */
> +      if (b_use && TREE_CODE (b_use->decl) == FUNCTION_DECL
> +       && TREE_CODE (x) == FUNCTION_DECL && DECL_FILE_SCOPE_P (b_use->decl)
> +       && DECL_FILE_SCOPE_P (x)
> +       && disjoint_version_decls (x, b_use->decl)
> +       && comptypes (vistype, type) != 0)
> +     {
> +       if (current_scope->depth != b->depth)
> +         error ("FMV versions must all be declared at the same scope level");

Is this error actually possible?  If it is, then (a) there should be tests 
for it in patch 12, and (b) my next question would be whether it's 
possible without also getting "versioned declarations are only allowed at 
file scope".  But I think this is in a context of "if (b && B_IN_SCOPE (b, 
scope))" (where scope was initialized to current_scope) and that error may 
not be possible at all (in which case it could be replaced by an assertion 
if you wish to keep such a check).

> @@ -5770,6 +5859,17 @@ start_decl (struct c_declarator *declarator, struct 
> c_declspecs *declspecs,
>        && VAR_OR_FUNCTION_DECL_P (decl))
>        objc_check_global_decl (decl);
>  
> +  /* To enable versions to be created across TU's we mark and mangle all
> +     non-default versioned functions.  */
> +  if (TREE_CODE (decl) == FUNCTION_DECL
> +      && !TARGET_HAS_FMV_TARGET_ATTRIBUTE
> +      && get_target_version (decl).is_valid ())
> +    {
> +      maybe_mark_function_versioned (decl);
> +      if (current_scope != file_scope)
> +     error ("versioned declarations are only allowed at file scope");
> +    }

I'd expect tests for this error as well.  As far as I can see, you only 
have a test in patch 12 for the different error about versioned 
*definitions* not at file scope (i.e. versioned nested functions).

-- 
Joseph S. Myers
[email protected]

Reply via email to