Skip to content

Fix JerryScript build with clang-6.0 #2610

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

Merged

Conversation

DanielBallaSZTE
Copy link

@DanielBallaSZTE DanielBallaSZTE commented Nov 21, 2018

Clang-6.0 would throw the following error while building

jerryscript/jerry-core/api/jerry.c:1527:71: error: implicit conversion loses integer precision:
      'jerry_regexp_flags_t' to 'uint16_t' (aka 'unsigned short') [-Werror,-Wconversion]
  jerry_value_t ret_val = ecma_op_create_regexp_object (ecma_pattern, flags);

This patch fixes the issue.
Also change the jerry_create_regexp and jerry_create_regexp_sz functions' flags parameter to uint16_t since the values created with bitwise inclusive OR are not part of the enum.

JerryScript-DCO-1.0-Signed-off-by: Daniel Balla [email protected]

@akosthekiss akosthekiss added the api Related to the public API label Nov 22, 2018
jerry_value_t jerry_create_regexp (const jerry_char_t *pattern, jerry_regexp_flags_t flags);
jerry_value_t jerry_create_regexp_sz (const jerry_char_t *pattern, jerry_size_t pattern_size,
jerry_regexp_flags_t flags);
jerry_value_t jerry_create_regexp (const jerry_char_t *pattern, uint16_t flags);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reasion why this is limited to 16 bits? Usually this takes a register regardless of type. I would use a 32 bit value.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use a 32 bit value, however that would go way out of the scope of this patch.
In that case we must change everything related to ecma_op_create_regexp_object. I would like to leave it as it is in this patch, and create a follow up, that changes every related function's parameters to 32 bit values.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @DanielBallaSZTE is right here. The API mirrors the internals.

On the other hand, if the goal is to break away from the internals, then I'd suggest not to use a bitwidth-fixed (e.g., 32 bit) type, but a simple (unsigned?) int instead. Actually, that should be the fastest and easiest and most future-proof type on any machine.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akosthekiss Using an unsigned int requires you to cast it to unsigned short int (uint16_t) when calling the ecma_op_create_regexp_object. I already have a patch prepared that changes all the internal parameters to uint32_t, so I would like to leave it as an uint16_t for now and submit the patch if this one lands.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I was not pushing for a change here. I was only reflecting to @zherczeg 's proposal to change this to uint32_t. And my comment was that if we wanted a change (i.e., to have an API type that was different from the internal type) then we should go for a non-sized type.

jerry_value_t jerry_create_regexp (const jerry_char_t *pattern, jerry_regexp_flags_t flags);
jerry_value_t jerry_create_regexp_sz (const jerry_char_t *pattern, jerry_size_t pattern_size,
jerry_regexp_flags_t flags);
jerry_value_t jerry_create_regexp (const jerry_char_t *pattern, uint16_t flags);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @DanielBallaSZTE is right here. The API mirrors the internals.

On the other hand, if the goal is to break away from the internals, then I'd suggest not to use a bitwidth-fixed (e.g., 32 bit) type, but a simple (unsigned?) int instead. Actually, that should be the fastest and easiest and most future-proof type on any machine.

@akosthekiss
Copy link
Member

@DanielBallaSZTE ping (has this PR been abandoned?)

@DanielBallaSZTE
Copy link
Author

@akosthekiss Sorry, definitely not, had to work on something else, will update today with the changes, thanks for the ping!

Clang-6.0 would throw the following error while building

```
jerryscript/jerry-core/api/jerry.c:1527:71: error: implicit conversion loses integer precision:
      'jerry_regexp_flags_t' to 'uint16_t' (aka 'unsigned short') [-Werror,-Wconversion]
  jerry_value_t ret_val = ecma_op_create_regexp_object (ecma_pattern, flags);
```

This patch fixes the issue.
Also change the `jerry_create_regexp` and `jerry_create_regexp_sz` functions' `flags` parameter to `uint16_t` since the values created with `bitwise inclusive OR` are not part of the enum.

JerryScript-DCO-1.0-Signed-off-by: Daniel Balla [email protected]
Copy link
Member

@akosthekiss akosthekiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@zherczeg zherczeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zherczeg zherczeg merged commit 3ee7716 into jerryscript-project:master Jan 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Related to the public API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants