Modify the two situations:
1. __attribute__ ((target ("arch")))
ICE will be reported before modification, and there will be an error
prompt after modification.
2. __attribute__ ((target ("arch=12345")))
Fixed the issue where the attribute string was not printed completely
in the previous error message.
gcc/ChangeLog:
* config/loongarch/loongarch-target-attr.cc
(loongarch_process_one_target_attr): Fix ICE.
gcc/testsuite/ChangeLog:
* gcc.target/loongarch/attr-check-error-message.c: Add tests.
/* Use the option setting machinery to set an option to an enum. */
case loongarch_attr_enum:
{
- gcc_assert (arg);
+ if (!arg)
+ {
+ error_at (loc, "the value of pragma or attribute "
+ "%<target(\"%s\")%> not be empty", str_to_check);
+ return false;
+ }
+
bool valid;
int value;
struct cl_decoded_option decoded;
were malformed we will have returned false already. */
if (!found)
error_at (loc, "attribute %<target%> argument %qs is unknown",
- str_to_check);
+ arg_str);
return found;
}
__attribute__ ((target ("lsx,"))) void
test7 (void) /* { dg-error "malformed \\\'target\\\(\\\"lsx,\\\"\\\)\\\' pragma or attribute" } */
{}
+
+__attribute__ ((target ("arch"))) void
+test8 (void) /* { dg-error "the value of pragma or attribute \\\'target\\\(\\\"arch\\\"\\\)\\\' not be empty" } */
+{}
+
+__attribute__ ((target ("lsx;priority=1"))) void
+test9 (void) /* { dg-error "attribute \\\'target\\\' argument \\\'lsx;priority=1\\\' is unknown" } */
+{}