summaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2011-12-12 09:48:08 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2011-12-12 09:48:08 +0000
commita08c9086662af01e9b45c14a9254a9f8c8ed2c57 (patch)
treee100d0deea8e73f61b639ceca819feeedad88a45 /gcc/cp
parent30be4b5bc2781a437162c35b2d95672ce77cc6c5 (diff)
downloadgcc-a08c9086662af01e9b45c14a9254a9f8c8ed2c57.tar.gz
2011-12-12 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 182221 using svnmerge git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@182223 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog58
-rw-r--r--gcc/cp/call.c5
-rw-r--r--gcc/cp/cp-tree.h29
-rw-r--r--gcc/cp/decl.c14
-rw-r--r--gcc/cp/init.c3
-rw-r--r--gcc/cp/parser.c7
-rw-r--r--gcc/cp/pt.c24
-rw-r--r--gcc/cp/semantics.c2
-rw-r--r--gcc/cp/tree.c11
-rw-r--r--gcc/cp/typeck.c6
-rw-r--r--gcc/cp/typeck2.c23
11 files changed, 140 insertions, 42 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index defc0a5eb44..1ba9f347a17 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,61 @@
+2011-12-12 Richard Guenther <rguenther@suse.de>
+
+ PR lto/51262
+ * tree.c (cp_free_lang_data): No longer clear anonymous names.
+
+2011-12-09 Jason Merrill <jason@redhat.com>
+
+ PR c++/51151
+ * call.c (perform_implicit_conversion_flags): Remove earlier kludge.
+ * parser.c (cp_parser_omp_for_loop): Use cp_parser_omp_for_incr
+ in templates even if decl isn't type-dependent.
+
+2011-12-09 Dodji Seketeli <dodji@redhat.com>
+
+ PR c++/51289
+ * cp-tree.h (TYPE_TEMPLATE_INFO): Rewrite this accessor macro to
+ better support aliased types.
+ (TYPE_ALIAS_P): Don't crash on TYPE_NAME nodes that are not
+ TYPE_DECL.
+ * pt.c (find_parameter_packs_r): Handle types aliases.
+ (push_template_decl_real): Check for bare parameter packs in the
+ underlying type of an alias template.
+
+2011-12-08 Jason Merrill <jason@redhat.com>
+
+ PR c++/51318
+ * typeck.c (build_x_conditional_expr): Restrict glvalue games to C++11.
+
+ PR c++/51459
+ * pt.c (tsubst_expr) [DECL_EXPR]: Handle capture proxies properly.
+ * semantics.c (insert_capture_proxy): No longer static.
+ * cp-tree.h: Declare it.
+
+2011-12-07 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/51401
+ * decl.c (grokdeclarator): Error for auto on non-static data members.
+
+ PR c++/51429
+ * typeck2.c (cxx_incomplete_type_diagnostic): Don't
+ ICE if TREE_OPERAND (value, 1) is overloaded.
+
+ PR c++/51229
+ * decl.c (reshape_init_class): Complain if d->cur->index is
+ INTEGER_CST.
+ * parser.c (cp_parser_initializer_list): If cp_parser_parse_definitely
+ fails, clear designator.
+
+ PR c++/51369
+ * init.c (build_value_init): Allow array types even when
+ processing_template_decl.
+
+2011-12-07 Ed Smith-Rowland <3dw4rd@verizon.net>
+
+ PR c++/51420
+ * parser.c (lookup_literal_operator): Check that declaration is an
+ overloaded function.
+
2011-12-06 Jakub Jelinek <jakub@redhat.com>
PR c++/51430
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index d8fc4f1d2d5..65283685a39 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -8437,10 +8437,7 @@ perform_implicit_conversion_flags (tree type, tree expr, tsubst_flags_t complain
}
expr = error_mark_node;
}
- else if (processing_template_decl
- /* As a kludge, we always perform conversions between scalar
- types, as IMPLICIT_CONV_EXPR confuses c_finish_omp_for. */
- && !(SCALAR_TYPE_P (type) && SCALAR_TYPE_P (TREE_TYPE (expr))))
+ else if (processing_template_decl && conv->kind != ck_identity)
{
/* In a template, we are only concerned about determining the
type of non-dependent expressions, so we do not have to
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index dccf485a60f..955d0eb3668 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -2555,6 +2555,7 @@ extern void decl_shadowed_for_var_insert (tree, tree);
#define TYPE_ALIAS_P(NODE) \
(TYPE_P (NODE) \
&& TYPE_NAME (NODE) \
+ && TREE_CODE (TYPE_NAME (NODE)) == TYPE_DECL \
&& TYPE_DECL_ALIAS_P (TYPE_NAME (NODE)))
/* For a class type: if this structure has many fields, we'll sort them
@@ -2607,17 +2608,24 @@ extern void decl_shadowed_for_var_insert (tree, tree);
(LANG_TYPE_CLASS_CHECK (BOUND_TEMPLATE_TEMPLATE_PARM_TYPE_CHECK (NODE)) \
->template_info)
-/* Template information for an ENUMERAL_, RECORD_, or UNION_TYPE. */
+/* Template information for an ENUMERAL_, RECORD_, UNION_TYPE, or
+ BOUND_TEMPLATE_TEMPLATE_PARM type. Note that if NODE is a
+ specialization of an alias template, this accessor returns the
+ template info for the alias template, not the one (if any) for the
+ template of the underlying type. */
#define TYPE_TEMPLATE_INFO(NODE) \
- (TREE_CODE (NODE) == ENUMERAL_TYPE \
- ? ENUM_TEMPLATE_INFO (NODE) : \
- (TREE_CODE (NODE) == BOUND_TEMPLATE_TEMPLATE_PARM \
- ? TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO (NODE) : \
- ((CLASS_TYPE_P (NODE) && !TYPE_ALIAS_P (NODE)) \
- ? CLASSTYPE_TEMPLATE_INFO (NODE) \
- : ((TYPE_NAME (NODE) && DECL_LANG_SPECIFIC (TYPE_NAME (NODE))) \
- ? (DECL_TEMPLATE_INFO (TYPE_NAME (NODE))) \
- : NULL_TREE))))
+ (TYPE_ALIAS_P (NODE) \
+ ? ((TYPE_NAME (NODE) && DECL_LANG_SPECIFIC (TYPE_NAME (NODE))) \
+ ? DECL_TEMPLATE_INFO (TYPE_NAME (NODE)) \
+ : NULL_TREE) \
+ : ((TREE_CODE (NODE) == ENUMERAL_TYPE) \
+ ? ENUM_TEMPLATE_INFO (NODE) \
+ : ((TREE_CODE (NODE) == BOUND_TEMPLATE_TEMPLATE_PARM) \
+ ? TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO (NODE) \
+ : (CLASS_TYPE_P (NODE) \
+ ? CLASSTYPE_TEMPLATE_INFO (NODE) \
+ : NULL_TREE))))
+
/* Set the template information for an ENUMERAL_, RECORD_, or
UNION_TYPE to VAL. */
@@ -5593,6 +5601,7 @@ extern void apply_lambda_return_type (tree, tree);
extern tree add_capture (tree, tree, tree, bool, bool);
extern tree add_default_capture (tree, tree, tree);
extern tree build_capture_proxy (tree);
+extern void insert_capture_proxy (tree);
extern void insert_pending_capture_proxies (void);
extern bool is_capture_proxy (tree);
extern bool is_normal_capture_proxy (tree);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 055c1b2020f..5a4e0270957 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -5078,6 +5078,14 @@ reshape_init_class (tree type, reshape_iter *d, bool first_initializer_p,
/* Handle designated initializers, as an extension. */
if (d->cur->index)
{
+ if (TREE_CODE (d->cur->index) == INTEGER_CST)
+ {
+ if (complain & tf_error)
+ error ("%<[%E] =%> used in a GNU-style designated initializer"
+ " for class %qT", d->cur->index, type);
+ return error_mark_node;
+ }
+
field = lookup_field_1 (type, d->cur->index, /*want_type=*/false);
if (!field || TREE_CODE (field) != FIELD_DECL)
@@ -9963,6 +9971,12 @@ grokdeclarator (const cp_declarator *declarator,
}
else if (decl_context == FIELD)
{
+ if (!staticp && type_uses_auto (type))
+ {
+ error ("non-static data member declared %<auto%>");
+ type = error_mark_node;
+ }
+
/* The C99 flexible array extension. */
if (!staticp && TREE_CODE (type) == ARRAY_TYPE
&& TYPE_DOMAIN (type) == NULL_TREE)
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index e1eb681de67..e93e82cac57 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -333,7 +333,8 @@ build_value_init (tree type, tsubst_flags_t complain)
constructor. */
/* The AGGR_INIT_EXPR tweaking below breaks in templates. */
- gcc_assert (!processing_template_decl || SCALAR_TYPE_P (type));
+ gcc_assert (!processing_template_decl
+ || (SCALAR_TYPE_P (type) || TREE_CODE (type) == ARRAY_TYPE));
if (CLASS_TYPE_P (type))
{
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index daf2ded45dc..2985d765a9f 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -3554,7 +3554,7 @@ lookup_literal_operator (tree name, VEC(tree,gc) *args)
{
tree decl, fns;
decl = lookup_name (name);
- if (!decl || decl == error_mark_node)
+ if (!decl || !is_overloaded_fn (decl))
return error_mark_node;
for (fns = decl; fns; fns = OVL_NEXT (fns))
@@ -17737,7 +17737,8 @@ cp_parser_initializer_list (cp_parser* parser, bool* non_constant_p)
designator = cp_parser_constant_expression (parser, false, NULL);
cp_parser_require (parser, CPP_CLOSE_SQUARE, RT_CLOSE_SQUARE);
cp_parser_require (parser, CPP_EQ, RT_EQ);
- cp_parser_parse_definitely (parser);
+ if (!cp_parser_parse_definitely (parser))
+ designator = NULL_TREE;
}
else
designator = NULL_TREE;
@@ -26304,7 +26305,7 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses)
/* If decl is an iterator, preserve the operator on decl
until finish_omp_for. */
if (decl
- && ((type_dependent_expression_p (decl)
+ && ((processing_template_decl
&& !POINTER_TYPE_P (TREE_TYPE (decl)))
|| CLASS_TYPE_P (TREE_TYPE (decl))))
incr = cp_parser_omp_for_incr (parser, decl);
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 7603c1151e5..bb5aa0c1484 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -2976,6 +2976,20 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data)
(struct find_parameter_pack_data*)data;
bool parameter_pack_p = false;
+ /* Handle type aliases/typedefs. */
+ if (TYPE_P (t)
+ && TYPE_NAME (t)
+ && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL
+ && TYPE_DECL_ALIAS_P (TYPE_NAME (t)))
+ {
+ if (TYPE_TEMPLATE_INFO (t))
+ cp_walk_tree (&TYPE_TI_ARGS (t),
+ &find_parameter_packs_r,
+ ppd, ppd->visited);
+ *walk_subtrees = 0;
+ return NULL_TREE;
+ }
+
/* Identify whether this is a parameter pack or not. */
switch (TREE_CODE (t))
{
@@ -4905,7 +4919,10 @@ push_template_decl_real (tree decl, bool is_friend)
if (check_for_bare_parameter_packs (TYPE_RAISES_EXCEPTIONS (type)))
TYPE_RAISES_EXCEPTIONS (type) = NULL_TREE;
}
- else if (check_for_bare_parameter_packs (TREE_TYPE (decl)))
+ else if (check_for_bare_parameter_packs ((TREE_CODE (decl) == TYPE_DECL
+ && TYPE_DECL_ALIAS_P (decl))
+ ? DECL_ORIGINAL_TYPE (decl)
+ : TREE_TYPE (decl)))
{
TREE_TYPE (decl) = error_mark_node;
return error_mark_node;
@@ -12810,6 +12827,11 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
&& ANON_AGGR_TYPE_P (TREE_TYPE (decl)))
/* Anonymous aggregates are a special case. */
finish_anon_union (decl);
+ else if (is_capture_proxy (DECL_EXPR_DECL (t)))
+ {
+ DECL_CONTEXT (decl) = current_function_decl;
+ insert_capture_proxy (decl);
+ }
else
{
int const_init = false;
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 9a1043a1a9b..2dab6a722a6 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -8804,7 +8804,7 @@ is_normal_capture_proxy (tree decl)
/* VAR is a capture proxy created by build_capture_proxy; add it to the
current function, which is the operator() for the appropriate lambda. */
-static inline void
+void
insert_capture_proxy (tree var)
{
cp_binding_level *b;
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 8d179d8d2a0..7899397cdd8 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -3479,17 +3479,6 @@ cp_free_lang_data (tree t)
DECL_EXTERNAL (t) = 1;
TREE_STATIC (t) = 0;
}
- if (CP_AGGREGATE_TYPE_P (t)
- && TYPE_NAME (t))
- {
- tree name = TYPE_NAME (t);
- if (TREE_CODE (name) == TYPE_DECL)
- name = DECL_NAME (name);
- /* Drop anonymous names. */
- if (name != NULL_TREE
- && ANON_AGGRNAME_P (name))
- TYPE_NAME (t) = NULL_TREE;
- }
if (TREE_CODE (t) == NAMESPACE_DECL)
{
/* The list of users of a namespace isn't useful for the middle-end
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 9a5365c612c..4973d7d72ce 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -5517,8 +5517,10 @@ build_x_conditional_expr (tree ifexp, tree op1, tree op2,
{
tree min = build_min_non_dep (COND_EXPR, expr,
orig_ifexp, orig_op1, orig_op2);
- /* Remember that the result is an lvalue or xvalue. */
- if (lvalue_or_rvalue_with_address_p (expr)
+ /* In C++11, remember that the result is an lvalue or xvalue.
+ In C++98, lvalue_kind can just assume lvalue in a template. */
+ if (cxx_dialect >= cxx0x
+ && lvalue_or_rvalue_with_address_p (expr)
&& !lvalue_or_rvalue_with_address_p (min))
TREE_TYPE (min) = cp_build_reference_type (TREE_TYPE (min),
!real_lvalue_p (expr));
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 2db3248d028..4648e756481 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -428,15 +428,20 @@ cxx_incomplete_type_diagnostic (const_tree value, const_tree type,
case OFFSET_TYPE:
bad_member:
- if (DECL_FUNCTION_MEMBER_P (TREE_OPERAND (value, 1))
- && ! flag_ms_extensions)
- emit_diagnostic (diag_kind, input_location, 0,
- "invalid use of member function "
- "(did you forget the %<()%> ?)");
- else
- emit_diagnostic (diag_kind, input_location, 0,
- "invalid use of member "
- "(did you forget the %<&%> ?)");
+ {
+ tree member = TREE_OPERAND (value, 1);
+ if (is_overloaded_fn (member))
+ member = get_first_fn (member);
+ if (DECL_FUNCTION_MEMBER_P (member)
+ && ! flag_ms_extensions)
+ emit_diagnostic (diag_kind, input_location, 0,
+ "invalid use of member function "
+ "(did you forget the %<()%> ?)");
+ else
+ emit_diagnostic (diag_kind, input_location, 0,
+ "invalid use of member "
+ "(did you forget the %<&%> ?)");
+ }
break;
case TEMPLATE_TYPE_PARM: