parse_arch tested "if (*m_loc)", dereferencing the location_t pointer,
while every other diagnostic site guards with "if (m_loc)". Since
m_loc can be NULL, test the pointer instead of dereferencing it.
gcc/ChangeLog:
* config/riscv/riscv-target-attr.cc
(riscv_target_attr_parser::parse_arch): Check m_loc instead of
*m_loc before emitting the diagnostic.
Signed-off-by: Jim Lin <[email protected]>
---
gcc/config/riscv/riscv-target-attr.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/config/riscv/riscv-target-attr.cc
b/gcc/config/riscv/riscv-target-attr.cc
index 5f265d0b242..652e8d4a550 100644
--- a/gcc/config/riscv/riscv-target-attr.cc
+++ b/gcc/config/riscv/riscv-target-attr.cc
@@ -148,7 +148,7 @@ riscv_target_attr_parser::parse_arch (const char *str)
{
if (token[0] != '+')
{
- if (*m_loc)
+ if (m_loc)
error_at (*m_loc, "unexpected arch for %<target()%> "
"attribute: must start with + or rv");
goto fail;
--
2.52.0