aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/analyzer/first-field-1.c
blob: c11707d9aa62b1d67c592a3962b39ceb8718f18d (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
#include "../../gcc.dg/analyzer/analyzer-decls.h"

typedef struct base_obj
{
  int m_first;
  int m_second;
} base_obj;

typedef struct sub_obj
{
  base_obj base;
} sub_obj;

void test (sub_obj *sub)
{
  sub->base.m_first = 1;
  sub->base.m_second = 2;
  __analyzer_eval (sub->base.m_first == 1); /* { dg-warning "TRUE" } */
  __analyzer_eval (sub->base.m_second == 2); /* { dg-warning "TRUE" } */

  base_obj *base = (struct base_obj *)sub;
  __analyzer_eval (base->m_first == 1); /* { dg-warning "TRUE" } */
  __analyzer_eval (base->m_second == 2); /* { dg-warning "TRUE" } */
}