[gcc r17-2426] [PATCH] RISC-V: Fix NULL location pointer check in target attribute parser

Jeff Law via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:267d62e93e1be7ee62ab674090547a1585ceecf6

commit r17-2426-g267d62e93e1be7ee62ab674090547a1585ceecf6
Author: Jim Lin <[email protected]>
Date:   Wed Jul 15 13:58:47 2026 -0600

    [PATCH] RISC-V: Fix NULL location pointer check in target attribute parser
    
    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]>

Diff:
---
 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 5f265d0b242d..652e8d4a550d 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;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.