callandmessage_example.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //C
  2. void test() {
  3. void (*foo)(void);
  4. foo = 0;
  5. foo(); // warn: function pointer is null
  6. }
  7. // C++
  8. class C {
  9. public:
  10. void f();
  11. };
  12. void test() {
  13. C *pc;
  14. pc->f(); // warn: object pointer is uninitialized
  15. }
  16. // C++
  17. class C {
  18. public:
  19. void f();
  20. };
  21. void test() {
  22. C *pc = 0;
  23. pc->f(); // warn: object pointer is null
  24. }
  25. // Objective-C
  26. @interface MyClass : NSObject
  27. @property (readwrite,assign) id x;
  28. - (long double)longDoubleM;
  29. @end
  30. void test() {
  31. MyClass *obj1;
  32. long double ld1 = [obj1 longDoubleM];
  33. // warn: receiver is uninitialized
  34. }
  35. // Objective-C
  36. @interface MyClass : NSObject
  37. @property (readwrite,assign) id x;
  38. - (long double)longDoubleM;
  39. @end
  40. void test() {
  41. MyClass *obj1;
  42. id i = obj1.x; // warn: uninitialized object pointer
  43. }
  44. // Objective-C
  45. @interface Subscriptable : NSObject
  46. - (id)objectAtIndexedSubscript:(unsigned int)index;
  47. @end
  48. @interface MyClass : Subscriptable
  49. @property (readwrite,assign) id x;
  50. - (long double)longDoubleM;
  51. @end
  52. void test() {
  53. MyClass *obj1;
  54. id i = obj1[0]; // warn: uninitialized object pointer
  55. }