[aarch64] PR102376 - Emit better diagnostic for arch extensions in target attr.

gcc/ChangeLog:
	PR target/102376
	* config/aarch64/aarch64.c (aarch64_process_target_attr): Check if
	token is arch extension without leading '+' and emit appropriate
	diagnostic for the same.

gcc/testsuite/ChangeLog:
	PR target/102376
	* gcc.target/aarch64/pr102376.c: New test.
This commit is contained in:
Prathamesh Kulkarni 2021-11-11 14:37:22 +05:30
parent 48d7327f2a
commit 145be5efaf
2 changed files with 15 additions and 1 deletions

View File

@ -17977,7 +17977,18 @@ aarch64_process_target_attr (tree args)
num_attrs++;
if (!aarch64_process_one_target_attr (token))
{
error ("pragma or attribute %<target(\"%s\")%> is not valid", token);
/* Check if token is possibly an arch extension without
leading '+'. */
uint64_t isa_temp = 0;
auto with_plus = std::string ("+") + token;
enum aarch64_parse_opt_result ext_res
= aarch64_parse_extension (with_plus.c_str (), &isa_temp, nullptr);
if (ext_res == AARCH64_PARSE_OK)
error ("arch extension %<%s%> should be prefixed by %<+%>",
token);
else
error ("pragma or attribute %<target(\"%s\")%> is not valid", token);
return false;
}

View File

@ -0,0 +1,3 @@
/* { dg-do compile } */
void calculate(void) __attribute__ ((__target__ ("sve"))); /* { dg-error "arch extension 'sve' should be prefixed by '\\+'" } */