plateform
stringclasses
1 value
repo_name
stringclasses
2 values
name
stringlengths
1
78
ext
stringclasses
2 values
path
stringlengths
15
1.11k
size
int64
1
8.55M
source_encoding
stringclasses
11 values
md5
stringlengths
32
32
text
stringlengths
0
8.49M
google
chromium
pr21983
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/pr21983.C
272
utf_8
89bf2aeef07d83dd1991bf02317481b5
// PR c++/21983 // { dg-do compile } struct B { virtual void foo () = 0; }; struct D1 : public virtual B { virtual void foo () {} }; struct D2 : public virtual B { virtual void foo () {} }; struct D : public D1, public D2 { }; // { dg-error "no unique final overrider" }
google
chromium
main-4
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/main-4.C
159
utf_8
b8c62de5dbf97777a789b0e6031264f5
// This pattern is used by a lot of autoconf scripts, so don't // complain about it unless -pedantic. // { dg-options "" } int main () { main (); return 0; }
google
chromium
Wreorder-1
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wreorder-1.C
204
utf_8
c581ab7bc1c10728c1e68266d06af6e9
// { dg-options "-Wreorder -W" } struct S { S (); }; struct T { T (); }; struct U : virtual public S, virtual public T { U () : T (), S () {} // { dg-warning "" } U (const U&) : S () {} };
google
chromium
miss-format-3
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/miss-format-3.C
892
utf_8
d38eae092825c980b4c8c291c3d56273
/* { dg-do compile } */ /* { dg-options "-Wmissing-format-attribute" } */ /* { dg-options "-Wmissing-format-attribute -Wno-abi" { target arm_eabi } } */ #include <stdarg.h> typedef void (*noattr_t) (const char *, ...); typedef noattr_t __attribute__ ((__format__(__printf__, 1, 2))) attr_t; typedef void (*vnoattr_t) (const char *, va_list); typedef vnoattr_t __attribute__ ((__format__(__printf__, 1, 0))) vattr_t; void foo1 (noattr_t na, attr_t a, vnoattr_t vna, vattr_t va) { noattr_t na1 = na; noattr_t na2 = a; /* { dg-warning "candidate" "initialization warning" } */ attr_t a1 = na; attr_t a2 = a; vnoattr_t vna1 = vna; vnoattr_t vna2 = va; /* { dg-warning "candidate" "initialization warning" } */ vattr_t va1 = vna; vattr_t va2 = va; }
google
chromium
do-empty
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/do-empty.C
265
utf_8
9c49d36a54518ba5874b3fe7045ef791
/* Test diagnostics for empty bodies in do / while. */ /* { dg-do compile } */ /* { dg-options "-Wempty-body" } */ void f (int x) { do ; /* { dg-warning "empty body in" } */ while (x--); do {} /* { dg-bogus "empty body in" } */ while (++x < 10); }
google
chromium
noreturn-5
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/noreturn-5.C
274
utf_8
cdfdbc855eb8f2a2ccce7134c9da053f
// PR c++/30988 // { dg-do compile } // { dg-options "-O2 -Wall" } void f (const char *) __attribute__ ((noreturn)); void f (int) __attribute__ ((noreturn)); void f (double) __attribute__ ((noreturn)); template <typename T> struct A { int g () { f ((T) 0); } };
google
chromium
compare1
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/compare1.C
246
utf_8
064f2d562e6ae3005fac3be98940a167
/* -Wall is supposed to trigger -Wsign-compare for C++. PR 10604. See also gcc.dg/compare7.c. */ /* { dg-do compile } */ /* { dg-options "-Wall" } */ int f(unsigned a, int b) { return a < b; /* { dg-warning "signed and unsigned" } */ }
google
chromium
Wconversion1
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wconversion1.C
303
utf_8
d10152133e840d3699814c5271083357
// { dg-options "-fsigned-char -Wsign-conversion" } char c1 = 1024; // { dg-warning "overflow" } char c2 = char(1024); char c3 = (char) 1024; char c4 = static_cast<char>(1024); unsigned char uc1 = -129; // { dg-warning "unsigned" } bool b1 = -3; int i1 = 0x80000000; // { dg-warning "conversion" }
google
chromium
Weff1
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Weff1.C
141
utf_8
6cbb434563bf5c0247156042fe84718d
// { dg-options "-Weffc++" } struct S {}; /* Base classes should have virtual destructors. */ struct T : public S {}; // { dg-warning "" }
google
chromium
effc3
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/effc3.C
994
utf_8
a09300084b0484d20d1e01b50584cbd6
// { dg-do compile } // { dg-options "-Weffc++" } // Contributed by Benjamin Kosnik <bkoz at redhat dot com> // PR c++/16165 and PR c++/8211: Improve item 11 of -Weffc++ // We should not warn for this class since this kind of pointers can // never hold dynamic memory. struct A { void (*func1)(void); void (A::*func2)(void); int A::*func3; int a; void b(void); A(); ~A(); }; // We do not warn for this class because there is no destructor, so we // assume there is no dynamic memory allocated (it could point to a // global variable). struct B { int *ptr; B(); }; // We should emit a warning for these struct C1 { // { dg-warning "" "" } int *ptr; C1(); ~C1(); }; struct C2 { // { dg-warning "" "" } int *ptr; C2(); C2(const C2&); ~C2(); }; struct C3 { // { dg-warning "" "" } int *ptr; C3(); ~C3(); C3& operator=(const C3&); }; // But not for this struct C4 { int *ptr; C4(); C4(const C4&); ~C4(); C4& operator=(const C4&); };
google
chromium
Wdtor1
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wdtor1.C
347
utf_8
ee0b4d9e331b2ed8b1a730e066fc0084
// PR c++/20145 // { dg-options "-Wnon-virtual-dtor" } # 1 "t.cc" # 1 "<built-in>" # 1 "<command line>" # 1 "t.cc" # 1 "include/t.h" 1 3 4 // Declare the template with explicit C++ linkage in case system // headers have implicit C linkage. extern "C++" { template <int> class t { virtual void f(); }; } # 2 "t.cc" 2 void f(void) { t<1> h; }
google
chromium
pr35602
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/pr35602.C
432
utf_8
50363ca948a4d64c43b9acf226a68ae9
// PR 35602 Bogus warning with -Wsign-conversion // { dg-do compile } // { dg-options "-Wconversion -Wsign-conversion" } struct c { ~c(); c(); }; int main(const int, const char * const * const) { c x[0UL][0UL] = // { dg-bogus "warning: conversion to .long unsigned int. from .long int. may change the sign of the result" } { }; c y[0UL] = { }; int z[0ul][0UL] = { }; return 0; }
google
chromium
Wuninitializable-member
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wuninitializable-member.C
362
utf_8
cb6b38abe346f8950bdb218ab4c6e17d
// { dg-do compile } // { dg-options "-Wuninitialized" } class X { int & flag;// { dg-warning "non-static reference 'int& X::flag' in class without a constructor" } public: void f(){ flag++ ; } }; class Y { const int var;// { dg-warning "non-static const member 'const int Y::var' in class without a constructor" } public: int g(){ return 2*var; } };
google
chromium
Wparentheses-22
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wparentheses-22.C
2,119
utf_8
d18ff788cbb2084df4ebb3ddadb46dd8
// { dg-do compile } // { dg-options "-Wparentheses" } // Warnings for assignments used as truth-values when using classes. // Like Wparentheses-1.C, but with a class. int foo (int); class C { public: C() : b(0) { } // Use default assignment constructor. // Provide conversion to bool so that an instance of this class will // work as a condition. operator bool() const { return b != 0; } private: int b; }; C a, b, c; bool d; void bar (void) { if (a = b) // { dg-warning "assignment" "correct warning" } foo (0); if ((a = b)) foo (1); if (a = a) // { dg-warning "assignment" "correct warning" } foo (2); if ((a = a)) foo (3); if (b = c) // { dg-warning "assignment" "correct warning" } foo (4); else foo (5); if ((b = c)) foo (6); else foo (7); if (b = b) // { dg-warning "assignment" "correct warning" } foo (8); else foo (9); if ((b = b)) foo (10); else foo (11); while (c = b) // { dg-warning "assignment" "correct warning" } foo (12); while ((c = b)) foo (13); while (c = c) // { dg-warning "assignment" "correct warning" } foo (14); while ((c = c)) foo (15); do foo (16); while (a = b); // { dg-warning "assignment" "correct warning" } do foo (17); while ((a = b)); do foo (18); while (a = a); // { dg-warning "assignment" "correct warning" } do foo (19); while ((a = a)); for (;c = b;) // { dg-warning "assignment" "correct warning" } foo (20); for (;(c = b);) foo (21); for (;c = c;) // { dg-warning "assignment" "correct warning" } foo (22); for (;(c = c);) foo (23); d = a = b; // { dg-warning "assignment" "correct warning" } foo (24); d = (a = b); foo (25); d = a = a; // { dg-warning "assignment" "correct warning" } foo (26); d = (a = a); foo (27); if (C(a)) foo (28); } bool bar1 (void) { return a = b; // { dg-warning "assignment" "correct warning" } } bool bar2 (void) { return (a = b); } bool bar3 (void) { return a = a; // { dg-warning "assignment" "correct warning" } } bool bar4 (void) { return (a = a); }
google
chromium
overflow-warn-6
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/overflow-warn-6.C
359
utf_8
e36e0e34c32010c5c54008377dce599e
/* Test non-constant operands in overflowed expressions. */ /* { dg-do compile } */ /* { dg-options "-Woverflow" } */ #include <limits.h> int h1 (int x) { return x * (0 * (INT_MAX + 1)); /* { dg-warning "integer overflow in expression" } */ } int h2 (int x) { return ((INT_MAX + 1) * 0) * x; /* { dg-warning "integer overflow in expression" } */ }
google
chromium
Wstrict-aliasing-4
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-4.C
252
utf_8
018ddc3284f5451940a479a4b278702c
/* { dg-do compile } */ /* { dg-options "-Wstrict-aliasing=2 -O2" } */ double x; template <typename T> T *foo(void) { int a[2]; float *y = (float *)a; /* { dg-bogus "strict-aliasing" } */ return (T *)&x; /* { dg-bogus "strict-aliasing" } */ }
google
chromium
noeffect8
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/noeffect8.C
220
utf_8
66e0590894778b4ef227905c708142a8
// PR c++/26696, 28996 // { dg-do compile } // { dg-options "-Waddress" } struct A { static void f() {} }; int main() { A a; a.f; // { dg-warning "not call" } A().f; // { dg-warning "not call" } }
google
chromium
Wunreachable-code-2
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wunreachable-code-2.C
293
utf_8
aa9f0a4fa9133811690bf8fa76df33b7
// PR c++/21228 /* { dg-options "-Wunreachable-code" } */ class testStringBase { public: char *stringPtr; }; class testString : public testStringBase { public: testString(); }; testString::testString() { stringPtr = (char *) 9; } int main(int argc, char **argv) { testString s; }
google
chromium
pr5645
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/pr5645.C
468
utf_8
6421a1ed78a5d7624b4d5f88e8d92add
// PR5645: gcc warns that pure virtual class not explicitly initialized. // { dg-do compile } // { dg-options "-Wall -Wextra" } class a { public: virtual int f() = 0; virtual int g() = 0; }; class b : public a { public: b(); b(const b& c); protected: int i; }; b::b() {} b::b(const b& c) { // { dg-bogus "base class .class a. should be explicitly initialized in the copy constructor" } i = c.i; } struct X {}; struct Y : X { Y (Y const&) {} };
google
chromium
Wstrict-aliasing-3
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-3.C
333
utf_8
b3735a938e1a49d3bef2fa33d5905d04
/* { dg-do compile } */ /* { dg-options "-Wstrict-aliasing=2 -O2" } */ double x; template <typename T> T *foo(void) { return (T *)&x; /* { dg-warning "strict-aliasing" } */ } template int *foo<int>(void); /* { dg-message "instantiated from here" } */ template char *foo<char>(void); /* { dg-bogus "instantiated from here" } */
google
chromium
Wctor-dtor
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wctor-dtor.C
227
utf_8
2d2da24222711602624d6870a966c8b0
// PR c++/21347 // { dg-options "-Wctor-dtor-privacy" } class A { public: int x; int getX() { return x; } // comment out to avoid warning }; int foo() { A a; // accepted: clearly the ctor is not private return a.x; }
google
chromium
Wparentheses-9
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wparentheses-9.C
4,163
utf_8
6ac2e35b5e4a2de47ad29a14a6dbe103
// { dg-do compile } // { dg-options "-Wparentheses" } // C++ version of gcc.dg/Wparentheses-6.c int foo (int); int bar (int a, int b, int c) { foo (a & b | c); // { dg-warning "parentheses" "correct warning" } foo ((a & b) | c); foo (a & (b | c)); foo (1 & 2 | c); // { dg-warning "parentheses" "correct warning" } foo ((1 & 2) | c); foo (1 & (2 | c)); foo (1 & 2 | 3); // { dg-warning "parentheses" "correct warning" } foo ((1 & 2) | 3); foo (1 & (2 | 3)); foo (a | b & c); // { dg-warning "parentheses" "correct warning" } foo ((a | b) & c); foo (a | (b & c)); foo (1 | 2 & c); // { dg-warning "parentheses" "correct warning" } foo ((1 | 2) & c); foo (1 | (2 & c)); foo (1 | 2 & 3); // { dg-warning "parentheses" "correct warning" } foo ((1 | 2) & 3); foo (1 | (2 & 3)); foo (a ^ b | c); // { dg-warning "parentheses" "correct warning" } foo ((a ^ b) | c); foo (a ^ (b | c)); foo (1 ^ 2 | c); // { dg-warning "parentheses" "correct warning" } foo ((1 ^ 2) | c); foo (1 ^ (2 | c)); foo (1 ^ 2 | 3); // { dg-warning "parentheses" "correct warning" } foo ((1 ^ 2) | 3); foo (1 ^ (2 | 3)); foo (a | b ^ c); // { dg-warning "parentheses" "correct warning" } foo ((a | b) ^ c); foo (a | (b ^ c)); foo (1 | 2 ^ c); // { dg-warning "parentheses" "correct warning" } foo ((1 | 2) ^ c); foo (1 | (2 ^ c)); foo (1 | 2 ^ 3); // { dg-warning "parentheses" "correct warning" } foo ((1 | 2) ^ 3); foo (1 | (2 ^ 3)); foo (a + b | c); // { dg-warning "parentheses" "correct warning" } foo ((a + b) | c); foo (a + (b | c)); foo (1 + 2 | c); // { dg-warning "parentheses" "correct warning" } foo ((1 + 2) | c); foo (1 + (2 | c)); foo (1 + 2 | 3); // { dg-warning "parentheses" "correct warning" } foo ((1 + 2) | 3); foo (1 + (2 | 3)); foo (a | b + c); // { dg-warning "parentheses" "correct warning" } foo ((a | b) + c); foo (a | (b + c)); foo (1 | 2 + c); // { dg-warning "parentheses" "correct warning" } foo ((1 | 2) + c); foo (1 | (2 + c)); foo (1 | 2 + 3); // { dg-warning "parentheses" "correct warning" } foo ((1 | 2) + 3); foo (1 | (2 + 3)); foo (a - b | c); // { dg-warning "parentheses" "correct warning" } foo ((a - b) | c); foo (a - (b | c)); foo (1 - 2 | c); // { dg-warning "parentheses" "correct warning" } foo ((1 - 2) | c); foo (1 - (2 | c)); foo (1 - 2 | 3); // { dg-warning "parentheses" "correct warning" } foo ((1 - 2) | 3); foo (1 - (2 | 3)); foo (a | b - c); // { dg-warning "parentheses" "correct warning" } foo ((a | b) - c); foo (a | (b - c)); foo (1 | 2 - c); // { dg-warning "parentheses" "correct warning" } foo ((1 | 2) - c); foo (1 | (2 - c)); foo (1 | 2 - 3); // { dg-warning "parentheses" "correct warning" } foo ((1 | 2) - 3); foo (1 | (2 - 3)); foo (a > b | c); // { dg-warning "parentheses" "correct warning" } foo ((a > b) | c); foo (a > (b | c)); foo (1 > 2 | c); // { dg-warning "parentheses" "correct warning" } foo ((1 > 2) | c); foo (1 > (2 | c)); foo (1 > 2 | 3); // { dg-warning "parentheses" "correct warning" } foo ((1 > 2) | 3); foo (1 > (2 | 3)); foo (a | b > c); // { dg-warning "parentheses" "correct warning" } foo ((a | b) > c); foo (a | (b > c)); foo (1 | 2 > c); // { dg-warning "parentheses" "correct warning" } foo ((1 | 2) > c); foo (1 | (2 > c)); foo (1 | 2 > 3); // { dg-warning "parentheses" "correct warning" } foo ((1 | 2) > 3); foo (1 | (2 > 3)); foo (a <= b | c); // { dg-warning "parentheses" "correct warning" } foo ((a <= b) | c); foo (a <= (b | c)); foo (1 <= 2 | c); // { dg-warning "parentheses" "correct warning" } foo ((1 <= 2) | c); foo (1 <= (2 | c)); foo (1 <= 2 | 3); // { dg-warning "parentheses" "correct warning" } foo ((1 <= 2) | 3); foo (1 <= (2 | 3)); foo (a | b <= c); // { dg-warning "parentheses" "correct warning" } foo ((a | b) <= c); foo (a | (b <= c)); foo (1 | 2 <= c); // { dg-warning "parentheses" "correct warning" } foo ((1 | 2) <= c); foo (1 | (2 <= c)); foo (1 | 2 <= 3); // { dg-warning "parentheses" "correct warning" } foo ((1 | 2) <= 3); foo (1 | (2 <= 3)); }
google
chromium
Wsign-compare-2
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wsign-compare-2.C
206
utf_8
9783f1e807119d28bffbe38aaa6b2a85
// PR c/35430 // { dg-do compile } // { dg-options "-Wsign-compare" } void foo (__complex__ int i) { i == 0u; i == ~1u; // { dg-warning "comparison between signed and unsigned integer expressions" } }
google
chromium
Wswitch-default-1
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wswitch-default-1.C
274
utf_8
ec17a45e76ade076a9d23dd01ca9751f
// PR C++/21123 /* { dg-do compile } */ /* { dg-options "-Wswitch-default" } */ template <typename ArrayType> void foo( ) { int i = 0; switch ( i ) /* { dg-bogus "switch missing default case" } */ { case 9: default: break; } } void f() { foo<int>(); }
google
chromium
pr5310
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/pr5310.C
200
utf_8
89c64e7b581401ee2f6738f0d18e7483
// PR 5310 // { dg-do compile } // { dg-options "-pedantic -Wall -Wextra -Wpointer-arith -Wconversion" } void foo (int); void foo (long); void bar() { foo ((int)__null); foo ((long)__null); }
google
chromium
noeffect2
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/noeffect2.C
700
utf_8
ddc9b2fcd58aa6e2e3d1775009375e12
// { dg-do compile } // { dg-options "-Wall" } // PR 11945 inconsistent warnings extern "C" void FormatDisk(); template <class T> struct C { C(){ FormatDisk(), 0; } // { dg-warning "right-hand operand of comma" "" } }; template struct C<int>; // { dg-message "instantiated" } template <class T> void f() { FormatDisk(), 0; } // { dg-warning "right-hand operand of comma" "" } template void f<int> (); // { dg-message "instantiated" } void g() { FormatDisk(), 0; } // { dg-warning "right-hand operand of comma" "" }
google
chromium
Wparentheses-3
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wparentheses-3.C
233
utf_8
f54d3fb57e7ea75f1954d2671e769fd5
// Test that -Wparentheses does not give bogus warnings in the // presence of templates. Bug 17041. // { dg-do compile } // { dg-options "-Wparentheses" } template<int> struct A { int i; A() { if ((i = 0)) ; } }; A<0> a;
google
chromium
Wconversion3
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wconversion3.C
1,184
utf_8
7a1aeeb61c3d0cced96983f6490193ae
// PR c++/34198 // { dg-do compile } // { dg-options "-O2 -Wconversion -Wsign-conversion" } signed char sc; unsigned char uc; short int ss; unsigned short int us; int si; unsigned int ui; void test1 (void) { int a = uc & 0xff; int b = sc & 0x7f; int c = 0xff & uc; int d = 0x7f & sc; int e = uc & sc; unsigned char f = (int) uc; signed char g = (int) sc; unsigned char h = (unsigned int) (short int) uc; signed char i = (int) (unsigned short int) sc; // { dg-warning "may alter its value" } unsigned char j = (unsigned int) (short int) us; // { dg-warning "may alter its value" } signed char k = (int) (unsigned short int) ss; // { dg-warning "may alter its value" } } void test2 (void) { signed char a = (unsigned char) sc; // { dg-warning "may change the sign" } unsigned char b = (signed char) uc; // { dg-warning "may change the sign" } signed char c = (int) (unsigned char) sc; // { dg-warning "may change the sign" } unsigned char d = (int) (signed char) uc; // { dg-warning "may change the sign" } int e = (unsigned int) si; // { dg-warning "may change the sign" } unsigned int f = (int) ui; // { dg-warning "may change the sign" } }
google
chromium
changes-meaning
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/changes-meaning.C
246
utf_8
9d482788ebfbc6a8f5bfebe98d71ae94
/* { dg-do compile } */ /* { dg-options "-fpermissive" } */ template <class _Tp> class auto_ptr {}; /* { dg-warning "changes meaning" } */ template <class _Tp> class counted_ptr { public: auto_ptr<_Tp> auto_ptr(); /* { dg-warning "" } */ };
google
chromium
anonymous-namespace-1
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/anonymous-namespace-1.C
397
utf_8
b718de980adb60556e7ed2d1500c1178
// Test for the warning of exposing types from an anonymous namespace // { dg-do compile } #include "anonymous-namespace-1.h" namespace { class good { }; } class foo::bar : public good { }; class foobar1 { good g; }; #line 17 "foo.C" class foobar : public bad { }; // { dg-warning "uses the anonymous namespace" } class foobar2 { bad b; }; // { dg-warning "uses the anonymous namespace" }
google
chromium
Wparentheses-4
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wparentheses-4.C
353
utf_8
5cb9671988084dbee7c5cdf77fbbfa0c
// Test that -Wparentheses does not give bogus warnings in the // presence of templates for non-plain assignment. Bug 17120. // { dg-do compile } // { dg-options "-Wparentheses" } template<typename _Tp> inline _Tp cmath_power(_Tp __x, unsigned int __n) { while (__n >>= 1) ; return __x; } int main() { cmath_power(1.0, 3); }
google
chromium
Wsign-compare-1
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wsign-compare-1.C
100
utf_8
2247cfbc59da044c90471731c49fe14d
// { dg-options "-Wsign-compare" } extern unsigned u; template<class F> int f() { return u > 1; }
google
chromium
Wunreachable-code-1
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wunreachable-code-1.C
566
utf_8
f3d80e4b7c90755533b6b7bd8812abae
/* PR17544 Incorrect -Wunreachable-code warning G++ appends a "return 0;" when finishing a function, but it was not given a source location. The gimplifier thinks a return statement needs a locus so it would add one, making the compiler generated code visible to the unreachable code warning. */ /* { dg-do compile } */ /* { dg-options "-O -Wunreachable-code" } */ int main (int argc, char *argv[]) { const char* const s = argc < 2 ? "" : argv [1]; int i = 0; do { ++i; } while (i < s [0]); return i; }
google
chromium
return-reference
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/return-reference.C
296
utf_8
70f8973f83c648dfef793b81d7b5a128
// { dg-do compile } const int* bar(); const int& foo1() { static int empty; const int* x = bar(); return (x ? *x : empty); // { dg-bogus ".*" "" { xfail *-*-* } } } const int& foo2() { static int empty; const int* x = bar(); const int& r = (x ? *x : empty); return (r); }
google
chromium
Wtype-limits-no
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wtype-limits-no.C
3,164
utf_8
d803f73370f8916f5ec2a47e528fa49a
/* Test disabling -Wtype-limits. */ /* { dg-do compile } */ /* { dg-options "-Wextra -Wno-type-limits" } */ extern void assert (int); void a (unsigned char x) { if (x < 0) return;/* { dg-bogus "comparison is always false due to limited range of data type" } */ if (x >= 0) return;/* { dg-bogus "comparison is always true due to limited range of data type" } */ if (0 > x) return;/* { dg-bogus "comparison is always false due to limited range of data type" } */ if (0 <= x) return;/* { dg-bogus "comparison is always true due to limited range of data type" } */ if (x <= 255) /* { dg-bogus "comparison is always true due to limited range of data type" } */ return; if (255 >= x) /* { dg-bogus "comparison is always true due to limited range of data type" } */ return; if ((int)x <= 255) return; if (255 >= (unsigned char) 1) return; } void b (unsigned short x) { if (x < 0) return;/* { dg-bogus "comparison is always false due to limited range of data type" } */ if (x >= 0) return;/* { dg-bogus "comparison is always true due to limited range of data type" } */ if (0 > x) return;/* { dg-bogus "comparison is always false due to limited range of data type" } */ if (0 <= x) return;/* { dg-bogus "comparison is always true due to limited range of data type" } */ } void c (unsigned int x) { if (x < 0) return;/* { dg-bogus "comparison of unsigned expression < 0 is always false" } */ if (x >= 0) return;/* { dg-bogus "comparison of unsigned expression >= 0 is always true" } */ if (0 > x) return;/* { dg-bogus "comparison of unsigned expression < 0 is always false" } */ if (0 <= x) return;/* { dg-bogus "comparison of unsigned expression >= 0 is always true" } */ if (1U >= 0) return; if (1U < 0) return; if (0 <= 1U) return; if (0 > 1U) return; } void d (unsigned long x) { if (x < 0) return;/* { dg-bogus "comparison of unsigned expression < 0 is always false" } */ if (x >= 0) return;/* { dg-bogus "comparison of unsigned expression >= 0 is always true" } */ if (0 > x) return;/* { dg-bogus "comparison of unsigned expression < 0 is always false" } */ if (0 <= x) return;/* { dg-bogus "comparison of unsigned expression >= 0 is always true" } */ } void e (unsigned long long x) { if (x < 0) return;/* { dg-bogus "comparison of unsigned expression < 0 is always false" } */ if (x >= 0) return;/* { dg-bogus "comparison of unsigned expression >= 0 is always true" } */ if (0 > x) return;/* { dg-bogus "comparison of unsigned expression < 0 is always false" } */ if (0 <= x) return;/* { dg-bogus "comparison of unsigned expression >= 0 is always true" } */ } int test (int x) { if ((long long)x <= 0x123456789ABCLL) /* { dg-bogus "comparison is always true due to limited range of data type" } */ return 1; else return 0; } template <typename Int, Int D> void f(Int x) { assert(0 <= x and x <= D); // { dg-bogus "comparison is always true due to limited range of data type" } } int ff(void) { f<unsigned char, 2>(5); f<signed char, 2>(5); } template <typename Int, Int D> void g(void) { assert(0 <= D); } int gg(void) { g<unsigned char, 2>(); }
google
chromium
ctor-dtor-privacy-2
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/ctor-dtor-privacy-2.C
97
utf_8
ca9f620c9a4fcfd05cfa551f64c2c55c
struct C { static bool result; private: static bool check(); }; bool C::result = check();
google
chromium
empty-body
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/empty-body.C
364
utf_8
9362e9b4176e1dea1998f49b49d8bbcc
// PR c++/5520 // { dg-options "-O2 -Wempty-body" } void breakme() { if(1) ; // { dg-warning "empty body" } if(1) {} // { dg-bogus "empty body" } if(1) (void)0; // { dg-bogus "empty body" } if(1) {} else; // { dg-warning "empty body" } if(1) {} else (void)0; // // { dg-bogus "empty body" } if(1) ; else (void)0; // // { dg-bogus "empty body" } }
google
chromium
missing-field-init-1
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/missing-field-init-1.C
402
utf_8
67d018f4028bfdad4712e6c50a3eefa7
/* { dg-do compile } */ /* { dg-options "-Wextra -Wno-missing-field-initializers" } */ struct s { int a, b, c; }; struct s s1 = { 1, 2, 3 }; struct s s2 = { 1, 2 }; /* { dg-bogus "missing initializer" } */ struct s s3[] = { { 1, 2 }, { 4, 5 } }; /* { dg-bogus "missing initializer" } */ struct s s4[] = { 1, 2, 3, 4, 5 }; /* { dg-bogus "missing initializer" } */ struct s s5[] = { 1, 2, 3, 4, 5, 6 };
google
chromium
noeffect7
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/noeffect7.C
309
utf_8
165e60b3a0c53a0c1e6a87c65f59860e
// PR c++/8057 // Don't give a "statement has no effect" warning when declaring a // template, only when instantiating it. // { dg-do compile } // { dg-options "-Wunused" } struct Y { static int i; }; template <typename T> class X { X() { Y::i; }; }; class Z { Z() { Y::i; }; }; // { dg-warning "no effect" }
google
chromium
private1
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/private1.C
213
utf_8
8c096cfbcb0f16fa5bde02650ac4ab41
// g++ should not complain about A having private [cd]tors. class A { A(); ~A(); public: int dummy(); // needed to get bogus warning static A* get_A (); }; A* A::get_A() { static A a; return &a; }
google
chromium
Wmissing-declarations-1
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wmissing-declarations-1.C
658
utf_8
d3017d025f43f9093bf016847e418a34
// { dg-options "-Wmissing-declarations" } void fn1() { } // { dg-warning "no previous declaration" } namespace ns { void fn2() { } // { dg-warning "no previous declaration" } } namespace { void fn3() { } } static void fn4() { } void fn5(); namespace ns { void fn6(); } void fn5() { } namespace ns { void fn6() { } } inline void fn7() { } class c { void cfn1() { } static void cfn2() { } void cfn3(); static void cfn4(); }; void c::cfn3() { } void c::cfn4() { } static struct { void sfn1() { } static void sfn2() { } } s; template<typename C> void tfn1() { } template void tfn1<c>(); class d { }; template<> void tfn1<d>() { }
google
chromium
multiple-overflow-warn-2
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/multiple-overflow-warn-2.C
363
utf_8
5a5d76c338de16945c65cd2aa45bfef0
/* PR c/19978 : Test for duplicated warnings (binary operators). */ /* { dg-do compile } */ /* { dg-options "-Woverflow" } */ #include <limits.h> int g1 (void) { return INT_MAX + 1 - INT_MAX; /* { dg-bogus "integer overflow in expression.*integer overflow in expression" } */ /* { dg-warning "integer overflow in expression" "" { target *-*-* } 10 } */ }
google
chromium
Wnvdtor-2
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wnvdtor-2.C
935
utf_8
e5ddbe9f88e16de304b8fb39e7eb35af
// PR c++/7302 // { dg-do compile } // { dg-options "-Wnon-virtual-dtor" } // Warn when a class has virtual functions and accessible non-virtual // destructor, in which case it would be possible but unsafe to delete // an instance of a derived class through a pointer to the base class. struct A { // { dg-bogus "non-virtual destructor" } protected: ~A(); public: virtual void f() = 0; }; struct B { // { dg-bogus "non-virtual destructor" } private: ~B(); public: virtual void f() = 0; }; struct C { // { dg-warning "non-virtual destructor" } virtual void f() = 0; }; struct D { // { dg-warning "non-virtual destructor" } ~D(); virtual void f() = 0; }; struct E; struct F { // { dg-warning "non-virtual destructor" } protected: friend class E; ~F(); public: virtual void f() = 0; }; struct G { // { dg-warning "non-virtual destructor" } private: friend class E; ~G(); public: virtual void f() = 0; };
google
chromium
noreturn-2
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/noreturn-2.C
94
utf_8
10a2dc88ff4acf5169ed37d5b483050b
// { dg-options "-Wall" } template <class T> int f (T t) { } // { dg-warning "no return" }
google
chromium
Wunused-2
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wunused-2.C
174
utf_8
61051d6055a088efd9b196d7533030ea
// { dg-do compile } // { dg-options "-Wunused -O3" } static const int i = 0; static void f() { } /* { dg-warning "defined but not used" "" } */ static inline void g() { }
google
chromium
Woverflow-2
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Woverflow-2.C
149
utf_8
9bc388e58bfd1cdb62f20ded1e767644
/* { dg-do compile } */ /* { dg-options "-O2 -Woverflow" } */ #include <limits.h> int foo = INT_MAX + 1; /* { dg-warning "integer overflow" } */
google
chromium
Wstrict-aliasing-7
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-7.C
366
utf_8
de6922f52681362a988b2a9e27c6e865
/* { dg-do compile } */ /* { dg-options "-Wstrict-aliasing=2 -O2" } */ int a[2]; double *foo1(void) { return (double *)a; /* { dg-warning "strict-aliasing" } */ } double *foo2(void) { return (double *)&a[0]; /* { dg-warning "strict-aliasing" } */ } __complex__ double x; int *bar(void) { return (int *)&__imag__ x; /* { dg-warning "strict-aliasing" } */ }
google
chromium
overflow-warn-3
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/overflow-warn-3.C
4,555
utf_8
a14024f8c187790a13607fe4f2439552
/* { dg-do compile } */ /* { dg-options "-fpermissive -pedantic" } */ #include <limits.h> enum e { E0 = INT_MAX, /* Unsigned overflow wraps around. */ E1 = UINT_MAX + 1, /* Overflow in an unevaluated part of an expression is OK (example in the standard). */ E2 = 2 || 1 / 0, /* { dg-bogus "warning: division by zero" "" { xfail *-*-* } 14 } */ E3 = 1 / 0, /* { dg-warning "division by zero" } */ /* { dg-error "enumerator value for 'E3' is not an integer constant" "enum error" { target *-*-* } 15 } */ /* But as in DR#031, the 1/0 in an evaluated subexpression means the whole expression violates the constraints. */ E4 = 0 * (1 / 0), /* { dg-warning "division by zero" } */ /* { dg-error "enumerator value for 'E4' is not an integer constant" "enum error" { xfail *-*-* } 19 } */ E5 = INT_MAX + 1, /* { dg-warning "integer overflow in expression" } */ /* { dg-warning "overflow in constant expression" "constant" { target *-*-* } 21 } */ /* Again, overflow in evaluated subexpression. */ E6 = 0 * (INT_MAX + 1), /* { dg-warning "integer overflow in expression" } */ /* { dg-warning "overflow in constant expression" "constant" { target *-*-* } 24 } */ /* A cast does not constitute overflow in conversion. */ E7 = (char) INT_MAX }; struct s { int a; int : 0 * (1 / 0); /* { dg-warning "division by zero" } */ int : 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */ /* { dg-warning "overflow in constant expression" "constant" { target *-*-* } 33 } */ }; void f (void) { /* This expression is not required to be a constant expression, so it should just involve undefined behavior at runtime. */ int c = INT_MAX + 1; /* { dg-warning "integer overflow in expression" } */ } /* This expression is neither required to be constant. */ static int sc = INT_MAX + 1; /* { dg-warning "integer overflow in expression" } */ // Test for overflow in null pointer constant. void *n = 0; /* The first two of these involve overflow, so are not null pointer constants. The third has the overflow in an unevaluated subexpression, so is a null pointer constant. */ void *p = 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */ /* { dg-warning "invalid conversion from 'int' to 'void" "null" { target *-*-* } 55 } */ void *q = 0 * (1 / 0); /* { dg-warning "division by zero" } */ /* { dg-warning "invalid conversion from 'int' to 'void*'" "null" { xfail *-*-* } 58 } */ void *r = (1 ? 0 : INT_MAX+1); /* { dg-bogus "integer overflow in expression" "" { xfail *-*-* } 60 } */ void g (int i) { switch (i) { case 0 * (1/0): /* { dg-warning "division by zero" } */ ; case 1 + 0 * (INT_MAX + 1): /* { dg-warning "integer overflow in expression" } */ /* { dg-warning "overflow in constant expression" "constant" { target *-*-* } 69 } */ ; } } int h (void) { return INT_MAX + 1; /* { dg-warning "integer overflow in expression" } */ } int h1 (void) { return INT_MAX + 1 - INT_MAX; /* { dg-warning "integer overflow in expression" } */ } void fuc (unsigned char); void fsc (signed char); void h2 (void) { fsc (SCHAR_MAX + 1); /* { dg-warning "overflow in implicit constant conversion" } */ fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in implicit constant conversion" } */ fsc (UCHAR_MAX); /* { dg-warning "overflow in implicit constant conversion" } */ fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in implicit constant conversion" } */ fuc (-1); fuc (UCHAR_MAX + 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */ fuc (SCHAR_MIN); fuc (SCHAR_MIN - 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */ fuc (-UCHAR_MAX); /* { dg-warning "large integer implicitly truncated to unsigned type" } */ } void fui (unsigned int); void fsi (signed int); int si; unsigned ui; void h2i (int x) { /* For some reason, we only give certain warnings for implicit conversions among values of the same precision with -Wconversion, while we don't give others at all. */ fsi ((unsigned)INT_MAX + 1); si = (unsigned)INT_MAX + 1; si = x ? (unsigned)INT_MAX + 1 : 1; fsi ((unsigned)INT_MAX + 2); si = (unsigned)INT_MAX + 2; si = x ? (unsigned)INT_MAX + 2 : 1; fsi (UINT_MAX); si = UINT_MAX; fui (-1); ui = -1; ui = x ? -1 : 1U; fui (INT_MIN); ui = INT_MIN; ui = x ? INT_MIN : 1U; }
google
chromium
volatile1
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/volatile1.C
174
utf_8
5cc9f29112baf492791a6e061240f16e
// PR c++/26577 struct A { A(const A&); A& operator=(const A&); void baz() volatile; }; void A::baz() volatile { *this; // { dg-warning "will not be accessed" } }
google
chromium
Wstring-literal-comparison-4
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wstring-literal-comparison-4.C
336
utf_8
839fdbb04e93708d893f0f0e3f961ef5
/* PR c/7776 */ /* { dg-do compile } */ /* { dg-options "-Wall -Wno-address" } */ int test1(char *ptr) { return ptr == "foo"; } int test2() { return "foo" != (const char*)0; } int test3() { return "foo" == (const char*)0; } int test4() { return (const char*)0 != "foo"; } int test5() { return (const char*)0 == "foo"; }
google
chromium
pragma-system_header2
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/pragma-system_header2.C
329
utf_8
9bcc53cc5dde27e75ab5715ac9f3c8aa
// PR c++/30500 // { dg-options "-Wconversion" } #include "pragma-system_header2.h" void f() { g<int>(); h<int>(); } // { dg-warning "conversion" "" { target *-*-* } 2 } // { dg-warning "conversion" "" { target *-*-* } 5 } // I couldn't find another way to make this work. // { dg-prune-output "In file included from" }
google
chromium
Wshadow-4
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wshadow-4.C
703
utf_8
cb568c46e03078f29a2040ab53ab0387
// PR c++/39526 // { dg-options "-Wshadow" } class INetURLObject { public: INetURLObject(int i); int GetMainURL() const; }; int foo(int infoo) // { dg-warning "shadowed declaration" } { int outfoo( INetURLObject( infoo ).GetMainURL()); // { dg-bogus "shadows" } extern void f(int infoo); struct A { void f(int infoo) { } // { dg-warning "shadows a parameter" } }; return outfoo; } // PR c++/39763 int foo2(void) { int infoo = 0; // { dg-warning "shadowed declaration" } int outfoo( INetURLObject( infoo ).GetMainURL()); // { dg-bogus "shadows" } struct A { void f(int infoo) { } // { dg-warning "shadows a previous local" } }; return outfoo; }
google
chromium
Wparentheses-25
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wparentheses-25.C
9,471
utf_8
c800cdb325b2c16421f6bdf47aae1930
/* PR 7543. Test operation of -Wparentheses. Precedence warnings. !a | b and !a & b. */ /* { dg-do compile } */ /* { dg-options "-Wparentheses" } */ // C++ version of Wparentheses-11.c int foo (int); int bar (int a, int b, int c) { foo (!a & b); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a & (b < c)); foo (!a & (b > c)); foo (!a & (b == c)); foo (!a & (b != c)); foo (!a & (b <= c)); foo (!a & (b >= c)); foo (!a & (b && c)); foo (!a & (b || c)); foo (!a & !b); foo (!(a & b)); foo ((!a) & b); foo (!a & 2); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a & (2 < c)); foo (!a & (2 > c)); foo (!a & (2 == c)); foo (!a & (2 != c)); foo (!a & (2 <= c)); foo (!a & (2 >= c)); foo (!a & (2 && c)); foo (!a & (2 || c)); foo (!a & !2); foo (!(a & 2)); foo ((!a) & 2); foo (!1 & 2); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!1 & (2 < c)); foo (!1 & (2 > c)); foo (!1 & (2 == c)); foo (!1 & (2 != c)); foo (!1 & (2 <= c)); foo (!1 & (2 >= c)); foo (!1 & (2 && c)); foo (!1 & (2 || c)); foo (!1 & !2); foo (!(1 & 2)); foo (!a | b); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a | (b < c)); foo (!a | (b > c)); foo (!a | (b == c)); foo (!a | (b != c)); foo (!a | (b <= c)); foo (!a | (b >= c)); foo (!a | (b && c)); foo (!a | (b || c)); foo (!a | !b); foo (!(a | b)); foo ((!a) | b); foo (!a | 2); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a | (2 < c)); foo (!a | (2 > c)); foo (!a | (2 == c)); foo (!a | (2 != c)); foo (!a | (2 <= c)); foo (!a | (2 >= c)); foo (!a | (2 && c)); foo (!a | (2 || c)); foo (!a | !2); foo (!(a | 2)); foo ((!a) | 2); foo (!1 | 2); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!1 | (2 < c)); foo (!1 | (2 > c)); foo (!1 | (2 == c)); foo (!1 | (2 != c)); foo (!1 | (2 <= c)); foo (!1 | (2 >= c)); foo (!1 | (2 && c)); foo (!1 | (2 || c)); foo (!1 | !2); foo (!(1 | 2)); foo ((!1) | 2); foo (b & !a); /* { dg-bogus "parentheses" "bogus warning" } */ foo ((b < c) & !a); foo ((b > c) & !a); foo ((b == c) & !a); foo ((b != c) & !a); foo ((b <= c) & !a); foo ((b >= c) & !a); foo ((b && c) & !a); foo ((b || c) & !a); foo (!b & !a); foo (!(b & a)); foo (b & (!a)); foo (2 & !a); /* { dg-bogus "parentheses" "correct warning" } */ foo ((2 < c) & !a); foo ((2 > c) & !a); foo ((2 == c) & !a); foo ((2 != c) & !a); foo ((2 <= c) & !a); foo ((2 >= c) & !a); foo ((2 && c) & !a); foo ((2 || c) & !a); foo (!2 & !a); foo (!(2 & a)); foo (2 & (!a)); foo (2 & !1); /* { dg-bogus "parentheses" "correct warning" } */ foo ((2 < c) & !1); foo ((2 > c) & !1); foo ((2 == c) & !1); foo ((2 != c) & !1); foo ((2 <= c) & !1); foo ((2 >= c) & !1); foo ((2 && c) & !1); foo ((2 || c) & !1); foo (!2 & !1); foo (!(2 & 1)); foo (b | !a); /* { dg-bogus "parentheses" "correct warning" } */ foo ((b < c) | !a); foo ((b > c) | !a); foo ((b == c) | !a); foo ((b != c) | !a); foo ((b <= c) | !a); foo ((b >= c) | !a); foo ((b && c) | !a); foo ((b || c) | !a); foo (!b | !a); foo (!(b | a)); foo (b | (!a)); foo (2 | !a); /* { dg-bogus "parentheses" "correct warning" } */ foo ((2 < c) | !a); foo ((2 > c) | !a); foo ((2 == c) | !a); foo ((2 != c) | !a); foo ((2 <= c) | !a); foo ((2 >= c) | !a); foo ((2 && c) | !a); foo ((2 || c) | !a); foo (!2 | !a); foo (!(2 | a)); foo (2 | (!a)); foo (2 | !1); /* { dg-bogus "parentheses" "correct warning" } */ foo ((2 < c) | !1); foo ((2 > c) | !1); foo ((2 == c) | !1); foo ((2 != c) | !1); foo ((2 <= c) | !1); foo ((2 >= c) | !1); foo ((2 && c) | !1); foo ((2 || c) | !1); foo (!2 | !1); foo (!(2 | 1)); foo (2 | (!1)); } int baz (int a, int b, int c) { foo (!a & (b << c));/* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a & (b >> c));/* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a & (b + c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a & (b - c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a & (b = c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a & ~b); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a & (b & c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a & (b | c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a & 2); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a & (2 << c));/* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a & (2 >> c));/* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a & (2 + c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a & (2 - c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a & (c = 2)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a & ~2); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a & (2 & c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a & (2 | c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!1 & (2 << c));/* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!1 & (2 >> c));/* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!1 & (2 + c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!1 & (2 - c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!1 & (c = 2)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!1 & ~2); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!1 & (2 & c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!1 & (2 | c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a | (b << c));/* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a | (b >> c));/* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a | (b + c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a | (b - c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a | (b = c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a | ~b); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a | (b & c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a | (b | c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a | (2 << c));/* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a | (2 >> c));/* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a | (2 + c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a | (2 - c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a | (c = 2)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a | ~2); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a | (2 & c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!a | (2 | c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!1 | (2 << c));/* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!1 | (2 >> c));/* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!1 | (2 + c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!1 | (2 - c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!1 | (c = 2)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!1 | ~2); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!1 | (2 & c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo (!1 | (2 | c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ foo ((b << c) & !a); foo ((b >> c) & !a); foo ((b + c) & !a); foo ((b - c) & !a); foo ((b = c) & !a); foo (~b & !a); foo ((b & c) & !a); foo ((b | c) & !a); foo ((2 << c) & !a); foo ((2 >> c) & !a); foo ((2 + c) & !a); foo ((2 - c) & !a); foo ((c = 2) & !a); foo (~2 & !a); foo ((2 & c) & !a); foo ((2 | c) & !a); foo ((2 << c) & !1); foo ((2 >> c) & !1); foo ((2 + c) & !1); foo ((2 - c) & !1); foo ((c = 2) & !1); foo (~2 & !1); foo ((2 & c) & !1); foo ((2 | c) & !1); foo ((b << c) | !a); foo ((b >> c) | !a); foo ((b + c) | !a); foo ((b - c) | !a); foo ((b = c) | !a); foo (~b | !a); foo ((b & c) | !a); foo ((b | c) | !a); foo ((2 << c) | !a); foo ((2 >> c) | !a); foo ((2 + c) | !a); foo ((2 - c) | !a); foo ((c = 2) | !a); foo (~2 | !a); foo ((2 & c) | !a); foo ((2 | c) | !a); foo ((2 << c) | !1); foo ((2 >> c) | !1); foo ((2 + c) | !1); foo ((2 - c) | !1); foo ((c = 2) | !1); foo (~2 | !1); foo ((2 & c) | !1); foo ((2 | c) | !1); }
google
chromium
missing-field-init-2
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/missing-field-init-2.C
469
utf_8
5810653b0c8f7de9557f67564c81fa60
/* { dg-do compile } */ /* { dg-options "-Wmissing-field-initializers" } */ struct s { int a, b, c; }; struct s s1 = { 1, 2, 3 }; struct s s2 = { 1, 2 }; /* { dg-warning "(missing initializer)|(near initialization)" } */ struct s s3[] = { { 1, 2 }, { 4, 5 } }; /* { dg-warning "(missing initializer)|(near initialization)" } */ struct s s4[] = { 1, 2, 3, 4, 5 }; /* { dg-warning "(missing initializer)|(near initialization)" } */ struct s s5[] = { 1, 2, 3, 4, 5, 6 };
google
chromium
format4
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/format4.C
301
utf_8
127a75cc2feba3be6bc12b766e660668
// { dg-do compile } // { dg-options "-Wformat=2" } extern "C" int printf (const char*, ...); void foo(int i) { printf("Hello World %d!\n", i); printf(&"Hello World %d!\n"[0], i); printf(&"Hello World %d!\n"[6], i); printf(&"Hello World %d!\n"[8]-2, i); printf(&"Hello World %d!\n"[4]+2, i); }
google
chromium
pr33160
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/pr33160.C
244
utf_8
e8794ff206600f5a49415327a54a5bf8
// PR 33160 // { dg-do compile } // { dg-options "-Wall -Wextra -Wpointer-arith -pedantic -Wconversion" } typedef int __attribute__((mode(pointer))) intptr_t; int foo(void) { intptr_t t = 0; if (t != ((intptr_t)__null)) t = 1; return 0; }
google
chromium
Wnvdtor
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wnvdtor.C
118
utf_8
17ce52166f1ac71872bcacc58c562353
// { dg-options "-Wnon-virtual-dtor" } extern "Java" { class Foo { public: virtual void bar( void); }; }
google
chromium
pr35635
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/pr35635.C
3,263
utf_8
ab2522c9f88b8ca84af673f1f53b5c2f
/* PR 35635 */ /* { dg-do compile } */ /* { dg-options "-Wconversion -Wsign-conversion" } */ struct unsigned_bit { unsigned int x:1; } unsigned_bit; struct signed_bit { int x:1; } signed_bit; int bar; int bar2; void func1() { /* The result of boolean operators fits in unsiged int:1, thus do not warn. */ unsigned_bit.x = (bar != 0); /* { dg-bogus "conversion" } */ unsigned_bit.x = (bar == 0); /* { dg-bogus "conversion" } */ unsigned_bit.x = (bar <= 0); /* { dg-bogus "conversion" } */ unsigned_bit.x = (bar >= 0); /* { dg-bogus "conversion" } */ unsigned_bit.x = (bar < 0); /* { dg-bogus "conversion" } */ unsigned_bit.x = (bar > 0); /* { dg-bogus "conversion" } */ unsigned_bit.x = !bar; /* { dg-bogus "conversion" } */ unsigned_bit.x = (bar || bar2); /* { dg-bogus "conversion" } */ unsigned_bit.x = (bar && bar2); /* { dg-bogus "conversion" } */ /* Both branches of ? fit in the destination, thus do not warn. */ unsigned_bit.x = bar != 0 ? 1 : 0; /* { dg-bogus "conversion" } */ unsigned_bit.x = bar != 0 ? 1.0 : 0.0; /* { dg-bogus "conversion" } */ /* At least one branch of ? does not fit in the destination, thus warn. */ unsigned_bit.x = bar != 0 ? 2 : 0; /* { dg-warning "conversion" } */ unsigned_bit.x = bar != 0 ? 0 : -1; /* { dg-warning "conver" } */ } void func2() { signed char schar_x; /* Both branches of ? fit in the destination, thus do not warn. */ schar_x = bar != 0 ? 1 : 0; /* { dg-bogus "conversion" } */ schar_x = bar != 0 ? 2.0 : 10; /* { dg-bogus "conversion" } */ /* At least one branch of ? does not fit in the destination, thus warn. */ schar_x = bar != 0 ? 2.1 : 10; /* { dg-warning "conversion" } */ schar_x = bar != 0 ? (signed char) 1024: -1024; /* { dg-warning "conversion" } */ } void func3() { unsigned char uchar_x; /* Both branches of ? fit in the destination, thus do not warn. */ uchar_x = bar != 0 ? 1 : 0; uchar_x = bar != 0 ? 2.0 : 10; /* At least one branch of ? does not fit in the destination, thus warn. */ uchar_x = bar != 0 ? 2.1 : 10; /* { dg-warning "conversion" } */ uchar_x = bar != 0 ? (unsigned char) 1024 : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ } void func4() { signed_bit.x = -1; /* { dg-bogus "conversion" } */ signed_bit.x = bar != 0 ? -1.0 : 0.0; /* { dg-bogus "conversion" } */ signed_bit.x = bar != 0 ? -1 : 0; /* { dg-bogus "conversion" } */ signed_bit.x = 1; /* { dg-warning "conversion" } */ signed_bit.x = (bar != 0); /* { dg-warning "conversion" } */ signed_bit.x = (bar == 0); /* { dg-warning "conversion" } */ signed_bit.x = (bar <= 0); /* { dg-warning "conversion" } */ signed_bit.x = (bar >= 0); /* { dg-warning "conversion" } */ signed_bit.x = (bar < 0); /* { dg-warning "conversion" } */ signed_bit.x = (bar > 0); /* { dg-warning "conversion" } */ signed_bit.x = !bar; /* { dg-warning "conversion" } */ signed_bit.x = (bar || bar2); /* { dg-warning "conversion" } */ signed_bit.x = (bar && bar2); /* { dg-warning "conversion" } */ signed_bit.x = bar != 0 ? 1 : 0; /* { dg-warning "conversion" } */ signed_bit.x = bar != 0 ? 2 : 0; /* { dg-warning "conversion" } */ }
google
chromium
Wunused-5
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wunused-5.C
270
utf_8
a1eac98a6496704d61be03bb58327d0f
/* PR opt/14288 */ /* { dg-do compile } */ /* { dg-options "-O -Wall" } */ volatile int sink; extern int foo(int); struct S { int x; S() { x = foo(0); } ~S() { sink = x; } }; int test(bool p) { return p ? foo(S().x) : 0; /* { dg-bogus "uninitialized" } */ }
google
chromium
Wswitch-default-2
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wswitch-default-2.C
267
utf_8
2908bb9b9b3a7ea3f41f0effd0934ce0
// PR C++/21123 /* { dg-do compile } */ /* { dg-options "-Wswitch-default" } */ template <typename ArrayType> void foo( ) { int i = 0; switch ( i ) /* { dg-warning "switch missing default case" } */ { case 9: break; } } void f() { foo<int>(); }
google
chromium
Wunused-7
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wunused-7.C
163
utf_8
c969e351f86316e8ad9196c0ce95cd3c
// PR c++/14481 // { dg-options "-Wunused" } void func() { struct mybitfields { unsigned int s_field:8; }; struct mybitfields s; s.s_field = 255; };
google
chromium
Wconversion-integer
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wconversion-integer.C
3,114
utf_8
2087b0b8d0d8185a0532862748386767
/* Test for diagnostics for implicit conversions between integer types C++ equivalent of gcc/testsuite/gcc.dg/Wconversion-integer.c */ // { dg-do compile } // { dg-options "-fsigned-char -Wconversion" } #include <limits.h> void fsc (signed char sc); void fuc (unsigned char uc); unsigned fui (unsigned int ui); void fsi (signed int ui); void h (int x) { unsigned int ui = 3; int si = 3; unsigned char uc = 3; signed char sc = 3; uc = ui; /* { dg-warning "conversion" } */ uc = si; /* { dg-warning "conversion" } */ sc = ui; /* { dg-warning "conversion" } */ sc = si; /* { dg-warning "conversion" } */ fuc (ui); /* { dg-warning "conversion" } */ fuc (si); /* { dg-warning "conversion" } */ fsc (ui); /* { dg-warning "conversion" } */ fsc (si); /* { dg-warning "conversion" } */ fsi (si); fui (ui); fsi (uc); si = uc; fui (uc); ui = uc; fui ('A'); ui = 'A'; fsi ('A'); si = 'A'; fuc ('A'); uc = 'A'; uc = x ? 1U : -1; /* { dg-warning "conversion" } */ uc = x ? SCHAR_MIN : 1U; /* { dg-warning "conversion" } */ uc = x ? 1 : -1; /* Warned by -Wsign-conversion. */ uc = x ? SCHAR_MIN : 1; /* Warned by -Wsign-conversion. */ ui = x ? 1U : -1; /* Warned by -Wsign-conversion. */ ui = x ? INT_MIN : 1U; /* Warned by -Wsign-conversion. */ ui = ui ? SCHAR_MIN : 1U; /* Warned by -Wsign-conversion. */ ui = 1U * -1; /* Warned by -Wsign-conversion. */ ui = ui + INT_MIN; /* Warned by -Wsign-conversion. */ ui = x ? 1 : -1; /* Warned by -Wsign-conversion. */ ui = ui ? SCHAR_MIN : 1; /* Warned by -Wsign-conversion. */ fuc (-1); /* Warned by -Wsign-conversion. */ uc = -1; /* Warned by -Wsign-conversion. */ fui (-1); /* Warned by -Wsign-conversion. */ ui = -1; /* Warned by -Wsign-conversion. */ fuc ('\xa0'); /* Warned by -Wsign-conversion. */ uc = '\xa0'; /* Warned by -Wsign-conversion. */ fui ('\xa0'); /* Warned by -Wsign-conversion. */ ui = '\xa0'; /* Warned by -Wsign-conversion. */ fsi (0x80000000); /* Warned by -Wsign-conversion. */ si = 0x80000000; /* Warned by -Wsign-conversion. */ fsi (UINT_MAX - 1); /* Warned by -Wsign-conversion. */ si = UINT_MAX - 1; /* Warned by -Wsign-conversion. */ fsi (UINT_MAX - 1U); /* Warned by -Wsign-conversion. */ si = UINT_MAX - 1U; /* Warned by -Wsign-conversion. */ fsi (UINT_MAX/3U); si = UINT_MAX/3U; fsi (UINT_MAX/3); si = UINT_MAX/3; fui (UINT_MAX - 1); ui = UINT_MAX - 1; uc = (unsigned char) -1; ui = -1 * (1 * -1); ui = (unsigned) -1; fsc (uc); /* Warned by -Wsign-conversion. */ sc = uc; /* Warned by -Wsign-conversion. */ fuc (sc); /* Warned by -Wsign-conversion. */ uc = sc; /* Warned by -Wsign-conversion. */ fsi (ui); /* Warned by -Wsign-conversion. */ si = ui; /* Warned by -Wsign-conversion. */ fui (si); /* Warned by -Wsign-conversion. */ ui = si; /* Warned by -Wsign-conversion. */ fui (sc); /* Warned by -Wsign-conversion. */ ui = sc; /* Warned by -Wsign-conversion. */ } unsigned fui (unsigned a) { return a + -1; } /* Warned by -Wsign-conversion. */
google
chromium
nonnull1
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/nonnull1.C
430
utf_8
40efbe938691eeff621e7ef02235827f
// Test that "nonnull" attribute works for C++. // { dg-do compile } // { dg-options "-Wall" } // The "nonnull" attribute is thoroughly tested for C, so here we // simply test that it works at all, as at one point the relevant // checking code was only called for C. extern void f (char *) __attribute__((nonnull)); void g () { f (0); // { dg-warning "null" "null argument" } }
google
chromium
Wsequence-point-pr18050
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wsequence-point-pr18050.C
414
utf_8
8fb4b9a6c1d26c1e9bde7782d85ab4db
/* PR 18050 : bogus warning with -Wsequence-point */ /* { dg-do compile } */ /* { dg-options "-Wsequence-point" } */ struct x { int i; }; void bar(struct x*, int *); void foo(struct x *y) { bar(y++, &y->i); /* { dg-warning "operation on 'y' may be undefined" } */ } void zz(int a, int *b) { *b = a; } void baz(void) { int a = 5; zz(++a, &a); /* { dg-bogus "operation on 'a' may be undefined" } */ }
google
chromium
Wconversion2
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wconversion2.C
132
utf_8
f4ec0cfd531d7446511e8f16049b47e1
// { dg-options "-Wconversion" } void foo(const char *); void bar() { foo(false); } // { dg-warning "pointer type for argument" }
google
chromium
Wchar-subscripts-2
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wchar-subscripts-2.C
235
utf_8
d15107f3d840c1f7539a3dc2f640a5df
/* PR c++/16307 */ // { dg-do compile } // { dg-options "-Wchar-subscripts" } extern volatile char bla; char foo (const char *s) { return s [bla]; // { dg-warning "array subscript" } } int main () { foo ("\x80"); }
google
chromium
Wunused-11
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wunused-11.C
171
utf_8
509e856e0fc2084da098b641f1d63e89
// PR c++/20212 // { dg-options "-O2 -Wunused -Wextra" } template<int> void f(int); void g(int i) { f<0>(i); } template<int> void f(int i __attribute__((unused)) ) {}
google
chromium
write-strings-default
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/write-strings-default.C
140
utf_8
41dc346d5678dfa4632f8a0389b3f2c2
// { dg-do compile } // Test the default for -Wwrite-strings int main() { char* p = "Asgaard"; // { dg-warning "deprecated" } }
google
chromium
var-args1
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/var-args1.C
169
utf_8
aee910320aa561272260bfc2fcc381f9
/* { dg-do compile } */ #include <stdarg.h> void foo(int, ...) { va_list va; int i; i = va_arg(va, int&); /* { dg-warning "cannot receive objects" } */ }
google
chromium
pr8570
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/pr8570.C
334
utf_8
8e67188b7bdbe0df3618b69da33f302a
// PR c++/8570 // { dg-do compile } // { dg-options "" } template <typename T, typename P> class X { // { dg-message "note: previous declaration .* used 2" } public: X() { } private: template <typename U> friend class X; // { dg-error "redeclared with 1 template parameter" } }; X<int, int> i; // { dg-message "instantiated" }
google
chromium
Wextra-2
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wextra-2.C
307
utf_8
fd872aba23fcbd09e4b5cb3b61dbaadf
// { dg-options "-Wextra" } struct S { S(); }; struct T { private: int i; public: // There should be no warning about this data member because the // default constructor for "T" will invoke the default constructor // for "S", even though "S" is "const". const S s; // { dg-bogus "const" } };
google
chromium
Wstrict-aliasing-bogus-const
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-const.C
194
utf_8
ac260e0cd387ad68b172cae5830684be
/* { dg-do compile } */ /* { dg-options "-O2 -Wstrict-aliasing -fstrict-aliasing" } */ int foo(int* p) { const int& q = *p; /* { dg-bogus "const vs. non-const" } */ *p = 1; return q; }
google
chromium
Wparentheses-5
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wparentheses-5.C
316
utf_8
2e05be0ce305723a94a4113e02835003
// { dg-do compile } // { dg-options -Wparentheses } // C++ version of gcc.dg/Wparentheses-1.c. int foo (int a, int b) { int c = (a && b) || 0; // { dg-bogus "suggest parentheses" } c = a && b || 0; // { dg-warning "suggest parentheses" } return (a && b && 1) || 0; // { dg-bogus "suggest parentheses" } }
google
chromium
Wstrict-aliasing-bogus-struct-included
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-struct-included.C
269
utf_8
73aa8fdd361564d9ba904d4252613717
/* { dg-do compile } */ /* { dg-options "-O2 -Wstrict-aliasing -fstrict-aliasing" } */ struct S { int i; float f; }; int foo () { struct S s; s.i = 7; float* f = &s.f; /* { dg-bogus "float included in struct S" } */ *f = 2.0; return s.i + (int)s.f; }
google
chromium
Wenum-compare
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wenum-compare.C
237
utf_8
37c21b63185cc6eb45eceb0b75e600a3
/* Test that we get the -Wenum-compare by default. See PR27975. */ /* { dg-do compile } */ /* { dg-options "" } */ enum E1 { a }; enum E2 { b }; int foo (E1 e1, E2 e2) { return e1 == e2; /* { dg-warning "comparison between" } */ }
google
chromium
unit-1
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/unit-1.C
210
utf_8
6d4a9123531aa6035c839c056617799a
/* { dg-do compile } */ /* { dg-options "-O2 -Wuninitialized" } */ struct a { int mode; }; int sys_msgctl (void) { struct a setbuf; /* { dg-warning "'setbuf\.a::mode' is used" } */ return setbuf.mode; }
google
chromium
miss-format-1
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/miss-format-1.C
1,111
utf_8
07fe4fb2b51d4221c1df7237e70070f8
/* { dg-do compile } */ /* { dg-options "-Wmissing-format-attribute" } */ /* { dg-options "-Wmissing-format-attribute -Wno-abi" { target arm_eabi } } */ /* VxWorks does not provide vscanf, either in kernel or RTP mode. */ /* { dg-error "not declared" "" { target *-*-solaris2.[7-8] *-*-vxworks* } 25 } */ #include <stdio.h> #include <stdarg.h> void foo (const char *fmt, ...) { va_list ap; va_start (ap, fmt); vprintf (fmt, ap); /* { dg-warning "candidate" "printf attribute warning" } */ va_end (ap); } void bar (const char *fmt, ...) { va_list ap; va_start (ap, fmt); vscanf (fmt, ap); /* { dg-warning "candidate" "scanf attribute warning" { xfail *-*-solaris2.[7-8] *-*-vxworks* } } */ va_end (ap); } __attribute__((__format__(__printf__, 1, 2))) void foo2 (const char *fmt, ...) { va_list ap; va_start (ap, fmt); vprintf (fmt, ap); va_end (ap); } void vfoo (const char *fmt, va_list arg) { vprintf (fmt, arg); /* { dg-warning "candidate" "printf attribute warning 2" } */ }
google
chromium
Wparentheses-24
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wparentheses-24.C
150
utf_8
30a2aacc6bcdb30c12ed12f8648679cc
// { dg-do compile } // { dg-options "-Wparentheses" } extern int foo (int); bool a, b, c; bool bar () { c = a = b; foo (0); return a = b; }
google
chromium
Woverloaded-1
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Woverloaded-1.C
217
utf_8
4d3b7ed38b5e078db7e76014e7eab321
/* { dg-options "-Woverloaded-virtual" } */ class Base { public: virtual ~Base() { } }; class Derived: public Base { public: int Base() { // There should be no error here. return 5; } }; int main() { }
google
chromium
Wreturn-2
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wreturn-2.C
118
utf_8
6a9ad99dea244e7a1d6655a1e95ccfea
// { dg-do compile } int foo(int first) { while (true) { return first; } } // { dg-bogus "control reaches" }
google
chromium
pr30551-2
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/pr30551-2.C
361
utf_8
eb7f623d124b0bcc1f9722099c010844
// PR 30551 -Wmain is enabled by -pedantic/-pedantic-errors. // { dg-do compile } // { dg-options "-pedantic-errors" } // { dg-skip-if "-Wmain not enabled with -pedantic on SPU" { spu-*-* } } int main(char a) {} /* { dg-error "first argument of .*main.* should be .int." } */ /* { dg-error "main.* takes only zero or two arguments" "" { target *-*-* } 5 } */
google
chromium
huge-val1
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/huge-val1.C
623
utf_8
e81d20f2a65cb672129118ceab24cd3e
// PR c++/23139: HUGE_VAL definition should be accepted with -pedantic. // { dg-do link } // { dg-options "-pedantic-errors" } #include <math.h> double d = HUGE_VAL; #ifdef HUGE_VALF float f = HUGE_VALF; #endif #ifdef HUGE_VALL long double l = HUGE_VALL; #endif extern void link_failure (); int main () { #ifdef __GLIBC__ if (HUGE_VAL != __builtin_huge_val ()) link_failure (); #ifdef HUGE_VALF if (HUGE_VALF != __builtin_huge_valf ()) link_failure (); #endif #ifdef HUGE_VALL if (HUGE_VALL != __builtin_huge_vall ()) link_failure (); #endif #endif }
google
chromium
Wreturn-type-1
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wreturn-type-1.C
123
utf_8
784c916e3f956afe80f26ff565b29be6
// PR c++/11725 // { dg-options "-Wreturn-type" } template <class T> struct A { int foo() { throw "Stop"; } };
google
chromium
pr11159
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/pr11159.C
383
utf_8
adea0a023eba0c3c51b6a4894014d35a
// PR c++/11159 : erroneous warning in copy ctor with virtual inheritance // { dg-do compile } // { dg-options "-Wall -Wextra" } struct A { A (); }; struct B : virtual A { B (); }; struct C : virtual A { C (); }; struct D : B, C { D (D const&){} }; template <typename Base> struct E : Base { E (); E (E const &) : Base () { }; }; E<C> foo; E<C> bar (foo);
google
chromium
noreturn-6
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/noreturn-6.C
240
utf_8
c5311890f0c28242d0882ede510185e1
// PR c++/30988 // { dg-do compile } // { dg-options "-O2 -Wall" } void f (const char *); template <typename T> struct A { int g () { f (__FUNCTION__); } // { dg-warning "no return statement in function returning non-void" } };
google
chromium
noreturn-7
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/noreturn-7.C
318
utf_8
f5f5c1617ee81b4a95bfe5a2c43b2cf3
// PR c++/30988 // { dg-do compile } // { dg-options "-O2 -Wall" } void f (const char *) __attribute__ ((noreturn)); void f (int); void f (double) __attribute__ ((noreturn)); template <typename T> struct A { int g () { f ((T) 0); } // { dg-warning "no return statement in function returning non-void" } };
google
chromium
Wsign-conversion
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wsign-conversion.C
3,684
utf_8
b338731942d8716fd302c4acb247e53a
/* Test for diagnostics for implicit conversions between signed and unsigned integer types. C++ equivalent of gcc/testsuite/gcc.dg/Wsign-conversion.c */ // { dg-do compile } // { dg-options "-fsigned-char -Wsign-conversion" } #include <limits.h> void fsc (signed char sc); void fuc (unsigned char uc); unsigned fui (unsigned int ui); void fsi (signed int ui); void h (int x) { unsigned int ui = 3; int si = 3; unsigned char uc = 3; signed char sc = 3; uc = ui; uc = si; sc = ui; sc = si; fuc (ui); fuc (si); fsc (ui); fsc (si); fsi (si); fui (ui); fsi (uc); si = uc; fui (uc); ui = uc; fui ('A'); ui = 'A'; fsi ('A'); si = 'A'; fuc ('A'); uc = 'A'; uc = x ? 1U : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ uc = x ? SCHAR_MIN : 1U; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ uc = x ? 1 : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ uc = x ? SCHAR_MIN : 1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ ui = x ? 1U : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ ui = x ? INT_MIN : 1U; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ ui = ui ? SCHAR_MIN : 1U; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ ui = 1U * -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ ui = ui + INT_MIN; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ ui = x ? 1 : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ ui = ui ? SCHAR_MIN : 1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ fuc (-1); /* { dg-warning "negative integer implicitly converted to unsigned type" } */ uc = -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ fui (-1); /* { dg-warning "negative integer implicitly converted to unsigned type" } */ ui = -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ fuc ('\xa0'); /* { dg-warning "negative integer implicitly converted to unsigned type" } */ uc = '\xa0'; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ fui ('\xa0');/* { dg-warning "negative integer implicitly converted to unsigned type" } */ ui = '\xa0'; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ fsi (0x80000000); /* { dg-warning "conversion" } */ si = 0x80000000; /* { dg-warning "conversion" } */ fsi (UINT_MAX - 1); /* { dg-warning "conversion" } */ si = UINT_MAX - 1; /* { dg-warning "conversion" } */ fsi (UINT_MAX - 1U); /* { dg-warning "conversion" } */ si = UINT_MAX - 1U; /* { dg-warning "conversion" } */ fsi (UINT_MAX/3U); si = UINT_MAX/3U; fsi (UINT_MAX/3); si = UINT_MAX/3; fui (UINT_MAX - 1); ui = UINT_MAX - 1; uc = (unsigned char) -1; ui = -1 * (1 * -1); ui = (unsigned) -1; fsc (uc); /* { dg-warning "conversion" } */ sc = uc; /* { dg-warning "conversion" } */ fuc (sc); /* { dg-warning "conversion" } */ uc = sc; /* { dg-warning "conversion" } */ fsi (ui); /* { dg-warning "conversion" } */ si = ui; /* { dg-warning "conversion" } */ fui (si); /* { dg-warning "conversion" } */ ui = si; /* { dg-warning "conversion" } */ fui (sc); /* { dg-warning "conversion" } */ ui = sc; /* { dg-warning "conversion" } */ } unsigned fui (unsigned a) { return a + -1; } /* { dg-warning "negative integer implicitly converted to unsigned type" } */
google
chromium
pedantic1
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/pedantic1.C
184
utf_8
a17c4c0444990921d3c66161e1a84c51
// PR10032 // { dg-options "-pedantic" } int main() { goto label; // { dg-error "" } int temp = 1; // { dg-error "" } label: // { dg-error "" } return 1; }
google
chromium
Wstrict-aliasing-5
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-5.C
188
utf_8
f203af23e924be80d891b0c53a7bee3e
/* { dg-do compile } */ /* { dg-options "-Wstrict-aliasing=2 -O2" } */ float foo () { unsigned int MASK = 0x80000000; return (float &) MASK; /* { dg-warning "strict-aliasing" } */ }
google
chromium
Wstrict-aliasing-bogus-placement-new
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-placement-new.C
415
utf_8
f345b06fca626501d991adc9447c18e0
/* { dg-do compile } */ /* { dg-options "-O2 -Wstrict-aliasing" } */ inline void *operator new (__SIZE_TYPE__, void *__p) throw() { return __p; } struct Y { Y() {} int i; }; struct X { X() {} void construct(const Y& y) { new (&m_data[0]) Y(y); } bool initialized; char m_data[sizeof (Y)]; }; void bar(const X&); void foo(Y& y) { X x; x.construct(y); x.initialized = true; bar(x); }
google
chromium
Wstring-literal-comparison-1
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wstring-literal-comparison-1.C
374
utf_8
b2ac295c001e28b6659dd1cbaecfc2a9
/* PR c/7776 */ /* { dg-do compile } */ /* { dg-options "-Waddress" } */ int test1(char *ptr) { return ptr == "foo"; /* { dg-warning "comparison with string" } */ } int test2() { return "foo" != (const char*)0; } int test3() { return "foo" == (const char*)0; } int test4() { return (const char*)0 != "foo"; } int test5() { return (const char*)0 == "foo"; }
google
chromium
deprecated-2
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/deprecated-2.C
305
utf_8
26bafcbe2a9f3729e0b0e2ff8ccf5317
/* Test __attribute__((deprecated)). Test merging with multiple declarations. Bug 7425 (C++ version). */ /* { dg-do compile } */ /* { dg-options "" } */ void func(void); void func(void) __attribute__((deprecated)); void f(void) { func(); /* { dg-warning "'void func\\(\\)' is deprecated" } */ }
google
chromium
Wunused-4
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wunused-4.C
553
utf_8
3c7c2b442d4bd62310dcfdd99d91e1b2
// { dg-do compile } // { dg-options "-Wunused-parameter" } // PR c++/9848. Missing warning struct C1 { // Only use in-charge ctor C1(int bi) {} // { dg-warning "unused parameter" "" } }; struct C2 { // Only use base ctor C2(int bi) {} // { dg-warning "unused parameter" "" } }; struct D : C2 { D (int) : C2 (1) {} }; void show_compile_warning () { C1 c1 (1); D d (1); }
google
chromium
Wparentheses-1
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wparentheses-1.C
1,661
utf_8
d1f22f759809f81b1b677be34f938b02
// Test operation of -Wparentheses. Warnings for assignments used as // truth-values. Essentially the same as gcc.dg/Wparentheses-3.c. // { dg-do compile } // { dg-options "-Wparentheses" } int foo (int); int a, b, c; bool d; void bar (void) { if (a = b) // { dg-warning "assignment" "correct warning" } foo (0); if ((a = b)) foo (1); if (a = a) // { dg-warning "assignment" "correct warning" } foo (2); if ((a = a)) foo (3); if (b = c) // { dg-warning "assignment" "correct warning" } foo (4); else foo (5); if ((b = c)) foo (6); else foo (7); if (b = b) // { dg-warning "assignment" "correct warning" } foo (8); else foo (9); if ((b = b)) foo (10); else foo (11); while (c = b) // { dg-warning "assignment" "correct warning" } foo (12); while ((c = b)) foo (13); while (c = c) // { dg-warning "assignment" "correct warning" } foo (14); while ((c = c)) foo (15); do foo (16); while (a = b); // { dg-warning "assignment" "correct warning" } do foo (17); while ((a = b)); do foo (18); while (a = a); // { dg-warning "assignment" "correct warning" } do foo (19); while ((a = a)); for (;c = b;) // { dg-warning "assignment" "correct warning" } foo (20); for (;(c = b);) foo (21); for (;c = c;) // { dg-warning "assignment" "correct warning" } foo (22); for (;(c = c);) foo (23); d = a = b; // { dg-warning "assignment" "correct warning" } foo (24); d = (a = b); foo (25); d = a = a; // { dg-warning "assignment" "correct warning" } foo (26); d = (a = a); foo (27); }
google
chromium
new1
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/new1.C
50
utf_8
f90f92d0ee11df948b19aaef9ca54cd1
void f() { new int[0]; // { dg-bogus "zero" } }
google
chromium
register-var-2
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/register-var-2.C
274
utf_8
ea73d6265dc16c3e8af8fcf468fbfdee
/* PR/18160 */ /* { dg-do compile } */ /* This should yield an error even without -pedantic. */ /* { dg-options "-Wall -W" } */ void g(int *); void f(void) { register int x; g(&x); /* { dg-warning "address requested for 'x', which is declared 'register'" } */ }
google
chromium
Wstrict-aliasing-bogus-escape-3
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-escape-3.C
386
utf_8
ef9cbc9a3736627428296e32dffe78fd
/* { dg-do compile } */ /* { dg-options "-O2 -Wstrict-aliasing" } */ struct Node_base {}; struct Node : Node_base { int data; }; struct List { Node_base node, *prev; List() : prev(&node) { xyz(); } void xyz(); int back() { return static_cast<Node*>(prev)->data; } }; struct A { virtual ~A(); }; A* foo(); void bar() { List y; if (y.back()) delete foo(); }
google
chromium
Wenum-compare-no
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/Wenum-compare-no.C
251
utf_8
0159dc16051c0a3deaba6db2eeae85f8
/* Test disabling -Wenum-compare (on by default). See PR27975. */ /* { dg-do compile } */ /* { dg-options "-Wno-enum-compare" } */ enum E1 { a }; enum E2 { b }; int foo (E1 e1, E2 e2) { return e1 == e2; /* { dg-bogus "comparison between" } */ }
google
chromium
format1
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/format1.C
471
utf_8
931d147f4baed695f1a67ae899cebd03
// Test that formats get checked according to C94. // { dg-do compile } // { dg-options "-ansi -pedantic -Wformat" } #include <cstdio> void foo (int i, int *ip, __WINT_TYPE__ lc, wchar_t *ls) { std::printf ("%d%ls%lc\n", i, ls, lc); std::printf ("%d", ls); // { dg-warning "format" "printf warning" } std::scanf ("%d%lc%ls%l[abc]", ip, ls, ls, ls); std::scanf ("%hd", ip); // { dg-warning "format" "scanf warning" } }
google
chromium
overflow-warn-4
.C
native_client/nacl-gcc/gcc/testsuite/g++.dg/warn/overflow-warn-4.C
4,544
utf_8
4aa78519246c6b2b640070e4fd79e697
/* { dg-do compile } */ /* { dg-options "-pedantic-errors" } */ #include <limits.h> enum e { E0 = INT_MAX, /* Unsigned overflow wraps around. */ E1 = UINT_MAX + 1, /* Overflow in an unevaluated part of an expression is OK (example in the standard). */ E2 = 2 || 1 / 0, /* { dg-bogus "warning: division by zero" "" { xfail *-*-* } 14 } */ E3 = 1 / 0, /* { dg-warning "division by zero" } */ /* { dg-error "enumerator value for 'E3' is not an integer constant" "enum error" { target *-*-* } 15 } */ /* But as in DR#031, the 1/0 in an evaluated subexpression means the whole expression violates the constraints. */ E4 = 0 * (1 / 0), /* { dg-warning "division by zero" } */ /* { dg-error "enumerator value for 'E4' is not an integer constant" "enum error" { xfail *-*-* } 19 } */ E5 = INT_MAX + 1, /* { dg-warning "integer overflow in expression" } */ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 21 } */ /* Again, overflow in evaluated subexpression. */ E6 = 0 * (INT_MAX + 1), /* { dg-warning "integer overflow in expression" } */ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 24 } */ /* A cast does not constitute overflow in conversion. */ E7 = (char) INT_MAX }; struct s { int a; int : 0 * (1 / 0); /* { dg-warning "division by zero" } */ int : 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 33 } */ }; void f (void) { /* This expression is not required to be a constant expression, so it should just involve undefined behavior at runtime. */ int c = INT_MAX + 1; /* { dg-warning "integer overflow in expression" } */ } /* This expression is neither required to be constant. */ static int sc = INT_MAX + 1; /* { dg-warning "integer overflow in expression" } */ // Test for overflow in null pointer constant. void *n = 0; /* The first two of these involve overflow, so are not null pointer constants. The third has the overflow in an unevaluated subexpression, so is a null pointer constant. */ void *p = 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */ /* { dg-error "invalid conversion from 'int' to 'void" "null" { target *-*-* } 55 } */ void *q = 0 * (1 / 0); /* { dg-warning "division by zero" } */ /* { dg-error "invalid conversion from 'int' to 'void*'" "null" { xfail *-*-* } 58 } */ void *r = (1 ? 0 : INT_MAX+1); /* { dg-bogus "integer overflow in expression" "" { xfail *-*-* } 60 } */ void g (int i) { switch (i) { case 0 * (1/0): /* { dg-warning "division by zero" } */ ; case 1 + 0 * (INT_MAX + 1): /* { dg-warning "integer overflow in expression" } */ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 69 } */ ; } } int h (void) { return INT_MAX + 1; /* { dg-warning "integer overflow in expression" } */ } int h1 (void) { return INT_MAX + 1 - INT_MAX; /* { dg-warning "integer overflow in expression" } */ } void fuc (unsigned char); void fsc (signed char); void h2 (void) { fsc (SCHAR_MAX + 1); /* { dg-warning "overflow in implicit constant conversion" } */ fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in implicit constant conversion" } */ fsc (UCHAR_MAX); /* { dg-warning "overflow in implicit constant conversion" } */ fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in implicit constant conversion" } */ fuc (-1); fuc (UCHAR_MAX + 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */ fuc (SCHAR_MIN); fuc (SCHAR_MIN - 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */ fuc (-UCHAR_MAX); /* { dg-warning "large integer implicitly truncated to unsigned type" } */ } void fui (unsigned int); void fsi (signed int); int si; unsigned ui; void h2i (int x) { /* For some reason, we only give certain warnings for implicit conversions among values of the same precision with -Wconversion, while we don't give others at all. */ fsi ((unsigned)INT_MAX + 1); si = (unsigned)INT_MAX + 1; si = x ? (unsigned)INT_MAX + 1 : 1; fsi ((unsigned)INT_MAX + 2); si = (unsigned)INT_MAX + 2; si = x ? (unsigned)INT_MAX + 2 : 1; fsi (UINT_MAX); si = UINT_MAX; fui (-1); ui = -1; ui = x ? -1 : 1U; fui (INT_MIN); ui = INT_MIN; ui = x ? INT_MIN : 1U; }