Commit 6eb3870
committed
Enhance function parsing
Since the previous parser may incorrectly handle a function with a
forward declaration before implementation, the code generator produces
wrong instructions for a function because the frontend provides
incorrect information.
For example, consider the following code:
int func(int *a);
int func(int *a)
{
return *a;
}
int main()
{
/* ... */
}
After parsing the forward declaration of 'func', it is added to the
function list, and its parameter 'a' is recorded with the type 'int *'.
When the function implementation is later parsed, the parser processes
the declaration again, but the pointer level of 'a' is accumulated,
causing the type of 'a' to become 'int **'.
Therefore, to resolve the above issue and enhance the function parsing,
these changes improve the parser to correctly handle functions with
forward declarations, and report an error message if a later declaration
differs from a previous one.
Close #3051 parent c4f778e commit 6eb3870
1 file changed
+99
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1206 | 1206 | | |
1207 | 1207 | | |
1208 | 1208 | | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
1209 | 1215 | | |
1210 | 1216 | | |
1211 | 1217 | | |
| |||
4796 | 4802 | | |
4797 | 4803 | | |
4798 | 4804 | | |
| 4805 | + | |
| 4806 | + | |
| 4807 | + | |
| 4808 | + | |
| 4809 | + | |
| 4810 | + | |
| 4811 | + | |
| 4812 | + | |
| 4813 | + | |
| 4814 | + | |
| 4815 | + | |
| 4816 | + | |
| 4817 | + | |
| 4818 | + | |
| 4819 | + | |
| 4820 | + | |
| 4821 | + | |
| 4822 | + | |
| 4823 | + | |
| 4824 | + | |
| 4825 | + | |
| 4826 | + | |
| 4827 | + | |
| 4828 | + | |
| 4829 | + | |
| 4830 | + | |
| 4831 | + | |
| 4832 | + | |
| 4833 | + | |
| 4834 | + | |
| 4835 | + | |
| 4836 | + | |
| 4837 | + | |
| 4838 | + | |
| 4839 | + | |
| 4840 | + | |
| 4841 | + | |
| 4842 | + | |
4799 | 4843 | | |
4800 | 4844 | | |
4801 | 4845 | | |
| |||
4808 | 4852 | | |
4809 | 4853 | | |
4810 | 4854 | | |
4811 | | - | |
| 4855 | + | |
| 4856 | + | |
| 4857 | + | |
| 4858 | + | |
| 4859 | + | |
| 4860 | + | |
| 4861 | + | |
| 4862 | + | |
| 4863 | + | |
| 4864 | + | |
4812 | 4865 | | |
4813 | 4866 | | |
4814 | | - | |
4815 | 4867 | | |
4816 | 4868 | | |
| 4869 | + | |
| 4870 | + | |
| 4871 | + | |
| 4872 | + | |
| 4873 | + | |
| 4874 | + | |
| 4875 | + | |
| 4876 | + | |
| 4877 | + | |
| 4878 | + | |
| 4879 | + | |
| 4880 | + | |
| 4881 | + | |
| 4882 | + | |
| 4883 | + | |
| 4884 | + | |
| 4885 | + | |
| 4886 | + | |
| 4887 | + | |
| 4888 | + | |
| 4889 | + | |
| 4890 | + | |
| 4891 | + | |
| 4892 | + | |
| 4893 | + | |
| 4894 | + | |
| 4895 | + | |
| 4896 | + | |
| 4897 | + | |
| 4898 | + | |
| 4899 | + | |
| 4900 | + | |
| 4901 | + | |
| 4902 | + | |
| 4903 | + | |
| 4904 | + | |
| 4905 | + | |
| 4906 | + | |
| 4907 | + | |
| 4908 | + | |
| 4909 | + | |
| 4910 | + | |
| 4911 | + | |
| 4912 | + | |
| 4913 | + | |
4817 | 4914 | | |
4818 | 4915 | | |
4819 | 4916 | | |
| |||
0 commit comments