File tree Expand file tree Collapse file tree 1 file changed +117
-0
lines changed Expand file tree Collapse file tree 1 file changed +117
-0
lines changed Original file line number Diff line number Diff line change @@ -5690,6 +5690,123 @@ int main() {
5690
5690
}
5691
5691
EOF
5692
5692
5693
+ begin_category " Function parsing" " Forward declaration and implementation"
5694
+
5695
+ # Normal case
5696
+ try_output 0 " Hello" << EOF
5697
+ void func(char *ptr);
5698
+
5699
+ void func(char *ptr)
5700
+ {
5701
+ while (*ptr) {
5702
+ printf("%c", *ptr);
5703
+ ptr++;
5704
+ }
5705
+ }
5706
+
5707
+ int main()
5708
+ {
5709
+ func("Hello");
5710
+ return 0;
5711
+ }
5712
+ EOF
5713
+
5714
+ # Incorrect function returning type
5715
+ try_compile_error << EOF
5716
+ void func(void);
5717
+
5718
+ int **func(void)
5719
+ {
5720
+ return 3;
5721
+ }
5722
+
5723
+ int main()
5724
+ {
5725
+ func();
5726
+ return 0;
5727
+ }
5728
+ EOF
5729
+
5730
+ # Incorrect number of parameters
5731
+ try_compile_error << EOF
5732
+ void func(void *a);
5733
+
5734
+ void func(void *a, int x)
5735
+ {
5736
+ return 3;
5737
+ }
5738
+
5739
+ int main()
5740
+ {
5741
+ func();
5742
+ return 0;
5743
+ }
5744
+ EOF
5745
+
5746
+ # Conflicting parameter types
5747
+ try_compile_error << EOF
5748
+ void func(void *a, char x);
5749
+
5750
+ void func(void *a, int x)
5751
+ {
5752
+ return 3;
5753
+ }
5754
+
5755
+ int main()
5756
+ {
5757
+ func();
5758
+ return 0;
5759
+ }
5760
+ EOF
5761
+
5762
+ # Conflicting parameter types (variadic parameters)
5763
+ try_compile_error << EOF
5764
+ void func(void *a);
5765
+
5766
+ void func(void *a, ...)
5767
+ {
5768
+ return 3;
5769
+ }
5770
+
5771
+ int main()
5772
+ {
5773
+ func();
5774
+ return 0;
5775
+ }
5776
+ EOF
5777
+
5778
+ # Incorrect function returning type (const)
5779
+ try_compile_error << EOF
5780
+ void *func(int *a, char x);
5781
+
5782
+ const void *func(int *a, char x)
5783
+ {
5784
+ return 3;
5785
+ }
5786
+
5787
+ int main()
5788
+ {
5789
+ func();
5790
+ return 0;
5791
+ }
5792
+ EOF
5793
+
5794
+ # Conflicting parameter types (const)
5795
+ try_compile_error << EOF
5796
+ void func(int *a, char x);
5797
+
5798
+ void func(const int *a, char x)
5799
+ {
5800
+ return 3;
5801
+ }
5802
+
5803
+ int main()
5804
+ {
5805
+ func();
5806
+ return 0;
5807
+ }
5808
+ EOF
5809
+
5693
5810
# Test Results Summary
5694
5811
5695
5812
echo " "
You can’t perform that action at this time.
0 commit comments