summaryrefslogtreecommitdiff
path: root/testsuites/validation/tc-basedefs.c
blob: f827b851584a5cfbdbf2cd3e58202e54896be58e (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
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
/* SPDX-License-Identifier: BSD-2-Clause */

/**
 * @file
 *
 * @ingroup RTEMSTestCaseRtemsBasedefsValBasedefs
 */

/*
 * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

/*
 * This file is part of the RTEMS quality process and was automatically
 * generated.  If you find something that needs to be fixed or
 * worded better please post a report or patch to an RTEMS mailing list
 * or raise a bug report:
 *
 * https://docs.rtems.org/branches/master/user/support/bugs.html
 *
 * For information on updating and regenerating please refer to:
 *
 * https://docs.rtems.org/branches/master/eng/req/howto.html
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <rtems.h>
#include <stdarg.h>
#include <stddef.h>

#include "tc-basedefs-pendant.h"

#include <rtems/test.h>

/**
 * @defgroup RTEMSTestCaseRtemsBasedefsValBasedefs \
 *   spec:/rtems/basedefs/val/basedefs
 *
 * @ingroup RTEMSTestSuiteTestsuitesValidation0
 *
 * @brief Tests the basedefs macros of the Classic API.
 *
 * This test case performs the following actions:
 *
 * - Use the RTEMS_ALIAS() macro.
 *
 *   - Check that ori_func() and alias_func() are the same function.
 *
 * - Use the RTEMS_ALIGN_DOWN() macro in various examples.
 *
 *   - Check that RTEMS_ALIGN_DOWN() calculates the expected result and is
 *     side-effect free.
 *
 * - Use the RTEMS_ALIGN_UP() macro in various examples.
 *
 *   - Check that RTEMS_ALIGN_UP() calculates the expected result and is
 *     side-effect free.
 *
 * - Use the RTEMS_ALIGNED() macro.
 *
 *   - Check that RTEMS_ALIGNED() correctly aligns a variable on the stack and
 *     a structure member.
 *
 * - Use a function declared with the RTEMS_ALLOC_ALIGN() macro.
 *
 *   - It cannot be checked that the RTEMS_ALLOC_ALIGN() macro has the desired
 *     effect. Yet, the check confirms that such a macro exists and that it can
 *     be used on such a memory function and that the argument counting starts
 *     at 1.
 *
 * - Use a function declared with the RTEMS_ALLOC_SIZE() macro.
 *
 *   - It cannot be checked that the RTEMS_ALLOC_SIZE() macro has the desired
 *     effect. Yet, the check confirms that such a macro exists and that it can
 *     be used on such a memory function and that the argument counting starts
 *     at 1.
 *
 * - Use a function declared with the RTEMS_ALLOC_SIZE_2() macro.
 *
 *   - It cannot be checked that the RTEMS_ALLOC_SIZE_2() macro has the desired
 *     effect. Yet, the check confirms that such a macro exists and that it can
 *     be used on such a memory function and that the argument counting starts
 *     at 1.
 *
 * - Use the RTEMS_ARRAY_SIZE() macro.
 *
 *   - Check that the calculated size of the arrays fit their definition.
 *
 * - Use the RTEMS_COMPILER_DEPRECATED_ATTRIBUTE macro.
 *
 *   - It cannot automatically be checked that the
 *     RTEMS_COMPILER_DEPRECATED_ATTRIBUTE() macro has the desired effect. The
 *     gcc compiler should issue a warning about the use of a deprecated
 *     variable on the above line where the ``compiler_deprecated_attribute``
 *     is used.
 *
 * - Use the RTEMS_COMPILER_MEMORY_BARRIER macro.
 *
 *   - It cannot be checked that the RTEMS_COMPILER_MEMORY_BARRIER macro has
 *     the desired effect. It is only checked that such a macro exists.
 *
 * - Use of the RTEMS_COMPILER_NO_RETURN_ATTRIBUTE macro at the beginning of
 *   this file.
 *
 *   - It cannot be checked that the RTEMS_COMPILER_NO_RETURN_ATTRIBUTE macro
 *     has the desired effect. It is only checked that such a macro exists.
 *
 * - Use the RTEMS_COMPILER_PACKED_ATTRIBUTE macro.
 *
 *   - Check that RTEMS_COMPILER_PACKED_ATTRIBUTE() correctly aligns a
 *     structure member.
 *
 * - Use the RTEMS_COMPILER_PURE_ATTRIBUTE macro at the beginning of this file.
 *
 *   - It cannot be checked that the RTEMS_COMPILER_PURE_ATTRIBUTE macro has
 *     the desired effect. It is checked that such a macro exists.
 *
 * - Use the RTEMS_COMPILER_UNUSED_ATTRIBUTE macro.
 *
 *   - It cannot automatically be checked that the
 *     RTEMS_COMPILER_UNUSED_ATTRIBUTE macro has the desired effect. It is
 *     checked that such a macro exists and one can manually check that no
 *     compiler warnings are produced for the compiler_unused_attribute_var.
 *
 * - Invoke the  RTEMS_CONCAT() macro on examples.
 *
 *   - Check that the two arguments of RTEMS_CONCAT() are concatenated to a new
 *     token.
 *
 *   - Check that the result of the RTEMS_CONCAT() expansion is subject to a
 *     further pre-processor substitution.
 *
 * - Use the RTEMS_CONST macro at the beginning of this file.
 *
 *   - It cannot be checked that the RTEMS_CONST macro has the desired effect.
 *     It is checked that such a macro exists.
 *
 * - Use the RTEMS_CONTAINER_OF macro.
 *
 *   - Check that the RTEMS_CONTAINER_OF macro evaluates to a pointer to
 *     container_of_struct_var.
 *
 * - Use the RTEMS_DECLARE_GLOBAL_SYMBOL macro in the file
 *   tc-basedefs-pendant.h.
 *
 *   - Check that the RTEMS_DECLARE_GLOBAL_SYMBOL macro declares a global
 *     symbol which can be accessed by function basedefs_get_global_symbol()
 *     which is defined in a file different from the file in which the gobal
 *     symbol is defined.
 *
 * - Use the RTEMS_DECONST macro.
 *
 *   - Check that the RTEMS_DECONST macro returns a pointer which allows to
 *     write into an otherwise const value.
 *
 * - Use the RTEMS_DEFINE_GLOBAL_SYMBOL macro at the beginning of this file.
 *
 *   - Check that the RTEMS_DEFINE_GLOBAL_SYMBOL macro defines a global symbol
 *     with the correct value.
 *
 * - Use a function declared with the RTEMS_DEPRECATED() macro.
 *
 *   - It cannot automatically be checked that the RTEMS_DEPRECATED macro has
 *     the desired effect. The gcc compiler should issue a warning about the
 *     use of a deprecated function on the above line where the
 *     ``deprecated_func`` is used.
 *
 * - Use the RTEMS_DEQUALIFY_DEPTHX macro.
 *
 *   - Check that the RTEMS_DEQUALIFY_DEPTHX macro returns a pointer which
 *     allows to write into an otherwise const (volatile) value.
 *
 * - Use the RTEMS_DEQUALIFY macro.
 *
 *   - Check that the RTEMS_DEQUALIFY macro returns a pointer which allows to
 *     write into an otherwise const volatile value.
 *
 * - Use the RTEMS_DEVOLATILE macro.
 *
 *   - Check that the RTEMS_DEVOLATILE macro returns a pointer which allows to
 *     write into an otherwise volatile value.
 *
 * - Invoke the  RTEMS_EXPAND() macro on an example.
 *
 *   - Check that the argument of RTEMS_EXPAND() is expanded and returned.
 *
 * - Invoke the  FALSE() macro on an example.
 *
 *   - Check that of FALSE is substituted by 0.
 *
 * - Invoke the  RTEMS_HAVE_MEMBER_SAME_TYPE() macro on examples.
 *
 *   - Check that of RTEMS_HAVE_MEMBER_SAME_TYPE returns 0 and 1 depending on
 *     whether these types are compatible.
 *
 * - Use the RTEMS_INLINE_ROUTINE in the definition of function
 *   inline_routine_func() at the beginning of this file. Obtain the text the
 *   macro RTEMS_INLINE_ROUTINE produces.
 *
 *   - Check that the RTEMS_INLINE_ROUTINE exists and that it produces the
 *     desired text.
 *
 * - Use a function declared with the RTEMS_MALLOCLIKE() macro.
 *
 *   - It cannot be checked that the RTEMS_MALLOCLIKE macro has the desired
 *     effect. Yet, the check confirms that such a macro exists and that it can
 *     be used on such a memory function and that it produces the correct code.
 *
 * - Use a function declared with the RTEMS_NO_INLINE() macro.
 *
 *   - It cannot be checked that the RTEMS_NO_INLINE macro has the desired
 *     effect. Yet, the check confirms that such a macro exists and that it can
 *     be used on such a function and that it produces the correct code.
 *
 * - Use of the RTEMS_NO_RETURN macro at the beginning of this file.
 *
 *   - It cannot be checked that the RTEMS_NO_RETURN macro has the desired
 *     effect. It is only checked that such a macro exists.
 *
 * - Use the RTEMS_OBFUSCATE_VARIABLE() macro.
 *
 *   - It cannot be checked that the RTEMS_OBFUSCATE_VARIABLE macro has the
 *     desired effect. Yet, the check confirms that such a macro exists and can
 *     be used.
 *
 * - Use the RTEMS_PACKED macro.
 *
 *   - Check that RTEMS_PACKED() correctly aligns a structure member.
 *
 *   - Check that RTEMS_PACKED() correctly aligns all structure members.
 *
 *   - Check that RTEMS_PACKED() correctly enforces a minimal enum type.
 *
 * - Use the RTEMS_PREDICT_FALSE() macro.
 *
 *   - It cannot be checked that the RTEMS_PREDICT_FALSE macro has the desired
 *     effect. Yet, the check confirms that such a macro exists and can be
 *     used.
 *
 * - Use the RTEMS_PREDICT_TRUE() macro.
 *
 *   - It cannot be checked that the RTEMS_PREDICT_TRUE macro has the desired
 *     effect. Yet, the check confirms that such a macro exists and can be
 *     used.
 *
 * - Use a function declared with the RTEMS_PRINTFLIKE() macro.
 *
 *   - It cannot automatically be checked that the RTEMS_PRINTFLIKE macro has
 *     the desired effect. Yet, the check confirms that such a macro exists and
 *     that it can be used on such a printf-like function and that the argument
 *     numbers are correct.
 *
 * - Use the RTEMS_PURE macro at the beginning of this file.
 *
 *   - It cannot be checked that the RTEMS_PURE macro has the desired effect.
 *     It is checked that such a macro exists.
 *
 * - Get the code the RTEMS_RETURN_ADDRESS() macro produces as string.
 *
 *   - The check confirms that a RTEMS_RETURN_ADDRESS() macro exists and that
 *     it produces the correct code.
 *
 * - Use the RTEMS_SECTION() macro on ``section_variable`` and ``section_func``
 *   at the beginning of this file.
 *
 *   - It cannot be checked that the RTEMS_SECTION() macro has the desired
 *     effect. Yet, the check confirms that such a macro exists and can be
 *     used.
 *
 * - Use the RTEMS_STATIC_ASSERT() macro.
 *
 *   - It cannot be automatically check that the RTEMS_STATIC_ASSERT() macro
 *     has the desired effect. Yet, it can be checked that the macro exists and
 *     accepts the specified arguments.
 *
 * - Use the RTEMS_STRING() macro.
 *
 *   - Check that the RTEMS_STRING() macro converts its argument into a string
 *     without applying pre-processor substitutions on its argument.
 *
 * - Use the RTEMS_SYMBOL_NAME() macro on examples.
 *
 *   - Case ``__USER_LABEL_PREFIX__`` undefined. Check that the
 *     RTEMS_SYMBOL_NAME() macro without any pre-processor substitutions
 *     applicable results in its literal argument.
 *
 *   - Case ``__USER_LABEL_PREFIX__`` undefined. Check that the
 *     RTEMS_SYMBOL_NAME() macro applies pre-processor substitutions to its
 *     argument and its result.
 *
 *   - Case ``__USER_LABEL_PREFIX__`` defined. Check that the
 *     RTEMS_SYMBOL_NAME() macro without any pre-processor substitutions
 *     applicable results in the literal prefix and argument.
 *
 *   - Case ``__USER_LABEL_PREFIX__`` defined. Check that the
 *     RTEMS_SYMBOL_NAME() macro applies pre-processor substitutions to its
 *     argument.
 *
 *   - Case ``__USER_LABEL_PREFIX__`` defined. Check that the
 *     RTEMS_SYMBOL_NAME() macro applies pre-processor substitutions to its
 *     result.
 *
 * - Invoke the  TRUE() macro on an example.
 *
 *   - Check that of TRUE is substituted by 0.
 *
 * - Use of the  RTEMS_TYPEOF_REFX() macro on several examples. This use is
 *   already the test as the statements will not compile without error if the
 *   macro did not evaluate to the correct type.
 *
 *   - The checks here are proforma. The macro is tested by the fact that the
 *     action will not compile if the macro returns a wrong result.
 *
 * - Use the RTEMS_UNUSED macro. See also unused_func() at the beginning of
 *   this file.
 *
 *   - It cannot automatically be checked that the RTEMS_UNUSED macro has the
 *     desired effect. It is checked that such a macro exists and one can
 *     manually check that no compiler warnings are produced for the
 *     unused_func().
 *
 *   - It cannot automatically be checked that the RTEMS_UNUSED macro has the
 *     desired effect. It is checked that such a macro exists and one can
 *     manually check that no compiler warnings are produced for the
 *     unused_lable.
 *
 *   - It cannot automatically be checked that the RTEMS_UNUSED macro has the
 *     desired effect. It is checked that such a macro exists and one can
 *     manually check that no compiler warnings are produced for the
 *     unused_struct.
 *
 *   - It cannot automatically be checked that the RTEMS_UNUSED macro has the
 *     desired effect. It is checked that such a macro exists and one can
 *     manually check that no compiler warnings are produced for the unused
 *     items unused_var and the unused argument and variable in unused_func().
 *
 * - Use of the RTEMS_UNREACHABLE macro in function definition of
 *   unreachable_func() at the beginning of this file.
 *
 *   - It cannot be checked that the RTEMS_UNREACHABLE macro has the desired
 *     effect. It is checked that such a macro exists and the compiler warning
 *     about the missing return statement is suppressed.
 *
 * - Use of the RTEMS_USED macro in function definition of used_func() at the
 *   beginning of this file and with used_var above.
 *
 *   - It cannot be checked that the RTEMS_USED macro has the desired effect.
 *     It is checked that such a macro exists.
 *
 * - Use of the RTEMS_WARN_UNUSED_RESULT macro in function definition of
 *   warn_unused_func() at the beginning of this file.
 *
 *   - It cannot be checked that the RTEMS_WARN_UNUSED_RESULT macro has the
 *     desired effect. The GNU C compiler should issue a warning about the
 *     disregarded result returned by the call to the ``warn_unused_func()``
 *     function.
 *
 * - Use of ``basedefs_weak_alias_0/1_func()`` which are defined with the
 *   RTEMS_WEAK_ALIAS macro at the beginning of this file.
 *
 *   - There exists no strong alias for basedefs_weak_alias_0_func(). Check
 *     that ori_func() and basedefs_weak_alias_0_func() are the same function.
 *
 *   - File ``tc_basedefs_pndant.c`` defines a strong function for
 *     basedefs_weak_alias_1_func(). Check that ori_func() and
 *     basedefs_weak_alias_1_func() are not the same function.
 *
 * - Use of ``basedefs_weak_0/1_var`` and ``basedefs_weak_0/1_func()`` which
 *   are defined with the RTEMS_WEAK macro at the beginning of this file.
 *
 *   - For ``basedefs_weak_0_var`` and ``basedefs_weak_0_func()`` there exists
 *     no other symbols with the same name. Hence, the checks test that the
 *     weak symbols are used.
 *
 *   - ``basedefs_weak_1_var`` and ``basedefs_weak_1_func()`` are overwritten
 *     by strong symbols defined in file ``tc_basedefs_pendant.c``. Hence, the
 *     checks test that the strong variants are used.
 *
 * - Invoke the RTEMS_XCONCAT() macro on examples.
 *
 *   - Check that the two arguments of RTEMS_XCONCAT() are concatenated without
 *     inserting new characters.
 *
 *   - Check that the two arguments of RTEMS_XCONCAT() are substituted before
 *     they are concatenated.
 *
 *   - Check that the two arguments of RTEMS_XCONCAT() are can be the macro
 *     itself.
 *
 *   - Check that the result of the RTEMS_XCONCAT() expansion is subject to a
 *     further pre-processor substitution.
 *
 * - Use the RTEMS_XSTRING() macro.
 *
 *   - Check that the RTEMS_XSTRING() macro applies pre-processor substitutions
 *     on its argument and converts its argument into a string.
 *
 * - Use of the RTEMS_ZERO_LENGTH_ARRAY macro in a declaration of a structure.
 *
 *   - Checked that the RTEMS_ZERO_LENGTH_ARRAY macro produces a structure
 *     similar to a structure with one element.
 *
 * @{
 */

#define WHITE_SPACE_STRING_MAX_LENGTH 80
#define abccat concat
#define abc ABC
#define CON con
#define CAT cat
#define defcat concat
#define GLOBAL_SYMBOL_VALULE( _hex ) 0x ## _hex
#define EXPAND expand
#define PREDICT_FALSE 1 -
#define SECTION_NAME ".rtemsroset.test"
#define STATIC_ASSERT_COND 0 +
#define STRING_PREFIX str
#define SYMBOL_NAME SYMBOL_name
#define SYMBOL_name symbol_name
#define _TO_STR2( _text ) #_text
#define _TO_STR( _text ) _TO_STR2( _text )

/*
 * For some reasons - which I fail to fully understand - _TO_STR()
 * seems to remove spaces around `()` at times and at other times
 * not. For example, I get
 *
 *   *  "__attribute__(( __malloc__ ))" or
 *   *  "__attribute__((__malloc__))".
 *
 * To avoid trouble, the function below returns a version of a
 * string without any spaces. Albeit, the implementation is rather
 * brute and raw. It returns a pointer to a static buffer of fixed
 * size. That will do for tests but not serve as generic function.
 */
static const char *remove_white_space( const char *str )
{
  char c;
  int i = 0;
  static char buffer[WHITE_SPACE_STRING_MAX_LENGTH] = {};

  /* Sanity check */
  if( strlen( str ) >= sizeof( buffer ) ) {
    T_assert_true( false,
      "Buffer too small; increase WHITE_SPACE_STRING_MAX_LENGTH" );
  }

  /* Copy string but skip white spaces */
  do {
    c = *( str++ );
    if ( ' ' != c && '\t' !=c ) {
      buffer[i++] = c;
    }
  } while ( '\0' != c );

  return buffer;
}

static int alias_func( int i ) RTEMS_ALIAS( ori_func );

typedef struct {
  uint8_t c;
  uint8_t aligned_member RTEMS_ALIGNED( 8 );
} aligned_member_struct;

static int concat( void )
{
  return 91;
}

RTEMS_CONST static int const_func( int arg )
{
  return 4 * arg;
}

RTEMS_COMPILER_NO_RETURN_ATTRIBUTE
  static void compiler_no_return_attribute_func( int i );
static void compiler_no_return_attribute_func( int i )
{
  while ( true ) {
    /* Loop forever */
  }
}

RTEMS_COMPILER_PURE_ATTRIBUTE static int compiler_pure_attribute_func( void )
{
  return 21;
}

RTEMS_DEFINE_GLOBAL_SYMBOL(
  GLOBAL_SYMBOL, GLOBAL_SYMBOL_VALULE( abc ) );

static int deprecated_func( int i ) RTEMS_DEPRECATED;
static int deprecated_func( int i )
{
  return 3 * i;
}

static int expand( void )
{
  return 82;
}

RTEMS_INLINE_ROUTINE int inline_routine_func( int arg )
{
  return 1 << arg;
}

RTEMS_NO_INLINE static int no_inline_func( void )
{
  asm ("");
  return 75;
}

RTEMS_NO_RETURN static void no_return_func( int i )
{
  while ( true ) {
    /* Loop forever */
  }
}

static int ori_func( int x )
{
   return 2 * x;
}

RTEMS_PRINTFLIKE(2, 3) static int printflike_func(
  const char *prefix,
  const char *fmt,
  ...
)
{
  int result;
  va_list va_list;

  T_printf( "%s: ", prefix );
  va_start( va_list, fmt );
  result = T_vprintf( fmt, va_list );
  va_end( va_list );

  return result;
}

RTEMS_PURE static int pure_func( void )
{
  return 21;
}

RTEMS_SECTION( ".rtemsrwset.test" ) static int section_var = 28;
RTEMS_SECTION( SECTION_NAME ) static int section_func( int arg )
{
  return arg % 100;
}

static int unreachable_func( int arg )
{
  if ( 1 == arg % 100 ) {
    return arg;
  } else {
    T_assert_true( false,
      "Oops! Function caled with bad argument." );
    RTEMS_UNREACHABLE();
  }
}

RTEMS_USED static int used_var = 4711;
RTEMS_USED static int used_func( void )
{
  return 35;
}

static int warn_unused_func( int arg ) RTEMS_WARN_UNUSED_RESULT;
static int warn_unused_func( int arg )
{
  return arg / 3;
}

int basedefs_weak_alias_0_func( int i ) RTEMS_WEAK_ALIAS( ori_func );
int basedefs_weak_alias_1_func( int i ) RTEMS_WEAK_ALIAS( ori_func );

RTEMS_WEAK const volatile int basedefs_weak_0_var = 60;
RTEMS_WEAK const volatile int basedefs_weak_1_var = 61;
RTEMS_WEAK int basedefs_weak_0_func( void )
{
  return 63;
}

RTEMS_WEAK int basedefs_weak_1_func( void )
{
  return 64;
}

/**
 * @fn void T_case_body_RtemsBasedefsValBasedefs( void )
 */
T_TEST_CASE( RtemsBasedefsValBasedefs )
{
  T_plan(124);

  int alias_result;
  alias_result = ori_func( 3 ) + alias_func( 5 );
  T_step_eq_int( 0, alias_result, 16 );

  int align_down0_result;
  int align_down1_result;
  int align_down2_result;
  int align_down3_result;
  int align_down4_result;
  int align_down5_result;
  int align_down6_result;
  int align_down7_result;
  int align_down8_result;
  int align_down9_result;

  align_down0_result = RTEMS_ALIGN_DOWN( 0, 1 );
  align_down1_result = RTEMS_ALIGN_DOWN( 0, 4 );
  align_down2_result = RTEMS_ALIGN_DOWN( 1, 2 );
  align_down3_result = RTEMS_ALIGN_DOWN( 2, 2 );
  align_down4_result = RTEMS_ALIGN_DOWN( 3, 2 );
  align_down5_result = RTEMS_ALIGN_DOWN( 4, 2 );
  align_down6_result = RTEMS_ALIGN_DOWN( 5, 2 );
  align_down7_result = RTEMS_ALIGN_DOWN( 255, 16 );
  align_down8_result = RTEMS_ALIGN_DOWN( 256, 16 );
  align_down9_result = RTEMS_ALIGN_DOWN( 257, 16 );
  T_step_eq_int( 1, align_down0_result, 0 );
  T_step_eq_int( 2, align_down1_result, 0 );
  T_step_eq_int( 3, align_down2_result, 0 );
  T_step_eq_int( 4, align_down3_result, 2 );
  T_step_eq_int( 5, align_down4_result, 2 );
  T_step_eq_int( 6, align_down5_result, 4 );
  T_step_eq_int( 7, align_down6_result, 4 );
  T_step_eq_int( 8, align_down7_result, 240 );
  T_step_eq_int( 9, align_down8_result, 256 );
  T_step_eq_int( 10, align_down9_result, 256 );

  int align_up0_result;
  int align_up1_result;
  int align_up2_result;
  int align_up3_result;
  int align_up4_result;
  int align_up5_result;
  int align_up6_result;
  int align_up7_result;
  int align_up8_result;
  int align_up9_result;

  align_up0_result = RTEMS_ALIGN_UP( 0, 1 );
  align_up1_result = RTEMS_ALIGN_UP( 0, 4 );
  align_up2_result = RTEMS_ALIGN_UP( 1, 2 );
  align_up3_result = RTEMS_ALIGN_UP( 2, 2 );
  align_up4_result = RTEMS_ALIGN_UP( 3, 2 );
  align_up5_result = RTEMS_ALIGN_UP( 4, 2 );
  align_up6_result = RTEMS_ALIGN_UP( 5, 2 );
  align_up7_result = RTEMS_ALIGN_UP( 255, 16 );
  align_up8_result = RTEMS_ALIGN_UP( 256, 16 );
  align_up9_result = RTEMS_ALIGN_UP( 257, 16 );
  T_step_eq_int( 11, align_up0_result, 0 );
  T_step_eq_int( 12, align_up1_result, 0 );
  T_step_eq_int( 13, align_up2_result, 2 );
  T_step_eq_int( 14, align_up3_result, 2 );
  T_step_eq_int( 15, align_up4_result, 4 );
  T_step_eq_int( 16, align_up5_result, 4 );
  T_step_eq_int( 17, align_up6_result, 6 );
  T_step_eq_int( 18, align_up7_result, 256 );
  T_step_eq_int( 19, align_up8_result, 256 );
  T_step_eq_int( 20, align_up9_result, 272 );

  char unaligned_var = 'c';
  char aligned_var RTEMS_ALIGNED( 8 ) = 'd';
  alias_result = ori_func( 3 ) + alias_func( 5 );
  (void) unaligned_var;
  T_step_eq_int( 21, ( ( uintptr_t ) &aligned_var ) % 8, 0 );
  T_step_eq_int( 22,
    offsetof( aligned_member_struct, aligned_member ) % 8, 0 );

  void *free_ptr;
  void *alloc_align_ptr;
  alloc_align_ptr = basedefs_alloc_align_func( 1024, &free_ptr, 64 );
  basedefs_free( free_ptr );
  T_step_not_null( 23, alloc_align_ptr );
  T_step_eq_int( 24, ( ( uintptr_t ) alloc_align_ptr ) % 64, 0 );
  T_step_ge_uptr( 25, ( ( uintptr_t ) alloc_align_ptr ),
    ( ( uintptr_t ) free_ptr ) );
  T_step_lt_uptr( 26, ( ( uintptr_t ) alloc_align_ptr ),
    ( ( uintptr_t ) free_ptr ) + 64 );

  void *alloc_size_ptr;
  alloc_size_ptr = basedefs_alloc_size_func( 1024 );
  basedefs_free( alloc_size_ptr );
  T_step_not_null( 27, alloc_size_ptr );

  void *alloc_size_2_ptr;
  alloc_size_2_ptr = basedefs_alloc_size_2_func( 8, 128 );
  basedefs_free( alloc_size_2_ptr );
  T_step_not_null( 28, alloc_size_2_ptr );

  int array[] = { 10, 20, 30, 40, 50 };
  unsigned char array2[12];
  int array_size = RTEMS_ARRAY_SIZE(array);
  int array2_size = RTEMS_ARRAY_SIZE(array2);
  T_step_eq_sz( 29, array_size, 5 );
  T_step_eq_sz( 30, array2_size, 12 );

  int compiler_deprecated_attribute RTEMS_COMPILER_DEPRECATED_ATTRIBUTE = 42;
  /*
   * Derivation from Coding Style:
   * The following code suppresses a compiler warning (instead of fixing
   * it).
   * Rational: The variable compiler_deprecated_attribute is not really
   * deprecated but its purpose is to test the RTEMS_DEPRECATED macro.
   * The RTEMS_DEPRECATED macro must result in a compiler warning here.
   */
  _Pragma( "GCC diagnostic push" )
  _Pragma( "GCC diagnostic ignored \"-Wdeprecated-declarations\"" )
  T_step_eq_int( 31, compiler_deprecated_attribute, 42 );
  _Pragma( "GCC diagnostic pop" )

  RTEMS_COMPILER_MEMORY_BARRIER();


  (void) compiler_no_return_attribute_func;


  typedef struct {
    uint8_t c;
    RTEMS_COMPILER_PACKED_ATTRIBUTE uint32_t i;
  } compiler_packed_attribute_struct;
  int compiler_packed_attribute_offset =
    offsetof( compiler_packed_attribute_struct, i );
  T_step_eq_int( 32, compiler_packed_attribute_offset, 1 );

  int compiler_pure_attribute_result;
  int compiler_pure_attribute_result_2;
  compiler_pure_attribute_result = compiler_pure_attribute_func();
  compiler_pure_attribute_result_2 =
    compiler_pure_attribute_func();
  T_step_eq_int( 33, compiler_pure_attribute_result, 21 );
  T_step_eq_int( 34, compiler_pure_attribute_result_2, 21 );

  int compiler_unused_attribute_var RTEMS_COMPILER_UNUSED_ATTRIBUTE;


  int concat0_result;
  int concat1_result;
  concat0_result = RTEMS_CONCAT( con, cat )();
  concat1_result = RTEMS_CONCAT( abc, cat )();
  T_step_eq_int( 35, concat0_result, 91 );
  T_step_eq_int( 36, concat1_result, 91 );

  int const_result;
  int const_result_2;
  const_result = const_func( 7 );
  const_result_2 = const_func( 7 );
  T_step_eq_int( 37, const_result, 28 );
  T_step_eq_int( 38, const_result_2, 28 );

  typedef struct {
    int a;
    int b;
  } container_of_struct;

  container_of_struct container_of_struct_var;
  int *container_of_struct_b_adr = &container_of_struct_var.b;
  container_of_struct *container_of_struct_adr;
  container_of_struct_adr =
    RTEMS_CONTAINER_OF( container_of_struct_b_adr, container_of_struct, b );
  T_step_eq_ptr( 39,
    container_of_struct_adr, &container_of_struct_var );

  /* No action */
  T_step_eq_int( 40, basedefs_get_global_symbol(), 0xabc );

  const int deconst_array[] = { 52, 55 };
  int *deconst_pointer;
  deconst_pointer = RTEMS_DECONST( int *, deconst_array );
  T_step_eq_int( 41, deconst_pointer[0], 52 );
  T_step_eq_int( 42, deconst_pointer[1], 55 );
  deconst_pointer[1] = 13;
  T_step_eq_int( 43, deconst_pointer[1], 13 );

  /* No action */
  T_step_eq_int( 44, (uintptr_t) global_symbol, 0xabc );

  int deprecated_result;
  /*
   * Derivation from Coding Style:
   * The following code suppresses a compiler warning (instead of fixing it).
   * Rational: The function deprecated_func() is not really deprecated
   * but its purpose is to test the RTEMS_DEPRECATED macro.
   * The RTEMS_DEPRECATED macro must result in a compiler warning here.
   */
  _Pragma( "GCC diagnostic push" )
  _Pragma( "GCC diagnostic ignored \"-Wdeprecated-declarations\"" )
  deprecated_result = deprecated_func( 5 );
  _Pragma( "GCC diagnostic pop" )
  T_step_eq_int( 45, deprecated_result, 15 );

  const volatile int dequalify_depthx_array[] = { 52, 55 };
  const char dequalify_depthx_var = 'a';
  const char *dequalify_depthx_one_pointer = &dequalify_depthx_var;
  const char **dequalify_depthx_two_pointer =
    &dequalify_depthx_one_pointer;
  int *dequalify_depthx_pointer;
  volatile char **dequalify_depthx_twice_pointer;
  dequalify_depthx_pointer =
    RTEMS_DEQUALIFY_DEPTHX( *, int *, dequalify_depthx_array );
  dequalify_depthx_twice_pointer = RTEMS_DEQUALIFY_DEPTHX(
    **, volatile char **, dequalify_depthx_two_pointer );
  T_step_eq_int( 46, dequalify_depthx_pointer[0], 52 );
  T_step_eq_int( 47, dequalify_depthx_pointer[1], 55 );
  dequalify_depthx_pointer[0] = 13;
  T_step_eq_int( 48, dequalify_depthx_pointer[0], 13 );
  T_step_eq_char( 49, **dequalify_depthx_twice_pointer, 'a' );
  **dequalify_depthx_twice_pointer = 'Z';
  T_step_eq_char( 50, **dequalify_depthx_twice_pointer, 'Z' );

  const volatile int dequalify_array[] = { 52, 55 };
  int *dequalify_pointer;
  dequalify_pointer = RTEMS_DECONST( int *, dequalify_array );
  T_step_eq_int( 51, dequalify_pointer[0], 52 );
  T_step_eq_int( 52, dequalify_pointer[1], 55 );
  dequalify_pointer[0] = 13;
  T_step_eq_int( 53, dequalify_pointer[0], 13 );

  volatile int devolatile_array[] = { 52, 55 };
  int *devolatile_pointer;
  devolatile_pointer = RTEMS_DEVOLATILE( int *, devolatile_array );
  T_step_eq_int( 54, devolatile_pointer[0], 52 );
  T_step_eq_int( 55, devolatile_pointer[1], 55 );
  devolatile_pointer[1] = 13;
  T_step_eq_int( 56, devolatile_pointer[1], 13 );

  int expand_result;
  expand_result = RTEMS_EXPAND( EXPAND )();
  T_step_eq_int( 57, expand_result, 82 );

  char *false_result;
  false_result = _TO_STR( FALSE );
  T_step_eq_str( 58, false_result, "0" );

  typedef union {
    short s;
    int **i;
    char *c;
    int a[5];
  } same_type_union;
  typedef struct {
    const short u;
    short v;
    int *w;
    char *x;
    volatile int y[5];
    int z;
  } same_type_struct;
  int same_type_result_0 = RTEMS_HAVE_MEMBER_SAME_TYPE(
    same_type_union, s, same_type_struct, v );
  int same_type_result_1 = RTEMS_HAVE_MEMBER_SAME_TYPE(
    same_type_union, s, same_type_struct, z );
  int same_type_result_2 = RTEMS_HAVE_MEMBER_SAME_TYPE(
    same_type_union, i, same_type_struct, w );
  int same_type_result_3 = RTEMS_HAVE_MEMBER_SAME_TYPE(
    same_type_union, c, same_type_struct, x );
  int same_type_result_4 = RTEMS_HAVE_MEMBER_SAME_TYPE(
    same_type_union, a, same_type_struct, y );
  int same_type_result_5 = RTEMS_HAVE_MEMBER_SAME_TYPE(
    same_type_union, s, same_type_union, s );
  int same_type_result_6 = RTEMS_HAVE_MEMBER_SAME_TYPE(
    same_type_union, i, same_type_union, i );
  int same_type_result_7 = RTEMS_HAVE_MEMBER_SAME_TYPE(
    same_type_union, s, same_type_struct, y );
  int same_type_result_8 = RTEMS_HAVE_MEMBER_SAME_TYPE(
    same_type_union, a, same_type_struct, w );
  int same_type_result_9 = RTEMS_HAVE_MEMBER_SAME_TYPE(
    same_type_union, s, same_type_struct, u );
  T_step_eq_int( 59, same_type_result_0, 1 );
  T_step_eq_int( 60, same_type_result_1, 0 );
  T_step_eq_int( 61, same_type_result_2, 0 );
  T_step_eq_int( 62, same_type_result_3, 1 );
  T_step_eq_int( 63, same_type_result_4, 1 );
  T_step_eq_int( 64, same_type_result_5, 1 );
  T_step_eq_int( 65, same_type_result_6, 1 );
  T_step_eq_int( 66, same_type_result_7, 0 );
  T_step_eq_int( 67, same_type_result_8, 0 );
  T_step_eq_int( 68, same_type_result_9, 1 );

  const int inline_routine_step = 69;
  int inline_routine_result;
  char *inline_routine_text;
  inline_routine_result = inline_routine_func( 3 );
  inline_routine_text = _TO_STR( RTEMS_INLINE_ROUTINE );
  if( 0 == strcmp( "static inline", inline_routine_text ) ) {
    T_step_eq_str( inline_routine_step,
      inline_routine_text, "static inline" );
  } else {
    T_step_eq_str( inline_routine_step,
      inline_routine_text, "static __inline__" );
  }
  T_step_eq_int( 70, inline_routine_result, 8 );

  void *malloclike_ptr;
  /*
   * If this code is not compiled using GNU C, I still have to run a check
   * to avoid trouble with the {step} counter of the checks.
   */
  const char *malloclike_text = "__attribute__((__malloc__))";
  malloclike_ptr = basedefs_malloclike_func( 102 );
  basedefs_free( malloclike_ptr );
  #if defined( __GNUC__ )
  malloclike_text = remove_white_space( _TO_STR( RTEMS_MALLOCLIKE ) );
  #endif
  T_step_not_null( 71, malloclike_ptr );
  T_step_eq_str( 72, malloclike_text, "__attribute__((__malloc__))" );

  int no_inline_result;
  /*
   * If this code is not compiled using GNU C, I still have to run a check
   * to avoid trouble with the {step} counter of the checks.
   */
  const char *no_inline_text = "__attribute__((__noinline__))";
  no_inline_result = no_inline_func();
  #if defined( __GNUC__ )
  no_inline_text = remove_white_space( _TO_STR( RTEMS_NO_INLINE ) );
  #endif
  T_step_eq_int( 73, no_inline_result, 75 );
  T_step_eq_str( 74, no_inline_text, "__attribute__((__noinline__))" );

  (void) no_return_func;


  short obfuscate_variable = 66;
  RTEMS_OBFUSCATE_VARIABLE( obfuscate_variable );
  T_step_eq_int( 75, obfuscate_variable, 66 );

  int packed_offset;
  int packed_full_i_offset;
  int packed_full_j_offset;
  int packed_enum_size;
  typedef struct {
    uint8_t c;
    RTEMS_PACKED uint32_t i;
  } packed_struct;
  typedef struct RTEMS_PACKED {
    uint8_t c;
    uint32_t i;
    uint32_t j;
  } packed_full_struct;
  typedef enum RTEMS_PACKED {
    red = 1,
    green,
    yellow,
    blue = 255
  } packed_enum;
  packed_offset = offsetof( packed_struct, i );
  packed_full_i_offset = offsetof( packed_full_struct, i );
  packed_full_j_offset = offsetof( packed_full_struct, j );
  packed_enum_size = sizeof( packed_enum );
  T_step_eq_int( 76, packed_offset, 1 );
  T_step_eq_int( 77, packed_full_i_offset, 1 );
  T_step_eq_int( 78, packed_full_j_offset, 5 );
  T_step_eq_int( 79, packed_enum_size, 1 );

  /* No action */
  T_step_eq_int( 80, RTEMS_PREDICT_FALSE( PREDICT_FALSE 1 ), 0 );

  /* No action */
  T_step_eq_int( 81, RTEMS_PREDICT_TRUE( 6 - 5 ), 1 );

  int printflike_result;
  printflike_result = printflike_func(
    "RTEMS_PRINTFLIKE",
    "%d %lx %s\n",
    123,
    0xABCDEFL,
    "test output"
  );
  T_step_eq_int( 82, printflike_result, 23 );

  int pure_result;
  int pure_result_2;
  pure_result = pure_func();
  pure_result_2 = pure_func();
  T_step_eq_int( 83, pure_result, 21 );
  T_step_eq_int( 84, pure_result_2, 21 );

  /*
   * If this code is not compiled using GNU C, I still have to run a check
   * to avoid trouble with the {step} counter of the checks.
   */
  const char *return_address_text = "__builtin_return_address(0)";
  #if defined( __GNUC__ )
  return_address_text =
    remove_white_space( _TO_STR( RTEMS_RETURN_ADDRESS() ) );
  #endif
  T_step_eq_str( 85,
    return_address_text, "__builtin_return_address(0)" );

  short section_result;
  section_result = section_func( 1234567 );
  T_step_eq_int( 86, section_var, 28 );
  T_step_eq_int( 87, section_result, 67 );

  RTEMS_STATIC_ASSERT( STATIC_ASSERT_COND 1, RTEMS_STATIC_ASSERT_test );


  const char *string_var;
  const char *string_empty_var;
  /* strange spacing and tabs belong to the test */
  string_var = RTEMS_STRING( \\ STRING_PREFIX 		cat""\n   );
  string_empty_var = RTEMS_STRING();
  T_step_eq_str( 88, string_var, "\\ STRING_PREFIX cat\"\"\n" );
  T_step_eq_str( 89, string_empty_var, "" );

  const int symbol_name = 321;
  int symbol_name_0_var;
  int symbol_name_1_var;
  int prefixed_symbol_name_var;
  int prefixed_symbol_id_var;
  int prefixed_upper_symbol_name_var;
  symbol_name_0_var = RTEMS_SYMBOL_NAME( symbol_name );
  symbol_name_1_var = RTEMS_SYMBOL_NAME( SYMBOL_NAME );
  prefixed_symbol_name_var = basedefs_use_prefixed_symbol_name();
  prefixed_symbol_id_var = basedefs_use_prefixed_symbol_id();
  prefixed_upper_symbol_name_var = basedefs_use_prefixed_upper_symbol_name();
  T_step_eq_int( 90, symbol_name_0_var, 321 );
  T_step_eq_int( 91, symbol_name_1_var, 321 );
  T_step_eq_int( 92, prefixed_symbol_name_var, 124 );
  T_step_eq_int( 93, prefixed_upper_symbol_name_var, 125 );
  T_step_eq_int( 94, prefixed_symbol_id_var, 126 );

  char *true_result;
  true_result = _TO_STR( TRUE );
  T_step_eq_str( 95, true_result, "1" );

  int type_refx_val = 7;
  char type_refx_chr = 'c';
  char *type_refx_chr_p = &type_refx_chr;
  char **type_refx_chr_pp = &type_refx_chr_p;
  const short type_refx_const_val = 333;
  RTEMS_TYPEOF_REFX( *, int *) type_refx_x_int = 8;
  RTEMS_TYPEOF_REFX( **, int **) type_refx_xx_int = 9;
  RTEMS_TYPEOF_REFX( ***, int ***) type_refx_xxx_int = 10;
  RTEMS_TYPEOF_REFX( **, int ***) type_refx_xxx_int_p = &type_refx_val;
  RTEMS_TYPEOF_REFX( **, &type_refx_chr_p) type_refx_ax_char = 'd';
  RTEMS_TYPEOF_REFX( *, type_refx_chr_p) type_refx_x_char = 'e';
  RTEMS_TYPEOF_REFX( , *type_refx_chr_p) type_refx_char = 'f';
  RTEMS_TYPEOF_REFX( *, type_refx_chr_pp[0]) type_refx_xx_char = 'g';
  RTEMS_TYPEOF_REFX( *, const short **)
    type_refx_xx_const_short_p = &type_refx_const_val;
  T_step_eq_int( 96, type_refx_val, 7 );
  T_step_eq_int( 97, type_refx_x_int, 8 );
  T_step_eq_int( 98, type_refx_xx_int, 9 );
  T_step_eq_int( 99, type_refx_xxx_int, 10 );
  T_step_eq_int( 100, *type_refx_xxx_int_p, 7 );
  T_step_eq_char( 101, type_refx_chr, 'c' );
  T_step_eq_char( 102, type_refx_ax_char, 'd' );
  T_step_eq_char( 103, type_refx_x_char, 'e' );
  T_step_eq_char( 104, type_refx_char, 'f' );
  T_step_eq_char( 105, type_refx_xx_char, 'g' );
  T_step_eq_short( 106, *type_refx_xx_const_short_p, 333 );

  int unused_var RTEMS_UNUSED;
  typedef struct RTEMS_UNUSED {
    char c;
    int i;
  } unused_struct_t;
  unused_struct_t unused_struct = { '@', 13 };

  unused_lable:
    RTEMS_UNUSED;



  int unreachable_result;
  unreachable_result = unreachable_func(2101);
  T_step_eq_int( 107, unreachable_result, 2101 );

  /* No action */


  int warn_unused_result;
  warn_unused_result = warn_unused_func( 33 );
  /*
   * Derivation from Coding Style:
   * The following code suppresses a compiler warning (instead of fixing
   * it).
   * Rational: Ignoring the function warn_unused_func() result is not really
   * a bug but its purpose is to test the RTEMS_WARN_UNUSED_RESULT macro.
   * The RTEMS_WARN_UNUSED_RESULT macro must result in a compiler warning
   * here.
   */
  _Pragma( "GCC diagnostic push" )
  _Pragma( "GCC diagnostic ignored \"-Wunused-result\"" )
  warn_unused_func( 66 );
  _Pragma( "GCC diagnostic pop" )
  T_step_eq_int( 108, warn_unused_result, 11 );

  int weak_alias_0_result;
  int weak_alias_1_result;
  weak_alias_0_result = ori_func( 3 ) + basedefs_weak_alias_0_func( 5 );
  weak_alias_1_result = ori_func( 3 ) + basedefs_weak_alias_1_func( 5 );
  T_step_eq_int( 109, weak_alias_0_result, 16 );
  T_step_eq_int( 110, weak_alias_1_result, 56 );

  int weak_0_result;
  int weak_1_result;
  weak_0_result = basedefs_weak_0_func();
  weak_1_result = basedefs_weak_1_func();
  T_step_eq_int( 111, basedefs_weak_0_var, 60 );
  T_step_eq_int( 112, weak_0_result, 63 );
  T_step_eq_int( 113, basedefs_weak_1_var, 62 );
  T_step_eq_int( 114, weak_1_result, 65 );

  int xconcat0_result;
  int xconcat1_result;
  int xconcat2_result;
  int xconcat3_result;
  xconcat0_result = RTEMS_XCONCAT( con, cat )();
  xconcat1_result = RTEMS_XCONCAT( CON, CAT )();
  xconcat2_result =
    RTEMS_XCONCAT( RTEMS_XCONCAT( CO, N ), RTEMS_XCONCAT( ca, t ) )();
  xconcat3_result = RTEMS_CONCAT( def, cat )();
  T_step_eq_int( 115, xconcat0_result, 91 );
  T_step_eq_int( 116, xconcat1_result, 91 );
  T_step_eq_int( 117, xconcat2_result, 91 );
  T_step_eq_int( 118, xconcat3_result, 91 );

  const char *xstring_var;
  const char *xstring_empty_var;
  /* strange spacing and tabs belong to the test */
  xstring_var = RTEMS_XSTRING( \\ STRING_PREFIX 		cat""\n   );
  xstring_empty_var = RTEMS_XSTRING();
  T_step_eq_str( 119, xstring_var, "\\ str cat\"\"\n" );
  T_step_eq_str( 120, xstring_empty_var, "" );

  typedef struct {
    char chr;
    int array[RTEMS_ZERO_LENGTH_ARRAY];
  } zero_length_struct_0;
  typedef struct {
    char chr;
    int array[1];
  } zero_length_struct_1;
  T_step_eq_sz( 121, sizeof( zero_length_struct_0 ),
    sizeof( zero_length_struct_1 ) - sizeof( int ) );
  T_step_eq_sz( 122, offsetof( zero_length_struct_0, chr ),
    offsetof( zero_length_struct_1, chr ) );
  T_step_eq_sz( 123, offsetof( zero_length_struct_0, array ),
    offsetof( zero_length_struct_1, array ) );
}

/** @} */