浏览代码

gcc: Improve error handling for the `register' pragma.

* gcc-plugin/src/starpu.c (handle_pragma_register): Exit in error cases
  where there's nothing we can do.  This avoids premature exits ("confused
  by earlier errors, bailing out").

* gcc-plugin/tests/register-errors.c (main): Add case where COUNT is a
  identifier that does not correspond to a variable.
Ludovic Courtès 14 年之前
父节点
当前提交
a1eb86a437
共有 2 个文件被更改,包括 14 次插入4 次删除
  1. 12 3
      gcc-plugin/src/starpu.c
  2. 2 1
      gcc-plugin/tests/register-errors.c

+ 12 - 3
gcc-plugin/src/starpu.c

@@ -381,7 +381,10 @@ handle_pragma_register (struct cpp_reader *reader)
       /* End of line reached: don't consume TOKEN and check whether the array
 	 size was determined.  */
       if (count == NULL_TREE)
-	error_at (loc, "cannot determine size of array %qE", var_name);
+	{
+	  error_at (loc, "cannot determine size of array %qE", var_name);
+	  return;
+	}
     }
   else
     {
@@ -393,9 +396,15 @@ handle_pragma_register (struct cpp_reader *reader)
 	{
 	  count_arg = lookup_name (token);
 	  if (count_arg == NULL_TREE)
-	    error_at (loc, "unbound variable %qE", token);
+	    {
+	      error_at (loc, "unbound variable %qE", token);
+	      return;
+	    }
 	  else if (!INTEGRAL_TYPE_P (TREE_TYPE (count_arg)))
-	    error_at (loc, "integer expected");
+	    {
+	      error_at (loc, "integer expected");
+	      return;
+	    }
 	}
       else if (TREE_CODE (token) != INTEGER_CST)
 	error_at (loc, "integer expected");

+ 2 - 1
gcc-plugin/tests/register-errors.c

@@ -33,7 +33,8 @@ main (int argc, char *argv[])
   size_t x_size __attribute__ ((unused)) = sizeof x / sizeof x[0];
 #pragma starpu register x x_size /* (note "can be omitted") *//* (error "known at compile-time") */
 
-#pragma starpu register does_not_exit 123 /* (error "unbound variable") */
+#pragma starpu register does_not_exit 123  /* (error "unbound variable") */
+#pragma starpu register argv does_not_exit /* (error "unbound variable") */
 
 #pragma starpu register argv /* (error "cannot determine size") */