diff mbox

Patch: aesthetics for gcc/cp/cxx-pretty-print.c

Message ID 4DEC38CC.1080006@gmail.com
State New
Headers show

Commit Message

Bruce Korb June 6, 2011, 2:17 a.m. UTC
It also caused a code analysis tool to wander off into the weeds.

2011-06-05  Bruce Korb  <bkorb@gnu.org>

	* gcc/cp/cxx-pretty-print.c (pp_cxx_decl_specifier_seq): Do not have a switch
	label pointing into an "else" clause for an "if".

Comments

Basile Starynkevitch June 6, 2011, 4:30 a.m. UTC | #1
On Sun, 05 Jun 2011 19:17:48 -0700
Bruce Korb <bruce.korb@gmail.com> wrote:

> It also caused a code analysis tool to wander off into the weeds.
> +      if (DECL_NONSTATIC_MEMBER_FUNCTION_P (t))
> +        pp_cxx_decl_specifier_seq (pp, TREE_TYPE (TREE_TYPE (t))), break;
> +      /* FALLTHROUGH */


I believe the usual GCC style is using braces, e.g

      if (DECL_NONSTATIC_MEMBER_FUNCTION_P (t))
        {
          pp_cxx_decl_specifier_seq (pp, TREE_TYPE (TREE_TYPE (t)));
          break;
        }
      /* FALLTHROUGH */
Paolo Bonzini June 7, 2011, 4:01 p.m. UTC | #2
On 06/06/2011 04:17 AM, Bruce Korb wrote:
> It also caused a code analysis tool to wander off into the weeds.

And "x, break;" didn't? :)

(First time I see it, I swear).

Paolo
diff mbox

Patch

Index: gcc/cp/cxx-pretty-print.c
===================================================================
--- gcc/cp/cxx-pretty-print.c	(revision 174678)
+++ gcc/cp/cxx-pretty-print.c	(working copy)
@@ -1199,13 +1199,16 @@ 

      case FUNCTION_DECL:
        /* Constructors don't have return types.  And conversion functions
-	 do not have a type-specifier in their return types.  */
+         do not have a type-specifier in their return types.  */
+
        if (DECL_CONSTRUCTOR_P (t) || DECL_CONV_FN_P (t))
-	pp_cxx_function_specifier (pp, t);
-      else if (DECL_NONSTATIC_MEMBER_FUNCTION_P (t))
-	pp_cxx_decl_specifier_seq (pp, TREE_TYPE (TREE_TYPE (t)));
-      else
-	default:
+        pp_cxx_function_specifier (pp, t), break;
+
+      if (DECL_NONSTATIC_MEMBER_FUNCTION_P (t))
+        pp_cxx_decl_specifier_seq (pp, TREE_TYPE (TREE_TYPE (t))), break;
+      /* FALLTHROUGH */
+
+    default:
        pp_c_declaration_specifiers (pp_c_base (pp), t);
        break;
      }