diff mbox

[match-and-simplify] report error for invalid operator-lists

Message ID CAAgBjMn0VgYL9HV+8xiqihO9nzN_Y0HB9KDjmbQ+P=vSdRJjCg@mail.gmail.com
State New
Headers show

Commit Message

Prathamesh Kulkarni May 18, 2015, 11:24 p.m. UTC
Hi,
genmatch segfaults on:
(define_operator_list op (plus))

The above syntax is invalid, and it segfaults on:
fatal_error (token, "operator list is empty");
because token is NULL.

The patch puts a check for CPP_CLOSE_PAREN after parsing id-list.
OK for trunk after bootstrap+testing completes ?

Thanks,
Prathamesh

2015-05-19  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>

	* genmatch.c (parser::parse_operator_list): Check for CPP_CLOSE_PAREN after end of id-list.

Comments

Richard Biener May 19, 2015, 9:01 a.m. UTC | #1
On Tue, 19 May 2015, Prathamesh Kulkarni wrote:

> Hi,
> genmatch segfaults on:
> (define_operator_list op (plus))
> 
> The above syntax is invalid, and it segfaults on:
> fatal_error (token, "operator list is empty");
> because token is NULL.
> 
> The patch puts a check for CPP_CLOSE_PAREN after parsing id-list.
> OK for trunk after bootstrap+testing completes ?

Ok.

Thanks,
Richard.
diff mbox

Patch

Index: genmatch.c
===================================================================
--- genmatch.c	(revision 223294)
+++ genmatch.c	(working copy)
@@ -3427,6 +3427,11 @@ 
 	op->substitutes.safe_push (idb);
     }
 
+  // Check that there is no junk after id-list
+  token = peek();
+  if (token->type != CPP_CLOSE_PAREN)
+    fatal_at (token, "expected identifier got %s", cpp_type2name (token->type, 0));
+
   if (op->substitutes.length () == 0)
     fatal_at (token, "operator-list cannot be empty");