Commit 23dbc169 by Martin Liska Committed by Martin Liska

Fix all tests that fail with -sanitize=return.

2017-11-06  Martin Liska  <mliska@suse.cz>

	* c-c++-common/dfp/call-by-value.c (foo32): Return a default
	value of change return type 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): Likewise.
	* g++.dg/cpp0x/udlit-template.C: Likewise.
	* g++.dg/cpp1z/eval-order3.C (struct A): Likewise.
	(operator>>): Likewise.
	* g++.dg/expr/cond12.C (struct X): Likewise.
	(X::operator=): Likewise.
	* g++.dg/gcov/gcov-1.C: Likewise.
	* g++.dg/gcov/gcov-threads-1.C (ContentionNoDeadlock_thread): Likewise.
	* g++.dg/ipa/devirt-21.C: Likewise.
	* g++.dg/ipa/devirt-23.C: Likewise.
	* g++.dg/ipa/devirt-34.C (t): Likewise.
	* g++.dg/missing-return.C: New test. 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.

From-SVN: r254438
parent 1b6fa695
2017-11-06 Martin Liska <mliska@suse.cz>
* c-c++-common/dfp/call-by-value.c (foo32): Return a default
value of change return type 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): Likewise.
* g++.dg/cpp0x/udlit-template.C: Likewise.
* g++.dg/cpp1z/eval-order3.C (struct A): Likewise.
(operator>>): Likewise.
* g++.dg/expr/cond12.C (struct X): Likewise.
(X::operator=): Likewise.
* g++.dg/gcov/gcov-1.C: Likewise.
* g++.dg/gcov/gcov-threads-1.C (ContentionNoDeadlock_thread): Likewise.
* g++.dg/ipa/devirt-21.C: Likewise.
* g++.dg/ipa/devirt-23.C: Likewise.
* g++.dg/ipa/devirt-34.C (t): Likewise.
* g++.dg/missing-return.C: New test. 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.
2017-11-05 Thomas Koenig <tkoenig@gcc.gnu.org> 2017-11-05 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/82471 PR fortran/82471
......
...@@ -5,17 +5,17 @@ ...@@ -5,17 +5,17 @@
#include "dfp-dbg.h" #include "dfp-dbg.h"
int foo32 (_Decimal32 z) void foo32 (_Decimal32 z)
{ {
z = z + 1.0df; z = z + 1.0df;
} }
int foo64 (_Decimal64 z) void foo64 (_Decimal64 z)
{ {
z = z + 1.0dd; z = z + 1.0dd;
} }
int foo128 (_Decimal128 z) void foo128 (_Decimal128 z)
{ {
z = z + 1.0dl; z = z + 1.0dl;
} }
......
...@@ -35,7 +35,7 @@ test_for2 (int m, int n, int o) ...@@ -35,7 +35,7 @@ test_for2 (int m, int n, int o)
return for_temp; /* count(6) */ return for_temp; /* count(6) */
} }
int void
call_for () call_for ()
{ {
for_val1 += test_for1 (0); for_val1 += test_for1 (0);
......
...@@ -9,7 +9,7 @@ auto apply (T t) -> decltype (t()) ...@@ -9,7 +9,7 @@ auto apply (T t) -> decltype (t())
} }
template <class T> template <class T>
T f(T t) void f(T t)
{ {
T t2 = t; T t2 = t;
if (t != [=]()->T { return t; }()) if (t != [=]()->T { return t; }())
......
...@@ -14,6 +14,8 @@ template<typename T> T foo() ...@@ -14,6 +14,8 @@ template<typename T> T foo()
sum += x; sum += x;
if (sum != T(10)) if (sum != T(10))
abort(); abort();
return sum;
} }
int main() int main()
......
...@@ -23,7 +23,7 @@ template<> ...@@ -23,7 +23,7 @@ template<>
operator"" _abc<'6','6','6'>() operator"" _abc<'6','6','6'>()
{ return 21; } { return 21; }
int void
test1() test1()
{ {
int i = operator"" _abc<'1','2','3'>(); int i = operator"" _abc<'1','2','3'>();
......
...@@ -26,7 +26,7 @@ struct A ...@@ -26,7 +26,7 @@ struct A
int _i; int _i;
A(int i): _i(f(i)) { } A(int i): _i(f(i)) { }
A& memfn(int i, int j) { f(j); return *this; } 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=(const A&) { return *this; }
A& operator+=(int i) { return *this; } A& operator+=(int i) { return *this; }
}; };
...@@ -38,7 +38,7 @@ struct B ...@@ -38,7 +38,7 @@ struct B
B(int i): _i(f(i)) { } B(int i): _i(f(i)) { }
}; };
int operator>>(A&, int i) { } int operator>>(A&, int i) { return 0; }
A a(0); A a(0);
A* afn(int i) A* afn(int i)
......
...@@ -2,10 +2,16 @@ ...@@ -2,10 +2,16 @@
// { dg-do run } // { dg-do run }
struct X { struct X {
X& operator=(const X&){} X& operator=(const X&);
X& operator=(X&){__builtin_abort();} X& operator=(X&){__builtin_abort();}
}; };
X g;
X& X::operator=(const X&)
{
return g;
}
int main(int argv,char**) { int main(int argv,char**) {
X a, b; X a, b;
((argv > 2) ? a : b) = X(); ((argv > 2) ? a : b) = X();
......
...@@ -74,7 +74,7 @@ test_for2 (int m, int n, int o) ...@@ -74,7 +74,7 @@ test_for2 (int m, int n, int o)
return for_temp; /* count(6) */ return for_temp; /* count(6) */
} }
int void
call_for () call_for ()
{ {
for_val1 += test_for1 (0); for_val1 += test_for1 (0);
......
...@@ -19,6 +19,8 @@ static void *ContentionNoDeadlock_thread(void *start) ...@@ -19,6 +19,8 @@ static void *ContentionNoDeadlock_thread(void *start)
for (int32_t i = NR - 1; i >= starti; --i) for (int32_t i = NR - 1; i >= starti; --i)
pthread_mutex_unlock (&cndMs[i]); pthread_mutex_unlock (&cndMs[i]);
} }
return 0;
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {
for (unsigned i = 0; i < NR; i++) for (unsigned i = 0; i < NR; i++)
......
...@@ -12,7 +12,7 @@ class MultiTermDocs : public virtual B { ...@@ -12,7 +12,7 @@ class MultiTermDocs : public virtual B {
protected: protected:
A readerTermDocs; A readerTermDocs;
A subReaders; A subReaders;
virtual B *m_fn1(int *) {} virtual B *m_fn1(int *) { return NULL; }
virtual inline ~MultiTermDocs(); virtual inline ~MultiTermDocs();
void wrap(void) void wrap(void)
{ {
......
...@@ -12,7 +12,7 @@ class MultiTermDocs : public virtual B { ...@@ -12,7 +12,7 @@ class MultiTermDocs : public virtual B {
protected: protected:
A readerTermDocs; A readerTermDocs;
A subReaders; A subReaders;
virtual B *m_fn1(int *) {} virtual B *m_fn1(int *) { return NULL; }
virtual inline ~MultiTermDocs(); virtual inline ~MultiTermDocs();
inline void wrap(void) inline void wrap(void)
{ {
......
...@@ -10,6 +10,8 @@ t(struct B *b) ...@@ -10,6 +10,8 @@ t(struct B *b)
{ {
struct A *a=b; struct A *a=b;
a->t(); a->t();
return 0;
} }
/* We should guess that the pointer of type B probably points to an instance /* We should guess that the pointer of type B probably points to an instance
......
/* { 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" } } */
...@@ -53,6 +53,8 @@ UINT32 bar (const C * sPtr) ...@@ -53,6 +53,8 @@ UINT32 bar (const C * sPtr)
if (a.xy[0] != ((SINT16) 0xffff << 2)) if (a.xy[0] != ((SINT16) 0xffff << 2))
abort (); abort ();
return 0;
} }
int main() int main()
......
...@@ -30,8 +30,8 @@ struct A ...@@ -30,8 +30,8 @@ struct A
int i; int i;
int A::foo1(void *ios, const char *str) { } int A::foo1(void *ios, const char *str) { return 0; }
int A::foo2(int v, const Type t) { i=0; } int A::foo2(int v, const Type t) { i=0; return 0; }
int main() int main()
{ {
......
...@@ -50,6 +50,8 @@ E::c () ...@@ -50,6 +50,8 @@ E::c ()
if (x > 10) if (x > 10)
throw 1; throw 1;
x |= 2; x |= 2;
return x;
} }
int int
......
...@@ -10,11 +10,15 @@ class A ...@@ -10,11 +10,15 @@ class A
{ {
public: public:
int i; int i;
A &operator =(const A &i) A &operator =(const A &i);
{ };
A a;
A& A::operator=(const A &i) {
status = 0; status = 0;
return a;
} }
};
class B class B
{ {
......
...@@ -11,7 +11,7 @@ static int flag = 0; ...@@ -11,7 +11,7 @@ static int flag = 0;
template <typename> struct A template <typename> struct A
{ {
A &active () { flag++;} A &active () { flag++; static A a; return a; }
static void foo() {} static void foo() {}
......
...@@ -65,6 +65,8 @@ bool ...@@ -65,6 +65,8 @@ bool
jump = 0; jump = 0;
} }
} }
return false;
} }
bool bool
...@@ -102,4 +104,5 @@ bool ...@@ -102,4 +104,5 @@ bool
} }
} }
return true;
} }
...@@ -21,6 +21,7 @@ void f() ...@@ -21,6 +21,7 @@ void f()
void *thread_main(void *) void *thread_main(void *)
{ {
f(); f(); f(); f(); f(); f();
return 0;
} }
#include <pthread.h> #include <pthread.h>
......
...@@ -19,6 +19,7 @@ thread_local A a; ...@@ -19,6 +19,7 @@ thread_local A a;
void *thread_main(void *) void *thread_main(void *)
{ {
A* ap = &a; A* ap = &a;
return 0;
} }
#include <pthread.h> #include <pthread.h>
......
...@@ -30,6 +30,7 @@ void f() ...@@ -30,6 +30,7 @@ void f()
void *thread_main(void *) void *thread_main(void *)
{ {
f(); f(); f(); f(); f(); f();
return 0;
} }
int main() int main()
......
...@@ -28,6 +28,7 @@ thread_local A a; ...@@ -28,6 +28,7 @@ thread_local A a;
void *thread_main(void *) void *thread_main(void *)
{ {
A* ap = &a; A* ap = &a;
return 0;
} }
int main() int main()
......
...@@ -22,6 +22,7 @@ void f() ...@@ -22,6 +22,7 @@ void f()
void *thread_main(void *) void *thread_main(void *)
{ {
f(); f(); f(); f(); f(); f();
return 0;
} }
int main() int main()
......
...@@ -20,6 +20,7 @@ thread_local A a; ...@@ -20,6 +20,7 @@ thread_local A a;
void *thread_main(void *) void *thread_main(void *)
{ {
A* ap = &a; A* ap = &a;
return 0;
} }
int main() int main()
......
...@@ -13,6 +13,8 @@ extern "C" { ...@@ -13,6 +13,8 @@ extern "C" {
void * memset (void *__dest, int __ch, size_t __len) throw () { void * memset (void *__dest, int __ch, size_t __len) throw () {
if (__builtin_constant_p (__len) && __len == 0) if (__builtin_constant_p (__len) && __len == 0)
__warn_memset_zero_len (); /* { dg-warning "declared with attribute warning" } */ __warn_memset_zero_len (); /* { dg-warning "declared with attribute warning" } */
return __dest;
} }
} }
inline void clear_mem(void* ptr, u32bit n) { inline void clear_mem(void* ptr, u32bit n) {
...@@ -50,11 +52,13 @@ template<typename T> class SecureVector : public MemoryRegion<T> { ...@@ -50,11 +52,13 @@ template<typename T> class SecureVector : public MemoryRegion<T> {
public: public:
SecureVector<T>& operator=(const MemoryRegion<T>& in) { SecureVector<T>& operator=(const MemoryRegion<T>& in) {
if(this != &in) this->set(in); if(this != &in) this->set(in);
return *this;
} }
}; };
class OctetString { class OctetString {
public: public:
SecureVector<byte> bits_of() const { SecureVector<byte> bits_of() const {
return SecureVector<byte> ();
} }
OctetString& operator^=(const OctetString&); OctetString& operator^=(const OctetString&);
void change(const MemoryRegion<byte>& in) { void change(const MemoryRegion<byte>& in) {
...@@ -69,6 +73,8 @@ OctetString& OctetString::operator^=(const OctetString& k) { ...@@ -69,6 +73,8 @@ OctetString& OctetString::operator^=(const OctetString& k) {
if(&k == this) { if(&k == this) {
bits.clear(); bits.clear();
} }
return *this;
} }
bool __attribute__((flatten)) bool __attribute__((flatten))
operator==(const OctetString& s1, const OctetString& s2) { operator==(const OctetString& s1, const OctetString& s2) {
......
...@@ -11,6 +11,8 @@ fn2 () ...@@ -11,6 +11,8 @@ fn2 ()
{ {
if (a (c == 0)) if (a (c == 0))
return 0; return 0;
return 0;
} }
int main() int main()
......
...@@ -6,7 +6,7 @@ struct Value ...@@ -6,7 +6,7 @@ struct Value
double value; double value;
Value(double value_) : value (value_) {} Value(double value_) : value (value_) {}
operator double() const { return value; } operator double() const { return value; }
Value& operator=(double other) { value = other; } Value& operator=(double other) { value = other; return *this; }
}; };
struct Ref struct Ref
......
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-options "-O2 -std=gnu++11 -fopt-info-loop-missed -Wunsafe-loop-optimizations" } */ /* { dg-options "-O2 -std=gnu++11 -fopt-info-loop-missed -Wunsafe-loop-optimizations" } */
struct p
{
char *ay;
};
namespace a { namespace a {
void b () __attribute__ ((__noreturn__)); void b () __attribute__ ((__noreturn__));
...@@ -19,7 +23,7 @@ template <typename j, typename> class k ...@@ -19,7 +23,7 @@ template <typename j, typename> class k
j l; j l;
public: public:
typename d<j>::f operator* () {} typename d<j>::f operator* () { return p(); }
void operator++ () { ++l; } void operator++ () { ++l; }
j j
aa () aa ()
...@@ -33,7 +37,6 @@ operator!= (k<m, ab> o, k<n, ab> p2) ...@@ -33,7 +37,6 @@ operator!= (k<m, ab> o, k<n, ab> p2)
{ {
return o.aa () != p2.aa (); return o.aa () != p2.aa ();
} }
struct p;
namespace a { namespace a {
struct F struct F
{ {
...@@ -75,13 +78,10 @@ at ...@@ -75,13 +78,10 @@ at
av (au o) av (au o)
{ {
o.aq ('\n'); o.aq ('\n');
return at();
} }
u ax; u ax;
} }
struct p
{
char *ay;
};
a::H t; a::H t;
void void
ShowHelpListCommands () ShowHelpListCommands ()
......
...@@ -15,4 +15,6 @@ int test() { ...@@ -15,4 +15,6 @@ int test() {
// //
std::string s = ""; std::string s = "";
s += 'x' + "y"; // { dg-warning "bounds of constant string" } s += 'x' + "y"; // { dg-warning "bounds of constant string" }
return 0;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment