From 7e783eb31289e9c506e33c1f9286387c0ff08425 Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 2 Nov 2011 20:16:43 +0000 Subject: PR c++/50810 gcc/c-family * c-opts.c (c_common_handle_option): Enable -Wnarrowing as part of -Wall; include -Wnarrowing in -Wc++0x-compat; adjust default Wnarrowing for C++0x and C++98. * c.opt ([Wnarrowing]): Update. gcc/cp * typeck2.c (check_narrowing): Adjust OPT_Wnarrowing diagnostics. (digest_init_r): Call check_narrowing irrespective of the C++ dialect. * decl.c (check_initializer): Likewise. * semantics.c (finish_compound_literal): Likewise. gcc/ * configure.ac: Add -Wno-narrowing to warning options. libcpp/ * configure.ac: Add -Wno-narrowing to warning options. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180794 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index d76df5156b4..a80aec6c52d 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2369,7 +2369,7 @@ finish_compound_literal (tree type, tree compound_literal, && check_array_initializer (NULL_TREE, type, compound_literal)) return error_mark_node; compound_literal = reshape_init (type, compound_literal, complain); - if (cxx_dialect >= cxx0x && SCALAR_TYPE_P (type) + if (SCALAR_TYPE_P (type) && !BRACE_ENCLOSED_INITIALIZER_P (compound_literal)) check_narrowing (type, compound_literal); if (TREE_CODE (type) == ARRAY_TYPE -- cgit v1.2.1 From 7549df0d7fdace06856877633fbedddded3010e8 Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Fri, 4 Nov 2011 21:46:07 +0000 Subject: 2011-11-04 Eric Botcazou MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR c++/50608 * c-parser.c (c_parser_postfix_expression) : Adjust call to fold_offsetof. * c-typeck.c (build_unary_op) : Call fold_offsetof_1. c-family/ * c-common.c (c_fully_fold_internal) : Call fold_offsetof_1. (fold_offsetof_1): Make global.  Remove STOP_REF argument and adjust. : Return the argument. : Remove special code for negative offset. Call fold_build_pointer_plus instead of size_binop. (fold_offsetof): Remove STOP_REF argument and adjust. * c-common.h (fold_offsetof_1): Declare. (fold_offsetof): Remove STOP_REF argument. cp/ * semantics.c (finish_offsetof): Adjust call to fold_offsetof. * typeck.c (cp_build_addr_expr_1): Call fold_offsetof_1. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180986 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index a80aec6c52d..cebb7df2c3d 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3568,7 +3568,7 @@ finish_offsetof (tree expr) if (!complete_type_or_else (TREE_TYPE (object), object)) return error_mark_node; } - return fold_offsetof (expr, NULL_TREE); + return fold_offsetof (expr); } /* Replace the AGGR_INIT_EXPR at *TP with an equivalent CALL_EXPR. This -- cgit v1.2.1 From bfb588d6c0bc41c6c3fff588ff6f49ea33b82a78 Mon Sep 17 00:00:00 2001 From: paolo Date: Sun, 6 Nov 2011 21:05:44 +0000 Subject: 2011-11-06 Paolo Carlini PR c++/47695 * decl2.c (mark_used): Early return false after error or sorry. * cp-tree.h (mark_used): Adjust declaration. * semantics.c (finish_id_expression): Check mark_used return value. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@181042 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index cebb7df2c3d..c5ced8727dc 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3286,8 +3286,9 @@ finish_id_expression (tree id_expression, if (TREE_CODE (first_fn) == TEMPLATE_DECL) first_fn = DECL_TEMPLATE_RESULT (first_fn); - if (!really_overloaded_fn (decl)) - mark_used (first_fn); + if (!really_overloaded_fn (decl) + && !mark_used (first_fn)) + return error_mark_node; if (!template_arg_p && TREE_CODE (first_fn) == FUNCTION_DECL -- cgit v1.2.1 From 370478b178a3bdf01988c16782c90add8aea26aa Mon Sep 17 00:00:00 2001 From: dodji Date: Mon, 7 Nov 2011 21:28:50 +0000 Subject: PR c++/45114 - Support C++11 alias-declaration gcc/cp/ * cp-tree.h (TYPE_DECL_ALIAS_P, TYPE_ALIAS_P) (DECL_TYPE_TEMPLATE_P, DECL_ALIAS_TEMPLATE_P): New accessor macros. (TYPE_TEMPLATE_INFO): Get template info of an alias template specializations from its TYPE_DECL. (SET_TYPE_TEMPLATE_INFO): Set template info of alias template specializations into its TYPE_DECL. (DECL_CLASS_TEMPLATE_P): Re-write using the new DECL_TYPE_TEMPLATE_P. (enum cp_decl_spec): Add new ds_alias enumerator. (alias_type_or_template_p, alias_template_specialization_p): Declare new functions. * parser.c (cp_parser_alias_declaration): New static function. (cp_parser_check_decl_spec): Add "using" name for the `alias' declspec. (cp_parser_type_name): Update comment. Support simple-template-id representing alias template specializations in c++0x mode. (cp_parser_qualifying_entity): Update comment. Use cp_parser_type_name. (cp_parser_block_declaration): Handle alias-declaration in c++11. Update comment. (cp_parser_template_id): Handle specializations of alias templates. (cp_parser_member_declaration): Add alias-declaration production to comment. Support alias-declarations. (cp_parser_template_declaration_after_export): Handle alias templates in c++11. * decl.c (make_typename_type, make_unbound_class_template): Accept alias templates. (grokdeclarator): Set TYPE_DECL_ALIAS_P on alias declarations. * decl2.c (grokfield): Move template creation after setting up the TYPE_DECL of the alias, so that the TEMPLATE_DECL of the alias template actually carries the right type-id of the alias declaration. * pt.c (alias_type_or_template_p) (alias_template_specialization_p): Define new public functions. (maybe_process_partial_specialization): Reject partial specializations of alias templates. (primary_template_instantiation_p): Consider alias template instantiations. (push_template_decl_real): Assert that TYPE_DECLs of alias templates are different from those of class template. Store template info onto the TYPE_DECL of the alias template. (convert_template_argument): Strip aliases from template arguments. (lookup_template_class_1): Handle the creation of the specialization of an alias template. (tsubst_decl): Create a substituted copy of the TYPE_DECL of an member alias template. (tsubst): Handle substituting into the type of an alias template. Handle substituting UNBOUND_CLASS_TEMPLATE into BOUND_TEMPLATE_TEMPLATE_PARM. (do_type_instantiation): Better diagnostics when trying to explicitely instantiate a non-class template. * search.c (lookup_field_1, lookup_field_r): Support looking up alias templates. * semantics.c (finish_template_type): For instantiations of alias templates, return the TYPE_DECL of the actual alias and not the one of the aliased type. * error.c (dump_alias_template_specialization): New static function. (dump_type): Handle printing of alias templates and their specializations. templates. (dump_aggr_type): For specialization of alias templates, fetch arguments from the right place. (dump_decl): Print an alias-declaration like `using decl = type;' (dump_template_decl): Support printing of alias templates. gcc/testsuite/ * g++.dg/cpp0x/alias-decl-0.C: New test case. * g++.dg/cpp0x/alias-decl-1.C: Likewise. * g++.dg/cpp0x/alias-decl-3.C: Likewise. * g++.dg/cpp0x/alias-decl-4.C: Likewise. * g++.dg/cpp0x/alias-decl-6.C: Likewise. * g++.dg/cpp0x/alias-decl-7.C: Likewise. * g++.dg/cpp0x/alias-decl-8.C: Likewise. * g++.dg/cpp0x/alias-decl-9.C: Likewise. * g++.dg/cpp0x/alias-decl-10.C: Likewise. * g++.dg/ext/alias-decl-attr1.C: Likewise. * g++.dg/ext/alias-decl-attr2.C: Likewise. * g++.dg/ext/alias-decl-attr3.C: Likewise. * g++.dg/ext/alias-decl-attr4.C: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@181118 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index c5ced8727dc..9d6bd316aa1 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2733,15 +2733,17 @@ finish_template_decl (tree parms) tree finish_template_type (tree name, tree args, int entering_scope) { - tree decl; + tree type; - decl = lookup_template_class (name, args, + type = lookup_template_class (name, args, NULL_TREE, NULL_TREE, entering_scope, tf_warning_or_error | tf_user); - if (decl != error_mark_node) - decl = TYPE_STUB_DECL (decl); - - return decl; + if (type == error_mark_node) + return type; + else if (CLASS_TYPE_P (type) && !alias_type_or_template_p (type)) + return TYPE_STUB_DECL (type); + else + return TYPE_NAME (type); } /* Finish processing a BASE_CLASS with the indicated ACCESS_SPECIFIER. -- cgit v1.2.1