context-stmt.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. static void foo(int x)
  2. {
  3. __context__(0); // OK
  4. __context__(x, 0); // OK
  5. __context__ (x, 1); // OK
  6. __context__(x); // KO: no const expr
  7. __context__(1,x); // KO: no const expr
  8. __context__; // KO: no expression at all
  9. __context__(; // KO: no expression at all
  10. __context__ 0; // KO: need parens
  11. __context__ x, 0; // KO: need parens
  12. __context__(x, 0; // KO: unmatched parens
  13. __context__ x, 0); // KO: unmatched parens
  14. __context__(0; // KO: unmatched parens
  15. __context__ 0); // KO: unmatched parens
  16. __context__(); // KO: no expression at all
  17. __context__(,0); // KO: no expression at all
  18. __context__(x,); // KO: no expression at all
  19. __context__(,); // KO: no expression at all
  20. }
  21. /*
  22. * check-name: context-stmt
  23. * check-command: sparse -Wno-context $file
  24. *
  25. * check-error-start
  26. context-stmt.c:10:20: error: Expected ( after __context__ statement
  27. context-stmt.c:10:20: error: got ;
  28. context-stmt.c:11:21: error: expression expected after '('
  29. context-stmt.c:11:21: error: got ;
  30. context-stmt.c:11:21: error: Expected ) at end of __context__ statement
  31. context-stmt.c:11:21: error: got ;
  32. context-stmt.c:13:21: error: Expected ( after __context__ statement
  33. context-stmt.c:13:21: error: got 0
  34. context-stmt.c:14:21: error: Expected ( after __context__ statement
  35. context-stmt.c:14:21: error: got x
  36. context-stmt.c:15:25: error: Expected ) at end of __context__ statement
  37. context-stmt.c:15:25: error: got ;
  38. context-stmt.c:16:21: error: Expected ( after __context__ statement
  39. context-stmt.c:16:21: error: got x
  40. context-stmt.c:17:22: error: Expected ) at end of __context__ statement
  41. context-stmt.c:17:22: error: got ;
  42. context-stmt.c:18:21: error: Expected ( after __context__ statement
  43. context-stmt.c:18:21: error: got 0
  44. context-stmt.c:20:21: error: expression expected after '('
  45. context-stmt.c:20:21: error: got )
  46. context-stmt.c:21:21: error: expression expected after '('
  47. context-stmt.c:21:21: error: got ,
  48. context-stmt.c:22:23: error: expression expected after ','
  49. context-stmt.c:22:23: error: got )
  50. context-stmt.c:23:21: error: expression expected after '('
  51. context-stmt.c:23:21: error: got ,
  52. context-stmt.c:23:22: error: expression expected after ','
  53. context-stmt.c:23:22: error: got )
  54. context-stmt.c:7:21: error: bad constant expression
  55. context-stmt.c:8:23: error: bad constant expression
  56. * check-error-end
  57. */