tree cleanup;
const char *asmspec = NULL;
int was_readonly = 0;
+ bool var_definition_p = false;
if (decl == error_mark_node)
return;
/* Remember that the initialization for this variable has
taken place. */
DECL_INITIALIZED_P (decl) = 1;
+ /* This declaration is the definition of this variable,
+ unless we are initializing a static data member within
+ the class specifier. */
+ if (!DECL_EXTERNAL (decl))
+ var_definition_p = true;
/* The variable is being defined, so determine its
visibility. */
determine_visibility (decl);
else if (!TREE_STATIC (decl))
initialize_local_var (decl, init);
}
-
- if (TREE_STATIC (decl))
- expand_static_init (decl, init);
- }
+
+ /* If a variable is defined, and then a subsequent
+ definintion with external linkage is encountered, we will
+ get here twice for the same variable. We want to avoid
+ calling expand_static_init more than once. For variables
+ that are not static data members, we can call
+ expand_static_init only when we actually process the
+ initializer. It is not legal to redeclare a static data
+ member, so this issue does not arise in that case. */
+ if (var_definition_p && TREE_STATIC (decl))
+ expand_static_init (decl, init);
+ }
}
/* If a CLEANUP_STMT was created to destroy a temporary bound to a