public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][RFC] Instrument function exit with __builtin_unreachable in C++.
@ 2017-10-05 10:32 Martin Liška
  2017-10-05 11:04 ` Jakub Jelinek
  2017-10-05 15:08 ` Jason Merrill
  0 siblings, 2 replies; 64+ messages in thread
From: Martin Liška @ 2017-10-05 10:32 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jakub Jelinek, Jonathan Wakely

[-- Attachment #1: Type: text/plain, Size: 5965 bytes --]

Hello.

As discussed 2 days ago on IRC with Jakub and Jonathan, C++ standard says that having a non-return
function with missing return statement is undefined behavior. We've got -fsanitize=return check for
that and we can in such case instrument __builtin_unreachable(). This patch does that. It produces quite
some fallout in test-suite.

And there's still some fallout:

FAIL: g++.dg/cpp0x/constexpr-diag3.C  -std=c++11  (test for errors, line 7)
FAIL: g++.dg/cpp0x/constexpr-neg3.C  -std=c++11  (test for errors, line 12)
FAIL: g++.dg/cpp1y/constexpr-return2.C  -std=c++14  (test for errors, line 7)
FAIL: g++.dg/cpp1y/constexpr-return2.C  -std=c++14 (test for excess errors)
FAIL: g++.dg/cpp1y/pr63996.C  -std=c++14  (test for errors, line 9)
FAIL: g++.dg/cpp1y/pr63996.C  -std=c++14 (test for excess errors)

1) there are causing:

./xg++ -B. /home/marxin/Programming/gcc/gcc/testsuite/g++.dg/cpp1y/pr63996.C
/home/marxin/Programming/gcc/gcc/testsuite/g++.dg/cpp1y/pr63996.C:9:23:   in constexpr expansion of ‘foo(1)’
/home/marxin/Programming/gcc/gcc/testsuite/g++.dg/cpp1y/pr63996.C:4:1: error: ‘__builtin_unreachable()’ is not a constant expression
 foo (int i)
 ^~~

Where we probably should not emit the built-in call. Am I right?

FAIL: g++.dg/torture/pr34850.C   -O1   (test for warnings, line 15)
FAIL: g++.dg/torture/pr34850.C   -O2   (test for warnings, line 15)
FAIL: g++.dg/torture/pr34850.C   -O2 -flto -fno-use-linker-plugin -flto-partition=none   (test for warnings, line 15)
FAIL: g++.dg/torture/pr34850.C   -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects   (test for warnings, line 15)
FAIL: g++.dg/torture/pr34850.C   -O3 -g   (test for warnings, line 15)
FAIL: g++.dg/torture/pr34850.C   -Os   (test for warnings, line 15)

2) this test is somehow hard to fix as it requires some unreachability.

Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.

Thoughts?
Martin

gcc/cp/ChangeLog:

2017-10-05  Martin Liska  <mliska@suse.cz>

	PR middle-end/82404
	* cp-gimplify.c (cp_ubsan_maybe_instrument_return): Remove as
	renamed to ...
	(cp_maybe_instrument_return): ... this.
	(cp_genericize): Update call of the function.

gcc/testsuite/ChangeLog:

