diff mbox series

[4/6] RISC-V: Fix comment/naming in attribute parsing code

Message ID 20240709124757.1405749-5-christoph.muellner@vrull.eu
State New
Headers show
Series RISC-V: Rewrite target arch attribute handling | expand

Commit Message

Christoph Müllner July 9, 2024, 12:47 p.m. UTC
Function target attributes have to be separated by semi-colons.
Let's fix the comment and variable naming to better explain what
the code does.

gcc/ChangeLog:

	* config/riscv/riscv-target-attr.cc (riscv_process_target_attr):
	Fix comments and variable names.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
---
 gcc/config/riscv/riscv-target-attr.cc | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Kito Cheng July 9, 2024, 1:02 p.m. UTC | #1
LGTM, that must be something I didn't update during...reference code from ARM :P


On Tue, Jul 9, 2024 at 8:48 PM Christoph Müllner
<christoph.muellner@vrull.eu> wrote:
>
> Function target attributes have to be separated by semi-colons.
> Let's fix the comment and variable naming to better explain what
> the code does.
>
> gcc/ChangeLog:
>
>         * config/riscv/riscv-target-attr.cc (riscv_process_target_attr):
>         Fix comments and variable names.
>
> Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
> ---
>  gcc/config/riscv/riscv-target-attr.cc | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/gcc/config/riscv/riscv-target-attr.cc b/gcc/config/riscv/riscv-target-attr.cc
> index e59cc53f23c6..3d7753f64574 100644
> --- a/gcc/config/riscv/riscv-target-attr.cc
> +++ b/gcc/config/riscv/riscv-target-attr.cc
> @@ -335,11 +335,11 @@ riscv_process_target_attr (tree fndecl, tree args, location_t loc,
>    char *str_to_check = (char *) alloca (len + 1);
>    strcpy (str_to_check, TREE_STRING_POINTER (args));
>
> -  /* Used to catch empty spaces between commas i.e.
> +  /* Used to catch empty spaces between semi-colons i.e.
>       attribute ((target ("attr1;;attr2"))).  */
> -  unsigned int num_commas = num_occurences_in_str (';', str_to_check);
> +  unsigned int num_semicolons = num_occurences_in_str (';', str_to_check);
>
> -  /* Handle multiple target attributes separated by ','.  */
> +  /* Handle multiple target attributes separated by ';'.  */
>    char *token = strtok_r (str_to_check, ";", &str_to_check);
>
>    riscv_target_attr_parser attr_parser (loc);
> @@ -351,7 +351,7 @@ riscv_process_target_attr (tree fndecl, tree args, location_t loc,
>        token = strtok_r (NULL, ";", &str_to_check);
>      }
>
> -  if (num_attrs != num_commas + 1)
> +  if (num_attrs != num_semicolons + 1)
>      {
>        error_at (loc, "malformed %<target(\"%s\")%> attribute",
>                 TREE_STRING_POINTER (args));
> --
> 2.45.2
>
diff mbox series

Patch

diff --git a/gcc/config/riscv/riscv-target-attr.cc b/gcc/config/riscv/riscv-target-attr.cc
index e59cc53f23c6..3d7753f64574 100644
--- a/gcc/config/riscv/riscv-target-attr.cc
+++ b/gcc/config/riscv/riscv-target-attr.cc
@@ -335,11 +335,11 @@  riscv_process_target_attr (tree fndecl, tree args, location_t loc,
   char *str_to_check = (char *) alloca (len + 1);
   strcpy (str_to_check, TREE_STRING_POINTER (args));
 
-  /* Used to catch empty spaces between commas i.e.
+  /* Used to catch empty spaces between semi-colons i.e.
      attribute ((target ("attr1;;attr2"))).  */
-  unsigned int num_commas = num_occurences_in_str (';', str_to_check);
+  unsigned int num_semicolons = num_occurences_in_str (';', str_to_check);
 
-  /* Handle multiple target attributes separated by ','.  */
+  /* Handle multiple target attributes separated by ';'.  */
   char *token = strtok_r (str_to_check, ";", &str_to_check);
 
   riscv_target_attr_parser attr_parser (loc);
@@ -351,7 +351,7 @@  riscv_process_target_attr (tree fndecl, tree args, location_t loc,
       token = strtok_r (NULL, ";", &str_to_check);
     }
 
-  if (num_attrs != num_commas + 1)
+  if (num_attrs != num_semicolons + 1)
     {
       error_at (loc, "malformed %<target(\"%s\")%> attribute",
 		TREE_STRING_POINTER (args));