diff options
author | Martin Liska <mliska@suse.cz> | 2022-09-05 10:44:56 +0200 |
---|---|---|
committer | Martin Liska <mliska@suse.cz> | 2022-09-05 10:44:56 +0200 |
commit | d8e441f4b8698f38e4564fe1bbe9ff112814ecff (patch) | |
tree | 62aac45da0a2358e1ea29a07ab734f607a201e5b /gcc/cp | |
parent | 4483fe115cef3eea1d64e913816e2d117b38ac73 (diff) | |
parent | ca60bd93e216ae0425f790e1d4f4dc4a48763c0e (diff) | |
download | gcc-d8e441f4b8698f38e4564fe1bbe9ff112814ecff.zip gcc-d8e441f4b8698f38e4564fe1bbe9ff112814ecff.tar.gz gcc-d8e441f4b8698f38e4564fe1bbe9ff112814ecff.tar.bz2 |
Merge branch 'master' into devel/sphinx
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 94 | ||||
-rw-r--r-- | gcc/cp/Make-lang.in | 9 | ||||
-rw-r--r-- | gcc/cp/call.cc | 7 | ||||
-rw-r--r-- | gcc/cp/cp-objcp-common.cc | 2 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 28 | ||||
-rw-r--r-- | gcc/cp/decl.cc | 10 | ||||
-rw-r--r-- | gcc/cp/name-lookup.cc | 231 | ||||
-rw-r--r-- | gcc/cp/parser.cc | 195 | ||||
-rw-r--r-- | gcc/cp/pt.cc | 13 | ||||
-rw-r--r-- | gcc/cp/semantics.cc | 19 | ||||
-rw-r--r-- | gcc/cp/std-name-hint.gperf | 287 | ||||
-rw-r--r-- | gcc/cp/std-name-hint.h | 675 | ||||
-rw-r--r-- | gcc/cp/typeck.cc | 53 |
13 files changed, 1313 insertions, 310 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 083ead1..a11675e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,97 @@ +2022-09-03 Jakub Jelinek <jakub@redhat.com> + + * parser.cc (cp_parser_omp_clause_name): Handle doacross. + (cp_parser_omp_clause_depend_sink): Renamed to ... + (cp_parser_omp_clause_doacross_sink): ... this. Add depend_p + argument. Handle parsing of doacross(sink:omp_cur_iteration-1). Use + OMP_CLAUSE_DOACROSS_SINK_NEGATIVE instead of + OMP_CLAUSE_DEPEND_SINK_NEGATIVE, build OMP_CLAUSE_DOACROSS instead + of OMP_CLAUSE_DEPEND and set OMP_CLAUSE_DOACROSS_DEPEND flag on it. + (cp_parser_omp_clause_depend): Use OMP_CLAUSE_DOACROSS_SINK and + OMP_CLAUSE_DOACROSS_SOURCE instead of OMP_CLAUSE_DEPEND_SINK and + OMP_CLAUSE_DEPEND_SOURCE, build OMP_CLAUSE_DOACROSS for depend(source) + and set OMP_CLAUSE_DOACROSS_DEPEND on it. + (cp_parser_omp_clause_doacross): New function. + (cp_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_DOACROSS. + (cp_parser_omp_depobj): Use OMP_CLAUSE_DEPEND_INVALID instead of + OMP_CLAUSE_DEPEND_SOURCE. + (cp_parser_omp_for_loop): Don't diagnose here linear clause together + with ordered with argument. + (cp_parser_omp_simd): Don't diagnose ordered clause with argument on + for simd. + (OMP_ORDERED_DEPEND_CLAUSE_MASK): Add PRAGMA_OMP_CLAUSE_DOACROSS. + (cp_parser_omp_ordered): Handle also doacross and adjust for it + diagnostic wording. + * pt.cc (tsubst_omp_clause_decl): Use + OMP_CLAUSE_DOACROSS_SINK_NEGATIVE instead of + OMP_CLAUSE_DEPEND_SINK_NEGATIVE. + (tsubst_omp_clauses): Handle OMP_CLAUSE_DOACROSS. + (tsubst_expr): Use OMP_CLAUSE_DEPEND_INVALID instead of + OMP_CLAUSE_DEPEND_SOURCE. + * semantics.cc (cp_finish_omp_clause_depend_sink): Rename to ... + (cp_finish_omp_clause_doacross_sink): ... this. + (finish_omp_clauses): Handle OMP_CLAUSE_DOACROSS. Don't handle + OMP_CLAUSE_DEPEND_SOURCE and OMP_CLAUSE_DEPEND_SINK. + +2022-09-02 David Malcolm <dmalcolm@redhat.com> + + PR c/90885 + * cp-tree.h (class cp_expr): Add bitfield m_decimal. Clear it in + existing ctors. Add ctor that allows specifying its value. + (cp_expr::decimal_p): New accessor. + * parser.cc (cp_parser_expression_stack_entry::flags): New field. + (cp_parser_primary_expression): Set m_decimal of cp_expr when + handling numbers. + (cp_parser_binary_expression): Extract flags from token when + populating stack. Call check_for_xor_used_as_pow. + +2022-09-01 Marek Polacek <polacek@redhat.com> + + * cp-tree.h (maybe_strip_ref_conversion): Remove. + +2022-08-30 Ulrich Drepper <drepper@gmail.com> + + * Make-lang.in: Add rule to rebuild std-name-hint.h from + std-name-hint.gperf. + * name-lookup.cc (get_std_name_hint): Remove hints array. + Use gperf-generated class std_name_hint_lookup. + Include "std-name-hint.h". + * std-name-hint.gperf: New file. + * std-name-hint.h: New file. Generated from the .gperf file. + +2022-08-30 Marek Polacek <polacek@redhat.com> + + PR c++/106759 + * cp-objcp-common.cc (names_builtin_p): Handle RID_IS_NOTHROW_ASSIGNABLE + and RID_IS_NOTHROW_CONSTRUCTIBLE. + +2022-08-29 Marek Polacek <polacek@redhat.com> + + PR c++/106712 + * decl.cc (grokdeclarator): Reverse the order of arguments to + attr_chainon. + +2022-08-26 Marek Polacek <polacek@redhat.com> + + PR c++/81159 + * typeck.cc (maybe_warn_self_move): New. + (cp_build_modify_expr): Call maybe_warn_self_move. + +2022-08-25 Marek Polacek <polacek@redhat.com> + + * cp-tree.h (enum cp_tree_index): Remove CTI_NULLPTR, CTI_NULLPTR_TYPE. + Move it to c_tree_index. + (nullptr_node): No longer define here. + (nullptr_type_node): Likewise. + (NULLPTR_TYPE_P): Likewise. + * decl.cc (cxx_init_decl_processing): Only keep C++-specific nullptr + initialization; move the shared code to c_common_nodes_and_builtins. + +2022-08-25 Jason Merrill <jason@redhat.com> + + * call.cc (unsafe_return_slot_p): Return 2 for *this in a + constructor. + 2022-08-23 Marek Polacek <polacek@redhat.com> * typeck.cc (maybe_warn_pessimizing_move): Don't warn about diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in index 23d98c8..38d8eee 100644 --- a/gcc/cp/Make-lang.in +++ b/gcc/cp/Make-lang.in @@ -153,6 +153,15 @@ endif gperf -o -C -E -k '1-6,$$' -j1 -D -N 'libc_name_p' -L C++ \ $(srcdir)/cp/cfns.gperf --output-file $(srcdir)/cp/cfns.h +# The same procedure for the std-name-hint.gperf file. +ifeq ($(ENABLE_MAINTAINER_RULES), true) +$(srcdir)/cp/std-name-hint.h: $(srcdir)/cp/std-name-hint.gperf +else +$(srcdir)/cp/std-name-hint.h: +endif + gperf -o -C -E -k '1,2,7,11,$$' -D -N find -L C++ \ + $(srcdir)/cp/std-name-hint.gperf --output-file $(srcdir)/cp/std-name-hint.h + cc1plus.fda: ../stage1-gcc/cc1plus$(exeext) ../prev-gcc/$(PERF_DATA) $(CREATE_GCOV) -binary ../stage1-gcc/cc1plus$(exeext) -gcov cc1plus.fda -profile ../prev-gcc/$(PERF_DATA) -gcov_version 1 diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc index 370137e..d107a28 100644 --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -9022,6 +9022,13 @@ unsafe_return_slot_p (tree t) if (is_empty_base_ref (t)) return 2; + /* A delegating constructor might be used to initialize a base. */ + if (current_function_decl + && DECL_CONSTRUCTOR_P (current_function_decl) + && (t == current_class_ref + || tree_strip_nop_conversions (t) == current_class_ptr)) + return 2; + STRIP_NOPS (t); if (TREE_CODE (t) == ADDR_EXPR) t = TREE_OPERAND (t, 0); diff --git a/gcc/cp/cp-objcp-common.cc b/gcc/cp/cp-objcp-common.cc index 4079a4b..1ffac08 100644 --- a/gcc/cp/cp-objcp-common.cc +++ b/gcc/cp/cp-objcp-common.cc @@ -460,6 +460,8 @@ names_builtin_p (const char *name) case RID_IS_UNION: case RID_IS_ASSIGNABLE: case RID_IS_CONSTRUCTIBLE: + case RID_IS_NOTHROW_ASSIGNABLE: + case RID_IS_NOTHROW_CONSTRUCTIBLE: case RID_UNDERLYING_TYPE: case RID_REF_CONSTRUCTS_FROM_TEMPORARY: case RID_REF_CONVERTS_FROM_TEMPORARY: diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 9f2ff37..7b28405 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -54,13 +54,23 @@ class cp_expr { public: cp_expr () : - m_value (NULL), m_loc (UNKNOWN_LOCATION) {} + m_value (NULL), m_loc (UNKNOWN_LOCATION), + m_decimal (false) + {} cp_expr (tree value) : - m_value (value), m_loc (cp_expr_location (m_value)) {} + m_value (value), m_loc (cp_expr_location (m_value)), + m_decimal (false) + {} cp_expr (tree value, location_t loc): - m_value (value), m_loc (loc) + m_value (value), m_loc (loc), m_decimal (false) + { + protected_set_expr_location (value, loc); + } + + cp_expr (tree value, location_t loc, bool decimal): + m_value (value), m_loc (loc), m_decimal (decimal) { protected_set_expr_location (value, loc); } @@ -102,9 +112,12 @@ public: return *this; } + bool decimal_p () const { return m_decimal; } + private: tree m_value; location_t m_loc; + bool m_decimal : 1; }; inline bool @@ -187,9 +200,6 @@ enum cp_tree_index CPTI_NOEXCEPT_FALSE_SPEC, CPTI_NOEXCEPT_DEFERRED_SPEC, - CPTI_NULLPTR, - CPTI_NULLPTR_TYPE, - CPTI_ANY_TARG, CPTI_MODULE_HWM, @@ -254,8 +264,6 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX]; #define conv_op_marker cp_global_trees[CPTI_CONV_OP_MARKER] #define abort_fndecl cp_global_trees[CPTI_ABORT_FNDECL] #define current_aggr cp_global_trees[CPTI_AGGR_TAG] -#define nullptr_node cp_global_trees[CPTI_NULLPTR] -#define nullptr_type_node cp_global_trees[CPTI_NULLPTR_TYPE] /* std::align_val_t */ #define align_type_node cp_global_trees[CPTI_ALIGN_TYPE] @@ -4405,9 +4413,6 @@ get_vec_init_expr (tree t) || TREE_CODE (TYPE) == REAL_TYPE \ || TREE_CODE (TYPE) == COMPLEX_TYPE) -/* True iff TYPE is cv decltype(nullptr). */ -#define NULLPTR_TYPE_P(TYPE) (TREE_CODE (TYPE) == NULLPTR_TYPE) - /* [basic.types] Arithmetic types, enumeration types, pointer types, @@ -7606,7 +7611,6 @@ extern tree force_paren_expr (tree, bool = false); inline tree force_paren_expr_uneval (tree t) { return force_paren_expr (t, true); } extern tree maybe_undo_parenthesized_ref (tree); -extern tree maybe_strip_ref_conversion (tree); extern tree finish_non_static_data_member (tree, tree, tree, tsubst_flags_t = tf_warning_or_error); extern tree begin_stmt_expr (void); diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc index 84a1a01..b72b2a8 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -4793,16 +4793,10 @@ cxx_init_decl_processing (void) } } - nullptr_type_node = make_node (NULLPTR_TYPE); - TYPE_SIZE (nullptr_type_node) = bitsize_int (GET_MODE_BITSIZE (ptr_mode)); - TYPE_SIZE_UNIT (nullptr_type_node) = size_int (GET_MODE_SIZE (ptr_mode)); - TYPE_UNSIGNED (nullptr_type_node) = 1; - TYPE_PRECISION (nullptr_type_node) = GET_MODE_BITSIZE (ptr_mode); + /* C++-specific nullptr initialization. */ if (abi_version_at_least (9)) SET_TYPE_ALIGN (nullptr_type_node, GET_MODE_ALIGNMENT (ptr_mode)); - SET_TYPE_MODE (nullptr_type_node, ptr_mode); record_builtin_type (RID_MAX, "decltype(nullptr)", nullptr_type_node); - nullptr_node = build_int_cst (nullptr_type_node, 0); } if (! supports_one_only ()) @@ -13480,7 +13474,7 @@ grokdeclarator (const cp_declarator *declarator, /* [dcl.meaning]/1: The optional attribute-specifier-seq following a declarator-id appertains to the entity that is declared. */ if (declarator->std_attributes != error_mark_node) - *attrlist = attr_chainon (*attrlist, declarator->std_attributes); + *attrlist = attr_chainon (declarator->std_attributes, *attrlist); else /* We should have already diagnosed the issue (c++/78344). */ gcc_assert (seen_error ()); diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc index ce62276..f89a1dc 100644 --- a/gcc/cp/name-lookup.cc +++ b/gcc/cp/name-lookup.cc @@ -6691,20 +6691,14 @@ suggest_alternatives_in_other_namespaces (location_t location, tree name) } /* A well-known name within the C++ standard library, returned by - get_std_name_hint. */ + get_std_name_hint. -struct std_name_hint -{ - /* A name within "std::". */ - const char *name; - - /* The header name defining it within the C++ Standard Library - (with '<' and '>'). */ - const char *header; + The gperf-generated file contains the definition of the class + "std_name_hint_lookup" with a static member function which + returns the pointer to a structure "std_name_hint" which + is also defined in that file. */ - /* The dialect of C++ in which this was added. */ - enum cxx_dialect min_dialect; -}; +#include "std-name-hint.h" /* Subroutine of maybe_suggest_missing_header for handling unrecognized names for some of the most common names within "std::". @@ -6713,218 +6707,7 @@ struct std_name_hint static const std_name_hint * get_std_name_hint (const char *name) { - static const std_name_hint hints[] = { - /* <any>. */ - {"any", "<any>", cxx17}, - {"any_cast", "<any>", cxx17}, - {"make_any", "<any>", cxx17}, - /* <array>. */ - {"array", "<array>", cxx11}, - {"to_array", "<array>", cxx20}, - /* <atomic>. */ - {"atomic", "<atomic>", cxx11}, - {"atomic_flag", "<atomic>", cxx11}, - {"atomic_ref", "<atomic>", cxx20}, - /* <bitset>. */ - {"bitset", "<bitset>", cxx11}, - /* <compare> */ - {"weak_equality", "<compare>", cxx20}, - {"strong_equality", "<compare>", cxx20}, - {"partial_ordering", "<compare>", cxx20}, - {"weak_ordering", "<compare>", cxx20}, - {"strong_ordering", "<compare>", cxx20}, - /* <complex>. */ - {"complex", "<complex>", cxx98}, - {"complex_literals", "<complex>", cxx14}, - /* <condition_variable>. */ - {"condition_variable", "<condition_variable>", cxx11}, - {"condition_variable_any", "<condition_variable>", cxx11}, - /* <cstddef>. */ - {"byte", "<cstddef>", cxx17}, - /* <deque>. */ - {"deque", "<deque>", cxx98}, - /* <forward_list>. */ - {"forward_list", "<forward_list>", cxx11}, - /* <fstream>. */ - {"basic_filebuf", "<fstream>", cxx98}, - {"basic_ifstream", "<fstream>", cxx98}, - {"basic_ofstream", "<fstream>", cxx98}, - {"basic_fstream", "<fstream>", cxx98}, - {"fstream", "<fstream>", cxx98}, - {"ifstream", "<fstream>", cxx98}, - {"ofstream", "<fstream>", cxx98}, - /* <functional>. */ - {"bind", "<functional>", cxx11}, - {"bind_front", "<functional>", cxx20}, - {"function", "<functional>", cxx11}, - {"hash", "<functional>", cxx11}, - {"invoke", "<functional>", cxx17}, - {"mem_fn", "<functional>", cxx11}, - {"not_fn", "<functional>", cxx17}, - {"reference_wrapper", "<functional>", cxx11}, - {"unwrap_reference", "<functional>", cxx20}, - {"unwrap_reference_t", "<functional>", cxx20}, - {"unwrap_ref_decay", "<functional>", cxx20}, - {"unwrap_ref_decay_t", "<functional>", cxx20}, - /* <future>. */ - {"async", "<future>", cxx11}, - {"future", "<future>", cxx11}, - {"packaged_task", "<future>", cxx11}, - {"promise", "<future>", cxx11}, - /* <iostream>. */ - {"cin", "<iostream>", cxx98}, - {"cout", "<iostream>", cxx98}, - {"cerr", "<iostream>", cxx98}, - {"clog", "<iostream>", cxx98}, - {"wcin", "<iostream>", cxx98}, - {"wcout", "<iostream>", cxx98}, - {"wclog", "<iostream>", cxx98}, - /* <istream>. */ - {"istream", "<istream>", cxx98}, - /* <iterator>. */ - {"advance", "<iterator>", cxx98}, - {"back_inserter", "<iterator>", cxx98}, - {"begin", "<iterator>", cxx11}, - {"distance", "<iterator>", cxx98}, - {"end", "<iterator>", cxx11}, - {"front_inserter", "<iterator>", cxx98}, - {"inserter", "<iterator>", cxx98}, - {"istream_iterator", "<iterator>", cxx98}, - {"istreambuf_iterator", "<iterator>", cxx98}, - {"iterator_traits", "<iterator>", cxx98}, - {"move_iterator", "<iterator>", cxx11}, - {"next", "<iterator>", cxx11}, - {"ostream_iterator", "<iterator>", cxx98}, - {"ostreambuf_iterator", "<iterator>", cxx98}, - {"prev", "<iterator>", cxx11}, - {"reverse_iterator", "<iterator>", cxx98}, - /* <ostream>. */ - {"ostream", "<ostream>", cxx98}, - /* <list>. */ - {"list", "<list>", cxx98}, - /* <map>. */ - {"map", "<map>", cxx98}, - {"multimap", "<map>", cxx98}, - /* <memory>. */ - {"allocate_shared", "<memory>", cxx11}, - {"allocator", "<memory>", cxx98}, - {"allocator_traits", "<memory>", cxx11}, - {"make_shared", "<memory>", cxx11}, - {"make_unique", "<memory>", cxx14}, - {"shared_ptr", "<memory>", cxx11}, - {"unique_ptr", "<memory>", cxx11}, - {"weak_ptr", "<memory>", cxx11}, - /* <memory_resource>. */ - {"pmr", "<memory_resource>", cxx17}, - /* <mutex>. */ - {"mutex", "<mutex>", cxx11}, - {"timed_mutex", "<mutex>", cxx11}, - {"recursive_mutex", "<mutex>", cxx11}, - {"recursive_timed_mutex", "<mutex>", cxx11}, - {"once_flag", "<mutex>", cxx11}, - {"call_once,", "<mutex>", cxx11}, - {"lock", "<mutex>", cxx11}, - {"scoped_lock", "<mutex>", cxx17}, - {"try_lock", "<mutex>", cxx11}, - {"lock_guard", "<mutex>", cxx11}, - {"unique_lock", "<mutex>", cxx11}, - /* <optional>. */ - {"optional", "<optional>", cxx17}, - {"make_optional", "<optional>", cxx17}, - /* <ostream>. */ - {"ostream", "<ostream>", cxx98}, - {"wostream", "<ostream>", cxx98}, - {"ends", "<ostream>", cxx98}, - {"flush", "<ostream>", cxx98}, - {"endl", "<ostream>", cxx98}, - /* <queue>. */ - {"queue", "<queue>", cxx98}, - {"priority_queue", "<queue>", cxx98}, - /* <set>. */ - {"set", "<set>", cxx98}, - {"multiset", "<set>", cxx98}, - /* <shared_mutex>. */ - {"shared_lock", "<shared_mutex>", cxx14}, - {"shared_mutex", "<shared_mutex>", cxx17}, - {"shared_timed_mutex", "<shared_mutex>", cxx14}, - /* <source_location>. */ - {"source_location", "<source_location>", cxx20}, - /* <sstream>. */ - {"basic_stringbuf", "<sstream>", cxx98}, - {"basic_istringstream", "<sstream>", cxx98}, - {"basic_ostringstream", "<sstream>", cxx98}, - {"basic_stringstream", "<sstream>", cxx98}, - {"istringstream", "<sstream>", cxx98}, - {"ostringstream", "<sstream>", cxx98}, - {"stringstream", "<sstream>", cxx98}, - /* <stack>. */ - {"stack", "<stack>", cxx98}, - /* <string>. */ - {"basic_string", "<string>", cxx98}, - {"string", "<string>", cxx98}, - {"wstring", "<string>", cxx98}, - {"u8string", "<string>", cxx20}, - {"u16string", "<string>", cxx11}, - {"u32string", "<string>", cxx11}, - /* <string_view>. */ - {"basic_string_view", "<string_view>", cxx17}, - {"string_view", "<string_view>", cxx17}, - /* <thread>. */ - {"thread", "<thread>", cxx11}, - {"this_thread", "<thread>", cxx11}, - /* <tuple>. */ - {"apply", "<tuple>", cxx17}, - {"forward_as_tuple", "<tuple>", cxx11}, - {"make_from_tuple", "<tuple>", cxx17}, - {"make_tuple", "<tuple>", cxx11}, - {"tie", "<tuple>", cxx11}, - {"tuple", "<tuple>", cxx11}, - {"tuple_cat", "<tuple>", cxx11}, - {"tuple_element", "<tuple>", cxx11}, - {"tuple_element_t", "<tuple>", cxx14}, - {"tuple_size", "<tuple>", cxx11}, - {"tuple_size_v", "<tuple>", cxx17}, - /* <type_traits>. */ - {"enable_if", "<type_traits>", cxx11}, - {"enable_if_t", "<type_traits>", cxx14}, - {"invoke_result", "<type_traits>", cxx17}, - {"invoke_result_t", "<type_traits>", cxx17}, - {"remove_cvref", "<type_traits>", cxx20}, - {"remove_cvref_t", "<type_traits>", cxx20}, - {"type_identity", "<type_traits>", cxx20}, - {"type_identity_t", "<type_traits>", cxx20}, - {"void_t", "<type_traits>", cxx17}, - {"conjunction", "<type_traits>", cxx17}, - {"conjunction_v", "<type_traits>", cxx17}, - {"disjunction", "<type_traits>", cxx17}, - {"disjunction_v", "<type_traits>", cxx17}, - {"negation", "<type_traits>", cxx17}, - {"negation_v", "<type_traits>", cxx17}, - /* <unordered_map>. */ - {"unordered_map", "<unordered_map>", cxx11}, - {"unordered_multimap", "<unordered_map>", cxx11}, - /* <unordered_set>. */ - {"unordered_set", "<unordered_set>", cxx11}, - {"unordered_multiset", "<unordered_set>", cxx11}, - /* <utility>. */ - {"declval", "<utility>", cxx11}, - {"forward", "<utility>", cxx11}, - {"make_pair", "<utility>", cxx98}, - {"move", "<utility>", cxx11}, - {"pair", "<utility>", cxx98}, - /* <variant>. */ - {"variant", "<variant>", cxx17}, - {"visit", "<variant>", cxx17}, - /* <vector>. */ - {"vector", "<vector>", cxx98}, - }; - const size_t num_hints = ARRAY_SIZE (hints); - for (size_t i = 0; i < num_hints; i++) - { - if (strcmp (name, hints[i].name) == 0) - return &hints[i]; - } - return NULL; + return std_name_hint_lookup::find(name, strlen(name)); } /* Describe DIALECT. */ diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 68fc78e..076ad62 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -2069,6 +2069,8 @@ struct cp_parser_expression_stack_entry enum cp_parser_prec prec; /* Location of the binary operation we are parsing. */ location_t loc; + /* Flags from the operator token. */ + unsigned char flags; }; /* The stack for storing partial expressions. We only need NUM_PREC_VALUES @@ -5614,7 +5616,7 @@ cp_parser_primary_expression (cp_parser *parser, if (!cast_p) cp_parser_non_integral_constant_expression (parser, NIC_FLOAT); } - return (cp_expr (token->u.value, token->location) + return (cp_expr (token->u.value, token->location, token->flags & DECIMAL_INT) .maybe_add_location_wrapper ()); case CPP_CHAR_USERDEF: @@ -10160,6 +10162,7 @@ cp_parser_binary_expression (cp_parser* parser, bool cast_p, get_rhs: current.tree_type = binops_by_token[token->type].tree_type; current.loc = token->location; + current.flags = token->flags; /* We used the operator token. */ cp_lexer_consume_token (parser->lexer); @@ -10244,6 +10247,18 @@ cp_parser_binary_expression (cp_parser* parser, bool cast_p, warn_logical_not_parentheses (current.loc, current.tree_type, current.lhs, maybe_constant_value (rhs)); + if (warn_xor_used_as_pow + && current.tree_type == BIT_XOR_EXPR + /* Don't warn for named "xor" (as opposed to '^'). */ + && !(current.flags & NAMED_OP) + && current.lhs.decimal_p () + && rhs.decimal_p ()) + check_for_xor_used_as_pow + (current.lhs.get_location (), + tree_strip_any_location_wrapper (current.lhs), + current.loc, + tree_strip_any_location_wrapper (rhs)); + overload = NULL; location_t combined_loc = make_location (current.loc, @@ -11979,14 +11994,18 @@ cp_parser_handle_statement_omp_attributes (cp_parser *parser, tree attrs) if (dir->id == PRAGMA_OMP_ORDERED) { /* ordered is C_OMP_DIR_CONSTRUCT only if it doesn't contain - depend clause. */ - if (directive[1] && strcmp (directive[1], "depend") == 0) + depend/doacross clause. */ + if (directive[1] + && (strcmp (directive[1], "depend") == 0 + || strcmp (directive[1], "doacross") == 0)) kind = C_OMP_DIR_STANDALONE; else if (first + 2 < last && first[1].type == CPP_COMMA && first[2].type == CPP_NAME - && strcmp (IDENTIFIER_POINTER (first[2].u.value), - "depend") == 0) + && (strcmp (IDENTIFIER_POINTER (first[2].u.value), + "depend") == 0 + || strcmp (IDENTIFIER_POINTER (first[2].u.value), + "doacross") == 0)) kind = C_OMP_DIR_STANDALONE; } else if (dir->id == PRAGMA_OMP_ERROR) @@ -36587,6 +36606,8 @@ cp_parser_omp_clause_name (cp_parser *parser) result = PRAGMA_OMP_CLAUSE_DEVICE_TYPE; else if (!strcmp ("dist_schedule", p)) result = PRAGMA_OMP_CLAUSE_DIST_SCHEDULE; + else if (!strcmp ("doacross", p)) + result = PRAGMA_OMP_CLAUSE_DOACROSS; break; case 'e': if (!strcmp ("enter", p)) @@ -39314,8 +39335,8 @@ cp_parser_omp_clause_simdlen (cp_parser *parser, tree list, */ static tree -cp_parser_omp_clause_depend_sink (cp_parser *parser, location_t clause_loc, - tree list) +cp_parser_omp_clause_doacross_sink (cp_parser *parser, location_t clause_loc, + tree list, bool depend_p) { tree vec = NULL; @@ -39325,6 +39346,29 @@ cp_parser_omp_clause_depend_sink (cp_parser *parser, location_t clause_loc, return list; } + if (!depend_p) + { + tree id = cp_lexer_peek_token (parser->lexer)->u.value; + if (strcmp (IDENTIFIER_POINTER (id), "omp_cur_iteration") == 0 + && cp_lexer_nth_token_is (parser->lexer, 2, CPP_MINUS) + && cp_lexer_nth_token_is (parser->lexer, 3, CPP_NUMBER) + && cp_lexer_nth_token_is (parser->lexer, 4, CPP_CLOSE_PAREN)) + { + tree val = cp_lexer_peek_nth_token (parser->lexer, 3)->u.value; + if (integer_onep (val) + && same_type_p (TREE_TYPE (val), integer_type_node)) + { + cp_lexer_consume_token (parser->lexer); + cp_lexer_consume_token (parser->lexer); + cp_lexer_consume_token (parser->lexer); + tree u = build_omp_clause (clause_loc, OMP_CLAUSE_DOACROSS); + OMP_CLAUSE_DOACROSS_KIND (u) = OMP_CLAUSE_DOACROSS_SINK; + OMP_CLAUSE_CHAIN (u) = list; + return u; + } + } + } + while (cp_lexer_next_token_is (parser->lexer, CPP_NAME)) { location_t id_loc = cp_lexer_peek_token (parser->lexer)->location; @@ -39372,7 +39416,7 @@ cp_parser_omp_clause_depend_sink (cp_parser *parser, location_t clause_loc, { vec = tree_cons (addend, t, vec); if (neg) - OMP_CLAUSE_DEPEND_SINK_NEGATIVE (vec) = 1; + OMP_CLAUSE_DOACROSS_SINK_NEGATIVE (vec) = 1; } if (cp_lexer_next_token_is_not (parser->lexer, CPP_COMMA) @@ -39384,8 +39428,9 @@ cp_parser_omp_clause_depend_sink (cp_parser *parser, location_t clause_loc, if (vec) { - tree u = build_omp_clause (clause_loc, OMP_CLAUSE_DEPEND); - OMP_CLAUSE_DEPEND_KIND (u) = OMP_CLAUSE_DEPEND_SINK; + tree u = build_omp_clause (clause_loc, OMP_CLAUSE_DOACROSS); + OMP_CLAUSE_DOACROSS_KIND (u) = OMP_CLAUSE_DOACROSS_SINK; + OMP_CLAUSE_DOACROSS_DEPEND (u) = depend_p; OMP_CLAUSE_DECL (u) = nreverse (vec); OMP_CLAUSE_CHAIN (u) = list; return u; @@ -39634,6 +39679,7 @@ cp_parser_omp_clause_depend (cp_parser *parser, tree list, location_t loc) { tree nlist, c, iterators = NULL_TREE; enum omp_clause_depend_kind kind = OMP_CLAUSE_DEPEND_LAST; + enum omp_clause_doacross_kind dkind = OMP_CLAUSE_DOACROSS_LAST; matching_parens parens; if (!parens.require_open (parser)) @@ -39667,9 +39713,9 @@ cp_parser_omp_clause_depend (cp_parser *parser, tree list, location_t loc) else if (strcmp ("depobj", p) == 0) kind = OMP_CLAUSE_DEPEND_DEPOBJ; else if (strcmp ("sink", p) == 0) - kind = OMP_CLAUSE_DEPEND_SINK; + dkind = OMP_CLAUSE_DOACROSS_SINK; else if (strcmp ("source", p) == 0) - kind = OMP_CLAUSE_DEPEND_SOURCE; + dkind = OMP_CLAUSE_DOACROSS_SOURCE; else goto invalid_kind; break; @@ -39679,18 +39725,20 @@ cp_parser_omp_clause_depend (cp_parser *parser, tree list, location_t loc) cp_lexer_consume_token (parser->lexer); if (iterators - && (kind == OMP_CLAUSE_DEPEND_SOURCE || kind == OMP_CLAUSE_DEPEND_SINK)) + && (dkind == OMP_CLAUSE_DOACROSS_SOURCE + || dkind == OMP_CLAUSE_DOACROSS_SINK)) { poplevel (0, 1, 0); error_at (loc, "%<iterator%> modifier incompatible with %qs", - kind == OMP_CLAUSE_DEPEND_SOURCE ? "source" : "sink"); + dkind == OMP_CLAUSE_DOACROSS_SOURCE ? "source" : "sink"); iterators = NULL_TREE; } - if (kind == OMP_CLAUSE_DEPEND_SOURCE) + if (dkind == OMP_CLAUSE_DOACROSS_SOURCE) { - c = build_omp_clause (loc, OMP_CLAUSE_DEPEND); - OMP_CLAUSE_DEPEND_KIND (c) = kind; + c = build_omp_clause (loc, OMP_CLAUSE_DOACROSS); + OMP_CLAUSE_DOACROSS_KIND (c) = dkind; + OMP_CLAUSE_DOACROSS_DEPEND (c) = 1; OMP_CLAUSE_DECL (c) = NULL_TREE; OMP_CLAUSE_CHAIN (c) = list; if (!parens.require_close (parser)) @@ -39703,9 +39751,9 @@ cp_parser_omp_clause_depend (cp_parser *parser, tree list, location_t loc) if (!cp_parser_require (parser, CPP_COLON, RT_COLON)) goto resync_fail; - if (kind == OMP_CLAUSE_DEPEND_SINK) + if (dkind == OMP_CLAUSE_DOACROSS_SINK) { - nlist = cp_parser_omp_clause_depend_sink (parser, loc, list); + nlist = cp_parser_omp_clause_doacross_sink (parser, loc, list, true); if (!parens.require_close (parser)) cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true, /*or_comma=*/false, @@ -39746,6 +39794,73 @@ cp_parser_omp_clause_depend (cp_parser *parser, tree list, location_t loc) return list; } +/* OpenMP 5.2: + doacross ( source : ) + doacross ( source : omp_cur_iteration ) + + doacross ( sink : vec ) + doacross ( sink : omp_cur_iteration - logical_iteration ) */ + +static tree +cp_parser_omp_clause_doacross (cp_parser *parser, tree list, location_t loc) +{ + tree nlist; + enum omp_clause_doacross_kind kind = OMP_CLAUSE_DOACROSS_LAST; + + matching_parens parens; + if (!parens.require_open (parser)) + return list; + + if (cp_lexer_next_token_is_not (parser->lexer, CPP_NAME)) + { + invalid_kind: + cp_parser_error (parser, "invalid doacross kind"); + resync_fail: + cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true, + /*or_comma=*/false, + /*consume_paren=*/true); + return list; + } + + tree id = cp_lexer_peek_token (parser->lexer)->u.value; + const char *p = IDENTIFIER_POINTER (id); + + if (strcmp ("sink", p) == 0) + kind = OMP_CLAUSE_DOACROSS_SINK; + else if (strcmp ("source", p) == 0) + kind = OMP_CLAUSE_DOACROSS_SOURCE; + else + goto invalid_kind; + + cp_lexer_consume_token (parser->lexer); + + if (!cp_parser_require (parser, CPP_COLON, RT_COLON)) + goto resync_fail; + + if (kind == OMP_CLAUSE_DOACROSS_SOURCE) + { + if (cp_lexer_next_token_is (parser->lexer, CPP_NAME)) + { + id = cp_lexer_peek_token (parser->lexer)->u.value; + p = IDENTIFIER_POINTER (id); + if (strcmp (p, "omp_cur_iteration") == 0) + cp_lexer_consume_token (parser->lexer); + } + nlist = build_omp_clause (loc, OMP_CLAUSE_DOACROSS); + OMP_CLAUSE_DOACROSS_KIND (nlist) = OMP_CLAUSE_DOACROSS_SOURCE; + OMP_CLAUSE_DECL (nlist) = NULL_TREE; + OMP_CLAUSE_CHAIN (nlist) = list; + } + else + nlist = cp_parser_omp_clause_doacross_sink (parser, loc, list, false); + + if (!parens.require_close (parser)) + cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true, + /*or_comma=*/false, + /*consume_paren=*/true); + return nlist; +} + /* OpenMP 4.0: map ( map-kind : variable-list ) map ( variable-list ) @@ -40688,6 +40803,11 @@ cp_parser_omp_all_clauses (cp_parser *parser, omp_clause_mask mask, token->location); c_name = "depend"; break; + case PRAGMA_OMP_CLAUSE_DOACROSS: + clauses = cp_parser_omp_clause_doacross (parser, clauses, + token->location); + c_name = "doacross"; + break; case PRAGMA_OMP_CLAUSE_DETACH: clauses = cp_parser_omp_clause_detach (parser, clauses); c_name = "detach"; @@ -41926,7 +42046,7 @@ cp_parser_omp_depobj (cp_parser *parser, cp_token *pragma_tok) /*consume_paren=*/true); tree clause = NULL_TREE; - enum omp_clause_depend_kind kind = OMP_CLAUSE_DEPEND_SOURCE; + enum omp_clause_depend_kind kind = OMP_CLAUSE_DEPEND_INVALID; location_t c_loc = cp_lexer_peek_token (parser->lexer)->location; /* For now only in C++ attributes, do it always for OpenMP 5.1. */ if (parser->lexer->in_omp_attribute_pragma @@ -41974,7 +42094,7 @@ cp_parser_omp_depobj (cp_parser *parser, cp_token *pragma_tok) else if (!strcmp ("inoutset", p2)) kind = OMP_CLAUSE_DEPEND_INOUTSET; } - if (kind == OMP_CLAUSE_DEPEND_SOURCE) + if (kind == OMP_CLAUSE_DEPEND_INVALID) { clause = error_mark_node; error_at (c2_loc, "expected %<in%>, %<out%>, %<inout%>, " @@ -41990,7 +42110,7 @@ cp_parser_omp_depobj (cp_parser *parser, cp_token *pragma_tok) clause = error_mark_node; } } - if (!clause && kind == OMP_CLAUSE_DEPEND_SOURCE) + if (!clause && kind == OMP_CLAUSE_DEPEND_INVALID) { clause = error_mark_node; error_at (c_loc, "expected %<depend%>, %<destroy%> or %<update%> clause"); @@ -42822,19 +42942,6 @@ cp_parser_omp_for_loop (cp_parser *parser, enum tree_code code, tree clauses, = build_int_cst (NULL_TREE, collapse); ordered = collapse; } - if (ordered) - { - for (tree *pc = &clauses; *pc; ) - if (OMP_CLAUSE_CODE (*pc) == OMP_CLAUSE_LINEAR) - { - error_at (OMP_CLAUSE_LOCATION (*pc), - "%<linear%> clause may not be specified together " - "with %<ordered%> clause with a parameter"); - *pc = OMP_CLAUSE_CHAIN (*pc); - } - else - pc = &OMP_CLAUSE_CHAIN (*pc); - } gcc_assert (tiling || (collapse >= 1 && ordered >= 0)); count = ordered ? ordered : collapse; @@ -43286,15 +43393,6 @@ cp_parser_omp_simd (cp_parser *parser, cp_token *pragma_tok, { cp_omp_split_clauses (loc, OMP_SIMD, mask, clauses, cclauses); clauses = cclauses[C_OMP_CLAUSE_SPLIT_SIMD]; - tree c = omp_find_clause (cclauses[C_OMP_CLAUSE_SPLIT_FOR], - OMP_CLAUSE_ORDERED); - if (c && OMP_CLAUSE_ORDERED_EXPR (c)) - { - error_at (OMP_CLAUSE_LOCATION (c), - "%<ordered%> clause with parameter may not be specified " - "on %qs construct", p_name); - OMP_CLAUSE_ORDERED_EXPR (c) = NULL_TREE; - } } keep_next_level (true); @@ -43556,7 +43654,8 @@ cp_parser_omp_masked (cp_parser *parser, cp_token *pragma_tok, | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_SIMD)) #define OMP_ORDERED_DEPEND_CLAUSE_MASK \ - (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEPEND) + ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEPEND) \ + | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DOACROSS)) static bool cp_parser_omp_ordered (cp_parser *parser, cp_token *pragma_tok, @@ -43575,7 +43674,7 @@ cp_parser_omp_ordered (cp_parser *parser, cp_token *pragma_tok, tree id = cp_lexer_peek_nth_token (parser->lexer, n)->u.value; const char *p = IDENTIFIER_POINTER (id); - if (strcmp (p, "depend") == 0) + if (strcmp (p, "depend") == 0 || strcmp (p, "doacross") == 0) { if (!flag_openmp) /* flag_openmp_simd */ { @@ -43585,8 +43684,8 @@ cp_parser_omp_ordered (cp_parser *parser, cp_token *pragma_tok, if (context == pragma_stmt) { error_at (pragma_tok->location, "%<#pragma omp ordered%> with " - "%<depend%> clause may only be used in compound " - "statements"); + "%qs clause may only be used in compound " + "statements", p); cp_parser_skip_to_pragma_eol (parser, pragma_tok); return true; } diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index fe7e809..cd0d892 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -17830,8 +17830,8 @@ tsubst_omp_clause_decl (tree decl, tree args, tsubst_flags_t complain, } /* Handle an OpenMP array section represented as a TREE_LIST (or - OMP_CLAUSE_DEPEND_KIND). An OMP_CLAUSE_DEPEND (with a depend - kind of OMP_CLAUSE_DEPEND_SINK) can also be represented as a + OMP_CLAUSE_DOACROSS_KIND). An OMP_CLAUSE_DOACROSS (with a depend + kind of OMP_CLAUSE_DOACROSS_SINK) can also be represented as a TREE_LIST. We can handle it exactly the same as an array section (purpose, value, and a chain), even though the nomenclature (low_bound, length, etc) is different. */ @@ -17849,8 +17849,8 @@ tsubst_omp_clause_decl (tree decl, tree args, tsubst_flags_t complain, && TREE_CHAIN (decl) == chain) return decl; tree ret = tree_cons (low_bound, length, chain); - OMP_CLAUSE_DEPEND_SINK_NEGATIVE (ret) - = OMP_CLAUSE_DEPEND_SINK_NEGATIVE (decl); + OMP_CLAUSE_DOACROSS_SINK_NEGATIVE (ret) + = OMP_CLAUSE_DOACROSS_SINK_NEGATIVE (decl); return ret; } tree ret = tsubst_expr (decl, args, complain, in_decl, @@ -17898,6 +17898,7 @@ tsubst_omp_clauses (tree clauses, enum c_omp_region_type ort, case OMP_CLAUSE_COPYPRIVATE: case OMP_CLAUSE_UNIFORM: case OMP_CLAUSE_DEPEND: + case OMP_CLAUSE_DOACROSS: case OMP_CLAUSE_AFFINITY: case OMP_CLAUSE_FROM: case OMP_CLAUSE_TO: @@ -19414,7 +19415,7 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, r = RECUR (OMP_DEPOBJ_DEPOBJ (t)); if (OMP_DEPOBJ_CLAUSES (t) && OMP_DEPOBJ_CLAUSES (t) != error_mark_node) { - enum omp_clause_depend_kind kind = OMP_CLAUSE_DEPEND_SOURCE; + enum omp_clause_depend_kind kind = OMP_CLAUSE_DEPEND_INVALID; if (TREE_CODE (OMP_DEPOBJ_CLAUSES (t)) == OMP_CLAUSE) { tmp = tsubst_omp_clauses (OMP_DEPOBJ_CLAUSES (t), C_ORT_OMP, @@ -19432,7 +19433,7 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, } else finish_omp_depobj (EXPR_LOCATION (t), r, - OMP_CLAUSE_DEPEND_SOURCE, + OMP_CLAUSE_DEPEND_INVALID, OMP_DEPOBJ_CLAUSES (t)); break; diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index ae7c8ea..7b2c495 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -6477,13 +6477,13 @@ finish_omp_declare_simd_methods (tree t) } } -/* Adjust sink depend clause to take into account pointer offsets. +/* Adjust sink depend/doacross clause to take into account pointer offsets. Return TRUE if there was a problem processing the offset, and the whole clause should be removed. */ static bool -cp_finish_omp_clause_depend_sink (tree sink_clause) +cp_finish_omp_clause_doacross_sink (tree sink_clause) { tree t = OMP_CLAUSE_DECL (sink_clause); gcc_assert (TREE_CODE (t) == TREE_LIST); @@ -7795,21 +7795,18 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort) } goto handle_field_decl; - case OMP_CLAUSE_DEPEND: + case OMP_CLAUSE_DOACROSS: t = OMP_CLAUSE_DECL (c); if (t == NULL_TREE) + break; + if (OMP_CLAUSE_DOACROSS_KIND (c) == OMP_CLAUSE_DOACROSS_SINK) { - gcc_assert (OMP_CLAUSE_DEPEND_KIND (c) - == OMP_CLAUSE_DEPEND_SOURCE); - break; - } - if (OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_SINK) - { - if (cp_finish_omp_clause_depend_sink (c)) + if (cp_finish_omp_clause_doacross_sink (c)) remove = true; break; } - /* FALLTHRU */ + gcc_unreachable (); + case OMP_CLAUSE_DEPEND: case OMP_CLAUSE_AFFINITY: t = OMP_CLAUSE_DECL (c); if (TREE_CODE (t) == TREE_LIST diff --git a/gcc/cp/std-name-hint.gperf b/gcc/cp/std-name-hint.gperf new file mode 100644 index 0000000..976b90c --- /dev/null +++ b/gcc/cp/std-name-hint.gperf @@ -0,0 +1,287 @@ +%language=C++ +%define class-name std_name_hint_lookup +%struct-type +%{ +/* Copyright (C) 2022 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ +%} +struct std_name_hint +{ + /* A name within "std::". */ + const char *name; + + /* The header name defining it within the C++ Standard Library + (with '<' and '>'). */ + const char* header; + + /* The dialect of C++ in which this was added. */ + enum cxx_dialect min_dialect; +}; +%% +# The standard-defined types, functions, and options in the std:: namespace +# as defined in the C++ language specification. The result is used in the +# get_std_name_hint functions. +# throws an exception. +# +# <any> +any, "<any>", cxx17 +any_cast, "<any>", cxx17 +make_any, "<any>", cxx17 +# <array> +array, "<array>", cxx11 +to_array, "<array>", cxx20 +# <atomic> +atomic, "<atomic>", cxx11 +atomic_flag, "<atomic>", cxx11 +atomic_ref, "<atomic>", cxx20 +# <bitset> +bitset, "<bitset>", cxx11 +# <compare> +weak_equality, "<compare>", cxx20 +strong_equality, "<compare>", cxx20 +partial_ordering, "<compare>", cxx20 +weak_ordering, "<compare>", cxx20 +strong_ordering, "<compare>", cxx20 +# <complex> +complex, "<complex>", cxx98 +complex_literals, "<complex>", cxx14 +# <condition_variable>. */ +condition_variable, "<condition_variable>", cxx11 +condition_variable_any, "<condition_variable>", cxx11 +# <cstddef> +byte, "<cstddef>", cxx17 +# <deque> +deque, "<deque>", cxx98 +# <forward_list> +forward_list, "<forward_list>", cxx11 +# <fstream> +basic_filebuf, "<fstream>", cxx98 +basic_ifstream, "<fstream>", cxx98 +basic_ofstream, "<fstream>", cxx98 +basic_fstream, "<fstream>", cxx98 +fstream, "<fstream>", cxx98 +ifstream, "<fstream>", cxx98 +ofstream, "<fstream>", cxx98 +# <functional> +bind, "<functional>", cxx11 +bind_front, "<functional>", cxx20 +function, "<functional>", cxx11 +hash, "<functional>", cxx11 +invoke, "<functional>", cxx17 +mem_fn, "<functional>", cxx11 +not_fn, "<functional>", cxx17 +reference_wrapper, "<functional>", cxx11 +unwrap_reference, "<functional>", cxx20 +unwrap_reference_t, "<functional>", cxx20 +unwrap_ref_decay, "<functional>", cxx20 +unwrap_ref_decay_t, "<functional>", cxx20 +# <future>. */ +async, "<future>", cxx11 +future, "<future>", cxx11 +packaged_task, "<future>", cxx11 +promise, "<future>", cxx11 +# <iomanip> +resetiosflags, "<iomanip>", cxx98 +setiosflags, "<iomanip>", cxx98 +setbase, "<iomanip>", cxx98 +setfill, "<iomanip>", cxx98 +setprecision, "<iomanip>", cxx98 +setw, "<iomanip>", cxx98 +get_money, "<iomanip>", cxx11 +put_money, "<iomanip>", cxx11 +get_time, "<iomanip>", cxx11 +put_time, "<iomanip>", cxx11 +quoted, "<iomanip>", cxx14 +# <ios> +boolalpha, "<ios>", cxx98 +noboolalpha, "<ios>", cxx98 +showbase, "<ios>", cxx98 +noshowbase, "<ios>", cxx98 +showpoint, "<ios>", cxx98 +noshowpoint, "<ios>", cxx98 +showpos, "<ios>", cxx98 +noshowpos, "<ios>", cxx98 +skipws, "<ios>", cxx98 +noskipws, "<ios>", cxx98 +uppercase, "<ios>", cxx98 +nouppercase, "<ios>", cxx98 +unitbuf, "<ios>", cxx98 +nounitbuf, "<ios>", cxx98 +internal, "<ios>", cxx98 +left, "<ios>", cxx98 +right, "<ios>", cxx98 +dec, "<ios>", cxx98 +hex, "<ios>", cxx98 +oct, "<ios>", cxx98 +fixed, "<ios>", cxx98 +scientific, "<ios>", cxx98 +hexfloat, "<ios>", cxx11 +defaultfloat, "<ios>", cxx11 +# <iostream> +cin, "<iostream>", cxx98 +cout, "<iostream>", cxx98 +cerr, "<iostream>", cxx98 +clog, "<iostream>", cxx98 +wcin, "<iostream>", cxx98 +wcout, "<iostream>", cxx98 +wclog, "<iostream>", cxx98 +# <istream> +istream, "<istream>", cxx98 +ws, "<istream>", cxx98 +# <iterator> +advance, "<iterator>", cxx98 +back_inserter, "<iterator>", cxx98 +begin, "<iterator>", cxx11 +distance, "<iterator>", cxx98 +end, "<iterator>", cxx11 +front_inserter, "<iterator>", cxx98 +inserter, "<iterator>", cxx98 +istream_iterator, "<iterator>", cxx98 +istreambuf_iterator, "<iterator>", cxx98 +iterator_traits, "<iterator>", cxx98 +move_iterator, "<iterator>", cxx11 +next, "<iterator>", cxx11 +ostream_iterator, "<iterator>", cxx98 +ostreambuf_iterator, "<iterator>", cxx98 +prev, "<iterator>", cxx11 +reverse_iterator, "<iterator>", cxx98 +# <ostream> +ostream, "<ostream>", cxx98 +ends, "<ostream>", cxx98 +flush, "<ostream>", cxx98 +endl, "<ostream>", cxx98 +emit_on_flush, "<ostream>", cxx20 +noemit_on_flush, "<ostream>", cxx20 +flush_emit, "<ostream>", cxx20 +# <list> +list, "<list>", cxx98 +# <map> +map, "<map>", cxx98 +multimap, "<map>", cxx98 +# <memory> +allocate_shared, "<memory>", cxx11 +allocator, "<memory>", cxx98 +allocator_traits, "<memory>", cxx11 +make_shared, "<memory>", cxx11 +make_unique, "<memory>", cxx14 +shared_ptr, "<memory>", cxx11 +unique_ptr, "<memory>", cxx11 +weak_ptr, "<memory>", cxx11 +# <memory_resource> +pmr, "<memory_resource>", cxx17 +# <mutex> +mutex, "<mutex>", cxx11 +timed_mutex, "<mutex>", cxx11 +recursive_mutex, "<mutex>", cxx11 +recursive_timed_mutex, "<mutex>", cxx11 +once_flag, "<mutex>", cxx11 +call_once, "<mutex>", cxx11 +lock, "<mutex>", cxx11 +scoped_lock, "<mutex>", cxx17 +try_lock, "<mutex>", cxx11 +lock_guard, "<mutex>", cxx11 +unique_lock, "<mutex>", cxx11 +# <optional>. */ +optional, "<optional>", cxx17 +make_optional, "<optional>", cxx17 +# <ostream> +ostream, "<ostream>", cxx98 +wostream, "<ostream>", cxx98 +ends, "<ostream>", cxx98 +flush, "<ostream>", cxx98 +endl, "<ostream>", cxx98 +# <queue> +queue, "<queue>", cxx98 +priority_queue, "<queue>", cxx98 +# <set> +set, "<set>", cxx98 +multiset, "<set>", cxx98 +# <shared_mutex> +shared_lock, "<shared_mutex>", cxx14 +shared_mutex, "<shared_mutex>", cxx17 +shared_timed_mutex, "<shared_mutex>", cxx14 +# <source_location> +source_location, "<source_location>", cxx20 +# <sstream> +basic_stringbuf, "<sstream>", cxx98 +basic_istringstream, "<sstream>", cxx98 +basic_ostringstream, "<sstream>", cxx98 +basic_stringstream, "<sstream>", cxx98 +istringstream, "<sstream>", cxx98 +ostringstream, "<sstream>", cxx98 +stringstream, "<sstream>", cxx98 +# <stack> +stack, "<stack>", cxx98 +# <string> +basic_string, "<string>", cxx98 +string, "<string>", cxx98 +wstring, "<string>", cxx98 +u8string, "<string>", cxx20 +u16string, "<string>", cxx11 +u32string, "<string>", cxx11 +# <string_view> +basic_string_view, "<string_view>", cxx17 +string_view, "<string_view>", cxx17 +# <thread> +thread, "<thread>", cxx11 +this_thread, "<thread>", cxx11 +# <tuple> +apply, "<tuple>", cxx17 +forward_as_tuple, "<tuple>", cxx11 +make_from_tuple, "<tuple>", cxx17 +make_tuple, "<tuple>", cxx11 +tie, "<tuple>", cxx11 +tuple, "<tuple>", cxx11 +tuple_cat, "<tuple>", cxx11 +tuple_element, "<tuple>", cxx11 +tuple_element_t, "<tuple>", cxx14 +tuple_size, "<tuple>", cxx11 +tuple_size_v, "<tuple>", cxx17 +# <type_traits> +enable_if, "<type_traits>", cxx11 +enable_if_t, "<type_traits>", cxx14 +invoke_result, "<type_traits>", cxx17 +invoke_result_t, "<type_traits>", cxx17 +remove_cvref, "<type_traits>", cxx20 +remove_cvref_t, "<type_traits>", cxx20 +type_identity, "<type_traits>", cxx20 +type_identity_t, "<type_traits>", cxx20 +void_t, "<type_traits>", cxx17 +conjunction, "<type_traits>", cxx17 +conjunction_v, "<type_traits>", cxx17 +disjunction, "<type_traits>", cxx17 +disjunction_v, "<type_traits>", cxx17 +negation, "<type_traits>", cxx17 +negation_v, "<type_traits>", cxx17 +# <unordered_map> +unordered_map, "<unordered_map>", cxx11 +unordered_multimap, "<unordered_map>", cxx11 +# <unordered_set> +unordered_set, "<unordered_set>", cxx11 +unordered_multiset, "<unordered_set>", cxx11 +# <utility> +declval, "<utility>", cxx11 +forward, "<utility>", cxx11 +make_pair, "<utility>", cxx98 +move, "<utility>", cxx11 +pair, "<utility>", cxx98 +# <variant> +variant, "<variant>", cxx17 +visit, "<variant>", cxx17 +# <vector> +vector, "<vector>", cxx98 diff --git a/gcc/cp/std-name-hint.h b/gcc/cp/std-name-hint.h new file mode 100644 index 0000000..c48eac3 --- /dev/null +++ b/gcc/cp/std-name-hint.h @@ -0,0 +1,675 @@ +/* C++ code produced by gperf version 3.1 */ +/* Command-line: gperf -o -C -E -D -N find -L C++ --output-file std-name-hint.h -k'1,2,7,11,$' std-name-hint.gperf */ + +#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ + && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ + && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ + && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ + && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ + && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ + && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ + && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ + && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ + && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ + && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ + && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ + && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ + && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ + && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ + && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ + && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ + && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ + && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ + && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ + && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ + && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ + && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) +/* The character set is not based on ISO-646. */ +#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gperf@gnu.org>." +#endif + +#line 4 "std-name-hint.gperf" + +/* Copyright (C) 2022 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ +#line 23 "std-name-hint.gperf" +struct std_name_hint +{ + /* A name within "std::". */ + const char *name; + + /* The header name defining it within the C++ Standard Library + (with '<' and '>'). */ + const char* header; + + /* The dialect of C++ in which this was added. */ + enum cxx_dialect min_dialect; +}; +/* maximum key range = 626, duplicates = 4 */ + +class std_name_hint_lookup +{ +private: + static inline unsigned int hash (const char *str, size_t len); +public: + static const struct std_name_hint *find (const char *str, size_t len); +}; + +inline unsigned int +std_name_hint_lookup::hash (const char *str, size_t len) +{ + static const unsigned short asso_values[] = + { + 635, 635, 635, 635, 635, 635, 635, 635, 635, 635, + 635, 635, 635, 635, 635, 635, 635, 635, 635, 635, + 635, 635, 635, 635, 635, 635, 635, 635, 635, 635, + 635, 635, 635, 635, 635, 635, 635, 635, 635, 635, + 635, 635, 635, 635, 635, 635, 635, 635, 635, 5, + 635, 0, 635, 635, 635, 635, 25, 635, 635, 635, + 635, 635, 635, 635, 635, 635, 635, 635, 635, 635, + 635, 635, 635, 635, 635, 635, 635, 635, 635, 635, + 635, 635, 635, 635, 635, 635, 635, 635, 635, 635, + 635, 635, 635, 635, 635, 45, 635, 25, 70, 165, + 20, 0, 35, 225, 190, 95, 635, 120, 183, 10, + 5, 25, 165, 5, 5, 10, 0, 55, 4, 143, + 115, 229, 635, 635, 635, 635, 635, 635, 635, 635, + 635, 635, 635, 635, 635, 635, 635, 635, 635, 635, + 635, 635, 635, 635, 635, 635, 635, 635, 635, 635, + 635, 635, 635, 635, 635, 635, 635, 635, 635, 635, + 635, 635, 635, 635, 635, 635, 635, 635, 635, 635, + 635, 635, 635, 635, 635, 635, 635, 635, 635, 635, + 635, 635, 635, 635, 635, 635, 635, 635, 635, 635, + 635, 635, 635, 635, 635, 635, 635, 635, 635, 635, + 635, 635, 635, 635, 635, 635, 635, 635, 635, 635, + 635, 635, 635, 635, 635, 635, 635, 635, 635, 635, + 635, 635, 635, 635, 635, 635, 635, 635, 635, 635, + 635, 635, 635, 635, 635, 635, 635, 635, 635, 635, + 635, 635, 635, 635, 635, 635, 635, 635, 635, 635, + 635, 635, 635, 635, 635, 635 + }; + unsigned int hval = len; + + switch (hval) + { + default: + hval += asso_values[static_cast<unsigned char>(str[10])]; + /*FALLTHROUGH*/ + case 10: + case 9: + case 8: + case 7: + hval += asso_values[static_cast<unsigned char>(str[6])]; + /*FALLTHROUGH*/ + case 6: + case 5: + case 4: + case 3: + case 2: + hval += asso_values[static_cast<unsigned char>(str[1])]; + /*FALLTHROUGH*/ + case 1: + hval += asso_values[static_cast<unsigned char>(str[0])]; + break; + } + return hval + asso_values[static_cast<unsigned char>(str[len - 1])]; +} + +const struct std_name_hint * +std_name_hint_lookup::find (const char *str, size_t len) +{ + enum + { + TOTAL_KEYWORDS = 205, + MIN_WORD_LENGTH = 2, + MAX_WORD_LENGTH = 22, + MIN_HASH_VALUE = 9, + MAX_HASH_VALUE = 634 + }; + + static const struct std_name_hint wordlist[] = + { +#line 158 "std-name-hint.gperf" + {"next", "<iterator>", cxx11}, +#line 212 "std-name-hint.gperf" + {"set", "<set>", cxx98}, +#line 287 "std-name-hint.gperf" + {"vector", "<vector>", cxx98}, +#line 101 "std-name-hint.gperf" + {"setbase", "<iomanip>", cxx98}, +#line 165 "std-name-hint.gperf" + {"ends", "<ostream>", cxx98}, +#line 205 "std-name-hint.gperf" + {"ends", "<ostream>", cxx98}, +#line 86 "std-name-hint.gperf" + {"mem_fn", "<functional>", cxx11}, +#line 69 "std-name-hint.gperf" + {"deque", "<deque>", cxx98}, +#line 162 "std-name-hint.gperf" + {"reverse_iterator", "<iterator>", cxx98}, +#line 151 "std-name-hint.gperf" + {"end", "<iterator>", cxx11}, +#line 264 "std-name-hint.gperf" + {"void_t", "<type_traits>", cxx17}, +#line 284 "std-name-hint.gperf" + {"variant", "<variant>", cxx17}, +#line 281 "std-name-hint.gperf" + {"move", "<utility>", cxx11}, +#line 87 "std-name-hint.gperf" + {"not_fn", "<functional>", cxx17}, +#line 269 "std-name-hint.gperf" + {"negation", "<type_traits>", cxx17}, +#line 270 "std-name-hint.gperf" + {"negation_v", "<type_traits>", cxx17}, +#line 122 "std-name-hint.gperf" + {"nouppercase", "<ios>", cxx98}, +#line 43 "std-name-hint.gperf" + {"any_cast", "<any>", cxx17}, +#line 181 "std-name-hint.gperf" + {"make_unique", "<memory>", cxx14}, +#line 147 "std-name-hint.gperf" + {"advance", "<iterator>", cxx98}, +#line 157 "std-name-hint.gperf" + {"move_iterator", "<iterator>", cxx11}, +#line 246 "std-name-hint.gperf" + {"make_from_tuple", "<tuple>", cxx17}, +#line 134 "std-name-hint.gperf" + {"defaultfloat", "<ios>", cxx11}, +#line 249 "std-name-hint.gperf" + {"tuple", "<tuple>", cxx11}, +#line 257 "std-name-hint.gperf" + {"enable_if_t", "<type_traits>", cxx14}, +#line 164 "std-name-hint.gperf" + {"ostream", "<ostream>", cxx98}, +#line 203 "std-name-hint.gperf" + {"ostream", "<ostream>", cxx98}, +#line 261 "std-name-hint.gperf" + {"remove_cvref_t", "<type_traits>", cxx20}, +#line 209 "std-name-hint.gperf" + {"queue", "<queue>", cxx98}, +#line 159 "std-name-hint.gperf" + {"ostream_iterator", "<iterator>", cxx98}, +#line 227 "std-name-hint.gperf" + {"stringstream", "<sstream>", cxx98}, +#line 251 "std-name-hint.gperf" + {"tuple_element", "<tuple>", cxx11}, +#line 252 "std-name-hint.gperf" + {"tuple_element_t", "<tuple>", cxx14}, +#line 77 "std-name-hint.gperf" + {"fstream", "<fstream>", cxx98}, +#line 213 "std-name-hint.gperf" + {"multiset", "<set>", cxx98}, +#line 280 "std-name-hint.gperf" + {"make_pair", "<utility>", cxx98}, +#line 253 "std-name-hint.gperf" + {"tuple_size", "<tuple>", cxx11}, +#line 100 "std-name-hint.gperf" + {"setiosflags", "<iomanip>", cxx98}, +#line 99 "std-name-hint.gperf" + {"resetiosflags", "<iomanip>", cxx98}, +#line 149 "std-name-hint.gperf" + {"begin", "<iterator>", cxx11}, +#line 109 "std-name-hint.gperf" + {"quoted", "<iomanip>", cxx14}, +#line 275 "std-name-hint.gperf" + {"unordered_set", "<unordered_set>", cxx11}, +#line 276 "std-name-hint.gperf" + {"unordered_multiset", "<unordered_set>", cxx11}, +#line 256 "std-name-hint.gperf" + {"enable_if", "<type_traits>", cxx11}, +#line 95 "std-name-hint.gperf" + {"future", "<future>", cxx11}, +#line 260 "std-name-hint.gperf" + {"remove_cvref", "<type_traits>", cxx20}, +#line 248 "std-name-hint.gperf" + {"tie", "<tuple>", cxx11}, +#line 247 "std-name-hint.gperf" + {"make_tuple", "<tuple>", cxx11}, +#line 71 "std-name-hint.gperf" + {"forward_list", "<forward_list>", cxx11}, +#line 79 "std-name-hint.gperf" + {"ofstream", "<fstream>", cxx98}, +#line 285 "std-name-hint.gperf" + {"visit", "<variant>", cxx17}, +#line 127 "std-name-hint.gperf" + {"right", "<ios>", cxx98}, +#line 85 "std-name-hint.gperf" + {"invoke", "<functional>", cxx17}, +#line 279 "std-name-hint.gperf" + {"forward", "<utility>", cxx11}, +#line 114 "std-name-hint.gperf" + {"noshowbase", "<ios>", cxx98}, +#line 153 "std-name-hint.gperf" + {"inserter", "<iterator>", cxx98}, +#line 160 "std-name-hint.gperf" + {"ostreambuf_iterator", "<iterator>", cxx98}, +#line 51 "std-name-hint.gperf" + {"atomic_ref", "<atomic>", cxx20}, +#line 112 "std-name-hint.gperf" + {"noboolalpha", "<ios>", cxx98}, +#line 148 "std-name-hint.gperf" + {"back_inserter", "<iterator>", cxx98}, +#line 183 "std-name-hint.gperf" + {"unique_ptr", "<memory>", cxx11}, +#line 89 "std-name-hint.gperf" + {"unwrap_reference", "<functional>", cxx20}, +#line 90 "std-name-hint.gperf" + {"unwrap_reference_t", "<functional>", cxx20}, +#line 219 "std-name-hint.gperf" + {"source_location", "<source_location>", cxx20}, +#line 254 "std-name-hint.gperf" + {"tuple_size_v", "<tuple>", cxx17}, +#line 83 "std-name-hint.gperf" + {"function", "<functional>", cxx11}, +#line 144 "std-name-hint.gperf" + {"istream", "<istream>", cxx98}, +#line 229 "std-name-hint.gperf" + {"stack", "<stack>", cxx98}, +#line 154 "std-name-hint.gperf" + {"istream_iterator", "<iterator>", cxx98}, +#line 123 "std-name-hint.gperf" + {"unitbuf", "<ios>", cxx98}, +#line 224 "std-name-hint.gperf" + {"basic_stringstream", "<sstream>", cxx98}, +#line 245 "std-name-hint.gperf" + {"forward_as_tuple", "<tuple>", cxx11}, +#line 124 "std-name-hint.gperf" + {"nounitbuf", "<ios>", cxx98}, +#line 119 "std-name-hint.gperf" + {"skipws", "<ios>", cxx98}, +#line 75 "std-name-hint.gperf" + {"basic_ofstream", "<fstream>", cxx98}, +#line 156 "std-name-hint.gperf" + {"iterator_traits", "<iterator>", cxx98}, +#line 76 "std-name-hint.gperf" + {"basic_fstream", "<fstream>", cxx98}, +#line 131 "std-name-hint.gperf" + {"fixed", "<ios>", cxx98}, +#line 184 "std-name-hint.gperf" + {"weak_ptr", "<memory>", cxx11}, +#line 104 "std-name-hint.gperf" + {"setw", "<iomanip>", cxx98}, +#line 152 "std-name-hint.gperf" + {"front_inserter", "<iterator>", cxx98}, +#line 221 "std-name-hint.gperf" + {"basic_stringbuf", "<sstream>", cxx98}, +#line 145 "std-name-hint.gperf" + {"ws", "<istream>", cxx98}, +#line 92 "std-name-hint.gperf" + {"unwrap_ref_decay_t", "<functional>", cxx20}, +#line 53 "std-name-hint.gperf" + {"bitset", "<bitset>", cxx11}, +#line 78 "std-name-hint.gperf" + {"ifstream", "<fstream>", cxx98}, +#line 138 "std-name-hint.gperf" + {"cerr", "<iostream>", cxx98}, +#line 88 "std-name-hint.gperf" + {"reference_wrapper", "<functional>", cxx11}, +#line 97 "std-name-hint.gperf" + {"promise", "<future>", cxx11}, +#line 161 "std-name-hint.gperf" + {"prev", "<iterator>", cxx11}, +#line 82 "std-name-hint.gperf" + {"bind_front", "<functional>", cxx20}, +#line 186 "std-name-hint.gperf" + {"pmr", "<memory_resource>", cxx17}, +#line 155 "std-name-hint.gperf" + {"istreambuf_iterator", "<iterator>", cxx98}, +#line 188 "std-name-hint.gperf" + {"mutex", "<mutex>", cxx11}, +#line 126 "std-name-hint.gperf" + {"left", "<ios>", cxx98}, +#line 128 "std-name-hint.gperf" + {"dec", "<ios>", cxx98}, +#line 81 "std-name-hint.gperf" + {"bind", "<functional>", cxx11}, +#line 120 "std-name-hint.gperf" + {"noskipws", "<ios>", cxx98}, +#line 167 "std-name-hint.gperf" + {"endl", "<ostream>", cxx98}, +#line 207 "std-name-hint.gperf" + {"endl", "<ostream>", cxx98}, +#line 130 "std-name-hint.gperf" + {"oct", "<ios>", cxx98}, +#line 137 "std-name-hint.gperf" + {"cout", "<iostream>", cxx98}, +#line 49 "std-name-hint.gperf" + {"atomic", "<atomic>", cxx11}, +#line 282 "std-name-hint.gperf" + {"pair", "<utility>", cxx98}, +#line 174 "std-name-hint.gperf" + {"map", "<map>", cxx98}, +#line 193 "std-name-hint.gperf" + {"call_once", "<mutex>", cxx11}, +#line 94 "std-name-hint.gperf" + {"async", "<future>", cxx11}, +#line 116 "std-name-hint.gperf" + {"noshowpoint", "<ios>", cxx98}, +#line 204 "std-name-hint.gperf" + {"wostream", "<ostream>", cxx98}, +#line 258 "std-name-hint.gperf" + {"invoke_result", "<type_traits>", cxx17}, +#line 118 "std-name-hint.gperf" + {"noshowpos", "<ios>", cxx98}, +#line 259 "std-name-hint.gperf" + {"invoke_result_t", "<type_traits>", cxx17}, +#line 241 "std-name-hint.gperf" + {"thread", "<thread>", cxx11}, +#line 103 "std-name-hint.gperf" + {"setprecision", "<iomanip>", cxx98}, +#line 113 "std-name-hint.gperf" + {"showbase", "<ios>", cxx98}, +#line 74 "std-name-hint.gperf" + {"basic_ifstream", "<fstream>", cxx98}, +#line 178 "std-name-hint.gperf" + {"allocator", "<memory>", cxx98}, +#line 133 "std-name-hint.gperf" + {"hexfloat", "<ios>", cxx11}, +#line 117 "std-name-hint.gperf" + {"showpos", "<ios>", cxx98}, +#line 170 "std-name-hint.gperf" + {"flush_emit", "<ostream>", cxx20}, +#line 250 "std-name-hint.gperf" + {"tuple_cat", "<tuple>", cxx11}, +#line 179 "std-name-hint.gperf" + {"allocator_traits", "<memory>", cxx11}, +#line 191 "std-name-hint.gperf" + {"recursive_timed_mutex", "<mutex>", cxx11}, +#line 108 "std-name-hint.gperf" + {"put_time", "<iomanip>", cxx11}, +#line 210 "std-name-hint.gperf" + {"priority_queue", "<queue>", cxx98}, +#line 190 "std-name-hint.gperf" + {"recursive_mutex", "<mutex>", cxx11}, +#line 232 "std-name-hint.gperf" + {"string", "<string>", cxx98}, +#line 107 "std-name-hint.gperf" + {"get_time", "<iomanip>", cxx11}, +#line 223 "std-name-hint.gperf" + {"basic_ostringstream", "<sstream>", cxx98}, +#line 73 "std-name-hint.gperf" + {"basic_filebuf", "<fstream>", cxx98}, +#line 272 "std-name-hint.gperf" + {"unordered_map", "<unordered_map>", cxx11}, +#line 121 "std-name-hint.gperf" + {"uppercase", "<ios>", cxx98}, +#line 273 "std-name-hint.gperf" + {"unordered_multimap", "<unordered_map>", cxx11}, +#line 182 "std-name-hint.gperf" + {"shared_ptr", "<memory>", cxx11}, +#line 42 "std-name-hint.gperf" + {"any", "<any>", cxx17}, +#line 175 "std-name-hint.gperf" + {"multimap", "<map>", cxx98}, +#line 46 "std-name-hint.gperf" + {"array", "<array>", cxx11}, +#line 136 "std-name-hint.gperf" + {"cin", "<iostream>", cxx98}, +#line 238 "std-name-hint.gperf" + {"basic_string_view", "<string_view>", cxx17}, +#line 168 "std-name-hint.gperf" + {"emit_on_flush", "<ostream>", cxx20}, +#line 180 "std-name-hint.gperf" + {"make_shared", "<memory>", cxx11}, +#line 44 "std-name-hint.gperf" + {"make_any", "<any>", cxx17}, +#line 172 "std-name-hint.gperf" + {"list", "<list>", cxx98}, +#line 226 "std-name-hint.gperf" + {"ostringstream", "<sstream>", cxx98}, +#line 47 "std-name-hint.gperf" + {"to_array", "<array>", cxx20}, +#line 150 "std-name-hint.gperf" + {"distance", "<iterator>", cxx98}, +#line 197 "std-name-hint.gperf" + {"lock_guard", "<mutex>", cxx11}, +#line 111 "std-name-hint.gperf" + {"boolalpha", "<ios>", cxx98}, +#line 59 "std-name-hint.gperf" + {"strong_ordering", "<compare>", cxx20}, +#line 196 "std-name-hint.gperf" + {"try_lock", "<mutex>", cxx11}, +#line 267 "std-name-hint.gperf" + {"disjunction", "<type_traits>", cxx17}, +#line 268 "std-name-hint.gperf" + {"disjunction_v", "<type_traits>", cxx17}, +#line 67 "std-name-hint.gperf" + {"byte", "<cstddef>", cxx17}, +#line 115 "std-name-hint.gperf" + {"showpoint", "<ios>", cxx98}, +#line 64 "std-name-hint.gperf" + {"condition_variable", "<condition_variable>", cxx11}, +#line 129 "std-name-hint.gperf" + {"hex", "<ios>", cxx98}, +#line 141 "std-name-hint.gperf" + {"wcout", "<iostream>", cxx98}, +#line 222 "std-name-hint.gperf" + {"basic_istringstream", "<sstream>", cxx98}, +#line 169 "std-name-hint.gperf" + {"noemit_on_flush", "<ostream>", cxx20}, +#line 125 "std-name-hint.gperf" + {"internal", "<ios>", cxx98}, +#line 140 "std-name-hint.gperf" + {"wcin", "<iostream>", cxx98}, +#line 234 "std-name-hint.gperf" + {"u8string", "<string>", cxx20}, +#line 56 "std-name-hint.gperf" + {"strong_equality", "<compare>", cxx20}, +#line 62 "std-name-hint.gperf" + {"complex_literals", "<complex>", cxx14}, +#line 194 "std-name-hint.gperf" + {"lock", "<mutex>", cxx11}, +#line 189 "std-name-hint.gperf" + {"timed_mutex", "<mutex>", cxx11}, +#line 231 "std-name-hint.gperf" + {"basic_string", "<string>", cxx98}, +#line 96 "std-name-hint.gperf" + {"packaged_task", "<future>", cxx11}, +#line 239 "std-name-hint.gperf" + {"string_view", "<string_view>", cxx17}, +#line 225 "std-name-hint.gperf" + {"istringstream", "<sstream>", cxx98}, +#line 198 "std-name-hint.gperf" + {"unique_lock", "<mutex>", cxx11}, +#line 263 "std-name-hint.gperf" + {"type_identity_t", "<type_traits>", cxx20}, +#line 216 "std-name-hint.gperf" + {"shared_mutex", "<shared_mutex>", cxx17}, +#line 265 "std-name-hint.gperf" + {"conjunction", "<type_traits>", cxx17}, +#line 266 "std-name-hint.gperf" + {"conjunction_v", "<type_traits>", cxx17}, +#line 217 "std-name-hint.gperf" + {"shared_timed_mutex", "<shared_mutex>", cxx14}, +#line 102 "std-name-hint.gperf" + {"setfill", "<iomanip>", cxx98}, +#line 236 "std-name-hint.gperf" + {"u32string", "<string>", cxx11}, +#line 235 "std-name-hint.gperf" + {"u16string", "<string>", cxx11}, +#line 278 "std-name-hint.gperf" + {"declval", "<utility>", cxx11}, +#line 91 "std-name-hint.gperf" + {"unwrap_ref_decay", "<functional>", cxx20}, +#line 201 "std-name-hint.gperf" + {"make_optional", "<optional>", cxx17}, +#line 200 "std-name-hint.gperf" + {"optional", "<optional>", cxx17}, +#line 84 "std-name-hint.gperf" + {"hash", "<functional>", cxx11}, +#line 166 "std-name-hint.gperf" + {"flush", "<ostream>", cxx98}, +#line 206 "std-name-hint.gperf" + {"flush", "<ostream>", cxx98}, +#line 244 "std-name-hint.gperf" + {"apply", "<tuple>", cxx17}, +#line 61 "std-name-hint.gperf" + {"complex", "<complex>", cxx98}, +#line 242 "std-name-hint.gperf" + {"this_thread", "<thread>", cxx11}, +#line 177 "std-name-hint.gperf" + {"allocate_shared", "<memory>", cxx11}, +#line 132 "std-name-hint.gperf" + {"scientific", "<ios>", cxx98}, +#line 192 "std-name-hint.gperf" + {"once_flag", "<mutex>", cxx11}, +#line 106 "std-name-hint.gperf" + {"put_money", "<iomanip>", cxx11}, +#line 105 "std-name-hint.gperf" + {"get_money", "<iomanip>", cxx11}, +#line 195 "std-name-hint.gperf" + {"scoped_lock", "<mutex>", cxx17}, +#line 58 "std-name-hint.gperf" + {"weak_ordering", "<compare>", cxx20}, +#line 55 "std-name-hint.gperf" + {"weak_equality", "<compare>", cxx20}, +#line 215 "std-name-hint.gperf" + {"shared_lock", "<shared_mutex>", cxx14}, +#line 50 "std-name-hint.gperf" + {"atomic_flag", "<atomic>", cxx11}, +#line 142 "std-name-hint.gperf" + {"wclog", "<iostream>", cxx98}, +#line 65 "std-name-hint.gperf" + {"condition_variable_any", "<condition_variable>", cxx11}, +#line 139 "std-name-hint.gperf" + {"clog", "<iostream>", cxx98}, +#line 262 "std-name-hint.gperf" + {"type_identity", "<type_traits>", cxx20}, +#line 233 "std-name-hint.gperf" + {"wstring", "<string>", cxx98}, +#line 57 "std-name-hint.gperf" + {"partial_ordering", "<compare>", cxx20} + }; + + static const short lookup[] = + { + -1, -1, -1, -1, -1, -1, -1, -1, + -1, 0, -1, -1, -1, 1, -1, 2, + -1, 3, -1, -228, -1, 6, -201, -2, + -1, 7, 8, -1, 9, -1, -1, -1, + -1, -1, -1, 10, 11, -1, -1, 12, + -1, 13, -1, 14, 15, -1, 16, -1, + 17, -1, -1, 18, 19, 20, -1, 21, + -1, 22, -1, -1, 23, 24, -287, -1, + 27, 28, 29, 30, 31, -1, 32, -1, + 33, 34, 35, 36, 37, -1, 38, -1, + 39, -180, -2, -1, -1, -1, 40, -1, + 41, -1, -1, -1, -1, 42, 43, -1, + 44, 45, 46, -1, 47, -1, 48, 49, + 50, 51, 52, 53, -1, -1, 54, -1, + -1, 55, 56, 57, 58, -1, 59, -1, + 60, 61, -1, 62, -1, 63, 64, -1, + 65, -1, -1, -1, 66, -1, -1, 67, + 68, 69, 70, -1, -1, 71, -1, -1, + 72, -1, 73, -1, -1, 74, 75, -1, + -1, 76, -1, 77, 78, 79, -1, 80, + 81, -1, -1, -1, -1, 82, -1, -1, + 83, -1, -1, 84, -1, 85, 86, 87, + -1, 88, 89, -1, 90, -1, -1, 91, + 92, 93, -1, 94, 95, 96, -1, 97, + -403, 100, 101, -1, 102, -107, -2, 103, + -1, -1, -1, 104, 105, 106, 107, -1, + -1, -1, -1, 108, -1, 109, 110, 111, + 112, 113, 114, 115, -1, -1, 116, 117, + -1, -1, -1, 118, 119, 120, -1, -1, + -1, -1, 121, -1, 122, -1, 123, 124, + 125, 126, -1, 127, 128, -1, -1, -1, + 129, -1, -1, -1, -1, 130, 131, -1, + -1, -1, 132, -1, 133, -1, 134, 135, + 136, -1, -1, -1, 137, -1, 138, -1, + -1, 139, -1, -1, 140, 141, -1, -1, + -1, -1, 142, 143, -1, -1, -1, 144, + 145, -1, -1, -1, -1, 146, 147, 148, + -1, -1, 149, -1, -1, 150, 151, 152, + 153, -1, -1, 154, 155, -1, -1, -1, + -1, 156, 157, 158, 159, 160, 161, -1, + -1, -1, -1, -1, 162, -1, -1, -1, + -1, -1, -1, 163, 164, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 165, 166, 167, -1, -1, -1, + 168, 169, -1, -1, 170, -1, -1, 171, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 172, -1, -1, -1, + 173, 174, 175, -1, -1, -1, -1, 176, + 177, -1, -1, -1, -1, 178, -1, -1, + -1, 179, -1, 180, -1, -1, -1, -1, + -1, 181, -1, -1, -1, -1, 182, -1, + -1, 183, -1, -1, -1, -620, -21, -2, + -1, -1, -1, -1, -1, -1, -1, -1, + 186, -1, -1, 187, -1, -1, -1, 188, + -1, 189, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 190, -1, 191, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 192, + -1, -1, -1, -1, 193, -1, -1, 194, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, 195, -1, -1, -1, 196, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + 197, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 198, -1, -1, -1, -1, + -1, -1, 199, -1, 200, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, 201, -1, -1, -1, -1, -1, -1, + -1, -1, 202, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 203, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 204 + }; + + if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) + { + unsigned int key = hash (str, len); + + if (key <= MAX_HASH_VALUE) + { + int index = lookup[key]; + + if (index >= 0) + { + const char *s = wordlist[index].name; + + if (*str == *s && !strcmp (str + 1, s + 1)) + return &wordlist[index]; + } + else if (index < -TOTAL_KEYWORDS) + { + int offset = - 1 - TOTAL_KEYWORDS - index; + const struct std_name_hint *wordptr = &wordlist[TOTAL_KEYWORDS + lookup[offset]]; + const struct std_name_hint *wordendptr = wordptr + -lookup[offset + 1]; + + while (wordptr < wordendptr) + { + const char *s = wordptr->name; + + if (*str == *s && !strcmp (str + 1, s + 1)) + return wordptr; + wordptr++; + } + } + } + } + return 0; +} diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc index 7fde65a..b99947c 100644 --- a/gcc/cp/typeck.cc +++ b/gcc/cp/typeck.cc @@ -8897,7 +8897,56 @@ cp_build_c_cast (location_t loc, tree type, tree expr, return error_mark_node; } - + +/* Warn when a value is moved to itself with std::move. LHS is the target, + RHS may be the std::move call, and LOC is the location of the whole + assignment. */ + +static void +maybe_warn_self_move (location_t loc, tree lhs, tree rhs) +{ + if (!warn_self_move) + return; + + /* C++98 doesn't know move. */ + if (cxx_dialect < cxx11) + return; + + if (processing_template_decl) + return; + + if (!REFERENCE_REF_P (rhs) + || TREE_CODE (TREE_OPERAND (rhs, 0)) != CALL_EXPR) + return; + tree fn = TREE_OPERAND (rhs, 0); + if (!is_std_move_p (fn)) + return; + + /* Just a little helper to strip * and various NOPs. */ + auto extract_op = [] (tree &op) { + STRIP_NOPS (op); + while (INDIRECT_REF_P (op)) + op = TREE_OPERAND (op, 0); + op = maybe_undo_parenthesized_ref (op); + STRIP_ANY_LOCATION_WRAPPER (op); + }; + + tree arg = CALL_EXPR_ARG (fn, 0); + extract_op (arg); + if (TREE_CODE (arg) == ADDR_EXPR) + arg = TREE_OPERAND (arg, 0); + tree type = TREE_TYPE (lhs); + tree orig_lhs = lhs; + extract_op (lhs); + if (cp_tree_equal (lhs, arg)) + { + auto_diagnostic_group d; + if (warning_at (loc, OPT_Wself_move, + "moving %qE of type %qT to itself", orig_lhs, type)) + inform (loc, "remove %<std::move%> call"); + } +} + /* For use from the C common bits. */ tree build_modify_expr (location_t location, @@ -9101,6 +9150,8 @@ cp_build_modify_expr (location_t loc, tree lhs, enum tree_code modifycode, if (modifycode == NOP_EXPR) { + maybe_warn_self_move (loc, lhs, rhs); + if (c_dialect_objc ()) { result = objc_maybe_build_modify_expr (lhs, rhs); |