2017-10-05  Martin Liska  <mliska@suse.cz>

	PR middle-end/82404
	* c-c++-common/dfp/call-by-value.c (foo32): Change return value
	to void.
	(foo64): Likewise.
	(foo128): Likewise.
	* g++.dg/bprob/g++-bprob-1.C: Likewise.
	* g++.dg/cpp0x/lambda/lambda-template.C (f): Likewise.
	* g++.dg/cpp0x/range-for6.C (foo): Return a value.
	* g++.dg/cpp0x/udlit-template.C: Change return value
	to void.
	* g++.dg/cpp1z/eval-order3.C (struct A): Return a value.
	(operator>>): Likewise.
	* g++.dg/expr/cond12.C (struct X): Return a value.
	(X::operator=): Likewise.
	* g++.dg/gcov/gcov-1.C: Change return value
	to void.
	* g++.dg/gcov/gcov-threads-1.C (ContentionNoDeadlock_thread):
	Return a value.
	* g++.dg/ipa/devirt-21.C: Likewise.
	* g++.dg/ipa/devirt-23.C: Likewise.
	* g++.dg/ipa/devirt-34.C (t): Likewise.
	* g++.dg/opt/20050511-1.C (bar): Likewise.
	* g++.dg/opt/const3.C (A::foo1): Likewise.
	(A::foo2): Likewise.
	* g++.dg/opt/pr23299.C (E::c): Likewise.
	* g++.dg/other/copy2.C (A::operator=): Likewise.
	* g++.dg/overload/addr1.C: Likewise.
	* g++.dg/pr48484.C: Likewise.
	* g++.dg/tls/thread_local3.C (thread_main): Likewise.
	* g++.dg/tls/thread_local3g.C (thread_main): Likewise.
	* g++.dg/tls/thread_local5.C (thread_main): Likewise.
	* g++.dg/tls/thread_local5g.C (thread_main): Likewise.
	* g++.dg/tls/thread_local6.C (thread_main): Likewise.
	* g++.dg/tls/thread_local6g.C (thread_main): Likewise.
	* g++.dg/torture/pr34850.C (OctetString::operator^=): Likewise.
	* g++.dg/tree-prof/pr79259.C (fn2): Likewise.
	* g++.dg/tree-ssa/pr33604.C (struct Value): Likewise.
	* g++.dg/tree-ssa/pr81408.C (struct p): Likewise.
	(av): Likewise.
	* g++.dg/warn/string1.C (test): Likewise.
---
 gcc/cp/cp-gimplify.c                                | 18 ++++++++++++------
 gcc/testsuite/c-c++-common/dfp/call-by-value.c      |  6 +++---
 gcc/testsuite/g++.dg/bprob/g++-bprob-1.C            |  2 +-
 gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template.C |  2 +-
 gcc/testsuite/g++.dg/cpp0x/range-for6.C             |  2 ++
 gcc/testsuite/g++.dg/cpp0x/udlit-template.C         |  2 +-
 gcc/testsuite/g++.dg/cpp1z/eval-order3.C            |  4 ++--
 gcc/testsuite/g++.dg/expr/cond12.C                  |  8 +++++++-
 gcc/testsuite/g++.dg/gcov/gcov-1.C                  |  2 +-
 gcc/testsuite/g++.dg/gcov/gcov-threads-1.C          |  2 ++
 gcc/testsuite/g++.dg/ipa/devirt-21.C                |  2 +-
 gcc/testsuite/g++.dg/ipa/devirt-23.C                |  2 +-
 gcc/testsuite/g++.dg/ipa/devirt-34.C                |  2 ++
 gcc/testsuite/g++.dg/missing-return.C               |  8 ++++++++
 gcc/testsuite/g++.dg/opt/20050511-1.C               |  2 ++
 gcc/testsuite/g++.dg/opt/const3.C                   |  4 ++--
 gcc/testsuite/g++.dg/opt/pr23299.C                  |  2 ++
 gcc/testsuite/g++.dg/other/copy2.C                  | 10 +++++++---
 gcc/testsuite/g++.dg/overload/addr1.C               |  2 +-
 gcc/testsuite/g++.dg/pr48484.C                      |  3 +++
 gcc/testsuite/g++.dg/tls/thread_local3.C            |  1 +
 gcc/testsuite/g++.dg/tls/thread_local3g.C           |  1 +
 gcc/testsuite/g++.dg/tls/thread_local5.C            |  1 +
 gcc/testsuite/g++.dg/tls/thread_local5g.C           |  1 +
 gcc/testsuite/g++.dg/tls/thread_local6.C            |  1 +
 gcc/testsuite/g++.dg/tls/thread_local6g.C           |  1 +
 gcc/testsuite/g++.dg/torture/pr34850.C              |  6 ++++++
 gcc/testsuite/g++.dg/tree-prof/pr79259.C            |  2 ++
 gcc/testsuite/g++.dg/tree-ssa/pr33604.C             |  2 +-
 gcc/testsuite/g++.dg/tree-ssa/pr81408.C             | 12 ++++++------
 gcc/testsuite/g++.dg/warn/string1.C                 |  2 ++
 31 files changed, 84 insertions(+), 31 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/missing-return.C



