aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
AgeCommit message (Collapse)AuthorFilesLines
2019-09-02Use cxx_printable_name for __PRETTY_FUNCTION__ in cp_fname_init.Martin Liska1-3/+17
2019-09-02 Martin Liska <mliska@suse.cz> PR c++/91155 * c-common.c (fname_as_string): Use cxx_printable_name for __PRETTY_FUNCTION__ same as was used before r265711. 2019-09-02 Martin Liska <mliska@suse.cz> PR c++/91155 * g++.dg/torture/pr91155.C: New test. From-SVN: r275292
2019-09-01PR c++/91129 - wrong error with binary op in template argument.Marek Polacek2-11/+14
* typeck.c (warn_for_null_address): Use fold_for_warn instead of fold_non_dependent_expr. (cp_build_binary_op): Likewise. * g++.dg/cpp1y/nontype1.C: New test. From-SVN: r275285
2019-08-31Add source location to TRAIT_EXPR.Jason Merrill6-6/+25
Since TRAIT_EXPR is exceptional, maybe_wrap_with_location won't wrap it, so we need to put its location in the TRAIT_EXPR node itself. * cp-tree.h (TRAIT_EXPR_LOCATION): New. (struct tree_trait_expr): Add locus field. * parser.c (cp_parser_trait_expr): Pass trait_loc down. * pt.c (tsubst_copy_and_build) [TRAIT_EXPR]: Likewise. * semantics.c (finish_trait_expr): Add location parm. * tree.c (cp_expr_location): Handle TRAIT_EXPR. From-SVN: r275260
2019-08-29decl.c (check_var_type): Add location_t parameter and use it.Paolo Carlini4-8/+16
/cp 2019-08-29 Paolo Carlini <paolo.carlini@oracle.com> * decl.c (check_var_type): Add location_t parameter and use it. (grokdeclarator): Adjust call. * pt.c (tsubst_decl): Likewise. * cp-tree.h: Adjust declaration. /testsuite 2019-08-29 Paolo Carlini <paolo.carlini@oracle.com> * g++.dg/spellcheck-typenames.C: Adjust expected locations. * g++.dg/cpp0x/pr84676.C: Check locations. * g++.dg/other/pr88187.C: Likewise. * g++.dg/parse/crash13.C: Likewise. * g++.dg/parse/crash46.C: Likewise. * g++.dg/parse/template28.C: Likewise. * g++.dg/parse/typename4.C: Likewise. From-SVN: r275025
2019-08-29Implement P1152R4: Deprecating some uses of volatile.Marek Polacek5-2/+82
PR c++/91361 * c-opts.c (c_common_post_options): Enable -Wvolatile by default for C++2a, unless -Wno-deprecated. * c.opt (Wvolatile): New warning. * cp-gimplify.c (cp_fold): Set TREE_THIS_VOLATILE. * decl.c (grokdeclarator): Warn about a volatile-qualified structured binding and return type. (grokparms): Warn about a volatile-qualified function parameter. * expr.c (mark_use) <case MODIFY_EXPR>: Emit a -Wvolatile warning. * typeck.c (cp_build_unary_op): Emit a -Wvolatile warning for pre and post ++/-- on a volatile operand. (genericize_compound_lvalue): Use a better location. Don't lose TREE_THIS_VOLATILE. (cp_build_modify_expr): Emit a -Wvolatile warning for a compound assignment whose LHS is volatile-qualified. Build the assignment with a more precise location. * doc/invoke.texi: Document -Wvolatile. * c-c++-common/Wbool-operation-1.c: Use -Wno-volatile in C++. * c-c++-common/gomp/atomic-1.c: Likewise. * c-c++-common/gomp/atomic-9.c: Likewise. * c-c++-common/gomp/depend-iterator-1.c: Likewise. * c-c++-common/gomp/loop-1.c: Adjust warning location for C++. * c-c++-common/gomp/order-3.c: Likewise. * c-c++-common/pr69733.c: Use -Wno-volatile in C++. * c-c++-common/spec-barrier-2.c: Likewise. * c-c++-common/tm/pr54893.c: Likewise. * g++.dg/cpp0x/pr65327.C: Add dg-warning. * g++.dg/cpp0x/rv-conv2.C: Likewise. * g++.dg/cpp0x/rv1n.C: Likewise. * g++.dg/cpp0x/rv1p.C: Likewise. * g++.dg/cpp0x/rv2n.C: Likewise. * g++.dg/cpp0x/rv2p.C: Likewise. * g++.dg/cpp0x/rv3n.C: Likewise. * g++.dg/cpp0x/rv3p.C: Likewise. * g++.dg/cpp0x/rv4n.C: Likewise. * g++.dg/cpp0x/rv4p.C: Likewise. * g++.dg/cpp0x/rv5n.C: Likewise. * g++.dg/cpp0x/rv5p.C: Likewise. * g++.dg/cpp0x/rv6n.C: Likewise. * g++.dg/cpp0x/rv6p.C: Likewise. * g++.dg/cpp0x/rv7n.C: Likewise. * g++.dg/cpp0x/rv7p.C: Likewise. * g++.dg/cpp0x/rv8p.C: Likewise. * g++.dg/cpp0x/trailing14.C: Use -Wno-volatile. * g++.dg/cpp1y/new1.C: Add dg-warning. * g++.dg/cpp2a/volatile1.C: New test. * g++.dg/cpp2a/volatile2.C: New test. * g++.dg/cpp2a/volatile3.C: New test. * g++.dg/cpp2a/volatile4.C: New test. * g++.dg/expr/bool3.C: Add dg-warning. * g++.dg/expr/bool4.C: Likewise. * g++.dg/expr/cond9.C: Likewise. * g++.dg/ext/vector25.C: Likewise. * g++.dg/gomp/depend-iterator-1.C: Use -Wno-volatile. * g++.dg/inherit/covariant21.C: Add dg-warning. * g++.dg/init/ref18.C: Likewise. * g++.dg/ipa/pr63838.C: Likewise. * g++.dg/overload/rvalue2.C: Likewise. * g++.dg/parse/semicolon4.C: Likewise. * g++.dg/warn/Wreturn-type-4.C: Likewise. * g++.dg/warn/pr36069.C: Likewise. * g++.old-deja/g++.mike/p9506.C: Likewise. * g++.old-deja/g++.other/volatile1.C: Likewise. From-SVN: r275022
2019-08-28PR c++/91360 - Implement C++20 P1143R2: constinit.Marek Polacek7-15/+165
* c-common.c (c_common_reswords): Add constinit and __constinit. (keyword_is_decl_specifier): Handle RID_CONSTINIT. * c-common.h (enum rid): Add RID_CONSTINIT, RID_FIRST_CXX20, and RID_LAST_CXX20. (D_CXX20): Define. * c-cppbuiltin.c (c_cpp_builtins): Define __cpp_constinit. * c-format.c (cxx_keywords): Add "constinit". * c.opt (Wc++2a-compat, Wc++20-compat): New options. * cp-tree.h (TINFO_VAR_DECLARED_CONSTINIT): Define. (LOOKUP_CONSTINIT): Define. (enum cp_decl_spec): Add ds_constinit. * decl.c (check_tag_decl): Give an error for constinit in type declarations. (check_initializer): Also check LOOKUP_CONSTINIT. (cp_finish_decl): Add checking for a constinit declaration. Set TINFO_VAR_DECLARED_CONSTINIT. (grokdeclarator): Add checking for a declaration with the constinit specifier. * lex.c (init_reswords): Handle D_CXX20. * parser.c (cp_lexer_get_preprocessor_token): Pass a better location to warning_at. Warn about C++20 keywords. (cp_keyword_starts_decl_specifier_p): Handle RID_CONSTINIT. (cp_parser_diagnose_invalid_type_name): Add an inform about constinit. (cp_parser_decomposition_declaration): Maybe pass LOOKUP_CONSTINIT to cp_finish_decl. (cp_parser_decl_specifier_seq): Handle RID_CONSTINIT. (cp_parser_init_declarator): Maybe pass LOOKUP_CONSTINIT to cp_finish_decl. (set_and_check_decl_spec_loc): Add "constinit". * pt.c (tsubst_decl): Set TINFO_VAR_DECLARED_CONSTINIT. (instantiate_decl): Maybe pass LOOKUP_CONSTINIT to cp_finish_decl. * typeck2.c (store_init_value): If a constinit variable wasn't initialized using a constant initializer, give an error. * doc/invoke.texi: Document -Wc++20-compat. * g++.dg/cpp2a/constinit1.C: New test. * g++.dg/cpp2a/constinit2.C: New test. * g++.dg/cpp2a/constinit3.C: New test. * g++.dg/cpp2a/constinit4.C: New test. * g++.dg/cpp2a/constinit5.C: New test. * g++.dg/cpp2a/constinit6.C: New test. * g++.dg/cpp2a/constinit7.C: New test. * g++.dg/cpp2a/constinit8.C: New test. * g++.dg/cpp2a/constinit9.C: New test. * g++.dg/cpp2a/constinit10.C: New test. * g++.dg/cpp2a/constinit11.C: New test. * g++.dg/cpp2a/constinit12.C: New test. From-SVN: r275008
2019-08-28[PR c++/90613] Fix using-decl debug bloatNathan Sidwell2-16/+23
https://gcc.gnu.org/ml/gcc-patches/2019-08/msg01888.html cp/ PR c++/90613 * name-lookup.c (cp_emit_debug_info): Check for builtins during overload iteration. testsuite/ PR c++/90613 * g++.dg/lookup/using61.C: New. From-SVN: r274991
2019-08-28PR c++/81676 - bogus -Wunused warnings in constexpr if.Marek Polacek2-0/+26
* semantics.c (maybe_mark_exp_read_r): New function. (finish_if_stmt): Call it on THEN_CLAUSE and ELSE_CLAUSE. * g++.dg/cpp1z/constexpr-if31.C: New test. * g++.dg/cpp1z/constexpr-if32.C: New test. From-SVN: r274982
2019-08-28PR c++/91428 - warn about std::is_constant_evaluated in if constexpr.Marek Polacek4-1/+47
* cp-tree.h (decl_in_std_namespace_p): Declare. * semantics.c (is_std_constant_evaluated_p): New. (finish_if_stmt_cond): Warn about "std::is_constant_evaluated ()" in an if-constexpr. * typeck.c (decl_in_std_namespace_p): No longer static. * g++.dg/cpp2a/is-constant-evaluated9.C: New test. From-SVN: r274981
2019-08-26* decl.c (duplicate_decls): Always merge DECL_DECLARED_CONSTEXPR_P.Jason Merrill2-3/+6
From-SVN: r274932
2019-08-26PR c++/91545 - ICE in constexpr store evaluation.Marek Polacek2-1/+7
* constexpr.c (cxx_eval_store_expression): Check FIELD_DECL instead of DECL_P. * g++.dg/cpp0x/pr91545.C: New test. From-SVN: r274930
2019-08-24[C++ PATCH] vfunc overrider simplificationNathan Sidwell2-6/+13
https://gcc.gnu.org/ml/gcc-patches/2019-08/msg01674.html cp/ * class.c (check_for_overrides): Conversion operators need checking too. testsuite/ * g++.dg/inherit/virtual14.C: New. From-SVN: r274903
2019-08-24semantics.c (finish_switch_cond): Improve error message location.Paolo Carlini2-1/+7
/cp 2019-08-24 Paolo Carlini <paolo.carlini@oracle.com> * semantics.c (finish_switch_cond): Improve error message location. /testsuite 2019-08-24 Paolo Carlini <paolo.carlini@oracle.com> * g++.dg/conversion/simd4.C: Test all the locations. From-SVN: r274901
2019-08-23Fix handling of namespace-scope undeduced auto decls.Jason Merrill2-1/+28
* decl2.c (decl_dependent_p): New. (mark_used): Check it instead of just processing_template_decl. From-SVN: r274894
2019-08-23* parser.c (cp_parser_nested_name_specifier_opt): Avoid redundant error.Jason Merrill2-3/+10
From-SVN: r274893
2019-08-23PR c++/91521 - wrong error with operator->.Marek Polacek2-0/+6
* decl.c (grokdeclarator): Return error_mark_node for an invalid trailing return type. * g++.dg/parse/operator8.C: New test. From-SVN: r274891
2019-08-23PR c++/79817 - attribute deprecated on namespace.Marek Polacek7-1/+62
* cp-tree.h (cp_warn_deprecated_use_scopes): Declare. * decl.c (grokdeclarator): Call cp_warn_deprecated_use_scopes. (type_is_deprecated): Likewise. * decl2.c (cp_warn_deprecated_use_scopes): New function. * name-lookup.c (handle_namespace_attrs): Handle attribute deprecated. * parser.c (cp_parser_namespace_alias_definition): Call cp_warn_deprecated_use_scopes. (cp_parser_using_declaration): Likewise. (cp_parser_using_directive): Likewise. * semantics.c (finish_id_expression_1): Likewise. * g++.dg/cpp0x/attributes-namespace1.C: New test. * g++.dg/cpp0x/attributes-namespace2.C: New test. * g++.dg/cpp0x/attributes-namespace3.C: New test. * g++.dg/cpp0x/attributes-namespace4.C: New test. * g++.dg/cpp0x/attributes-namespace5.C: New test. * g++.dg/cpp1z/namespace-attribs.C: Adjust. * g++.dg/cpp1z/namespace-attribs2.C: Adjust. From-SVN: r274888
2019-08-23[C++ PATCH] vfunc overrider simplificationNathan Sidwell2-14/+26
https://gcc.gnu.org/ml/gcc-patches/2019-08/msg01674.html * class.c (check_for_override): Checking IDENTIFIER_VIRTUAL_P is sufficient, reorder DECL_OVERRIDE_P check. From-SVN: r274867
2019-08-23[PATCH, c-family] Fix a PCH thinko (and thus PR61250).Iain Sandoe2-1/+11
When we are parsing a source file, the very first token might be a PRAGMA_GCC_PCH_PREPROCESS. This indicates that we are going read in a PCH file (named as the value of the pragma). If we don't see this pragma, then we know that it's OK to release any resources that the host might have set aside for the PCH file. This fixes a thinko in the current implementation, in that the decision to release resources was happening unconditionally right after the first token is extracted but before it's been checked or acted upon. This leads to the pch bug (seen on Darwin), because we actually do release resources - which are subsequently (reasonably) assumed to be available when reading a PCH file. We then get random crashes or hangs depending on the interaction between unmmap and malloc. The bug is present everywhere but doesn't show on (say) Linux, since the release of PCH resources is a NOP there. This effects all the c-family front ends, because they all use c_lex_with_flags () to implement this. The solution is to check for the PRAGMA_GCC_PCH_PREPROCESS and only call c_common_no_more_pch () when that is not the first token. A secondary effect of the collection is that the name of the PCH file can be collected during the ggc_pch_read() reset of state. Therefore we should issue any diagnostic that might name the file before the collections are triggered. gcc/c-family/ 2019-08-23 Iain Sandoe <iain@sandoe.co.uk> PR pch/61250 * c-lex.c (c_lex_with_flags): Don't call c_common_no_more_pch () from here. gcc/c/ 2019-08-23 Iain Sandoe <iain@sandoe.co.uk> PR pch/61250 * c-parser.c (c_parse_file): Call c_common_no_more_pch () after determining that the first token is not PRAGMA_GCC_PCH_PREPROCESS. gcc/cp/ 2019-08-23 Iain Sandoe <iain@sandoe.co.uk> PR pch/61250 * parser.c (cp_parser_initial_pragma): Call c_common_no_more_pch () after determining that the first token is not PRAGMA_GCC_PCH_PREPROCESS. gcc/ 2019-08-23 Iain Sandoe <iain@sandoe.co.uk> PR pch/61250 * ggc-page.c (ggc_pch_read): Read the ggc_pch_ondisk structure and issue any diagnostics needed before collecting the pre-PCH state. From-SVN: r274856
2019-08-23PR c++/91304 - prefix attributes ignored in condition.Marek Polacek2-1/+10
* parser.c (cp_parser_condition): Handle prefix attributes. * g++.dg/cpp0x/gen-attrs-70.C: New test. From-SVN: r274839
2019-08-21[C++] Protect call to copy_attributes_to_builtin (PR91505)Richard Sandiford2-2/+8
copy_attributes_to_builtin only handles BUILT_IN_NORMAL, but C++ was calling it immediately after the: if (DECL_BUILT_IN_CLASS (newdecl) == BUILT_IN_NORMAL) block. The corresponding C code calls it inside the block instead. 2019-08-21 Richard Sandiford <richard.sandiford@arm.com> gcc/cp/ PR c++/91505 * decl.c (duplicate_decls): Call copy_attributes_to_builtin inside the BUILT_IN_NORMAL block rather than afterward. gcc/testsuite/ PR c++/91505 * g++.target/i386/crc32-4.C: New test. From-SVN: r274799
2019-08-19PR c++/91264 - detect modifying const objects in constexpr.Marek Polacek2-1/+153
* constexpr.c (modifying_const_object_error): New function. (cxx_eval_call_expression): Set TREE_READONLY on a CONSTRUCTOR of a const-qualified object after it's been fully constructed. (modifying_const_object_p): New function. (cxx_eval_store_expression): Detect modifying a const object during constant expression evaluation. (cxx_eval_increment_expression): Use a better location when building up the store. (cxx_eval_constant_expression) <case DECL_EXPR>: Mark a constant object's constructor TREE_READONLY. * g++.dg/cpp1y/constexpr-tracking-const1.C: New test. * g++.dg/cpp1y/constexpr-tracking-const2.C: New test. * g++.dg/cpp1y/constexpr-tracking-const3.C: New test. * g++.dg/cpp1y/constexpr-tracking-const4.C: New test. * g++.dg/cpp1y/constexpr-tracking-const5.C: New test. * g++.dg/cpp1y/constexpr-tracking-const6.C: New test. * g++.dg/cpp1y/constexpr-tracking-const7.C: New test. * g++.dg/cpp1y/constexpr-tracking-const8.C: New test. * g++.dg/cpp1y/constexpr-tracking-const9.C: New test. * g++.dg/cpp1y/constexpr-tracking-const10.C: New test. * g++.dg/cpp1y/constexpr-tracking-const11.C: New test. * g++.dg/cpp1y/constexpr-tracking-const12.C: New test. * g++.dg/cpp1y/constexpr-tracking-const13.C: New test. * g++.dg/cpp1y/constexpr-tracking-const14.C: New test. From-SVN: r274671
2019-08-17Put the CL into the right dir.Marek Polacek1-5/+0
From-SVN: r274596
2019-08-16re PR c++/85827 (false positive for -Wunused-but-set-variable because of ↵Marek Polacek1-0/+5
constexpr-if) PR c++/85827 g++.dg/cpp1z/constexpr-if29.C: New test. From-SVN: r274587
2019-08-15PR c++/90393 - ICE with thow in ?:Jason Merrill3-14/+40
My previous patch for 64372 was incomplete: it only stopped making the non-throw argument into an rvalue, lvalue_kind still considered the ?: expression to be an rvalue, leaving us worse than before. PR c++/64372, DR 1560 - Gratuitous lvalue-to-rvalue conversion in ?: * tree.c (lvalue_kind): Handle throw in one arm. * typeck.c (rationalize_conditional_expr): Likewise. (cp_build_modify_expr): Likewise. From-SVN: r274550
2019-08-15Implement P0848R3, Conditionally Trivial Special Member Functions.Jason Merrill6-20/+131
With Concepts, overloads of special member functions can differ in constraints, and this paper clarifies how that affects class properties: if a class has a more constrained trivial copy constructor and a less constrained non-trivial copy constructor, it is still trivially copyable. * tree.c (special_memfn_p): New. * class.c (add_method): When overloading, hide ineligible special member fns. (check_methods): Set TYPE_HAS_COMPLEX_* here. * decl.c (grok_special_member_properties): Not here. * name-lookup.c (push_class_level_binding_1): Move overloaded functions case down, accept FUNCTION_DECL as target_decl. From-SVN: r274534
2019-08-14PR c++/91436 fix C++ dialect for std::make_unique fix-it hintJonathan Wakely2-2/+8
The std::make_unique function wasn't added until C++14, and neither was the std::complex_literals namespace. gcc/cp: PR c++/91436 * name-lookup.c (get_std_name_hint): Fix min_dialect field for complex_literals and make_unique entries. gcc/testsuite: PR c++/91436 * g++.dg/lookup/missing-std-include-5.C: Limit test to C++14 and up. * g++.dg/lookup/missing-std-include-6.C: Don't check make_unique in test that runs for C++11. * g++.dg/lookup/missing-std-include-8.C: Check make_unique here. From-SVN: r274492
2019-08-14PR c++/91391 - bogus -Wcomma-subscript warning.Jakub Jelinek2-74/+36
* parser.c (cp_parser_postfix_open_square_expression): Don't warn about a deprecated comma here. Pass warn_comma_subscript down to cp_parser_expression. (cp_parser_expression): New bool parameter. Warn about uses of a comma operator within a subscripting expression. (cp_parser_skip_to_closing_square_bracket): Revert to pre-r274121 state. (cp_parser_skip_to_closing_square_bracket_1): Remove. * g++.dg/cpp2a/comma5.C: New test. Co-Authored-By: Marek Polacek <polacek@redhat.com> From-SVN: r274483
2019-08-14Add more entries to the C++ get_std_name_hint arrayJonathan Wakely2-0/+44
* name-lookup.c (get_std_name_hint): Add more entries. From-SVN: r274475
2019-08-14decl.c (grokdeclarator): Use id_loc and EXPR_LOCATION in a few error messages.Paolo Carlini2-2/+7
/cp 2019-08-08 Paolo Carlini <paolo.carlini@oracle.com> * decl.c (grokdeclarator): Use id_loc and EXPR_LOCATION in a few error messages. /testsuite 2019-08-08 Paolo Carlini <paolo.carlini@oracle.com> * g++.dg/cpp0x/enum20.C: Test location(s) too. * g++.dg/other/friend3.C: Likewise. * g++.dg/parse/dtor5.C: Likewise. * g++.dg/parse/friend7.C: Likewise. * g++.dg/template/error22.C: Likewise. * g++.old-deja/g++.brendan/err-msg5.C: Likewise. From-SVN: r274435
2019-08-14decl.c (grokdeclarator): Check here for typedef a function definition or a ↵Paolo Carlini1-0/+7
member function definition. /cp 2019-08-14 Paolo Carlini <paolo.carlini@oracle.com> * decl.c (grokdeclarator): Check here for typedef a function definition or a member function definition. (start_function): Adjust. (grokmethod): Likewise. /testsuite 2019-08-14 Paolo Carlini <paolo.carlini@oracle.com> * g++.dg/parse/typedef9.C: Test locations too. From-SVN: r274433
2019-08-14decl.c (grokdeclarator): Check here for typedef a function definition or a ↵Paolo Carlini1-13/+11
member function definition. /cp 2019-08-14 Paolo Carlini <paolo.carlini@oracle.com> * decl.c (grokdeclarator): Check here for typedef a function definition or a member function definition. (start_function): Adjust. (grokmethod): Likewise. /testsuite 2019-08-14 Paolo Carlini <paolo.carlini@oracle.com> * g++.dg/parse/typedef9.C: Test locations too. From-SVN: r274431
2019-08-13Use checking forms of DECL_FUNCTION_CODE (PR 91421)Richard Sandiford3-5/+9
We were shoe-horning all built-in enumerations (including frontend and target-specific ones) into a field of type built_in_function. This was accessed as either an lvalue or an rvalue using DECL_FUNCTION_CODE. The obvious danger with this (as was noted by several ??? comments) is that the ranges have nothing to do with each other, and targets can easily have more built-in functions than generic code. But my patch to make the field bigger was the straw that finally made the problem visible. This patch therefore: - replaces the field with a plain unsigned int - turns DECL_FUNCTION_CODE into an rvalue-only accessor that checks that the function really is BUILT_IN_NORMAL - adds corresponding DECL_MD_FUNCTION_CODE and DECL_FE_FUNCTION_CODE accessors for BUILT_IN_MD and BUILT_IN_FRONTEND respectively - adds DECL_UNCHECKED_FUNCTION_CODE for places that need to access the underlying field (should be low-level code only) - adds new helpers for setting the built-in class and function code - makes DECL_BUILT_IN_CLASS an rvalue-only accessor too, since all assignments should go through the new helpers 2019-08-13 Richard Sandiford <richard.sandiford@arm.com> gcc/ PR middle-end/91421 * tree-core.h (function_decl::function_code): Change type to unsigned int. * tree.h (DECL_FUNCTION_CODE): Rename old definition to... (DECL_UNCHECKED_FUNCTION_CODE): ...this. (DECL_BUILT_IN_CLASS): Make an rvalue macro only. (DECL_FUNCTION_CODE): New function. Assert that the built-in class is BUILT_IN_NORMAL. (DECL_MD_FUNCTION_CODE, DECL_FE_FUNCTION_CODE): New functions. (set_decl_built_in_function, copy_decl_built_in_function): Likewise. (fndecl_built_in_p): Change the type of the "name" argument to unsigned int. * builtins.c (expand_builtin): Move DECL_FUNCTION_CODE use after check for DECL_BUILT_IN_CLASS. * cgraphclones.c (build_function_decl_skip_args): Use set_decl_built_in_function. * ipa-param-manipulation.c (ipa_modify_formal_parameters): Likewise. * ipa-split.c (split_function): Likewise. * langhooks.c (add_builtin_function_common): Likewise. * omp-simd-clone.c (simd_clone_create): Likewise. * tree-streamer-in.c (unpack_ts_function_decl_value_fields): Likewise. * config/darwin.c (darwin_init_cfstring_builtins): Likewise. (darwin_fold_builtin): Use DECL_MD_FUNCTION_CODE instead of DECL_FUNCTION_CODE. * fold-const.c (operand_equal_p): Compare DECL_UNCHECKED_FUNCTION_CODE instead of DECL_FUNCTION_CODE. * lto-streamer-out.c (hash_tree): Use DECL_UNCHECKED_FUNCTION_CODE instead of DECL_FUNCTION_CODE. * tree-streamer-out.c (pack_ts_function_decl_value_fields): Likewise. * print-tree.c (print_node): Use DECL_MD_FUNCTION_CODE when printing DECL_BUILT_IN_MD. Handle DECL_BUILT_IN_FRONTEND. * config/aarch64/aarch64-builtins.c (aarch64_expand_builtin) (aarch64_fold_builtin, aarch64_gimple_fold_builtin): Use DECL_MD_FUNCTION_CODE instead of DECL_FUNCTION_CODE. * config/aarch64/aarch64.c (aarch64_builtin_reciprocal): Likewise. * config/alpha/alpha.c (alpha_expand_builtin, alpha_fold_builtin): (alpha_gimple_fold_builtin): Likewise. * config/arc/arc.c (arc_expand_builtin): Likewise. * config/arm/arm-builtins.c (arm_expand_builtin): Likewise. * config/avr/avr-c.c (avr_resolve_overloaded_builtin): Likewise. * config/avr/avr.c (avr_expand_builtin, avr_fold_builtin): Likewise. * config/bfin/bfin.c (bfin_expand_builtin): Likewise. * config/c6x/c6x.c (c6x_expand_builtin): Likewise. * config/frv/frv.c (frv_expand_builtin): Likewise. * config/gcn/gcn.c (gcn_expand_builtin_1): Likewise. (gcn_expand_builtin): Likewise. * config/i386/i386-builtins.c (ix86_builtin_reciprocal): Likewise. (fold_builtin_cpu): Likewise. * config/i386/i386-expand.c (ix86_expand_builtin): Likewise. * config/i386/i386.c (ix86_fold_builtin): Likewise. (ix86_gimple_fold_builtin): Likewise. * config/ia64/ia64.c (ia64_fold_builtin): Likewise. (ia64_expand_builtin): Likewise. * config/iq2000/iq2000.c (iq2000_expand_builtin): Likewise. * config/mips/mips.c (mips_expand_builtin): Likewise. * config/msp430/msp430.c (msp430_expand_builtin): Likewise. * config/nds32/nds32-intrinsic.c (nds32_expand_builtin_impl): Likewise. * config/nios2/nios2.c (nios2_expand_builtin): Likewise. * config/nvptx/nvptx.c (nvptx_expand_builtin): Likewise. * config/pa/pa.c (pa_expand_builtin): Likewise. * config/pru/pru.c (pru_expand_builtin): Likewise. * config/riscv/riscv-builtins.c (riscv_expand_builtin): Likewise. * config/rs6000/rs6000-c.c (altivec_resolve_overloaded_builtin): Likewise. * config/rs6000/rs6000-call.c (htm_expand_builtin): Likewise. (altivec_expand_dst_builtin, altivec_expand_builtin): Likewise. (rs6000_gimple_fold_builtin, rs6000_expand_builtin): Likewise. * config/rs6000/rs6000.c (rs6000_builtin_md_vectorized_function) (rs6000_builtin_reciprocal): Likewise. * config/rx/rx.c (rx_expand_builtin): Likewise. * config/s390/s390-c.c (s390_resolve_overloaded_builtin): Likewise. * config/s390/s390.c (s390_expand_builtin): Likewise. * config/sh/sh.c (sh_expand_builtin): Likewise. * config/sparc/sparc.c (sparc_expand_builtin): Likewise. (sparc_fold_builtin): Likewise. * config/spu/spu-c.c (spu_resolve_overloaded_builtin): Likewise. * config/spu/spu.c (spu_expand_builtin): Likewise. * config/stormy16/stormy16.c (xstormy16_expand_builtin): Likewise. * config/tilegx/tilegx.c (tilegx_expand_builtin): Likewise. * config/tilepro/tilepro.c (tilepro_expand_builtin): Likewise. * config/xtensa/xtensa.c (xtensa_fold_builtin): Likewise. (xtensa_expand_builtin): Likewise. gcc/ada/ PR middle-end/91421 * gcc-interface/trans.c (gigi): Call set_decl_buillt_in_function. (Call_to_gnu): Use DECL_FE_FUNCTION_CODE instead of DECL_FUNCTION_CODE. gcc/c/ PR middle-end/91421 * c-decl.c (merge_decls): Use copy_decl_built_in_function. gcc/c-family/ PR middle-end/91421 * c-common.c (resolve_overloaded_builtin): Use copy_decl_built_in_function. gcc/cp/ PR middle-end/91421 * decl.c (duplicate_decls): Use copy_decl_built_in_function. * pt.c (declare_integer_pack): Use set_decl_built_in_function. gcc/d/ PR middle-end/91421 * intrinsics.cc (maybe_set_intrinsic): Use set_decl_built_in_function. gcc/jit/ PR middle-end/91421 * jit-playback.c (new_function): Use set_decl_built_in_function. gcc/lto/ PR middle-end/91421 * lto-common.c (compare_tree_sccs_1): Use DECL_UNCHECKED_FUNCTION_CODE instead of DECL_FUNCTION_CODE. * lto-symtab.c (lto_symtab_merge_p): Likewise. From-SVN: r274404
2019-08-13PR c++/90473 - wrong code with nullptr in default argument.Marek Polacek3-4/+12
* call.c (null_ptr_cst_p): Update quote from the standard. * decl.c (check_default_argument): Don't return nullptr when the arg has side-effects. * g++.dg/cpp0x/nullptr42.C: New test. From-SVN: r274382
2019-08-13* cp-tree.h (DECL_MUTABLE_P): Use FIELD_DECL_CHECK.Marek Polacek2-2/+6
From-SVN: r274381
2019-08-10tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_DEVICE_TYPE.Jakub Jelinek3-6/+106
* tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_DEVICE_TYPE. (enum omp_clause_device_type_kind): New enum. (struct tree_omp_clause): Add subcode.device_type_kind. * tree.h (OMP_CLAUSE_DEVICE_TYPE_KIND): Define. * tree.c (omp_clause_num_ops, omp_clause_code_name): Add entries for device_type clause. (walk_tree_1): Handle OMP_CLAUSE_DEVICE_TYPE. * tree-pretty-print.c (dump_omp_clause): Likewise. c-family/ * c-pragma.h (enum pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_DEVICE_TYPE. c/ * c-parser.c (c_parser_omp_clause_name): Parse device_type. (c_parser_omp_clause_device_type): New function. (c_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_DEVICE_TYPE. (OMP_DECLARE_TARGET_CLAUSE_MASK): Add PRAGMA_OMP_CLAUSE_DEVICE_TYPE. (c_parser_omp_declare_target): Handle device_type clauses. Remove diagnostics for declare target with clauses nested in clause-less declare target declaration-definition-seq. * c-typeck.c (c_finish_omp_clauses): Handle OMP_CLAUSE_DEVICE_TYPE. cp/ * parser.c (cp_parser_omp_clause_name): Parse device_type. (cp_parser_omp_clause_device_type): New function. (cp_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_DEVICE_TYPE. (OMP_DECLARE_TARGET_CLAUSE_MASK): Add PRAGMA_OMP_CLAUSE_DEVICE_TYPE. (cp_parser_omp_declare_target): Handle device_type clauses. Remove diagnostics for declare target with clauses nested in clause-less declare target declaration-definition-seq. * semantics.c (finish_omp_clauses): Handle OMP_CLAUSE_DEVICE_TYPE. testsuite/ * c-c++-common/gomp/declare-target-2.c: Don't expect error for declare target with clauses in between declare target without clauses and end declare target. * c-c++-common/gomp/declare-target-4.c: New test. From-SVN: r274252
2019-08-10Assorted ChangeLog cleanups.Jakub Jelinek1-101/+109
From-SVN: r274250
2019-08-09c-parser.c (check_no_duplicate_clause): Simplify using omp_find_clause.Jakub Jelinek2-10/+9
c/ * c-parser.c (check_no_duplicate_clause): Simplify using omp_find_clause. (c_parser_omp_clause_if): Fix up printing of target {enter,exit} data directive name modifiers. (c_parser_omp_clause_proc_bind): Check for duplicate proc_bind clause. cp/ * parser.c (check_no_duplicate_clause): Simplify using omp_find_clause. (cp_parser_omp_clause_if): Fix up printing of target {enter,exit} data directive name modifiers. testsuite/ * c-c++-common/gomp/if-4.c: New test. * c-c++-common/gomp/clause-dups-1.c: New test. From-SVN: r274227
2019-08-09re PR c/91401 (schedule + dist_schedule clauses rejected on distribute ↵Jakub Jelinek2-2/+11
parallel for) PR c/91401 c/ * c-parser.c (c_parser_omp_clause_dist_schedule): Fix up typos in the check_no_duplicate_clause call. Comment it out, instead emit a warning for duplicate dist_schedule clauses. cp/ * parser.c (cp_parser_omp_clause_dist_schedule): Comment out the check_no_duplicate_clause call, instead emit a warning for duplicate dist_schedule clauses. testsuite/ * c-c++-common/gomp/pr91401-1.c: New test. * c-c++-common/gomp/pr91401-2.c: New test. From-SVN: r274226
2019-08-08decl.c (grokdeclarator): Use id_loc and EXPR_LOCATION in a few error messages.Paolo Carlini2-8/+16
/cp 2019-08-08 Paolo Carlini <paolo.carlini@oracle.com> * decl.c (grokdeclarator): Use id_loc and EXPR_LOCATION in a few error messages. /testsuite 2019-08-08 Paolo Carlini <paolo.carlini@oracle.com> * g++.dg/cpp0x/enum20.C: Test location(s) too. * g++.dg/other/friend3.C: Likewise. * g++.dg/parse/dtor5.C: Likewise. * g++.dg/parse/friend7.C: Likewise. * g++.dg/template/error22.C: Likewise. * g++.old-deja/g++.brendan/err-msg5.C: Likewise. From-SVN: r274220
2019-08-08PR c++/87519 - bogus warning with -Wsign-conversion.Marek Polacek2-2/+6
* typeck.c (cp_build_binary_op): Use same_type_p instead of comparing the types directly. * g++.dg/warn/Wsign-conversion-5.C: New test. From-SVN: r274211
2019-08-08constexpr.c (inline_asm_in_constexpr_error): New.Marek Polacek2-11/+21
* constexpr.c (inline_asm_in_constexpr_error): New. (cxx_eval_constant_expression) <case ASM_EXPR>: Call it. (potential_constant_expression_1) <case ASM_EXPR>: Likewise. * g++.dg/cpp2a/inline-asm3.C: New test. From-SVN: r274210
2019-08-08gimplify.c (omp_add_variable): Use GOVD_PRIVATE | GOVD_EXPLICIT for VLA ↵Jakub Jelinek2-4/+17
helper variables on target data even if... * gimplify.c (omp_add_variable): Use GOVD_PRIVATE | GOVD_EXPLICIT for VLA helper variables on target data even if not GOVD_FIRSTPRIVATE. (gimplify_scan_omp_clauses): For OMP_CLAUSE_USE_DEVICE_* use just GOVD_EXPLICIT flags. (gimplify_omp_workshare): For OMP_TARGET_DATA move all OMP_CLAUSE_USE_DEVICE_* clauses to the end of clauses chain. * omp-low.c (scan_sharing_clauses): For OMP_CLAUSE_USE_DEVICE_* call install_var_field with mask 11 instead of 3. (lower_omp_target): For OMP_CLAUSE_USE_DEVICE_* use pass (splay_tree_key) &DECL_UID (var) to build_sender_ref instead of var. gcc/c/ * c-typeck.c (c_finish_omp_clauses): For C_ORT_OMP OMP_CLAUSE_USE_DEVICE_* clauses use oacc_reduction_head bitmap instead of generic_head to track duplicates. gcc/cp/ * semantics.c (finish_omp_clauses): For C_ORT_OMP OMP_CLAUSE_USE_DEVICE_* clauses use oacc_reduction_head bitmap instead of generic_head to track duplicates. libgomp/ * target.c (gomp_map_vars_internal): For GOMP_MAP_USE_DEVICE_PTR perform the lookup in the first loop only if !not_found_cnt, otherwise perform lookups for it in the second loop guarded with if (not_found_cnt || has_firstprivate). * testsuite/libgomp.c/target-37.c: New test. * testsuite/libgomp.c++/target-22.C: New test. From-SVN: r274206
2019-08-07PR c++/81429 - wrong parsing of constructor with C++11 attribute.Marek Polacek2-1/+9
* parser.c (cp_parser_constructor_declarator_p): Handle the scenario when a parameter declaration begins with [[attribute]]. * g++.dg/cpp0x/gen-attrs-68.C: New test. * g++.dg/cpp0x/gen-attrs-69.C: New test. From-SVN: r274181
2019-08-07PR c++/91346 - Implement P1668R1, allow unevaluated asm in constexpr.Marek Polacek6-17/+51
* constexpr.c (cxx_eval_constant_expression): Handle ASM_EXPR. (potential_constant_expression_1) <case ASM_EXPR>: Allow. * cp-tree.h (finish_asm_stmt): Adjust. * parser.c (cp_parser_asm_definition): Grab the locaion of "asm" and use it. Change an error to a pedwarn. Allow asm in C++2a, warn otherwise. * pt.c (tsubst_expr): Pass a location down to finish_asm_stmt. * semantics.c (finish_asm_stmt): New location_t parameter. Use it. * g++.dg/cpp2a/inline-asm1.C: New test. * g++.dg/cpp2a/inline-asm2.C: New test. * g++.dg/cpp1y/constexpr-neg1.C: Adjust dg-error. From-SVN: r274169
2019-08-07tree-core.h (enum omp_clause_code): Adjust OMP_CLAUSE_USE_DEVICE_PTR OpenMP ↵Jakub Jelinek4-12/+59
description. * tree-core.h (enum omp_clause_code): Adjust OMP_CLAUSE_USE_DEVICE_PTR OpenMP description. Add OMP_CLAUSE_USE_DEVICE_ADDR clause. * tree.c (omp_clause_num_ops, omp_clause_code_name): Add entries for OMP_CLAUSE_USE_DEVICE_ADDR clause. (walk_tree_1): Handle OMP_CLAUSE_USE_DEVICE_ADDR. * tree-pretty-print.c (dump_omp_clause): Likewise. * tree-nested.c (convert_nonlocal_omp_clauses, convert_local_omp_clauses): Likewise. * gimplify.c (gimplify_scan_omp_clauses, gimplify_adjust_omp_clauses): Likewise. * omp-low.c (scan_sharing_clauses, lower_omp_target): Likewise. Treat OMP_CLAUSE_USE_DEVICE_ADDR like OMP_CLAUSE_USE_DEVICE_PTR clause with array or reference to array types, no matter what type except for reference it has. gcc/c-family/ * c-pragma.h (enum pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_USE_DEVICE_ADDR. Set PRAGMA_OACC_CLAUSE_USE_DEVICE equal to PRAGMA_OMP_CLAUSE_USE_DEVICE_PTR instead of being a separate enumeration value. gcc/c/ * c-parser.c (c_parser_omp_clause_name): Parse use_device_addr clause. (c_parser_omp_clause_use_device_addr): New function. (c_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_USE_DEVICE_ADDR. (OMP_TARGET_DATA_CLAUSE_MASK): Add PRAGMA_OMP_CLAUSE_USE_DEVICE_ADDR. (c_parser_omp_target_data): Handle PRAGMA_OMP_CLAUSE_USE_DEVICE_ADDR like PRAGMA_OMP_CLAUSE_USE_DEVICE_PTR, adjust diagnostics about no map or use_device_* clauses. * c-typeck.c (c_finish_omp_clauses): For OMP_CLAUSE_USE_DEVICE_PTR in OpenMP, require pointer type rather than pointer or array type. Handle OMP_CLAUSE_USE_DEVICE_ADDR. gcc/cp/ * parser.c (cp_parser_omp_clause_name): Parse use_device_addr clause. (cp_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_USE_DEVICE_ADDR. (OMP_TARGET_DATA_CLAUSE_MASK): Add PRAGMA_OMP_CLAUSE_USE_DEVICE_ADDR. (cp_parser_omp_target_data): Handle PRAGMA_OMP_CLAUSE_USE_DEVICE_ADDR like PRAGMA_OMP_CLAUSE_USE_DEVICE_PTR, adjust diagnostics about no map or use_device_* clauses. * semantics.c (finish_omp_clauses): For OMP_CLAUSE_USE_DEVICE_PTR in OpenMP, require pointer or reference to pointer type rather than pointer or array or reference to pointer or array type. Handle OMP_CLAUSE_USE_DEVICE_ADDR. * pt.c (tsubst_omp_clauses): Handle OMP_CLAUSE_USE_DEVICE_ADDR. gcc/testsuite/ * c-c++-common/gomp/target-data-1.c (foo): Use use_device_addr clause instead of use_device_ptr clause where required by OpenMP 5.0, add further tests for both use_device_ptr and use_device_addr clauses. libgomp/ * testsuite/libgomp.c/target-18.c (struct S): New type. (foo): Use use_device_addr clause instead of use_device_ptr clause where required by OpenMP 5.0, add further tests for both use_device_ptr and use_device_addr clauses. * testsuite/libgomp.c++/target-9.C (struct S): New type. (foo): Use use_device_addr clause instead of use_device_ptr clause where required by OpenMP 5.0, add further tests for both use_device_ptr and use_device_addr clauses. Add t and u arguments. (main): Adjust caller. From-SVN: r274159
2019-08-06PR c++/91378 - ICE with noexcept and auto return type.Jason Merrill2-5/+7
Here, since the call to g is not type-dependent, we call mark_used on it to determine its return type. This also wants to instantiate the noexcept-expression. But since nothing in maybe_instantiate_noexcept was calling push_to_top_level, we substituted b.i with processing_template_decl set, so we left it unresolved for later access checking. As a result, the type of C::g<int> remained instantiation-dependent, leading to an ICE in type_dependent_expression_p on the assert that the type of a function template with no dependent template arguments must be non-dependent. * pt.c (maybe_instantiate_noexcept): push_to_top_level. From-SVN: r274143
2019-08-06decl.c (check_array_designated_initializer): Use cp_expr_loc_or_input_loc in ↵Paolo Carlini2-2/+8
one place. /cp 2019-08-06 Paolo Carlini <paolo.carlini@oracle.com> * decl.c (check_array_designated_initializer): Use cp_expr_loc_or_input_loc in one place. /testsuite 2019-08-06 Paolo Carlini <paolo.carlini@oracle.com> * g++.dg/cpp0x/desig1.C: Check location too. From-SVN: r274141
2019-08-06tree.h (OMP_CLAUSE_LASTPRIVATE_TASKLOOP_IV): Rename to ...Jakub Jelinek6-21/+90
* tree.h (OMP_CLAUSE_LASTPRIVATE_TASKLOOP_IV): Rename to ... (OMP_CLAUSE_LASTPRIVATE_LOOP_IV): ... this. Adjust comment. * gimplify.c (gimple_add_tmp_var): In SIMD contexts, turn addressable new vars into GOVD_PRIVATE rather than GOVD_LOCAL. (gimplify_omp_for): Don't do C++ random access iterator clause adjustments on combined constructs from OMP_LOOP. For OMP_LOOP, don't predetermine the artificial iterator in case of C++ random access iterators as lastprivate, but private. For OMP_LOOP, force bind expr around simd body and force for_pre_body before the construct. Use OMP_CLAUSE_LASTPRIVATE_LOOP_IV instead of OMP_CLAUSE_LASTPRIVATE_TASKLOOP_IV. (gimplify_omp_loop): Add firstprivate clauses on OMP_PARALLEL for diff var of C++ random access iterators. Handle OMP_CLAUSE_FIRSTPRIVATE. For OMP_CLAUSE_LASTPRIVATE_LOOP_IV, if not outermost also add OMP_CLAUSE_FIRSTPRIVATE, and in both cases clear OMP_CLAUSE_LASTPRIVATE_LOOP_IV on the lastprivate clause on the OMP_FOR and OMP_DISTRIBUTE constructs if any. * omp-low.c (lower_rec_input_clauses): For OMP_CLAUSE_LASTPRIVATE_LOOP_IV on simd copy construct the private variables instead of default constructing them. (lower_lastprivate_clauses): Use OMP_CLAUSE_LASTPRIVATE_LOOP_IV instead of OMP_CLAUSE_LASTPRIVATE_TASKLOOP_IV and move the is_taskloop_ctx check from the assert to the guarding condition. gcc/cp/ * parser.c (cp_parser_omp_for_loop): For OMP_LOOP, ignore parallel clauses and predetermine iterator as lastprivate. * semantics.c (handle_omp_for_class_iterator): Use OMP_CLAUSE_LASTPRIVATE_LOOP_IV instead of OMP_CLAUSE_LASTPRIVATE_TASKLOOP_IV, set it for lastprivate also on OMP_LOOP construct. If a clause is missing for class iterator on OMP_LOOP, add firstprivate clause, and if there is private clause, turn it into firstprivate too. (finish_omp_for): Formatting fix. For OMP_LOOP, adjust OMP_CLAUSE_LASTPRIVATE_LOOP_IV clause CP_CLAUSE_INFO, so that it uses copy ctor instead of default ctor. * cp-gimplify.c (cp_gimplify_expr): Handle OMP_LOOP like OMP_DISTRIBUTE etc. (cp_fold_r): Likewise. (cp_genericize_r): Likewise. (cxx_omp_finish_clause): Also finish lastprivate clause with OMP_CLAUSE_LASTPRIVATE_LOOP_IV flag. * pt.c (tsubst_omp_clauses): Handle OMP_CLAUSE_BIND. (tsubst_omp_for_iterator): For OMP_LOOP, ignore parallel clauses and predetermine iterator as lastprivate. * constexpr.c (potential_constant_expression_1): Handle OMP_LOOP like OMP_DISTRIBUTE etc. libgomp/ * testsuite/libgomp.c++/loop-13.C: New test. * testsuite/libgomp.c++/loop-14.C: New test. * testsuite/libgomp.c++/loop-15.C: New test. From-SVN: r274138
2019-08-06DR 2413 - typename in conversion-function-ids.Marek Polacek2-2/+10
* parser.c (cp_parser_conversion_type_id): Call cp_parser_type_specifier_seq with CP_PARSER_FLAGS_TYPENAME_OPTIONAL instead of CP_PARSER_FLAGS_NONE. * g++.dg/cpp2a/typename17.C: New test. From-SVN: r274136