diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index fd9249c62b3..218a7e06f68 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -17844,7 +17844,18 @@ aarch64_process_target_attr (tree args) num_attrs++; if (!aarch64_process_one_target_attr (token)) { - error ("pragma or attribute % 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 % is not valid", token); return false; } diff --git a/gcc/testsuite/gcc.target/aarch64/pr102376.c b/gcc/testsuite/gcc.target/aarch64/pr102376.c new file mode 100644 index 00000000000..fc830ad4742 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr102376.c @@ -0,0 +1,3 @@ +/* { dg-do compile } */ + +void calculate(void) __attribute__ ((__target__ ("sve"))); /* { dg-error "arch extension 'sve' should be prefixed by '\\+'" } */