summaryrefslogtreecommitdiff
path: root/gcc/cp/semantics.c
diff options
context:
space:
mode:
authordnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4>2013-03-26 10:33:36 +0000
committerdnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4>2013-03-26 10:33:36 +0000
commita63f89638edc7c3120e52faf6815bfe3e9b270e2 (patch)
tree61b7552b10852929b89f1cb93878fadffc1885c2 /gcc/cp/semantics.c
parent9402409a6bd0d7d1f7358793f768bda3ec8a9574 (diff)
parent087a99ba8749638f86c111f776ed326b3fbd97c0 (diff)
downloadgcc-cxx-conversion.tar.gz
Merged revisions 196607-196608,196611-196614,196625,196629-196634,196636,196639,196645-196647,196649-196650,196654-196659,196666,196669,196671-196675,196682-196683,196694-196695,196697-196698,196700-196701,196704-196706,196709,196721-196748,196750-196751,196753,196755-196758,196762,196764-196765,196767-196771,196773-196779,196781-196784,196788-196792,196795-196797,196799-196800,196804-196807,196810-196814,196821,196823-196825,196828-196829,196831-196832,196834,196841-196842,196847-196853,196855-196856,196858,196860-196861,196864-196866,196868,196870-196872,196874,196876,196878-196879,196882,196884-196890,196896-196897,196899-196902,196954,196956-196961,196964-196965,196970,196977-196978,196981-196983,196989,197002-197005,197007,197011-197012,197016-197019,197021,197023-197025,197029-197034,197036-197042 via svnmerge from cxx-conversion
svn+ssh://gcc.gnu.org/svn/gcc/trunk git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/cxx-conversion@197098 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/semantics.c')
-rw-r--r--gcc/cp/semantics.c56
1 files changed, 38 insertions, 18 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index e909b984681..e3aeb817a52 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -536,7 +536,7 @@ simplify_loop_decl_cond (tree *cond_p, tree body)
tree
finish_goto_stmt (tree destination)
{
- if (TREE_CODE (destination) == IDENTIFIER_NODE)
+ if (identifier_p (destination))
destination = lookup_label (destination);
/* We warn about unused labels with -Wunused. That means we have to
@@ -1574,9 +1574,7 @@ finish_non_static_data_member (tree decl, tree object, tree qualifying_scope)
else
{
/* Set the cv qualifiers. */
- int quals = (current_class_ref
- ? cp_type_quals (TREE_TYPE (current_class_ref))
- : TYPE_UNQUALIFIED);
+ int quals = cp_type_quals (TREE_TYPE (object));
if (DECL_MUTABLE_P (decl))
quals &= ~TYPE_QUAL_CONST;
@@ -2001,7 +1999,7 @@ perform_koenig_lookup (tree fn, vec<tree, va_gc> *args, bool include_std,
}
/* Find the name of the overloaded function. */
- if (TREE_CODE (fn) == IDENTIFIER_NODE)
+ if (identifier_p (fn))
identifier = fn;
else if (is_overloaded_fn (fn))
{
@@ -2884,7 +2882,8 @@ outer_var_p (tree decl)
{
return ((TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == PARM_DECL)
&& DECL_FUNCTION_SCOPE_P (decl)
- && DECL_CONTEXT (decl) != current_function_decl);
+ && (DECL_CONTEXT (decl) != current_function_decl
+ || parsing_nsdmi ()));
}
/* As above, but also checks that DECL is automatic. */
@@ -2967,7 +2966,7 @@ finish_id_expression (tree id_expression,
if (scope
&& (!TYPE_P (scope)
|| (!dependent_type_p (scope)
- && !(TREE_CODE (id_expression) == IDENTIFIER_NODE
+ && !(identifier_p (id_expression)
&& IDENTIFIER_TYPENAME_P (id_expression)
&& dependent_type_p (TREE_TYPE (id_expression))))))
{
@@ -2996,8 +2995,7 @@ finish_id_expression (tree id_expression,
the current class so that we can check later to see if
the meaning would have been different after the class
was entirely defined. */
- if (!scope && decl != error_mark_node
- && TREE_CODE (id_expression) == IDENTIFIER_NODE)
+ if (!scope && decl != error_mark_node && identifier_p (id_expression))
maybe_note_name_used_in_class (id_expression, decl);
/* Disallow uses of local variables from containing functions, except
@@ -3041,12 +3039,14 @@ finish_id_expression (tree id_expression,
return integral_constant_value (decl);
}
+ if (parsing_nsdmi ())
+ containing_function = NULL_TREE;
/* If we are in a lambda function, we can move out until we hit
1. the context,
2. a non-lambda function, or
3. a non-default capturing lambda function. */
- while (context != containing_function
- && LAMBDA_FUNCTION_P (containing_function))
+ else while (context != containing_function
+ && LAMBDA_FUNCTION_P (containing_function))
{
lambda_expr = CLASSTYPE_LAMBDA_EXPR
(DECL_CONTEXT (containing_function));
@@ -3168,8 +3168,7 @@ finish_id_expression (tree id_expression,
/* A template-id where the name of the template was not resolved
is definitely dependent. */
else if (TREE_CODE (decl) == TEMPLATE_ID_EXPR
- && (TREE_CODE (TREE_OPERAND (decl, 0))
- == IDENTIFIER_NODE))
+ && (identifier_p (TREE_OPERAND (decl, 0))))
dependent_p = true;
/* For anything except an overloaded function, just check its
type. */
@@ -5300,7 +5299,7 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p,
[expr.ref]), decltype(e) is defined as the type of the entity
named by e. If there is no such entity, or e names a set of
overloaded functions, the program is ill-formed. */
- if (TREE_CODE (expr) == IDENTIFIER_NODE)
+ if (identifier_p (expr))
expr = lookup_name (expr);
if (TREE_CODE (expr) == INDIRECT_REF)
@@ -6837,6 +6836,9 @@ cxx_eval_call_expression (const constexpr_call *old_call, tree t,
bool
reduced_constant_expression_p (tree t)
{
+ if (TREE_CODE (t) == PTRMEM_CST)
+ /* Even if we can't lower this yet, it's constant. */
+ return true;
/* FIXME are we calling this too much? */
return initializer_constant_valid_p (t, TREE_TYPE (t)) != NULL_TREE;
}
@@ -7007,6 +7009,13 @@ cxx_eval_array_reference (const constexpr_call *call, tree t,
*non_constant_p = true;
return t;
}
+ else if (tree_int_cst_lt (index, integer_zero_node))
+ {
+ if (!allow_non_constant)
+ error ("negative array subscript");
+ *non_constant_p = true;
+ return t;
+ }
i = tree_low_cst (index, 0);
if (TREE_CODE (ary) == CONSTRUCTOR)
return (*CONSTRUCTOR_ELTS (ary))[i].value;
@@ -8487,6 +8496,13 @@ potential_constant_expression_1 (tree t, bool want_rval, tsubst_flags_t flags)
STRIP_NOPS (x);
if (is_this_parameter (x))
{
+ if (DECL_CONTEXT (x)
+ && !DECL_DECLARED_CONSTEXPR_P (DECL_CONTEXT (x)))
+ {
+ if (flags & tf_error)
+ error ("use of %<this%> in a constant expression");
+ return false;
+ }
if (want_rval && DECL_CONTEXT (x)
&& DECL_CONSTRUCTOR_P (DECL_CONTEXT (x)))
{
@@ -8967,7 +8983,7 @@ begin_lambda_type (tree lambda)
/* Create the new RECORD_TYPE for this lambda. */
type = xref_tag (/*tag_code=*/record_type,
name,
- /*scope=*/ts_within_enclosing_non_class,
+ /*scope=*/ts_lambda,
/*template_header_p=*/false);
}
@@ -9039,7 +9055,7 @@ tree
lambda_capture_field_type (tree expr)
{
tree type;
- if (type_dependent_expression_p (expr))
+ if (!TREE_TYPE (expr) || WILDCARD_TYPE_P (TREE_TYPE (expr)))
{
type = cxx_make_type (DECLTYPE_TYPE);
DECLTYPE_TYPE_EXPR (type) = expr;
@@ -9248,7 +9264,7 @@ lambda_proxy_type (tree ref)
if (REFERENCE_REF_P (ref))
ref = TREE_OPERAND (ref, 0);
type = TREE_TYPE (ref);
- if (!dependent_type_p (type))
+ if (type && !WILDCARD_TYPE_P (type))
return type;
type = cxx_make_type (DECLTYPE_TYPE);
DECLTYPE_TYPE_EXPR (type) = ref;
@@ -9661,7 +9677,11 @@ maybe_add_lambda_conv_op (tree type)
DECL_STATIC_FUNCTION_P (fn) = 1;
DECL_ARGUMENTS (fn) = copy_list (DECL_CHAIN (DECL_ARGUMENTS (callop)));
for (arg = DECL_ARGUMENTS (fn); arg; arg = DECL_CHAIN (arg))
- DECL_CONTEXT (arg) = fn;
+ {
+ /* Avoid duplicate -Wshadow warnings. */
+ DECL_NAME (arg) = NULL_TREE;
+ DECL_CONTEXT (arg) = fn;
+ }
if (nested)
DECL_INTERFACE_KNOWN (fn) = 1;