-
-
Notifications
You must be signed in to change notification settings - Fork 668
Fix 22384 - Add support for default values in C-style bitfields #22396
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
base: master
Are you sure you want to change the base?
Conversation
|
Thanks for your pull request and interest in making D better, @MadhurKumar004! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.
|
|
@MadhurKumar004 thanks for picking this up! 👍 |
27a9803 to
e4d0659
Compare
|
@ibuclaw Made the changes as you suggested |
e4d0659 to
4ab4fb4
Compare
|
@ibuclaw review please. |
ibuclaw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't comment on the backend part. Frontend looks ok, maybe just need more combinations of tests to ensure we don't start accepting invalid code.
If there's bitfield documentation on dlang.org, that requires updating too.
As this is a feature fix, would be best to include a changelog entry too.
Thanks!
4ab4fb4 to
7fffee9
Compare
|
@ibuclaw Thanks for the advice on test combination. Because of that i was able to fix couple of edge cases that were giving ICE. Also added the changelog and currently working on the dlang.org documentation. Will send a pr for that after this get merged. Please check and review |
compiler/src/dmd/parse.d
Outdated
| if (storage_class) | ||
| error("storage class not allowed for bitfield declaration"); | ||
| s = new AST.BitFieldDeclaration(loc, t, ident, width); | ||
| s = new AST.BitFieldDeclaration(width.loc, t, ident, width, _init); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rebase against current origin/master.
| s = new AST.BitFieldDeclaration(width.loc, t, ident, width, _init); | |
| s = new AST.BitFieldDeclaration(loc, t, ident, width, _init); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please expand on what you mean by Location is still wrong?
|
Front-end part LGTM. 👍 |
7fffee9 to
7e49e6f
Compare
ibuclaw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mind there are testsuite failures.
==============================
Test 'fail_compilation\biterrors.d' failed:
diff:
----
-fail_compilation\biterrors.d(103): Error: initializer not allowed for bitfield declaration
fail_compilation\biterrors.d(104): Error: storage class not allowed for bitfield declaration
----
==============================
Test 'fail_compilation\biterrors2.d' failed:
diff:
----
fail_compilation\biterrors2.d(100): Error: variable `biterrors2.a` - bitfield must be member of struct, union, or class
int a : 2;
- ^
+ ^
fail_compilation\biterrors2.d(104): Error: bitfield `b` has zero width
int b:0;
^
fail_compilation\biterrors2.d(105): Error: bitfield type `float` is not an integer type
float c:3;
- ^
+ ^
----
==============================
Test 'fail_compilation\fail22384.d' failed:
diff:
----
-fail_compilation\fail22384.d(21): Error: bitfield initializer `4294967295u` does not fit in 4 bits
-fail_compilation\fail22384.d(26): Error: bitfield initializer `E.B` does not fit in 2 bits
-fail_compilation\fail22384.d(30): Error: bitfield initializer `4` does not fit in 3 bits
-fail_compilation\fail22384.d(31): Error: bitfield initializer `65` does not fit in 7 bits
fail_compilation\fail22384.d(32): Error: bitfield `z` has zero width
fail_compilation\fail22384.d(36): Error: bitfield type `float` is not an integer type
fail_compilation\fail22384.d(36): Error: bitfield `f` has zero width
fail_compilation\fail22384.d(37): Error: bitfield type `float` is not an integer type
fail_compilation\fail22384.d(38): Error: bitfield type `float` is not an integer type
fail_compilation\fail22384.d(39): Error: bitfield type `float` is not an integer type
-fail_compilation\fail22384.d(43): Error: cannot implicitly convert expression `4.2F` of type `float` to `int`
fail_compilation\fail22384.d(45): Error: anonymous bitfield cannot be initialized
+fail_compilation\fail22384.d(21): Error: bitfield initializer `4294967295u` does not fit in 4 bits
+fail_compilation\fail22384.d(26): Error: bitfield initializer `E.B` does not fit in 2 bits
+fail_compilation\fail22384.d(30): Error: bitfield initializer `4` does not fit in 3 bits
+fail_compilation\fail22384.d(31): Error: bitfield initializer `65` does not fit in 7 bits
+fail_compilation\fail22384.d(43): Error: cannot implicitly convert expression `4.2F` of type `float` to `int`
fail_compilation\fail22384.d(46): Error: bitfield initializer `65` does not fit in 7 bits
fail_compilation\fail22384.d(47): Error: cannot implicitly convert expression `42` of type `int` to `bool`
----
This implements parsing, semantic analysis, and backend support for default initializers in bitfields. - Modified 'declaration.d' & 'parse.d' to parse assignment expressions after bitfield width. - Implemented semantic cheks in 'semantic2.d' using IntRange for bound validation. - Updated 'todt.d' to pack default values into the binary representation. - Added regression tests. - Added the changlog of the feature
509d399 to
e192afe
Compare
|
@ibuclaw fixed the testsuite failure , whitespace and the correct error message. Also can you please explain what you mean by location is still wrong? |
This implements parsing, semantic analysis, and backend support for default initializers in bitfields.