On 11/19/19 11:29 PM, Jakub Jelinek wrote:
Hi!
The following patch fixes build of older GCC releases with newer ones.
In GCC 4.6 and earlier, we had:
struct cgraph_node;
struct cgraph_node *cgraph_node (tree);
and that is something on which GCC 9+ code errors on if it sees any
__gcc_diag__ and similar attributes, because cgraph_node it wants to find is
not a type.
As older GCC releases don't have the __gcc_diag__ etc. attributes guarded on
no newer GCC releases, only on minimum GCC version that does support it,
I think we need to make sure we don't reject what older GCCs used to have.
The following patch does that. In addition, get_pointer_to_named_type
looked misnamed, because we actually aren't interested in getting gimple *
etc. type, but gimple.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk
and eventually 9 too?
2019-11-19 Jakub Jelinek <ja...@redhat.com>
PR c/90677
* c-format.c (get_pointer_to_named_type): Renamed to ...
(get_named_type): ... this. If result is FUNCTION_DECL for
cgraph_node, return cgraph_node from pointee of return type if
possible instead of emitting an error.
(init_dynamic_diag_info): Adjust get_pointer_to_named_type callers
to call get_named_type instead. Formatting fixes.
* c-c++-common/pr90677.c: New test.
--- gcc/c-family/c-format.c.jj 2019-10-05 09:35:12.917997709 +0200
+++ gcc/c-family/c-format.c 2019-11-19 13:05:10.113308578 +0100
@@ -4899,21 +4899,39 @@ init_dynamic_gfc_info (void)
}
}
-/* Lookup the type named NAME and return a pointer-to-NAME type if found.
- Otherwise, return void_type_node if NAME has not been used yet, or
NULL_TREE if
- NAME is not a type (issuing an error). */
+/* Lookup the type named NAME and return a NAME type if found.
+ Otherwise, return void_type_node if NAME has not been used yet,
+ or NULL_TREE if NAME is not a type (issuing an error). */
static tree
-get_pointer_to_named_type (const char *name)
+get_named_type (const char *name)
{
tree result;
- if ((result = maybe_get_identifier (name)))
+ if (tree id = maybe_get_identifier (name))
{
- result = identifier_global_value (result);
+ result = identifier_global_value (id);
I would think that get_named_type should find struct or enum names that
have been hidden by another declaration; that would fix this without
special-casing cgraph_node. For the C++ front-end, that would be
lookup_qualified_name (global_namespace, id, /*prefer_type*/2,
/*complain*/false)
Jason