#define FNDECL_USED_AUTO(NODE) \
TREE_LANG_FLAG_2 (FUNCTION_DECL_CHECK (NODE))
+/* True if NODE is a builtin decl. */
+#define DECL_BUILTIN_P(NODE) \
+ (DECL_SOURCE_LOCATION(NODE) == BUILTINS_LOCATION)
+
/* Nonzero if NODE is a DECL which we know about but which has not
been explicitly declared, such as a built-in function or a friend
declared inside a class. In the latter case DECL_HIDDEN_FRIEND_P
/* Check for redeclaration and other discrepancies. */
if (TREE_CODE (olddecl) == FUNCTION_DECL
- && DECL_ARTIFICIAL (olddecl)
- /* A C++20 implicit friend operator== uses the normal path (94462). */
- && !DECL_HIDDEN_FRIEND_P (olddecl))
+ && DECL_BUILTIN_P (olddecl))
{
if (TREE_CODE (newdecl) != FUNCTION_DECL)
{
"declaration %q#D", newdecl, olddecl);
return NULL_TREE;
}
- else if (DECL_OMP_DECLARE_REDUCTION_P (olddecl))
- {
- gcc_assert (DECL_OMP_DECLARE_REDUCTION_P (newdecl));
- error_at (newdecl_loc,
- "redeclaration of %<pragma omp declare reduction%>");
- inform (olddecl_loc,
- "previous %<pragma omp declare reduction%> declaration");
- return error_mark_node;
- }
else if (!types_match)
{
/* Avoid warnings redeclaring built-ins which have not been
return error_mark_node;
}
}
+ else if (TREE_CODE (newdecl) == FUNCTION_DECL
+ && DECL_OMP_DECLARE_REDUCTION_P (newdecl))
+ {
+ /* OMP UDRs are never duplicates. */
+ gcc_assert (DECL_OMP_DECLARE_REDUCTION_P (olddecl));
+ error_at (newdecl_loc,
+ "redeclaration of %<pragma omp declare reduction%>");
+ inform (olddecl_loc,
+ "previous %<pragma omp declare reduction%> declaration");
+ return error_mark_node;
+ }
else if (TREE_CODE (newdecl) == FUNCTION_DECL
&& ((DECL_TEMPLATE_SPECIALIZATION (olddecl)
&& (!DECL_TEMPLATE_INFO (newdecl)
tree fn = OVL_FUNCTION (ovl);
gcc_checking_assert (DECL_ANTICIPATED (fn));
- if (DECL_HIDDEN_FRIEND_P (fn))
- return false;
+ if (DECL_BUILTIN_P (fn))
+ return true;
- return true;
+ return false;
}
/* BINDING records an existing declaration for a name in the current scope.
{
if (TREE_CODE (decl) == FUNCTION_DECL
|| (VAR_P (decl) && DECL_EXTERNAL (decl)))
- /* Make sure local externs are marked as such. */
+ /* Make sure local externs are marked as such. OMP UDRs really
+ are nested functions. */
gcc_checking_assert (DECL_LOCAL_DECL_P (decl)
- && DECL_NAMESPACE_SCOPE_P (decl));
+ && (DECL_NAMESPACE_SCOPE_P (decl)
+ || (TREE_CODE (decl) == FUNCTION_DECL
+ && DECL_OMP_DECLARE_REDUCTION_P (decl))));
if (!DECL_CONTEXT (decl)
/* When parsing the parameter list of a function declarator,
}
else if (old.using_p ())
continue; /* This is a using decl. */
- else if (old.hidden_p () && !DECL_HIDDEN_FRIEND_P (old_fn))
+ else if (old.hidden_p () && DECL_BUILTIN_P (old_fn))
continue; /* This is an anticipated builtin. */
else if (!matching_fn_p (new_fn, old_fn))
continue; /* Parameters do not match. */
if (current_function_decl)
{
block_scope = true;
- DECL_CONTEXT (fndecl) = global_namespace;
+ DECL_CONTEXT (fndecl) = current_function_decl;
DECL_LOCAL_DECL_P (fndecl) = true;
if (!processing_template_decl)
pushdecl (fndecl);
else
{
DECL_CONTEXT (fndecl) = current_namespace;
- pushdecl (fndecl);
+ tree d = pushdecl (fndecl);
+ /* We should never meet a matched duplicate decl. */
+ gcc_checking_assert (d == error_mark_node || d == fndecl);
}
if (!block_scope)
start_preparsed_function (fndecl, NULL_TREE, SF_PRE_PARSED);
else if (DECL_IMPLICIT_TYPEDEF_P (t))
/* We already did a pushtag. */;
else if (TREE_CODE (decl) == FUNCTION_DECL
- && DECL_OMP_DECLARE_REDUCTION_P (decl)
- && DECL_FUNCTION_SCOPE_P (pattern_decl))
+ && DECL_LOCAL_DECL_P (decl)
+ && DECL_OMP_DECLARE_REDUCTION_P (decl))
{
- /* We pretend this is regular local extern decl of
- a namespace-scope fn. Then we make it really
- local, it is a nested function. */
- gcc_checking_assert (DECL_LOCAL_DECL_P (decl));
- DECL_CONTEXT (decl) = global_namespace;
- pushdecl (decl);
DECL_CONTEXT (decl) = current_function_decl;
+ pushdecl (decl);
if (cp_check_omp_declare_reduction (decl))
instantiate_body (pattern_decl, args, decl, true);
}
declared, pretend it is not there at all. */
|| (TREE_CODE (target_bval) == FUNCTION_DECL
&& DECL_ANTICIPATED (target_bval)
- && !DECL_HIDDEN_FRIEND_P (target_bval)))
+ && DECL_BUILTIN_P (target_bval)))
binding->value = decl;
else if (TREE_CODE (target_bval) == TYPE_DECL
&& DECL_ARTIFICIAL (target_bval)