gas: require an operand to .startof.()/.sizeof.()
[deliverable/binutils-gdb.git] / gas / expr.c
index 1cdd081322f3b291b55e187b9e1cd19917d2d4b9..6fc707b8a593eea0441568cf46e6cf7c14d71932 100644 (file)
@@ -1,5 +1,5 @@
 /* expr.c -operands, expressions-
-   Copyright (C) 1987-2016 Free Software Foundation, Inc.
+   Copyright (C) 1987-2017 Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
@@ -515,6 +515,14 @@ integer_constant (int radix, expressionS *expressionP)
   if (tc_allow_U_suffix && (c == 'U' || c == 'u'))
     c = * input_line_pointer++;
 
+#ifndef tc_allow_L_suffix
+#define tc_allow_L_suffix 1
+#endif
+  /* PR 20732: Look for, and ignore, a L or LL suffix to the number.  */
+  if (tc_allow_L_suffix)
+    while (c == 'L' || c == 'l')
+      c = * input_line_pointer++;
+
   if (small)
     {
       /* Here with number, in correct radix. c is the next char.
@@ -1146,6 +1154,10 @@ operand (expressionS *expressionP, enum expr_mode mode)
                   || input_line_pointer[1] == 'T');
          input_line_pointer += start ? 8 : 7;
          SKIP_WHITESPACE ();
+
+         /* Cover for the as_bad () invocations below.  */
+         expressionP->X_op = O_absent;
+
          if (*input_line_pointer != '(')
            as_bad (_("syntax error in .startof. or .sizeof."));
          else
@@ -1155,6 +1167,16 @@ operand (expressionS *expressionP, enum expr_mode mode)
              ++input_line_pointer;
              SKIP_WHITESPACE ();
              c = get_symbol_name (& name);
+             if (! *name)
+               {
+                 as_bad (_("expected symbol name"));
+                 (void) restore_line_pointer (c);
+                 if (c != ')')
+                   ignore_rest_of_line ();
+                 else
+                   ++input_line_pointer;
+                 break;
+               }
 
              buf = concat (start ? ".startof." : ".sizeof.", name,
                            (char *) NULL);
@@ -1298,6 +1320,14 @@ operand (expressionS *expressionP, enum expr_mode mode)
              SKIP_WHITESPACE_AFTER_NAME ();
 
              c = get_symbol_name (& name);
+             if (! *name)
+               {
+                 as_bad (_("expected symbol name"));
+                 expressionP->X_op = O_absent;
+                 (void) restore_line_pointer (c);
+                 ignore_rest_of_line ();
+                 break;
+               }
 
              buf = concat (start ? ".startof." : ".sizeof.", name,
                            (char *) NULL);
@@ -1363,7 +1393,7 @@ operand (expressionS *expressionP, enum expr_mode mode)
   /* It is more 'efficient' to clean up the expressionS when they are
      created.  Doing it here saves lines of code.  */
   clean_up_expression (expressionP);
-  SKIP_WHITESPACE ();          /* -> 1st char after operand.  */
+  SKIP_ALL_WHITESPACE ();              /* -> 1st char after operand.  */
   know (*input_line_pointer != ' ');
 
   /* The PA port needs this information.  */
This page took 0.024626 seconds and 4 git commands to generate.