On 18 December 2016 at 18:02, Jakub Jelinek <ja...@redhat.com> wrote:
> On Sun, Dec 18, 2016 at 05:41:23PM +0530, Prathamesh Kulkarni wrote:
>> --- a/gcc/c/gimple-parser.c
>> +++ b/gcc/c/gimple-parser.c
>> @@ -1046,6 +1046,17 @@ c_parser_gimple_pass_list (c_parser *parser)
>>    if (! c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>"))
>>      return NULL;
>>
>> +  if (pass)
>> +    {
>> +      char *full_passname = (char *) xmalloc (strlen ("tree-") + strlen 
>> (pass) + 1);
>> +      strcpy (full_passname, "tree-");
>> +      strcat (full_passname, pass);
>
> Use
>       char *full_passname = concat ("tree-", pass, NULL);
> instead?
Thanks! Modified the patch to use concat().

Regards,
Prathamesh
>
>         Jakub
2016-12-18  Prathamesh Kulkarni  <prathamesh.kulka...@linaro.org>

c/
        * gimple-parser.c (c_parser_gimple_pass_list): Reject invalid pass
        name.

testsuite/
        * gcc.dg/gimplefe-19.c: New test-case.

diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c
index ddecaec..68d2d74 100644
--- a/gcc/c/gimple-parser.c
+++ b/gcc/c/gimple-parser.c
@@ -1046,6 +1046,15 @@ c_parser_gimple_pass_list (c_parser *parser)
   if (! c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>"))
     return NULL;
 
+  if (pass)
+    {
+      char *full_passname = concat ("tree-", pass, NULL);
+      opt_pass *p = g->get_passes ()->get_pass_by_name (full_passname);
+      if (!p || p->type != GIMPLE_PASS)
+       error_at (c_parser_peek_token (parser)->location,
+                 "%s is not a valid GIMPLE pass\n", pass);
+      free (full_passname);
+    }
   return pass;
 }
 
diff --git a/gcc/testsuite/gcc.dg/gimplefe-19.c 
b/gcc/testsuite/gcc.dg/gimplefe-19.c
new file mode 100644
index 0000000..bb5be33
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gimplefe-19.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fgimple" } */
+
+void __GIMPLE (startwith ("combine")) foo ()  /* { dg-error "not a valid 
GIMPLE pass" } */
+{
+  return;
+}

Reply via email to