Commit 295a422
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 9062977 commit 295a422
1 file changed
+108
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1287 | 1287 | | |
1288 | 1288 | | |
1289 | 1289 | | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
1290 | 1296 | | |
1291 | 1297 | | |
1292 | 1298 | | |
| |||
4917 | 4923 | | |
4918 | 4924 | | |
4919 | 4925 | | |
| 4926 | + | |
| 4927 | + | |
| 4928 | + | |
| 4929 | + | |
| 4930 | + | |
| 4931 | + | |
| 4932 | + | |
| 4933 | + | |
| 4934 | + | |
| 4935 | + | |
| 4936 | + | |
| 4937 | + | |
| 4938 | + | |
| 4939 | + | |
| 4940 | + | |
| 4941 | + | |
| 4942 | + | |
| 4943 | + | |
| 4944 | + | |
| 4945 | + | |
| 4946 | + | |
| 4947 | + | |
| 4948 | + | |
| 4949 | + | |
| 4950 | + | |
| 4951 | + | |
| 4952 | + | |
| 4953 | + | |
| 4954 | + | |
| 4955 | + | |
| 4956 | + | |
| 4957 | + | |
| 4958 | + | |
| 4959 | + | |
| 4960 | + | |
| 4961 | + | |
| 4962 | + | |
| 4963 | + | |
| 4964 | + | |
| 4965 | + | |
| 4966 | + | |
| 4967 | + | |
| 4968 | + | |
4920 | 4969 | | |
4921 | 4970 | | |
4922 | 4971 | | |
| |||
4929 | 4978 | | |
4930 | 4979 | | |
4931 | 4980 | | |
4932 | | - | |
| 4981 | + | |
| 4982 | + | |
| 4983 | + | |
| 4984 | + | |
| 4985 | + | |
| 4986 | + | |
| 4987 | + | |
| 4988 | + | |
| 4989 | + | |
| 4990 | + | |
4933 | 4991 | | |
4934 | 4992 | | |
4935 | | - | |
4936 | 4993 | | |
4937 | 4994 | | |
| 4995 | + | |
| 4996 | + | |
| 4997 | + | |
| 4998 | + | |
| 4999 | + | |
| 5000 | + | |
| 5001 | + | |
| 5002 | + | |
| 5003 | + | |
| 5004 | + | |
| 5005 | + | |
| 5006 | + | |
| 5007 | + | |
| 5008 | + | |
| 5009 | + | |
| 5010 | + | |
| 5011 | + | |
| 5012 | + | |
| 5013 | + | |
| 5014 | + | |
| 5015 | + | |
| 5016 | + | |
| 5017 | + | |
| 5018 | + | |
| 5019 | + | |
| 5020 | + | |
| 5021 | + | |
| 5022 | + | |
| 5023 | + | |
| 5024 | + | |
| 5025 | + | |
| 5026 | + | |
| 5027 | + | |
| 5028 | + | |
| 5029 | + | |
| 5030 | + | |
| 5031 | + | |
| 5032 | + | |
| 5033 | + | |
| 5034 | + | |
| 5035 | + | |
| 5036 | + | |
| 5037 | + | |
| 5038 | + | |
| 5039 | + | |
| 5040 | + | |
| 5041 | + | |
| 5042 | + | |
| 5043 | + | |
4938 | 5044 | | |
4939 | 5045 | | |
4940 | 5046 | | |
| |||
0 commit comments