Bug 24924 - front end and preprocessor pedantic_errors settings should agree
Summary: front end and preprocessor pedantic_errors settings should agree
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.1.0
: P3 normal
Target Milestone: 4.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic, patch
Depends on:
Blocks: 4.4pending
  Show dependency treegraph
 
Reported: 2005-11-17 20:21 UTC by Joseph S. Myers
Modified: 2008-03-03 10:56 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-02-20 18:28:01


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph S. Myers 2005-11-17 20:21:31 UTC
The C++ front end makes pedwarns into errors by default (unless -fpermissive).  However, this only applies to front end pedwarns and not to preprocessor ones, as the preprocessor has its own pedantic_errors setting which is changed by an explicit -pedantic-errors option but doesn't default to 1 for C++ the way the global setting does.

There should be a consistent pedantic_errors setting for both compiler and preprocessor pedwarns.

Test: preprocess a testcase such as

#if 1
#endif 1

and observe it gives a warning which becomes an error with -pedantic-errors, whereas by the principle followed by the C++ front end it should be an error which becomes a warning with -fpermissive.
Comment 1 Andrew Pinski 2005-11-17 20:26:45 UTC
Confirmed.
Comment 2 patchapp@dberlin.org 2007-01-27 09:15:26 UTC
Subject: Bug number PR24924

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-01/msg02234.html
Comment 3 Manuel López-Ibáñez 2007-03-15 22:24:58 UTC
Subject: Bug 24924

Author: manu
Date: Thu Mar 15 22:24:42 2007
New Revision: 122961

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=122961
Log:
2007-03-15  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

	PR c++/24924
	* c-opts.c (c_common_post_options): Handle C++ post-processing here.
	Set also -pedantic-errors by default for the  preprocessor unless
	-fpermissive is given.
cp/
	* decl.c (cxx_init_decl_processing): Move command-line options
	processing to c-opts.c.
testsuite/
	* g++.dg/cpp/pedantic-errors.C: New.
	* g++.dg/cpp/permissive.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp/pedantic-errors.C
    trunk/gcc/testsuite/g++.dg/cpp/permissive.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-opts.c
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl.c
    trunk/gcc/testsuite/ChangeLog

Comment 4 Manuel López-Ibáñez 2007-03-15 22:49:24 UTC
Fixed for GCC 4.3
Comment 5 Manuel López-Ibáñez 2008-01-14 19:18:25 UTC
The fix was reverted so REOPEN.

There is a patch available for 4.4:
http://gcc.gnu.org/ml/gcc-patches/2008-01/msg00583.html
Comment 6 Manuel López-Ibáñez 2008-01-14 19:22:24 UTC
Subject: Bug 24924

Author: manu
Date: Mon Jan 14 19:21:38 2008
New Revision: 131530

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131530
Log:
2008-01-14  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

	PR c++/24924
	* c-opts (c_common_post_options): Do not enable CPP
	flag_pedantic_errors by default.
testsuite/
	* g++.dg/cpp/pedantic-errors.C: Delete.
	* g++.dg/cpp/permissive.C: Delete.

Removed:
    trunk/gcc/testsuite/g++.dg/cpp/pedantic-errors.C
    trunk/gcc/testsuite/g++.dg/cpp/permissive.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-opts.c
    trunk/gcc/testsuite/ChangeLog

Comment 7 Manuel López-Ibáñez 2008-03-02 15:46:15 UTC
Subject: Bug 24924

Author: manu
Date: Sun Mar  2 15:45:29 2008
New Revision: 132817

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=132817
Log:
2008-03-02  Manuel Lopez-Ibanez  <manu@gcc.gnu.org> 

	PR 24924
	* c-common.c (flag_permissive): Delete.
	(constant_expression_warnings): Check flags first.
	(constant_expression_error): New.
	* c-common.h (flag_permissive): Delete.
	(constant_expression_error): Declare.
	* flags.h (flag_permissive): Declare. Update description.
	* diagnostic.c (pedwarn): Update.
	(permerror): New.
	* diagnostic.h: (pedantic_error_kind): Rename as pedantic_warning_kind.
	(permissive_error_kind): New.
	* toplev.c (flag_permissive): Define. Update description.
	* toplev.h (permissive_error_kind): Declare.
	* c-errors.c (pedwarn_c99): Use pedantic_warning_kind.
	(pedwarn_c90): Use pedantic_warning_kind.
	* c-opts.c (c_common_post_options): flag_permissive does not affect
	flag_pedantic_errors.
cp/
	* class.c (finish_struct_anon): Use permerror instead of pedwarn.
	(check_field_decls): Likewise.
	(note_name_declared_in_class): Likewise.
	* call.c (build_new_op): Likewise.
	(convert_like_real): Likewise.
	(build_over_call): Likewise.
	* lex.c (unqualified_fn_lookup_error): Likewise.
	* parser.c (cp_parser_template_id): Likewise.
	* cvt.c (warn_ref_binding): Likewise.
	(convert_to_reference): Likewise.
	(ocp_convert): Likewise.
	(convert_to_void): Use error instead of pedwarn.
	* error.c (cp_cpp_error): Use pedantic_warning_kind.
	* decl.c (compute_array_index_type): Use constant_expression_error.
testsuite/
	* g++.dg/cpp/string-2.C: This is a warning now.
	* g++.dg/cpp/pedantic-errors.C: -pedantic-errors is not enabled by
	default, so add it.

Added:
    trunk/gcc/testsuite/g++.dg/cpp/pedantic-errors.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-common.c
    trunk/gcc/c-common.h
    trunk/gcc/c-errors.c
    trunk/gcc/c-opts.c
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c
    trunk/gcc/cp/class.c
    trunk/gcc/cp/cvt.c
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/error.c
    trunk/gcc/cp/lex.c
    trunk/gcc/cp/parser.c
    trunk/gcc/diagnostic.c
    trunk/gcc/diagnostic.h
    trunk/gcc/flags.h
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/cpp/string-2.C
    trunk/gcc/toplev.c
    trunk/gcc/toplev.h

Comment 8 Manuel López-Ibáñez 2008-03-03 10:56:29 UTC
This is fixed for 4.4 by introducing permerror which makes -fpermissive completely independent of -pedantic and -pedantic-errors.