[-- Attachment #2: 0001-Instrument-function-exit-with-__builtin_unreachable-.patch --]
[-- Type: text/x-patch, Size: 15123 bytes --]

diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index 262485a5c1f..0bf8f567d5b 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -1556,10 +1556,11 @@ cp_genericize_tree (tree* t_p, bool handle_invisiref_parm_p)
 
 /* If a function that should end with a return in non-void
    function doesn't obviously end with return, add ubsan
-   instrumentation code to verify it at runtime.  */
+   instrumentation code to verify it at runtime.  If -fsanitize=return
+   is not enabled, instrument __builtin_unreachable.  */
 
 static void
-cp_ubsan_maybe_instrument_return (tree fndecl)
+cp_maybe_instrument_return (tree fndecl)
 {
   if (VOID_TYPE_P (TREE_TYPE (TREE_TYPE (fndecl)))
       || DECL_CONSTRUCTOR_P (fndecl)
@@ -1600,7 +1601,14 @@ cp_ubsan_maybe_instrument_return (tree fndecl)
   tree *p = &DECL_SAVED_TREE (fndecl);
   if (TREE_CODE (*p) == BIND_EXPR)
     p = &BIND_EXPR_BODY (*p);
-  t = ubsan_instrument_return (DECL_SOURCE_LOCATION (fndecl));
+
+  location_t loc = DECL_SOURCE_LOCATION (fndecl);
+  if (sanitize_flags_p (SANITIZE_RETURN, fndecl))
+    t = ubsan_instrument_return (loc);
+  else
+    t = build_call_expr_loc (loc, builtin_decl_explicit (BUILT_IN_UNREACHABLE),
+			     0);
+
   append_to_statement_list (t, p);
 }
 
@@ -1674,9 +1682,7 @@ cp_genericize (tree fndecl)
      walk_tree's hash functionality.  */
   cp_genericize_tree (&DECL_SAVED_TREE (fndecl), true);
 
-  if (sanitize_flags_p (SANITIZE_RETURN)
-      && current_function_decl != NULL_TREE)
-    cp_ubsan_maybe_instrument_return (fndecl);
+  cp_maybe_instrument_return (fndecl);
 
   /* Do everything else.  */
   c_genericize (fndecl);
diff --git a/gcc/testsuite/c-c++-common/dfp/call-by-value.c b/gcc/testsuite/c-c++-common/dfp/call-by-value.c
index 74aec53aefb..e7aea3076cf 100644
--- a/gcc/testsuite/c-c++-common/dfp/call-by-value.c
+++ b/gcc/testsuite/c-c++-common/dfp/call-by-value.c
@@ -5,17 +5,17 @@
 
 #include "dfp-dbg.h"
 
-int foo32 (_Decimal32 z)
+void foo32 (_Decimal32 z)
 {
   z = z + 1.0df;
 }
 
-int foo64 (_Decimal64 z)
+void foo64 (_Decimal64 z)
 {
   z = z + 1.0dd;
 }
 
-int foo128 (_Decimal128 z)
+void foo128 (_Decimal128 z)
 {
   z = z + 1.0dl;
 }
diff --git a/gcc/testsuite/g++.dg/bprob/g++-bprob-1.C b/gcc/testsuite/g++.dg/bprob/g++-bprob-1.C
index b1a1de77e98..3aafc06d51d 100644
--- a/gcc/testsuite/g++.dg/bprob/g++-bprob-1.C
+++ b/gcc/testsuite/g++.dg/bprob/g++-bprob-1.C
@@ -35,7 +35,7 @@ test_for2 (int m, int n, int o)
   return for_temp;			/* count(6) */
 }
 
-int
+void
 call_for ()
 {
   for_val1 += test_for1 (0);
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template.C
index 66cc7a4e1df..17c6a6e5b52 100644
--- a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template.C
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template.C
@@ -9,7 +9,7 @@ auto apply (T t) -> decltype (t())
 }
 
 template <class T>
-T f(T t)
+void f(T t)
 {
   T t2 = t;
   if (t != [=]()->T { return t; }())
diff --git a/gcc/testsuite/g++.dg/cpp0x/range-for6.C b/gcc/testsuite/g++.dg/cpp0x/range-for6.C
index 366499a34d8..b4d9dd720ee 100644
--- a/gcc/testsuite/g++.dg/cpp0x/range-for6.C
+++ b/gcc/testsuite/g++.dg/cpp0x/range-for6.C
@@ -14,6 +14,8 @@ template<typename T> T foo()
         sum += x;
     if (sum != T(10))
         abort();
+
+    return sum;
 }
 
 int main()
diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-template.C b/gcc/testsuite/g++.dg/cpp0x/udlit-template.C
index de21b66028f..15583199297 100644
--- a/gcc/testsuite/g++.dg/cpp0x/udlit-template.C
+++ b/gcc/testsuite/g++.dg/cpp0x/udlit-template.C
@@ -23,7 +23,7 @@ template<>
   operator"" _abc<'6','6','6'>()
   { return 21; }
 
-int
+void
 test1()
 {
   int i = operator"" _abc<'1','2','3'>();
diff --git a/gcc/testsuite/g++.dg/cpp1z/eval-order3.C b/gcc/testsuite/g++.dg/cpp1z/eval-order3.C
index 966ac0a6523..b53e96a9f8f 100644
--- a/gcc/testsuite/g++.dg/cpp1z/eval-order3.C
+++ b/gcc/testsuite/g++.dg/cpp1z/eval-order3.C
@@ -26,7 +26,7 @@ struct A
   int _i;
   A(int i): _i(f(i)) { }
   A& memfn(int i, int j) { f(j); return *this; }
-  int operator<<(int i) { }
+  int operator<<(int i) { return 0; }
   A& operator=(const A&) { return *this; }
   A& operator+=(int i) { return *this; }
 };
@@ -38,7 +38,7 @@ struct B
   B(int i): _i(f(i)) { }
 };
 
