Skip to content

Commit f34d28c

Browse files
committed
Odin: fix coverity error in bison and flex
1 parent 461f853 commit f34d28c

File tree

2 files changed

+165
-7
lines changed

2 files changed

+165
-7
lines changed

ODIN_II/SRC/verilog_bison.y

Lines changed: 165 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ extern loc_t my_location;
4141

4242
void yyerror(const char *str){ delayed_error_message(PARSER, my_location, "error in parsing: (%s)\n",str);}
4343
int ieee_filter(int ieee_version, int return_type);
44+
std::string ieee_string(int return_type);
4445

4546
int yywrap(){ return 1;}
4647
int yylex(void);
@@ -941,7 +942,7 @@ var_signedness:
941942

942943
/**
943944
* This functions filters types based on the standard defined,
944-
**/
945+
*/
945946
int ieee_filter(int ieee_version, int return_type) {
946947

947948
switch(return_type) {
@@ -1064,7 +1065,7 @@ int ieee_filter(int ieee_version, int return_type) {
10641065
case vXNOR: //fallthrough
10651066
case vXOR: {
10661067
if(ieee_version < ieee_1995)
1067-
delayed_error_message(PARSER, my_location, "error in parsing: (%s) only exists in ieee 1995 or newer\n",return_type)
1068+
delayed_error_message(PARSER, my_location, "error in parsing: (%s) only exists in ieee 1995 or newer\n",ieee_string(return_type).c_str())
10681069
break;
10691070
}
10701071
case voASLEFT: //fallthrough
@@ -1083,7 +1084,7 @@ int ieee_filter(int ieee_version, int return_type) {
10831084
case vSIGNED: //fallthrough
10841085
case vUNSIGNED: {
10851086
if(ieee_version < ieee_2001_noconfig)
1086-
delayed_error_message(PARSER, my_location, "error in parsing: (%s) only exists in ieee 2001-noconfig or newer\n",return_type)
1087+
delayed_error_message(PARSER, my_location, "error in parsing: (%s) only exists in ieee 2001-noconfig or newer\n",ieee_string(return_type).c_str())
10871088
break;
10881089
}
10891090
case vCELL: //fallthrough
@@ -1097,25 +1098,183 @@ int ieee_filter(int ieee_version, int return_type) {
10971098
case vLIBRARY: //fallthrough
10981099
case vUSE: {
10991100
if(ieee_version < ieee_2001)
1100-
delayed_error_message(PARSER, my_location, "error in parsing: (%s) only exists in ieee 2001 or newer\n",return_type)
1101+
delayed_error_message(PARSER, my_location, "error in parsing: (%s) only exists in ieee 2001 or newer\n",ieee_string(return_type).c_str())
11011102
break;
11021103
}
11031104
case vUWIRE: {
11041105
if(ieee_version < ieee_2005)
1105-
delayed_error_message(PARSER, my_location, "error in parsing: (%s) only exists in ieee 2005 or newer\n",return_type)
1106+
delayed_error_message(PARSER, my_location, "error in parsing: (%s) only exists in ieee 2005 or newer\n",ieee_string(return_type).c_str())
11061107
break;
11071108
}
1108-
/* unsorted. TODO: actually sort these */
11091109
case vsCLOG2:
11101110
case vsUNSIGNED: //fallthrough
11111111
case vsSIGNED: //fallthrough
11121112
case vsFINISH: //fallthrough
11131113
case vsDISPLAY: //fallthrough
11141114
case vsFUNCTION: //fallthrough
1115+
/* unsorted. TODO: actually sort these */
1116+
break;
11151117
default: {
1118+
delayed_error_message(PARSER, my_location, "error in parsing: keyword index: %d is not a supported keyword.\n",return_type)
11161119
break;
11171120
}
11181121
}
11191122
return return_type;
11201123

11211124
}
1125+
1126+
std::string ieee_string(int return_type) {
1127+
1128+
switch(return_type) {
1129+
case vALWAYS: return "vALWAYS";
1130+
case vAND: return "vAND";
1131+
case vASSIGN: return "vASSIGN";
1132+
case vAUTOMATIC: return "vAUTOMATIC";
1133+
case vBEGIN: return "vBEGIN";
1134+
case vBUF: return "vBUF";
1135+
case vBUFIF0: return "vBUFIF0";
1136+
case vBUFIF1: return "vBUFIF1";
1137+
case vCASE: return "vCASE";
1138+
case vCASEX: return "vCASEX";
1139+
case vCASEZ: return "vCASEZ";
1140+
case vCELL: return "vCELL";
1141+
case vCMOS: return "vCMOS";
1142+
case vCONFIG: return "vCONFIG";
1143+
case vDEASSIGN: return "vDEASSIGN";
1144+
case vDEFAULT: return "vDEFAULT";
1145+
case vDEFPARAM: return "vDEFPARAM";
1146+
case vDESIGN: return "vDESIGN";
1147+
case vDISABLE: return "vDISABLE";
1148+
case vEDGE: return "vEDGE";
1149+
case vELSE: return "vELSE";
1150+
case vEND: return "vEND";
1151+
case vENDCASE: return "vENDCASE";
1152+
case vENDCONFIG: return "vENDCONFIG";
1153+
case vENDFUNCTION: return "vENDFUNCTION";
1154+
case vENDGENERATE: return "vENDGENERATE";
1155+
case vENDMODULE: return "vENDMODULE";
1156+
case vENDPRIMITIVE: return "vENDPRIMITIVE";
1157+
case vENDSPECIFY: return "vENDSPECIFY";
1158+
case vENDTABLE: return "vENDTABLE";
1159+
case vENDTASK: return "vENDTASK";
1160+
case vEVENT: return "vEVENT";
1161+
case vFOR: return "vFOR";
1162+
case vFORCE: return "vFORCE";
1163+
case vFOREVER: return "vFOREVER";
1164+
case vFORK: return "vFORK";
1165+
case vFUNCTION: return "vFUNCTION";
1166+
case vGENERATE: return "vGENERATE";
1167+
case vGENVAR: return "vGENVAR";
1168+
case vHIGHZ0: return "vHIGHZ0";
1169+
case vHIGHZ1: return "vHIGHZ1";
1170+
case vIF: return "vIF";
1171+
case vINCDIR: return "vINCDIR";
1172+
case vINCLUDE: return "vINCLUDE";
1173+
case vINITIAL: return "vINITIAL";
1174+
case vINOUT: return "vINOUT";
1175+
case vINPUT: return "vINPUT";
1176+
case vINSTANCE: return "vINSTANCE";
1177+
case vINTEGER: return "vINTEGER";
1178+
case vJOIN: return "vJOIN";
1179+
case vLARGE: return "vLARGE";
1180+
case vLIBLIST: return "vLIBLIST";
1181+
case vLIBRARY: return "vLIBRARY";
1182+
case vLOCALPARAM: return "vLOCALPARAM";
1183+
case vMEDIUM: return "vMEDIUM";
1184+
case vMODULE: return "vMODULE";
1185+
case vNAND: return "vNAND";
1186+
case vNEGEDGE: return "vNEGEDGE";
1187+
case vNMOS: return "vNMOS";
1188+
case vNONE: return "vNONE";
1189+
case vNOR: return "vNOR";
1190+
case vNOSHOWCANCELLED: return "vNOSHOWCANCELLED";
1191+
case vNOT: return "vNOT";
1192+
case vNOTIF0: return "vNOTIF0";
1193+
case vNOTIF1: return "vNOTIF1";
1194+
case vOR: return "vOR";
1195+
case vOUTPUT: return "vOUTPUT";
1196+
case vPARAMETER: return "vPARAMETER";
1197+
case vPMOS: return "vPMOS";
1198+
case vPOSEDGE: return "vPOSEDGE";
1199+
case vPRIMITIVE: return "vPRIMITIVE";
1200+
case vPULL0: return "vPULL0";
1201+
case vPULL1: return "vPULL1";
1202+
case vPULLDOWN: return "vPULLDOWN";
1203+
case vPULLUP: return "vPULLUP";
1204+
case vPULSESTYLE_ONDETECT: return "vPULSESTYLE_ONDETECT";
1205+
case vPULSESTYLE_ONEVENT: return "vPULSESTYLE_ONEVENT";
1206+
case vRCMOS: return "vRCMOS";
1207+
case vREG: return "vREG";
1208+
case vRELEASE: return "vRELEASE";
1209+
case vREPEAT: return "vREPEAT";
1210+
case vRNMOS: return "vRNMOS";
1211+
case vRPMOS: return "vRPMOS";
1212+
case vRTRAN: return "vRTRAN";
1213+
case vRTRANIF0: return "vRTRANIF0";
1214+
case vRTRANIF1: return "vRTRANIF1";
1215+
case vSCALARED: return "vSCALARED";
1216+
case vSHOWCANCELLED: return "vSHOWCANCELLED";
1217+
case vSIGNED: return "vSIGNED";
1218+
case vSMALL: return "vSMALL";
1219+
case vSPECIFY: return "vSPECIFY";
1220+
case vSPECPARAM: return "vSPECPARAM";
1221+
case vSTRONG0: return "vSTRONG0";
1222+
case vSTRONG1: return "vSTRONG1";
1223+
case vSUPPLY0: return "vSUPPLY0";
1224+
case vSUPPLY1: return "vSUPPLY1";
1225+
case vTABLE: return "vTABLE";
1226+
case vTASK: return "vTASK";
1227+
case vTIME: return "vTIME";
1228+
case vTRAN: return "vTRAN";
1229+
case vTRANIF0: return "vTRANIF0";
1230+
case vTRANIF1: return "vTRANIF1";
1231+
case vTRI0: return "vTRI0";
1232+
case vTRI1: return "vTRI1";
1233+
case vTRI: return "vTRI";
1234+
case vTRIAND: return "vTRIAND";
1235+
case vTRIOR: return "vTRIOR";
1236+
case vTRIREG: return "vTRIREG";
1237+
case vUNSIGNED: return "vUNSIGNED";
1238+
case vUSE: return "vUSE";
1239+
case vUWIRE: return "vUWIRE";
1240+
case vVECTORED: return "vVECTORED";
1241+
case vWAIT: return "vWAIT";
1242+
case vWAND: return "vWAND";
1243+
case vWEAK0: return "vWEAK0";
1244+
case vWEAK1: return "vWEAK1";
1245+
case vWHILE: return "vWHILE";
1246+
case vWIRE: return "vWIRE";
1247+
case vWOR: return "vWOR";
1248+
case vXNOR: return "vXNOR";
1249+
case vXOR: return "vXOR";
1250+
case voANDAND: return "voANDAND";
1251+
case voANDANDAND: return "voANDANDAND";
1252+
case voASLEFT: return "voASLEFT";
1253+
case voASRIGHT: return "voASRIGHT";
1254+
case voCASEEQUAL: return "voCASEEQUAL";
1255+
case voCASENOTEQUAL: return "voCASENOTEQUAL";
1256+
case voEGT: return "voEGT";
1257+
case voEQUAL: return "voEQUAL";
1258+
case voGTE: return "voGTE";
1259+
case voLTE: return "voLTE";
1260+
case voMINUSCOLON: return "voMINUSCOLON";
1261+
case voNAND: return "voNAND";
1262+
case voNOR: return "voNOR";
1263+
case voNOTEQUAL: return "voNOTEQUAL";
1264+
case voOROR: return "voOROR";
1265+
case voPLUSCOLON: return "voPLUSCOLON";
1266+
case voPOWER: return "voPOWER";
1267+
case voSLEFT: return "voSLEFT";
1268+
case voSRIGHT: return "voSRIGHT";
1269+
case voXNOR: return "voXNOR";
1270+
case vsCLOG2: return "vsCLOG2";
1271+
case vsDISPLAY: return "vsDISPLAY";
1272+
case vsFINISH: return "vsFINISH";
1273+
case vsFUNCTION: return "vsFUNCTION";
1274+
case vsSIGNED: return "vsSIGNED";
1275+
case vsUNSIGNED: return "vsUNSIGNED";
1276+
default: break;
1277+
}
1278+
return "";
1279+
}
1280+

ODIN_II/SRC/verilog_flex.l

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,6 @@ vPUNCT [\?\:\|\^\&\<\>\-\*\/\%\(\)\{\}\[\]\~\!\;\#\,\.\@\=\+]
340340
<INITIAL>"trior" { MP(); return ieee_filter(vTRIOR); }
341341
<INITIAL>"trireg" { MP(); return ieee_filter(vTRIREG); }
342342
<INITIAL>"uwire" { MP(); return ieee_filter(vUWIRE); }
343-
<INITIAL>"uwire" { MP(); return ieee_filter(vUWIRE); }
344343
<INITIAL>"none" { MP(); return ieee_filter(vNONE); }
345344
<INITIAL>"reg" { MP(); return ieee_filter(vREG); }
346345

0 commit comments

Comments
 (0)