gimple-parser.c (c_parser_gimple_postfix_expression): Check return value of c_parser_...
authorPrathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
Sun, 19 Feb 2017 09:14:38 +0000 (09:14 +0000)
committerPrathamesh Kulkarni <prathamesh3492@gcc.gnu.org>
Sun, 19 Feb 2017 09:14:38 +0000 (09:14 +0000)
2017-02-19  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>

* gimple-parser.c (c_parser_gimple_postfix_expression): Check return
value of c_parser_parse_ssa_name against error_mark_node and emit
error if ssa name is anonymous and written as default definition.

From-SVN: r245571

gcc/c/ChangeLog
gcc/c/gimple-parser.c

index 0626973d47a2d2c7a2b8dae4e0f9693c3a9885b1..5cff63a24d1b5c791b62673c21ab819dc382ac7f 100644 (file)
@@ -1,3 +1,9 @@
+2017-02-19  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>
+
+       * gimple-parser.c (c_parser_gimple_postfix_expression): Check return
+       value of c_parser_parse_ssa_name against error_mark_node and emit
+       error if ssa name is anonymous and written as default definition.
+
 2017-02-19  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>
 
        * gimple-parser.c (c_parser_gimple_postfix_expression): Handle
index 31d0a08d3035c1eba0d21fabf691d1deabb520b4..cb2b6af0cb12f791b2da1f90652240fbdf3ec444 100644 (file)
@@ -886,6 +886,8 @@ c_parser_gimple_postfix_expression (c_parser *parser)
              c_parser_consume_token (parser);
              expr.value = c_parser_parse_ssa_name (parser, id, NULL_TREE,
                                                    version, ver_offset);
+             if (expr.value == error_mark_node)
+               return expr;
              set_c_expr_source_range (&expr, tok_range);
              /* For default definition SSA names.  */
              if (c_parser_next_token_is (parser, CPP_OPEN_PAREN)
@@ -900,6 +902,13 @@ c_parser_gimple_postfix_expression (c_parser *parser)
                  c_parser_consume_token (parser);
                  if (! SSA_NAME_IS_DEFAULT_DEF (expr.value))
                    {
+                     if (!SSA_NAME_VAR (expr.value))
+                       {
+                         error_at (loc, "anonymous SSA name cannot have"
+                                   " default definition");
+                         expr.value = error_mark_node;
+                         return expr;
+                       }
                      set_ssa_default_def (cfun, SSA_NAME_VAR (expr.value),
                                           expr.value);
                      SSA_NAME_DEF_STMT (expr.value) = gimple_build_nop ();