-int operator>>(A&, int i) { }
+int operator>>(A&, int i) { return 0; }
 
 A a(0);
 A* afn(int i)
diff --git a/gcc/testsuite/g++.dg/expr/cond12.C b/gcc/testsuite/g++.dg/expr/cond12.C
index 9134f81668f..90d77dbd708 100644
--- a/gcc/testsuite/g++.dg/expr/cond12.C
+++ b/gcc/testsuite/g++.dg/expr/cond12.C
@@ -2,10 +2,16 @@
 // { dg-do run }
 
 struct X {
-    X& operator=(const X&){}
+    X& operator=(const X&);
     X& operator=(X&){__builtin_abort();}
 };
 
+X g;
+X& X::operator=(const X&)
+{
+  return g;
+}
+
 int main(int argv,char**) {
   X a, b;
   ((argv > 2) ? a : b) = X();
diff --git a/gcc/testsuite/g++.dg/gcov/gcov-1.C b/gcc/testsuite/g++.dg/gcov/gcov-1.C
index c279b1452fc..9018b9a3a73 100644
--- a/gcc/testsuite/g++.dg/gcov/gcov-1.C
+++ b/gcc/testsuite/g++.dg/gcov/gcov-1.C
@@ -74,7 +74,7 @@ test_for2 (int m, int n, int o)
   return for_temp;			/* count(6) */
 }
 
-int
+void
 call_for ()
 {
   for_val1 += test_for1 (0);
diff --git a/gcc/testsuite/g++.dg/gcov/gcov-threads-1.C b/gcc/testsuite/g++.dg/gcov/gcov-threads-1.C
index cc9266ab8ea..eb558614c18 100644
--- a/gcc/testsuite/g++.dg/gcov/gcov-threads-1.C
+++ b/gcc/testsuite/g++.dg/gcov/gcov-threads-1.C
@@ -19,6 +19,8 @@ static void *ContentionNoDeadlock_thread(void *start)
       for (int32_t i = NR - 1; i >= starti; --i)
 	pthread_mutex_unlock (&cndMs[i]);
   }
