From 37ec60ed2c973aa38044e19e3d16b5fa1e5c0a6b Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Sat, 21 Jun 2008 10:36:27 +0000 Subject: [PATCH] typeck.c (composite_pointer_type_r, [...]): Change pedwarn to permerror. * typeck.c (composite_pointer_type_r, cxx_sizeof_expr, cxx_alignof_expr, check_template_keyword, cp_build_binary_op, pointer_diff, cp_build_unary_op, build_x_compound_expr_from_list, build_reinterpret_cast_1, cp_build_c_cast, check_return_expr): Change pedwarn to permerror. * init.c (perform_member_init, build_new_1, build_new): Likewise. * decl.c (warn_extern_redeclared_static, duplicate_decls, * identify_goto, check_previous_goto_1, check_goto, define_label, check_tag_decl, start_decl, check_class_member_definition_namespace, grokfndecl, grokdeclarator): Likewise. * except.c (check_handlers): Likewise. * typeck2.c (digest_init): Likewise. * pt.c (check_specialization_namespace, check_explicit_instantiation_namespace, maybe_process_partial_specialization, check_explicit_specialization, convert_template_argument, do_decl_instantiation, do_type_instantiation, instantiate_decl): Likewise. * semantics.c (finish_template_type_parm): Likewise. * name-lookup.c (pushdecl_maybe_friend, check_for_out_of_scope_variable): Likewise. * decl2.c (finish_static_data_member_decl, build_anon_union_vars, coerce_new_type): Likewise. * parser.c (cp_parser_nested_name_specifier_opt, cp_parser_mem_initializer, cp_parser_elaborated_type_specifier, cp_parser_class_head, cp_parser_check_class_key): Likewise. (cp_parser_parameter_declaration): Check flag_permissive instead of flag_pedantic_errors. * call.c (joust): Change pedwarn to warning. * friend.c (make_friend_class): Likewise. From-SVN: r136999 --- gcc/cp/ChangeLog | 32 +++++++++++++ gcc/cp/call.c | 8 ++-- gcc/cp/decl.c | 110 ++++++++++++++++++++++--------------------- gcc/cp/decl2.c | 16 +++---- gcc/cp/except.c | 4 +- gcc/cp/friend.c | 2 +- gcc/cp/init.c | 12 ++--- gcc/cp/name-lookup.c | 22 ++++++--- gcc/cp/parser.c | 20 ++++---- gcc/cp/pt.c | 30 ++++++------ gcc/cp/semantics.c | 2 +- gcc/cp/typeck.c | 98 +++++++++++++++++++------------------- gcc/cp/typeck2.c | 2 +- 13 files changed, 201 insertions(+), 157 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 636ee6aa9d6..78f1d87a447 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,35 @@ +2008-06-21 Jonathan Wakely + + * typeck.c (composite_pointer_type_r, cxx_sizeof_expr, + cxx_alignof_expr, check_template_keyword, cp_build_binary_op, + pointer_diff, cp_build_unary_op, build_x_compound_expr_from_list, + build_reinterpret_cast_1, cp_build_c_cast, check_return_expr): Change + pedwarn to permerror. + * init.c (perform_member_init, build_new_1, build_new): Likewise. + * decl.c (warn_extern_redeclared_static, duplicate_decls, + * identify_goto, check_previous_goto_1, check_goto, define_label, + check_tag_decl, start_decl, check_class_member_definition_namespace, + grokfndecl, grokdeclarator): Likewise. + * except.c (check_handlers): Likewise. + * typeck2.c (digest_init): Likewise. + * pt.c (check_specialization_namespace, + check_explicit_instantiation_namespace, + maybe_process_partial_specialization, check_explicit_specialization, + convert_template_argument, do_decl_instantiation, + do_type_instantiation, instantiate_decl): Likewise. + * semantics.c (finish_template_type_parm): Likewise. + * name-lookup.c (pushdecl_maybe_friend, + check_for_out_of_scope_variable): Likewise. + * decl2.c (finish_static_data_member_decl, build_anon_union_vars, + coerce_new_type): Likewise. + * parser.c (cp_parser_nested_name_specifier_opt, + cp_parser_mem_initializer, cp_parser_elaborated_type_specifier, + cp_parser_class_head, cp_parser_check_class_key): Likewise. + (cp_parser_parameter_declaration): Check flag_permissive instead of + flag_pedantic_errors. + * call.c (joust): Change pedwarn to warning. + * friend.c (make_friend_class): Likewise. + 2008-06-16 Jan Hubicka * method.c: Include cgraph.h. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 1d54e7cb43e..7f4c0168483 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -6563,10 +6563,10 @@ tweak: { if (warn) { - pedwarn ("\ -ISO C++ says that these are ambiguous, even \ -though the worst conversion for the first is better than \ -the worst conversion for the second:"); + warning (0, + "ISO C++ says that these are ambiguous, even " + "though the worst conversion for the first is better than " + "the worst conversion for the second:"); print_z_candidate (_("candidate 1:"), w); print_z_candidate (_("candidate 2:"), l); } diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index f97039bfa2f..8b4e2e9d410 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1055,8 +1055,8 @@ warn_extern_redeclared_static (tree newdecl, tree olddecl) return; name = DECL_ASSEMBLER_NAME (newdecl); - pedwarn ("%qD was declared % and later %", newdecl); - pedwarn ("previous declaration of %q+D", olddecl); + permerror ("%qD was declared % and later %", newdecl); + permerror ("previous declaration of %q+D", olddecl); } /* NEW_DECL is a redeclaration of OLD_DECL; both are functions or @@ -1539,9 +1539,9 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) if (1 == simple_cst_equal (TREE_PURPOSE (t1), TREE_PURPOSE (t2))) { - pedwarn ("default argument given for parameter %d of %q#D", - i, newdecl); - pedwarn ("after previous specification in %q+#D", olddecl); + permerror ("default argument given for parameter %d of %q#D", + i, newdecl); + permerror ("after previous specification in %q+#D", olddecl); } else { @@ -2458,11 +2458,11 @@ static void identify_goto (tree decl, const location_t *locus) { if (decl) - pedwarn ("jump to label %qD", decl); + permerror ("jump to label %qD", decl); else - pedwarn ("jump to case label"); + permerror ("jump to case label"); if (locus) - pedwarn ("%H from here", locus); + permerror ("%H from here", locus); } /* Check that a single previously seen jump to a newly defined label @@ -2504,7 +2504,7 @@ check_previous_goto_1 (tree decl, struct cp_binding_level* level, tree names, if (problem > 1) error (" crosses initialization of %q+#D", new_decls); else - pedwarn (" enters scope of non-POD %q+#D", new_decls); + permerror (" enters scope of non-POD %q+#D", new_decls); } if (b == level) @@ -2600,8 +2600,8 @@ check_goto (tree decl) if (ent->in_try_scope || ent->in_catch_scope || ent->in_omp_scope || ent->bad_decls) { - pedwarn ("jump to label %q+D", decl); - pedwarn (" from here"); + permerror ("jump to label %q+D", decl); + permerror (" from here"); identified = true; } @@ -2619,7 +2619,7 @@ check_goto (tree decl) else if (u > 1) error (" skips initialization of %q+#D", b); else - pedwarn (" enters scope of non-POD %q+#D", b); + permerror (" enters scope of non-POD %q+#D", b); } if (ent->in_try_scope) @@ -2640,8 +2640,8 @@ check_goto (tree decl) { if (!identified) { - pedwarn ("jump to label %q+D", decl); - pedwarn (" from here"); + permerror ("jump to label %q+D", decl); + permerror (" from here"); identified = true; } error (" exits OpenMP structured block"); @@ -2693,7 +2693,7 @@ define_label (location_t location, tree name) p->more_cleanups_ok = 0; if (name == get_identifier ("wchar_t")) - pedwarn ("label named wchar_t"); + permerror ("label named wchar_t"); if (DECL_INITIAL (decl) != NULL_TREE) { @@ -3767,8 +3767,8 @@ check_tag_decl (cp_decl_specifier_seq *declspecs) else if (declspecs->redefined_builtin_type) { if (!in_system_header) - pedwarn ("redeclaration of C++ built-in type %qT", - declspecs->redefined_builtin_type); + permerror ("redeclaration of C++ built-in type %qT", + declspecs->redefined_builtin_type); return NULL_TREE; } @@ -3781,7 +3781,7 @@ check_tag_decl (cp_decl_specifier_seq *declspecs) else if (declspecs->type == error_mark_node) error_p = true; if (declared_type == NULL_TREE && ! saw_friend && !error_p) - pedwarn ("declaration does not declare anything"); + permerror ("declaration does not declare anything"); /* Check for an anonymous union. */ else if (declared_type && RECORD_OR_UNION_CODE_P (TREE_CODE (declared_type)) && TYPE_ANONYMOUS_P (declared_type)) @@ -4054,10 +4054,10 @@ start_decl (const cp_declarator *declarator, if (DECL_CONTEXT (field) != context) { if (!same_type_p (DECL_CONTEXT (field), context)) - pedwarn ("ISO C++ does not permit %<%T::%D%> " - "to be defined as %<%T::%D%>", - DECL_CONTEXT (field), DECL_NAME (decl), - context, DECL_NAME (decl)); + permerror ("ISO C++ does not permit %<%T::%D%> " + "to be defined as %<%T::%D%>", + DECL_CONTEXT (field), DECL_NAME (decl), + context, DECL_NAME (decl)); DECL_CONTEXT (decl) = DECL_CONTEXT (field); } if (processing_specialization @@ -4110,8 +4110,8 @@ start_decl (const cp_declarator *declarator, } if (DECL_EXTERNAL (decl) && ! DECL_TEMPLATE_SPECIALIZATION (decl)) - pedwarn ("declaration of %q#D outside of class is not definition", - decl); + permerror ("declaration of %q#D outside of class is not definition", + decl); } was_public = TREE_PUBLIC (decl); @@ -6319,8 +6319,8 @@ check_class_member_definition_namespace (tree decl) The definition for a static data member shall appear in a namespace scope enclosing the member's class definition. */ if (!is_ancestor (current_namespace, DECL_CONTEXT (decl))) - pedwarn ("definition of %qD is not in namespace enclosing %qT", - decl, DECL_CONTEXT (decl)); + permerror ("definition of %qD is not in namespace enclosing %qT", + decl, DECL_CONTEXT (decl)); } /* Build a PARM_DECL for the "this" parameter. TYPE is the @@ -6553,16 +6553,16 @@ grokfndecl (tree ctype, /* Allow this; it's pretty common in C. */; else { - pedwarn ("non-local function %q#D uses anonymous type", + permerror ("non-local function %q#D uses anonymous type", decl); if (DECL_ORIGINAL_TYPE (TYPE_NAME (t))) - pedwarn ("%q+#D does not refer to the unqualified " - "type, so it is not used for linkage", - TYPE_NAME (t)); + permerror ("%q+#D does not refer to the unqualified " + "type, so it is not used for linkage", + TYPE_NAME (t)); } } else - pedwarn ("non-local function %q#D uses local type %qT", decl, t); + permerror ("non-local function %q#D uses local type %qT", decl, t); } } @@ -7706,7 +7706,9 @@ grokdeclarator (const cp_declarator *declarator, /* We've already issued an error, don't complain more. */; else if (in_system_header || flag_ms_extensions) /* Allow it, sigh. */; - else if (pedantic || ! is_main) + else if (! is_main) + permerror ("ISO C++ forbids declaration of %qs with no type", name); + else if (pedantic) pedwarn ("ISO C++ forbids declaration of %qs with no type", name); else warning (OPT_Wreturn_type, @@ -8157,7 +8159,7 @@ grokdeclarator (const cp_declarator *declarator, explicitp = 2; if (virtualp) { - pedwarn ("constructors cannot be declared virtual"); + permerror ("constructors cannot be declared virtual"); virtualp = 0; } if (decl_context == FIELD @@ -8380,12 +8382,12 @@ grokdeclarator (const cp_declarator *declarator, { if (friendp) { - pedwarn ("member functions are implicitly friends of their class"); + permerror ("member functions are implicitly friends of their class"); friendp = 0; } else - pedwarn ("extra qualification %<%T::%> on member %qs", - ctype, name); + permerror ("extra qualification %<%T::%> on member %qs", + ctype, name); } else if (/* If the qualifying type is already complete, then we can skip the following checks. */ @@ -8569,9 +8571,9 @@ grokdeclarator (const cp_declarator *declarator, DECL_ABSTRACT (decl) = 1; } else if (constructor_name_p (unqualified_id, current_class_type)) - pedwarn ("ISO C++ forbids nested type %qD with same name " - "as enclosing class", - unqualified_id); + permerror ("ISO C++ forbids nested type %qD with same name " + "as enclosing class", + unqualified_id); /* If the user declares "typedef struct {...} foo" then the struct will have an anonymous name. Fill that name in now. @@ -8694,15 +8696,15 @@ grokdeclarator (const cp_declarator *declarator, { /* Don't allow friend declaration without a class-key. */ if (TREE_CODE (type) == TEMPLATE_TYPE_PARM) - pedwarn ("template parameters cannot be friends"); + permerror ("template parameters cannot be friends"); else if (TREE_CODE (type) == TYPENAME_TYPE) - pedwarn ("friend declaration requires class-key, " - "i.e. %", - TYPE_CONTEXT (type), TYPENAME_TYPE_FULLNAME (type)); + permerror ("friend declaration requires class-key, " + "i.e. %", + TYPE_CONTEXT (type), TYPENAME_TYPE_FULLNAME (type)); else - pedwarn ("friend declaration requires class-key, " - "i.e. %", - type); + permerror ("friend declaration requires class-key, " + "i.e. %", + type); } /* Only try to do this stuff if we didn't already give up. */ @@ -8987,7 +8989,7 @@ grokdeclarator (const cp_declarator *declarator, { /* Friends are treated specially. */ if (ctype == current_class_type) - ; /* We already issued a pedwarn. */ + ; /* We already issued a permerror. */ else if (decl && DECL_NAME (decl)) { if (template_class_depth (current_class_type) == 0) @@ -9028,9 +9030,9 @@ grokdeclarator (const cp_declarator *declarator, the rest of the compiler does not correctly handle the initialization unless the member is static so we make it static below. */ - pedwarn ("ISO C++ forbids initialization of member %qD", - unqualified_id); - pedwarn ("making %qD static", unqualified_id); + permerror ("ISO C++ forbids initialization of member %qD", + unqualified_id); + permerror ("making %qD static", unqualified_id); staticp = 1; } @@ -9152,8 +9154,8 @@ grokdeclarator (const cp_declarator *declarator, declaring main to be static. */ if (TREE_CODE (type) == METHOD_TYPE) { - pedwarn ("cannot declare member function %qD to have " - "static linkage", decl); + permerror ("cannot declare member function %qD to have " + "static linkage", decl); invalid_static = 1; } else if (current_function_decl) @@ -9189,8 +9191,8 @@ grokdeclarator (const cp_declarator *declarator, DECL_CONTEXT (decl) = ctype; if (staticp == 1) { - pedwarn ("% may not be used when defining " - "(as opposed to declaring) a static data member"); + permerror ("% may not be used when defining " + "(as opposed to declaring) a static data member"); staticp = 0; storage_class = sc_none; } diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index ca9440f4230..ee229f4e878 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -716,8 +716,8 @@ finish_static_data_member_decl (tree decl, VEC_safe_push (tree, gc, pending_statics, decl); if (LOCAL_CLASS_P (current_class_type)) - pedwarn ("local class %q#T shall not have static data member %q#D", - current_class_type, decl); + permerror ("local class %q#T shall not have static data member %q#D", + current_class_type, decl); /* Static consts need not be initialized in the class definition. */ if (init != NULL_TREE && TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (decl))) @@ -1233,15 +1233,15 @@ build_anon_union_vars (tree type, tree object) continue; if (TREE_CODE (field) != FIELD_DECL) { - pedwarn ("%q+#D invalid; an anonymous union can only " - "have non-static data members", field); + permerror ("%q+#D invalid; an anonymous union can only " + "have non-static data members", field); continue; } if (TREE_PRIVATE (field)) - pedwarn ("private member %q+#D in anonymous union", field); + permerror ("private member %q+#D in anonymous union", field); else if (TREE_PROTECTED (field)) - pedwarn ("protected member %q+#D in anonymous union", field); + permerror ("protected member %q+#D in anonymous union", field); if (processing_template_decl) ref = build_min_nt (COMPONENT_REF, object, @@ -1376,8 +1376,8 @@ coerce_new_type (tree type) e = 2; if (e == 2) - pedwarn ("% takes type % (%qT) " - "as first parameter", size_type_node); + permerror ("% takes type % (%qT) " + "as first parameter", size_type_node); switch (e) { diff --git a/gcc/cp/except.c b/gcc/cp/except.c index 5304381a499..3070cda4d54 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -1015,8 +1015,8 @@ check_handlers (tree handlers) if (tsi_end_p (i)) break; if (TREE_TYPE (handler) == NULL_TREE) - pedwarn ("%H%<...%> handler must be the last handler for" - " its try block", EXPR_LOCUS (handler)); + permerror ("%H%<...%> handler must be the last handler for" + " its try block", EXPR_LOCUS (handler)); else check_handlers_1 (handler, i); } diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c index a4c5e39a485..96c6dc653ba 100644 --- a/gcc/cp/friend.c +++ b/gcc/cp/friend.c @@ -253,7 +253,7 @@ make_friend_class (tree type, tree friend_type, bool complain) else if (same_type_p (type, friend_type)) { if (complain) - pedwarn ("class %qT is implicitly friends with itself", + warning (0, "class %qT is implicitly friends with itself", type); return; } diff --git a/gcc/cp/init.c b/gcc/cp/init.c index dab7dc8a68f..0c38a7fcb0c 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -533,11 +533,11 @@ perform_member_init (tree member, tree init) } /* member traversal: note it leaves init NULL */ else if (TREE_CODE (type) == REFERENCE_TYPE) - pedwarn ("%Juninitialized reference member %qD", - current_function_decl, member); + permerror ("%Juninitialized reference member %qD", + current_function_decl, member); else if (CP_TYPE_CONST_P (type)) - pedwarn ("%Juninitialized member %qD with % type %qT", - current_function_decl, member, type); + permerror ("%Juninitialized member %qD with % type %qT", + current_function_decl, member, type); } else if (TREE_CODE (init) == TREE_LIST) /* There was an explicit member initialization. Do some work @@ -2158,7 +2158,7 @@ build_new_1 (tree placement, tree type, tree nelts, tree init, else if (init) { if (complain & tf_error) - pedwarn ("ISO C++ forbids initialization in array new"); + permerror ("ISO C++ forbids initialization in array new"); else return error_mark_node; } @@ -2370,7 +2370,7 @@ build_new (tree placement, tree type, tree nelts, tree init, if (!build_expr_type_conversion (WANT_INT | WANT_ENUM, nelts, false)) { if (complain & tf_error) - pedwarn ("size in array new must have integral type"); + permerror ("size in array new must have integral type"); else return error_mark_node; } diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 94d1c8e509a..290cb7030b5 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -846,8 +846,8 @@ pushdecl_maybe_friend (tree x, bool is_friend) && TREE_CODE (decl) == TREE_CODE (x) && !same_type_p (TREE_TYPE (x), TREE_TYPE (decl))) { - pedwarn ("type mismatch with previous external decl of %q#D", x); - pedwarn ("previous external decl of %q+#D", decl); + permerror ("type mismatch with previous external decl of %q#D", x); + permerror ("previous external decl of %q+#D", decl); } } @@ -1165,7 +1165,7 @@ check_for_out_of_scope_variable (tree decl) if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (decl))) { - error ("name lookup of %qD changed for new ISO % scoping", + error ("name lookup of %qD changed for ISO % scoping", DECL_NAME (decl)); error (" cannot use obsolete binding at %q+D because " "it has a destructor", decl); @@ -1173,9 +1173,19 @@ check_for_out_of_scope_variable (tree decl) } else { - pedwarn ("name lookup of %qD changed for new ISO % scoping", - DECL_NAME (decl)); - pedwarn (" using obsolete binding at %q+D", decl); + permerror ("name lookup of %qD changed for ISO % scoping", + DECL_NAME (decl)); + if (flag_permissive) + permerror (" using obsolete binding at %q+D", decl); + else + { + static bool hint; + if (!hint) + { + inform ("(if you use %<-fpermissive%> G++ will accept your code)"); + hint = true; + } + } } return decl; diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index a53c0293b7a..81cd03fc863 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -4111,10 +4111,10 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser, && !(TREE_CODE (new_scope) == TYPENAME_TYPE && (TREE_CODE (TYPENAME_TYPE_FULLNAME (new_scope)) == TEMPLATE_ID_EXPR))) - pedwarn (TYPE_P (new_scope) - ? "%qT is not a template" - : "%qD is not a template", - new_scope); + permerror (TYPE_P (new_scope) + ? "%qT is not a template" + : "%qD is not a template", + new_scope); /* If it is a class scope, try to complete it; we are about to be looking up names inside the class. */ if (TYPE_P (new_scope) @@ -8928,7 +8928,7 @@ cp_parser_mem_initializer (cp_parser* parser) /* Find out what is being initialized. */ if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_PAREN)) { - pedwarn ("anachronistic old-style base class initializer"); + permerror ("anachronistic old-style base class initializer"); mem_initializer_id = NULL_TREE; } else @@ -9845,7 +9845,7 @@ cp_parser_template_id (cp_parser *parser, static bool hint; if (!hint) { - inform ("(if you use -fpermissive G++ will accept your code)"); + inform ("(if you use %<-fpermissive%> G++ will accept your code)"); hint = true; } } @@ -11186,7 +11186,7 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, tag_type = typename_type; /* The `typename' keyword is only allowed in templates. */ if (!processing_template_decl) - pedwarn ("using % outside of template"); + permerror ("using % outside of template"); } /* Otherwise it must be a class-key. */ else @@ -13865,7 +13865,7 @@ cp_parser_parameter_declaration (cp_parser *parser, if (!parser->default_arg_ok_p) { - if (!flag_pedantic_errors) + if (flag_permissive) warning (0, "deprecated use of default argument for parameter of non-function"); else { @@ -14758,7 +14758,7 @@ cp_parser_class_head (cp_parser* parser, class member of a namespace outside of its namespace. */ if (scope == nested_name_specifier) { - pedwarn ("extra qualification ignored"); + permerror ("extra qualification not allowed"); nested_name_specifier = NULL_TREE; num_templates = 0; } @@ -18121,7 +18121,7 @@ static void cp_parser_check_class_key (enum tag_types class_key, tree type) { if ((TREE_CODE (type) == UNION_TYPE) != (class_key == union_type)) - pedwarn ("%qs tag used in naming %q#T", + permerror ("%qs tag used in naming %q#T", class_key == union_type ? "union" : class_key == record_type ? "struct" : "class", type); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index eb4a7b7ed34..9926f3d834f 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -710,8 +710,8 @@ check_specialization_namespace (tree tmpl) return true; else { - pedwarn ("specialization of %qD in different namespace", tmpl); - pedwarn (" from definition of %q+#D", tmpl); + permerror ("specialization of %qD in different namespace", tmpl); + permerror (" from definition of %q+#D", tmpl); return false; } } @@ -728,9 +728,9 @@ check_explicit_instantiation_namespace (tree spec) namespace of its template. */ ns = decl_namespace_context (spec); if (!is_ancestor (current_namespace, ns)) - pedwarn ("explicit instantiation of %qD in namespace %qD " - "(which does not enclose namespace %qD)", - spec, current_namespace, ns); + permerror ("explicit instantiation of %qD in namespace %qD " + "(which does not enclose namespace %qD)", + spec, current_namespace, ns); } /* The TYPE is being declared. If it is a template type, that means it @@ -811,9 +811,9 @@ maybe_process_partial_specialization (tree type) if (current_namespace != decl_namespace_context (CLASSTYPE_TI_TEMPLATE (type))) { - pedwarn ("specializing %q#T in different namespace", type); - pedwarn (" from definition of %q+#D", - CLASSTYPE_TI_TEMPLATE (type)); + permerror ("specializing %q#T in different namespace", type); + permerror (" from definition of %q+#D", + CLASSTYPE_TI_TEMPLATE (type)); } /* Check for invalid specialization after instantiation: @@ -2006,7 +2006,7 @@ check_explicit_specialization (tree declarator, for (; t; t = TREE_CHAIN (t)) if (TREE_PURPOSE (t)) { - pedwarn + permerror ("default argument specified in explicit specialization"); break; } @@ -4942,8 +4942,8 @@ convert_template_argument (tree parm, if (requires_type && ! is_type && TREE_CODE (arg) == SCOPE_REF && TREE_CODE (TREE_OPERAND (arg, 0)) == TEMPLATE_TYPE_PARM) { - pedwarn ("to refer to a type member of a template parameter, " - "use %", orig_arg); + permerror ("to refer to a type member of a template parameter, " + "use %", orig_arg); orig_arg = make_typename_type (TREE_OPERAND (arg, 0), TREE_OPERAND (arg, 1), @@ -14567,7 +14567,7 @@ do_decl_instantiation (tree decl, tree storage) the first instantiation was `extern' and the second is not, and EXTERN_P for the opposite case. */ if (DECL_NOT_REALLY_EXTERN (result) && !extern_p) - pedwarn ("duplicate explicit instantiation of %q#D", result); + permerror ("duplicate explicit instantiation of %q#D", result); /* If an "extern" explicit instantiation follows an ordinary explicit instantiation, the template is instantiated. */ if (extern_p) @@ -14580,7 +14580,7 @@ do_decl_instantiation (tree decl, tree storage) } else if (!DECL_TEMPLATE_INFO (result)) { - pedwarn ("explicit instantiation of non-template %q#D", result); + permerror ("explicit instantiation of non-template %q#D", result); return; } @@ -14721,7 +14721,7 @@ do_type_instantiation (tree t, tree storage, tsubst_flags_t complain) if (!previous_instantiation_extern_p && !extern_p && (complain & tf_error)) - pedwarn ("duplicate explicit instantiation of %q#T", t); + permerror ("duplicate explicit instantiation of %q#T", t); /* If we've already instantiated the template, just return now. */ if (!CLASSTYPE_INTERFACE_ONLY (t)) @@ -15168,7 +15168,7 @@ instantiate_decl (tree d, int defer_ok, member function or static data member of a class template shall be present in every translation unit in which it is explicitly instantiated. */ - pedwarn + permerror ("explicit instantiation of %qD but no definition available", d); /* ??? Historically, we have instantiated inline functions, even diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index f39b8d1eb17..2400aeb37da 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2170,7 +2170,7 @@ finish_template_type_parm (tree aggr, tree identifier) { if (aggr != class_type_node) { - pedwarn ("template type parameters must use the keyword % or %"); + permerror ("template type parameters must use the keyword % or %"); aggr = class_type_node; } diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 026e4469b7d..8fd3be2c68d 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -435,9 +435,9 @@ composite_pointer_type_r (tree t1, tree t2, const char* location, else { if (complain & tf_error) - pedwarn ("%s between distinct pointer types %qT and %qT " - "lacks a cast", - location, t1, t2); + permerror ("%s between distinct pointer types %qT and %qT " + "lacks a cast", + location, t1, t2); result_type = void_type_node; } result_type = cp_build_qualified_type (result_type, @@ -450,9 +450,9 @@ composite_pointer_type_r (tree t1, tree t2, const char* location, if (!same_type_p (TYPE_PTRMEM_CLASS_TYPE (t1), TYPE_PTRMEM_CLASS_TYPE (t2)) && (complain & tf_error)) - pedwarn ("%s between distinct pointer types %qT and %qT " - "lacks a cast", - location, t1, t2); + permerror ("%s between distinct pointer types %qT and %qT " + "lacks a cast", + location, t1, t2); result_type = build_ptrmem_type (TYPE_PTRMEM_CLASS_TYPE (t1), result_type); } @@ -1355,8 +1355,8 @@ cxx_sizeof_expr (tree e, tsubst_flags_t complain) else if (is_overloaded_fn (e)) { if (complain & tf_error) - pedwarn ("ISO C++ forbids applying % to an expression of " - "function type"); + permerror ("ISO C++ forbids applying % to an expression of " + "function type"); else return error_mark_node; e = char_type_node; @@ -1415,8 +1415,8 @@ cxx_alignof_expr (tree e, tsubst_flags_t complain) else if (is_overloaded_fn (e)) { if (complain & tf_error) - pedwarn ("ISO C++ forbids applying %<__alignof%> to an expression of " - "function type"); + permerror ("ISO C++ forbids applying %<__alignof%> to an expression of " + "function type"); else return error_mark_node; if (TREE_CODE (e) == FUNCTION_DECL) @@ -2146,7 +2146,7 @@ check_template_keyword (tree decl) && TREE_CODE (decl) != TEMPLATE_ID_EXPR) { if (!is_overloaded_fn (decl)) - pedwarn ("%qD is not a template", decl); + permerror ("%qD is not a template", decl); else { tree fns; @@ -2166,7 +2166,7 @@ check_template_keyword (tree decl) fns = OVL_NEXT (fns); } if (!fns) - pedwarn ("%qD is not a template", decl); + permerror ("%qD is not a template", decl); } } } @@ -3258,8 +3258,8 @@ cp_build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, if (t != error_mark_node) { if (complain & tf_error) - pedwarn ("assuming cast to type %qT from overloaded function", - TREE_TYPE (t)); + permerror ("assuming cast to type %qT from overloaded function", + TREE_TYPE (t)); op0 = t; } } @@ -3269,8 +3269,8 @@ cp_build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, if (t != error_mark_node) { if (complain & tf_error) - pedwarn ("assuming cast to type %qT from overloaded function", - TREE_TYPE (t)); + permerror ("assuming cast to type %qT from overloaded function", + TREE_TYPE (t)); op1 = t; } } @@ -3544,7 +3544,7 @@ cp_build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, { result_type = type0; if (complain & tf_error) - pedwarn ("ISO C++ forbids comparison between pointer and integer"); + permerror ("ISO C++ forbids comparison between pointer and integer"); else return error_mark_node; } @@ -3552,7 +3552,7 @@ cp_build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, { result_type = type1; if (complain & tf_error) - pedwarn ("ISO C++ forbids comparison between pointer and integer"); + permerror ("ISO C++ forbids comparison between pointer and integer"); else return error_mark_node; } @@ -3732,7 +3732,7 @@ cp_build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, { result_type = type0; if (complain & tf_error) - pedwarn ("ISO C++ forbids comparison between pointer and integer"); + permerror ("ISO C++ forbids comparison between pointer and integer"); else return error_mark_node; } @@ -3740,7 +3740,7 @@ cp_build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, { result_type = type1; if (complain & tf_error) - pedwarn ("ISO C++ forbids comparison between pointer and integer"); + permerror ("ISO C++ forbids comparison between pointer and integer"); else return error_mark_node; } @@ -4111,11 +4111,11 @@ pointer_diff (tree op0, tree op1, tree ptrtype) if (pedantic || warn_pointer_arith) { if (TREE_CODE (target_type) == VOID_TYPE) - pedwarn ("ISO C++ forbids using pointer of type % in subtraction"); + permerror ("ISO C++ forbids using pointer of type % in subtraction"); if (TREE_CODE (target_type) == FUNCTION_TYPE) - pedwarn ("ISO C++ forbids using pointer to a function in subtraction"); + permerror ("ISO C++ forbids using pointer to a function in subtraction"); if (TREE_CODE (target_type) == METHOD_TYPE) - pedwarn ("ISO C++ forbids using pointer to a method in subtraction"); + permerror ("ISO C++ forbids using pointer to a method in subtraction"); } /* First do the subtraction as integers; @@ -4481,9 +4481,9 @@ cp_build_unary_op (enum tree_code code, tree xarg, int noconvert, if (TREE_CODE (argtype) == ENUMERAL_TYPE) { if (complain & tf_error) - pedwarn ((code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR) - ? G_("ISO C++ forbids incrementing an enum") - : G_("ISO C++ forbids decrementing an enum")); + permerror ((code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR) + ? G_("ISO C++ forbids incrementing an enum") + : G_("ISO C++ forbids decrementing an enum")); else return error_mark_node; } @@ -4509,11 +4509,11 @@ cp_build_unary_op (enum tree_code code, tree xarg, int noconvert, && !TYPE_PTROB_P (argtype)) { if (complain & tf_error) - pedwarn ((code == PREINCREMENT_EXPR - || code == POSTINCREMENT_EXPR) - ? G_("ISO C++ forbids incrementing a pointer of type %qT") - : G_("ISO C++ forbids decrementing a pointer of type %qT"), - argtype); + permerror ((code == PREINCREMENT_EXPR + || code == POSTINCREMENT_EXPR) + ? G_("ISO C++ forbids incrementing a pointer of type %qT") + : G_("ISO C++ forbids decrementing a pointer of type %qT"), + argtype); else return error_mark_node; } @@ -4570,7 +4570,7 @@ cp_build_unary_op (enum tree_code code, tree xarg, int noconvert, { /* ARM $3.4 */ if (complain & tf_error) - pedwarn ("ISO C++ forbids taking address of function %<::main%>"); + permerror ("ISO C++ forbids taking address of function %<::main%>"); else return error_mark_node; } @@ -4631,15 +4631,15 @@ cp_build_unary_op (enum tree_code code, tree xarg, int noconvert, else if (current_class_type && TREE_OPERAND (arg, 0) == current_class_ref) /* An expression like &memfn. */ - pedwarn ("ISO C++ forbids taking the address of an unqualified" - " or parenthesized non-static member function to form" - " a pointer to member function. Say %<&%T::%D%>", - base, name); + permerror ("ISO C++ forbids taking the address of an unqualified" + " or parenthesized non-static member function to form" + " a pointer to member function. Say %<&%T::%D%>", + base, name); else - pedwarn ("ISO C++ forbids taking the address of a bound member" - " function to form a pointer to member function." - " Say %<&%T::%D%>", - base, name); + permerror ("ISO C++ forbids taking the address of a bound member" + " function to form a pointer to member function." + " Say %<&%T::%D%>", + base, name); } arg = build_offset_ref (base, fn, /*address_p=*/true); } @@ -4665,7 +4665,7 @@ cp_build_unary_op (enum tree_code code, tree xarg, int noconvert, if (! lvalue_p (arg) && (pedantic || complain == tf_none)) { if (complain & tf_error) - pedwarn ("ISO C++ forbids taking the address of a cast to a non-lvalue expression"); + permerror ("ISO C++ forbids taking the address of a cast to a non-lvalue expression"); else return error_mark_node; } @@ -5010,7 +5010,7 @@ tree build_x_compound_expr_from_list (tree list, const char *msg) if (TREE_CHAIN (list)) { if (msg) - pedwarn ("%s expression list treated as compound expression", msg); + permerror ("%s expression list treated as compound expression", msg); for (list = TREE_CHAIN (list); list; list = TREE_CHAIN (list)) expr = build_x_compound_expr (expr, TREE_VALUE (list), @@ -5561,8 +5561,8 @@ build_reinterpret_cast_1 (tree type, tree expr, bool c_cast_p, if (TYPE_PRECISION (type) < TYPE_PRECISION (intype)) { if (complain & tf_error) - pedwarn ("cast from %qT to %qT loses precision", - intype, type); + permerror ("cast from %qT to %qT loses precision", + intype, type); else return error_mark_node; } @@ -5838,7 +5838,7 @@ cp_build_c_cast (tree type, tree expr, tsubst_flags_t complain) if (TREE_CODE (TREE_TYPE (expr)) == POINTER_TYPE) { if (complain & tf_error) - pedwarn ("ISO C++ forbids casting to an array type %qT", type); + permerror ("ISO C++ forbids casting to an array type %qT", type); else return error_mark_node; type = build_pointer_type (TREE_TYPE (type)); @@ -6964,8 +6964,8 @@ check_return_expr (tree retval, bool *no_warning) that's supposed to return a value. */ if (!retval && fn_returns_value_p) { - pedwarn ("return-statement with no value, in function returning %qT", - valtype); + permerror ("return-statement with no value, in function returning %qT", + valtype); /* Clear this, so finish_function won't say that we reach the end of a non-void function (which we don't, we gave a return!). */ @@ -6985,8 +6985,8 @@ check_return_expr (tree retval, bool *no_warning) its side-effects. */ finish_expr_stmt (retval); else - pedwarn ("return-statement with a value, in function " - "returning 'void'"); + permerror ("return-statement with a value, in function " + "returning 'void'"); current_function_returns_null = 1; diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index c1fea0c0bed..05e88b9002e 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -694,7 +694,7 @@ digest_init (tree type, tree init) counted in the length of the constant, but in C++ this would be invalid. */ if (size < TREE_STRING_LENGTH (init)) - pedwarn ("initializer-string for array of chars is too long"); + permerror ("initializer-string for array of chars is too long"); } return init; } -- 2.30.2