cc1 empty.c -pedantic -Werror empty.c:1:0: error: ISO C forbids an empty translation unit [-Werror=edantic]
I will propose to introduce -Wpedantic as the canonical name of pedantic. This will also make -Werror=pedantic work. I don't see any reason why -pedantic has to be special except historical. We can keep the old forms as aliases indefinitely. Joseph, Gabriel, what is your opinion? Should I prepare a patch to add -Wpedantic?
manuel@gcc11:~$ ~/test2/161617M/build/gcc/cc1 empty2.c -pedantic-errors empty2.c:1:1: error: struct has no members [-pedantic] empty2.c:2:1: error: unnamed struct/union that defines no instances manuel@gcc11:~$ ~/test2/161617M/build/gcc/cc1 empty2.c -pedantic -Werror empty2.c:1:1: error: struct has no members [-Werror=edantic] empty2.c:2:1: error: unnamed struct/union that defines no instances [-Werror] We also should add a -Wpedantic-default (or -Wpedantic-required) for pedwarns enabled by default (not by -pedantic). OK?
Subject: Re: -Werror=edantic On Thu, 1 Jul 2010, manu at gcc dot gnu dot org wrote: > We also should add a -Wpedantic-default (or -Wpedantic-required) for pedwarns > enabled by default (not by -pedantic). Those would be extremely bad option names, since diagnostics enabled by default have nothing to do with pedantry; "pedwarn" is simply a GCC-internal function name for diagnosing constraint violations and should not be allowed to influence command-line option names. -pedantic-errors means something like -Werror=standard-required-diagnostics and a pedwarn enabled by default is a standard-required diagnostic enabled by default (as opposed to a warning enabled by default which is a non-standard-required diagnostic enabled by default). There is no particular reason to allow people to disable standard-required default diagnostics as a group separately from non-standard-required ones; think about more useful classifications of the existing enabled-by-default diagnostics to work out suitable option names for disabling them.
I knew this couldn't be easy ;-) Let's restrict to -pedantic first. It is the only warning flag that doesn't start with "-W". This breaks some code that expects that every warning flag starts with -W. I want to introduce -Wpedantic as an alias. You do not like the name. What is your suggestion? Manuel.
Related PR 37187
Then the right fix would be not to assume that all such options start with -W, no?
Why? All of them do, except -pedantic. I don't see any reason for -pedantic being exceptional. Or can I start proposing warnings options that do not start with -W? Should we introduce a special case for pedantic (code and documentation) for -Werror= and for -Wno-error= and for -Wno-? I can start opening PRs for the missing special cases. We would also need to introduce (and handle specially) -no-pedantic and -no-pedantic-errors. All the above is free if we just make -Wpedantic an alias for -pedantic.
By the way, the subject should read -Werror=pedantic, right?
(In reply to comment #8) > By the way, the subject should read -Werror=pedantic, right? > Well, it depends. We actually print -Werror=edantic. ;-)
I see, I had only a quick look to the audit trail and thought it was a less trivial issue ;)
Subject: Re: -Werror=edantic On Fri, 2 Jul 2010, manu at gcc dot gnu dot org wrote: > Let's restrict to -pedantic first. It is the only warning flag that doesn't > start with "-W". This breaks some code that expects that every warning flag > starts with -W. I want to introduce -Wpedantic as an alias. You do not like the > name. What is your suggestion? I do not object to -Wpedantic. I object to -Wpedantic-default or other variants involving "pedantic" for diagnostics currently enabled by default.
(In reply to comment #11) > > I do not object to -Wpedantic. Ah, ok! Then, I will start with this and worry about the other warnings when their time comes. Thanks!
*** Bug 48247 has been marked as a duplicate of this bug. ***
*** Bug 48687 has been marked as a duplicate of this bug. ***
Created attachment 26688 [details] patch Bootstrapped and regression tested, but without documentation updated or testcase. Anyway, it is probably too late for 4.7 and I don't know when I will have time to pick this up again, so anyone feel free to take it/improve it.
Author: manu Date: Sun Apr 22 19:17:47 2012 New Revision: 186681 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186681 Log: 2012-04-22 Manuel López-Ibáñez <manu@gcc.gnu.org> PR c/44774 gcc/ * doc/invoke.texi (pedantic): Rename to Wpedantic. * common.opt (Wpedantic): New. (pedantic): Alias Wpedantic. * diagnostic.c (warning_at): Likewise. * c-decl.c (diagnose_mismatched_decls): Likewise. (build_array_declarator): Likewise. (mark_forward_parm_decls): (check_bitfield_type_and_width): Likewise. (grokdeclarator): Likewise. (grokfield): Likewise. (finish_struct): Likewise. (build_enumerator): Likewise. (store_parm_decls_oldstyle): Likewise. (declspecs_add_qual): Likewise. (declspecs_add_type): Likewise. (finish_declspecs): Likewise. * c-typeck.c (composite_type): Likewise. (comp_target_types): Likewise. (build_array_ref): Likewise. (pointer_diff): Likewise. (build_unary_op): Likewise. (build_conditional_expr): Likewise. (build_c_cast): Likewise. (convert_for_assignment): Likewise. (maybe_warn_string_init): Likewise. (digest_init): Likewise. (pop_init_level): Likewise. (set_init_index): Likewise. (c_finish_goto_label): Likewise. (c_finish_return): Likewise. (do_case): Likewise. (build_binary_op): Likewise. * c-parser.c (static): Likewise. (c_parser_external_declaration): Likewise. (c_parser_declaration_or_fndef): Likewise. (c_parser_static_assert_declaration_no_se): Likewise. (c_parser_enum_specifier): Likewise. (c_parser_struct_or_union_specifier): Likewise. (c_parser_struct_declaration): Likewise. (c_parser_alignas_specifier): Likewise. (c_parser_braced_init): Likewise. (c_parser_initelt): Likewise. (c_parser_compound_statement_nostart): Likewise. (c_parser_conditional_expression): Likewise. (c_parser_alignof_expression): Likewise. (c_parser_postfix_expression): Likewise. (c_parser_postfix_expression_after_paren_): Likewise. (c_parser_objc_class_instance_variables): Likewise. (c_parser_objc_method_definition): Likewise. (c_parser_objc_methodprotolist): Likewise. c-family/ * c.opt (Wpedantic): New. (pedantic): Alias Wpedantic. * c-opts.c (c_common_handle_option): Replace -pedantic with -Wpedantic. (c_common_post_options): Likewise. (sanitize_cpp_opts): Likewise. * c-lex.c (interpret_float): Likewise. * c-format.c (check_format_types): Likewise. * c-common.c (pointer_int_sum): Likewise. (c_sizeof_or_alignof_type): Likewise. (c_add_case_label): Likewise. (c_do_switch_warnings): Likewise. * c-pragma.c (handle_pragma_float_const_decimal64): Likewise. cp/ * typeck.c (composite_pointer_type): Likewise. (cxx_sizeof_or_alignof_type): Likewise. (cp_build_array_ref): Likewise. (cp_build_function_call_vec): Likewise. (cp_build_addr_expr_1): Likewise. (convert_member_func_to_ptr): Likewise. * decl.c (check_tag_decl): Likewise. (check_static_variable_definition): Likewise. (compute_array_index_type): Likewise. (create_array_type_for_decl): Likewise. (grokdeclarator): Likewise. (grok_op_properties): Likewise. * error.c (maybe_warn_cpp0x): Likewise. * pt.c (maybe_process_partial_specialization): Likewise. (convert_template_argument): Likewise. (do_decl_instantiation): Likewise. (do_type_instantiation): Likewise. * parser.c (cp_parser_primary_expression): Likewise. (cp_parser_postfix_expression): Likewise. (cp_parser_unary_expression): Likewise. (cp_parser_question_colon_clause): Likewise. (cp_parser_lambda_introducer): Likewise. (cp_parser_lambda_declarator_opt): Likewise. (cp_parser_compound_statement): Likewise. (cp_parser_jump_statement): Likewise. (cp_parser_declaration_seq_opt): Likewise. (cp_parser_enum_specifier): Likewise. (cp_parser_enumerator_list): Likewise. (cp_parser_initializer_list): Likewise. (cp_parser_member_declaration): Likewise. * call.c (build_conditional_expr_1): Likewise. * friend.c (make_friend_class): Likewise. * name-lookup.c (pushdecl_maybe_friend_1): Likewise. Modified: trunk/gcc/ChangeLog trunk/gcc/c-decl.c trunk/gcc/c-family/ChangeLog trunk/gcc/c-family/c-common.c trunk/gcc/c-family/c-format.c trunk/gcc/c-family/c-lex.c trunk/gcc/c-family/c-opts.c trunk/gcc/c-family/c-pragma.c trunk/gcc/c-family/c.opt trunk/gcc/c-parser.c trunk/gcc/c-typeck.c trunk/gcc/common.opt trunk/gcc/cp/ChangeLog trunk/gcc/cp/call.c trunk/gcc/cp/decl.c trunk/gcc/cp/error.c trunk/gcc/cp/friend.c trunk/gcc/cp/name-lookup.c trunk/gcc/cp/parser.c trunk/gcc/cp/pt.c trunk/gcc/cp/typeck.c trunk/gcc/diagnostic.c trunk/gcc/doc/invoke.texi
So the testcase here works, and -Werror=pedantic is accepted and printed correctly. However, -pedantic-errors still prints just -Wpedantic when it should print -Werror=pedantic. This is tracked in PR53075.