Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anonymous bit fields in structures cause crashes due to duplicate name fields and supports merging multiple bit fields into one underlying type, such as unsigned int. #104

Open
tsingbx opened this issue Oct 18, 2024 · 1 comment

Comments

@tsingbx
Copy link

tsingbx commented Oct 18, 2024

_structs.txt

1、Supports merging multiple bit fields into one underlying type, such as unsigned int.
2、The ast file should not contain code that the compiler ignores. For example, #ifdef XXX code #endif. The code here should be ignored when XXX is not defined, and the ast file should not contain this code.

@luoliwoshang
Copy link
Owner

  • 刚刚去看了一下Bit field这块,虽然在这里表达看起来是从 invalidpc 共同组成一个unsigned short ,但实际上这几个是分开的,连续的位域定义可以省略前面的类型,所以这里从invalid开始到pc 都是unsigned short 类型的位域,那我们肯定是不能将其合并为同一个底层类型的

  • 而中间那个没名字的位置则是用于对齐位置的空域,不能访问,仅用作占位对齐

#define _STRUCT_FP_CONTROL	struct fp_control
_STRUCT_FP_CONTROL
{
    unsigned short		invalid	:1,
    				denorm	:1,
				zdiv	:1,
				ovrfl	:1,
				undfl	:1,
				precis	:1,
					:2,
				pc	:2,
#define FP_PREC_24B		0
#define	FP_PREC_53B		2
#define FP_PREC_64B		3
				rc	:2,
#define FP_RND_NEAR		0
#define FP_RND_DOWN		1
#define FP_RND_UP		2
#define FP_CHOP			3
				/*inf*/	:1,
					:3;
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants