Commit 907d5bb
committed
Merge branch 'develop-test-integerSizes'. Close #471.
**Description**
The code generated by `copilot-c99` during tests produces warnings
during compilation. The reason is that some constants included in the
code are too big and the compiler is making assumptions about their
necessary types. If those constants are annotated, their intention will
be made clearer.
**Type**
- Bug: test produce warnings during compilation.
**Additional context**
None.
**Requester**
- Scott Talbert (Debian Developer & Debian Haskell Group)
**Method to check presence of bug**
Compiling `copilot-c99`'s tests can produce warnings:
```
main.c:9:23: warning: integer constant is so large that it is unsigned
9 | uint64_t input_s[] = {10613134964919841005};
| ^~~~~~~~~~~~~~~~~~~~
```
**Expected result**
The above tests should compile without warnings.
**Solution implemented**
Modify the [`CShow` instances for different
types](https://github.com/Copilot-Language/copilot/blob/cfc565bcf52dd359eb7ee768549459402c1785df/copilot-c99/tests/Test/Copilot/Compile/C99.hs#L884-L916)
so that constants are printed with the necessary annotations.
Instead of hard-coding the suffixes, which produces code that might not
be portable, we use macros defined in stdint.h to wrap the values. This
customizes the suffixes for the architecture for which the C code
produced is being compiled.
**Further notes**
- Tests are randomly generated, so there's no guarantee that code with
such warnings will be produced by a specific run. This issue is
therefore not always replicable unless we fix the number generator seed.
- We have confirmed that the solution implemented works by asking the
original user to check on their side that compilation now completes
without those warnings.2 files changed
+34
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
886 | 886 | | |
887 | 887 | | |
888 | 888 | | |
889 | | - | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
890 | 893 | | |
891 | 894 | | |
892 | | - | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
893 | 899 | | |
894 | 900 | | |
895 | | - | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
896 | 905 | | |
897 | 906 | | |
898 | | - | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
899 | 911 | | |
900 | 912 | | |
901 | | - | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
902 | 917 | | |
903 | 918 | | |
904 | | - | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
905 | 923 | | |
906 | 924 | | |
907 | | - | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
908 | 929 | | |
909 | 930 | | |
910 | | - | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
911 | 935 | | |
912 | 936 | | |
913 | 937 | | |
| |||
0 commit comments