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

Incorrect Parsing of Floating Point Literals #253

Closed
SethPoulsen opened this issue Apr 19, 2018 · 4 comments
Closed

Incorrect Parsing of Floating Point Literals #253

SethPoulsen opened this issue Apr 19, 2018 · 4 comments

Comments

@SethPoulsen
Copy link
Contributor

Currently, the floating point literal

double f = 4.5;

is parsed to

Decl: f, [], [], []
  TypeDecl: f, []
    IdentifierType: ['double']
  Constant: float, 4.5

when really, the type attribute of the Constant node should be "double". Likewise,

double f = 4.5L;

is parsed to

Decl: f, [], [], []
  TypeDecl: f, []
    IdentifierType: ['double']
  Constant: float, 4.5L

when the type attribute of the Constant node should be "long double". Note that the declared type is not what matters, it is the parsing of the floating point literal.

@eliben
Copy link
Owner

eliben commented Apr 22, 2018

Good point! Feel free to submit a PR

eliben pushed a commit that referenced this issue Aug 31, 2018
* Corrects the type attribute of a constant node when parsing doubles. This sets the type attribute to either 'float', 'long double' or 'double' depending on if 'f|F', 'l|L' or '' is specified at the end of the constant definition.

* Add tests for previous changes.
@eliben
Copy link
Owner

eliben commented Aug 31, 2018

Fixed by #277

@eliben eliben closed this as completed Aug 31, 2018
@jam1garner
Copy link

Thanks for properly naming the commits/PR @robbert-harms, it made it much easier to find what caused my compiler to break upon installing on another machine (and therefore getting a new version of pycparser)!

@Sparika
Copy link

Sparika commented May 2, 2019

It seems that the case for long int is not handled either.

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

4 participants