preprocessor: Fix negative shift with bad ids.

Fix this by producing an error on undefined or negative shifts.

BUG=629518

Change-Id: Idfca5ed3fc8e557f6178408f3426a5ef2ce7cf14
Reviewed-on: https://chromium-review.googlesource.com/362020
Reviewed-by: Antoine Labour <piman@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/compiler/preprocessor/ExpressionParser.cpp b/src/compiler/preprocessor/ExpressionParser.cpp
index 193b150..b765c64 100644
--- a/src/compiler/preprocessor/ExpressionParser.cpp
+++ b/src/compiler/preprocessor/ExpressionParser.cpp
@@ -498,12 +498,9 @@
 
 #if YYDEBUG
   /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
-static const yytype_uint16 yyrline[] =
-{
-       0,   110,   110,   117,   118,   129,   129,   150,   150,   171,
-     174,   177,   180,   183,   186,   189,   192,   195,   198,   201,
-     204,   207,   210,   230,   250,   253,   256,   259,   262,   265
-};
+static const yytype_uint16 yyrline[] = {0,   110, 110, 117, 118, 129, 129, 150, 150, 171,
+                                        174, 177, 180, 183, 186, 189, 192, 195, 198, 218,
+                                        238, 241, 244, 264, 284, 287, 290, 293, 296, 299};
 #endif
 
 #if YYDEBUG || YYERROR_VERBOSE || 0
@@ -1495,7 +1492,23 @@
   case 18:
 
     {
-        (yyval) = (yyvsp[-2]) >> (yyvsp[0]);
+        if ((yyvsp[0]) < 0)
+        {
+            if (!context->isIgnoringErrors())
+            {
+                std::ostringstream stream;
+                stream << (yyvsp[-2]) << " >> " << (yyvsp[0]);
+                std::string text = stream.str();
+                context->diagnostics->report(pp::Diagnostics::PP_UNDEFINED_SHIFT,
+                                             context->token->location, text.c_str());
+                *(context->valid) = false;
+            }
+            (yyval) = static_cast<YYSTYPE>(0);
+        }
+        else
+        {
+            (yyval) = (yyvsp[-2]) >> (yyvsp[0]);
+        }
     }
 
     break;
@@ -1503,7 +1516,23 @@
   case 19:
 
     {
-        (yyval) = (yyvsp[-2]) << (yyvsp[0]);
+        if ((yyvsp[0]) < 0)
+        {
+            if (!context->isIgnoringErrors())
+            {
+                std::ostringstream stream;
+                stream << (yyvsp[-2]) << " << " << (yyvsp[0]);
+                std::string text = stream.str();
+                context->diagnostics->report(pp::Diagnostics::PP_UNDEFINED_SHIFT,
+                                             context->token->location, text.c_str());
+                *(context->valid) = false;
+            }
+            (yyval) = static_cast<YYSTYPE>(0);
+        }
+        else
+        {
+            (yyval) = (yyvsp[-2]) << (yyvsp[0]);
+        }
     }
 
     break;