~ubuntu-branches/ubuntu/trusty/coccinelle/trusty

« back to all changes in this revision

Viewing changes to demos/external_ana.c

  • Committer: Package Import Robot
  • Author(s): Євгеній Мещеряков
  • Date: 2012-08-19 20:40:52 UTC
  • mfrom: (7.2.8 experimental)
  • Revision ID: package-import@ubuntu.com-20120819204052-8cujknwy6cn8a6h6
Tags: 1.0.0~rc15.deb-1
* New upstream RC 
  - Do not build-depend on libsexplib-camlp4-dev and libextlib-ocaml-dev
    anymore

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* An indirect way to compute zero, for an external analysis to find out. */
 
2
 
 
3
#include <stdio.h>
 
4
 
 
5
int sum(const int x, const int y) {
 
6
  return x + y;
 
7
}
 
8
 
 
9
int add4(const int z) {
 
10
  return sum(z, 1) + 3;
 
11
}
 
12
 
 
13
int main() {
 
14
  int x = add4(1) - 5;   /* should be zero */
 
15
 
 
16
  if (x) {
 
17
    printf("Dead code.");
 
18
  }
 
19
 
 
20
  int y = getchar() < 0; /* can happen */
 
21
  if (y) {
 
22
    printf("Not dead code.");
 
23
  }
 
24
 
 
25
  return 0;
 
26
}