to instantiation time is the comparison of underlying types. */
if (enumtype && TREE_CODE (enumtype) == ENUMERAL_TYPE)
{
- if (scoped_enum_p != SCOPED_ENUM_P (enumtype))
+ /* Attempt to set the declaring module. */
+ if (modules_p ())
{
+ tree decl = TYPE_NAME (enumtype);
+ if (!module_may_redeclare (decl))
+ {
+ auto_diagnostic_group d;
+ error ("cannot declare %qD in different module", decl);
+ inform (DECL_SOURCE_LOCATION (decl), "previously declared here");
+ enumtype = error_mark_node;
+ }
+ else
+ set_instantiating_module (decl);
+ }
+
+ if (enumtype == error_mark_node)
+ ;
+ else if (scoped_enum_p != SCOPED_ENUM_P (enumtype))
+ {
+ auto_diagnostic_group d;
error_at (input_location, "scoped/unscoped mismatch "
"in enum %q#T", enumtype);
inform (DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (enumtype)),
}
else if (ENUM_FIXED_UNDERLYING_TYPE_P (enumtype) != !! underlying_type)
{
+ auto_diagnostic_group d;
error_at (input_location, "underlying type mismatch "
"in enum %q#T", enumtype);
inform (DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (enumtype)),
&& !same_type_p (underlying_type,
ENUM_UNDERLYING_TYPE (enumtype)))
{
+ auto_diagnostic_group d;
error_at (input_location, "different underlying type "
"in enum %q#T", enumtype);
inform (DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (enumtype)),
"previous definition here");
underlying_type = NULL_TREE;
}
-
- if (modules_p ())
- {
- if (!module_may_redeclare (TYPE_NAME (enumtype)))
- {
- error ("cannot define %qD in different module",
- TYPE_NAME (enumtype));
- inform (DECL_SOURCE_LOCATION (TYPE_NAME (enumtype)),
- "declared here");
- enumtype = error_mark_node;
- }
- set_instantiating_module (TYPE_NAME (enumtype));
- }
}
if (!enumtype || TREE_CODE (enumtype) != ENUMERAL_TYPE