summaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog31
-rw-r--r--gcc/cp/call.c6
-rw-r--r--gcc/cp/decl.c6
-rw-r--r--gcc/cp/error.c4
-rw-r--r--gcc/cp/lex.c2
-rw-r--r--gcc/cp/name-lookup.c9
-rw-r--r--gcc/cp/name-lookup.h1
-rw-r--r--gcc/cp/pt.c39
-rw-r--r--gcc/cp/typeck2.c6
9 files changed, 77 insertions, 27 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index bb6d614fb3c..4d6c353a178 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,34 @@
+2011-08-16 Jason Merrill <jason@redhat.com>
+
+ PR c++/50086
+ * pt.c (unify_pack_expansion): Correct overloaded unification
+ logic.
+
+ * pt.c (instantiate_class_template_1): If DECL_PRESERVE_P is set
+ on a member function or static data member, call mark_used.
+
+ PR c++/50054
+ * typeck2.c (cxx_incomplete_type_diagnostic): Handle
+ init_list_type_node.
+
+2011-08-13 Jason Merrill <jason@redhat.com>
+
+ PR c++/50075
+ * name-lookup.c (local_bindings_p): New.
+ * name-lookup.h: Declare it.
+ * lex.c (unqualified_name_lookup_error): Use it.
+
+ PR c++/50059
+ * error.c (dump_expr): Handle MODIFY_EXPR properly.
+
+ * decl.c (grok_reference_init): Handle constexpr here.
+ * call.c (initialize_reference): Not here.
+
+2011-08-12 David Li <davidxl@google.com>
+
+ * class.c (update_vtable_entry_for_fn): Set
+ LOST_PRIMARY bit properly.
+
2011-08-12 Jason Merrill <jason@redhat.com>
PR c++/50034
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index e8fb68d833a..d2700cbeac8 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -8820,12 +8820,6 @@ initialize_reference (tree type, tree expr, tree decl, tree *cleanup,
(build_pointer_type (base_conv_type), expr,
complain));
expr = build_nop (type, expr);
- if (DECL_DECLARED_CONSTEXPR_P (decl))
- {
- expr = cxx_constant_value (expr);
- DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl)
- = reduced_constant_expression_p (expr);
- }
}
}
else
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 1db074809c8..c125f05478e 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -4597,6 +4597,12 @@ grok_reference_init (tree decl, tree type, tree init, tree *cleanup)
explicitly); we need to allow the temporary to be initialized
first. */
tmp = initialize_reference (type, init, decl, cleanup, tf_warning_or_error);
+ if (DECL_DECLARED_CONSTEXPR_P (decl))
+ {
+ tmp = cxx_constant_value (tmp);
+ DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl)
+ = reduced_constant_expression_p (tmp);
+ }
if (tmp == error_mark_node)
return NULL_TREE;
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index d435bbe9fce..598ddf10e5d 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -1868,6 +1868,10 @@ dump_expr (tree t, int flags)
case INIT_EXPR:
case MODIFY_EXPR:
+ dump_binary_op (assignment_operator_name_info[(int)NOP_EXPR].name,
+ t, flags);
+ break;
+
case PLUS_EXPR:
case MINUS_EXPR:
case MULT_EXPR:
diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c
index 691a2ec1311..c11e3b31561 100644
--- a/gcc/cp/lex.c
+++ b/gcc/cp/lex.c
@@ -456,7 +456,7 @@ unqualified_name_lookup_error (tree name)
}
/* Prevent repeated error messages by creating a VAR_DECL with
this NAME in the innermost block scope. */
- if (current_function_decl)
+ if (local_bindings_p ())
{
tree decl;
decl = build_decl (input_location,
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 1afd9edffec..64456b49699 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -1608,6 +1608,15 @@ namespace_bindings_p (void)
return b->kind == sk_namespace;
}
+/* True if the innermost non-class scope is a block scope. */
+
+bool
+local_bindings_p (void)
+{
+ cp_binding_level *b = innermost_nonclass_level ();
+ return b->kind < sk_function_parms || b->kind == sk_omp;
+}
+
/* True if the current level needs to have a BLOCK made. */
bool
diff --git a/gcc/cp/name-lookup.h b/gcc/cp/name-lookup.h
index 5974dce3288..a37afdb9b33 100644
--- a/gcc/cp/name-lookup.h
+++ b/gcc/cp/name-lookup.h
@@ -292,6 +292,7 @@ extern bool kept_level_p (void);
extern bool global_bindings_p (void);
extern bool toplevel_bindings_p (void);
extern bool namespace_bindings_p (void);
+extern bool local_bindings_p (void);
extern bool template_parm_scope_p (void);
extern scope_kind innermost_scope_kind (void);
extern cp_binding_level *begin_scope (scope_kind, tree);
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 10fdceda462..9ab110aa225 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -8675,6 +8675,9 @@ instantiate_class_template_1 (tree type)
--processing_template_decl;
set_current_access_from_decl (r);
finish_member_declaration (r);
+ /* Instantiate members marked with attribute used. */
+ if (r != error_mark_node && DECL_PRESERVE_P (r))
+ mark_used (r);
}
else
{
@@ -8724,6 +8727,9 @@ instantiate_class_template_1 (tree type)
/*init_const_expr_p=*/false,
/*asmspec_tree=*/NULL_TREE,
/*flags=*/0);
+ /* Instantiate members marked with attribute used. */
+ if (r != error_mark_node && DECL_PRESERVE_P (r))
+ mark_used (r);
}
else if (TREE_CODE (r) == FIELD_DECL)
{
@@ -15428,7 +15434,6 @@ unify_pack_expansion (tree tparms, tree targs, tree packed_parms,
tree arg = TREE_VEC_ELT (packed_args, i);
tree arg_expr = NULL_TREE;
int arg_strict = strict;
- bool skip_arg_p = false;
if (call_args_p)
{
@@ -15471,19 +15476,15 @@ unify_pack_expansion (tree tparms, tree targs, tree packed_parms,
if (resolve_overloaded_unification
(tparms, targs, parm, arg,
(unification_kind_t) strict,
- sub_strict, explain_p)
- != 0)
- return 1;
- skip_arg_p = true;
+ sub_strict, explain_p))
+ goto unified;
+ return unify_overload_resolution_failure (explain_p, arg);
}
- if (!skip_arg_p)
- {
- arg_expr = arg;
- arg = unlowered_expr_type (arg);
- if (arg == error_mark_node)
- return 1;
- }
+ arg_expr = arg;
+ arg = unlowered_expr_type (arg);
+ if (arg == error_mark_node)
+ return unify_invalid (explain_p);
}
arg_strict = sub_strict;
@@ -15494,16 +15495,14 @@ unify_pack_expansion (tree tparms, tree targs, tree packed_parms,
&parm, &arg, arg_expr);
}
- if (!skip_arg_p)
- {
- /* For deduction from an init-list we need the actual list. */
- if (arg_expr && BRACE_ENCLOSED_INITIALIZER_P (arg_expr))
- arg = arg_expr;
- RECUR_AND_CHECK_FAILURE (tparms, targs, parm, arg, arg_strict,
- explain_p);
- }
+ /* For deduction from an init-list we need the actual list. */
+ if (arg_expr && BRACE_ENCLOSED_INITIALIZER_P (arg_expr))
+ arg = arg_expr;
+ RECUR_AND_CHECK_FAILURE (tparms, targs, parm, arg, arg_strict,
+ explain_p);
}
+ unified:
/* For each parameter pack, collect the deduced value. */
for (pack = packs; pack; pack = TREE_CHAIN (pack))
{
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 07881387eba..79aa354ad02 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -450,6 +450,12 @@ cxx_incomplete_type_diagnostic (const_tree value, const_tree type,
break;
case LANG_TYPE:
+ if (type == init_list_type_node)
+ {
+ emit_diagnostic (diag_kind, input_location, 0,
+ "invalid use of brace-enclosed initializer list");
+ break;
+ }
gcc_assert (type == unknown_type_node);
if (value && TREE_CODE (value) == COMPONENT_REF)
goto bad_member;