aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/analyzer/attr-const-3.c
blob: 11238a77a658f714a81576e68eb718b642c6d92d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/* Verify that we handle unknown values passed to  __attribute__ ((const))
   (by imposing a complexity limit).  */

/* { dg-additional-options "--param analyzer-max-svalue-depth=4 -Wno-analyzer-symbol-too-complex" } */

#include "analyzer-decls.h"

extern int const_fn_1 (int) __attribute__ ((const));

void test_const_fn_1 (int x, int y)
{
  int x_1 = const_fn_1 (x);
  int x_2 = const_fn_1 (x);
  int y_1 = const_fn_1 (y);
  int y_2 = const_fn_1 (y);
  __analyzer_eval (x_1 == x_2); /* { dg-warning "UNKNOWN" } */
  __analyzer_eval (y_1 == y_2); /* { dg-warning "UNKNOWN" } */
  __analyzer_eval (x_1 == y_1); /* { dg-warning "UNKNOWN" } */
}

void test_2 (int x)
{
  int once = const_fn_1 (x);
  int again = const_fn_1 (once);
  __analyzer_eval (once == again); /* { dg-warning "UNKNOWN" } */  
}