Hi Richard,
The attached patch attempts to reject invalid pass-name in startwith
and verified gimplefe tests pass with the patch (not sure if bootstrap
is required?)
Does it look OK ?

Thanks,
Prathamesh
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..ec1dbb3 100644
--- 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);
+      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