Remove compile_only_p langhook

Use DECL_EXTERNAL instead.
This commit is contained in:
Marek Polacek
2025-12-03 13:16:51 -05:00
parent c4ffa609e5
commit 7cd1018769
7 changed files with 7 additions and 23 deletions

View File

@@ -32,7 +32,6 @@ along with GCC; see the file COPYING3. If not see
#include "ipa-utils.h"
#include "except.h"
#include "gimplify.h"
#include "langhooks.h"
/* Context of record_reference. */
struct record_reference_ctx
@@ -368,8 +367,7 @@ pass_build_cgraph_edges::execute (function *fun)
if (VAR_P (decl)
&& (TREE_STATIC (decl) && !DECL_EXTERNAL (decl))
&& !DECL_HAS_VALUE_EXPR_P (decl)
&& TREE_TYPE (decl) != error_mark_node
&& !lang_hooks.compile_only_p (decl))
&& TREE_TYPE (decl) != error_mark_node)
varpool_node::finalize_decl (decl);
record_eh_tables (node, fun);

View File

@@ -122,8 +122,6 @@ extern tree cxx_simulate_record_decl (location_t, const char *,
#define LANG_HOOKS_EMITS_BEGIN_STMT true
#undef LANG_HOOKS_FINALIZE_EARLY_DEBUG
#define LANG_HOOKS_FINALIZE_EARLY_DEBUG c_common_finalize_early_debug
#undef LANG_HOOKS_COMPILE_ONLY_P
#define LANG_HOOKS_COMPILE_ONLY_P consteval_only_p
static const scoped_attribute_specs *const cp_objcp_attribute_table[] =
{

View File

@@ -8799,7 +8799,11 @@ make_rtl_for_nonlocal_decl (tree decl, tree init, const char* asmspec)
/* Don't output reflection variables. */
if (consteval_only_p (decl))
return;
{
/* Disable assemble_variable. */
DECL_EXTERNAL (decl) = true;
return;
}
/* We defer emission of local statics until the corresponding
DECL_EXPR is expanded. But with constexpr its function might never

View File

@@ -159,7 +159,6 @@ extern const char *lhd_get_sarif_source_language (const char *);
#define LANG_HOOKS_GET_SUBSTRING_LOCATION lhd_get_substring_location
#define LANG_HOOKS_FINALIZE_EARLY_DEBUG lhd_finalize_early_debug
#define LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE lhd_get_sarif_source_language
#define LANG_HOOKS_COMPILE_ONLY_P hook_bool_tree_false
/* Attribute hooks. */
#define LANG_HOOKS_ATTRIBUTE_TABLE
@@ -414,8 +413,7 @@ extern void lhd_end_section (void);
LANG_HOOKS_RUN_LANG_SELFTESTS, \
LANG_HOOKS_GET_SUBSTRING_LOCATION, \
LANG_HOOKS_FINALIZE_EARLY_DEBUG, \
LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE, \
LANG_HOOKS_COMPILE_ONLY_P \
LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE \
}
#endif /* GCC_LANG_HOOKS_DEF_H */

View File

@@ -674,11 +674,6 @@ struct lang_hooks
languages. */
const char *(*get_sarif_source_language) (const char *filename);
/* True if this tree should only exist at compile time and not be output
at all. This is true for C++ consteval-only types which should not make
it out of the front end. */
bool (*compile_only_p) (tree);
/* Whenever you add entries here, make sure you adjust langhooks-def.h
and langhooks.cc accordingly. */
};

View File

@@ -352,10 +352,6 @@ wrapup_global_declaration_2 (tree decl)
|| (VAR_P (decl) && DECL_HAS_VALUE_EXPR_P (decl)))
return false;
/* Compile-only variables are not to be written out. */
if (lang_hooks.compile_only_p (decl))
return false;
/* Don't write out static consts, unless we still need them.
We also keep static consts if not optimizing (for debugging),

View File

@@ -36,7 +36,6 @@ along with GCC; see the file COPYING3. If not see
#include "stringpool.h"
#include "attribs.h"
#include "tree-pass.h"
#include "langhooks.h"
const char * const tls_model_names[]={"none", "emulated",
"global-dynamic", "local-dynamic",
@@ -586,10 +585,6 @@ varpool_node::assemble_decl (void)
if (DECL_HARD_REGISTER (decl))
return false;
/* Compile-only variables may not be output. */
if (lang_hooks.compile_only_p (decl))
return false;
gcc_checking_assert (!TREE_ASM_WRITTEN (decl)
&& VAR_P (decl)
&& !DECL_HAS_VALUE_EXPR_P (decl));