Target attribute handling avoids processing empty strings
Target attribute parsing now checks for empty arguments before validating others, preventing unexpected behavior with attributes like `target("avx2", "")`.
This commit refactors the handling of the target attribute to check for empty string arguments before validating other arguments. Previously, empty strings would be dropped, but their associated options were still used, leading to incorrect code generation. Now, if an empty string is encountered, the attribute is dropped without processing other arguments, and the validation hook is only called for non-empty attributes. This simplifies attribute handling and prevents issues where invalid arguments were ignored while valid ones were still processed.
In Details
The handle_target_attribute function in GCC's attribute handling now prioritizes checking for empty string arguments in the target attribute before calling targetm.target_option.valid_attribute_p. This prevents a scenario where an empty string argument causes the attribute to be dropped, but its associated options (e.g., -mavx2 from target("avx2", "")) are still applied, leading to incorrect code generation and validation warnings. The change ensures that if an attribute is dropped due to an empty string, its other arguments are not validated, simplifying the error reporting.