home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lclint.zip / lclint-2_3h-os2-bin.zip / test / args.c < prev    next >
Text File  |  1997-09-03  |  1KB  |  80 lines

  1. # include <stdarg.h>
  2. # include "bool.h"
  3. int sumn (int x, ...)
  4. {
  5.   int y = 0;
  6.   void *yaba;
  7.   va_list args;
  8.  
  9.   va_start (args, (void *)x); /* okay (args counts as out param) */
  10.   while (x > 0)
  11.     {
  12.       x--;
  13.       y = va_arg (args, int); /* okay */
  14.       y = va_arg (args, char *); /* type error */
  15.       y = va_arg (yaba, int); /* error */
  16.     }
  17.   return y;
  18. }
  19.  
  20. int test (int x, char *s)
  21. {
  22.   x = sumn(); /* bad */
  23.   x = sumn(x); /* okay */
  24.   x = sumn(s); /* bad */
  25.   x = sumn(x, s); /* okay */
  26.  
  27.   x = test (x, s, x); /* bad */
  28.   return x;
  29. }
  30.  
  31. int missingargs (int x, int y)  /* this is okay */
  32. {
  33.   y = x;
  34.   return x;
  35. }
  36.  
  37. int severalargs (char c, int y, bool b) /* first arg: int, second char *, third extra */
  38. {
  39.   if (b) { c = 'a'; }
  40.   return y;
  41. }
  42.  
  43. int severalargs2 (int x)  /* bad */
  44. {
  45.   return x;
  46. }
  47.  
  48. int voidargs (char c) /* bad */
  49. {
  50.   c = 'a'; 
  51.   return 3;
  52. }
  53.  
  54. int any (...) /* ok */
  55. {
  56.   return 3;
  57. }
  58.  
  59. int many1 (int x, char c, float f) /* bad */
  60. {
  61.   x;
  62.   c;
  63.   f;
  64.   return x;
  65. }
  66.  
  67. int many2 (int x, char c, ...)
  68. {
  69.   c;
  70.   return x;
  71. }
  72.  
  73. int many3 (int x) /* bad */
  74. {
  75.   return x;
  76. }
  77.  
  78.  
  79.  
  80.