This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Implement -Wswitch-fallthrough: go


2016-07-11  Marek Polacek  <polacek@redhat.com>

	PR c/7652
	* go-system.h (go_fallthrough): New macro. 
	* gofrontend/escape.cc (Escape_analysis_assign::statement): Use it.
	(Escape_analysis_assign::assign): Likewise.
	* gofrontend/expressions.cc
	(Binary_expression::do_get_backend): Likewise.
	* gofrontend/lex.cc (Lex::next_token): Likewise.

diff --git gcc/gcc/go/go-system.h gcc/gcc/go/go-system.h
index cb7e745..e1b6a70 100644
--- gcc/gcc/go/go-system.h
+++ gcc/gcc/go/go-system.h
@@ -138,4 +138,7 @@ struct hash<T*>
 // When using gcc, go_unreachable is just gcc_unreachable.
 #define go_unreachable() gcc_unreachable()
 
+// When using gcc, go_fallthrough is just gcc_fallthrough.
+#define go_fallthrough() gcc_fallthrough()
+
 #endif // !defined(GO_SYSTEM_H)
diff --git gcc/gcc/go/gofrontend/escape.cc gcc/gcc/go/gofrontend/escape.cc
index 7a55818..f3d09e5 100644
--- gcc/gcc/go/gofrontend/escape.cc
+++ gcc/gcc/go/gofrontend/escape.cc
@@ -729,6 +729,7 @@ Escape_analysis_assign::statement(Block*, size_t*, Statement* s)
       if (this->context_->loop_depth() == 1)
 	break;
       // fallthrough
+      go_fallthrough ();
 
     case Statement::STATEMENT_GO:
       {
@@ -1483,6 +1484,7 @@ Escape_analysis_assign::assign(Node* dst, Node* src)
 	    // A non-pointer can't escape from a struct.
 	    if (!e->type()->has_pointer())
 	      break;
+	    go_fallthrough ();
 	  }
 
 	case Expression::EXPRESSION_CONVERSION:
diff --git gcc/gcc/go/gofrontend/expressions.cc gcc/gcc/go/gofrontend/expressions.cc
index 5f7e4c9..a13c997 100644
--- gcc/gcc/go/gofrontend/expressions.cc
+++ gcc/gcc/go/gofrontend/expressions.cc
@@ -5745,6 +5745,7 @@ Binary_expression::do_get_backend(Translate_context* context)
     case OPERATOR_DIV:
       if (left_type->float_type() != NULL || left_type->complex_type() != NULL)
         break;
+      go_fallthrough ();
     case OPERATOR_MOD:
       is_idiv_op = true;
       break;
@@ -5754,6 +5755,7 @@ Binary_expression::do_get_backend(Translate_context* context)
       break;
     case OPERATOR_BITCLEAR:
       this->right_ = Expression::make_unary(OPERATOR_XOR, this->right_, loc);
+      go_fallthrough ();
     case OPERATOR_AND:
       break;
     default:
diff --git gcc/gcc/go/gofrontend/lex.cc gcc/gcc/go/gofrontend/lex.cc
index 34a0811..4defad5 100644
--- gcc/gcc/go/gofrontend/lex.cc
+++ gcc/gcc/go/gofrontend/lex.cc
@@ -674,6 +674,7 @@ Lex::next_token()
 		    }
 		}
 	      // Fall through.
+	      go_fallthrough ();
 	    case '|':
 	    case '=':
 	    case '!':


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]