Skip to content

Commit

Permalink
Warning fixes.
Browse files Browse the repository at this point in the history
ISO C99 doesn’t support unnamed structs/unions.
Comparison of distinct pointer types lacks a cast.
Dereferencing type-punned pointer will break strict-aliasing rules.
Type of bit-field ‘ext’ is a GCC extension.

JerryScript-DCO-1.0-Signed-off-by: Robert Sipka [email protected]
  • Loading branch information
robertsipka committed Feb 16, 2016
1 parent 7dc0658 commit 80811c8
Show file tree
Hide file tree
Showing 22 changed files with 149 additions and 144 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ project (Jerry C ASM)
endforeach()
endmacro()

add_jerry_compile_warnings(all extra format-nonliteral init-self conversion sign-conversion format-security missing-declarations)
add_jerry_compile_flags(-pedantic -Wno-stack-protector -Wno-attributes)
add_jerry_compile_warnings(all extra format-nonliteral init-self conversion sign-conversion format-security missing-declarations pedantic)
add_jerry_compile_flags(-Wno-stack-protector -Wno-attributes)
if(CMAKE_COMPILER_IS_GNUCC)
add_jerry_compile_warnings(logical-op)
else()
Expand Down
18 changes: 9 additions & 9 deletions jerry-core/ecma/base/ecma-globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ typedef enum
*/
typedef struct
{
mem_cpointer_t getter_p : ECMA_POINTER_FIELD_WIDTH; /**< pointer to getter object */
mem_cpointer_t setter_p : ECMA_POINTER_FIELD_WIDTH; /**< pointer to setter object */
__extension__ mem_cpointer_t getter_p : ECMA_POINTER_FIELD_WIDTH; /**< pointer to getter object */
__extension__ mem_cpointer_t setter_p : ECMA_POINTER_FIELD_WIDTH; /**< pointer to setter object */
} ecma_getter_setter_pointers_t;

/**
Expand All @@ -307,7 +307,7 @@ typedef struct __attr_packed___ ecma_property_t
unsigned int type : 2;

/** Compressed pointer to next property */
mem_cpointer_t next_property_p : ECMA_POINTER_FIELD_WIDTH;
__extension__ mem_cpointer_t next_property_p : ECMA_POINTER_FIELD_WIDTH;

