/* An approximation for now, so we can tell this is a function-scope tag.
This will be updated in pop_scope. */
TYPE_CONTEXT (type) = DECL_CONTEXT (TYPE_STUB_DECL (type));
+
+ if (warn_cxx_compat && name != NULL_TREE)
+ {
+ struct c_binding *b = I_SYMBOL_BINDING (name);
+
+ if (b != NULL
+ && b->decl != NULL_TREE
+ && TREE_CODE (b->decl) == TYPE_DECL
+ && (B_IN_CURRENT_SCOPE (b)
+ || (current_scope == file_scope && B_IN_EXTERNAL_SCOPE (b)))
+ && (TYPE_MAIN_VARIANT (TREE_TYPE (b->decl))
+ != TYPE_MAIN_VARIANT (type)))
+ {
+ warning_at (loc, OPT_Wc___compat,
+ ("using %qD as both a typedef and a tag is "
+ "invalid in C++"),
+ b->decl);
+ if (b->locus != UNKNOWN_LOCATION)
+ inform (b->locus, "originally defined here");
+ }
+ }
}
\f
/* Subroutine of compare_decls. Allow harmless mismatches in return
bool bitfield = width != NULL;
tree element_type;
struct c_arg_info *arg_info = 0;
+ const char *errmsg;
tree expr_dummy;
bool expr_const_operands_dummy;
error ("type name declared as function returning an array");
type = integer_type_node;
}
+ errmsg = targetm.invalid_return_type (type);
+ if (errmsg)
+ {
+ error (errmsg);
+ type = integer_type_node;
+ }
/* Construct the function type and go to the next
inner layer of declarator. */
C_TYPEDEF_EXPLICITLY_SIGNED (decl) = 1;
if (declspecs->inline_p)
pedwarn (input_location, 0,"typedef %q+D declared %<inline%>", decl);
+
+ if (warn_cxx_compat && declarator->u.id != NULL_TREE)
+ {
+ struct c_binding *b = I_TAG_BINDING (declarator->u.id);
+
+ if (b != NULL
+ && b->decl != NULL_TREE
+ && (B_IN_CURRENT_SCOPE (b)
+ || (current_scope == file_scope && B_IN_EXTERNAL_SCOPE (b)))
+ && TYPE_MAIN_VARIANT (b->decl) != TYPE_MAIN_VARIANT (type))
+ {
+ warning_at (declarator->id_loc, OPT_Wc___compat,
+ ("using %qD as both a typedef and a tag is "
+ "invalid in C++"),
+ decl);
+ if (b->locus != UNKNOWN_LOCATION)
+ inform (b->locus, "originally defined here");
+ }
+ }
+
return decl;
}
{
tree parm, type, typelt;
unsigned int parmno;
+ const char *errmsg;
/* If there is a parameter of incomplete type in a definition,
this is an error. In a declaration this is valid, and a
}
}
+ errmsg = targetm.invalid_parameter_type (type);
+ if (errmsg)
+ {
+ error (errmsg);
+ TREE_VALUE (typelt) = error_mark_node;
+ TREE_TYPE (parm) = error_mark_node;
+ }
+
if (DECL_NAME (parm) && TREE_USED (parm))
warn_if_shadowing (parm);
}