-
-
Notifications
You must be signed in to change notification settings - Fork 320
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
Fix Issue with SConsCPPConditionalScanner misinterpreting ifdefs suffixed with L or UL [Alternate Implementation] #4629
Conversation
Changes: - Preserve non-integer literals that contain valid integer specifications. - Add binary integer specifications - Add octal integer specification - Zero (0) is considered an octal number - Add negative lookbehind/lookahead for number specifications (text is not word/token based) - Add method to evaluate constant expression for define constant expressions - Replace int conversion with constant evaluation expression - int conversion failed for hex numbers due to default base 10 [int(s)] vs unknown base [int(s, 0)] - Add additional tests
Add a blurb to release and changes.txt and we can merge this. |
Wouldn't it be sufficient though to test the regex's alone without parsing a file? Simplify? |
Modifying the regex revealed underlying issues with the implementation and the way the tests were written. The example in the description above has nothing to do with the regexes (i.e., there is no suffix) but is a manifestation of a failure to convert a hex string to integer without specifying the optional base. There are a number of issues and potential issues with the implementation that I need to write up. I'm guessing there is a sizable gap between how one thinks the code is working and how it actually works. The expression evaluation for #if is not recursive so only the first level of replacement is performed which may then yield another string that should be expanded. Depending on the way the test is written, that could result in the string effectively being considered "True". |
Many of the tests are for the |
Since none of these have been detected (or at least not reported) thus far in the wild. It's probably safe to assume that it's existing functionality (when used) has been sufficient for most. That said, improvements are always welcome, and as usual @jcbrill 's contributions are well thought out and implemented! Add and CHANGES/RELEASE and we'll get this one merged. |
Quick-and-dirty notes concerning implementation so they are not forgotten. Known/Potential issues and TODO items for
|
Looks good. Thanks! |
Thanks for the fix @jcbrill :) |
This PR is an alternate implementation of PR #4624 based on the discussion in #4623 and #4624.
PR #4624 fails 9 of the tests included in this PR.
This PR also fixes a bug with evaluating hex integer literals.
For example:
This reason is the int conversion fails and is using string
'0x0'
which evaluates true (non-empty string) as opposed to an integer literal of0
. The integer conversion was implemented asint(expansion)
rather thanint(expansion, 0)
.This PR replaces the integer conversion with a method to evaluate a constant expression.
Changes:
Contributor Checklist:
CHANGES.txt
andRELEASE.txt
(and read theREADME.rst
).