From 85ffe83ad7b6fb4dae1c25979898044ad1765b2e Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Wed, 23 Mar 2022 17:55:35 +0100 Subject: Fix '#include ' [#159] ... recently introduced in #1044 commit 35ca685200830626e5abd623f65a850649beace2 "macros: Add base functions to check for follow-set ambiguities". GCC doesn't like that: In file included from [...] ./mm_malloc.h:42:12: error: attempt to use poisoned "malloc" return malloc (__size); ^ See commit e7b3f654f2ab0400c95c0517387a9ad645a5c4cd, for example. --- gcc/rust/parse/rust-parse-impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/rust') diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 1d1b624..9e3a631 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -20,9 +20,9 @@ along with GCC; see the file COPYING3. If not see /* DO NOT INCLUDE ANYWHERE - this is automatically included with rust-parse.h * This is also the reason why there are no include guards. */ +#define INCLUDE_ALGORITHM #include "rust-diagnostics.h" #include "util/rust-make-unique.h" -#include namespace Rust { // Left binding powers of operations. -- cgit v1.1 From 7af3505c97388b227f1799a4805e21e3f4de4d4e Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Wed, 23 Mar 2022 18:29:21 +0100 Subject: For use as 'std::unordered_map' key, provide 'std::hash' for 'Rust::AST::MacroFragSpec::Kind' enum class ... recently introduced in #1044 commit 35ca685200830626e5abd623f65a850649beace2 "macros: Add base functions to check for follow-set ambiguities". Otherwise, at least with an oldish GCC 5.2, compilation of 'gcc/rust/parse/rust-parse.cc' fails noisily: In file included from [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/hashtable.h:35:0, from [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/unordered_map:47, from [GCC/Rust]/gcc/rust/rust-system.h:46, from [GCC/Rust]/gcc/rust/rust-linemap.h:12, from [GCC/Rust]/gcc/rust/lex/rust-lex.h:22, from [GCC/Rust]/gcc/rust/parse/rust-parse.h:20, from [GCC/Rust]/gcc/rust/parse/rust-parse.cc:17: [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/hashtable_policy.h: In instantiation of 'struct std::__detail::__is_noexcept_hash >': [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/type_traits:137:12: required from 'struct std::__and_ >, std::__detail::__is_noexcept_hash > >' [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/type_traits:148:38: required from 'struct std::__not_ >, std::__detail::__is_noexcept_hash > > >' [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/unordered_map.h:100:66: required from 'class std::unordered_map >' [GCC/Rust]/gcc/rust/parse/rust-parse.cc:101:5: required from here [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/hashtable_policy.h:85:34: error: no match for call to '(const std::hash) (const Rust::AST::MacroFragSpec::Kind&)' noexcept(declval()(declval()))> ^ In file included from [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/move.h:57:0, from [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/stl_pair.h:59, from [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/stl_algobase.h:64, from [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/char_traits.h:39, from [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/string:40, from [GCC/Rust]/gcc/rust/rust-system.h:34, from [GCC/Rust]/gcc/rust/rust-linemap.h:12, from [GCC/Rust]/gcc/rust/lex/rust-lex.h:22, from [GCC/Rust]/gcc/rust/parse/rust-parse.h:20, from [GCC/Rust]/gcc/rust/parse/rust-parse.cc:17: [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/type_traits: In instantiation of 'struct std::__not_ >, std::__detail::__is_noexcept_hash > > >': [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/unordered_map.h:100:66: required from 'class std::unordered_map >' [GCC/Rust]/gcc/rust/parse/rust-parse.cc:101:5: required from here [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/type_traits:148:38: error: 'value' is not a member of 'std::__and_ >, std::__detail::__is_noexcept_hash > >' : public integral_constant ^ In file included from [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/unordered_map:48:0, from [GCC/Rust]/gcc/rust/rust-system.h:46, from [GCC/Rust]/gcc/rust/rust-linemap.h:12, from [GCC/Rust]/gcc/rust/lex/rust-lex.h:22, from [GCC/Rust]/gcc/rust/parse/rust-parse.h:20, from [GCC/Rust]/gcc/rust/parse/rust-parse.cc:17: [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/unordered_map.h: In instantiation of 'class std::unordered_map >': [GCC/Rust]/gcc/rust/parse/rust-parse.cc:101:5: required from here [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/unordered_map.h:100:66: error: 'value' is not a member of 'std::__not_ >, std::__detail::__is_noexcept_hash > > >' typedef __umap_hashtable<_Key, _Tp, _Hash, _Pred, _Alloc> _Hashtable; ^ [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/unordered_map.h:107:45: error: 'value' is not a member of 'std::__not_ >, std::__detail::__is_noexcept_hash > > >' typedef typename _Hashtable::key_type key_type; ^ [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/unordered_map.h:108:47: error: 'value' is not a member of 'std::__not_ >, std::__detail::__is_noexcept_hash > > >' typedef typename _Hashtable::value_type value_type; ^ [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/unordered_map.h:109:48: error: 'value' is not a member of 'std::__not_ >, std::__detail::__is_noexcept_hash > > >' typedef typename _Hashtable::mapped_type mapped_type; ^ [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/unordered_map.h:110:43: error: 'value' is not a member of 'std::__not_ >, std::__detail::__is_noexcept_hash > > >' typedef typename _Hashtable::hasher hasher; ^ [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/unordered_map.h:111:46: error: 'value' is not a member of 'std::__not_ >, std::__detail::__is_noexcept_hash > > >' typedef typename _Hashtable::key_equal key_equal; ^ [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/unordered_map.h:112:51: error: 'value' is not a member of 'std::__not_ >, std::__detail::__is_noexcept_hash > > >' typedef typename _Hashtable::allocator_type allocator_type; ^ [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/unordered_map.h:117:45: error: 'value' is not a member of 'std::__not_ >, std::__detail::__is_noexcept_hash > > >' typedef typename _Hashtable::pointer pointer; ^ [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/unordered_map.h:118:50: error: 'value' is not a member of 'std::__not_ >, std::__detail::__is_noexcept_hash > > >' typedef typename _Hashtable::const_pointer const_pointer; ^ [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/unordered_map.h:119:47: error: 'value' is not a member of 'std::__not_ >, std::__detail::__is_noexcept_hash > > >' typedef typename _Hashtable::reference reference; ^ [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/unordered_map.h:120:52: error: 'value' is not a member of 'std::__not_ >, std::__detail::__is_noexcept_hash > > >' typedef typename _Hashtable::const_reference const_reference; ^ [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/unordered_map.h:121:46: error: 'value' is not a member of 'std::__not_ >, std::__detail::__is_noexcept_hash > > >' typedef typename _Hashtable::iterator iterator; ^ [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/unordered_map.h:122:51: error: 'value' is not a member of 'std::__not_ >, std::__detail::__is_noexcept_hash > > >' typedef typename _Hashtable::const_iterator const_iterator; ^ [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/unordered_map.h:123:51: error: 'value' is not a member of 'std::__not_ >, std::__detail::__is_noexcept_hash > > >' typedef typename _Hashtable::local_iterator local_iterator; ^ [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/unordered_map.h:124:57: error: 'value' is not a member of 'std::__not_ >, std::__detail::__is_noexcept_hash > > >' typedef typename _Hashtable::const_local_iterator const_local_iterator; ^ [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/unordered_map.h:125:47: error: 'value' is not a member of 'std::__not_ >, std::__detail::__is_noexcept_hash > > >' typedef typename _Hashtable::size_type size_type; ^ [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/unordered_map.h:126:52: error: 'value' is not a member of 'std::__not_ >, std::__detail::__is_noexcept_hash > > >' typedef typename _Hashtable::difference_type difference_type; ^ [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/unordered_map.h:280:7: error: 'value' is not a member of 'std::__not_ >, std::__detail::__is_noexcept_hash > > >' operator=(initializer_list __l) ^ [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/unordered_map.h:379:2: error: 'value' is not a member of 'std::__not_ >, std::__detail::__is_noexcept_hash > > >' emplace(_Args&&... __args) ^ [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/unordered_map.h:432:7: error: 'value' is not a member of 'std::__not_ >, std::__detail::__is_noexcept_hash > > >' insert(const value_type& __x) ^ [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/unordered_map.h:439:2: error: 'value' is not a member of 'std::__not_ >, std::__detail::__is_noexcept_hash > > >' insert(_Pair&& __x) ^ [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/unordered_map.h:499:7: error: 'value' is not a member of 'std::__not_ >, std::__detail::__is_noexcept_hash > > >' insert(initializer_list __l) ^ [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/unordered_map.h:645:7: error: 'value' is not a member of 'std::__not_ >, std::__detail::__is_noexcept_hash > > >' equal_range(const key_type& __x) ^ [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/unordered_map.h:649:7: error: 'value' is not a member of 'std::__not_ >, std::__detail::__is_noexcept_hash > > >' equal_range(const key_type& __x) const ^ [GCC/Rust]/gcc/rust/parse/rust-parse.cc: In function 'bool Rust::peculiar_fragment_match_compatible(Rust::AST::MacroMatchFragment&, Rust::AST::MacroMatch&)': [GCC/Rust]/gcc/rust/parse/rust-parse.cc:104:5: error: too many initializers for 'std::unordered_map >' }; ^ [GCC/Rust]/gcc/rust/parse/rust-parse.cc:119:16: error: no match for 'operator[]' (operand types are 'std::unordered_map >' and 'Rust::AST::MacroFragSpec::Kind') = follow_set[last_match.get_frag_spec ().get_kind ()]; ^ make[2]: *** [[GCC/Rust]/gcc/rust/Make-lang.in:299: rust/rust-parse.o] Error 1 --- gcc/rust/ast/rust-macro.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'gcc/rust') diff --git a/gcc/rust/ast/rust-macro.h b/gcc/rust/ast/rust-macro.h index 478d3ab..d13890a 100644 --- a/gcc/rust/ast/rust-macro.h +++ b/gcc/rust/ast/rust-macro.h @@ -906,4 +906,15 @@ private: } // namespace AST } // namespace Rust +/* */ +namespace std { +template <> struct hash +{ + size_t operator() (const Rust::AST::MacroFragSpec::Kind &t) const noexcept + { + return size_t (t); + } +}; +} // namespace std + #endif -- cgit v1.1