re PR c++/10032 (-pedantic converts some errors to warnings)
authorMark Mitchell <mark@codesourcery.com>
Thu, 10 Jul 2003 16:47:52 +0000 (16:47 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Thu, 10 Jul 2003 16:47:52 +0000 (16:47 +0000)
PR c++/10032
* doc/invoke.texi (C++ Dialect Options): Change documentation of
-fpermissive.

PR c++/10032
* decl.c (cxx_init_decl_processing): With -pedantic, pedwarns are
still errors.

PR c++/10527
* error.c (decl_to_string): Do not print default argument
expressions.

* cp-tree.h (break_out_calls): Remove declaration.
* tree.c (break_out_calls): Remove.
* typeck.c (build_modify_expr): Avoid invalid sharing of trees.

PR c++/10032
* g++.dg/warn/pedantic1.C: New test.

From-SVN: r69191

gcc/ChangeLog
gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/error.c
gcc/cp/tree.c
gcc/cp/typeck.c
gcc/doc/invoke.texi
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/pedantic1.C [new file with mode: 0644]

index 510512a061f0ff8a65896db6b757ed5a128af36d..be28a684dfd0cc69d1723f3f3cc4b643a2adad06 100644 (file)
@@ -1,3 +1,9 @@
+2003-07-09  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/10032
+       * doc/invoke.texi (C++ Dialect Options): Change documentation of
+       -fpermissive.
+
 2003-07-10  J"orn Rennecke <joern.rennecke@superh.com>
 
        * tm.texi (RETURN_ADDR_OFFSET): Document.
index 0f91172fcccc97c5ba0f93682c9d51cfdfded804..e91e535c18b164fedfdb8e16a5776f801e398dbe 100644 (file)
@@ -1,3 +1,17 @@
+2003-07-09  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/10032
+       * decl.c (cxx_init_decl_processing): With -pedantic, pedwarns are
+       still errors.
+
+       PR c++/10527
+       * error.c (decl_to_string): Do not print default argument
+       expressions.
+
+       * cp-tree.h (break_out_calls): Remove declaration.
+       * tree.c (break_out_calls): Remove.
+       * typeck.c (build_modify_expr): Avoid invalid sharing of trees.
+       
 2003-07-09  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++ 9483
index 58eabc3a396afb3d99d8ec03919fc8e65be834da..052c12ab09e0b7527b7e2e24d565ea9628712402 100644 (file)
@@ -4174,7 +4174,6 @@ extern tree build_min                             (enum tree_code, tree,
 extern tree build_min_nt                       (enum tree_code, ...);
 extern tree build_cplus_new                    (tree, tree);
 extern tree get_target_expr                    (tree);
-extern tree break_out_calls                    (tree);
 extern tree build_cplus_method_type            (tree, tree, tree);
 extern tree build_cplus_staticfn_type          (tree, tree, tree);
 extern tree build_cplus_array_type             (tree, tree);
index 8ed521341d4ab43c0ff9d72aff0fe20ca1987fa9..966da3ca704acea35bdd9d3980ffa7f5f3217936 100644 (file)
@@ -6213,7 +6213,7 @@ cxx_init_decl_processing (void)
   current_lang_name = NULL_TREE;
 
   /* Adjust various flags based on command-line settings.  */
-  if (! flag_permissive && ! pedantic)
+  if (!flag_permissive)
     flag_pedantic_errors = 1;
   if (!flag_no_inline)
     {
index 79803d2dfff91ed38ad13b59088a0d565f82a6ec..9edf118eee985a5cc12291936a148881f0abb750 100644 (file)
@@ -2169,7 +2169,7 @@ decl_to_string (tree decl, int verbose)
       || TREE_CODE (decl) == UNION_TYPE || TREE_CODE (decl) == ENUMERAL_TYPE)
     flags = TFF_CLASS_KEY_OR_ENUM;
   if (verbose)
-    flags |= TFF_DECL_SPECIFIERS | TFF_FUNCTION_DEFAULT_ARGUMENTS;
+    flags |= TFF_DECL_SPECIFIERS;
   else if (TREE_CODE (decl) == FUNCTION_DECL)
     flags |= TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE;
   flags |= TFF_TEMPLATE_HEADER;
index 366ea3ab01a88e89a3c945d91a7b7e374a241735..7f137343686bcec96f4db6a9d57d10a01822c60d 100644 (file)
@@ -368,86 +368,6 @@ get_target_expr (tree init)
   return build_target_expr_with_type (init, TREE_TYPE (init));
 }
 
-/* Recursively perform a preorder search EXP for CALL_EXPRs, making
-   copies where they are found.  Returns a deep copy all nodes transitively
-   containing CALL_EXPRs.  */
-
-tree
-break_out_calls (tree exp)
-{
-  register tree t1, t2 = NULL_TREE;
-  register enum tree_code code;
-  register int changed = 0;
-  register int i;
-
-  if (exp == NULL_TREE)
-    return exp;
-
-  code = TREE_CODE (exp);
-
-  if (code == CALL_EXPR)
-    return copy_node (exp);
-
-  /* Don't try and defeat a save_expr, as it should only be done once.  */
-    if (code == SAVE_EXPR)
-       return exp;
-
-  switch (TREE_CODE_CLASS (code))
-    {
-    default:
-      abort ();
-
-    case 'c':  /* a constant */
-    case 't':  /* a type node */
-    case 'x':  /* something random, like an identifier or an ERROR_MARK.  */
-      return exp;
-
-    case 'd':  /* A decl node */
-      return exp;
-
-    case 'b':  /* A block node */
-      {
-       /* Don't know how to handle these correctly yet.   Must do a
-          break_out_calls on all DECL_INITIAL values for local variables,
-          and also break_out_calls on all sub-blocks and sub-statements.  */
-       abort ();
-      }
-      return exp;
-
-    case 'e':  /* an expression */
-    case 'r':  /* a reference */
-    case 's':  /* an expression with side effects */
-      for (i = TREE_CODE_LENGTH (code) - 1; i >= 0; i--)
-       {
-         t1 = break_out_calls (TREE_OPERAND (exp, i));
-         if (t1 != TREE_OPERAND (exp, i))
-           {
-             exp = copy_node (exp);
-             TREE_OPERAND (exp, i) = t1;
-           }
-       }
-      return exp;
-
-    case '<':  /* a comparison expression */
-    case '2':  /* a binary arithmetic expression */
-      t2 = break_out_calls (TREE_OPERAND (exp, 1));
-      if (t2 != TREE_OPERAND (exp, 1))
-       changed = 1;
-    case '1':  /* a unary arithmetic expression */
-      t1 = break_out_calls (TREE_OPERAND (exp, 0));
-      if (t1 != TREE_OPERAND (exp, 0))
-       changed = 1;
-      if (changed)
-       {
-         if (TREE_CODE_LENGTH (code) == 1)
-           return build1 (code, TREE_TYPE (exp), t1);
-         else
-           return build (code, TREE_TYPE (exp), t1, t2);
-       }
-      return exp;
-    }
-
-}
 \f
 /* Construct, lay out and return the type of methods belonging to class
    BASETYPE and whose arguments are described by ARGTYPES and whose values
index 189bda2dd35c256723d73dc122ad38497ab9eee2..58055eca08b5155dd593e42fa9dae014af99e435 100644 (file)
@@ -5399,44 +5399,8 @@ build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs)
   if (newrhs == error_mark_node)
     return error_mark_node;
 
-  if (TREE_CODE (newrhs) == COND_EXPR)
-    {
-      tree lhs1;
-      tree cond = TREE_OPERAND (newrhs, 0);
-
-      if (TREE_SIDE_EFFECTS (lhs))
-       cond = build_compound_expr (tree_cons
-                                   (NULL_TREE, lhs,
-                                    build_tree_list (NULL_TREE, cond)));
-
-      /* Cannot have two identical lhs on this one tree (result) as preexpand
-        calls will rip them out and fill in RTL for them, but when the
-        rtl is generated, the calls will only be in the first side of the
-        condition, not on both, or before the conditional jump! (mrs) */
-      lhs1 = break_out_calls (lhs);
-
-      if (lhs == lhs1)
-       /* If there's no change, the COND_EXPR behaves like any other rhs.  */
-       result = build (modifycode == NOP_EXPR ? MODIFY_EXPR : INIT_EXPR,
-                       lhstype, lhs, newrhs);
-      else
-       {
-         tree result_type = TREE_TYPE (newrhs);
-         /* We have to convert each arm to the proper type because the
-            types may have been munged by constant folding.  */
-         result
-           = build (COND_EXPR, result_type, cond,
-                    build_modify_expr (lhs, modifycode,
-                                       cp_convert (result_type,
-                                                   TREE_OPERAND (newrhs, 1))),
-                    build_modify_expr (lhs1, modifycode,
-                                       cp_convert (result_type,
-                                                   TREE_OPERAND (newrhs, 2))));
-       }
-    }
-  else
-    result = build (modifycode == NOP_EXPR ? MODIFY_EXPR : INIT_EXPR,
-                   lhstype, lhs, newrhs);
+  result = build (modifycode == NOP_EXPR ? MODIFY_EXPR : INIT_EXPR,
+                 lhstype, lhs, newrhs);
 
   TREE_SIDE_EFFECTS (result) = 1;
 