/** Property's details (depending on Type) */
union
Expand All @@ -316,10 +316,10 @@ typedef struct __attr_packed___ ecma_property_t
struct __attr_packed___ ecma_named_data_property_t
{
/** Value */
ecma_value_t value : ECMA_VALUE_SIZE;
__extension__ ecma_value_t value : ECMA_VALUE_SIZE;

/** Compressed pointer to property's name (pointer to String) */
mem_cpointer_t name_p : ECMA_POINTER_FIELD_WIDTH;
__extension__ mem_cpointer_t name_p : ECMA_POINTER_FIELD_WIDTH;

/** Flag indicating whether the property is registered in LCache */
unsigned int is_lcached : 1;
Expand All @@ -338,7 +338,7 @@ typedef struct __attr_packed___ ecma_property_t
struct __attr_packed___ ecma_named_accessor_property_t
{
/** Compressed pointer to property's name (pointer to String) */
mem_cpointer_t name_p : ECMA_POINTER_FIELD_WIDTH;
__extension__ mem_cpointer_t name_p : ECMA_POINTER_FIELD_WIDTH;

/** Attribute 'Enumerable' (ecma_property_enumerable_value_t) */
unsigned int enumerable : 1;
Expand All @@ -350,7 +350,7 @@ typedef struct __attr_packed___ ecma_property_t
unsigned int is_lcached : 1;

/** Compressed pointer to pair of pointers - to property's getter and setter */
mem_cpointer_t getter_setter_pair_cp : ECMA_POINTER_FIELD_WIDTH;
__extension__ mem_cpointer_t getter_setter_pair_cp : ECMA_POINTER_FIELD_WIDTH;
} named_accessor_property;

/** Description of internal property */
Expand Down Expand Up @@ -795,10 +795,10 @@ typedef struct ecma_string_t
lit_cpointer_t lit_cp;

/** Compressed pointer to an ecma_collection_header_t */
mem_cpointer_t collection_cp : ECMA_POINTER_FIELD_WIDTH;
__extension__ mem_cpointer_t collection_cp : ECMA_POINTER_FIELD_WIDTH;

/** Compressed pointer to an ecma_number_t */
mem_cpointer_t number_cp : ECMA_POINTER_FIELD_WIDTH;
__extension__ mem_cpointer_t number_cp : ECMA_POINTER_FIELD_WIDTH;

/** UInt32-represented number placed locally in the descriptor */
uint32_t uint32_number;
Expand Down
2 changes: 1 addition & 1 deletion jerry-core/ecma/base/ecma-helpers-string.c
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ ecma_compare_ecma_strings_longpath (const ecma_string_t *string1_p, /* ecma-stri
{
case ECMA_STRING_CONTAINER_LIT_TABLE:
{
JERRY_ASSERT (string1_p->u.lit_cp.packed_value != string2_p->u.lit_cp.packed_value);
JERRY_ASSERT (string1_p->u.lit_cp.u.packed_value != string2_p->u.lit_cp.u.packed_value);
return false;
}
case ECMA_STRING_CONTAINER_MAGIC_STRING:
Expand Down
2 changes: 1 addition & 1 deletion jerry-core/ecma/base/ecma-helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -1388,7 +1388,7 @@ ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */

for (uint32_t i = const_literal_end; i < literal_end; i++)
{
mem_cpointer_t bytecode_cpointer = literal_start_p[i].value.base_cp;
mem_cpointer_t bytecode_cpointer = literal_start_p[i].u.value.base_cp;
ecma_compiled_code_t *bytecode_literal_p = ECMA_GET_NON_NULL_POINTER (ecma_compiled_code_t,
bytecode_cpointer);

Expand Down
2 changes: 1 addition & 1 deletion jerry-core/ecma/operations/ecma-objects-arguments.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ ecma_op_create_arguments_object (ecma_object_t *func_obj_p, /**< callee function
indx++)
{
// i.
if (literal_p[indx].packed_value == MEM_CP_NULL)
if (literal_p[indx].u.packed_value == MEM_CP_NULL)
{
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion jerry-core/ecma/operations/ecma-reference.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ typedef struct
ecma_value_t base;

/** referenced name */
mem_cpointer_t referenced_name_cp : ECMA_POINTER_FIELD_WIDTH;
__extension__ mem_cpointer_t referenced_name_cp : ECMA_POINTER_FIELD_WIDTH;

/** strict reference flag */
unsigned int is_strict : 1;
Expand Down
10 changes: 4 additions & 6 deletions jerry-core/jerry-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,10 @@ typedef struct jerry_api_value_t

uint32_t v_uint32; /**< number converted 32-bit unsigned integer */

union
{
jerry_api_string_t *v_string; /**< pointer to a JS string */
jerry_api_object_t *v_object; /**< pointer to a JS object */
};
};
jerry_api_string_t *v_string; /**< pointer to a JS string */
jerry_api_object_t *v_object; /**< pointer to a JS object */

} u;
} jerry_api_value_t;

/**
Expand Down
6 changes: 3 additions & 3 deletions jerry-core/jerry-snapshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ typedef struct
{
uint32_t last_compiled_code_offset; /**< offset of the last compiled code */
uint32_t lit_table_size; /**< size of literal table */
uint32_t is_run_global : 1; /**< flag, indicating whether the snapshot
* was dumped as 'Global scope'-mode code (true)
* or as eval-mode code (false) */
__extension__ uint32_t is_run_global : 1; /**< flag, indicating whether the snapshot
* was dumped as 'Global scope'-mode code (true)
* or as eval-mode code (false) */
} jerry_snapshot_header_t;

/**
Expand Down
Loading

0 comments on commit 80811c8

Please sign in to comment.