+ /* Skip the '=' */
+ NextToken ();
+
+ /* Allow initialization of static vars */
+ Size = ParseInit (Decl->Type);
+
+ /* Mark the variable as referenced */
+ *SC |= SC_REF;
+
+ } else {
+
+ /* Get the size of the variable */
+ Size = SizeOf (Decl->Type);
+
+ /* Allocate a label and space for the variable in the BSS segment */
+ SymData = AllocStorage (g_usebss, Size);
+
+ }
+
+ /* Cannot allocate a variable of zero size */
+ if (Size == 0) {
+ Error ("Variable `%s' has unknown size", Decl->Ident);
+ }
+
+ /* Return the symbol data */
+ return SymData;
+}
+
+
+
+static void ParseOneDecl (const DeclSpec* Spec)
+/* Parse one variable declaration */
+{
+ unsigned SymData = 0; /* Symbol data (offset, label name, ...) */
+ Declaration Decl; /* Declaration data structure */
+
+
+ /* Read the declaration */
+ ParseDecl (Spec, &Decl, DM_NEED_IDENT);
+
+ /* Set the correct storage class for functions */
+ if ((Decl.StorageClass & SC_FUNC) == SC_FUNC) {
+ /* Function prototypes are always external */
+ if ((Decl.StorageClass & SC_EXTERN) == 0) {
+ Warning ("Function must be extern");
+ }
+ Decl.StorageClass |= SC_EXTERN;
+ }
+
+ /* If we don't have a name, this was flagged as an error earlier.
+ * To avoid problems later, use an anonymous name here.
+ */
+ if (Decl.Ident[0] == '\0') {
+ AnonName (Decl.Ident, "param");
+ }
+
+ /* Handle anything that needs storage (no functions, no typdefs) */
+ if ((Decl.StorageClass & SC_FUNC) != SC_FUNC &&
+ (Decl.StorageClass & SC_TYPEDEF) != SC_TYPEDEF) {
+
+ /* If we have a register variable, try to allocate a register and
+ * convert the declaration to "auto" if this is not possible.
+ */
+ int Reg = 0; /* Initialize to avoid gcc complains */
+ if ((Decl.StorageClass & SC_REGISTER) != 0 &&
+ (Reg = F_AllocRegVar (CurrentFunc, Decl.Type)) < 0) {
+ /* No space for this register variable, convert to auto */
+ Decl.StorageClass = (Decl.StorageClass & ~SC_REGISTER) | SC_AUTO;
+ }
+
+ /* Check the variable type */
+ if ((Decl.StorageClass & SC_REGISTER) == SC_REGISTER) {
+ /* Register variable */
+ SymData = ParseRegisterDecl (&Decl, &Decl.StorageClass, Reg);
+ } else if ((Decl.StorageClass & SC_AUTO) == SC_AUTO) {
+ /* Auto variable */
+ SymData = ParseAutoDecl (&Decl, &Decl.StorageClass);
+ } else if ((Decl.StorageClass & SC_EXTERN) == SC_EXTERN) {
+ /* External identifier - may not get initialized */
+ if (CurTok.Tok == TOK_ASSIGN) {
+ Error ("Cannot initialize externals");
+ }
+ SymData = 0;
+ } else if ((Decl.StorageClass & SC_STATIC) == SC_STATIC) {
+ /* Static variable */
+ SymData = ParseStaticDecl (&Decl, &Decl.StorageClass);
+ } else {
+ Internal ("Invalid storage class in ParseOneDecl: %04X", Decl.StorageClass);
+ }