aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
AgeCommit message (Collapse)AuthorFilesLines
2016-08-09Implement C++17 constexpr lambda.Jason Merrill9-22/+184
gcc/c-family/ * c-cppbuiltin.c (c_cpp_builtins): Update __cpp_constexpr for C++17 constexpr lambdas. gcc/cp/ * class.c (finalize_literal_type_property): Handle lambdas. * constexpr.c (is_valid_constexpr_fn): Likewise. No longer static. (explain_invalid_constexpr_fn, cxx_eval_call_expression): Handle lambdas. (cxx_eval_constant_expression): Handle capture proxy. (var_in_constexpr_fn): Don't check for C++14. (var_in_maybe_constexpr_fn): New. (potential_constant_expression_1): Use it. Check DECL_EXPR for declarations not allowed in constexpr function. * decl.c (make_rtl_for_nonlocal_decl): Use var_in_maybe_constexpr_fn. (finish_function): Set DECL_DECLARED_CONSTEXPR_P on lambda members. * lambda.c (begin_lambda_type): Set CLASSTYPE_LITERAL_P. (maybe_add_lambda_conv_op): Clear thunk CALL_EXPR location. (lambda_static_thunk_p): New. * parser.c (cp_keyword_starts_decl_specifier_p): Add RID_CONSTEXPR. (CP_PARSER_FLAGS_ONLY_MUTABLE_OR_CONSTEXPR): New enumerator. (cp_parser_decl_specifier_seq): Handle it. (cp_parser_lambda_declarator_opt): Use cp_parser_decl_specifier_seq. * pt.c (instantiate_class_template_1): Set CLASSTYPE_LITERAL_P. (tsubst_copy_and_build) [CALL_EXPR]: Propagate CALL_FROM_THUNK_P. * error.c (dump_function_decl): Check TFF_NO_TEMPLATE_BINDINGS. (dump_expr) [FUNCTION_DECL]: Pass it. From-SVN: r239268
2016-08-09Fix empty class parameters with constexpr.Jason Merrill3-5/+24
PR c++/67131 * class.c (is_really_empty_class): Call complete_type. * constexpr.c (cxx_eval_constant_expression): Check is_really_empty_class. (potential_constant_expression_1): Likewise. Check for error type. From-SVN: r239267
2016-08-08re PR c++/58706 (ICE with lambda in OpenMP for-loop)Jakub Jelinek2-3/+45
PR c++/58706 * parser.c: Include tree-iterator.h. (cp_parser_omp_for_loop_init): Move lambda DECL_EXPRs from init to FOR_BLOCK. (cp_parser_omp_for_loop): Handle non-STATEMENT_LIST FOR_BLOCK entries. * testsuite/libgomp.c++/pr58706.C: New test. From-SVN: r239251
2016-08-06Harmonize diagnostics for invalid reference bindingJonathan Wakely2-6/+11
gcc/cp: * call.c (convert_like_real): Harmonize diagnostics for invalid reference binding. gcc/testsuite: * call.c (convert_like_real): Harmonize diagnostics for invalid reference binding. * g++.dg/conversion/pr16333.C: Adjust dg-error regexp. * g++.dg/conversion/pr41426.C: Likewise. * g++.dg/conversion/pr66211.C: Likewise. * g++.dg/cpp1y/lambda-init9.C: Likewise. * g++.dg/init/ref8.C: Likewise. * g++.old-deja/g++.law/cvt20.C: Likewise. * g++.old-deja/g++.mike/p9732c.C: Likewise. From-SVN: r239184
2016-08-05constexpr.c (cxx_eval_store_expression): Remove hyphen from the spelling of ↵Martin Sebor2-11/+20
"constant-expression" in diagnostic messages... gcc/cp/ChangeLog: * constexpr.c (cxx_eval_store_expression): Remove hyphen from the spelling of "constant-expression" in diagnostic messages for consistency. (cxx_eval_constant_expression): Same. (cxx_eval_outermost_constant_expr): Same. (potential_constant_expression_1): Same. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/constexpr-cast.C: Avoid assuming (void*)1 is spelled 1ul in diagnostics. Remove hyphen from "constant-expression." * g++.dg/cpp0x/constexpr-50060.C: Adjust. * g++.dg/cpp0x/static_assert3.C: Same. * g++.dg/cpp1y/constexpr-throw.C: Same. * g++.dg/template/nontype3.C: Same. * g++.dg/warn/overflow-warn-1.C: Same. * g++.dg/warn/overflow-warn-3.C: Same. * g++.dg/warn/overflow-warn-4.C: Same. From-SVN: r239176
2016-08-05re PR c++/68724 (ice in unify, at cp/pt.c:19902)Nathan Sidwell2-1/+6
PR c++/68724 * pt.c (unify): TRAIT_EXPR is an expr. PR c++/68724 * g++.dg/cpp0x/pr68724.C: New. From-SVN: r239167
2016-08-04re PR c++/72800 (ICE on invalid C++14 code with initialized lambda capture: ↵Paolo Carlini2-0/+8
tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in add_capture, at cp/lambda.c:505) /cp 2016-08-04 Paolo Carlini <paolo.carlini@oracle.com> PR c++/72800 * lambda.c (add_capture): Check lambda_capture_field_type return value for error_mark_node. /testsuite 2016-08-04 Paolo Carlini <paolo.carlini@oracle.com> PR c++/72800 * g++.dg/cpp1y/lambda-ice1.C: New. From-SVN: r239148
2016-08-04Fix ICE on invalid variable template instantiation (PR c++/72759)Patrick Palka2-0/+8
gcc/cp/ChangeLog: PR c++/72759 * pt.c (tsubst_qualified_id): Return error_mark_node if template_args is error_mark_node. gcc/testsuite/ChangeLog: PR c++/72759 * g++.dg/cpp1y/pr72759.C: New test. From-SVN: r239147
2016-08-04PR c++/72415 - member template with fold-expression constraintJason Merrill2-0/+10
* pt.c (tsubst_pack_expansion): Pull a single pack expansion out of the TREE_VEC. From-SVN: r239138
2016-08-04Rename TYPE_ANONYMOUS_P to TYPE_UNNAMED_P.Jason Merrill13-44/+50
* cp-tree.h (TYPE_UNNAMED_P): Rename from TYPE_ANONYMOUS_P. (TYPE_WAS_UNNAMED): Rename from TYPE_WAS_ANONYMOUS. * class.c, decl.c, decl2.c, error.c, lambda.c, mangle.c, name-lookup.c, parser.c, pt.c, semantics.c, tree.c: Adjust. From-SVN: r239137
2016-08-04PR c++/72796 - wrong resolution of scoped method call.Jason Merrill2-1/+7
* typeck.c (finish_class_member_access_expr): Avoid stripping SCOPE_REF to dependent base. From-SVN: r239136
2016-08-04Rework C/C++ OpenACC routine parsingThomas Schwinge2-99/+89
gcc/c/ * c-parser.c (struct oacc_routine_data): Add error_seen and fndecl_seen members. (c_finish_oacc_routine): Use these. (c_parser_declaration_or_fndef): Adjust. (c_parser_oacc_routine): Likewise. Support more C language constructs, and improve diagnostics. Move pragma context checking... (c_parser_pragma): ... here. gcc/cp/ * parser.c (cp_ensure_no_oacc_routine): Improve diagnostics. (cp_parser_late_parsing_cilk_simd_fn_info): Fix diagnostics. (cp_parser_late_parsing_oacc_routine, cp_finalize_oacc_routine): Simplify code, and improve diagnostics. (cp_parser_oacc_routine): Likewise. Move pragma context checking... (cp_parser_pragma): ... here. gcc/testsuite/ * c-c++-common/goacc/routine-5.c: Update. From-SVN: r239128
2016-08-04C/C++: Simplify handling of location information for OpenACC routine directivesThomas Schwinge3-70/+74
gcc/c/ * c-parser.c (struct oacc_routine_data): New. (c_parser_declaration_or_fndef, c_parser_oacc_routine): Use it. Simplify code. (c_finish_oacc_routine): Likewise. Don't attach clauses to "omp declare target" attribute. gcc/cp/ * parser.h (struct cp_omp_declare_simd_data): New. (struct cp_parser): Use it for oacc_routine member. * parser.c (cp_ensure_no_oacc_routine, cp_parser_oacc_routine) (cp_parser_late_parsing_oacc_routine, cp_finalize_oacc_routine): Use it. Simplify code. (cp_parser_new): Initialize all members pointing to special parsing data structures. (cp_parser_cilk_simd_fn_vector_attrs): Initialize parser->cilk_simd_fn_info->clauses. (cp_parser_omp_declare_simd): Initialize parser->omp_declare_simd->clauses. (cp_parser_late_parsing_omp_declare_simd): Simplify code. From-SVN: r239127
2016-08-04re PR c++/70229 (error: constexpr constructor does not have empty body)Marek Polacek2-1/+8
PR c++/70229 * constexpr.c (check_constexpr_ctor_body_1): Allow typedef declarations. * g++.dg/cpp0x/constexpr-ctor19.C: New test. From-SVN: r239115
2016-08-01Warn about mangled name change even if DECL_REALLY_EXTERN.Jason Merrill2-29/+34
* mangle.c (mangle_decl): Warn about mangled name change even if DECL_REALLY_EXTERN. From-SVN: r238966
2016-08-01mangle.c (get_abi_tags): New.Jason Merrill2-17/+34
* mangle.c (get_abi_tags): New. (find_substitution, write_unqualified_name, write_abi_tags) (maybe_check_abi_tags): Use it. From-SVN: r238965
2016-08-01* mangle.c (mangle_decl): Fix mangled name change warning.Jason Merrill2-3/+6
From-SVN: r238964
2016-08-01PR c++/72766 - ICE with VLAJason Merrill3-1/+14
* constexpr.c (cxx_eval_pointer_plus_expression): Check constancy of nelts. * cp-gimplify.c (cp_fully_fold): Only maybe_constant_value in C++11 and up. From-SVN: r238957
2016-07-30PR c++/60760 - arithmetic on null pointers should not be allowed in constantMartin Sebor2-10/+85
PR c++/60760 - arithmetic on null pointers should not be allowed in constant PR c++/71091 - constexpr reference bound to a null pointer dereference gcc/cp/ChangeLog: PR c++/60760 PR c++/71091 * constexpr.c (cxx_eval_binary_expression): Reject invalid expressions involving null pointers. (cxx_eval_component_reference): Reject null pointer dereferences. (cxx_eval_indirect_ref): Reject indirecting through null pointers. (cxx_eval_constant_expression): Reject invalid expressions involving null pointers. gcc/testsuite/ChangeLog: PR c++/60760 PR c++/71091 * g++.dg/cpp0x/constexpr-cast.C: New test. * g++.dg/cpp0x/constexpr-nullptr-2.C: New test. * g++.dg/cpp1y/constexpr-sfinae.C: Correct. * g++.dg/ubsan/pr63956.C: Correct. From-SVN: r238909
2016-07-29re PR c/71926 (wrong location for -Wparentheses warning)Marek Polacek2-2/+8
PR c/71926 * c-common.c (c_common_truthvalue_conversion): Use LOCATION for the parentheses warning. * semantics.c (maybe_convert_cond): Use the location of COND for the parentheses warning. * g++.dg/warn/Wparentheses-30.C: New test. * gcc.dg/Wparentheses-14.c: New test. From-SVN: r238886
2016-07-29* decl.c (build_enumerator): Tweak diagnostic.Jason Merrill2-1/+3
From-SVN: r238873
2016-07-29PR c++/72457 - ICE with list-value-initialized base.Jason Merrill3-4/+16
* init.c (expand_aggr_init_1): Only handle value-init of bases. * constexpr.c (build_data_member_initialization): Handle multiple initializers for the same field. From-SVN: r238867
2016-07-28re PR c++/71665 (ICE on invalid C++ code with non-integral constant ↵Paolo Carlini2-6/+21
enumerator value: in cxx_eval_constant_expression, at cp/constexpr.c:3918) /cp 2016-07-28 Paolo Carlini <paolo.carlini@oracle.com> PR c++/71665 * decl.c (build_enumerator): Check the type of the enumerator before calling cxx_constant_value. /testsuite 2016-07-28 Paolo Carlini <paolo.carlini@oracle.com> PR c++/71665 * g++.dg/cpp0x/pr71665-1.C: New. * g++.dg/cpp0x/pr71665-2.C: Likewise. * g++.dg/cpp0x/enum29.C: Adjust dg-error string. * g++.dg/ext/label10.C: Likewise. * g++.dg/parse/constant5.C: Likewise. From-SVN: r238828
2016-07-27PR c++/71747 - ICE with self-referential partial specJason Merrill2-40/+33
* pt.c (get_partial_spec_bindings): Replace tparms and spec_args parameters with spec_tmpl. Call push_tinst_level. (most_specialized_partial_spec): Adjust. (more_specialized_partial_spec): Adjust. From-SVN: r238785
2016-07-25PR c++/65970 - revert loop location changeJason Merrill2-1/+11
* cp-gimplify.c (genericize_cp_loop): Revert location change. From-SVN: r238737
2016-07-25PR c++/71837 - pack expansion in init-captureJason Merrill3-1/+24
* lambda.c (add_capture): Leave a pack expansion in a TREE_LIST. (build_lambda_object): Call build_x_compound_expr_from_list. * pt.c (tsubst) [DECLTYPE_TYPE]: Likewise. From-SVN: r238733
2016-07-25PR c++/71833 - member template with two parameter packsJason Merrill2-3/+9
PR c++/54440 * pt.c (coerce_template_parameter_pack): Fix logic for pack index. From-SVN: r238731
2016-07-25PR c++/65970 - constexpr infinite loopJason Merrill3-8/+17
gcc/c-family/ * c.opt (fconstexpr-loop-limit): New. gcc/cp/ * constexpr.c (cxx_eval_loop_expr): Count iterations. * cp-gimplify.c (genericize_cp_loop): Use start_locus even for infinite loops. From-SVN: r238730
2016-07-25PR c++/71972 - constexpr array self-modificationJason Merrill2-28/+41
* constexpr.c (cxx_eval_array_reference): Handle looking for the value of an element we're currently modifying. From-SVN: r238729
2016-07-24PR c++/71515 - typename in partial specializationJason Merrill2-14/+17
* pt.c (resolve_typename_type): Try to avoid calling currently_open_class. From-SVN: r238696
2016-07-23PR c++/66617 - virtual base list-initializationJason Merrill2-13/+28
* call.c (add_list_candidates): Handle VTT parm. (build_new_method_call_1): Likewise. From-SVN: r238689
2016-07-23PR c++/55922 - list-value-initialization of baseJason Merrill2-0/+17
PR c++/63151 * init.c (expand_aggr_init_1): Handle list-initialization from {}. From-SVN: r238688
2016-07-23PR c++/70709 - zero-length array memberJason Merrill2-1/+5
* class.c (walk_subobject_offsets): Handle 0-length array. From-SVN: r238687
2016-07-23PR c++/70778 - member template template parameterJason Merrill2-2/+13
* pt.c (tsubst): Also substitute into the template of a BOUND_TEMPLATE_TEMPLATE_PARM. From-SVN: r238686
2016-07-23PR c++/71738 - nested template friendJason Merrill2-1/+6
* pt.c (lookup_template_class_1): Handle getting template from tsubst. From-SVN: r238685
2016-07-23PR c++/71350 - error recursion with initializer-listJason Merrill2-2/+9
* decl.c (reshape_init_r): Check complain for missing braces warning. From-SVN: r238684
2016-07-23PR c++/71576 - bitfield and rvalue referenceJason Merrill2-1/+4
* call.c (convert_like_real): Use lvalue_kind. From-SVN: r238683
2016-07-23PR c++/71748 - call to base destructor in template.Jason Merrill2-4/+19
PR c++/52746 * pt.c (tsubst_baselink): Call adjust_result_of_qualified_name_lookup for unqualified destructors. From-SVN: r238681
2016-07-21PR c++/69223 - ICE with deduced template return type.Jason Merrill2-2/+8
* semantics.c (apply_deduced_return_type): Call complete_type_or_else before building the new RESULT_DECL. From-SVN: r238624
2016-07-21PR c++/71274 - deprecated warning without use.Jason Merrill2-19/+39
* decl2.c (maybe_instantiate_decl): Split out from mark_used. (decl_constant_var_p): Use it instead. From-SVN: r238623
2016-07-21PR c++/71630 - extern variable templateJason Merrill2-1/+8
* pt.c (instantiate_decl): Fix pattern_defined for namespace scope variable templates. From-SVN: r238622
2016-07-21PR c++/71913 - missing copy elision with new.Jason Merrill2-3/+8
* call.c (unsafe_copy_elision_p): It's OK to elide when initializing an unknown object. From-SVN: r238621
2016-07-21call.c (build_over_call): Check unsafe_copy_elision_p even for trivial ↵Jason Merrill3-10/+37
constructors. * call.c (build_over_call): Check unsafe_copy_elision_p even for trivial constructors. * method.c (do_build_copy_constructor): Don't copy tail padding even in a trivial constructor. From-SVN: r238620
2016-07-21re PR c++/71728 (ICE with goto in statement-expression inside a condition)Jakub Jelinek2-5/+14
PR c++/71728 * constexpr.c (potential_constant_expression_1) <case GOTO_EXPR>: Replace assert with test, return false if the goto isn't break or continue. Formatting fix. * g++.dg/other/pr71728.C: New test. From-SVN: r238601
2016-07-21function-tests.c (build_trivial_generic_function): Set BLOCK_SUPERCONTEXT of ↵Richard Biener2-0/+8
DECL_INITIAL. 2016-07-21 Richard Biener <rguenther@suse.de> * function-tests.c (build_trivial_generic_function): Set BLOCK_SUPERCONTEXT of DECL_INITIAL. * omp-low.c (create_omp_child_function): Likewise. (grid_expand_target_grid_body): Likewise. * cgraphunit.c (init_lowered_empty_function): Likewise. (cgraph_node::expand_thunk): Likewise. * tree-parloops.c (create_loop_fn): Likewise. * ipa.c (cgraph_build_static_cdtor_1): Likewise. cp/ * vtable-class-hierarchy.c (vtv_generate_init_routine): Set DECL_IGNORED_P. java/ * jcf-parse.c (java_emit_static_constructor): Set BLOCK_SUPERCONTEXT of DECL_INITIAL. From-SVN: r238589
2016-07-21re PR libgomp/71941 (ICE with OpenMP tasks and queue)Jakub Jelinek2-0/+15
PR c++/71941 * cp-gimplify.c (cp_genericize): For nested cp_genericize calls save/restore bc_label array. * g++.dg/gomp/pr71941.C: New test. From-SVN: r238579
2016-07-21PR c++/70781 - ICE on ill-formed lambda.Jason Merrill2-2/+8
* parser.c (cp_parser_lambda_expression): Unset OK if there was an error parsing the lambda-declarator. From-SVN: r238563
2016-07-21PR c++/71896 - constexpr pointer-to-member comparison.Jason Merrill2-0/+8
* constexpr.c (cxx_eval_binary_expression): Handle comparison between lowered and unlowered PTRMEM_CST. From-SVN: r238562
2016-07-21PR c++/65168 - -Waddress in unevaluated context.Jason Merrill2-13/+6
gcc/c-family/ * c-common.c (c_common_truthvalue_conversion): Check c_inhibit_evaluation_warnings for warning about address of reference. gcc/cp/ * typeck.c (cp_truthvalue_conversion): Compare pointers to nullptr. Don't set c_inhibit_evaluation_warnings. From-SVN: r238560
2016-07-21PR c++/71121 - -Waddress, constexpr, and PMFs.Jason Merrill2-0/+10
* cp-gimplify.c (cp_fully_fold): First call maybe_constant_value. From-SVN: r238559