]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[aarch64] PR102376 - Emit better diagnostic for arch extensions in target attr.
authorPrathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
Thu, 11 Nov 2021 09:07:22 +0000 (14:37 +0530)
committerPrathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
Thu, 11 Nov 2021 09:10:21 +0000 (14:40 +0530)
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.

gcc/config/aarch64/aarch64.c
gcc/testsuite/gcc.target/aarch64/pr102376.c [new file with mode: 0644]

index cd4332d04e548aede63cb4ab269bc4ffeb87f2e6..a8f53b85d9259784ed53c5c922f04bf15a01edbb 100644 (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;
        }
 
diff --git a/gcc/testsuite/gcc.target/aarch64/pr102376.c b/gcc/testsuite/gcc.target/aarch64/pr102376.c
new file mode 100644 (file)
index 0000000..fc830ad
--- /dev/null
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+
+void calculate(void) __attribute__ ((__target__ ("sve"))); /* { dg-error "arch extension 'sve' should be prefixed by '\\+'" } */