&& !TREE_NO_WARNING (cond)
&& warn_parentheses)
{
- warning_at (EXPR_LOC_OR_LOC (cond, input_location), OPT_Wparentheses,
+ warning_at (cp_expr_loc_or_loc (cond, input_location), OPT_Wparentheses,
"suggest parentheses around assignment used as truth value");
TREE_NO_WARNING (cond) = 1;
}
{
cond = maybe_convert_cond (cond);
if (IF_STMT_CONSTEXPR_P (if_stmt)
+ && !type_dependent_expression_p (cond)
&& require_constant_expression (cond)
- && !value_dependent_expression_p (cond))
+ && !instantiation_dependent_expression_p (cond)
+ /* Wait until instantiation time, since only then COND has been
+ converted to bool. */
+ && TYPE_MAIN_VARIANT (TREE_TYPE (cond)) == boolean_type_node)
{
cond = instantiate_non_dependent_expr (cond);
cond = cxx_constant_value (cond, NULL_TREE);
tree
begin_for_scope (tree *init)
{
- tree scope = NULL_TREE;
- if (flag_new_for_scope)
- scope = do_pushlevel (sk_for);
+ tree scope = do_pushlevel (sk_for);
if (processing_template_decl)
*init = push_stmt_list ();
if (scope == NULL_TREE)
{
- gcc_assert (!init || !flag_new_for_scope);
- if (!init)
- scope = begin_for_scope (&init);
+ gcc_assert (!init);
+ scope = begin_for_scope (&init);
}
+
FOR_INIT_STMT (r) = init;
FOR_SCOPE (r) = scope;
FOR_BODY (for_stmt) = do_poplevel (FOR_BODY (for_stmt));
/* Pop the scope for the body of the loop. */
- if (flag_new_for_scope)
- {
- tree scope;
- tree *scope_ptr = (TREE_CODE (for_stmt) == RANGE_FOR_STMT
- ? &RANGE_FOR_SCOPE (for_stmt)
- : &FOR_SCOPE (for_stmt));
- scope = *scope_ptr;
- *scope_ptr = NULL;
- add_stmt (do_poplevel (scope));
+ tree *scope_ptr = (TREE_CODE (for_stmt) == RANGE_FOR_STMT
+ ? &RANGE_FOR_SCOPE (for_stmt)
+ : &FOR_SCOPE (for_stmt));
+ tree scope = *scope_ptr;
+ *scope_ptr = NULL;
+
+ /* During parsing of the body, range for uses "__for_{range,begin,end} "
+ decl names to make those unaccessible by code in the body.
+ Change it to ones with underscore instead of space, so that it can
+ be inspected in the debugger. */
+ tree range_for_decl[3] = { NULL_TREE, NULL_TREE, NULL_TREE };
+ gcc_assert (CPTI_FOR_BEGIN__IDENTIFIER == CPTI_FOR_RANGE__IDENTIFIER + 1
+ && CPTI_FOR_END__IDENTIFIER == CPTI_FOR_RANGE__IDENTIFIER + 2
+ && CPTI_FOR_RANGE_IDENTIFIER == CPTI_FOR_RANGE__IDENTIFIER + 3
+ && CPTI_FOR_BEGIN_IDENTIFIER == CPTI_FOR_BEGIN__IDENTIFIER + 3
+ && CPTI_FOR_END_IDENTIFIER == CPTI_FOR_END__IDENTIFIER + 3);
+ for (int i = 0; i < 3; i++)
+ {
+ tree id = cp_global_trees[CPTI_FOR_RANGE__IDENTIFIER + i];
+ if (IDENTIFIER_BINDING (id)
+ && IDENTIFIER_BINDING (id)->scope == current_binding_level)
+ {
+ range_for_decl[i] = IDENTIFIER_BINDING (id)->value;
+ gcc_assert (VAR_P (range_for_decl[i])
+ && DECL_ARTIFICIAL (range_for_decl[i]));
+ }
}
+
+ add_stmt (do_poplevel (scope));
+
+ for (int i = 0; i < 3; i++)
+ if (range_for_decl[i])
+ DECL_NAME (range_for_decl[i])
+ = cp_global_trees[CPTI_FOR_RANGE_IDENTIFIER + i];
}
/* Begin a range-for-statement. Returns a new RANGE_FOR_STMT.
tree
begin_range_for_stmt (tree scope, tree init)
{
- tree r;
-
begin_maybe_infinite_loop (boolean_false_node);
- r = build_stmt (input_location, RANGE_FOR_STMT,
- NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE);
+ tree r = build_stmt (input_location, RANGE_FOR_STMT, NULL_TREE, NULL_TREE,
+ NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE);
if (scope == NULL_TREE)
{
- gcc_assert (!init || !flag_new_for_scope);
- if (!init)
- scope = begin_for_scope (&init);
+ gcc_assert (!init);
+ scope = begin_for_scope (&init);
}
- /* RANGE_FOR_STMTs do not use nor save the init tree, so we
- pop it now. */
- if (init)
- pop_stmt_list (init);
+ /* Since C++20, RANGE_FOR_STMTs can use the init tree, so save it. */
+ RANGE_FOR_INIT_STMT (r) = init;
RANGE_FOR_SCOPE (r) = scope;
return r;
}
/* Finish the head of a range-based for statement, which may
- be given by RANGE_FOR_STMT. DECL must be the declaration
+ be given by RANGE_FOR_STMT. DECL must be the declaration
and EXPR must be the loop expression. */
void
finish_range_for_decl (tree range_for_stmt, tree decl, tree expr)
{
+ if (processing_template_decl)
+ RANGE_FOR_INIT_STMT (range_for_stmt)
+ = pop_stmt_list (RANGE_FOR_INIT_STMT (range_for_stmt));
RANGE_FOR_DECL (range_for_stmt) = decl;
RANGE_FOR_EXPR (range_for_stmt) = expr;
add_stmt (range_for_stmt);
if (warn_catch_value
&& type != NULL_TREE
&& type != error_mark_node
- && TREE_CODE (TREE_TYPE (decl)) != REFERENCE_TYPE)
+ && !TYPE_REF_P (TREE_TYPE (decl)))
{
tree orig_type = TREE_TYPE (decl);
if (CLASS_TYPE_P (orig_type))
effectively const. */
|| (CLASS_TYPE_P (TREE_TYPE (operand))
&& C_TYPE_FIELDS_READONLY (TREE_TYPE (operand)))))
- cxx_readonly_error (operand, lv_asm);
+ cxx_readonly_error (input_location, operand, lv_asm);
+
+ tree *op = &operand;
+ while (TREE_CODE (*op) == COMPOUND_EXPR)
+ op = &TREE_OPERAND (*op, 1);
+ switch (TREE_CODE (*op))
+ {
+ case PREINCREMENT_EXPR:
+ case PREDECREMENT_EXPR:
+ case MODIFY_EXPR:
+ *op = genericize_compound_lvalue (*op);
+ op = &TREE_OPERAND (*op, 1);
+ break;
+ default:
+ break;
+ }
constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (t)));
oconstraints[i] = constraint;
{
/* If the operand is going to end up in memory,
mark it addressable. */
- if (!allows_reg && !cxx_mark_addressable (operand))
+ if (!allows_reg && !cxx_mark_addressable (*op))
operand = error_mark_node;
}
else
/* Strip the nops as we allow this case. FIXME, this really
should be rejected or made deprecated. */
STRIP_NOPS (operand);
- if (!cxx_mark_addressable (operand))
+
+ tree *op = &operand;
+ while (TREE_CODE (*op) == COMPOUND_EXPR)
+ op = &TREE_OPERAND (*op, 1);
+ switch (TREE_CODE (*op))
+ {
+ case PREINCREMENT_EXPR:
+ case PREDECREMENT_EXPR:
+ case MODIFY_EXPR:
+ *op = genericize_compound_lvalue (*op);
+ op = &TREE_OPERAND (*op, 1);
+ break;
+ default:
+ break;
+ }
+
+ if (!cxx_mark_addressable (*op))
operand = error_mark_node;
}
else if (!allows_reg && !allows_mem)
if (TREE_CODE (expr) == COMPONENT_REF
|| TREE_CODE (expr) == SCOPE_REF)
REF_PARENTHESIZED_P (expr) = true;
- else if (type_dependent_expression_p (expr))
+ else if (processing_template_decl)
expr = build1 (PAREN_EXPR, TREE_TYPE (expr), expr);
- else if (VAR_P (expr) && DECL_HARD_REGISTER (expr))
- /* We can't bind a hard register variable to a reference. */;
else
{
- cp_lvalue_kind kind = lvalue_kind (expr);
- if ((kind & ~clk_class) != clk_none)
- {
- tree type = unlowered_expr_type (expr);
- bool rval = !!(kind & clk_rvalueref);
- type = cp_build_reference_type (type, rval);
- /* This inhibits warnings in, eg, cxx_mark_addressable
- (c++/60955). */
- warning_sentinel s (extra_warnings);
- expr = build_static_cast (type, expr, tf_error);
- if (expr != error_mark_node)
- REF_PARENTHESIZED_P (expr) = true;
- }
+ expr = build1 (VIEW_CONVERT_EXPR, TREE_TYPE (expr), expr);
+ REF_PARENTHESIZED_P (expr) = true;
}
return expr;
tree
maybe_undo_parenthesized_ref (tree t)
{
- if (cxx_dialect >= cxx14
- && INDIRECT_REF_P (t)
- && REF_PARENTHESIZED_P (t))
+ if (cxx_dialect < cxx14)
+ return t;
+
+ if (INDIRECT_REF_P (t) && REF_PARENTHESIZED_P (t))
{
t = TREE_OPERAND (t, 0);
while (TREE_CODE (t) == NON_LVALUE_EXPR
|| TREE_CODE (t) == STATIC_CAST_EXPR);
t = TREE_OPERAND (t, 0);
}
+ else if (TREE_CODE (t) == PAREN_EXPR)
+ t = TREE_OPERAND (t, 0);
+ else if (TREE_CODE (t) == VIEW_CONVERT_EXPR
+ && REF_PARENTHESIZED_P (t))
+ t = TREE_OPERAND (t, 0);
return t;
}
{
tree type = TREE_TYPE (decl);
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
/* Quals on the object don't matter. */;
else if (PACK_EXPANSION_P (type))
/* Don't bother trying to represent this. */
}
/* No need to check access within an enum. */
- if (TREE_CODE (qualifying_class) == ENUMERAL_TYPE)
+ if (TREE_CODE (qualifying_class) == ENUMERAL_TYPE
+ && TREE_CODE (expr) != IDENTIFIER_NODE)
return expr;
/* Within the scope of a class, turn references to non-static
non-type template argument handling. */
if (processing_template_decl
&& (!currently_open_class (qualifying_class)
+ || TREE_CODE (expr) == IDENTIFIER_NODE
+ || TREE_CODE (expr) == TEMPLATE_ID_EXPR
|| TREE_CODE (expr) == BIT_NOT_EXPR))
expr = build_qualified_name (TREE_TYPE (expr),
qualifying_class, expr,
{
tree type = TREE_TYPE (expr);
- if (processing_template_decl)
+ if (type && type_unknown_p (type))
+ {
+ error ("a statement expression is an insufficient context"
+ " for overload resolution");
+ TREE_TYPE (stmt_expr) = error_mark_node;
+ return error_mark_node;
+ }
+ else if (processing_template_decl)
{
expr = build_stmt (input_location, EXPR_STMT, expr);
expr = add_stmt (expr);
else
fn = identifier;
}
+ else if (TREE_CODE (fn) == OVERLOAD && processing_template_decl)
+ /* FIXME: We shouldn't really need to mark the lookup here, as
+ resolving the (non-dependent) call should save the single
+ function we resolve to. Related to PR c++/83529. */
+ lookup_keep (fn);
}
if (fn && template_id && fn != error_mark_node)
{
tree result;
tree orig_fn;
- vec<tree, va_gc> *orig_args = NULL;
+ vec<tree, va_gc> *orig_args = *args;
if (fn == error_mark_node)
return error_mark_node;
|| any_type_dependent_arguments_p (*args))
{
result = build_min_nt_call_vec (orig_fn, *args);
- SET_EXPR_LOCATION (result, EXPR_LOC_OR_LOC (fn, input_location));
+ SET_EXPR_LOCATION (result, cp_expr_loc_or_loc (fn, input_location));
KOENIG_LOOKUP_P (result) = koenig_p;
if (is_overloaded_fn (fn))
- {
- fn = get_fns (fn);
- lookup_keep (fn, true);
- }
+ fn = get_fns (fn);
if (cfun)
{
sizeof_arg, same_type_ignoring_top_level_qualifiers_p);
}
+ if ((complain & tf_warning)
+ && TREE_CODE (fn) == FUNCTION_DECL
+ && fndecl_built_in_p (fn, BUILT_IN_MEMSET)
+ && vec_safe_length (*args) == 3
+ && !any_type_dependent_arguments_p (*args))
+ {
+ tree arg0 = (*orig_args)[0];
+ tree arg1 = (*orig_args)[1];
+ tree arg2 = (*orig_args)[2];
+ int literal_mask = ((literal_integer_zerop (arg1) << 1)
+ | (literal_integer_zerop (arg2) << 2));
+ arg2 = instantiate_non_dependent_expr (arg2);
+ warn_for_memset (input_location, arg0, arg2, literal_mask);
+ }
+
/* A call to a namespace-scope function. */
result = build_new_function_call (fn, args, complain);
}
result = convert_from_reference (result);
}
- /* Free or retain OVERLOADs from lookup. */
- if (is_overloaded_fn (orig_fn))
- lookup_keep (get_fns (orig_fn), processing_template_decl);
-
return result;
}
/* TODO: build_x_unary_op doesn't always honor the location. */
result.set_location (combined_loc);
- tree result_ovl, expr_ovl;
+ if (result == error_mark_node)
+ return result;
if (!(complain & tf_warning))
return result;
- result_ovl = result;
- expr_ovl = expr;
+ tree result_ovl = result;
+ tree expr_ovl = expr;
if (!processing_template_decl)
expr_ovl = cp_fully_fold (expr_ovl);
if (type == error_mark_node)
return error_mark_node;
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
{
compound_literal
= finish_compound_literal (TREE_TYPE (type), compound_literal,
complain, fcl_context);
- return cp_build_c_cast (type, compound_literal, complain);
+ /* The prvalue is then used to direct-initialize the reference. */
+ tree r = (perform_implicit_conversion_flags
+ (type, compound_literal, complain, LOOKUP_NORMAL));
+ return convert_from_reference (r);
}
if (!TYPE_OBJ_P (type))
else
decl = id_expression;
}
- /* If DECL is a variable that would be out of scope under
- ANSI/ISO rules, but in scope in the ARM, name lookup
- will succeed. Issue a diagnostic here. */
- else
- decl = check_for_out_of_scope_variable (decl);
/* Remember that the name was used in the definition of
the current class so that we can check later to see if
*idk = CP_ID_KIND_NONE;
if (TREE_CODE (decl) == TEMPLATE_PARM_INDEX)
decl = TEMPLATE_PARM_DECL (decl);
- r = convert_from_reference (DECL_INITIAL (decl));
-
+ r = DECL_INITIAL (decl);
+ if (CLASS_TYPE_P (TREE_TYPE (r)) && !CP_TYPE_CONST_P (TREE_TYPE (r)))
+ {
+ /* If the entity is a template parameter object for a template
+ parameter of type T, the type of the expression is const T. */
+ tree ctype = TREE_TYPE (r);
+ ctype = cp_build_qualified_type (ctype, (cp_type_quals (ctype)
+ | TYPE_QUAL_CONST));
+ r = build1 (VIEW_CONVERT_EXPR, ctype, r);
+ }
+ r = convert_from_reference (r);
if (integral_constant_expression_p
&& !dependent_type_p (TREE_TYPE (decl))
&& !(INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (r))))
}
/* Implement the __direct_bases keyword: Return the direct base classes
- of type */
+ of type. */
tree
-calculate_direct_bases (tree type)
+calculate_direct_bases (tree type, tsubst_flags_t complain)
{
- vec<tree, va_gc> *vector = make_tree_vector();
- tree bases_vec = NULL_TREE;
- vec<tree, va_gc> *base_binfos;
- tree binfo;
- unsigned i;
-
- complete_type (type);
-
- if (!NON_UNION_CLASS_TYPE_P (type))
+ if (!complete_type_or_maybe_complain (type, NULL_TREE, complain)
+ || !NON_UNION_CLASS_TYPE_P (type))
return make_tree_vec (0);
- base_binfos = BINFO_BASE_BINFOS (TYPE_BINFO (type));
+ vec<tree, va_gc> *vector = make_tree_vector ();
+ vec<tree, va_gc> *base_binfos = BINFO_BASE_BINFOS (TYPE_BINFO (type));
+ tree binfo;
+ unsigned i;
/* Virtual bases are initialized first */
for (i = 0; base_binfos->iterate (i, &binfo); i++)
- {
- if (BINFO_VIRTUAL_P (binfo))
- {
- vec_safe_push (vector, binfo);
- }
- }
+ if (BINFO_VIRTUAL_P (binfo))
+ vec_safe_push (vector, binfo);
/* Now non-virtuals */
for (i = 0; base_binfos->iterate (i, &binfo); i++)
- {
- if (!BINFO_VIRTUAL_P (binfo))
- {
- vec_safe_push (vector, binfo);
- }
- }
-
+ if (!BINFO_VIRTUAL_P (binfo))
+ vec_safe_push (vector, binfo);
- bases_vec = make_tree_vec (vector->length ());
+ tree bases_vec = make_tree_vec (vector->length ());
for (i = 0; i < vector->length (); ++i)
- {
- TREE_VEC_ELT (bases_vec, i) = BINFO_TYPE ((*vector)[i]);
- }
+ TREE_VEC_ELT (bases_vec, i) = BINFO_TYPE ((*vector)[i]);
+
+ release_tree_vector (vector);
return bases_vec;
}
{
vec<tree, va_gc> **data = ((vec<tree, va_gc> **) data_);
if (!BINFO_VIRTUAL_P (binfo))
- {
- vec_safe_push (*data, BINFO_TYPE (binfo));
- }
+ vec_safe_push (*data, BINFO_TYPE (binfo));
return NULL_TREE;
}
static vec<tree, va_gc> *
calculate_bases_helper (tree type)
{
- vec<tree, va_gc> *vector = make_tree_vector();
+ vec<tree, va_gc> *vector = make_tree_vector ();
/* Now add non-virtual base classes in order of construction */
if (TYPE_BINFO (type))
}
tree
-calculate_bases (tree type)
+calculate_bases (tree type, tsubst_flags_t complain)
{
- vec<tree, va_gc> *vector = make_tree_vector();
+ if (!complete_type_or_maybe_complain (type, NULL_TREE, complain)
+ || !NON_UNION_CLASS_TYPE_P (type))
+ return make_tree_vec (0);
+
+ vec<tree, va_gc> *vector = make_tree_vector ();
tree bases_vec = NULL_TREE;
unsigned i;
vec<tree, va_gc> *vbases;
vec<tree, va_gc> *nonvbases;
tree binfo;
- complete_type (type);
-
- if (!NON_UNION_CLASS_TYPE_P (type))
- return make_tree_vec (0);
-
/* First go through virtual base classes */
for (vbases = CLASSTYPE_VBASECLASSES (type), i = 0;
vec_safe_iterate (vbases, i, &binfo); i++)
{
- vec<tree, va_gc> *vbase_bases;
- vbase_bases = calculate_bases_helper (BINFO_TYPE (binfo));
+ vec<tree, va_gc> *vbase_bases
+ = calculate_bases_helper (BINFO_TYPE (binfo));
vec_safe_splice (vector, vbase_bases);
release_tree_vector (vbase_bases);
}
if (vector->length () > 1)
{
/* Last element is entire class, so don't copy */
- bases_vec = make_tree_vec (vector->length() - 1);
+ bases_vec = make_tree_vec (vector->length () - 1);
for (i = 0; i < vector->length () - 1; ++i)
TREE_VEC_ELT (bases_vec, i) = (*vector)[i];
|| TREE_CODE (TREE_TYPE (expr)) == METHOD_TYPE
|| TREE_TYPE (expr) == unknown_type_node)
{
- if (INDIRECT_REF_P (expr))
- error ("second operand of %<offsetof%> is neither a single "
- "identifier nor a sequence of member accesses and "
- "array references");
- else
+ while (TREE_CODE (expr) == COMPONENT_REF
+ || TREE_CODE (expr) == COMPOUND_EXPR)
+ expr = TREE_OPERAND (expr, 1);
+
+ if (DECL_P (expr))
{
- if (TREE_CODE (expr) == COMPONENT_REF
- || TREE_CODE (expr) == COMPOUND_EXPR)
- expr = TREE_OPERAND (expr, 1);
error ("cannot apply %<offsetof%> to member function %qD", expr);
+ inform (DECL_SOURCE_LOCATION (expr), "declared here");
}
+ else
+ error ("cannot apply %<offsetof%> to member function");
+ return error_mark_node;
+ }
+ if (TREE_CODE (expr) == CONST_DECL)
+ {
+ error ("cannot apply %<offsetof%> to an enumerator %qD", expr);
return error_mark_node;
}
if (REFERENCE_REF_P (expr))
&& CLASS_TYPE_P (TREE_TYPE (TREE_TYPE (object_ptr)))
&& CLASSTYPE_NON_STD_LAYOUT (TREE_TYPE (TREE_TYPE (object_ptr)))
&& cp_unevaluated_operand == 0)
- pedwarn (loc, OPT_Winvalid_offsetof,
- "offsetof within non-standard-layout type %qT is undefined",
- TREE_TYPE (TREE_TYPE (object_ptr)));
+ warning_at (loc, OPT_Winvalid_offsetof, "offsetof within "
+ "non-standard-layout type %qT is conditionally-supported",
+ TREE_TYPE (TREE_TYPE (object_ptr)));
return fold_offsetof (expr);
}
&& DECL_OMP_PRIVATIZED_MEMBER (decl))
{
tree f = DECL_VALUE_EXPR (decl);
- if (TREE_CODE (f) == INDIRECT_REF)
+ if (INDIRECT_REF_P (f))
f = TREE_OPERAND (f, 0);
if (TREE_CODE (f) == COMPONENT_REF)
{
return error_mark_node;
if (!omp_private_member_map && !shared)
omp_private_member_map = new hash_map<tree, tree>;
- if (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE)
+ if (TYPE_REF_P (TREE_TYPE (t)))
{
- gcc_assert (TREE_CODE (m) == INDIRECT_REF);
+ gcc_assert (INDIRECT_REF_P (m));
m = TREE_OPERAND (m, 0);
}
tree vb = NULL_TREE;
omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
return error_mark_node;
}
- else if (TREE_CODE (t) == PARM_DECL
+ else if (ort == C_ORT_OMP
+ && TREE_CODE (t) == PARM_DECL
&& DECL_ARTIFICIAL (t)
&& DECL_NAME (t) == this_identifier)
{
}
}
}
- else if (TREE_CODE (type) == POINTER_TYPE)
+ else if (TYPE_PTR_P (type))
{
if (length == NULL_TREE)
{
eltype = TREE_TYPE (eltype);
tree type = build_array_type (eltype, index_type);
tree ptype = build_pointer_type (eltype);
- if (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE
- && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (t))))
+ if (TYPE_REF_P (TREE_TYPE (t))
+ && INDIRECT_TYPE_P (TREE_TYPE (TREE_TYPE (t))))
t = convert_from_reference (t);
else if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
t = build_fold_addr_expr (t);
ptrdiff_type_node, t);
tree ptr = OMP_CLAUSE_DECL (c2);
ptr = convert_from_reference (ptr);
- if (!POINTER_TYPE_P (TREE_TYPE (ptr)))
+ if (!INDIRECT_TYPE_P (TREE_TYPE (ptr)))
ptr = build_fold_addr_expr (ptr);
t = fold_build2_loc (OMP_CLAUSE_LOCATION (c), MINUS_EXPR,
ptrdiff_type_node, t,
OMP_CLAUSE_CHAIN (c) = c2;
ptr = OMP_CLAUSE_DECL (c2);
if (OMP_CLAUSE_MAP_KIND (c2) != GOMP_MAP_FIRSTPRIVATE_POINTER
- && TREE_CODE (TREE_TYPE (ptr)) == REFERENCE_TYPE
- && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (ptr))))
+ && TYPE_REF_P (TREE_TYPE (ptr))
+ && INDIRECT_TYPE_P (TREE_TYPE (TREE_TYPE (ptr))))
{
tree c3 = build_omp_clause (OMP_CLAUSE_LOCATION (c),
OMP_CLAUSE_MAP);
cp_check_omp_declare_reduction (tree udr)
{
tree type = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (udr)));
- gcc_assert (TREE_CODE (type) == REFERENCE_TYPE);
+ gcc_assert (TYPE_REF_P (type));
type = TREE_TYPE (type);
int i;
location_t loc = DECL_SOURCE_LOCATION (udr);
"%<#pragma omp declare reduction%>", type);
return;
}
- else if (TREE_CODE (type) == REFERENCE_TYPE)
+ else if (TYPE_REF_P (type))
{
error_at (loc, "reference type %qT in %<#pragma omp declare reduction%>",
type);
tree type = TREE_TYPE (t);
if (TREE_CODE (t) == MEM_REF)
type = TREE_TYPE (type);
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
type = TREE_TYPE (type);
if (TREE_CODE (type) == ARRAY_TYPE)
{
return false;
}
else if (processing_template_decl)
- return false;
+ {
+ if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) == error_mark_node)
+ return true;
+ return false;
+ }
tree id = OMP_CLAUSE_REDUCTION_PLACEHOLDER (c);
if (TREE_ADDRESSABLE (DECL_EXPR_DECL (stmts[0])))
cxx_mark_addressable (placeholder);
if (TREE_ADDRESSABLE (DECL_EXPR_DECL (stmts[1]))
- && TREE_CODE (TREE_TYPE (OMP_CLAUSE_DECL (c)))
- != REFERENCE_TYPE)
+ && !TYPE_REF_P (TREE_TYPE (OMP_CLAUSE_DECL (c))))
cxx_mark_addressable (decl_placeholder ? decl_placeholder
: OMP_CLAUSE_DECL (c));
tree omp_out = placeholder;
if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LINEAR
&& integer_zerop (OMP_CLAUSE_DECL (c))
&& OMP_CLAUSE_LINEAR_STEP (c)
- && TREE_CODE (TREE_TYPE (OMP_CLAUSE_LINEAR_STEP (c)))
- == POINTER_TYPE)
+ && TYPE_PTR_P (TREE_TYPE (OMP_CLAUSE_LINEAR_STEP (c))))
{
tree s = OMP_CLAUSE_LINEAR_STEP (c);
s = fold_convert_loc (OMP_CLAUSE_LOCATION (c), sizetype, s);
for (; t; t = TREE_CHAIN (t))
{
tree decl = TREE_VALUE (t);
- if (TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE)
+ if (TYPE_PTR_P (TREE_TYPE (decl)))
{
tree offset = TREE_PURPOSE (t);
bool neg = wi::neg_p (wi::to_wide (offset));
if (TREE_CODE (t) == POINTER_PLUS_EXPR)
t = TREE_OPERAND (t, 0);
if (TREE_CODE (t) == ADDR_EXPR
- || TREE_CODE (t) == INDIRECT_REF)
+ || INDIRECT_REF_P (t))
t = TREE_OPERAND (t, 0);
}
tree n = omp_clause_decl_field (t);
tree type = TREE_TYPE (t);
if ((OMP_CLAUSE_LINEAR_KIND (c) == OMP_CLAUSE_LINEAR_REF
|| OMP_CLAUSE_LINEAR_KIND (c) == OMP_CLAUSE_LINEAR_UVAL)
- && TREE_CODE (type) != REFERENCE_TYPE)
+ && !TYPE_REF_P (type))
{
error ("linear clause with %qs modifier applied to "
"non-reference variable with %qT type",
remove = true;
break;
}
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
type = TREE_TYPE (type);
if (OMP_CLAUSE_LINEAR_KIND (c) != OMP_CLAUSE_LINEAR_REF)
{
if (!INTEGRAL_TYPE_P (type)
- && TREE_CODE (type) != POINTER_TYPE)
+ && !TYPE_PTR_P (type))
{
error ("linear clause applied to non-integral non-pointer"
" variable with %qT type", TREE_TYPE (t));
&& !INTEGRAL_TYPE_P (TREE_TYPE (t))
&& (ort != C_ORT_OMP_DECLARE_SIMD
|| TREE_CODE (t) != PARM_DECL
- || TREE_CODE (TREE_TYPE (t)) != REFERENCE_TYPE
+ || !TYPE_REF_P (TREE_TYPE (t))
|| !INTEGRAL_TYPE_P (TREE_TYPE (TREE_TYPE (t)))))
{
error ("linear step expression must be integral");
}
t = fold_build_cleanup_point_expr (TREE_TYPE (t), t);
tree type = TREE_TYPE (OMP_CLAUSE_DECL (c));
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
type = TREE_TYPE (type);
if (OMP_CLAUSE_LINEAR_KIND (c) == OMP_CLAUSE_LINEAR_REF)
{
break;
}
}
- else if (TREE_CODE (type) == POINTER_TYPE
+ else if (TYPE_PTR_P (type)
/* Can't multiply the step yet if *this
is still incomplete type. */
&& (ort != C_ORT_OMP_DECLARE_SIMD
remove = true;
}
else if (!type_dependent_expression_p (t)
- && TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE
+ && !TYPE_PTR_P (TREE_TYPE (t))
&& TREE_CODE (TREE_TYPE (t)) != ARRAY_TYPE
- && (TREE_CODE (TREE_TYPE (t)) != REFERENCE_TYPE
- || (!POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (t)))
+ && (!TYPE_REF_P (TREE_TYPE (t))
+ || (!INDIRECT_TYPE_P (TREE_TYPE (TREE_TYPE (t)))
&& (TREE_CODE (TREE_TYPE (TREE_TYPE (t)))
!= ARRAY_TYPE))))
{
break;
}
else if (!processing_template_decl
- && TREE_CODE (TREE_TYPE (t)) != REFERENCE_TYPE
+ && !TYPE_REF_P (TREE_TYPE (t))
&& (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP
|| (OMP_CLAUSE_MAP_KIND (c)
!= GOMP_MAP_FIRSTPRIVATE_POINTER))
== GOMP_MAP_FIRSTPRIVATE_POINTER)))
&& t == OMP_CLAUSE_DECL (c)
&& !type_dependent_expression_p (t)
- && !cp_omp_mappable_type ((TREE_CODE (TREE_TYPE (t))
- == REFERENCE_TYPE)
+ && !cp_omp_mappable_type (TYPE_REF_P (TREE_TYPE (t))
? TREE_TYPE (TREE_TYPE (t))
: TREE_TYPE (t)))
{
else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
&& OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_FORCE_DEVICEPTR
&& !type_dependent_expression_p (t)
- && !POINTER_TYPE_P (TREE_TYPE (t)))
+ && !INDIRECT_TYPE_P (TREE_TYPE (t)))
{
error ("%qD is not a pointer variable", t);
remove = true;
handle_map_references:
if (!remove
&& !processing_template_decl
- && (ort & C_ORT_OMP_DECLARE_SIMD) == C_ORT_OMP
- && TREE_CODE (TREE_TYPE (OMP_CLAUSE_DECL (c))) == REFERENCE_TYPE)
+ && ort != C_ORT_DECLARE_SIMD
+ && TYPE_REF_P (TREE_TYPE (OMP_CLAUSE_DECL (c))))
{
t = OMP_CLAUSE_DECL (c);
if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP)
if (!type_dependent_expression_p (t))
{
tree type = TREE_TYPE (t);
- if (TREE_CODE (type) != POINTER_TYPE
+ if (!TYPE_PTR_P (type)
&& TREE_CODE (type) != ARRAY_TYPE
- && (TREE_CODE (type) != REFERENCE_TYPE
- || (TREE_CODE (TREE_TYPE (type)) != POINTER_TYPE
+ && (!TYPE_REF_P (type)
+ || (!TYPE_PTR_P (TREE_TYPE (type))
&& TREE_CODE (TREE_TYPE (type)) != ARRAY_TYPE)))
{
error_at (OMP_CLAUSE_LOCATION (c),
case OMP_CLAUSE_AUTO:
case OMP_CLAUSE_INDEPENDENT:
case OMP_CLAUSE_SEQ:
+ case OMP_CLAUSE_IF_PRESENT:
+ case OMP_CLAUSE_FINALIZE:
break;
case OMP_CLAUSE_TILE:
t = require_complete_type (t);
if (t == error_mark_node)
remove = true;
- else if (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE
+ else if (TYPE_REF_P (TREE_TYPE (t))
&& !complete_type_or_else (TREE_TYPE (TREE_TYPE (t)), t))
remove = true;
}
if (VAR_P (t) && CP_DECL_THREAD_LOCAL_P (t))
share_name = "threadprivate";
- else switch (cxx_omp_predetermined_sharing (t))
+ else switch (cxx_omp_predetermined_sharing_1 (t))
{
case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
break;
if ((need_complete_type
|| need_copy_assignment
|| OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION)
- && TREE_CODE (inner_type) == REFERENCE_TYPE)
+ && TYPE_REF_P (inner_type))
inner_type = TREE_TYPE (inner_type);
while (TREE_CODE (inner_type) == ARRAY_TYPE)
inner_type = TREE_TYPE (inner_type);
{
/* Allocate a LANG_SPECIFIC structure for V, if needed. */
if (DECL_LANG_SPECIFIC (v) == NULL)
- {
- retrofit_lang_decl (v);
-
- /* Make sure that DECL_DISCRIMINATOR_P continues to be true
- after the allocation of the lang_decl structure. */
- if (DECL_DISCRIMINATOR_P (v))
- DECL_LANG_SPECIFIC (v)->u.base.u2sel = 1;
- }
+ retrofit_lang_decl (v);
if (! CP_DECL_THREAD_LOCAL_P (v))
{
handle_omp_for_class_iterator (int i, location_t locus, enum tree_code code,
tree declv, tree orig_declv, tree initv,
tree condv, tree incrv, tree *body,
- tree *pre_body, tree &clauses, tree *lastp,
+ tree *pre_body, tree &clauses,
int collapse, int ordered)
{
tree diff, iter_init, iter_incr = NULL, last;
TREE_VEC_ELT (initv, i) = init;
TREE_VEC_ELT (condv, i) = cond;
TREE_VEC_ELT (incrv, i) = incr;
- *lastp = last;
+ TREE_VEC_ELT (orig_declv, i)
+ = tree_cons (TREE_VEC_ELT (orig_declv, i), last, NULL_TREE);
return false;
}
{
tree omp_for = NULL, orig_incr = NULL;
tree decl = NULL, init, cond, incr;
- tree last = NULL_TREE;
location_t elocus;
int i;
int collapse = 1;
}
if (handle_omp_for_class_iterator (i, locus, code, declv, orig_declv,
initv, condv, incrv, &body,
- &pre_body, clauses, &last,
+ &pre_body, clauses,
collapse, ordered))
return NULL;
continue;
case POSTINCREMENT_EXPR:
/* c_omp_for_incr_canonicalize_ptr() should have been
called to massage things appropriately. */
- gcc_assert (!POINTER_TYPE_P (TREE_TYPE (decl)));
+ gcc_assert (!INDIRECT_TYPE_P (TREE_TYPE (decl)));
OMP_CLAUSE_LINEAR_STEP (c) = build_int_cst (TREE_TYPE (decl), 1);
break;
case PREDECREMENT_EXPR:
case POSTDECREMENT_EXPR:
/* c_omp_for_incr_canonicalize_ptr() should have been
called to massage things appropriately. */
- gcc_assert (!POINTER_TYPE_P (TREE_TYPE (decl)));
+ gcc_assert (!INDIRECT_TYPE_P (TREE_TYPE (decl)));
OMP_CLAUSE_LINEAR_STEP (c)
= build_int_cst (TREE_TYPE (decl), -1);
break;
gcc_unreachable ();
}
stept = TREE_TYPE (decl);
- if (POINTER_TYPE_P (stept))
+ if (INDIRECT_TYPE_P (stept))
stept = sizetype;
step = fold_convert (stept, step);
if (TREE_CODE (incr) == MINUS_EXPR)
if (check_for_bare_parameter_packs (condition))
condition = error_mark_node;
- if (type_dependent_expression_p (condition)
- || value_dependent_expression_p (condition))
+ if (instantiation_dependent_expression_p (condition))
{
/* We're in a template; build a STATIC_ASSERT and put it in
the right place. */
/* Fold the expression and convert it to a boolean value. */
condition = perform_implicit_conversion_flags (boolean_type_node, condition,
complain, LOOKUP_NORMAL);
- condition = fold_non_dependent_expr (condition);
+ condition = fold_non_dependent_expr (condition, complain);
if (TREE_CODE (condition) == INTEGER_CST && !integer_zerop (condition))
/* Do nothing; the condition is satisfied. */
else if (condition && condition != error_mark_node)
{
error ("non-constant condition for static assertion");
- if (require_potential_rvalue_constant_expression (condition))
+ if (require_rvalue_constant_expression (condition))
cxx_constant_value (condition);
}
input_location = saved_loc;
if (identifier_p (expr))
expr = lookup_name (expr);
- if (INDIRECT_REF_P (expr))
+ if (INDIRECT_REF_P (expr)
+ || TREE_CODE (expr) == VIEW_CONVERT_EXPR)
/* This can happen when the expression is, e.g., "a.b". Just
look at the underlying operand. */
expr = TREE_OPERAND (expr, 0);
decltype(e) is defined as T&; if an xvalue, T&&; otherwise, T. */
cp_lvalue_kind clk = lvalue_kind (expr);
type = unlowered_expr_type (expr);
- gcc_assert (TREE_CODE (type) != REFERENCE_TYPE);
+ gcc_assert (!TYPE_REF_P (type));
/* For vector types, pick a non-opaque variant. */
if (VECTOR_TYPE_P (type))
case CPLD_COPY:
type = TREE_TYPE (decl);
- if (TREE_CODE (type) == REFERENCE_TYPE
+ if (TYPE_REF_P (type)
&& TREE_CODE (TREE_TYPE (type)) != FUNCTION_TYPE)
type = TREE_TYPE (type);
break;
case CPLD_REFERENCE:
type = TREE_TYPE (decl);
- if (TREE_CODE (type) != REFERENCE_TYPE)
+ if (!TYPE_REF_P (type))
type = build_reference_type (TREE_TYPE (decl));
break;
gcc_unreachable ();
}
- if (TREE_CODE (type) != REFERENCE_TYPE)
+ if (!TYPE_REF_P (type))
{
if (!LAMBDA_EXPR_MUTABLE_P (lam))
type = cp_build_qualified_type (type, (cp_type_quals (type)
if (error_operand_p (arg))
return error_mark_node;
if (!type_dependent_expression_p (arg)
- && TREE_CODE (TREE_TYPE (arg)) != POINTER_TYPE)
+ && !TYPE_PTR_P (TREE_TYPE (arg)))
{
error_at (loc, "non-pointer argument to %<__builtin_launder%>");
return error_mark_node;