2019-11-22 Jakub Jelinek <jakub@redhat.com>
+ PR c/90677
+ * c-common.h (identifier_global_tag): Declare.
+ * c-format.c (get_pointer_to_named_type): Renamed to ...
+ (get_named_type): ... this. Use identifier_global_tag instead of
+ identifier_global_value, handle the return value being a TYPE_P.
+ (init_dynamic_diag_info): Adjust get_pointer_to_named_type callers
+ to call get_named_type instead. Formatting fixes.
+
Implement P1920R1, Missing feature-test macros 2017-2019.
* c-cppbuiltin.c (c_cpp_builtins): Bump __cpp_init_captures
and __cpp_generic_lambdas for -std=c++2a. Define
}
}
-/* 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 result = maybe_get_identifier (name))
{
- result = identifier_global_value (result);
+ result = identifier_global_tag (result);
if (result)
{
- if (TREE_CODE (result) != TYPE_DECL)
+ if (TYPE_P (result))
+ ;
+ else if (TREE_CODE (result) == TYPE_DECL)
+ result = TREE_TYPE (result);
+ else
{
error ("%qs is not defined as a type", name);
result = NULL_TREE;
}
- else
- result = TREE_TYPE (result);
}
+ return result;
}
else
- result = void_type_node;
- return result;
+ return void_type_node;
}
/* Determine the types of "tree" and "location_t" in the code being
an extra type level. */
if ((local_tree_type_node = maybe_get_identifier ("tree")))
{
- local_tree_type_node = identifier_global_value (local_tree_type_node);
+ local_tree_type_node
+ = identifier_global_value (local_tree_type_node);
if (local_tree_type_node)
{
if (TREE_CODE (local_tree_type_node) != TYPE_DECL)
{
error ("%<tree%> is not defined as a type");
- local_tree_type_node = 0;
+ local_tree_type_node = NULL_TREE;
}
else if (TREE_CODE (TREE_TYPE (local_tree_type_node))
!= POINTER_TYPE)
{
error ("%<tree%> is not defined as a pointer type");
- local_tree_type_node = 0;
+ local_tree_type_node = NULL_TREE;
}
else
- local_tree_type_node =
- TREE_TYPE (TREE_TYPE (local_tree_type_node));
+ local_tree_type_node
+ = TREE_TYPE (TREE_TYPE (local_tree_type_node));
}
}
else
/* Similar to the above but for gimple*. */
if (!local_gimple_ptr_node
|| local_gimple_ptr_node == void_type_node)
- local_gimple_ptr_node = get_pointer_to_named_type ("gimple");
+ local_gimple_ptr_node = get_named_type ("gimple");
/* Similar to the above but for cgraph_node*. */
if (!local_cgraph_node_ptr_node
|| local_cgraph_node_ptr_node == void_type_node)
- local_cgraph_node_ptr_node = get_pointer_to_named_type ("cgraph_node");
+ local_cgraph_node_ptr_node = get_named_type ("cgraph_node");
static tree hwi;