Refactor parser GCC diagnostic statements
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
#! /bin/bash
|
||||
#
|
||||
# Copyright by The HDF Group.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is part of HDF5. The full HDF5 copyright notice, including
|
||||
# terms governing use, modification, and redistribution, is contained in
|
||||
# Copyright by The HDF Group.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is part of HDF5. The full HDF5 copyright notice, including
|
||||
# terms governing use, modification, and redistribution, is contained in
|
||||
# the COPYING file, which can be found at the root of the source code
|
||||
# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
|
||||
# If you do not have access to either file, you may request a copy from
|
||||
@@ -204,8 +204,8 @@ ${HDF5_FLEX} --nounistd -PH5LTyy -o ${path_to_hl_src}/H5LTanalyze.c ${path_to_hl
|
||||
# instead of int. Currently the generated function H5LTyyparse is
|
||||
# generated with a return value of type int, which is a mapping to the
|
||||
# flex yyparse function. The return value in the HL library should be
|
||||
# an hid_t.
|
||||
# I propose to not use flex to generate this function, but for now I am
|
||||
# an hid_t.
|
||||
# I propose to not use flex to generate this function, but for now I am
|
||||
# adding a perl command to find and replace this function declaration in
|
||||
# H5LTparse.c.
|
||||
perl -0777 -pi -e 's/int yyparse/hid_t yyparse/igs' ${path_to_hl_src}/H5LTparse.c
|
||||
@@ -218,7 +218,8 @@ perl -0777 -pi -e 's/int H5LTyyparse/hid_t H5LTyyparse/igs' ${path_to_hl_src}/H5
|
||||
# will simply ignore them, but we want to avoid those warnings.
|
||||
for f in ${path_to_hl_src}/H5LTparse.c ${path_to_hl_src}/H5LTanalyze.c
|
||||
do
|
||||
echo '#if defined __GNUC__ && 402 <= __GNUC__ * 100 + __GNUC_MINOR__ ' >> tmp.out
|
||||
echo '#if defined (__GNUC__) ' >> tmp.out
|
||||
echo '#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402 ' >> tmp.out
|
||||
echo '#pragma GCC diagnostic ignored "-Wconversion" ' >> tmp.out
|
||||
echo '#pragma GCC diagnostic ignored "-Wimplicit-function-declaration" ' >> tmp.out
|
||||
echo '#pragma GCC diagnostic ignored "-Wlarger-than=" ' >> tmp.out
|
||||
@@ -230,11 +231,16 @@ do
|
||||
echo '#pragma GCC diagnostic ignored "-Wsign-conversion" ' >> tmp.out
|
||||
echo '#pragma GCC diagnostic ignored "-Wstrict-overflow" ' >> tmp.out
|
||||
echo '#pragma GCC diagnostic ignored "-Wstrict-prototypes" ' >> tmp.out
|
||||
echo '#pragma GCC diagnostic ignored "-Wsuggest-attribute=const" ' >> tmp.out
|
||||
echo '#pragma GCC diagnostic ignored "-Wsuggest-attribute=pure" ' >> tmp.out
|
||||
echo '#pragma GCC diagnostic ignored "-Wswitch-default" ' >> tmp.out
|
||||
echo '#pragma GCC diagnostic ignored "-Wunused-function" ' >> tmp.out
|
||||
echo '#pragma GCC diagnostic ignored "-Wunused-macros" ' >> tmp.out
|
||||
echo '#pragma GCC diagnostic ignored "-Wunused-parameter" ' >> tmp.out
|
||||
echo '#endif ' >> tmp.out
|
||||
echo '#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 600 ' >> tmp.out
|
||||
echo '#pragma GCC diagnostic ignored "-Wnull-dereference" ' >> tmp.out
|
||||
echo '#endif ' >> tmp.out
|
||||
echo '#elif defined __SUNPRO_CC ' >> tmp.out
|
||||
echo '#pragma disable_warn ' >> tmp.out
|
||||
echo '#elif defined _MSC_VER ' >> tmp.out
|
||||
|
||||
@@ -35,21 +35,29 @@ if (FILE_PARSE)
|
||||
# will simply ignore them, but we want to avoid those warnings.
|
||||
file (READ ${FILE_PARSE}.c TEST_STREAM)
|
||||
file (WRITE ${FILE_PARSE}.c "
|
||||
#if __GNUC__ >= 4 && __GNUC_MINOR__ >=2\n
|
||||
#if defined __GNUC__
|
||||
#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402\n
|
||||
#pragma GCC diagnostic ignored \"-Wconversion\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wimplicit-function-declaration\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wlarger-than=\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wmissing-prototypes\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wnested-externs\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wold-style-definition\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wredundant-decls\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wsign-compare\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wsign-conversion\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wstrict-overflow\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wsuggest-attribute=const\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wsuggest-attribute=pure\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wswitch-default\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wunused-function\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wunused-macros\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wunused-parameter\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wredundant-decls\"\n
|
||||
#endif\n
|
||||
#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 600\n
|
||||
#pragma GCC diagnostic ignored "-Wnull-dereference"\"\n
|
||||
#endif\n
|
||||
#elif defined __SUNPRO_CC\n
|
||||
#pragma disable_warn\n
|
||||
#elif defined _MSC_VER\n
|
||||
@@ -69,21 +77,29 @@ if (FILE_ANALYZE)
|
||||
# will simply ignore them, but we want to avoid those warnings.
|
||||
file (READ ${GEN_DIR}/${FILE_ANALYZE} TEST_STREAM)
|
||||
file (WRITE ${FILE_ANALYZE} "
|
||||
#if __GNUC__ >= 4 && __GNUC_MINOR__ >=2\n
|
||||
#if defined __GNUC__
|
||||
#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402\n
|
||||
#pragma GCC diagnostic ignored \"-Wconversion\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wimplicit-function-declaration\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wlarger-than=\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wmissing-prototypes\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wnested-externs\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wold-style-definition\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wredundant-decls\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wsign-compare\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wsign-conversion\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wstrict-overflow\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wsuggest-attribute=const\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wsuggest-attribute=pure\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wswitch-default\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wunused-function\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wunused-macros\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wunused-parameter\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wredundant-decls\"\n
|
||||
#endif\n
|
||||
#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 600\n
|
||||
#pragma GCC diagnostic ignored "-Wnull-dereference"\"\n
|
||||
#endif\n
|
||||
#elif defined __SUNPRO_CC\n
|
||||
#pragma disable_warn\n
|
||||
#elif defined _MSC_VER\n
|
||||
|
||||
@@ -23,18 +23,6 @@
|
||||
#include <hdf5.h>
|
||||
#include "H5LTparse.h"
|
||||
|
||||
/* Turn off suggest const & malloc attribute warnings in gcc */
|
||||
#if defined __GNUC__ && 402 <= __GNUC__ * 100 + __GNUC_MINOR__
|
||||
#pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
|
||||
#endif
|
||||
|
||||
/* Turn off null dereference warnings in gcc.
|
||||
* We have no control over this generated code.
|
||||
*/
|
||||
#if defined __GNUC__ && 600 <= __GNUC__ * 100
|
||||
#pragma GCC diagnostic ignored "-Wnull-dereference"
|
||||
#endif
|
||||
|
||||
int my_yyinput(char *, int);
|
||||
#undef YY_INPUT
|
||||
#define YY_INPUT(b, r, ms) (r=my_yyinput(b, ms))
|
||||
@@ -131,9 +119,9 @@ STRSIZE {return token(STRSIZE_TOKEN);}
|
||||
STRPAD {return token(STRPAD_TOKEN);}
|
||||
CSET {return token(CSET_TOKEN);}
|
||||
CTYPE {return token(CTYPE_TOKEN);}
|
||||
H5T_STR_NULLTERM {return token(H5T_STR_NULLTERM_TOKEN);}
|
||||
H5T_STR_NULLPAD {return token(H5T_STR_NULLPAD_TOKEN);}
|
||||
H5T_STR_SPACEPAD {return token(H5T_STR_SPACEPAD_TOKEN);}
|
||||
H5T_STR_NULLTERM {return token(H5T_STR_NULLTERM_TOKEN);}
|
||||
H5T_STR_NULLPAD {return token(H5T_STR_NULLPAD_TOKEN);}
|
||||
H5T_STR_SPACEPAD {return token(H5T_STR_SPACEPAD_TOKEN);}
|
||||
H5T_CSET_ASCII {return token(H5T_CSET_ASCII_TOKEN);}
|
||||
H5T_CSET_UTF8 {return token(H5T_CSET_UTF8_TOKEN);}
|
||||
H5T_C_S1 {return token(H5T_C_S1_TOKEN);}
|
||||
@@ -149,19 +137,19 @@ H5T_OPAQUE {return token(H5T_OPAQUE_TOKEN);}
|
||||
OPQ_SIZE {return token(OPQ_SIZE_TOKEN);}
|
||||
OPQ_TAG {return token(OPQ_TAG_TOKEN);}
|
||||
|
||||
[0-9]+ {
|
||||
if( is_str_size || (is_enum && is_enum_memb) ||
|
||||
[0-9]+ {
|
||||
if( is_str_size || (is_enum && is_enum_memb) ||
|
||||
is_opq_size || (asindex>-1 && arr_stack[asindex].is_dim) ||
|
||||
(csindex>-1 && cmpd_stack[csindex].is_field) ) {
|
||||
H5LTyylval.ival = atoi(yytext);
|
||||
return NUMBER;
|
||||
return NUMBER;
|
||||
} else
|
||||
REJECT;
|
||||
}
|
||||
|
||||
"\"" {
|
||||
/*if it's first quote, and is a compound field name or an enum symbol*/
|
||||
if((is_opq_tag || is_enum || (csindex>-1 && cmpd_stack[csindex].is_field))
|
||||
if((is_opq_tag || is_enum || (csindex>-1 && cmpd_stack[csindex].is_field))
|
||||
&& first_quote) {
|
||||
first_quote = 0;
|
||||
BEGIN TAG_STRING;
|
||||
@@ -178,7 +166,7 @@ OPQ_TAG {return token(OPQ_TAG_TOKEN);}
|
||||
BEGIN INITIAL;
|
||||
return STRING;
|
||||
}
|
||||
|
||||
|
||||
"{" {return token('{');}
|
||||
"}" {return token('}');}
|
||||
"[" {return token('[');}
|
||||
@@ -192,8 +180,8 @@ OPQ_TAG {return token(OPQ_TAG_TOKEN);}
|
||||
int my_yyinput(char *buf, int max_size)
|
||||
{
|
||||
int ret;
|
||||
|
||||
memcpy(buf, myinput, input_len);
|
||||
|
||||
memcpy(buf, myinput, input_len);
|
||||
ret = (int)input_len;
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user