+
+  return 0;
 }
 int main(int argc, char **argv) {
   for (unsigned i = 0; i < NR; i++)
diff --git a/gcc/testsuite/g++.dg/ipa/devirt-21.C b/gcc/testsuite/g++.dg/ipa/devirt-21.C
index a33be4eca04..440570c8ddb 100644
--- a/gcc/testsuite/g++.dg/ipa/devirt-21.C
+++ b/gcc/testsuite/g++.dg/ipa/devirt-21.C
@@ -12,7 +12,7 @@ class MultiTermDocs : public virtual B {
 protected:
   A readerTermDocs;
   A subReaders;
-  virtual B *m_fn1(int *) {}
+  virtual B *m_fn1(int *) { return NULL; }
   virtual inline  ~MultiTermDocs();
   void wrap(void)
   {
diff --git a/gcc/testsuite/g++.dg/ipa/devirt-23.C b/gcc/testsuite/g++.dg/ipa/devirt-23.C
index 665e953cae7..76fc3fde42b 100644
--- a/gcc/testsuite/g++.dg/ipa/devirt-23.C
+++ b/gcc/testsuite/g++.dg/ipa/devirt-23.C
@@ -12,7 +12,7 @@ class MultiTermDocs : public virtual B {
 protected:
   A readerTermDocs;
   A subReaders;
-  virtual B *m_fn1(int *) {}
+  virtual B *m_fn1(int *) { return NULL; }
   virtual inline  ~MultiTermDocs();
   inline void wrap(void)
   {
diff --git a/gcc/testsuite/g++.dg/ipa/devirt-34.C b/gcc/testsuite/g++.dg/ipa/devirt-34.C
index 030e08bba8a..083c305665f 100644
--- a/gcc/testsuite/g++.dg/ipa/devirt-34.C
+++ b/gcc/testsuite/g++.dg/ipa/devirt-34.C
@@ -10,6 +10,8 @@ t(struct B *b)
 {
   struct A *a=b;
   a->t();
+
+  return 0;
 }
 
 /* We should guess that the pointer of type B probably points to an instance
diff --git a/gcc/testsuite/g++.dg/missing-return.C b/gcc/testsuite/g++.dg/missing-return.C
new file mode 100644
index 00000000000..f7fcfebb2b4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/missing-return.C
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-Wreturn-type -fdump-tree-optimized" } */
+
+int foo(int a)
+{
+} /* { dg-warning "no return statement" } */
+
+/* { dg-final { scan-tree-dump "__builtin_unreachable" "optimized" } } */
diff --git a/gcc/testsuite/g++.dg/opt/20050511-1.C b/gcc/testsuite/g++.dg/opt/20050511-1.C
index a8929030af4..a840fb0db8e 100644
--- a/gcc/testsuite/g++.dg/opt/20050511-1.C
+++ b/gcc/testsuite/g++.dg/opt/20050511-1.C
@@ -53,6 +53,8 @@ UINT32 bar (const C * sPtr)
 
   if (a.xy[0] != ((SINT16) 0xffff << 2))
 	abort ();
+
+  return 0;
 }
 
 int main()
diff --git a/gcc/testsuite/g++.dg/opt/const3.C b/gcc/testsuite/g++.dg/opt/const3.C
index c7c0a1645de..969df91e6e1 100644
--- a/gcc/testsuite/g++.dg/opt/const3.C
+++ b/gcc/testsuite/g++.dg/opt/const3.C
@@ -30,8 +30,8 @@ struct A
 
 int i;
 
-int A::foo1(void *ios, const char *str) { }
-int A::foo2(int v, const Type t) { i=0; }
+int A::foo1(void *ios, const char *str) { return 0; }
+int A::foo2(int v, const Type t) { i=0; return 0; }
 
 int main()
 {
diff --git a/gcc/testsuite/g++.dg/opt/pr23299.C b/gcc/testsuite/g++.dg/opt/pr23299.C
index 94a414aa5f7..b791bf954e8 100644
--- a/gcc/testsuite/g++.dg/opt/pr23299.C
+++ b/gcc/testsuite/g++.dg/opt/pr23299.C
@@ -50,6 +50,8 @@ E::c ()
   if (x > 10)
     throw 1;
   x |= 2;
+
+  return x;
 }
 
 int
diff --git a/gcc/testsuite/g++.dg/other/copy2.C b/gcc/testsuite/g++.dg/other/copy2.C
index 335cab8d19f..df480f06ecc 100644
--- a/gcc/testsuite/g++.dg/other/copy2.C
+++ b/gcc/testsuite/g++.dg/other/copy2.C
@@ -10,11 +10,15 @@ class A
 {
 public:
   int i;
-  A &operator =(const A &i)
-  {
+  A &operator =(const A &i);
+};
+
+A a;
+
+A& A::operator=(const A &i)  {
     status = 0;
+    return a;
   }
-};
 
 class B
 {
diff --git a/gcc/testsuite/g++.dg/overload/addr1.C b/gcc/testsuite/g++.dg/overload/addr1.C
index 25856a20fc6..4eb9e2f31ca 100644
--- a/gcc/testsuite/g++.dg/overload/addr1.C
+++ b/gcc/testsuite/g++.dg/overload/addr1.C
@@ -11,7 +11,7 @@ static int flag = 0;
 
 template <typename> struct A
 {
-  A &active ()  { flag++;}
+  A &active () { flag++; static A a; return a; }
   
   static void foo() {}
 
diff --git a/gcc/testsuite/g++.dg/pr48484.C b/gcc/testsuite/g++.dg/pr48484.C
index 1380c452fa4..19e9b9a8d0a 100644
--- a/gcc/testsuite/g++.dg/pr48484.C
+++ b/gcc/testsuite/g++.dg/pr48484.C
@@ -65,6 +65,8 @@ bool
 	jump = 0;
       }
     }
+
+  return false;
 }
 
 bool
@@ -102,4 +104,5 @@ bool
 	}
     }
 
+  return true;
 }
