DeclSpec Spec;
Declaration Decl;
- int NeedStorage;
/* Check for empty statements */
if (CurTok.Tok == TOK_SEMI) {
continue;
}
- /* Check if we must reserve storage for the variable. We do
- * this if we don't had a storage class given ("int i") or
- * if the storage class is explicitly specified as static.
- * This means that "extern int i" will not get storage
- * allocated.
- */
- NeedStorage = (Spec.StorageClass & SC_TYPEDEF) == 0 &&
- ((Spec.Flags & DS_DEF_STORAGE) != 0 ||
- (Spec.StorageClass & (SC_STATIC | SC_EXTERN)) == SC_STATIC);
-
/* Read declarations for this type */
Entry = 0;
comma = 0;
break;
}
- /* Get the symbol flags */
- if (IsTypeFunc (Decl.Type)) {
- Decl.StorageClass |= SC_FUNC;
- } else if ((Decl.StorageClass & SC_TYPEDEF) == 0) {
- if ((Spec.Flags & DS_DEF_TYPE) != 0 && IS_Get (&Standard) >= STD_C99) {
- Warning ("Implicit `int' is an obsolete feature");
- }
- if (NeedStorage) {
- /* We will allocate storage, variable is defined */
- Decl.StorageClass |= SC_STORAGE | SC_DEF;
- }
+ /* Check if we must reserve storage for the variable. We do this,
+ * if it is not a typedef or function, if we don't had a storage
+ * class given ("int i") or if the storage class is explicitly
+ * specified as static. This means that "extern int i" will not
+ * get storage allocated.
+ */
+ if ((Decl.StorageClass & SC_FUNC) == 0 &&
+ (Decl.StorageClass & SC_TYPEDEF) == 0 &&
+ ((Spec.Flags & DS_DEF_STORAGE) != 0 ||
+ (Decl.StorageClass & (SC_STATIC | SC_EXTERN)) == SC_STATIC)) {
+
+ /* We will allocate storage */
+ Decl.StorageClass |= SC_STORAGE | SC_DEF;
}
/* Add an entry to the symbol table */
/* Fix any type qualifiers attached to an array type */
FixArrayQualifiers (D->Type);
+ /* If we have a function, add a special storage class */
+ if (IsTypeFunc (D->Type)) {
+ D->StorageClass |= SC_FUNC;
+ }
+
/* Check several things for function or function pointer types */
if (IsTypeFunc (D->Type) || IsTypeFuncPtr (D->Type)) {
}
+ /* For anthing that is not a function or typedef, check for an implicit
+ * int declaration.
+ */
+ if ((D->StorageClass & SC_FUNC) != SC_FUNC &&
+ (D->StorageClass & SC_TYPEDEF) != SC_TYPEDEF) {
+ /* If the standard was not set explicitly to C89, print a warning
+ * for variables with implicit int type.
+ */
+ if ((Spec->Flags & DS_DEF_TYPE) != 0 && IS_Get (&Standard) >= STD_C99) {
+ Warning ("Implicit `int' is an obsolete feature");
+ }
+ }
+
/* Check the size of the generated type */
if (!IsTypeFunc (D->Type) && !IsTypeVoid (D->Type)) {
unsigned Size = SizeOf (D->Type);
ParseDecl (Spec, &Decl, DM_NEED_IDENT);
/* Set the correct storage class for functions */
- if (IsTypeFunc (Decl.Type)) {
+ 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_FUNC | SC_EXTERN;
-
+ Decl.StorageClass |= SC_EXTERN;
}
/* If we don't have a name, this was flagged as an error earlier.
} else {
Internal ("Invalid storage class in ParseOneDecl: %04X", Decl.StorageClass);
}
-
- /* If the standard was not set explicitly to C89, print a warning
- * for variables with implicit int type.
- */
- if ((Spec->Flags & DS_DEF_TYPE) != 0 && IS_Get (&Standard) >= STD_C99) {
- Warning ("Implicit `int' is an obsolete feature");
- }
}
/* If the symbol is not marked as external, it will be defined now */