This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
(C++) Patch for -fpermissive
- To: egcs-patches at cygnus dot com
- Subject: (C++) Patch for -fpermissive
- From: Jason Merrill <jason at cygnus dot com>
- Date: Mon, 7 Dec 1998 12:23:56 -0800
This patch turns on flag_pedantic_errors by default, which can be
overridden by -fpermissive. This is also overridden by -pedantic. I've
also turned some errors back into pedwarns.
1998-12-07 Jason Merrill <jason@yorick.cygnus.com>
* lang-options.h: Add -fpermissive.
* decl2.c: Likewise.
* cp-tree.h: Add flag_permissive.
* decl.c (init_decl_processing): If neither -fpermissive or -pedantic
were specified, set flag_pedantic_errors.
* call.c (build_over_call): Turn dropped qualifier messages
back into pedwarns.
* cvt.c (convert_to_reference): Likewise.
* typeck.c (convert_for_assignment): Likewise.
Index: NEWS
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/NEWS,v
retrieving revision 1.15
diff -c -p -r1.15 NEWS
*** NEWS 1998/09/04 01:43:56 1.15
--- NEWS 1998/12/07 20:20:42
***************
*** 1,3 ****
--- 1,9 ----
+ *** Changes since EGCS 1.1:
+
+ * Messages about non-conformant code that we can still handle ("pedwarns")
+ are now errors by default, rather than warnings. This can be reverted
+ with -fpermissive, and is overridden by -pedantic or -pedantic-errors.
+
*** Changes in EGCS 1.1:
* Namespaces are fully supported. The library has not yet been converted
Index: call.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/call.c,v
retrieving revision 1.125
diff -c -p -r1.125 call.c
*** call.c 1998/12/06 01:33:09 1.125
--- call.c 1998/12/07 20:20:43
*************** build_over_call (cand, args, flags)
*** 3258,3265 ****
tree argtype = TREE_TYPE (TREE_VALUE (arg));
tree t;
if (ICS_BAD_FLAG (TREE_VEC_ELT (convs, i)))
! cp_error ("passing `%T' as `this' argument of `%#D' discards qualifiers",
! TREE_TYPE (argtype), fn);
/* [class.mfct.nonstatic]: If a nonstatic member function of a class
X is called for an object that is not of type X, or of a type
--- 3258,3265 ----
tree argtype = TREE_TYPE (TREE_VALUE (arg));
tree t;
if (ICS_BAD_FLAG (TREE_VEC_ELT (convs, i)))
! cp_pedwarn ("passing `%T' as `this' argument of `%#D' discards qualifiers",
! TREE_TYPE (argtype), fn);
/* [class.mfct.nonstatic]: If a nonstatic member function of a class
X is called for an object that is not of type X, or of a type
Index: cp-tree.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/cp-tree.h,v
retrieving revision 1.177
diff -c -p -r1.177 cp-tree.h
*** cp-tree.h 1998/12/03 16:57:59 1.177
--- cp-tree.h 1998/12/07 20:20:43
*************** extern int flag_optional_diags;
*** 498,508 ****
/* Nonzero means do not consider empty argument prototype to mean function
takes no arguments. */
-
extern int flag_strict_prototype;
/* Nonzero means output .vtable_{entry,inherit} for use in doing vtable gc. */
extern int flag_vtable_gc;
/* C++ language-specific tree codes. */
#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) SYM,
--- 498,511 ----
/* Nonzero means do not consider empty argument prototype to mean function
takes no arguments. */
extern int flag_strict_prototype;
/* Nonzero means output .vtable_{entry,inherit} for use in doing vtable gc. */
extern int flag_vtable_gc;
+
+ /* Nonzero means make the default pedwarns warnings instead of errors.
+ The value of this flag is ignored if -pedantic is specified. */
+ int flag_permissive;
/* C++ language-specific tree codes. */
#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) SYM,
Index: cvt.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/cvt.c,v
retrieving revision 1.44
diff -c -p -r1.44 cvt.c
*** cvt.c 1998/11/25 00:28:48 1.44
--- cvt.c 1998/12/07 20:20:44
*************** convert_to_reference (reftype, expr, con
*** 468,480 ****
else
msg = "conversion to non-const reference type `%#T'";
! cp_error (msg, reftype);
! cp_error ("from rvalue of type `%T'", intype);
}
else if (! (convtype & CONV_CONST)
&& !at_least_as_qualified_p (ttl, ttr))
! cp_error ("conversion from `%T' to `%T' discards qualifiers",
! ttr, reftype);
}
return build_up_reference (reftype, expr, flags);
--- 468,480 ----
else
msg = "conversion to non-const reference type `%#T'";
! cp_pedwarn (msg, reftype);
! cp_pedwarn ("from rvalue of type `%T'", intype);
}
else if (! (convtype & CONV_CONST)
&& !at_least_as_qualified_p (ttl, ttr))
! cp_pedwarn ("conversion from `%T' to `%T' discards qualifiers",
! ttr, reftype);
}
return build_up_reference (reftype, expr, flags);
Index: decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.278
diff -c -p -r1.278 decl.c
*** decl.c 1998/12/04 11:13:56 1.278
--- decl.c 1998/12/07 20:20:45
*************** init_decl_processing ()
*** 5620,5625 ****
--- 5624,5631 ----
if (flag_strict_prototype == 2)
flag_strict_prototype = pedantic;
+ if (! flag_permissive && ! pedantic)
+ flag_pedantic_errors = 1;
strict_prototypes_lang_c = flag_strict_prototype;
Index: decl2.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl2.c,v
retrieving revision 1.164
diff -c -p -r1.164 decl2.c
*** decl2.c 1998/12/06 01:44:12 1.164
--- decl2.c 1998/12/07 20:20:45
*************** int flag_do_squangling;
*** 445,450 ****
--- 445,455 ----
int flag_vtable_gc;
+ /* Nonzero means make the default pedwarns warnings instead of errors.
+ The value of this flag is ignored if -pedantic is specified. */
+
+ int flag_permissive;
+
/* Table of language-dependent -f options.
STRING is the option name. VARIABLE is the address of the variable.
ON_VALUE is the value to store in VARIABLE
*************** static struct { char *string; int *varia
*** 488,493 ****
--- 493,499 ----
{"nonansi-builtins", &flag_no_nonansi_builtin, 0},
{"operator-names", &flag_operator_names, 1},
{"optional-diags", &flag_optional_diags, 1},
+ {"permissive", &flag_permissive, 1},
{"repo", &flag_use_repository, 1},
{"rtti", &flag_rtti, 1},
{"squangle", &flag_do_squangling, 1},
Index: lang-options.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/lang-options.h,v
retrieving revision 1.21
diff -c -p -r1.21 lang-options.h
*** lang-options.h 1998/12/04 11:14:02 1.21
--- lang-options.h 1998/12/07 20:20:46
*************** DEFINE_LANG_NAME ("C++")
*** 82,87 ****
--- 82,89 ----
{ "-fno-operator-names", "" },
{ "-foptional-diags", "" },
{ "-fno-optional-diags", "Disable optional diagnostics" },
+ { "-fpermissive", "Downgrade conformance errors to warnings" },
+ { "-fno-permissive", "" },
{ "-frepo", "Enable automatic template instantiation" },
{ "-fno-repo", "" },
{ "-fsave-memoized", "" },
Index: typeck.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/typeck.c,v
retrieving revision 1.127
diff -c -p -r1.127 typeck.c
*** typeck.c 1998/11/24 17:56:27 1.127
--- typeck.c 1998/12/07 20:20:47
*************** convert_for_assignment (type, rhs, errty
*** 6618,6628 ****
if (!at_least_as_qualified_p (ttl, ttr))
{
if (fndecl)
! cp_error ("passing `%T' as argument %P of `%D' discards qualifiers",
! rhstype, parmnum, fndecl);
else
! cp_error ("%s to `%T' from `%T' discards qualifiers",
! errtype, type, rhstype);
}
}
--- 6618,6628 ----
if (!at_least_as_qualified_p (ttl, ttr))
{
if (fndecl)
! cp_pedwarn ("passing `%T' as argument %P of `%D' discards qualifiers",
! rhstype, parmnum, fndecl);
else
! cp_pedwarn ("%s to `%T' from `%T' discards qualifiers",
! errtype, type, rhstype);
}
}
*************** convert_for_assignment (type, rhs, errty
*** 6675,6684 ****
if (string_conv_p (type, rhs, 1))
/* converting from string constant to char *, OK. */;
else if (fndecl)
! cp_error ("passing `%T' as argument %P of `%D' discards qualifiers",
! rhstype, parmnum, fndecl);
else
! cp_error ("%s to `%T' from `%T' discards qualifiers",
errtype, type, rhstype);
}
else if (TREE_CODE (ttl) == TREE_CODE (ttr)
--- 6675,6684 ----
if (string_conv_p (type, rhs, 1))
/* converting from string constant to char *, OK. */;
else if (fndecl)
! cp_pedwarn ("passing `%T' as argument %P of `%D' discards qualifiers",
! rhstype, parmnum, fndecl);
else
! cp_pedwarn ("%s to `%T' from `%T' discards qualifiers",
errtype, type, rhstype);
}
else if (TREE_CODE (ttl) == TREE_CODE (ttr)
*************** convert_for_assignment (type, rhs, errty
*** 6739,6748 ****
if (drops_quals)
{
if (fndecl)
! cp_error ("passing `%T' as argument %P of `%D' discards qualifiers",
! rhstype, parmnum, fndecl);
else
! cp_error ("%s to `%T' from `%T' discards qualifiers",
errtype, type, rhstype);
}
if (unsigned_parity > 0)
--- 6739,6748 ----
if (drops_quals)
{
if (fndecl)
! cp_pedwarn ("passing `%T' as argument %P of `%D' discards qualifiers",
! rhstype, parmnum, fndecl);
else
! cp_pedwarn ("%s to `%T' from `%T' discards qualifiers",
errtype, type, rhstype);
}
if (unsigned_parity > 0)