diff --git a/gcc/testsuite/g++.dg/tls/thread_local3.C b/gcc/testsuite/g++.dg/tls/thread_local3.C
index e05a0b95306..d29bda1a000 100644
--- a/gcc/testsuite/g++.dg/tls/thread_local3.C
+++ b/gcc/testsuite/g++.dg/tls/thread_local3.C
@@ -21,6 +21,7 @@ void f()
 void *thread_main(void *)
 {
   f(); f(); f();
+  return 0;
 }
 
 #include <pthread.h>
diff --git a/gcc/testsuite/g++.dg/tls/thread_local3g.C b/gcc/testsuite/g++.dg/tls/thread_local3g.C
index a3c9ebcc2c5..2f9fdee1a73 100644
--- a/gcc/testsuite/g++.dg/tls/thread_local3g.C
+++ b/gcc/testsuite/g++.dg/tls/thread_local3g.C
@@ -19,6 +19,7 @@ thread_local A a;
 void *thread_main(void *)
 {
   A* ap = &a;
+  return 0;
 }
 
 #include <pthread.h>
diff --git a/gcc/testsuite/g++.dg/tls/thread_local5.C b/gcc/testsuite/g++.dg/tls/thread_local5.C
index c4d5ff01bf5..61fea722dc2 100644
--- a/gcc/testsuite/g++.dg/tls/thread_local5.C
+++ b/gcc/testsuite/g++.dg/tls/thread_local5.C
@@ -30,6 +30,7 @@ void f()
 void *thread_main(void *)
 {
   f(); f(); f();
+  return 0;
 }
 
 int main()
diff --git a/gcc/testsuite/g++.dg/tls/thread_local5g.C b/gcc/testsuite/g++.dg/tls/thread_local5g.C
index 5ced551fb57..596bbbe542f 100644
--- a/gcc/testsuite/g++.dg/tls/thread_local5g.C
+++ b/gcc/testsuite/g++.dg/tls/thread_local5g.C
@@ -28,6 +28,7 @@ thread_local A a;
 void *thread_main(void *)
 {
   A* ap = &a;
+  return 0;
 }
 
 int main()
diff --git a/gcc/testsuite/g++.dg/tls/thread_local6.C b/gcc/testsuite/g++.dg/tls/thread_local6.C
index 2810efaea93..0009726626b 100644
--- a/gcc/testsuite/g++.dg/tls/thread_local6.C
+++ b/gcc/testsuite/g++.dg/tls/thread_local6.C
@@ -22,6 +22,7 @@ void f()
 void *thread_main(void *)
 {
   f(); f(); f();
+  return 0;
 }
 
 int main()
diff --git a/gcc/testsuite/g++.dg/tls/thread_local6g.C b/gcc/testsuite/g++.dg/tls/thread_local6g.C
index b8f9cdf1dea..d357ca4fa1f 100644
--- a/gcc/testsuite/g++.dg/tls/thread_local6g.C
+++ b/gcc/testsuite/g++.dg/tls/thread_local6g.C
@@ -20,6 +20,7 @@ thread_local A a;
 void *thread_main(void *)
 {
   A* ap = &a;
+  return 0;
 }
 
 int main()