index bd49134720387e812ada38347268d982f3240056..83c2354d151cc7c9a74ab302f0afd830ed2ba8b6 100644 (file)
@@ -1414,10 +1414,9 @@ a name having multiple meanings within a class.
 
 @item -fpermissive
 @opindex fpermissive
-Downgrade messages about nonconformant code from errors to warnings.  By
-default, G++ effectively sets @option{-pedantic-errors} without
-@option{-pedantic}; this option reverses that.  This behavior and this
-option are superseded by @option{-pedantic}, which works as it does for GNU C@.
+Downgrade some diagnostics about nonconformant code from errors to
+warnings.  Thus, using @option{-fpermissive} will allow some
+nonconforming code to compile.
 
 @item -frepo
 @opindex frepo
index 491e8b4f382d84e803267e043f360b9ee96b89ac..100c0edf7c9d21833cfdd023a672a74a444a09c4 100644 (file)
@@ -1,3 +1,8 @@
+2003-07-10  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/10032
+       * g++.dg/warn/pedantic1.C: New test.
+
 2003-07-10  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++ 9483
diff --git a/gcc/testsuite/g++.dg/warn/pedantic1.C b/gcc/testsuite/g++.dg/warn/pedantic1.C
new file mode 100644 (file)
index 0000000..2a4d055
--- /dev/null
@@ -0,0 +1,11 @@
+// PR10032
+// { dg-options "-pedantic" }
+
+int main() {
+  goto label;   // { dg-error "" }
+  
+  int temp = 1; // { dg-error "" } 
+  
+  label:        // { dg-error "" } 
+    return 1;
+}