Skip to content

Commit 90f938c

Browse files
bors[bot]tschwinge
andauthored
Merge #1056 #1057
1056: Fix '#include <algorithm>' [#159] r=tschwinge a=tschwinge ... recently introduced in #1044 commit 35ca685 "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 e7b3f65, for example. 1057: For use as 'std::unordered_map' key, provide 'std::hash' for 'Rust::AST::MacroFragSpec::Kind' enum class r=tschwinge a=tschwinge ... recently introduced in #1044 commit 35ca685 "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<Rust::AST::MacroFragSpec::Kind, std::hash<Rust::AST::MacroFragSpec::Kind> >': [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/type_traits:137:12: required from 'struct std::__and_<std::__is_fast_hash<std::hash<Rust::AST::MacroFragSpec::Kind> >, std::__detail::__is_noexcept_hash<Rust::AST::MacroFragSpec::Kind, std::hash<Rust::AST::MacroFragSpec::Kind> > >' [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/type_traits:148:38: required from 'struct std::__not_<std::__and_<std::__is_fast_hash<std::hash<Rust::AST::MacroFragSpec::Kind> >, std::__detail::__is_noexcept_hash<Rust::AST::MacroFragSpec::Kind, std::hash<Rust::AST::MacroFragSpec::Kind> > > >' [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/unordered_map.h:100:66: required from 'class std::unordered_map<Rust::AST::MacroFragSpec::Kind, std::vector<Rust::TokenId> >' [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<Rust::AST::MacroFragSpec::Kind>) (const Rust::AST::MacroFragSpec::Kind&)' noexcept(declval<const _Hash&>()(declval<const _Key&>()))> ^ 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::__and_<std::__is_fast_hash<std::hash<Rust::AST::MacroFragSpec::Kind> >, std::__detail::__is_noexcept_hash<Rust::AST::MacroFragSpec::Kind, std::hash<Rust::AST::MacroFragSpec::Kind> > > >': [GCC]/i686-pc-linux-gnu/include/c++/5.2.0/bits/unordered_map.h:100:66: required from 'class std::unordered_map<Rust::AST::MacroFragSpec::Kind, std::vector<Rust::TokenId> >' [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::__is_fast_hash<std::hash<Rust::AST::MacroFragSpec::Kind> >, std::__detail::__is_noexcept_hash<Rust::AST::MacroFragSpec::Kind, std::hash<Rust::AST::MacroFragSpec::Kind> > >' : public integral_constant<bool, !_Pp::value> ^ 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<Rust::AST::MacroFragSpec::Kind, std::vector<Rust::TokenId> >': [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::__and_<std::__is_fast_hash<std::hash<Rust::AST::MacroFragSpec::Kind> >, std::__detail::__is_noexcept_hash<Rust::AST::MacroFragSpec::Kind, std::hash<Rust::AST::MacroFragSpec::Kind> > > >' 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::__and_<std::__is_fast_hash<std::hash<Rust::AST::MacroFragSpec::Kind> >, std::__detail::__is_noexcept_hash<Rust::AST::MacroFragSpec::Kind, std::hash<Rust::AST::MacroFragSpec::Kind> > > >' 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::__and_<std::__is_fast_hash<std::hash<Rust::AST::MacroFragSpec::Kind> >, std::__detail::__is_noexcept_hash<Rust::AST::MacroFragSpec::Kind, std::hash<Rust::AST::MacroFragSpec::Kind> > > >' 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::__and_<std::__is_fast_hash<std::hash<Rust::AST::MacroFragSpec::Kind> >, std::__detail::__is_noexcept_hash<Rust::AST::MacroFragSpec::Kind, std::hash<Rust::AST::MacroFragSpec::Kind> > > >' 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::__and_<std::__is_fast_hash<std::hash<Rust::AST::MacroFragSpec::Kind> >, std::__detail::__is_noexcept_hash<Rust::AST::MacroFragSpec::Kind, std::hash<Rust::AST::MacroFragSpec::Kind> > > >' 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::__and_<std::__is_fast_hash<std::hash<Rust::AST::MacroFragSpec::Kind> >, std::__detail::__is_noexcept_hash<Rust::AST::MacroFragSpec::Kind, std::hash<Rust::AST::MacroFragSpec::Kind> > > >' 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::__and_<std::__is_fast_hash<std::hash<Rust::AST::MacroFragSpec::Kind> >, std::__detail::__is_noexcept_hash<Rust::AST::MacroFragSpec::Kind, std::hash<Rust::AST::MacroFragSpec::Kind> > > >' 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::__and_<std::__is_fast_hash<std::hash<Rust::AST::MacroFragSpec::Kind> >, std::__detail::__is_noexcept_hash<Rust::AST::MacroFragSpec::Kind, std::hash<Rust::AST::MacroFragSpec::Kind> > > >' 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::__and_<std::__is_fast_hash<std::hash<Rust::AST::MacroFragSpec::Kind> >, std::__detail::__is_noexcept_hash<Rust::AST::MacroFragSpec::Kind, std::hash<Rust::AST::MacroFragSpec::Kind> > > >' 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::__and_<std::__is_fast_hash<std::hash<Rust::AST::MacroFragSpec::Kind> >, std::__detail::__is_noexcept_hash<Rust::AST::MacroFragSpec::Kind, std::hash<Rust::AST::MacroFragSpec::Kind> > > >' 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::__and_<std::__is_fast_hash<std::hash<Rust::AST::MacroFragSpec::Kind> >, std::__detail::__is_noexcept_hash<Rust::AST::MacroFragSpec::Kind, std::hash<Rust::AST::MacroFragSpec::Kind> > > >' 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::__and_<std::__is_fast_hash<std::hash<Rust::AST::MacroFragSpec::Kind> >, std::__detail::__is_noexcept_hash<Rust::AST::MacroFragSpec::Kind, std::hash<Rust::AST::MacroFragSpec::Kind> > > >' 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::__and_<std::__is_fast_hash<std::hash<Rust::AST::MacroFragSpec::Kind> >, std::__detail::__is_noexcept_hash<Rust::AST::MacroFragSpec::Kind, std::hash<Rust::AST::MacroFragSpec::Kind> > > >' 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::__and_<std::__is_fast_hash<std::hash<Rust::AST::MacroFragSpec::Kind> >, std::__detail::__is_noexcept_hash<Rust::AST::MacroFragSpec::Kind, std::hash<Rust::AST::MacroFragSpec::Kind> > > >' 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::__and_<std::__is_fast_hash<std::hash<Rust::AST::MacroFragSpec::Kind> >, std::__detail::__is_noexcept_hash<Rust::AST::MacroFragSpec::Kind, std::hash<Rust::AST::MacroFragSpec::Kind> > > >' 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::__and_<std::__is_fast_hash<std::hash<Rust::AST::MacroFragSpec::Kind> >, std::__detail::__is_noexcept_hash<Rust::AST::MacroFragSpec::Kind, std::hash<Rust::AST::MacroFragSpec::Kind> > > >' 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::__and_<std::__is_fast_hash<std::hash<Rust::AST::MacroFragSpec::Kind> >, std::__detail::__is_noexcept_hash<Rust::AST::MacroFragSpec::Kind, std::hash<Rust::AST::MacroFragSpec::Kind> > > >' 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::__and_<std::__is_fast_hash<std::hash<Rust::AST::MacroFragSpec::Kind> >, std::__detail::__is_noexcept_hash<Rust::AST::MacroFragSpec::Kind, std::hash<Rust::AST::MacroFragSpec::Kind> > > >' operator=(initializer_list<value_type> __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::__and_<std::__is_fast_hash<std::hash<Rust::AST::MacroFragSpec::Kind> >, std::__detail::__is_noexcept_hash<Rust::AST::MacroFragSpec::Kind, std::hash<Rust::AST::MacroFragSpec::Kind> > > >' 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::__and_<std::__is_fast_hash<std::hash<Rust::AST::MacroFragSpec::Kind> >, std::__detail::__is_noexcept_hash<Rust::AST::MacroFragSpec::Kind, std::hash<Rust::AST::MacroFragSpec::Kind> > > >' 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::__and_<std::__is_fast_hash<std::hash<Rust::AST::MacroFragSpec::Kind> >, std::__detail::__is_noexcept_hash<Rust::AST::MacroFragSpec::Kind, std::hash<Rust::AST::MacroFragSpec::Kind> > > >' 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::__and_<std::__is_fast_hash<std::hash<Rust::AST::MacroFragSpec::Kind> >, std::__detail::__is_noexcept_hash<Rust::AST::MacroFragSpec::Kind, std::hash<Rust::AST::MacroFragSpec::Kind> > > >' insert(initializer_list<value_type> __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::__and_<std::__is_fast_hash<std::hash<Rust::AST::MacroFragSpec::Kind> >, std::__detail::__is_noexcept_hash<Rust::AST::MacroFragSpec::Kind, std::hash<Rust::AST::MacroFragSpec::Kind> > > >' 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::__and_<std::__is_fast_hash<std::hash<Rust::AST::MacroFragSpec::Kind> >, std::__detail::__is_noexcept_hash<Rust::AST::MacroFragSpec::Kind, std::hash<Rust::AST::MacroFragSpec::Kind> > > >' 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<Rust::AST::MacroFragSpec::Kind, std::vector<Rust::TokenId> >' }; ^ [GCC/Rust]/gcc/rust/parse/rust-parse.cc:119:16: error: no match for 'operator[]' (operand types are 'std::unordered_map<Rust::AST::MacroFragSpec::Kind, std::vector<Rust::TokenId> >' 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 Co-authored-by: Thomas Schwinge <thomas@codesourcery.com>
3 parents eef1ee2 + 85ffe83 + 7af3505 commit 90f938c

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

gcc/rust/ast/rust-macro.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,4 +906,15 @@ struct AttributeParser
906906
} // namespace AST
907907
} // namespace Rust
908908

909+
/* <https://stackoverflow.com/a/35304501> */
910+
namespace std {
911+
template <> struct hash<Rust::AST::MacroFragSpec::Kind>
912+
{
913+
size_t operator() (const Rust::AST::MacroFragSpec::Kind &t) const noexcept
914+
{
915+
return size_t (t);
916+
}
917+
};
918+
} // namespace std
919+
909920
#endif

gcc/rust/parse/rust-parse-impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ along with GCC; see the file COPYING3. If not see
2020
/* DO NOT INCLUDE ANYWHERE - this is automatically included with rust-parse.h
2121
* This is also the reason why there are no include guards. */
2222

23+
#define INCLUDE_ALGORITHM
2324
#include "rust-diagnostics.h"
2425
#include "util/rust-make-unique.h"
25-
#include <algorithm>
2626

2727
namespace Rust {
2828
// Left binding powers of operations.

0 commit comments

Comments
 (0)