aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/semantics.c9
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/warn/Wreturn-type-7.C16
4 files changed, 34 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 19d4ecc..e88d64e 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2012-01-13 Jason Merrill <jason@redhat.com>
+ PR c++/20681
+ * semantics.c (finish_break_stmt): Avoid adding an unreachable
+ BREAK_STMT.
+
PR c++/51813
* decl2.c (constrain_visibility): Clear DECL_VISIBILITY_SPECIFIED
when reducing the visibility.
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 6f6f0ac..8c976eb 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -995,6 +995,15 @@ finish_range_for_decl (tree range_for_stmt, tree decl, tree expr)
tree
finish_break_stmt (void)
{
+ /* In switch statements break is sometimes stylistically used after
+ a return statement. This can lead to spurious warnings about
+ control reaching the end of a non-void function when it is
+ inlined. Note that we are calling block_may_fallthru with
+ language specific tree nodes; this works because
+ block_may_fallthru returns true when given something it does not
+ understand. */
+ if (!block_may_fallthru (cur_stmt_list))
+ return void_zero_node;
return add_stmt (build_stmt (input_location, BREAK_STMT));
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5c4ff69..a007b23 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2012-01-13 Jason Merrill <jason@redhat.com>
+
+ PR c++/20681
+ * g++.dg/warn/Wreturn-type-7.C: New.
+
2012-01-13 Georg-Johann Lay <avr@gjlay.de>
* gcc.c-torture/execute/20120111-1.c: Fix wrong int = int32_t
diff --git a/gcc/testsuite/g++.dg/warn/Wreturn-type-7.C b/gcc/testsuite/g++.dg/warn/Wreturn-type-7.C
new file mode 100644
index 0000000..62e34a5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wreturn-type-7.C
@@ -0,0 +1,16 @@
+// PR c++/20681
+// { dg-options -Wreturn-type }
+
+struct a{~a();a();};
+int GetMetaCombination (int a2)
+{
+ a bi;
+ switch (a2)
+ {
+ case 1:
+ return 18;
+ break;//removing this works around the warning
+ default:
+ return 0;
+ }
+}