-
Notifications
You must be signed in to change notification settings - Fork 4
/
D_04_08_2.c
executable file
·62 lines (51 loc) · 1.11 KB
/
D_04_08_2.c
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* Release: 2016-01-01
*
* Example from MISRA C:2012 ( THIS IS NOT A TEST SUITE )
*
* Copyright HORIBA MIRA Limited.
*
* See file READ_ME.txt for full copyright, license and release instructions.
*/
/*
* D.4.8
*
* If a pointer to a structure or union is never dereferenced within a
* translation unit, then the implementation of the object should be hidden
*/
#include "D_04_08.h"
struct OpaqueType
{
/* Object implementation */
int32_t a;
int32_t b;
};
static struct OpaqueType global_obj = { 0 };
pOpaqueType GetObject( void )
{
return &global_obj;
}
void UseObject( const pOpaqueType p )
{
if ( p != NULL )
{
p->b += p->a;
use_int32 ( p->b );
}
use_int32 ( global_obj.a + global_obj.b );
}
static struct Not_OpaqueType global_obj2 = { 0 };
pNot_OpaqueType GetObject_notop( void )
{
return &global_obj2;
}
void UseObject_notop( const pNot_OpaqueType p )
{
if ( p != NULL )
{
p->d += p->c;
use_int32 ( p->d );
}
use_int32 ( global_obj2.c + global_obj2.d );
}
/* end of D_04_08_2.c */