@@ -128,6 +128,10 @@ impl<'a> AsmParser<'a> {
128
128
// Are we dealing with a label marker?
129
129
// These are found at the start of a line and act as a target for branching instructions.
130
130
if raw_args[ 0 ] . starts_with ( ':' ) {
131
+ if raw_args[ 0 ] . len ( ) == 1 {
132
+ panic ! ( "invalid syntax - a label designator without a name!" ) ;
133
+ }
134
+
131
135
let ins = Instruction :: Label ( raw_args[ 0 ] . to_string ( ) ) ;
132
136
instructions. push ( ins) ;
133
137
continue ;
@@ -263,6 +267,10 @@ impl<'a> AsmParser<'a> {
263
267
// address at compile time. For now we'll use dummy values and keep track of the
264
268
// used labels for reference later.
265
269
if substring. starts_with ( ':' ) {
270
+ if substring. len ( ) == 1 {
271
+ panic ! ( "invalid syntax - a label designator without a name!" ) ;
272
+ }
273
+
266
274
self . labeled_instructions . insert ( i, substring. to_string ( ) ) ;
267
275
268
276
// We want to insert a dummy 32-bit address argument for now.
@@ -1029,6 +1037,8 @@ mod tests_asm_parsing {
1029
1037
false ,
1030
1038
"failed to correctly parse label instruction." ,
1031
1039
) ,
1040
+ ParserTest :: new ( ":" , & [ ] , true , "succeeded in parsing an empty label." ) ,
1041
+ ParserTest :: new ( "call :" , & [ ] , true , "succeeded in parsing an empty label." ) ,
1032
1042
] ;
1033
1043
1034
1044
ParserTests :: new ( & tests) . run_all ( ) ;
0 commit comments