summaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2012-05-02 07:54:07 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2012-05-02 07:54:07 +0000
commit8ab7ada7e20e6dfd07336b6304216ab5aa58a76a (patch)
treeaebc63f729cc9472233ec6e6441f5019915f64ac /gcc/cp
parent666ebe7fced2506b14b95511c8b2630d85aebe2c (diff)
downloadgcc-8ab7ada7e20e6dfd07336b6304216ab5aa58a76a.tar.gz
2012-05-02 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 187035 using svnmerge git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@187037 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog43
-rw-r--r--gcc/cp/call.c15
-rw-r--r--gcc/cp/class.c6
-rw-r--r--gcc/cp/cp-tree.h2
-rw-r--r--gcc/cp/cvt.c9
-rw-r--r--gcc/cp/decl.c3
-rw-r--r--gcc/cp/decl2.c13
-rw-r--r--gcc/cp/method.c3
-rw-r--r--gcc/cp/optimize.c9
-rw-r--r--gcc/cp/parser.c9
-rw-r--r--gcc/cp/pt.c6
-rw-r--r--gcc/cp/semantics.c5
-rw-r--r--gcc/cp/typeck.c25
13 files changed, 104 insertions, 44 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 86e44fc0fc6..e52149f023d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,46 @@
+2012-04-30 Marc Glisse <marc.glisse@inria.fr>
+
+ PR c++/51033
+ * typeck.c (cp_build_array_ref): Handle VECTOR_TYPE.
+ * decl2.c (grok_array_decl): Likewise.
+
+ PR c++/51314
+ * parser.c (cp_parser_sizeof_operand): Require parentheses for
+ sizeof...
+
+2012-04-30 Dodji Seketeli <dodji@redhat.com>
+
+ Fix location for static class members
+ * decl.c (grokdeclarator): Use the location carried by the
+ declarator for the DECL of the static class member.
+
+ Fix va_arg type location
+ * cp-tree.h (build_x_va_arg): Take an additional location
+ parameter.
+ * call.c (build_x_va_arg): Take a loc parameter for the location
+ of the type of the va_arg expression.
+ * parser.c (cp_parser_primary_expression): Pass the type of the
+ type in the va_arg expression to build_x_va_arg.
+ * pt.c (tsubst_copy): Adjust calls to build_x_va_arg.
+
+ Make conversion warnings work on NULL with -ftrack-macro-expansion
+ * call.c (conversion_null_warnings): Use the new
+ expansion_point_location_if_in_system_header.
+ * cvt.c (build_expr_type_conversion): Likewise.
+ * typeck.c (cp_build_binary_op): Likewise.
+
+2012-04-30 Manuel López-Ibáñez <manu@gcc.gnu.org>
+
+ * typeck.c (convert_for_assignment): Replace
+ Wmissing-format-attribute with Wsuggest-attribute=format.
+ * call.c (convert_for_arg_passing): Likewise.
+
+2012-04-26 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/53096
+ * class.c (check_bases_and_members): Implement core/1333, do not
+ disallow defaulted in the class body non-const ref special members.
+
2012-04-24 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/52363
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index f9a7f08b8d3..e072891f927 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -5598,12 +5598,15 @@ conversion_null_warnings (tree totype, tree expr, tree fn, int argnum)
if (expr == null_node && TREE_CODE (totype) != BOOLEAN_TYPE
&& ARITHMETIC_TYPE_P (totype))
{
+ source_location loc =
+ expansion_point_location_if_in_system_header (input_location);
+
if (fn)
- warning_at (input_location, OPT_Wconversion_null,
+ warning_at (loc, OPT_Wconversion_null,
"passing NULL to non-pointer argument %P of %qD",
argnum, fn);
else
- warning_at (input_location, OPT_Wconversion_null,
+ warning_at (loc, OPT_Wconversion_null,
"converting to non-pointer type %qT from NULL", totype);
}
@@ -6130,7 +6133,7 @@ convert_arg_to_ellipsis (tree arg, tsubst_flags_t complain)
/* va_arg (EXPR, TYPE) is a builtin. Make sure it is not abused. */
tree
-build_x_va_arg (tree expr, tree type)
+build_x_va_arg (source_location loc, tree expr, tree type)
{
if (processing_template_decl)
return build_min (VA_ARG_EXPR, type, expr);
@@ -6156,7 +6159,7 @@ build_x_va_arg (tree expr, tree type)
return expr;
}
- return build_va_arg (input_location, expr, type);
+ return build_va_arg (loc, expr, type);
}
/* TYPE has been given to va_arg. Apply the default conversions which
@@ -6321,7 +6324,7 @@ convert_for_arg_passing (tree type, tree val, tsubst_flags_t complain)
TYPE_SIZE (integer_type_node)))
val = perform_integral_promotions (val);
if ((complain & tf_warning)
- && warn_missing_format_attribute)
+ && warn_suggest_attribute_format)
{
tree rhstype = TREE_TYPE (val);
const enum tree_code coder = TREE_CODE (rhstype);
@@ -6329,7 +6332,7 @@ convert_for_arg_passing (tree type, tree val, tsubst_flags_t complain)
if ((codel == POINTER_TYPE || codel == REFERENCE_TYPE)
&& coder == codel
&& check_missing_format_attribute (type, rhstype))
- warning (OPT_Wmissing_format_attribute,
+ warning (OPT_Wsuggest_attribute_format,
"argument of function call might be a candidate for a format attribute");
}
return val;
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 7b6559c4231..00aeefd5d48 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -1,6 +1,7 @@
/* Functions related to building classes and their related objects.
Copyright (C) 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011,
+ 2012
Free Software Foundation, Inc.
Contributed by Michael Tiemann (tiemann@cygnus.com)
@@ -5144,9 +5145,6 @@ check_bases_and_members (tree t)
give the synthesis error. */
error ("%q+D declared to take const reference, but implicit "
"declaration would take non-const", fn);
- else if (imp_const_p && !fn_const_p)
- error ("%q+D declared to take non-const reference cannot be "
- "defaulted in the class body", fn);
}
defaulted_late_check (fn);
}
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index e046069182c..5a7ebaed993 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -4891,7 +4891,7 @@ extern void pop_defarg_context (void);
extern tree convert_default_arg (tree, tree, tree, int,
tsubst_flags_t);
extern tree convert_arg_to_ellipsis (tree, tsubst_flags_t);
-extern tree build_x_va_arg (tree, tree);
+extern tree build_x_va_arg (source_location, tree, tree);
extern tree cxx_type_promotes_to (tree);
extern tree type_passed_as (tree);
extern tree convert_for_arg_passing (tree, tree, tsubst_flags_t);
diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c
index 3dab372a301..49ba38a3f39 100644
--- a/gcc/cp/cvt.c
+++ b/gcc/cp/cvt.c
@@ -1472,8 +1472,13 @@ build_expr_type_conversion (int desires, tree expr, bool complain)
if (expr == null_node
&& (desires & WANT_INT)
&& !(desires & WANT_NULL))
- warning_at (input_location, OPT_Wconversion_null,
- "converting NULL to non-pointer type");
+ {
+ source_location loc =
+ expansion_point_location_if_in_system_header (input_location);
+
+ warning_at (loc, OPT_Wconversion_null,
+ "converting NULL to non-pointer type");
+ }
basetype = TREE_TYPE (expr);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 28c7cee4d90..40818a3f3ff 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -10267,7 +10267,8 @@ grokdeclarator (const cp_declarator *declarator,
{
/* C++ allows static class members. All other work
for this is done by grokfield. */
- decl = build_lang_decl (VAR_DECL, unqualified_id, type);
+ decl = build_lang_decl_loc (declarator->id_loc,
+ VAR_DECL, unqualified_id, type);
set_linkage_for_static_data_member (decl);
/* Even if there is an in-class initialization, DECL
is considered undefined until an out-of-class
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 34c969c31fc..5d1f8de4ed9 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -373,7 +373,7 @@ grok_array_decl (tree array_expr, tree index_exp)
It is a little-known fact that, if `a' is an array and `i' is
an int, you can write `i[a]', which means the same thing as
`a[i]'. */
- if (TREE_CODE (type) == ARRAY_TYPE)
+ if (TREE_CODE (type) == ARRAY_TYPE || TREE_CODE (type) == VECTOR_TYPE)
p1 = array_expr;
else
p1 = build_expr_type_conversion (WANT_POINTER, array_expr, false);
@@ -1830,7 +1830,7 @@ maybe_emit_vtables (tree ctype)
tree vtbl;
tree primary_vtbl;
int needed = 0;
- struct varpool_node *current = NULL, *last = NULL, *first = NULL;
+ struct varpool_node *current = NULL, *last = NULL;
/* If the vtables for this class have already been emitted there is
nothing more to do. */
@@ -1894,16 +1894,11 @@ maybe_emit_vtables (tree ctype)
{
current = varpool_node (vtbl);
if (last)
- last->symbol.same_comdat_group = (symtab_node) current;
+ symtab_add_to_same_comdat_group ((symtab_node) current, (symtab_node) last);
last = current;
- if (!first)
- first = current;
}
}
- if (first != last)
- last->symbol.same_comdat_group = (symtab_node)first;
-
/* Since we're writing out the vtable here, also write the debug
info. */
note_debug_info_needed (ctype);
@@ -4027,7 +4022,7 @@ cp_write_global_declarations (void)
timevar_stop (TV_PHASE_DEFERRED);
timevar_start (TV_PHASE_CGRAPH);
- cgraph_finalize_compilation_unit ();
+ finalize_compilation_unit ();
timevar_stop (TV_PHASE_CGRAPH);
timevar_start (TV_PHASE_CHECK_DBGINFO);
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index cea44d491d3..77f8839828a 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -389,7 +389,8 @@ use_thunk (tree thunk_fndecl, bool emit_p)
this_adjusting, fixed_offset, virtual_value,
virtual_offset, alias);
if (DECL_ONE_ONLY (function))
- cgraph_add_to_same_comdat_group (thunk_node, funcn);
+ symtab_add_to_same_comdat_group ((symtab_node) thunk_node,
+ (symtab_node) funcn);
if (!this_adjusting
|| !targetm.asm_out.can_output_mi_thunk (thunk_fndecl, fixed_offset,
diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c
index 6a069880398..5698c975a48 100644
--- a/gcc/cp/optimize.c
+++ b/gcc/cp/optimize.c
@@ -324,8 +324,8 @@ maybe_clone_body (tree fn)
*[CD][12]*. */
comdat_group = cdtor_comdat_group (fns[1], fns[0]);
DECL_COMDAT_GROUP (fns[0]) = comdat_group;
- cgraph_add_to_same_comdat_group (cgraph_get_node (clone),
- cgraph_get_node (fns[0]));
+ symtab_add_to_same_comdat_group (symtab_get_node (clone),
+ symtab_get_node (fns[0]));
}
}
@@ -337,8 +337,9 @@ maybe_clone_body (tree fn)
/* If *[CD][12]* dtors go into the *[CD]5* comdat group and dtor is
virtual, it goes into the same comdat group as well. */
if (comdat_group)
- cgraph_add_to_same_comdat_group (cgraph_get_create_node (clone),
- cgraph_get_node (fns[0]));
+ symtab_add_to_same_comdat_group
+ ((symtab_node) cgraph_get_create_node (clone),
+ symtab_get_node (fns[0]));
}
else if (alias)
/* No need to populate body. */ ;
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 3b5a476cdd0..0c423536dd7 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -4168,6 +4168,7 @@ cp_parser_primary_expression (cp_parser *parser,
{
tree expression;
tree type;
+ source_location type_location;
/* The `__builtin_va_arg' construct is used to handle
`va_arg'. Consume the `__builtin_va_arg' token. */
@@ -4179,6 +4180,7 @@ cp_parser_primary_expression (cp_parser *parser,
/*cast_p=*/false, NULL);
/* Look for the `,'. */
cp_parser_require (parser, CPP_COMMA, RT_COMMA);
+ type_location = cp_lexer_peek_token (parser->lexer)->location;
/* Parse the type-id. */
type = cp_parser_type_id (parser);
/* Look for the closing `)'. */
@@ -4188,7 +4190,7 @@ cp_parser_primary_expression (cp_parser *parser,
if (cp_parser_non_integral_constant_expression (parser,
NIC_VA_ARG))
return error_mark_node;
- return build_x_va_arg (expression, type);
+ return build_x_va_arg (type_location, expression, type);
}
case RID_OFFSETOF:
@@ -15375,7 +15377,7 @@ cp_parser_asm_definition (cp_parser* parser)
}
}
else
- cgraph_add_asm_node (string);
+ add_asm_node (string);
}
}
@@ -21967,6 +21969,9 @@ cp_parser_sizeof_operand (cp_parser* parser, enum rid keyword)
/*attrlist=*/NULL);
}
}
+ else if (pack_expansion_p)
+ permerror (cp_lexer_peek_token (parser->lexer)->location,
+ "%<sizeof...%> argument must be surrounded by parentheses");
/* If the type-id production did not work out, then we must be
looking at the unary-expression production. */
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 409e6b9cd52..b720d4a3161 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -12480,7 +12480,8 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
gcc_unreachable ();
case VA_ARG_EXPR:
- return build_x_va_arg (tsubst_copy (TREE_OPERAND (t, 0), args, complain,
+ return build_x_va_arg (EXPR_LOCATION (t),
+ tsubst_copy (TREE_OPERAND (t, 0), args, complain,
in_decl),
tsubst (TREE_TYPE (t), args, complain, in_decl));
@@ -14313,7 +14314,8 @@ tsubst_copy_and_build (tree t,
}
case VA_ARG_EXPR:
- return build_x_va_arg (RECUR (TREE_OPERAND (t, 0)),
+ return build_x_va_arg (EXPR_LOCATION (t),
+ RECUR (TREE_OPERAND (t, 0)),
tsubst (TREE_TYPE (t), args, complain, in_decl));
case OFFSETOF_EXPR:
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index a621f25a4f4..90378dc4122 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -9330,8 +9330,9 @@ maybe_add_lambda_conv_op (tree type)
if (DECL_ONE_ONLY (statfn))
{
/* Put the thunk in the same comdat group as the call op. */
- cgraph_add_to_same_comdat_group (cgraph_get_create_node (statfn),
- cgraph_get_create_node (callop));
+ symtab_add_to_same_comdat_group
+ ((symtab_node) cgraph_get_create_node (statfn),
+ (symtab_node) cgraph_get_create_node (callop));
}
body = begin_function_body ();
compound_stmt = begin_compound_stmt (0);
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index fb2f1bc6bbb..b59741c6471 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -2915,6 +2915,8 @@ cp_build_array_ref (location_t loc, tree array, tree idx,
break;
}
+ convert_vector_to_pointer_for_subscript (loc, &array, idx);
+
if (TREE_CODE (TREE_TYPE (array)) == ARRAY_TYPE)
{
tree rval, type;
@@ -3838,9 +3840,12 @@ cp_build_binary_op (location_t location,
|| (!null_ptr_cst_p (orig_op1)
&& !TYPE_PTR_P (type1) && !TYPE_PTR_TO_MEMBER_P (type1)))
&& (complain & tf_warning))
- /* Some sort of arithmetic operation involving NULL was
- performed. */
- warning (OPT_Wpointer_arith, "NULL used in arithmetic");
+ {
+ source_location loc =
+ expansion_point_location_if_in_system_header (input_location);
+
+ warning_at (loc, OPT_Wpointer_arith, "NULL used in arithmetic");
+ }
switch (code)
{
@@ -7624,7 +7629,7 @@ convert_for_assignment (tree type, tree rhs,
return error_mark_node;
}
}
- if (warn_missing_format_attribute)
+ if (warn_suggest_attribute_format)
{
const enum tree_code codel = TREE_CODE (type);
if ((codel == POINTER_TYPE || codel == REFERENCE_TYPE)
@@ -7636,31 +7641,31 @@ convert_for_assignment (tree type, tree rhs,
case ICR_ARGPASS:
case ICR_DEFAULT_ARGUMENT:
if (fndecl)
- warning (OPT_Wmissing_format_attribute,
+ warning (OPT_Wsuggest_attribute_format,
"parameter %qP of %qD might be a candidate "
"for a format attribute", parmnum, fndecl);
else
- warning (OPT_Wmissing_format_attribute,
+ warning (OPT_Wsuggest_attribute_format,
"parameter might be a candidate "
"for a format attribute");
break;
case ICR_CONVERTING:
- warning (OPT_Wmissing_format_attribute,
+ warning (OPT_Wsuggest_attribute_format,
"target of conversion might be a candidate "
"for a format attribute");
break;
case ICR_INIT:
- warning (OPT_Wmissing_format_attribute,
+ warning (OPT_Wsuggest_attribute_format,
"target of initialization might be a candidate "
"for a format attribute");
break;
case ICR_RETURN:
- warning (OPT_Wmissing_format_attribute,
+ warning (OPT_Wsuggest_attribute_format,
"return type might be a candidate "
"for a format attribute");
break;
case ICR_ASSIGN:
- warning (OPT_Wmissing_format_attribute,
+ warning (OPT_Wsuggest_attribute_format,
"left-hand side of assignment might be a candidate "
"for a format attribute");
break;