diff --git a/gcc/testsuite/g++.dg/torture/pr34850.C b/gcc/testsuite/g++.dg/torture/pr34850.C
index c33dbfb5c93..c2538288964 100644
--- a/gcc/testsuite/g++.dg/torture/pr34850.C
+++ b/gcc/testsuite/g++.dg/torture/pr34850.C
@@ -13,6 +13,8 @@ extern "C" {
     void * memset (void *__dest, int __ch, size_t __len) throw () {
 	if (__builtin_constant_p (__len) && __len == 0)
 	    __warn_memset_zero_len (); /* { dg-warning "declared with attribute warning" } */
+
+	return __dest;
     }
 }
 inline void clear_mem(void* ptr, u32bit n)    {
@@ -50,11 +52,13 @@ template<typename T> class SecureVector : public MemoryRegion<T>    {
 public:
     SecureVector<T>& operator=(const MemoryRegion<T>& in)          {
 	if(this != &in) this->set(in);
+	return *this;
     }
 };
 class OctetString    {
 public:
     SecureVector<byte> bits_of() const {
+	return SecureVector<byte> ();
     }
     OctetString& operator^=(const OctetString&);
     void change(const MemoryRegion<byte>& in) {
@@ -69,6 +73,8 @@ OctetString& OctetString::operator^=(const OctetString& k)    {
     if(&k == this) {
 	bits.clear();
     }
+
+    return *this;
 }
 bool __attribute__((flatten))
 operator==(const OctetString& s1, const OctetString& s2)    {
diff --git a/gcc/testsuite/g++.dg/tree-prof/pr79259.C b/gcc/testsuite/g++.dg/tree-prof/pr79259.C
index a55172b62d2..6125a179bdc 100644
--- a/gcc/testsuite/g++.dg/tree-prof/pr79259.C
+++ b/gcc/testsuite/g++.dg/tree-prof/pr79259.C
@@ -11,6 +11,8 @@ fn2 ()
 {
   if (a (c == 0))
     return 0;
+
+  return 0;
 }
 
 int main()
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr33604.C b/gcc/testsuite/g++.dg/tree-ssa/pr33604.C
index 1c0f550bfdf..668db49d146 100644
--- a/gcc/testsuite/g++.dg/tree-ssa/pr33604.C
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr33604.C
@@ -6,7 +6,7 @@ struct Value
   double value;
   Value(double value_) : value (value_) {}
   operator double() const { return value; }
-  Value& operator=(double other) { value = other; }
+  Value& operator=(double other) { value = other; return *this; }
 };
 
 struct Ref
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr81408.C b/gcc/testsuite/g++.dg/tree-ssa/pr81408.C
index f94544b9e2d..60e6e5277d7 100644
--- a/gcc/testsuite/g++.dg/tree-ssa/pr81408.C
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr81408.C
@@ -1,5 +1,9 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -std=gnu++11 -fopt-info-loop-missed -Wunsafe-loop-optimizations" } */
+struct p
+{
+  char *ay;
+};
 
 namespace a {
 void b () __attribute__ ((__noreturn__));
@@ -19,7 +23,7 @@ template <typename j, typename> class k
   j l;
 
 public:
-  typename d<j>::f operator* () {}
+  typename d<j>::f operator* () { return p(); }
   void operator++ () { ++l; }
   j
   aa ()
@@ -33,7 +37,6 @@ operator!= (k<m, ab> o, k<n, ab> p2)
 {
   return o.aa () != p2.aa ();
 }
-struct p;
 namespace a {
 struct F
 {
@@ -75,13 +78,10 @@ at
 av (au o)
 {
   o.aq ('\n');
+  return at();
 }
 u ax;
 }
-struct p
-{
-  char *ay;
-};
 a::H t;
 void
 ShowHelpListCommands ()
diff --git a/gcc/testsuite/g++.dg/warn/string1.C b/gcc/testsuite/g++.dg/warn/string1.C
index 2670f63d931..8f24a78f709 100644
--- a/gcc/testsuite/g++.dg/warn/string1.C
+++ b/gcc/testsuite/g++.dg/warn/string1.C
@@ -15,4 +15,6 @@ int test() {
   //
   std::string s = "";
   s += 'x' + "y";	      // { dg-warning "bounds of constant string" }
+
+  return 0;
 }


^ permalink raw reply	[flat|nested] 64+ messages in thread

end of thread, other threads:[~2018-03-02 16:37 UTC | newest]

Thread overview: 64+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-05 10:32 [PATCH][RFC] Instrument function exit with __builtin_unreachable in C++ Martin Liška
2017-10-05 11:04 ` Jakub Jelinek
2017-10-05 15:08 ` Jason Merrill
2017-10-05 16:53   ` Martin Liška
2017-10-11 14:04     ` Martin Liška
2017-10-11 15:31     ` Jason Merrill
2017-10-12  8:48       ` Martin Liška
2017-10-12  9:36         ` Jakub Jelinek
2017-10-18 12:47           ` Martin Liška
2017-10-18 13:04             ` Marek Polacek
2017-10-18 13:15               ` Martin Liška
2017-10-24 14:30                 ` Jason Merrill
2017-11-03 13:42                   ` Martin Liška
2017-11-06 17:27                     ` Eric Botcazou
2017-11-06 17:41                       ` Jakub Jelinek
2017-11-06 23:07                         ` Eric Botcazou
2017-11-07 10:18                         ` Martin Liška
2017-11-15  7:57                           ` Martin Liška
2017-11-15  8:23                           ` Jakub Jelinek
2017-11-15  9:58                             ` Eric Botcazou
2017-11-15 10:02                               ` Martin Liška
2017-11-15 10:10                                 ` Eric Botcazou
2017-11-15 10:45                                 ` Jakub Jelinek
2017-11-15 12:46                                   ` Martin Liška
2017-11-06 18:41                     ` Martin Sebor
2017-11-15 12:49                       ` [PATCH][RFC] Add quotes for constexpr keyword Martin Liška
2017-11-15 16:38                         ` Martin Sebor
2017-11-15 16:59                           ` Jonathan Wakely
2017-11-15 17:06                             ` Martin Sebor
2017-11-15 17:14                               ` Jonathan Wakely
2017-11-21 15:27                                 ` Martin Liška
2017-11-21 15:48                                   ` Martin Sebor
2017-11-21 17:23                                   ` Jeff Law
2017-11-21 19:07                                     ` Martin Liška
2017-11-07 17:28                     ` [PATCH][RFC] Instrument function exit with __builtin_unreachable in C++ Andreas Schwab
2017-11-07 19:06                       ` Martin Liška
2017-11-19 17:06                     ` Thomas Schwinge
2017-10-18 12:48           ` [PATCH] Fix all tests that fail with -sanitize=return Martin Liška
2017-10-24 14:39             ` Jason Merrill
2017-11-06  8:48               ` Martin Liška
2017-10-18 12:53           ` [PATCH] Fix test-suite fallout of default -Wreturn-type Martin Liška
2017-10-24 14:40             ` Jason Merrill
2017-10-26 12:17               ` Martin Liška
2017-11-03 15:29                 ` Jason Merrill
2017-11-06  8:48                   ` Martin Liška
2017-11-06  9:58                     ` Paolo Carlini
2017-11-06 10:03                       ` Martin Liška
2017-11-06 10:09                         ` Paolo Carlini
2017-11-06 10:41                           ` Martin Liška
2017-11-06 11:40                             ` Paolo Carlini
2017-11-06 12:20                               ` Paolo Carlini
2017-11-06 13:38                                 ` Martin Liška
2017-11-06 13:58                                   ` Paolo Carlini
2017-11-06 14:12                                     ` Martin Liška
2017-11-06 21:17                                       ` [PATCH] Further -Wreturn-type testsuite fallout Jakub Jelinek
2017-11-15 13:33                                       ` [PATCH] Fix test-suite fallout of default -Wreturn-type Jonathan Wakely
2017-11-07 17:33             ` Andreas Schwab
2017-11-07 17:38               ` Jakub Jelinek
2017-11-08  8:02                 ` Andreas Schwab
2017-11-19 13:26             ` Thomas Schwinge
2017-11-20 13:58               ` Martin Liška
2017-11-20 14:14               ` Jason Merrill
2018-03-02 16:37                 ` Thomas Schwinge
2017-10-12 12:57         ` [PATCH][RFC] Instrument function exit with __builtin_unreachable in C++ Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).