diff options
author | Alexandre Oliva <aoliva@redhat.com> | 2015-06-10 06:21:57 -0300 |
---|---|---|
committer | Alexandre Oliva <aoliva@redhat.com> | 2016-02-19 19:55:04 -0200 |
commit | 691f99ba64278f5c0b9365a79f1066c50faf73e2 (patch) | |
tree | 454fb01e18bf8410368138cf8df0fa09d63f5335 | |
parent | 20b1c33ea8b5ff8380bc1e65b996d8d49214cc6c (diff) | |
download | gcc-691f99ba64278f5c0b9365a79f1066c50faf73e2.tar.gz |
Fix build_constant for C++.
C++ wants CONST_DECLs to be used for enumerators only. Define a VAR_DECL
with a READONLY and STATIC flags, and let cp_finish_decl take care of the
initialization. Then introduce the declaration like other decls, removing
the only remaining use of pushdecl_safe, so the function is removed too.
-rw-r--r-- | libcc1/libcp1plugin.cc | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/libcc1/libcp1plugin.cc b/libcc1/libcp1plugin.cc index b0d1cb0faab..a25e851fa5f 100644 --- a/libcc1/libcp1plugin.cc +++ b/libcc1/libcp1plugin.cc @@ -153,22 +153,6 @@ struct string_hasher : typed_noop_remove<const char> -// A wrapper for pushdecl that doesn't let gdb have a chance to -// instantiate a symbol. - -static void -pushdecl_safe (tree decl) -{ - void (*save) (enum cp_oracle_request, tree identifier); - - save = cp_binding_oracle; - cp_binding_oracle = NULL; - pushdecl (decl); - cp_binding_oracle = save; -} - - - struct plugin_context : public cc1_plugin::connection { plugin_context (int fd); @@ -831,10 +815,14 @@ plugin_build_constant (cc1_plugin::connection *self, gcc_type type_in, tree type = convert_in (type_in); cst = build_int_cst (type, value); + if (!TYPE_READONLY (type)) + type = build_qualified_type (type, TYPE_QUAL_CONST); decl = build_decl (ctx->get_source_location (filename, line_number), - CONST_DECL, get_identifier (name), type); - DECL_INITIAL (decl) = cst; - pushdecl_safe (decl); + VAR_DECL, get_identifier (name), type); + TREE_STATIC (decl) = 1; + TREE_READONLY (decl) = 1; + cp_finish_decl (decl, cst, true, NULL, LOOKUP_ONLYCONVERTING); + pushdecl_maybe_friend (decl, false); return 1; } |