diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2015-04-22 10:21:45 +0000 |
---|---|---|
committer | <> | 2015-04-25 21:44:09 +0000 |
commit | f80b5ea1605c9f9408c5aa386ba71c16d918ebbf (patch) | |
tree | bb7eafaa81fc4b8c5c215bc08d517fd158db234a /gcc/testsuite/g++.dg | |
parent | c27a97d04853380f1e80525391b3f0d156ed4c84 (diff) | |
download | gcc-tarball-f80b5ea1605c9f9408c5aa386ba71c16d918ebbf.tar.gz |
Imported from /home/lorry/working-area/delta_gcc-tarball/gcc-5.1.0.tar.bz2.gcc-5.1.0
Diffstat (limited to 'gcc/testsuite/g++.dg')
1184 files changed, 25973 insertions, 3260 deletions
diff --git a/gcc/testsuite/g++.dg/README b/gcc/testsuite/g++.dg/README index 998f8ece6b..1160a2a9e4 100644 --- a/gcc/testsuite/g++.dg/README +++ b/gcc/testsuite/g++.dg/README @@ -33,7 +33,7 @@ special Tests that need custom expect code to run them; see special/ecos.exp for an example. -Copyright (C) 2001-2014 Free Software Foundation, Inc. +Copyright (C) 2001-2015 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright diff --git a/gcc/testsuite/g++.dg/Wshadow.C b/gcc/testsuite/g++.dg/Wshadow.C new file mode 100644 index 0000000000..482d2f0309 --- /dev/null +++ b/gcc/testsuite/g++.dg/Wshadow.C @@ -0,0 +1,15 @@ +// { dg-do compile } +// { dg-options "-Wshadow" } +// PR c++/57709 +class C { + int both_var; // { dg-message "declaration" } + void var_and_method(void) {} // { dg-message "declaration" } + void m() { + int + both_var, // { dg-warning "shadows" } + var_and_method; + } + void m2() { + void (C::*var_and_method)(void); // { dg-warning "shadows" } + } +}; diff --git a/gcc/testsuite/g++.dg/abi/abi-tag1.C b/gcc/testsuite/g++.dg/abi/abi-tag1.C index 942929cdd3..d57ed87d80 100644 --- a/gcc/testsuite/g++.dg/abi/abi-tag1.C +++ b/gcc/testsuite/g++.dg/abi/abi-tag1.C @@ -5,8 +5,8 @@ void f(int) __attribute ((abi_tag ("foo","bar"))); struct __attribute ((abi_tag ("bar"))) A { }; -struct B: A { }; // { dg-warning "bar. abi tag" } -struct D { A* ap; }; // { dg-warning "bar. abi tag" } +struct B: A { }; // { dg-warning "bar. ABI tag" } +struct D { A* ap; }; // { dg-warning "bar. ABI tag" } // { dg-final { scan-assembler "_Z1gB3baz1AB3bar" } } void g(A) __attribute ((abi_tag ("baz"))); diff --git a/gcc/testsuite/g++.dg/abi/abi-tag10.C b/gcc/testsuite/g++.dg/abi/abi-tag10.C new file mode 100644 index 0000000000..f320828516 --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/abi-tag10.C @@ -0,0 +1,28 @@ +#ifndef ABI_TAG +#define ABI_TAG __attribute__((__abi_tag__("cxx11"))) +#endif + +typedef unsigned long size_t; + +template<typename C> +struct char_traits { }; +template<typename C> +struct allocator { }; + +template<typename C, typename T = char_traits<C>, typename A = allocator<C> > +struct ABI_TAG basic_string { }; + +typedef basic_string<char> string; + +template<typename T> +struct hash +{ + size_t + operator()(T val) const; +}; + +template<> +size_t +hash<string>::operator()(string) const { return 0; } + +// { dg-final { scan-assembler "_ZNK4hashI12basic_stringB5cxx11Ic11char_traitsIcE9allocatorIcEEEclES5_" } } diff --git a/gcc/testsuite/g++.dg/abi/abi-tag11.C b/gcc/testsuite/g++.dg/abi/abi-tag11.C new file mode 100644 index 0000000000..36c1c9f0c0 --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/abi-tag11.C @@ -0,0 +1,12 @@ +// { dg-final { scan-assembler "_Z1fSbB3fooIwSt11char_traitsIwESaIwEES3_" } } + +namespace std { + template <class T> struct char_traits {}; + template <class T> struct allocator {}; + template <class T, class U, class V> + struct __attribute ((abi_tag ("foo"))) basic_string { }; + typedef basic_string<wchar_t,char_traits<wchar_t>,allocator<wchar_t> > + wstring; +} + +void f(std::wstring,std::wstring) {} diff --git a/gcc/testsuite/g++.dg/abi/abi-tag12.C b/gcc/testsuite/g++.dg/abi/abi-tag12.C new file mode 100644 index 0000000000..74dffa0efa --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/abi-tag12.C @@ -0,0 +1,8 @@ +// { dg-options "-Wabi-tag" } + +inline namespace A __attribute ((abi_tag)) { + struct Foo { }; // { dg-message "declared here" } + struct Baz: Foo { }; +} + +struct Bar: Foo { }; // { dg-warning "tag" } diff --git a/gcc/testsuite/g++.dg/abi/abi-tag13.C b/gcc/testsuite/g++.dg/abi/abi-tag13.C new file mode 100644 index 0000000000..34e8da3bb5 --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/abi-tag13.C @@ -0,0 +1,5 @@ +const char *foo = "bar"; +void __attribute((abi_tag(foo))) f1() {} // { dg-error "abi_tag" } +void __attribute((abi_tag(L"foo"))) f2(); // { dg-error "abi_tag" } +void __attribute((abi_tag("3foo"))) f3(); // { dg-error "abi_tag" } +void __attribute((abi_tag(1))) f5(); // { dg-error "abi_tag" } diff --git a/gcc/testsuite/g++.dg/abi/abi-tag14.C b/gcc/testsuite/g++.dg/abi/abi-tag14.C new file mode 100644 index 0000000000..a66e6552cb --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/abi-tag14.C @@ -0,0 +1,30 @@ +// { dg-options "-Wabi-tag" } + +inline namespace __cxx11 __attribute ((abi_tag ("cxx11"))) { + struct A {}; +}; + +// { dg-final { scan-assembler "_Z1aB5cxx11" } } +A a; // { dg-warning "\"cxx11\"" } + +// { dg-final { scan-assembler "_Z1fB5cxx11v" } } +A f() {} // { dg-warning "\"cxx11\"" } + +namespace { + A a2; + A f2() {} + struct B: A {}; +} + +// { dg-final { scan-assembler "_Z1fPN7__cxx111AE" } } +A f(A*) {} + +// { dg-final { scan-assembler "_Z1gIN7__cxx111AEET_v" } } +template <class T> T g() { } +template <> A g<A>() { } + +// { dg-final { scan-assembler "_Z1vIN7__cxx111AEE" { target c++14 } } } +#if __cplusplus >= 201402L +template <class T> T v = T(); +void *p = &v<A>; +#endif diff --git a/gcc/testsuite/g++.dg/abi/abi-tag4.C b/gcc/testsuite/g++.dg/abi/abi-tag4.C index 3f8d7bfbc3..6bf4fa1c53 100644 --- a/gcc/testsuite/g++.dg/abi/abi-tag4.C +++ b/gcc/testsuite/g++.dg/abi/abi-tag4.C @@ -2,7 +2,7 @@ struct __attribute ((abi_tag ("X"))) A { }; -struct B // { dg-warning "abi tag" } +struct B // { dg-warning "ABI tag" } { virtual void f(A); // { dg-message "declared here" } }; diff --git a/gcc/testsuite/g++.dg/abi/abi-tag8.C b/gcc/testsuite/g++.dg/abi/abi-tag8.C new file mode 100644 index 0000000000..7ead1cb86b --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/abi-tag8.C @@ -0,0 +1,9 @@ +// { dg-options "-Wabi-tag" } + +template<class T> +struct __attribute ((__abi_tag__("cxx11"))) list // { dg-message "list" } +{ }; + +struct X { // { dg-warning "ABI tag" } + list<int> l; // { dg-message "X::l" } +}; diff --git a/gcc/testsuite/g++.dg/abi/abi-tag9.C b/gcc/testsuite/g++.dg/abi/abi-tag9.C new file mode 100644 index 0000000000..9ec78a9ac1 --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/abi-tag9.C @@ -0,0 +1,11 @@ +// { dg-final { scan-assembler "_Z1fSsB3fooS_" } } + +namespace std { + template <class T> struct char_traits {}; + template <class T> struct allocator {}; + template <class T, class U, class V> + struct __attribute ((abi_tag ("foo"))) basic_string { }; + typedef basic_string<char,char_traits<char>,allocator<char> > string; +} + +void f(std::string,std::string) {} diff --git a/gcc/testsuite/g++.dg/abi/anon3.C b/gcc/testsuite/g++.dg/abi/anon3.C index 623c7f5c6e..3e38024aed 100644 --- a/gcc/testsuite/g++.dg/abi/anon3.C +++ b/gcc/testsuite/g++.dg/abi/anon3.C @@ -2,13 +2,13 @@ typedef struct { // { dg-final { scan-assembler ".weak\(_definition\)?\[ \t\]_?_ZN4Heya4blahEv" } } - // { dg-final { scan-assembler ".weak\(_definition\)?\[ \t\]_?_ZTI4Heya" } } + // { dg-final { scan-assembler ".weak\(_definition\)?\[ \t\]_?_ZTI4Heya" { target { ! { hppa*-*-hpux* } } } } } // { dg-final { scan-assembler ".weak\(_definition\)?\[ \t\]_?_ZTV4Heya" } } virtual const char *blah() { return "Heya::blah"; } // { dg-final { scan-assembler ".weak\(_definition\)?\[ \t\]_?_ZN4Heya1A1fEv" } } - // { dg-final { scan-assembler ".weak\(_definition\)?\[ \t\]_?_ZTIN4Heya1AE" } } + // { dg-final { scan-assembler ".weak\(_definition\)?\[ \t\]_?_ZTIN4Heya1AE" { target { ! { hppa*-*-hpux* } } } } } // { dg-final { scan-assembler ".weak\(_definition\)?\[ \t\]_?_ZTVN4Heya1AE" } } struct A { virtual void f() { } diff --git a/gcc/testsuite/g++.dg/abi/anon4.C b/gcc/testsuite/g++.dg/abi/anon4.C new file mode 100644 index 0000000000..088ba99401 --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/anon4.C @@ -0,0 +1,41 @@ +// PR c++/65209 +// { dg-final { scan-assembler-not "comdat" } } + +// Everything involving the anonymous namespace bits should be private, not +// COMDAT. + +struct Bar +{ + static Bar *self(); + char pad[24]; +}; + +template <Bar *(&holderFunction)()> +struct BarGlobalStatic +{ + Bar *operator()() { return holderFunction(); } +}; + +namespace { + namespace Q_QGS_s_self { + inline Bar *innerFunction() { + static struct Holder { + Bar value; + ~Holder() {} + } holder; + return &holder.value; + } + } +} +static BarGlobalStatic<Q_QGS_s_self::innerFunction> s_self; + +Bar *Bar::self() +{ + return s_self(); +} + +int main(int argc, char *argv[]) +{ + Bar* bar = Bar::self(); + return 0; +} diff --git a/gcc/testsuite/g++.dg/abi/arm_rtti1.C b/gcc/testsuite/g++.dg/abi/arm_rtti1.C index a481bdd1f1..74f00033d9 100644 --- a/gcc/testsuite/g++.dg/abi/arm_rtti1.C +++ b/gcc/testsuite/g++.dg/abi/arm_rtti1.C @@ -1,4 +1,4 @@ -// { dg-do compile { target arm*-*-eabi* arm*-*-symbianelf* } } +// { dg-do compile { target arm_eabi } } // { dg-options "-O2" } // Check that, even when optimizing, we emit an out-of-line call to // the type-info comparison function. diff --git a/gcc/testsuite/g++.dg/abi/bitfield12.C b/gcc/testsuite/g++.dg/abi/bitfield12.C deleted file mode 100644 index 6cfda5d47d..0000000000 --- a/gcc/testsuite/g++.dg/abi/bitfield12.C +++ /dev/null @@ -1,5 +0,0 @@ -// { dg-options "-Wabi -fabi-version=1" } - -struct S { // { dg-warning "ABI" } - char c : 1024; // { dg-warning "width" } -}; diff --git a/gcc/testsuite/g++.dg/abi/bitfield5.C b/gcc/testsuite/g++.dg/abi/bitfield5.C deleted file mode 100644 index 5313140143..0000000000 --- a/gcc/testsuite/g++.dg/abi/bitfield5.C +++ /dev/null @@ -1,15 +0,0 @@ -// { dg-do compile } -// { dg-options "-Wabi -fabi-version=1" } -// { dg-options "-Wabi -fabi-version=1 -mno-ms-bitfields" { target i?86-*-* x86_64-*-* } } - -struct A { - virtual void f(); - int f1 : 1; -}; - -struct B : public A { - int f2 : 1; // { dg-warning "ABI" } - int : 0; - int f3 : 4; - int f4 : 3; -}; diff --git a/gcc/testsuite/g++.dg/abi/bitfield7.C b/gcc/testsuite/g++.dg/abi/bitfield7.C deleted file mode 100644 index b5b656ffa4..0000000000 --- a/gcc/testsuite/g++.dg/abi/bitfield7.C +++ /dev/null @@ -1,7 +0,0 @@ -// { dg-do compile } -// { dg-options "-Wabi -fabi-version=1" } - -union U { // { dg-warning "ABI" } - int i: 4096; // { dg-warning "exceeds" } -}; - diff --git a/gcc/testsuite/g++.dg/abi/comdat1.C b/gcc/testsuite/g++.dg/abi/comdat1.C new file mode 100644 index 0000000000..e1025e357b --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/comdat1.C @@ -0,0 +1,13 @@ +// PR c++/62302 + +// { dg-do compile { target *-*-*gnu* } } +// { dg-final { scan-assembler "_ZN3optIiED5Ev,comdat" } } +// { dg-final { scan-assembler-not "_ZN3optIiED0Ev,comdat" } } +// { dg-final { scan-assembler-not "_ZN3optIiED1Ev,comdat" } } +// { dg-final { scan-assembler-not "_ZN3optIiED2Ev,comdat" } } + +struct Option { + virtual ~Option() {} +}; +template <class DataType> class opt : public Option {}; +template class opt<int>; diff --git a/gcc/testsuite/g++.dg/abi/cookie2.C b/gcc/testsuite/g++.dg/abi/cookie2.C deleted file mode 100644 index dc180453b7..0000000000 --- a/gcc/testsuite/g++.dg/abi/cookie2.C +++ /dev/null @@ -1,16 +0,0 @@ -// { dg-options "-fabi-version=1" } - -void *operator new[](__SIZE_TYPE__, void *); - -struct A { - ~A(){} -}; - -int main() -{ - A * a = (A*) new char[20]; - A * b = new(a) A[3]; - // In the 3.2 ABI, a cookie was allocated in this case. - if (a == b) - return 1; -} diff --git a/gcc/testsuite/g++.dg/abi/dtor2.C b/gcc/testsuite/g++.dg/abi/dtor2.C deleted file mode 100644 index 6b89cc8eae..0000000000 --- a/gcc/testsuite/g++.dg/abi/dtor2.C +++ /dev/null @@ -1,14 +0,0 @@ -// { dg-do compile } -// { dg-options "-Wabi -fabi-version=1" } - -struct A { - virtual void a (); -}; - -struct B { - virtual ~B (); -}; - -struct C : public A, public B { // { dg-warning "virtual" } - virtual void c (); -}; diff --git a/gcc/testsuite/g++.dg/abi/empty6.C b/gcc/testsuite/g++.dg/abi/empty6.C deleted file mode 100644 index 1b14a6d03b..0000000000 --- a/gcc/testsuite/g++.dg/abi/empty6.C +++ /dev/null @@ -1,14 +0,0 @@ -// { dg-options "-Wabi -fabi-version=1" } - -struct A {}; - -struct B { - A a; // { dg-warning "empty" "" { xfail mmix-*-* } } - virtual void f () {} -} __attribute__((aligned(2 * sizeof (void *)))); -/* The preceding attribute is necessary on targets with - BIGGEST_ALIGNMENT <= POINTER_SIZE to trigger the warning, as - otherwise the offset of 'a' (i.e. POINTER_SIZE) is split into a - non-zero DECL_FIELD_OFFSET and a zero DECL_FIELD_BIT_OFFSET, - and then there is no discrepancy between DECL_FIELD_OFFSET and - byte_position to warn about. */ diff --git a/gcc/testsuite/g++.dg/abi/key1.C b/gcc/testsuite/g++.dg/abi/key1.C index 6c03809264..1c00b03b5a 100644 --- a/gcc/testsuite/g++.dg/abi/key1.C +++ b/gcc/testsuite/g++.dg/abi/key1.C @@ -1,5 +1,5 @@ // On ARM EABI platforms, key methods may never be inline. -// { dg-do compile { target arm*-*-eabi* arm*-*-symbianelf* } } +// { dg-do compile { target arm_eabi } } // { dg-final { scan-assembler-not _ZTV1S } } // { dg-final { scan-assembler-not _ZTV1T } } // { dg-final { scan-assembler _ZTV1U } } diff --git a/gcc/testsuite/g++.dg/abi/layout4.C b/gcc/testsuite/g++.dg/abi/layout4.C deleted file mode 100644 index da3c2f5d8c..0000000000 --- a/gcc/testsuite/g++.dg/abi/layout4.C +++ /dev/null @@ -1,19 +0,0 @@ -// { dg-do run { target i?86-*-* x86_64-*-* } } -// { dg-require-effective-target ilp32 } -// { dg-options "-fabi-version=1" } - -struct C4 -{ - int b:30; - C4(){}; -}; - -struct C1: virtual C4 -{ - int i; -}; - -int main() { - if (sizeof (C1) != 12) - return 1; -} diff --git a/gcc/testsuite/g++.dg/abi/macro0.C b/gcc/testsuite/g++.dg/abi/macro0.C index 6c391e6891..fbcbb2cdc9 100644 --- a/gcc/testsuite/g++.dg/abi/macro0.C +++ b/gcc/testsuite/g++.dg/abi/macro0.C @@ -1,5 +1,6 @@ +// This testcase will need to be kept in sync with c_common_post_options. // { dg-options "-fabi-version=0" } -#if __GXX_ABI_VERSION != 999999 +#if __GXX_ABI_VERSION != 1008 #error "Incorrect value of __GXX_ABI_VERSION" #endif diff --git a/gcc/testsuite/g++.dg/abi/macro1.C b/gcc/testsuite/g++.dg/abi/macro1.C deleted file mode 100644 index 871208da3a..0000000000 --- a/gcc/testsuite/g++.dg/abi/macro1.C +++ /dev/null @@ -1,5 +0,0 @@ -// { dg-options "-fabi-version=1" } - -#if __GXX_ABI_VERSION != 102 -#error "Incorrect value of __GXX_ABI_VERSION" -#endif diff --git a/gcc/testsuite/g++.dg/abi/mangle-arm-crypto.C b/gcc/testsuite/g++.dg/abi/mangle-arm-crypto.C new file mode 100644 index 0000000000..f3fb1a9660 --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/mangle-arm-crypto.C @@ -0,0 +1,16 @@ +// Test that ARM NEON types used by the Cryptograpy Extensions +// have their names mangled correctly. + +// { dg-do compile } +// { dg-require-effective-target arm_crypto_ok } +// { dg-add-options arm_crypto } + +#include <arm_neon.h> + +void f0 (poly64_t a) {} +void f1 (poly128_t a) {} +void f2 (poly64x2_t a) {} + +// { dg-final { scan-assembler "_Z2f0y:" } } +// { dg-final { scan-assembler "_Z2f1o:" } } +// { dg-final { scan-assembler "_Z2f2Dv2_y:" } } diff --git a/gcc/testsuite/g++.dg/abi/mangle-neon-aarch64.C b/gcc/testsuite/g++.dg/abi/mangle-neon-aarch64.C index 09540e8414..09a20dc985 100644 --- a/gcc/testsuite/g++.dg/abi/mangle-neon-aarch64.C +++ b/gcc/testsuite/g++.dg/abi/mangle-neon-aarch64.C @@ -8,9 +8,11 @@ void f0 (int8x8_t a) {} void f1 (int16x4_t a) {} void f2 (int32x2_t a) {} +void f22 (int64x1_t a) {} void f3 (uint8x8_t a) {} void f4 (uint16x4_t a) {} void f5 (uint32x2_t a) {} +void f23 (uint64x1_t a) {} void f6 (float32x2_t a) {} void f7 (poly8x8_t a) {} void f8 (poly16x4_t a) {} @@ -27,16 +29,19 @@ void f17 (float32x4_t a) {} void f18 (float64x2_t a) {} void f19 (poly8x16_t a) {} void f20 (poly16x8_t a) {} +void f21 (float64x1_t a) {} -void f21 (int8x16_t, int8x16_t) {} +void g1 (int8x16_t, int8x16_t) {} // { dg-final { scan-assembler "_Z2f010__Int8x8_t:" } } // { dg-final { scan-assembler "_Z2f111__Int16x4_t:" } } // { dg-final { scan-assembler "_Z2f211__Int32x2_t:" } } +// { dg-final { scan-assembler "_Z3f2211__Int64x1_t:" } } // { dg-final { scan-assembler "_Z2f311__Uint8x8_t:" } } // { dg-final { scan-assembler "_Z2f412__Uint16x4_t:" } } // { dg-final { scan-assembler "_Z2f512__Uint32x2_t:" } } +// { dg-final { scan-assembler "_Z3f2312__Uint64x1_t:" } } // { dg-final { scan-assembler "_Z2f613__Float32x2_t:" } } // { dg-final { scan-assembler "_Z2f711__Poly8x8_t:" } } // { dg-final { scan-assembler "_Z2f812__Poly16x4_t:" } } @@ -52,4 +57,5 @@ void f21 (int8x16_t, int8x16_t) {} // { dg-final { scan-assembler "_Z3f1813__Float64x2_t:" } } // { dg-final { scan-assembler "_Z3f1912__Poly8x16_t:" } } // { dg-final { scan-assembler "_Z3f2012__Poly16x8_t:" } } -// { dg-final { scan-assembler "_Z3f2111__Int8x16_tS_:" } } +// { dg-final { scan-assembler "_Z3f2113__Float64x1_t:" } } +// { dg-final { scan-assembler "_Z2g111__Int8x16_tS_:" } } diff --git a/gcc/testsuite/g++.dg/abi/mangle-neon.C b/gcc/testsuite/g++.dg/abi/mangle-neon.C index af1fe49f1e..9fabf4df00 100644 --- a/gcc/testsuite/g++.dg/abi/mangle-neon.C +++ b/gcc/testsuite/g++.dg/abi/mangle-neon.C @@ -28,6 +28,9 @@ void f17 (poly16x8_t a) {} void f18 (int8x16_t, int8x16_t) {} +void f19 (poly8_t a) {} +void f20 (poly16_t a) {} + // { dg-final { scan-assembler "_Z2f015__simd64_int8_t:" } } // { dg-final { scan-assembler "_Z2f116__simd64_int16_t:" } } // { dg-final { scan-assembler "_Z2f216__simd64_int32_t:" } } @@ -47,3 +50,5 @@ void f18 (int8x16_t, int8x16_t) {} // { dg-final { scan-assembler "_Z3f1617__simd128_poly8_t:" } } // { dg-final { scan-assembler "_Z3f1718__simd128_poly16_t:" } } // { dg-final { scan-assembler "_Z3f1816__simd128_int8_tS_:" } } +// { dg-final { scan-assembler "_Z3f19a:" } } +// { dg-final { scan-assembler "_Z3f20s:" } } diff --git a/gcc/testsuite/g++.dg/abi/mangle11.C b/gcc/testsuite/g++.dg/abi/mangle11.C deleted file mode 100644 index 722d43c85a..0000000000 --- a/gcc/testsuite/g++.dg/abi/mangle11.C +++ /dev/null @@ -1,10 +0,0 @@ -// { dg-options "-Wabi -fabi-version=1" } - -template <typename Q> -void f (typename Q::X) {} // { dg-warning "mangle" } - -struct S { - typedef int X; -}; - -template void f<S> (int); // { dg-message "required" } diff --git a/gcc/testsuite/g++.dg/abi/mangle12.C b/gcc/testsuite/g++.dg/abi/mangle12.C deleted file mode 100644 index 92f49c22fd..0000000000 --- a/gcc/testsuite/g++.dg/abi/mangle12.C +++ /dev/null @@ -1,11 +0,0 @@ -// { dg-options "-Wabi -fabi-version=1" } - -template <template <typename> class Q> -void f (typename Q<int>::X) {} // { dg-warning "mangle" } - -template <typename Q> -struct S { - typedef int X; -}; - -template void f<S> (int); // { dg-message "required" } diff --git a/gcc/testsuite/g++.dg/abi/mangle14.C b/gcc/testsuite/g++.dg/abi/mangle14.C deleted file mode 100644 index 2b38255ac0..0000000000 --- a/gcc/testsuite/g++.dg/abi/mangle14.C +++ /dev/null @@ -1,13 +0,0 @@ -// { dg-do compile } -// { dg-options "-Wabi -fabi-version=1" } -// { dg-final { scan-assembler "_Z1g1SIXadsr1ANS0_1fIiEEivEE" } } - -struct A { - template <typename T> int f (); -}; - -typedef int (A::*P)(); - -template <P> struct S {}; - -void g (S<&A::f<int> >) {} // { dg-warning "mangle" } diff --git a/gcc/testsuite/g++.dg/abi/mangle17.C b/gcc/testsuite/g++.dg/abi/mangle17.C deleted file mode 100644 index f98e2717d8..0000000000 --- a/gcc/testsuite/g++.dg/abi/mangle17.C +++ /dev/null @@ -1,11 +0,0 @@ -// { dg-options "-Wabi -fabi-version=1" } - -enum E { e = 3 }; - -template <int I> struct S {}; - -template <int I> void f (S<I + e + int (3.7)>) {} // { dg-warning "mangle" } -template void f<7>(S<7 + e + int (3.7)>); // { dg-message "required" } - -template <int I> void g (S<I + e + int (3.7)>) {} // { dg-warning "mangle" } -template void g<7>(S<7 + e + int (3.7)>); // { dg-message "required" } diff --git a/gcc/testsuite/g++.dg/abi/mangle18-2.C b/gcc/testsuite/g++.dg/abi/mangle18-2.C deleted file mode 100644 index a231d495fe..0000000000 --- a/gcc/testsuite/g++.dg/abi/mangle18-2.C +++ /dev/null @@ -1,23 +0,0 @@ -// { dg-do compile } -// { dg-options "-fabi-version=1 -Wabi" } - -// Copyright (C) 2003 Free Software Foundation, Inc. -// Contributed by Nathan Sidwell 30 Nov 2003 <nathan@codesourcery.com> - -// PR 13241 -// mangled template arguments that are external objects incorrectly - -extern "C" void Foo (); -namespace NMS -{ - extern "C" int V; -} - -template <void (*)()> struct S {}; -template <int *> struct T {}; - -void f (S<Foo>){} // { dg-warning "mangled name" } -// { dg-final { scan-assembler "\n_?_Z1f1SIXadL3FooEEE\[: \t\n\]" } } - -void g (T<&NMS::V>){} // { dg-warning "mangled name" } -// { dg-final { scan-assembler "\n_?_Z1g1TIXadL_ZN3NMS1VEEEE\[: \t\n\]" } } diff --git a/gcc/testsuite/g++.dg/abi/mangle19-1.C b/gcc/testsuite/g++.dg/abi/mangle19-1.C index 1463d03f31..a888173304 100644 --- a/gcc/testsuite/g++.dg/abi/mangle19-1.C +++ b/gcc/testsuite/g++.dg/abi/mangle19-1.C @@ -1,5 +1,5 @@ // { dg-do compile } -// { dg-options "-fabi-version=2 -Wno-abi" } +// { dg-options "-fabi-version=2 -Wabi" } // Copyright (C) 2003 Free Software Foundation, Inc. // Contributed by Nathan Sidwell 15 Dec 2003 <nathan@codesourcery.com> @@ -9,5 +9,5 @@ extern int N; template <int &> struct S {}; -void n (S<N>) {} +void n (S<N>) {} // { dg-warning "mangle" } // { dg-final { scan-assembler "\n_?_Z1n1SILZ1NEE\[: \t\n\]" } } diff --git a/gcc/testsuite/g++.dg/abi/mangle19-2.C b/gcc/testsuite/g++.dg/abi/mangle19-2.C deleted file mode 100644 index f0855e69d3..0000000000 --- a/gcc/testsuite/g++.dg/abi/mangle19-2.C +++ /dev/null @@ -1,13 +0,0 @@ -// { dg-do compile } -// { dg-options "-fabi-version=1 -Wabi" } - -// Copyright (C) 2003 Free Software Foundation, Inc. -// Contributed by Nathan Sidwell 15 Dec 2003 <nathan@codesourcery.com> - -// PR 13242 -// mangled template arguments that are external objects incorrectly - -extern int N; -template <int &> struct S {}; -void n (S<N>) {} // { dg-warning "mangled name" } -// { dg-final { scan-assembler "\n_?_Z1n1SIXadL_Z1NEEE\[: \t\n\]" } } diff --git a/gcc/testsuite/g++.dg/abi/mangle20-2.C b/gcc/testsuite/g++.dg/abi/mangle20-2.C deleted file mode 100644 index 5ba6bac03a..0000000000 --- a/gcc/testsuite/g++.dg/abi/mangle20-2.C +++ /dev/null @@ -1,16 +0,0 @@ -// { dg-do compile } -// { dg-options "-fabi-version=1 -Wabi" } - -// Copyright (C) 2003 Free Software Foundation, Inc. -// Contributed by Nathan Sidwell 15 Dec 2003 <nathan@codesourcery.com> - -// PR 9043 -// mangled array types in templates - -template <int I> void f(int (*)[2]) {} // { dg-warning "mangled name" } -template <int I> void g(int (*)[I+2]) {} - -template void f<1>(int (*)[2]); // { dg-message "required" } -// { dg-final { scan-assembler "\n_?_Z1fILi1EEvPALi2E_i\[: \t\n\]" } } -template void g<1>(int (*)[3]); -// { dg-final { scan-assembler "\n_?_Z1gILi1EEvPAplT_Li2E_i\[: \t\n\]" } } diff --git a/gcc/testsuite/g++.dg/abi/mangle3-2.C b/gcc/testsuite/g++.dg/abi/mangle3-2.C index ac85fb0456..538c5cbfae 100644 --- a/gcc/testsuite/g++.dg/abi/mangle3-2.C +++ b/gcc/testsuite/g++.dg/abi/mangle3-2.C @@ -1,12 +1,12 @@ // Test mangling of type casts -// { dg-options "-fabi-version=0" } +// { dg-options "-fabi-version=0 -Wabi=5" } // { dg-do compile } template<int i> class A {}; template<bool b> class B {}; template<int i> void f(A<i> &, B<bool(i)> &) {} -template<int i> void g(A<i> &, B<static_cast<bool>(i)> &) {} +template<int i> void g(A<i> &, B<static_cast<bool>(i)> &) {} // { dg-warning "mangle" } int main() { diff --git a/gcc/testsuite/g++.dg/abi/mangle3.C b/gcc/testsuite/g++.dg/abi/mangle3.C index 5f44f76773..42f8deac53 100644 --- a/gcc/testsuite/g++.dg/abi/mangle3.C +++ b/gcc/testsuite/g++.dg/abi/mangle3.C @@ -1,12 +1,12 @@ // Test mangling of type casts -// { dg-options "-fabi-version=2" } +// { dg-options "-fabi-version=2 -Wabi" } // { dg-do compile } template<int i> class A {}; template<bool b> class B {}; template<int i> void f(A<i> &, B<bool(i)> &) {} -template<int i> void g(A<i> &, B<static_cast<bool>(i)> &) {} +template<int i> void g(A<i> &, B<static_cast<bool>(i)> &) {} // { dg-warning "mangle" } int main() { diff --git a/gcc/testsuite/g++.dg/abi/mangle45.C b/gcc/testsuite/g++.dg/abi/mangle45.C index 5e202a2f52..bdedb0ab3b 100644 --- a/gcc/testsuite/g++.dg/abi/mangle45.C +++ b/gcc/testsuite/g++.dg/abi/mangle45.C @@ -1,26 +1,26 @@ // Testcase for mangling of parameters used other than in a trailing return type // { dg-do compile { target c++11 } } -// { dg-options "-fabi-version=5" } +// { dg-options "-fabi-version=5 -Wabi=4" } -template<class T> void f(T p, decltype(p)) { } // L = 1 -template<class T> void g(T p, decltype(p) (*)()) { } // L = 1 +template<class T> void f(T p, decltype(p)) { } // L = 1 { dg-warning "mangle" } +template<class T> void g(T p, decltype(p) (*)()) { } // L = 1 { dg-warning "mangle" } // G++ incorrectly rejects these currently. // template<class T> void h(T p, auto (*)()->decltype(p)); // L = 1 // template<class T> void i(T p, auto (*)(T q)->decltype(q)); // L = 0 // template<class T> void j(T p, auto (*)(decltype(p))->T); // L = 2 -template<class T> void k(T p, int (*(*)(T* p))[sizeof(p)]) {} // L = 1 +template<class T> void k(T p, int (*(*)(T* p))[sizeof(p)]) {} // L = 1 { dg-warning "mangle" } int garg(); int (*karg (int*))[sizeof(int)]; int main() { - // { dg-final { scan-assembler "_Z1fIiEvT_DtfL0p_E" } } + // { dg-final { scan-assembler "\n_?_Z1fIiEvT_DtfL0p_E\[: \t\n\]" } } f (1,0); - // { dg-final { scan-assembler "_Z1gIiEvT_PFDtfL0p_EvE" } } + // { dg-final { scan-assembler "\n_?_Z1gIiEvT_PFDtfL0p_EvE\[: \t\n\]" } } g (1,garg); // h (1,0); // i (1,0); // j (1,0); - // { dg-final { scan-assembler "_Z1kIiEvT_PFPAszfL0p__iPS0_E" } } + // { dg-final { scan-assembler "\n_?_Z1kIiEvT_PFPAszfL0p__iPS0_E\[: \t\n\]" } } k (1,karg); } diff --git a/gcc/testsuite/g++.dg/abi/mangle49.C b/gcc/testsuite/g++.dg/abi/mangle49.C index 3795c556d0..fae013a263 100644 --- a/gcc/testsuite/g++.dg/abi/mangle49.C +++ b/gcc/testsuite/g++.dg/abi/mangle49.C @@ -1,10 +1,10 @@ // PR c++/49932 // { dg-do compile { target c++11 } } -// { dg-options "-fabi-version=0" } +// { dg-options "-fabi-version=0 -Wabi=2" } template < typename T > auto -f1( T x ) // ICE on here +f1( T x ) // { dg-warning "mangle" } -> typename decltype( x )::type {} template < typename T > @@ -19,5 +19,5 @@ void g() f2( S() ); } -// { dg-final { scan-assembler "_Z2f1I1SENDtfp_E4typeET_" } } -// { dg-final { scan-assembler "_Z2f2I1SENDTcvT__EE4typeES1_" } } +// { dg-final { scan-assembler "\n_?_Z2f1I1SENDtfp_E4typeET_\[: \t\n\]" } } +// { dg-final { scan-assembler "\n_?_Z2f2I1SENDTcvT__EE4typeES1_\[: \t\n\]" } } diff --git a/gcc/testsuite/g++.dg/abi/mangle52.C b/gcc/testsuite/g++.dg/abi/mangle52.C index 2c463415f1..0b9a72fd21 100644 --- a/gcc/testsuite/g++.dg/abi/mangle52.C +++ b/gcc/testsuite/g++.dg/abi/mangle52.C @@ -1,13 +1,13 @@ -// { dg-options "-fabi-version=0" } +// { dg-options "-fabi-version=0 -Wabi=2" } template <unsigned int> struct helper {}; -// { dg-final { scan-assembler "_Z6check1IiEvP6helperIXszscT_Li1EEE" } } -template <class T> void check1( helper<sizeof(static_cast<T>(1))> * ) { } -// { dg-final { scan-assembler "_Z6check2IiXadL_Z1iEEEvP6helperIXszccPT_T0_EE" } } -template <class T, T* p> void check2( helper<sizeof(const_cast<T*>(p))> * ) { } -// { dg-final { scan-assembler "_Z6check3IiEvP6helperIXszrcPT_Li0EEE" } } +// { dg-final { scan-assembler "\n_?_Z6check1IiEvP6helperIXszscT_Li1EEE\[: \t\n\]" } } +template <class T> void check1( helper<sizeof(static_cast<T>(1))> * ) { } // { dg-warning "mangle" } +// { dg-final { scan-assembler "\n_?_Z6check2IiXadL_Z1iEEEvP6helperIXszccPT_T0_EE\[: \t\n\]" } } +template <class T, T* p> void check2( helper<sizeof(const_cast<T*>(p))> * ) { } // { dg-warning "mangle" } +// { dg-final { scan-assembler "\n_?_Z6check3IiEvP6helperIXszrcPT_Li0EEE\[: \t\n\]" } } template <class T> void check3( helper<sizeof(reinterpret_cast<T*>(0))> * ) { } -// { dg-final { scan-assembler "_Z6check4I1AXadL_Z1aEEEvP6helperIXszdcPT_T0_EE" } } +// { dg-final { scan-assembler "\n_?_Z6check4I1AXadL_Z1aEEEvP6helperIXszdcPT_T0_EE\[: \t\n\]" } } template <class T, T* p> void check4( helper<sizeof(dynamic_cast<T*>(p))> * ) { } struct A{} a; diff --git a/gcc/testsuite/g++.dg/abi/mangle54.C b/gcc/testsuite/g++.dg/abi/mangle54.C index 926275c8cb..ba1d3bc318 100644 --- a/gcc/testsuite/g++.dg/abi/mangle54.C +++ b/gcc/testsuite/g++.dg/abi/mangle54.C @@ -1,15 +1,15 @@ // { dg-do compile { target c++11 } } -// { dg-options "-fabi-version=0" } +// { dg-options "-fabi-version=0 -Wabi=2" } int i; // { dg-final { scan-assembler "_Z2f1IiEDTppfp_ET_" } } template <class T> auto f1 (T t) -> decltype(t++) { return i; } // { dg-final { scan-assembler "_Z2f2IiEDTpp_fp_ET_" } } -template <class T> auto f2 (T t) -> decltype(++t) { return i; } +template <class T> auto f2 (T t) -> decltype(++t) { return i; } // { dg-warning "mangle" } // { dg-final { scan-assembler "_Z2f3IiEDTmmfp_ET_" } } template <class T> auto f3 (T t) -> decltype(t--) { return i; } // { dg-final { scan-assembler "_Z2f4IiEDTmm_fp_ET_" } } -template <class T> auto f4 (T t) -> decltype(--t) { return i; } +template <class T> auto f4 (T t) -> decltype(--t) { return i; } // { dg-warning "mangle" } int main() { diff --git a/gcc/testsuite/g++.dg/abi/mangle57.C b/gcc/testsuite/g++.dg/abi/mangle57.C index cd59cb87b1..46cf377ebc 100644 --- a/gcc/testsuite/g++.dg/abi/mangle57.C +++ b/gcc/testsuite/g++.dg/abi/mangle57.C @@ -1,13 +1,13 @@ // { dg-do compile { target c++11 } } -// { dg-options "-fabi-version=0" } +// { dg-options "-fabi-version=0 -Wabi=2" } template<typename T> int cmp1(T a, T b); int cmp2(char a, char b); template<typename T, int (*cmp)(T, T)> struct A { }; -// { dg-final { scan-assembler "_Z1fIcEvR1AIT_X4cmp1EE" } } -template <typename T> void f (A<T,cmp1> &); -// { dg-final { scan-assembler "_Z1fIcEvR1AIT_L_Z4cmp2ccEE" } } -template <typename T> void f (A<T,cmp2> &); +// { dg-final { scan-assembler "\n_?_Z1fIcEvR1AIT_X4cmp1EE\[: \t\n\]" } } +template <typename T> void f (A<T,cmp1> &) {} +// { dg-final { scan-assembler "\n_?_Z1fIcEvR1AIT_L_Z4cmp2ccEE\[: \t\n\]" } } +template <typename T> void f (A<T,cmp2> &) {} // { dg-warning "mangle" } void g() { A<char,cmp1> a; diff --git a/gcc/testsuite/g++.dg/abi/mangle58.C b/gcc/testsuite/g++.dg/abi/mangle58.C index abcb3ca47a..f9aadc2a90 100644 --- a/gcc/testsuite/g++.dg/abi/mangle58.C +++ b/gcc/testsuite/g++.dg/abi/mangle58.C @@ -1,5 +1,5 @@ // { dg-do compile { target c++11 } } -// { dg-options "-fabi-version=0" } +// { dg-options "-fabi-version=0 -Wabi=2" } template<typename T, int (*cmp)(T, T)> struct A { }; struct B { @@ -10,9 +10,9 @@ struct B { // { dg-final { scan-assembler "_ZN1B1gIcEEvR1AIT_XsrS_4cmp1EE" } } template <typename T> static void g (A<T,B::cmp1> &); // { dg-final { scan-assembler "_ZN1B1fIcEEvR1AIT_L_ZNS_4cmp2EccEE" } } - template <typename T> static void f (A<T,cmp2> &); + template <typename T> static void f (A<T,cmp2> &); // { dg-warning "mangle" } // { dg-final { scan-assembler "_ZN1B1gIcEEvR1AIT_L_ZNS_4cmp2EccEE" } } - template <typename T> static void g (A<T,B::cmp2> &); + template <typename T> static void g (A<T,B::cmp2> &); // { dg-warning "mangle" } }; void g() diff --git a/gcc/testsuite/g++.dg/abi/mangle62.C b/gcc/testsuite/g++.dg/abi/mangle62.C index 6dbfd7865c..db541ca190 100644 --- a/gcc/testsuite/g++.dg/abi/mangle62.C +++ b/gcc/testsuite/g++.dg/abi/mangle62.C @@ -2,10 +2,10 @@ // as a substitution candidate for a function type with function-cv-quals. // Test for the conformant behavior. -// { dg-options -fabi-version=0 } +// { dg-options "-fabi-version=0 -Wabi=7" } template <class T, class U> struct A { }; -// { dg-final { scan-assembler "_Z1fP1AIKFvvEFvvEE" } } -void f (A<void()const, void()> *){} -// { dg-final { scan-assembler "_Z1gP1AIFvvEKFvvEE" } } -void g (A<void(), void()const> *){} +// { dg-final { scan-assembler "\n_?_Z1fP1AIKFvvEFvvEE\[: \t\n\]" } } +void f (A<void()const, void()> *){} // { dg-warning "mangled name" } +// { dg-final { scan-assembler "\n_?_Z1gP1AIFvvEKFvvEE\[: \t\n\]" } } +void g (A<void(), void()const> *){} // { dg-warning "mangled name" } diff --git a/gcc/testsuite/g++.dg/abi/mangle62a.C b/gcc/testsuite/g++.dg/abi/mangle62a.C index fca1cb6c43..a48efd07ae 100644 --- a/gcc/testsuite/g++.dg/abi/mangle62a.C +++ b/gcc/testsuite/g++.dg/abi/mangle62a.C @@ -2,10 +2,10 @@ // as a substitution candidate for a function type with function-cv-quals. // Test for that for backward compatibility. -// { dg-options -fabi-version=7 } +// { dg-options "-fabi-version=7 -Wabi" } template <class T, class U> struct A { }; -// { dg-final { scan-assembler "_Z1fP1AIKFvvES0_E" } } -void f (A<void()const, void()> *){} -// { dg-final { scan-assembler "_Z1gP1AIFvvEKS0_E" } } -void g (A<void(), void()const> *){} +// { dg-final { scan-assembler "\n_?_Z1fP1AIKFvvES0_E\[: \t\n\]" } } +void f (A<void()const, void()> *){} // { dg-warning "mangle" } +// { dg-final { scan-assembler "\n_?_Z1gP1AIFvvEKS0_E\[: \t\n\]" } } +void g (A<void(), void()const> *){} // { dg-warning "mangle" } diff --git a/gcc/testsuite/g++.dg/abi/mangle63.C b/gcc/testsuite/g++.dg/abi/mangle63.C new file mode 100644 index 0000000000..d6a58a35b8 --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/mangle63.C @@ -0,0 +1,11 @@ +// DR 850 makes this valid +// { dg-do compile { target c++11 } } + +template<class T> struct A +{ + int mem; + template<class U> decltype(U()+mem) f(); +}; +int i = A<int>().f<int>(); + +// { dg-final { scan-assembler "_ZN1AIiE1fIiEEDTplcvT__E3memEv" } } diff --git a/gcc/testsuite/g++.dg/abi/mangle64.C b/gcc/testsuite/g++.dg/abi/mangle64.C new file mode 100644 index 0000000000..778cda70dd --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/mangle64.C @@ -0,0 +1,13 @@ +// { dg-do compile { target msp430*-*-* } } +// { dg-options "-std=gnu++11" } +// { dg-skip-if "" { msp430*-*-* } { "-mcpu=msp430" } { "" } } + +__int20 x; + +__int20 foo (__int20 a, unsigned __int20 b) +{ + return a + b; +} + +// { dg-final { scan-assembler "\n_?_Z3foou5int20u6uint20\[: \t\n\]" } } + diff --git a/gcc/testsuite/g++.dg/abi/mangle65.C b/gcc/testsuite/g++.dg/abi/mangle65.C new file mode 100644 index 0000000000..13169c2797 --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/mangle65.C @@ -0,0 +1,13 @@ +// PR c++/64898 +// { dg-final { scan-assembler-not "_Z6foovar" } } + +template <class> void f() +{ + extern int foovar; + foovar = 42; +} + +int main() +{ + f<int>(); +} diff --git a/gcc/testsuite/g++.dg/abi/no-weak1.C b/gcc/testsuite/g++.dg/abi/no-weak1.C index d539015312..065c414ff8 100644 --- a/gcc/testsuite/g++.dg/abi/no-weak1.C +++ b/gcc/testsuite/g++.dg/abi/no-weak1.C @@ -1,5 +1,6 @@ // { dg-options "-fno-weak" } -// { dg-final { scan-assembler "local\[ \t\]*_ZZL1fvE1i" { target x86_64-*-*gnu } } } +// { dg-final { scan-assembler "local\[ \t\]*_ZZL1fvE1i" { target i?86-*-gnu* x86_64-*-gnu* } } } +// { dg-final { scan-assembler "local\[ \t\]*_ZZ1gIiEvvE1i" { target i?86-*-gnu* x86_64-*-gnu* } } } static inline void f() { @@ -7,7 +8,14 @@ static inline void f() ++i; }; +template <class T> static void g() +{ + static int i; + ++i; +} + int main() { f(); + g<int>(); } diff --git a/gcc/testsuite/g++.dg/abi/offsetof.C b/gcc/testsuite/g++.dg/abi/offsetof.C index d6a53e6f80..5a66511f2b 100644 --- a/gcc/testsuite/g++.dg/abi/offsetof.C +++ b/gcc/testsuite/g++.dg/abi/offsetof.C @@ -4,7 +4,6 @@ // implementation thereof. // Yes, this is bad, naughty, evil code. But it seems to be well-formed. -// So we'll just warn. // { dg-do run } @@ -18,5 +17,5 @@ struct C: public B { }; int main () { - return ((__SIZE_TYPE__) &((C*)0)->i) != sizeof(void*); // { dg-warning "offsetof|invalid" "" } + return ((__SIZE_TYPE__) &((C*)0)->i) != sizeof(void*); } diff --git a/gcc/testsuite/g++.dg/abi/rtti3.C b/gcc/testsuite/g++.dg/abi/rtti3.C index c03e4611c0..0316bcb5de 100644 --- a/gcc/testsuite/g++.dg/abi/rtti3.C +++ b/gcc/testsuite/g++.dg/abi/rtti3.C @@ -3,7 +3,7 @@ // { dg-require-weak "" } // { dg-skip-if "Linkonce not weak" { *-*-mingw* *-*-cygwin } { "*" } { "" } } -// { dg-final { scan-assembler ".weak\[ \t\]_?_ZTSPP1A" { target { ! { *-*-darwin* } } } } } +// { dg-final { scan-assembler ".weak\[ \t\]_?_ZTSPP1A" { target { ! { *-*-darwin* hppa*-*-hpux* } } } } } // { dg-final { scan-assembler-not ".weak\[ \t\]_?_ZTIPP1A" { target { ! { *-*-darwin* } } } } } // { dg-final { scan-assembler ".weak_definition\[ \t\]_?_ZTSPP1A" { target { *-*-darwin* } } } } // { dg-final { scan-assembler-not ".weak_definition\[ \t\]_?_ZTIPP1A" { target { *-*-darwin* } } } } diff --git a/gcc/testsuite/g++.dg/abi/scoped1.C b/gcc/testsuite/g++.dg/abi/scoped1.C new file mode 100644 index 0000000000..7589ed4406 --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/scoped1.C @@ -0,0 +1,23 @@ +// { dg-do run { target c++11 } } +// { dg-options "-fabi-version=0 -Wabi=2" } + +enum class A: short { a1, a2, a3 }; +void f(int i, ...) +{ + __builtin_va_list ap; + __builtin_va_start (ap, i); + if (__builtin_va_arg (ap, A) != A::a1) __builtin_abort(); // { dg-warning "passed" } + if (__builtin_va_arg (ap, A) != A::a2) __builtin_abort(); // { dg-warning "passed" } + if (__builtin_va_arg (ap, A) != A::a3) __builtin_abort(); // { dg-warning "passed" } + if (__builtin_va_arg (ap, A) != A::a1) __builtin_abort(); // { dg-warning "passed" } + if (__builtin_va_arg (ap, A) != A::a2) __builtin_abort(); // { dg-warning "passed" } + if (__builtin_va_arg (ap, A) != A::a3) __builtin_abort(); // { dg-warning "passed" } + if (__builtin_va_arg (ap, A) != A::a1) __builtin_abort(); // { dg-warning "passed" } + if (__builtin_va_arg (ap, A) != A::a2) __builtin_abort(); // { dg-warning "passed" } + if (__builtin_va_arg (ap, A) != A::a3) __builtin_abort(); // { dg-warning "passed" } +} + +int main() +{ + f(9, A::a1, A::a2, A::a3, A::a1, A::a2, A::a3, A::a1, A::a2, A::a3); // { dg-warning "passed" } +} diff --git a/gcc/testsuite/g++.dg/abi/vbase10.C b/gcc/testsuite/g++.dg/abi/vbase10.C deleted file mode 100644 index b6e7f88fca..0000000000 --- a/gcc/testsuite/g++.dg/abi/vbase10.C +++ /dev/null @@ -1,14 +0,0 @@ -// { dg-do compile } -// -fpack-struct is necessary because the code below assumes the initial -// packing is larger than 1, which cannot ge guaranteed for all targets. -// { dg-options "-Wabi -fabi-version=1 -fpack-struct=8" } -// On ARM processors, the alignment of B will be 4 even though it -// contains only a single "char". That would avoids the situation -// that the warning below is designed to catch. We therefore -// explicitly set the default structure alignment to 1. -// { dg-options "-Wabi -fabi-version=1 -mstructure-size-boundary=8" { target arm*-*-* } } - -struct A { virtual void f(); char c1; }; -struct B { B(); char c2; }; -struct C : public A, public virtual B {}; // { dg-warning "ABI" } - diff --git a/gcc/testsuite/g++.dg/abi/vbase14.C b/gcc/testsuite/g++.dg/abi/vbase14.C deleted file mode 100644 index 320d5ba77d..0000000000 --- a/gcc/testsuite/g++.dg/abi/vbase14.C +++ /dev/null @@ -1,6 +0,0 @@ -// { dg-options "-Wabi -fabi-version=1" } - -struct E1 {}; -struct E2 : public E1 {}; // { dg-warning "layout" } -struct E : public E1, public E2 {}; // { dg-warning "layout|ambiguity" } -struct N : public E { virtual void f () {} }; // { dg-warning "nearly" } diff --git a/gcc/testsuite/g++.dg/asan/asan.exp b/gcc/testsuite/g++.dg/asan/asan.exp index 30fbb1d91a..d91962df2c 100644 --- a/gcc/testsuite/g++.dg/asan/asan.exp +++ b/gcc/testsuite/g++.dg/asan/asan.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2014 Free Software Foundation, Inc. +# Copyright (C) 2012-2015 Free Software Foundation, Inc. # # This file is part of GCC. # @@ -20,17 +20,13 @@ load_lib g++-dg.exp load_lib asan-dg.exp -if ![check_effective_target_faddress_sanitizer] { - return -} - # Initialize `dg'. dg-init -if [asan_init] { +asan_init # Main loop. -gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C $srcdir/c-c++-common/asan/*.c]] "" - +if [check_effective_target_fsanitize_address] { + gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C $srcdir/c-c++-common/asan/*.c]] "" "" } # All done. diff --git a/gcc/testsuite/g++.dg/asan/asan_mem_test.cc b/gcc/testsuite/g++.dg/asan/asan_mem_test.cc index 5656aab0ba..5fc4af7e9e 100644 --- a/gcc/testsuite/g++.dg/asan/asan_mem_test.cc +++ b/gcc/testsuite/g++.dg/asan/asan_mem_test.cc @@ -74,17 +74,17 @@ TEST(AddressSanitizer, MemSetOOBTest) { // Strictly speaking we are not guaranteed to find such two pointers, // but given the structure of asan's allocator we will. static bool AllocateTwoAdjacentArrays(char **x1, char **x2, size_t size) { - vector<char *> v; + vector<uintptr_t> v; bool res = false; for (size_t i = 0; i < 1000U && !res; i++) { - v.push_back(new char[size]); + v.push_back(reinterpret_cast<uintptr_t>(new char[size])); if (i == 0) continue; sort(v.begin(), v.end()); for (size_t j = 1; j < v.size(); j++) { assert(v[j] > v[j-1]); if ((size_t)(v[j] - v[j-1]) < size * 2) { - *x2 = v[j]; - *x1 = v[j-1]; + *x2 = reinterpret_cast<char*>(v[j]); + *x1 = reinterpret_cast<char*>(v[j-1]); res = true; break; } @@ -92,9 +92,10 @@ static bool AllocateTwoAdjacentArrays(char **x1, char **x2, size_t size) { } for (size_t i = 0; i < v.size(); i++) { - if (res && v[i] == *x1) continue; - if (res && v[i] == *x2) continue; - delete [] v[i]; + char *p = reinterpret_cast<char *>(v[i]); + if (res && p == *x1) continue; + if (res && p == *x2) continue; + delete [] p; } return res; } @@ -223,6 +224,13 @@ TEST(AddressSanitizer, MemCmpOOBTest) { s1[size - 1] = '\0'; s2[size - 1] = '\0'; EXPECT_DEATH(Ident(memcmp)(s1, s2, size + 1), RightOOBReadMessage(0)); + + // Even if the buffers differ in the first byte, we still assume that + // memcmp may access the whole buffer and thus reporting the overflow here: + s1[0] = 1; + s2[0] = 123; + EXPECT_DEATH(Ident(memcmp)(s1, s2, size + 1), RightOOBReadMessage(0)); + free(s1); free(s2); } diff --git a/gcc/testsuite/g++.dg/asan/asan_oob_test.cc b/gcc/testsuite/g++.dg/asan/asan_oob_test.cc index 61d5055370..2361dc286d 100644 --- a/gcc/testsuite/g++.dg/asan/asan_oob_test.cc +++ b/gcc/testsuite/g++.dg/asan/asan_oob_test.cc @@ -97,7 +97,6 @@ TEST(AddressSanitizer, OOBRightTest) { } } -#if ASAN_ALLOCATOR_VERSION == 2 // Broken with the asan_allocator1 TEST(AddressSanitizer, LargeOOBRightTest) { size_t large_power_of_two = 1 << 19; for (size_t i = 16; i <= 256; i *= 2) { @@ -107,7 +106,6 @@ TEST(AddressSanitizer, LargeOOBRightTest) { delete [] p; } } -#endif // ASAN_ALLOCATOR_VERSION == 2 TEST(AddressSanitizer, DISABLED_DemoOOBLeftLow) { oob_test<U1>(10, -1); diff --git a/gcc/testsuite/g++.dg/asan/asan_str_test.cc b/gcc/testsuite/g++.dg/asan/asan_str_test.cc index 1b9805e8eb..207de42231 100644 --- a/gcc/testsuite/g++.dg/asan/asan_str_test.cc +++ b/gcc/testsuite/g++.dg/asan/asan_str_test.cc @@ -10,6 +10,10 @@ //===----------------------------------------------------------------------===// #include "asan_test_utils.h" +#if defined(__APPLE__) +#include <AvailabilityMacros.h> // For MAC_OS_X_VERSION_* +#endif + // Used for string functions tests static char global_string[] = "global"; static size_t global_string_length = 6; @@ -59,7 +63,19 @@ TEST(AddressSanitizer, StrLenOOBTest) { free(heap_string); } -#ifndef __APPLE__ +TEST(AddressSanitizer, WcsLenTest) { + EXPECT_EQ(0U, wcslen(Ident(L""))); + size_t hello_len = 13; + size_t hello_size = (hello_len + 1) * sizeof(wchar_t); + EXPECT_EQ(hello_len, wcslen(Ident(L"Hello, World!"))); + wchar_t *heap_string = Ident((wchar_t*)malloc(hello_size)); + memcpy(heap_string, L"Hello, World!", hello_size); + EXPECT_EQ(hello_len, Ident(wcslen(heap_string))); + EXPECT_DEATH(Ident(wcslen(heap_string + 14)), RightOOBReadMessage(0)); + free(heap_string); +} + +#if SANITIZER_TEST_HAS_STRNLEN TEST(AddressSanitizer, StrNLenOOBTest) { size_t size = Ident(123); char *str = MallocAndMemsetString(size); @@ -77,7 +93,7 @@ TEST(AddressSanitizer, StrNLenOOBTest) { EXPECT_DEATH(Ident(strnlen(str, size + 1)), RightOOBReadMessage(0)); free(str); } -#endif +#endif // SANITIZER_TEST_HAS_STRNLEN TEST(AddressSanitizer, StrDupOOBTest) { size_t size = Ident(42); @@ -168,7 +184,7 @@ TEST(AddressSanitizer, StrNCpyOOBTest) { typedef char*(*PointerToStrChr1)(const char*, int); typedef char*(*PointerToStrChr2)(char*, int); -USED static void RunStrChrTest(PointerToStrChr1 StrChr) { +UNUSED static void RunStrChrTest(PointerToStrChr1 StrChr) { size_t size = Ident(100); char *str = MallocAndMemsetString(size); str[10] = 'q'; @@ -184,7 +200,7 @@ USED static void RunStrChrTest(PointerToStrChr1 StrChr) { EXPECT_DEATH(Ident(StrChr(str, 'a')), RightOOBReadMessage(0)); free(str); } -USED static void RunStrChrTest(PointerToStrChr2 StrChr) { +UNUSED static void RunStrChrTest(PointerToStrChr2 StrChr) { size_t size = Ident(100); char *str = MallocAndMemsetString(size); str[10] = 'q'; @@ -203,7 +219,9 @@ USED static void RunStrChrTest(PointerToStrChr2 StrChr) { TEST(AddressSanitizer, StrChrAndIndexOOBTest) { RunStrChrTest(&strchr); +#if !defined(_WIN32) // no index() on Windows. RunStrChrTest(&index); +#endif } TEST(AddressSanitizer, StrCmpAndFriendsLogicTest) { @@ -226,6 +244,7 @@ TEST(AddressSanitizer, StrCmpAndFriendsLogicTest) { EXPECT_LT(0, strncmp("baa", "aaa", 1)); EXPECT_LT(0, strncmp("zyx", "", 2)); +#if !defined(_WIN32) // no str[n]casecmp on Windows. // strcasecmp EXPECT_EQ(0, strcasecmp("", "")); EXPECT_EQ(0, strcasecmp("zzz", "zzz")); @@ -245,6 +264,7 @@ TEST(AddressSanitizer, StrCmpAndFriendsLogicTest) { EXPECT_LT(0, strncasecmp("xyz", "xyy", 10)); EXPECT_LT(0, strncasecmp("Baa", "aaa", 1)); EXPECT_LT(0, strncasecmp("zyx", "", 2)); +#endif // memcmp EXPECT_EQ(0, memcmp("a", "b", 0)); @@ -287,9 +307,11 @@ TEST(AddressSanitizer, StrCmpOOBTest) { RunStrCmpTest(&strcmp); } +#if !defined(_WIN32) // no str[n]casecmp on Windows. TEST(AddressSanitizer, StrCaseCmpOOBTest) { RunStrCmpTest(&strcasecmp); } +#endif typedef int(*PointerToStrNCmp)(const char*, const char*, size_t); void RunStrNCmpTest(PointerToStrNCmp StrNCmp) { @@ -322,9 +344,12 @@ TEST(AddressSanitizer, StrNCmpOOBTest) { RunStrNCmpTest(&strncmp); } +#if !defined(_WIN32) // no str[n]casecmp on Windows. TEST(AddressSanitizer, StrNCaseCmpOOBTest) { RunStrNCmpTest(&strncasecmp); } +#endif + TEST(AddressSanitizer, StrCatOOBTest) { // strcat() reads strlen(to) bytes from |to| before concatenating. size_t to_size = Ident(100); @@ -506,11 +531,13 @@ void RunAtoiOOBTest(PointerToCallAtoi Atoi) { free(array); } +#if !defined(_WIN32) // FIXME: Fix and enable on Windows. TEST(AddressSanitizer, AtoiAndFriendsOOBTest) { RunAtoiOOBTest(&CallAtoi); RunAtoiOOBTest(&CallAtol); RunAtoiOOBTest(&CallAtoll); } +#endif void CallStrtol(const char *nptr, char **endptr, int base) { Ident(strtol(nptr, endptr, base)); @@ -560,11 +587,13 @@ void RunStrtolOOBTest(PointerToCallStrtol Strtol) { free(array); } +#if !defined(_WIN32) // FIXME: Fix and enable on Windows. TEST(AddressSanitizer, StrtollOOBTest) { RunStrtolOOBTest(&CallStrtoll); } TEST(AddressSanitizer, StrtolOOBTest) { RunStrtolOOBTest(&CallStrtol); } +#endif diff --git a/gcc/testsuite/g++.dg/asan/asan_test.C b/gcc/testsuite/g++.dg/asan/asan_test.C index e11531e07d..3cee7150f7 100644 --- a/gcc/testsuite/g++.dg/asan/asan_test.C +++ b/gcc/testsuite/g++.dg/asan/asan_test.C @@ -2,7 +2,7 @@ // { dg-skip-if "" { *-*-* } { "*" } { "-O2" } } // { dg-skip-if "" { *-*-* } { "-flto" } { "" } } // { dg-additional-sources "asan_globals_test-wrapper.cc" } -// { dg-options "-fsanitize=address -fno-builtin -Wall -Wno-format -Werror -g -DASAN_UAR=0 -DASAN_HAS_EXCEPTIONS=1 -DASAN_HAS_BLACKLIST=0 -DASAN_USE_DEJAGNU_GTEST=1 -lasan -lpthread -ldl" } +// { dg-options "-std=c++11 -fsanitize=address -fno-builtin -Wall -Wno-format -Werror -g -DASAN_UAR=0 -DASAN_HAS_EXCEPTIONS=1 -DASAN_HAS_BLACKLIST=0 -DSANITIZER_USE_DEJAGNU_GTEST=1 -lasan -lpthread -ldl" } // { dg-additional-options "-DASAN_NEEDS_SEGV=1" { target { ! arm*-*-* } } } // { dg-additional-options "-DASAN_LOW_MEMORY=1 -DASAN_NEEDS_SEGV=0" { target arm*-*-* } } // { dg-additional-options "-DASAN_AVOID_EXPENSIVE_TESTS=1" { target { ! run_expensive_tests } } } diff --git a/gcc/testsuite/g++.dg/asan/asan_test.cc b/gcc/testsuite/g++.dg/asan/asan_test.cc index 2df8c62cbb..5f2e2c244d 100644 --- a/gcc/testsuite/g++.dg/asan/asan_test.cc +++ b/gcc/testsuite/g++.dg/asan/asan_test.cc @@ -23,27 +23,10 @@ NOINLINE void *malloc_bbb(size_t size) { NOINLINE void *malloc_aaa(size_t size) { void *res = malloc_bbb(size); break_optimization(0); return res;} -#ifndef __APPLE__ -NOINLINE void *memalign_fff(size_t alignment, size_t size) { - void *res = memalign/**/(alignment, size); break_optimization(0); return res;} -NOINLINE void *memalign_eee(size_t alignment, size_t size) { - void *res = memalign_fff(alignment, size); break_optimization(0); return res;} -NOINLINE void *memalign_ddd(size_t alignment, size_t size) { - void *res = memalign_eee(alignment, size); break_optimization(0); return res;} -NOINLINE void *memalign_ccc(size_t alignment, size_t size) { - void *res = memalign_ddd(alignment, size); break_optimization(0); return res;} -NOINLINE void *memalign_bbb(size_t alignment, size_t size) { - void *res = memalign_ccc(alignment, size); break_optimization(0); return res;} -NOINLINE void *memalign_aaa(size_t alignment, size_t size) { - void *res = memalign_bbb(alignment, size); break_optimization(0); return res;} -#endif // __APPLE__ - - NOINLINE void free_ccc(void *p) { free(p); break_optimization(0);} NOINLINE void free_bbb(void *p) { free_ccc(p); break_optimization(0);} NOINLINE void free_aaa(void *p) { free_bbb(p); break_optimization(0);} - template<typename T> NOINLINE void uaf_test(int size, int off) { char *p = (char *)malloc_aaa(size); @@ -88,19 +71,19 @@ TEST(AddressSanitizer, VariousMallocsTest) { *c = 0; delete c; -#if !defined(__APPLE__) && !defined(ANDROID) && !defined(__ANDROID__) +#if SANITIZER_TEST_HAS_POSIX_MEMALIGN int *pm; int pm_res = posix_memalign((void**)&pm, kPageSize, kPageSize); EXPECT_EQ(0, pm_res); free(pm); -#endif +#endif // SANITIZER_TEST_HAS_POSIX_MEMALIGN -#if !defined(__APPLE__) +#if SANITIZER_TEST_HAS_MEMALIGN int *ma = (int*)memalign(kPageSize, kPageSize); EXPECT_EQ(0U, (uintptr_t)ma % kPageSize); ma[123] = 0; free(ma); -#endif // __APPLE__ +#endif // SANITIZER_TEST_HAS_MEMALIGN } TEST(AddressSanitizer, CallocTest) { @@ -109,13 +92,37 @@ TEST(AddressSanitizer, CallocTest) { free(a); } +TEST(AddressSanitizer, CallocReturnsZeroMem) { + size_t sizes[] = {16, 1000, 10000, 100000, 2100000}; + for (size_t s = 0; s < sizeof(sizes)/sizeof(sizes[0]); s++) { + size_t size = sizes[s]; + for (size_t iter = 0; iter < 5; iter++) { + char *x = Ident((char*)calloc(1, size)); + EXPECT_EQ(x[0], 0); + EXPECT_EQ(x[size - 1], 0); + EXPECT_EQ(x[size / 2], 0); + EXPECT_EQ(x[size / 3], 0); + EXPECT_EQ(x[size / 4], 0); + memset(x, 0x42, size); + free(Ident(x)); +#if !defined(_WIN32) + // FIXME: OOM on Windows. We should just make this a lit test + // with quarantine size set to 1. + free(Ident(malloc(Ident(1 << 27)))); // Try to drain the quarantine. +#endif + } + } +} + +#if !defined(_WIN32) // No valloc on Windows. TEST(AddressSanitizer, VallocTest) { void *a = valloc(100); EXPECT_EQ(0U, (uintptr_t)a % kPageSize); free(a); } +#endif -#ifndef __APPLE__ +#if SANITIZER_TEST_HAS_PVALLOC TEST(AddressSanitizer, PvallocTest) { char *a = (char*)pvalloc(kPageSize + 100); EXPECT_EQ(0U, (uintptr_t)a % kPageSize); @@ -127,8 +134,10 @@ TEST(AddressSanitizer, PvallocTest) { a[101] = 1; // we should not report an error here. free(a); } -#endif // __APPLE__ +#endif // SANITIZER_TEST_HAS_PVALLOC +#if !defined(_WIN32) +// FIXME: Use an equivalent of pthread_setspecific on Windows. void *TSDWorker(void *test_key) { if (test_key) { pthread_setspecific(*(pthread_key_t*)test_key, (void*)0xfeedface); @@ -158,6 +167,7 @@ TEST(AddressSanitizer, DISABLED_TSDTest) { PTHREAD_JOIN(th, NULL); pthread_key_delete(test_key); } +#endif TEST(AddressSanitizer, UAF_char) { const char *uaf_string = "AddressSanitizer:.*heap-use-after-free"; @@ -168,6 +178,36 @@ TEST(AddressSanitizer, UAF_char) { EXPECT_DEATH(uaf_test<U1>(kLargeMalloc, kLargeMalloc / 2), uaf_string); } +TEST(AddressSanitizer, UAF_long_double) { + if (sizeof(long double) == sizeof(double)) return; + long double *p = Ident(new long double[10]); + EXPECT_DEATH(Ident(p)[12] = 0, "WRITE of size 1[026]"); + EXPECT_DEATH(Ident(p)[0] = Ident(p)[12], "READ of size 1[026]"); + delete [] Ident(p); +} + +#if !defined(_WIN32) +struct Packed5 { + int x; + char c; +} __attribute__((packed)); +#else +# pragma pack(push, 1) +struct Packed5 { + int x; + char c; +}; +# pragma pack(pop) +#endif + +TEST(AddressSanitizer, UAF_Packed5) { + static_assert(sizeof(Packed5) == 5, "Please check the keywords used"); + Packed5 *p = Ident(new Packed5[2]); + EXPECT_DEATH(p[0] = p[3], "READ of size 5"); + EXPECT_DEATH(p[3] = p[0], "WRITE of size 5"); + delete [] Ident(p); +} + #if ASAN_HAS_BLACKLIST TEST(AddressSanitizer, IgnoreTest) { int *x = Ident(new int); @@ -244,41 +284,6 @@ TEST(AddressSanitizer, SignalTest) { } // namespace #endif -static void MallocStress(size_t n) { - uint32_t seed = my_rand(); - for (size_t iter = 0; iter < 10; iter++) { - vector<void *> vec; - for (size_t i = 0; i < n; i++) { - if ((i % 3) == 0) { - if (vec.empty()) continue; - size_t idx = my_rand_r(&seed) % vec.size(); - void *ptr = vec[idx]; - vec[idx] = vec.back(); - vec.pop_back(); - free_aaa(ptr); - } else { - size_t size = my_rand_r(&seed) % 1000 + 1; -#ifndef __APPLE__ - size_t alignment = 1 << (my_rand_r(&seed) % 7 + 3); - char *ptr = (char*)memalign_aaa(alignment, size); -#else - char *ptr = (char*) malloc_aaa(size); -#endif - vec.push_back(ptr); - ptr[0] = 0; - ptr[size-1] = 0; - ptr[size/2] = 0; - } - } - for (size_t i = 0; i < vec.size(); i++) - free_aaa(vec[i]); - } -} - -TEST(AddressSanitizer, MallocStressTest) { - MallocStress((ASAN_LOW_MEMORY) ? 20000 : 200000); -} - static void TestLargeMalloc(size_t size) { char buff[1024]; sprintf(buff, "is located 1 bytes to the left of %lu-byte", (long)size); @@ -286,28 +291,21 @@ static void TestLargeMalloc(size_t size) { } TEST(AddressSanitizer, LargeMallocTest) { - for (int i = 113; i < (1 << 28); i = i * 2 + 13) { + const int max_size = (SANITIZER_WORDSIZE == 32) ? 1 << 26 : 1 << 28; + for (int i = 113; i < max_size; i = i * 2 + 13) { TestLargeMalloc(i); } } -#if ASAN_LOW_MEMORY != 1 TEST(AddressSanitizer, HugeMallocTest) { -#ifdef __APPLE__ - // It was empirically found out that 1215 megabytes is the maximum amount of - // memory available to the process under AddressSanitizer on 32-bit Mac 10.6. - // 32-bit Mac 10.7 gives even less (< 1G). - // (the libSystem malloc() allows allocating up to 2300 megabytes without - // ASan). - size_t n_megs = SANITIZER_WORDSIZE == 32 ? 500 : 4100; -#else - size_t n_megs = SANITIZER_WORDSIZE == 32 ? 2600 : 4100; -#endif - TestLargeMalloc(n_megs << 20); + if (SANITIZER_WORDSIZE != 64 || ASAN_AVOID_EXPENSIVE_TESTS) return; + size_t n_megs = 4100; + EXPECT_DEATH(Ident((char*)malloc(n_megs << 20))[-1] = 0, + "is located 1 bytes to the left|" + "AddressSanitizer failed to allocate"); } -#endif -#ifndef __APPLE__ +#if SANITIZER_TEST_HAS_MEMALIGN void MemalignRun(size_t align, size_t size, int idx) { char *p = (char *)memalign(align, size); Ident(p)[idx] = 0; @@ -323,20 +321,7 @@ TEST(AddressSanitizer, memalign) { "is located 1 bytes to the right"); } } -#endif - -TEST(AddressSanitizer, ThreadedMallocStressTest) { - const int kNumThreads = 4; - const int kNumIterations = (ASAN_LOW_MEMORY) ? 10000 : 100000; - pthread_t t[kNumThreads]; - for (int i = 0; i < kNumThreads; i++) { - PTHREAD_CREATE(&t[i], 0, (void* (*)(void *x))MallocStress, - (void*)kNumIterations); - } - for (int i = 0; i < kNumThreads; i++) { - PTHREAD_JOIN(t[i], 0); - } -} +#endif // SANITIZER_TEST_HAS_MEMALIGN void *ManyThreadsWorker(void *a) { for (int iter = 0; iter < 100; iter++) { @@ -377,17 +362,30 @@ TEST(AddressSanitizer, ReallocTest) { free(ptr2); } +TEST(AddressSanitizer, ReallocFreedPointerTest) { + void *ptr = Ident(malloc(42)); + ASSERT_TRUE(NULL != ptr); + free(ptr); + EXPECT_DEATH(ptr = realloc(ptr, 77), "attempting double-free"); +} + +TEST(AddressSanitizer, ReallocInvalidPointerTest) { + void *ptr = Ident(malloc(42)); + EXPECT_DEATH(ptr = realloc((int*)ptr + 1, 77), "attempting free.*not malloc"); + free(ptr); +} + TEST(AddressSanitizer, ZeroSizeMallocTest) { // Test that malloc(0) and similar functions don't return NULL. void *ptr = Ident(malloc(0)); EXPECT_TRUE(NULL != ptr); free(ptr); -#if !defined(__APPLE__) && !defined(ANDROID) && !defined(__ANDROID__) +#if SANITIZER_TEST_HAS_POSIX_MEMALIGN int pm_res = posix_memalign(&ptr, 1<<20, 0); EXPECT_EQ(0, pm_res); EXPECT_TRUE(NULL != ptr); free(ptr); -#endif +#endif // SANITIZER_TEST_HAS_POSIX_MEMALIGN int *int_ptr = new int[0]; int *int_ptr2 = new int[0]; EXPECT_TRUE(NULL != int_ptr); @@ -397,7 +395,7 @@ TEST(AddressSanitizer, ZeroSizeMallocTest) { delete[] int_ptr2; } -#ifndef __APPLE__ +#if SANITIZER_TEST_HAS_MALLOC_USABLE_SIZE static const char *kMallocUsableSizeErrorMsg = "AddressSanitizer: attempting to call malloc_usable_size()"; @@ -413,8 +411,9 @@ TEST(AddressSanitizer, MallocUsableSizeTest) { kMallocUsableSizeErrorMsg); free(array); EXPECT_DEATH(malloc_usable_size(array), kMallocUsableSizeErrorMsg); + delete int_ptr; } -#endif +#endif // SANITIZER_TEST_HAS_MALLOC_USABLE_SIZE void WrongFree() { int *x = (int*)malloc(100 * sizeof(int)); @@ -423,10 +422,14 @@ void WrongFree() { free(x + 1); } +#if !defined(_WIN32) // FIXME: This should be a lit test. TEST(AddressSanitizer, WrongFreeTest) { - EXPECT_DEATH(WrongFree(), - "ERROR: AddressSanitizer: attempting free.*not malloc"); + EXPECT_DEATH(WrongFree(), ASAN_PCRE_DOTALL + "ERROR: AddressSanitizer: attempting free.*not malloc" + ".*is located 4 bytes inside of 400-byte region" + ".*allocated by thread"); } +#endif void DoubleFree() { int *x = (int*)malloc(100 * sizeof(int)); @@ -437,6 +440,7 @@ void DoubleFree() { abort(); } +#if !defined(_WIN32) // FIXME: This should be a lit test. TEST(AddressSanitizer, DoubleFreeTest) { EXPECT_DEATH(DoubleFree(), ASAN_PCRE_DOTALL "ERROR: AddressSanitizer: attempting double-free" @@ -444,20 +448,22 @@ TEST(AddressSanitizer, DoubleFreeTest) { ".*freed by thread T0 here" ".*previously allocated by thread T0 here"); } +#endif template<int kSize> NOINLINE void SizedStackTest() { char a[kSize]; char *A = Ident((char*)&a); + const char *expected_death = "AddressSanitizer: stack-buffer-"; for (size_t i = 0; i < kSize; i++) A[i] = i; - EXPECT_DEATH(A[-1] = 0, ""); - EXPECT_DEATH(A[-20] = 0, ""); - EXPECT_DEATH(A[-31] = 0, ""); - EXPECT_DEATH(A[kSize] = 0, ""); - EXPECT_DEATH(A[kSize + 1] = 0, ""); - EXPECT_DEATH(A[kSize + 10] = 0, ""); - EXPECT_DEATH(A[kSize + 31] = 0, ""); + EXPECT_DEATH(A[-1] = 0, expected_death); + EXPECT_DEATH(A[-5] = 0, expected_death); + EXPECT_DEATH(A[kSize] = 0, expected_death); + EXPECT_DEATH(A[kSize + 1] = 0, expected_death); + EXPECT_DEATH(A[kSize + 5] = 0, expected_death); + if (kSize > 16) + EXPECT_DEATH(A[kSize + 31] = 0, expected_death); } TEST(AddressSanitizer, SimpleStackTest) { @@ -478,6 +484,9 @@ TEST(AddressSanitizer, SimpleStackTest) { SizedStackTest<128>(); } +#if !defined(_WIN32) +// FIXME: It's a bit hard to write multi-line death test expectations +// in a portable way. Anyways, this should just be turned into a lit test. TEST(AddressSanitizer, ManyStackObjectsTest) { char XXX[10]; char YYY[20]; @@ -486,6 +495,47 @@ TEST(AddressSanitizer, ManyStackObjectsTest) { Ident(YYY); EXPECT_DEATH(Ident(ZZZ)[-1] = 0, ASAN_PCRE_DOTALL "XXX.*YYY.*ZZZ"); } +#endif + +#if 0 // This test requires online symbolizer. +// Moved to lit_tests/stack-oob-frames.cc. +// Reenable here once we have online symbolizer by default. +NOINLINE static void Frame0(int frame, char *a, char *b, char *c) { + char d[4] = {0}; + char *D = Ident(d); + switch (frame) { + case 3: a[5]++; break; + case 2: b[5]++; break; + case 1: c[5]++; break; + case 0: D[5]++; break; + } +} +NOINLINE static void Frame1(int frame, char *a, char *b) { + char c[4] = {0}; Frame0(frame, a, b, c); + break_optimization(0); +} +NOINLINE static void Frame2(int frame, char *a) { + char b[4] = {0}; Frame1(frame, a, b); + break_optimization(0); +} +NOINLINE static void Frame3(int frame) { + char a[4] = {0}; Frame2(frame, a); + break_optimization(0); +} + +TEST(AddressSanitizer, GuiltyStackFrame0Test) { + EXPECT_DEATH(Frame3(0), "located .*in frame <.*Frame0"); +} +TEST(AddressSanitizer, GuiltyStackFrame1Test) { + EXPECT_DEATH(Frame3(1), "located .*in frame <.*Frame1"); +} +TEST(AddressSanitizer, GuiltyStackFrame2Test) { + EXPECT_DEATH(Frame3(2), "located .*in frame <.*Frame2"); +} +TEST(AddressSanitizer, GuiltyStackFrame3Test) { + EXPECT_DEATH(Frame3(3), "located .*in frame <.*Frame3"); +} +#endif NOINLINE void LongJmpFunc1(jmp_buf buf) { // create three red zones for these two stack objects. @@ -498,6 +548,24 @@ NOINLINE void LongJmpFunc1(jmp_buf buf) { longjmp(buf, 1); } +NOINLINE void TouchStackFunc() { + int a[100]; // long array will intersect with redzones from LongJmpFunc1. + int *A = Ident(a); + for (int i = 0; i < 100; i++) + A[i] = i*i; +} + +// Test that we handle longjmp and do not report false positives on stack. +TEST(AddressSanitizer, LongJmpTest) { + static jmp_buf buf; + if (!setjmp(buf)) { + LongJmpFunc1(buf); + } else { + TouchStackFunc(); + } +} + +#if !defined(_WIN32) // Only basic longjmp is available on Windows. NOINLINE void BuiltinLongJmpFunc1(jmp_buf buf) { // create three red zones for these two stack objects. int a; @@ -531,25 +599,10 @@ NOINLINE void SigLongJmpFunc1(sigjmp_buf buf) { siglongjmp(buf, 1); } - -NOINLINE void TouchStackFunc() { - int a[100]; // long array will intersect with redzones from LongJmpFunc1. - int *A = Ident(a); - for (int i = 0; i < 100; i++) - A[i] = i*i; -} - -// Test that we handle longjmp and do not report fals positives on stack. -TEST(AddressSanitizer, LongJmpTest) { - static jmp_buf buf; - if (!setjmp(buf)) { - LongJmpFunc1(buf); - } else { - TouchStackFunc(); - } -} - -#if not defined(__ANDROID__) +#if !defined(__ANDROID__) && \ + !defined(__powerpc64__) && !defined(__powerpc__) +// Does not work on Power: +// https://code.google.com/p/address-sanitizer/issues/detail?id=185 TEST(AddressSanitizer, BuiltinLongJmpTest) { static jmp_buf buf; if (!__builtin_setjmp((void**)buf)) { @@ -558,7 +611,8 @@ TEST(AddressSanitizer, BuiltinLongJmpTest) { TouchStackFunc(); } } -#endif // not defined(__ANDROID__) +#endif // !defined(__ANDROID__) && !defined(__powerpc64__) && + // !defined(__powerpc__) TEST(AddressSanitizer, UnderscopeLongJmpTest) { static jmp_buf buf; @@ -577,8 +631,10 @@ TEST(AddressSanitizer, SigLongJmpTest) { TouchStackFunc(); } } +#endif -#ifdef __EXCEPTIONS +// FIXME: Why does clang-cl define __EXCEPTIONS? +#if defined(__EXCEPTIONS) && !defined(_WIN32) NOINLINE void ThrowFunc() { // create three red zones for these two stack objects. int a; @@ -626,7 +682,8 @@ TEST(AddressSanitizer, ThreadStackReuseTest) { PTHREAD_JOIN(t, 0); } -#if defined(__i386__) || defined(__x86_64__) +#if defined(__i686__) || defined(__x86_64__) +#include <emmintrin.h> TEST(AddressSanitizer, Store128Test) { char *a = Ident((char*)malloc(Ident(12))); char *p = a; @@ -644,11 +701,19 @@ TEST(AddressSanitizer, Store128Test) { } #endif +// FIXME: All tests that use this function should be turned into lit tests. string RightOOBErrorMessage(int oob_distance, bool is_write) { assert(oob_distance >= 0); char expected_str[100]; - sprintf(expected_str, ASAN_PCRE_DOTALL "%s.*located %d bytes to the right", - is_write ? "WRITE" : "READ", oob_distance); + sprintf(expected_str, ASAN_PCRE_DOTALL +#if !GTEST_USES_SIMPLE_RE + "buffer-overflow.*%s.*" +#endif + "located %d bytes to the right", +#if !GTEST_USES_SIMPLE_RE + is_write ? "WRITE" : "READ", +#endif + oob_distance); return string(expected_str); } @@ -660,11 +725,19 @@ string RightOOBReadMessage(int oob_distance) { return RightOOBErrorMessage(oob_distance, /*is_write*/false); } +// FIXME: All tests that use this function should be turned into lit tests. string LeftOOBErrorMessage(int oob_distance, bool is_write) { assert(oob_distance > 0); char expected_str[100]; - sprintf(expected_str, ASAN_PCRE_DOTALL "%s.*located %d bytes to the left", - is_write ? "WRITE" : "READ", oob_distance); + sprintf(expected_str, +#if !GTEST_USES_SIMPLE_RE + ASAN_PCRE_DOTALL "%s.*" +#endif + "located %d bytes to the left", +#if !GTEST_USES_SIMPLE_RE + is_write ? "WRITE" : "READ", +#endif + oob_distance); return string(expected_str); } @@ -818,6 +891,7 @@ void ThreadedTestSpawn() { PTHREAD_JOIN(t, 0); } +#if !defined(_WIN32) // FIXME: This should be a lit test. TEST(AddressSanitizer, ThreadedTest) { EXPECT_DEATH(ThreadedTestSpawn(), ASAN_PCRE_DOTALL @@ -825,6 +899,7 @@ TEST(AddressSanitizer, ThreadedTest) { ".*Thread T.*created" ".*Thread T.*created"); } +#endif void *ThreadedTestFunc(void *unused) { // Check if prctl(PR_SET_NAME) is supported. Return if not. @@ -855,7 +930,11 @@ TEST(AddressSanitizer, ShadowGapTest) { #if SANITIZER_WORDSIZE == 32 char *addr = (char*)0x22000000; #else +# if defined(__powerpc64__) + char *addr = (char*)0x024000800000; +# else char *addr = (char*)0x0000100000080000; +# endif #endif EXPECT_DEATH(*addr = 1, "AddressSanitizer: SEGV on unknown"); } @@ -1015,7 +1094,8 @@ TEST(AddressSanitizer, PthreadExitTest) { } } -#ifdef __EXCEPTIONS +// FIXME: Why does clang-cl define __EXCEPTIONS? +#if defined(__EXCEPTIONS) && !defined(_WIN32) NOINLINE static void StackReuseAndException() { int large_stack[1000]; Ident(large_stack); @@ -1033,12 +1113,14 @@ TEST(AddressSanitizer, DISABLED_StressStackReuseAndExceptionsTest) { } #endif +#if !defined(_WIN32) TEST(AddressSanitizer, MlockTest) { EXPECT_EQ(0, mlockall(MCL_CURRENT)); EXPECT_EQ(0, mlock((void*)0x12345, 0x5678)); EXPECT_EQ(0, munlockall()); EXPECT_EQ(0, munlock((void*)0x987, 0x654)); } +#endif struct LargeStruct { int foo[100]; @@ -1051,19 +1133,26 @@ TEST(AddressSanitizer, LargeStructCopyTest) { *Ident(&a) = *Ident(&a); } -ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS -static void NoAddressSafety() { +ATTRIBUTE_NO_SANITIZE_ADDRESS +static void NoSanitizeAddress() { char *foo = new char[10]; Ident(foo)[10] = 0; delete [] foo; } -TEST(AddressSanitizer, AttributeNoAddressSafetyTest) { - Ident(NoAddressSafety)(); +TEST(AddressSanitizer, AttributeNoSanitizeAddressTest) { + Ident(NoSanitizeAddress)(); } -// It doesn't work on Android, as calls to new/delete go through malloc/free. -#if !defined(ANDROID) && !defined(__ANDROID__) +// The new/delete/etc mismatch checks don't work on Android, +// as calls to new/delete go through malloc/free. +// OS X support is tracked here: +// https://code.google.com/p/address-sanitizer/issues/detail?id=131 +// Windows support is tracked here: +// https://code.google.com/p/address-sanitizer/issues/detail?id=309 +#if !defined(ANDROID) && !defined(__ANDROID__) && \ + !defined(__APPLE__) && \ + !defined(_WIN32) static string MismatchStr(const string &str) { return string("AddressSanitizer: alloc-dealloc-mismatch \\(") + str; } @@ -1177,3 +1266,18 @@ TEST(AddressSanitizer, LongDoubleNegativeTest) { memcpy(Ident(&a), Ident(&b), sizeof(long double)); memcpy(Ident(&c), Ident(&b), sizeof(long double)); } + +#if !defined(_WIN32) +TEST(AddressSanitizer, pthread_getschedparam) { + int policy; + struct sched_param param; + EXPECT_DEATH( + pthread_getschedparam(pthread_self(), &policy, Ident(¶m) + 2), + "AddressSanitizer: stack-buffer-.*flow"); + EXPECT_DEATH( + pthread_getschedparam(pthread_self(), Ident(&policy) - 1, ¶m), + "AddressSanitizer: stack-buffer-.*flow"); + int res = pthread_getschedparam(pthread_self(), &policy, ¶m); + ASSERT_EQ(0, res); +} +#endif diff --git a/gcc/testsuite/g++.dg/asan/asan_test_config.h b/gcc/testsuite/g++.dg/asan/asan_test_config.h index b039dc8beb..97b7dd0873 100644 --- a/gcc/testsuite/g++.dg/asan/asan_test_config.h +++ b/gcc/testsuite/g++.dg/asan/asan_test_config.h @@ -19,12 +19,6 @@ #include <string> #include <map> -#if ASAN_USE_DEJAGNU_GTEST -# include "dejagnu-gtest.h" -#else -# include "gtest/gtest.h" -#endif - using std::string; using std::vector; using std::map; @@ -42,11 +36,11 @@ using std::map; #endif #ifndef ASAN_NEEDS_SEGV -# error "please define ASAN_NEEDS_SEGV" -#endif - -#ifndef ASAN_LOW_MEMORY -# define ASAN_LOW_MEMORY 0 +# if defined(_WIN32) +# define ASAN_NEEDS_SEGV 0 +# else +# define ASAN_NEEDS_SEGV 1 +# endif #endif #ifndef ASAN_AVOID_EXPENSIVE_TESTS diff --git a/gcc/testsuite/g++.dg/asan/asan_test_utils.h b/gcc/testsuite/g++.dg/asan/asan_test_utils.h index 5ea7d4449f..f5281a6a9e 100644 --- a/gcc/testsuite/g++.dg/asan/asan_test_utils.h +++ b/gcc/testsuite/g++.dg/asan/asan_test_utils.h @@ -12,24 +12,28 @@ #ifndef ASAN_TEST_UTILS_H #define ASAN_TEST_UTILS_H -#if !defined(ASAN_EXTERNAL_TEST_CONFIG) +#if !defined(SANITIZER_EXTERNAL_TEST_CONFIG) # define INCLUDED_FROM_ASAN_TEST_UTILS_H # include "asan_test_config.h" # undef INCLUDED_FROM_ASAN_TEST_UTILS_H #endif #include "sanitizer_test_utils.h" +#include "sanitizer_pthread_wrappers.h" + #include <stdio.h> #include <signal.h> #include <stdlib.h> #include <string.h> -#include <strings.h> -#include <pthread.h> #include <stdint.h> -#include <setjmp.h> #include <assert.h> #include <algorithm> -#include <sys/mman.h> + +#if !defined(_WIN32) +# include <strings.h> +# include <sys/mman.h> +# include <setjmp.h> +#endif #ifdef __linux__ # include <sys/prctl.h> @@ -39,18 +43,10 @@ #include <unistd.h> #endif -#if defined(__i386__) || defined(__x86_64__) -#include <emmintrin.h> -#endif - -#ifndef __APPLE__ +#if !defined(__APPLE__) && !defined(__FreeBSD__) #include <malloc.h> #endif -// Check that pthread_create/pthread_join return success. -#define PTHREAD_CREATE(a, b, c, d) ASSERT_EQ(0, pthread_create(a, b, c, d)) -#define PTHREAD_JOIN(a, b) ASSERT_EQ(0, pthread_join(a, b)) - #if ASAN_HAS_EXCEPTIONS # define ASAN_THROW(x) throw (x) #else diff --git a/gcc/testsuite/g++.dg/asan/deep-stack-uaf-1.C b/gcc/testsuite/g++.dg/asan/deep-stack-uaf-1.C index 6ffec4c4c6..4ae91f7ea5 100644 --- a/gcc/testsuite/g++.dg/asan/deep-stack-uaf-1.C +++ b/gcc/testsuite/g++.dg/asan/deep-stack-uaf-1.C @@ -34,6 +34,6 @@ int main() { } // { dg-output "ERROR: AddressSanitizer:? heap-use-after-free on address.*(\n|\r\n|\r)" } -// { dg-output " #37 0x\[0-9a-f\]+ (in \[^\n\r]*DeepFree\[^\n\r]*36|\[(\]).*(\n|\r\n|\r)" } -// { dg-output " #99 0x\[0-9a-f\]+ (in \[^\n\r]*DeepFree\[^\n\r]*98|\[(\]).*(\n|\r\n|\r)" } -// { dg-output " #116 0x\[0-9a-f\]+ (in \[^\n\r]*DeepFree\[^\n\r]*115|\[(\])\[^\n\r]*(\n|\r\n|\r)" } +// { dg-output " #37 0x\[0-9a-f\]+ +(in \[^\n\r]*DeepFree\[^\n\r]*36|\[(\]).*(\n|\r\n|\r)" } +// { dg-output " #99 0x\[0-9a-f\]+ +(in \[^\n\r]*DeepFree\[^\n\r]*98|\[(\]).*(\n|\r\n|\r)" } +// { dg-output " #116 0x\[0-9a-f\]+ +(in \[^\n\r]*DeepFree\[^\n\r]*115|\[(\])\[^\n\r]*(\n|\r\n|\r)" } diff --git a/gcc/testsuite/g++.dg/asan/deep-tail-call-1.C b/gcc/testsuite/g++.dg/asan/deep-tail-call-1.C index 5ac63f1d54..a7cdb9fd61 100644 --- a/gcc/testsuite/g++.dg/asan/deep-tail-call-1.C +++ b/gcc/testsuite/g++.dg/asan/deep-tail-call-1.C @@ -15,8 +15,8 @@ int main() { } // { dg-output "AddressSanitizer:? global-buffer-overflow.*(\n|\r\n|\r)" } -// { dg-output " #0 0x\[0-9a-f\]+ (in \[^\n\r]*call4\[^\n\r]*|\[(\])\[^\n\r]*(\n|\r\n|\r)" } -// { dg-output " #1 0x\[0-9a-f\]+ (in \[^\n\r]*call3\[^\n\r]*|\[(\])\[^\n\r]*(\n|\r\n|\r)" } -// { dg-output " #2 0x\[0-9a-f\]+ (in \[^\n\r]*call2\[^\n\r]*|\[(\])\[^\n\r]*(\n|\r\n|\r)" } -// { dg-output " #3 0x\[0-9a-f\]+ (in \[^\n\r]*call1\[^\n\r]*|\[(\])\[^\n\r]*(\n|\r\n|\r)" } -// { dg-output " #4 0x\[0-9a-f\]+ (in \[^\n\r]*main\[^\n\r]*|\[(\])\[^\n\r]*(\n|\r\n|\r)" } +// { dg-output " #0 0x\[0-9a-f\]+ +(in \[^\n\r]*call4\[^\n\r]*|\[(\])\[^\n\r]*(\n|\r\n|\r)" } +// { dg-output " #1 0x\[0-9a-f\]+ +(in \[^\n\r]*call3\[^\n\r]*|\[(\])\[^\n\r]*(\n|\r\n|\r)" } +// { dg-output " #2 0x\[0-9a-f\]+ +(in \[^\n\r]*call2\[^\n\r]*|\[(\])\[^\n\r]*(\n|\r\n|\r)" } +// { dg-output " #3 0x\[0-9a-f\]+ +(in \[^\n\r]*call1\[^\n\r]*|\[(\])\[^\n\r]*(\n|\r\n|\r)" } +// { dg-output " #4 0x\[0-9a-f\]+ +(in \[^\n\r]*main\[^\n\r]*|\[(\])\[^\n\r]*(\n|\r\n|\r)" } diff --git a/gcc/testsuite/g++.dg/asan/large-func-test-1.C b/gcc/testsuite/g++.dg/asan/large-func-test-1.C index 9344c3bcff..0c1b6ce0c6 100644 --- a/gcc/testsuite/g++.dg/asan/large-func-test-1.C +++ b/gcc/testsuite/g++.dg/asan/large-func-test-1.C @@ -38,8 +38,8 @@ int main() { // { dg-output "ERROR: AddressSanitizer:? heap-buffer-overflow on address\[^\n\r]*" } // { dg-output "0x\[0-9a-f\]+ at pc 0x\[0-9a-f\]+ bp 0x\[0-9a-f\]+ sp 0x\[0-9a-f\]+\[^\n\r]*(\n|\r\n|\r)" } // { dg-output "\[^\n\r]*READ of size 4 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r)" } -// { dg-output " #0 0x\[0-9a-f\]+ (in \[^\n\r]*LargeFunction\[^\n\r]*(large-func-test-1.C:18|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } +// { dg-output " #0 0x\[0-9a-f\]+ +(in \[^\n\r]*LargeFunction\[^\n\r]*(large-func-test-1.C:18|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } // { dg-output "\[^\n\r]*0x\[0-9a-f\]+ is located 44 bytes to the right of 400-byte region.*(\n|\r\n|\r)" } // { dg-output "\[^\n\r]*allocated by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } -// { dg-output " #0( 0x\[0-9a-f\]+ (in _*(interceptor_|)malloc|\[(\])\[^\n\r]*(\n|\r\n|\r)" } -// { dg-output " #1|) 0x\[0-9a-f\]+ (in (operator new|_*_Zn\[aw\]\[mj\])|\[(\])\[^\n\r]*(\n|\r\n|\r)" } +// { dg-output " #0( 0x\[0-9a-f\]+ +(in _*(interceptor_|)malloc|\[(\])\[^\n\r]*(\n|\r\n|\r)" } +// { dg-output " #1|) 0x\[0-9a-f\]+ +(in (operator new|(wrap|)_*_Zn\[aw\]\[mj\])|\[(\])\[^\n\r]*(\n|\r\n|\r)" } diff --git a/gcc/testsuite/g++.dg/asan/pr64937.C b/gcc/testsuite/g++.dg/asan/pr64937.C new file mode 100644 index 0000000000..91beee0eed --- /dev/null +++ b/gcc/testsuite/g++.dg/asan/pr64937.C @@ -0,0 +1,30 @@ +// PR middle-end/64937 +// { dg-do compile } +// { dg-options "-fsanitize=address -fcompare-debug" } + +namespace foo_aux { + struct BarParser { }; +} +extern "C" { + extern void __assert_fail (__const char *__assertion, __const char *__file, + unsigned int __line, __const char *__function); +} +namespace foo { + class BarBox { + public: + BarBox (int xl = 0, int yl = 0) { } + }; + class BarFoo { + public: + explicit BarFoo (BarBox box) { + ((_orig_mask) ? static_cast < void >(0) : + __assert_fail ("_orig_mask", "foo.h", 159, __PRETTY_FUNCTION__)); + } + BarBox *_orig_mask; + }; +} +static void +ProcessOp (foo_aux::BarParser * p, int xl, int yr) +{ + foo::BarFoo tiles (foo::BarBox (xl, yr)); +} diff --git a/gcc/testsuite/g++.dg/asan/pr65004.C b/gcc/testsuite/g++.dg/asan/pr65004.C new file mode 100644 index 0000000000..78cb204054 --- /dev/null +++ b/gcc/testsuite/g++.dg/asan/pr65004.C @@ -0,0 +1,48 @@ +// PR sanitizer/65004 +// { dg-do compile } +// { dg-options "-fcompare-debug -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all" } + +namespace N { + template <typename Signature> struct function; + namespace detail { + namespace function { + struct vtable_base { }; + } + } + struct function_base { + detail::function::vtable_base * vtable; + }; + template <typename R, typename T0> struct function1 : public function_base { }; + template <typename R, typename T0> struct function <R (T0)> : public function1 <R, T0> { }; +} +namespace Bar { + typedef N::function <void (const char *)> WarningHandler; +} +namespace Foo { + struct FooRecord { + virtual ~FooRecord (); + }; + struct TestRecord : public FooRecord { + long x; + }; +} +namespace Foo { + using Bar::WarningHandler; + struct FooScanner { + WarningHandler warnHandler; + int readByte (); + long readSignedInteger (); + }; + struct FooRecordReader { + FooScanner & scanner; + long readSInt (); + void readTestRecord (TestRecord * recp); + }; + inline long FooRecordReader::readSInt () { + return scanner.readSignedInteger (); + } + void FooRecordReader::readTestRecord (TestRecord * recp) { + int infoByte = scanner.readByte (); + recp->x = readSInt (); + } +} diff --git a/gcc/testsuite/g++.dg/asan/sanitizer_pthread_wrappers.h b/gcc/testsuite/g++.dg/asan/sanitizer_pthread_wrappers.h new file mode 100644 index 0000000000..2e71ecbb33 --- /dev/null +++ b/gcc/testsuite/g++.dg/asan/sanitizer_pthread_wrappers.h @@ -0,0 +1,64 @@ +//===-- sanitizer_pthread_wrappers.h ----------------------------*- C++ -*-===// +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file is a part of *Sanitizer runtime. +// It provides handy wrappers for thread manipulation, that: +// a) assert on any failure rather than returning an error code +// b) defines pthread-like interface on platforms where where <pthread.h> +// is not supplied by default. +// +//===----------------------------------------------------------------------===// + +#ifndef SANITIZER_PTHREAD_WRAPPERS_H +#define SANITIZER_PTHREAD_WRAPPERS_H + +#include "sanitizer_test_utils.h" + +#if !defined(_WIN32) +# include <pthread.h> +// Simply forward the arguments and check that the pthread functions succeed. +# define PTHREAD_CREATE(a, b, c, d) ASSERT_EQ(0, pthread_create(a, b, c, d)) +# define PTHREAD_JOIN(a, b) ASSERT_EQ(0, pthread_join(a, b)) +#else +typedef HANDLE pthread_t; + +struct PthreadHelperCreateThreadInfo { + void *(*start_routine)(void *); + void *arg; +}; + +inline DWORD WINAPI PthreadHelperThreadProc(void *arg) { + PthreadHelperCreateThreadInfo *start_data = + reinterpret_cast<PthreadHelperCreateThreadInfo*>(arg); + void *ret = (start_data->start_routine)(start_data->arg); + delete start_data; + return (DWORD)ret; +} + +inline void PTHREAD_CREATE(pthread_t *thread, void *attr, + void *(*start_routine)(void *), void *arg) { + ASSERT_EQ(0, attr) << "Thread attributes are not supported yet."; + PthreadHelperCreateThreadInfo *data = new PthreadHelperCreateThreadInfo; + data->start_routine = start_routine; + data->arg = arg; + *thread = CreateThread(0, 0, PthreadHelperThreadProc, data, 0, 0); + ASSERT_NE(nullptr, *thread) << "Failed to create a thread."; +} + +inline void PTHREAD_JOIN(pthread_t thread, void **value_ptr) { + ASSERT_EQ(0, value_ptr) << "Nonzero value_ptr is not supported yet."; + ASSERT_EQ(WAIT_OBJECT_0, WaitForSingleObject(thread, INFINITE)); + ASSERT_NE(0, CloseHandle(thread)); +} + +inline void pthread_exit(void *retval) { + ASSERT_EQ(0, retval) << "Nonzero retval is not supported yet."; + ExitThread((DWORD)retval); +} +#endif // _WIN32 + +#endif // SANITIZER_PTHREAD_WRAPPERS_H diff --git a/gcc/testsuite/g++.dg/asan/sanitizer_test_config.h b/gcc/testsuite/g++.dg/asan/sanitizer_test_config.h new file mode 100644 index 0000000000..a819a4097a --- /dev/null +++ b/gcc/testsuite/g++.dg/asan/sanitizer_test_config.h @@ -0,0 +1,28 @@ +//===-- sanitizer_test_config.h ---------------------------------*- C++ -*-===// +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file is a part of *Sanitizer runtime. +// +//===----------------------------------------------------------------------===// +#if !defined(INCLUDED_FROM_SANITIZER_TEST_UTILS_H) +# error "This file should be included into sanitizer_test_utils.h only" +#endif + +#ifndef SANITIZER_TEST_CONFIG_H +#define SANITIZER_TEST_CONFIG_H + +#include <vector> +#include <string> +#include <map> + +#if SANITIZER_USE_DEJAGNU_GTEST +# include "dejagnu-gtest.h" +#else +# include "gtest/gtest.h" +#endif + +#endif // SANITIZER_TEST_CONFIG_H diff --git a/gcc/testsuite/g++.dg/asan/sanitizer_test_utils.h b/gcc/testsuite/g++.dg/asan/sanitizer_test_utils.h index 99720c354f..b118de1d34 100644 --- a/gcc/testsuite/g++.dg/asan/sanitizer_test_utils.h +++ b/gcc/testsuite/g++.dg/asan/sanitizer_test_utils.h @@ -14,32 +14,47 @@ #define SANITIZER_TEST_UTILS_H #if defined(_WIN32) -typedef unsigned __int8 uint8_t; -typedef unsigned __int16 uint16_t; -typedef unsigned __int32 uint32_t; -typedef unsigned __int64 uint64_t; -typedef __int8 int8_t; -typedef __int16 int16_t; -typedef __int32 int32_t; -typedef __int64 int64_t; +// <windows.h> should always be the first include on Windows. +# include <windows.h> +// MSVS headers define max/min as macros, so std::max/min gets crazy. +# undef max +# undef min +#endif + +#if !defined(SANITIZER_EXTERNAL_TEST_CONFIG) +# define INCLUDED_FROM_SANITIZER_TEST_UTILS_H +# include "sanitizer_test_config.h" +# undef INCLUDED_FROM_SANITIZER_TEST_UTILS_H +#endif + +#include <stdint.h> + +#if defined(_MSC_VER) # define NOINLINE __declspec(noinline) -# define USED -#else // defined(_WIN32) +#else // defined(_MSC_VER) # define NOINLINE __attribute__((noinline)) +#endif // defined(_MSC_VER) + +#if !defined(_MSC_VER) || defined(__clang__) +# define UNUSED __attribute__((unused)) # define USED __attribute__((used)) -#include <stdint.h> -#endif // defined(_WIN32) +#else +# define UNUSED +# define USED +#endif #if !defined(__has_feature) #define __has_feature(x) 0 #endif -#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__) -# define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS \ +#ifndef ATTRIBUTE_NO_SANITIZE_ADDRESS +# if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__) +# define ATTRIBUTE_NO_SANITIZE_ADDRESS \ __attribute__((no_sanitize_address)) -#else -# define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS -#endif +# else +# define ATTRIBUTE_NO_SANITIZE_ADDRESS +# endif +#endif // ATTRIBUTE_NO_SANITIZE_ADDRESS #if __LP64__ || defined(_WIN64) # define SANITIZER_WORDSIZE 64 @@ -49,7 +64,9 @@ typedef __int64 int64_t; // Make the compiler thinks that something is going on there. inline void break_optimization(void *arg) { +#if !defined(_WIN32) || defined(__clang__) __asm__ __volatile__("" : : "r" (arg) : "memory"); +#endif } // This function returns its parameter but in such a way that compiler @@ -74,5 +91,28 @@ static inline uint32_t my_rand() { return my_rand_r(&global_seed); } +// Set availability of platform-specific functions. + +#if !defined(__APPLE__) && !defined(ANDROID) && !defined(__ANDROID__) && !defined(_WIN32) +# define SANITIZER_TEST_HAS_POSIX_MEMALIGN 1 +#else +# define SANITIZER_TEST_HAS_POSIX_MEMALIGN 0 +#endif + +#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(_WIN32) +# define SANITIZER_TEST_HAS_MEMALIGN 1 +# define SANITIZER_TEST_HAS_PVALLOC 1 +# define SANITIZER_TEST_HAS_MALLOC_USABLE_SIZE 1 +#else +# define SANITIZER_TEST_HAS_MEMALIGN 0 +# define SANITIZER_TEST_HAS_PVALLOC 0 +# define SANITIZER_TEST_HAS_MALLOC_USABLE_SIZE 0 +#endif + +#if !defined(__APPLE__) +# define SANITIZER_TEST_HAS_STRNLEN 1 +#else +# define SANITIZER_TEST_HAS_STRNLEN 0 +#endif #endif // SANITIZER_TEST_UTILS_H diff --git a/gcc/testsuite/g++.dg/asan/symbolize-callback-1.C b/gcc/testsuite/g++.dg/asan/symbolize-callback-1.C deleted file mode 100644 index 9978958f9e..0000000000 --- a/gcc/testsuite/g++.dg/asan/symbolize-callback-1.C +++ /dev/null @@ -1,21 +0,0 @@ -// { dg-do run } -// { dg-skip-if "" { *-*-* } { "*" } { "-O2" } } -// { dg-options "-fno-builtin-malloc -fno-builtin-free" } -// { dg-shouldfail "asan" } - -#include <stdio.h> -#include <stdlib.h> - -extern "C" -bool __asan_symbolize(const void *, char *out_buffer, int out_size) { - snprintf(out_buffer, out_size, "MySymbolizer"); - return true; -} - -int main() { - char *x = (char*)malloc(10); - free(x); - return x[5]; -} - -// { dg-output "MySymbolizer" } diff --git a/gcc/testsuite/g++.dg/bprob/bprob.exp b/gcc/testsuite/g++.dg/bprob/bprob.exp index 8b68b859dd..760fabb949 100644 --- a/gcc/testsuite/g++.dg/bprob/bprob.exp +++ b/gcc/testsuite/g++.dg/bprob/bprob.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2014 Free Software Foundation, Inc. +# Copyright (C) 2001-2015 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/gcc/testsuite/g++.dg/charset/charset.exp b/gcc/testsuite/g++.dg/charset/charset.exp index 3ca071eea5..4d7a4ed230 100644 --- a/gcc/testsuite/g++.dg/charset/charset.exp +++ b/gcc/testsuite/g++.dg/charset/charset.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2004-2014 Free Software Foundation, Inc. +# Copyright (C) 2004-2015 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -38,7 +38,7 @@ dg-init # Main loop. g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.{c,cc,S} ]] \ - $DEFAULT_CHARSETCFLAGS + "" $DEFAULT_CHARSETCFLAGS # All done. dg-finish diff --git a/gcc/testsuite/g++.dg/cilk-plus/AN/array_function.cc b/gcc/testsuite/g++.dg/cilk-plus/AN/array_function.cc new file mode 100644 index 0000000000..b111e217cf --- /dev/null +++ b/gcc/testsuite/g++.dg/cilk-plus/AN/array_function.cc @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +void f() { } +int main() +{ + f[0:1:1]; // { dg-error "function type" } +} diff --git a/gcc/testsuite/g++.dg/cilk-plus/CK/cf3.cc b/gcc/testsuite/g++.dg/cilk-plus/CK/cf3.cc new file mode 100644 index 0000000000..8d88c5f346 --- /dev/null +++ b/gcc/testsuite/g++.dg/cilk-plus/CK/cf3.cc @@ -0,0 +1,96 @@ +/* { dg-options "-fcilkplus" } */ + +typedef __PTRDIFF_TYPE__ ptrdiff_t; + +template <typename T> +class I +{ +public: + typedef ptrdiff_t difference_type; + I (); + ~I (); + I (T *); + I (const I &); + T &operator * (); + T *operator -> (); + T &operator [] (const difference_type &) const; + I &operator = (const I &); + I &operator ++ (); + I operator ++ (int); + I &operator -- (); + I operator -- (int); + I &operator += (const difference_type &); + I &operator -= (const difference_type &); + I operator + (const difference_type &) const; + I operator - (const difference_type &) const; + template <typename S> friend bool operator == (I<S> &, I<S> &); + template <typename S> friend bool operator == (const I<S> &, const I<S> &); + template <typename S> friend bool operator < (I<S> &, I<S> &); + template <typename S> friend bool operator < (const I<S> &, const I<S> &); + template <typename S> friend bool operator <= (I<S> &, I<S> &); + template <typename S> friend bool operator <= (const I<S> &, const I<S> &); + template <typename S> friend bool operator > (I<S> &, I<S> &); + template <typename S> friend bool operator > (const I<S> &, const I<S> &); + template <typename S> friend bool operator >= (I<S> &, I<S> &); + template <typename S> friend bool operator >= (const I<S> &, const I<S> &); + template <typename S> friend typename I<S>::difference_type operator - (I<S> &, I<S> &); + template <typename S> friend typename I<S>::difference_type operator - (const I<S> &, const I<S> &); + template <typename S> friend I<S> operator + (typename I<S>::difference_type , const I<S> &); +private: + T *p; +}; +template <typename T> I<T>::I () : p (0) {} +template <typename T> I<T>::~I () {} +template <typename T> I<T>::I (T *x) : p (x) {} +template <typename T> I<T>::I (const I &x) : p (x.p) {} +template <typename T> T &I<T>::operator * () { return *p; } +template <typename T> T *I<T>::operator -> () { return p; } +template <typename T> T &I<T>::operator [] (const difference_type &x) const { return p[x]; } +template <typename T> I<T> &I<T>::operator = (const I &x) { p = x.p; return *this; } +template <typename T> I<T> &I<T>::operator ++ () { ++p; return *this; } +template <typename T> I<T> I<T>::operator ++ (int) { return I (p++); } +template <typename T> I<T> &I<T>::operator -- () { --p; return *this; } +template <typename T> I<T> I<T>::operator -- (int) { return I (p--); } +template <typename T> I<T> &I<T>::operator += (const difference_type &x) { p += x; return *this; } +template <typename T> I<T> &I<T>::operator -= (const difference_type &x) { p -= x; return *this; } +template <typename T> I<T> I<T>::operator + (const difference_type &x) const { return I (p + x); } +template <typename T> I<T> I<T>::operator - (const difference_type &x) const { return I (p - x); } +template <typename T> bool operator == (I<T> &x, I<T> &y) { return x.p == y.p; } +template <typename T> bool operator == (const I<T> &x, const I<T> &y) { return x.p == y.p; } +template <typename T> bool operator != (I<T> &x, I<T> &y) { return !(x == y); } +template <typename T> bool operator != (const I<T> &x, const I<T> &y) { return !(x == y); } +template <typename T> bool operator < (I<T> &x, I<T> &y) { return x.p < y.p; } +template <typename T> bool operator < (const I<T> &x, const I<T> &y) { return x.p < y.p; } +template <typename T> bool operator <= (I<T> &x, I<T> &y) { return x.p <= y.p; } +template <typename T> bool operator <= (const I<T> &x, const I<T> &y) { return x.p <= y.p; } +template <typename T> bool operator > (I<T> &x, I<T> &y) { return x.p > y.p; } +template <typename T> bool operator > (const I<T> &x, const I<T> &y) { return x.p > y.p; } +template <typename T> bool operator >= (I<T> &x, I<T> &y) { return x.p >= y.p; } +template <typename T> bool operator >= (const I<T> &x, const I<T> &y) { return x.p >= y.p; } +template <typename T> typename I<T>::difference_type operator - (I<T> &x, I<T> &y) { return x.p - y.p; } +template <typename T> typename I<T>::difference_type operator - (const I<T> &x, const I<T> &y) { return x.p - y.p; } +template <typename T> I<T> operator + (typename I<T>::difference_type x, const I<T> &y) { return I<T> (x + y.p); } + +template <typename T> +class J +{ +public: + J(const I<T> &x, const I<T> &y) : b (x), e (y) {} + const I<T> &begin (); + const I<T> &end (); +private: + I<T> b, e; +}; + +template <typename T> const I<T> &J<T>::begin () { return b; } +template <typename T> const I<T> &J<T>::end () { return e; } + +template <typename T> +void baz (I<T> &i); + +void +foo (J<int> j) +{ + _Cilk_for (I<int> i = j.begin (); i < j.end (); i += 2) + baz (i); +} diff --git a/gcc/testsuite/g++.dg/cilk-plus/CK/cilk-for-tplt.cc b/gcc/testsuite/g++.dg/cilk-plus/CK/cilk-for-tplt.cc new file mode 100644 index 0000000000..ff9a324a13 --- /dev/null +++ b/gcc/testsuite/g++.dg/cilk-plus/CK/cilk-for-tplt.cc @@ -0,0 +1,25 @@ +/* { dg-do run { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-options "-fcilkplus" } */ +/* { dg-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */ + +#define SIZE 100 +#define CHECK_VALUE 5 + +template <class T> +int func (T start, T end) +{ + int Array[SIZE]; + _Cilk_for (T ii = 0; ii < end; ii++) + Array[ii] = CHECK_VALUE; + + for (T ii = 0; ii < end; ii++) + if (Array[ii] != CHECK_VALUE) + __builtin_abort (); + + return 0; +} + +int main (void) +{ + return func <int> (0, 100) + func <long> (0, 100); +} diff --git a/gcc/testsuite/g++.dg/cilk-plus/CK/for1.cc b/gcc/testsuite/g++.dg/cilk-plus/CK/for1.cc new file mode 100644 index 0000000000..d2243acf58 --- /dev/null +++ b/gcc/testsuite/g++.dg/cilk-plus/CK/for1.cc @@ -0,0 +1,376 @@ +/* { dg-do run { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-options "-fcilkplus" } */ +/* { dg-additional-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */ + +#if HAVE_IO +#include <cstdio> +#endif + +typedef __PTRDIFF_TYPE__ ptrdiff_t; +extern "C" void abort (); + +template <typename T> +class I +{ +public: + typedef ptrdiff_t difference_type; + I (); + ~I (); + I (T *); + I (const I &); + T &operator * (); + T *operator -> (); + T &operator [] (const difference_type &) const; + I &operator = (const I &); + I &operator ++ (); + I operator ++ (int); + I &operator -- (); + I operator -- (int); + I &operator += (const difference_type &); + I &operator -= (const difference_type &); + I operator + (const difference_type &) const; + I operator - (const difference_type &) const; + template <typename S> friend bool operator == (I<S> &, I<S> &); + template <typename S> friend bool operator == (const I<S> &, const I<S> &); + template <typename S> friend bool operator < (I<S> &, I<S> &); + template <typename S> friend bool operator < (const I<S> &, const I<S> &); + template <typename S> friend bool operator <= (I<S> &, I<S> &); + template <typename S> friend bool operator <= (const I<S> &, const I<S> &); + template <typename S> friend bool operator > (I<S> &, I<S> &); + template <typename S> friend bool operator > (const I<S> &, const I<S> &); + template <typename S> friend bool operator >= (I<S> &, I<S> &); + template <typename S> friend bool operator >= (const I<S> &, const I<S> &); + template <typename S> friend typename I<S>::difference_type operator - (I<S> &, I<S> &); + template <typename S> friend typename I<S>::difference_type operator - (const I<S> &, const I<S> &); + template <typename S> friend I<S> operator + (typename I<S>::difference_type , const I<S> &); +private: + T *p; +}; +template <typename T> I<T>::I () : p (0) {} +template <typename T> I<T>::~I () {} +template <typename T> I<T>::I (T *x) : p (x) {} +template <typename T> I<T>::I (const I &x) : p (x.p) {} +template <typename T> T &I<T>::operator * () { return *p; } +template <typename T> T *I<T>::operator -> () { return p; } +template <typename T> T &I<T>::operator [] (const difference_type &x) const { return p[x]; } +template <typename T> I<T> &I<T>::operator = (const I &x) { p = x.p; return *this; } +template <typename T> I<T> &I<T>::operator ++ () { ++p; return *this; } +template <typename T> I<T> I<T>::operator ++ (int) { return I (p++); } +template <typename T> I<T> &I<T>::operator -- () { --p; return *this; } +template <typename T> I<T> I<T>::operator -- (int) { return I (p--); } +template <typename T> I<T> &I<T>::operator += (const difference_type &x) { p += x; return *this; } +template <typename T> I<T> &I<T>::operator -= (const difference_type &x) { p -= x; return *this; } +template <typename T> I<T> I<T>::operator + (const difference_type &x) const { return I (p + x); } +template <typename T> I<T> I<T>::operator - (const difference_type &x) const { return I (p - x); } +template <typename T> bool operator == (I<T> &x, I<T> &y) { return x.p == y.p; } +template <typename T> bool operator == (const I<T> &x, const I<T> &y) { return x.p == y.p; } +template <typename T> bool operator != (I<T> &x, I<T> &y) { return !(x == y); } +template <typename T> bool operator != (const I<T> &x, const I<T> &y) { return !(x == y); } +template <typename T> bool operator < (I<T> &x, I<T> &y) { return x.p < y.p; } +template <typename T> bool operator < (const I<T> &x, const I<T> &y) { return x.p < y.p; } +template <typename T> bool operator <= (I<T> &x, I<T> &y) { return x.p <= y.p; } +template <typename T> bool operator <= (const I<T> &x, const I<T> &y) { return x.p <= y.p; } +template <typename T> bool operator > (I<T> &x, I<T> &y) { return x.p > y.p; } +template <typename T> bool operator > (const I<T> &x, const I<T> &y) { return x.p > y.p; } +template <typename T> bool operator >= (I<T> &x, I<T> &y) { return x.p >= y.p; } +template <typename T> bool operator >= (const I<T> &x, const I<T> &y) { return x.p >= y.p; } +template <typename T> typename I<T>::difference_type operator - (I<T> &x, I<T> &y) { return x.p - y.p; } +template <typename T> typename I<T>::difference_type operator - (const I<T> &x, const I<T> &y) { return x.p - y.p; } +template <typename T> I<T> operator + (typename I<T>::difference_type x, const I<T> &y) { return I<T> (x + y.p); } + +template <typename T> +class J +{ +public: + J(const I<T> &x, const I<T> &y) : b (x), e (y) {} + const I<T> &begin (); + const I<T> &end (); +private: + I<T> b, e; +}; + +template <typename T> const I<T> &J<T>::begin () { return b; } +template <typename T> const I<T> &J<T>::end () { return e; } + +int results[2000]; + +template <typename T> +void +baz (I<T> &i) +{ + if (*i < 0 || *i >= 2000) + { +#if HAVE_IO + printf ("*i(%d) is < 0 or >= 2000\n", *i); + fflush (stdout); +#endif + __builtin_abort (); + } + else + results[*i]++; +} + +void +f1 (const I<int> &x, const I<int> &y) +{ + _Cilk_for (I<int> i = x; i <= y; i += 6) + { + baz (i); + } + +#if HAVE_IO + printf("===== Starting F1 =========\n"); + for (I<int> i = x; i <= y; i+= 6) { + printf("Result[%4d] = %2d\n", *i, results[*i]); + fflush (stdout); + } +#endif +} + +void +f2 (const I<int> &x, const I<int> &y) +{ + _Cilk_for (I<int> i = x; i < y - 1; i += 2) + baz (i); + +#if HAVE_IO + printf("===== Starting F2 =========\n"); + for (int ii = 0; ii < 1998; ii += 2) { + printf("Result[%4d] = %2d\n", ii, results[ii]); + fflush (stdout); + } +#endif +} + +template <typename T> +void +f3 (const I<int> &x, const I<int> &y) +{ + _Cilk_for (I<int> i = x; i <= y; i += 1) + baz (i); +#if HAVE_IO + printf("===== Starting F3 =========\n"); + for (int ii = 20; ii < 1987; ii += 1) { + printf("Result[%4d] = %2d\n", ii, results[ii]); + fflush (stdout); + } + +#endif +} + +template <typename T> +void +f4 (const I<int> &x, const I<int> &y) +{ + _Cilk_for (I<int> i = x + (2000 - 64); i > y + 10; --i) + baz (i); +#if HAVE_IO + printf("===== Starting F3 =========\n"); + for (I<int> i = x + (2000 - 64); i > y + 10; --i) { + printf("Result[%4d] = %2d\n", *i, results[*i]); + fflush (stdout); + } +#endif +} +void +f5 (const I<int> &x, const I<int> &y) +{ + _Cilk_for (I<int> i = x + 2000 - 64; i > y + 10; i -= 10) + baz (i); +#if HAVE_IO + for (I<int> i = x + 2000 - 64; i > y + 10; i -= 10) { + printf("Result[%4d] = %2d\n", *i, results[*i]); + fflush (stdout); + } +#endif +} + +template <int N> +void +f6 (const I<int> &x, const I<int> &y) +{ + _Cilk_for (I<int> i = x + 2000 - 64; i > y + 10; i -= 10) + { + I<int> j = i + N; + baz (j); + } +#if HAVE_IO + for (I<int> i = x + 2000 - 64; i > y + 10; i = i - 12 + 2) + { + I<int> j = i + N; + printf("Result[%4d] = %2d\n", *j, results[*j]); + fflush (stdout); + } +#endif +} +template <int N> +void +f7 (I<int> ii, const I<int> &x, const I<int> &y) +{ + _Cilk_for (I <int> i = x - 10; i <= y + 10; i += N) + baz (i); +#if HAVE_IO + for (I<int> i = x - 10; i <= y + 10; i += N) + { + printf("Result[%4d] = %2d\n", *i, results[*i]); + fflush (stdout); + } +#endif +} + +template <int N> +void +f8 (J<int> j) +{ + _Cilk_for (I<int> i = j.begin (); i <= j.end () + N; i += 2) + baz (i); +#if HAVE_IO + for (I<int> i = j.begin (); i <= j.end () + N; i += 2) { + printf("Result[%4d] = %2d\n", *i, results[*i]); + fflush (stdout); + } +#endif + +} + +template <typename T, int N> +void +f9 (const I<T> &x, const I<T> &y) +{ + _Cilk_for (I<T> i = x; i <= y; i += N) + baz (i); +#if HAVE_IO + for (I<T> i = x; i <= y; i = i + N) + { + printf("Result[%4d] = %2d\n", *i, results[*i]); + fflush (stdout); + } +#endif +} + +template <typename T, int N> +void +f10 (const I<T> &x, const I<T> &y) +{ + _Cilk_for (I<T> i = x; i > y; i += N) + baz (i); +#if HAVE_IO + for (I<T> i = x; i > y; i = i + N) { + printf("Result[%4d] = %2d\n", *i, results[*i]); + fflush (stdout); + } +#endif +} + +template <typename T> +void +f11 (const T &x, const T &y) +{ + _Cilk_for (T i = x; i <= y; i += 3) + baz (i); + +#if HAVE_IO + for (T i = x; i <= y; i += 3) { + printf("Result[%4d] = %2d\n", *i, results[*i]); + fflush (stdout); + } +#endif + T j = y + 3; + baz (j); + +} + +template <typename T> +void +f12 (const T &x, const T &y) +{ + _Cilk_for (T i = x; i > y; --i) + baz (i); +#if HAVE_IO + for (T i = x; i > y; --i) { + printf("Result[%4d] = %2d\n", *i, results[*i]); + fflush (stdout); + } +#endif +} +template <int N> +struct K +{ + template <typename T> + static void + f13 (const T &x, const T &y) + { + _Cilk_for (T i = x; i <= y + N; i += N) + baz (i); +#if HAVE_IO + for (T i = x; i < y+N; i += N) { + printf("Result[%4d] = %2d\n", *i, results[*i]); + fflush (stdout); + } +#endif + } +}; + +#define check(expr) \ + for (int i = 0; i < 2000; i++) \ + if (expr) \ + { \ + if (results[i] != 1) { \ + __builtin_abort (); \ + } \ + results[i] = 0; \ + } \ + else if (results[i]) \ + abort () + +int +main () +{ + int a[2000]; + long b[2000]; + for (int i = 0; i < 2000; i++) + { + a[i] = i; + b[i] = i; + } + f1 (&a[10], &a[1990]); + check (i >= 10 && i <= 1990 && (i - 10) % 6 == 0); + f2 (&a[0], &a[1999]); + check (i < 1998 && (i & 1) == 0); + f3<int> (&a[20], &a[1837]); + check (i >= 20 && i <= 1837); + f4<int> (&a[0], &a[30]); + check (i > 40 && i <= 2000 - 64); + + f5 (&a[0], &a[100]); + check (i >= 116 && i <= 2000 - 64 && (i - 116) % 10 == 0); + f6<-10> (&a[10], &a[110]); + check (i >= 116 && i <= 2000 - 64 && (i - 116) % 10 == 0); + + f7<6> (I<int> (), &a[12], &a[1800]); + check (i >= 2 && i <= 1808 && (i - 2) % 6 == 0); + + f8<121> (J<int> (&a[14], &a[1803])); + check (i >= 14 && i <= 1924 && (i & 1) == 0); + f9<int, 7> (&a[33], &a[1967]); + check (i >= 33 && i <= 1967 && (i - 33) % 7 == 0); + f10<int, -7> (&a[1939], &a[17]); + check (i >= 21 && i <= 1939 && (i - 21) % 7 == 0); + f11<I<int> > (&a[16], &a[1981]); + check (i >= 16 && i <= 1984 && (i - 16) % 3 == 0); + f12<I<int> > (&a[1761], &a[37]); + check (i > 37 && i <= 1761); + K<5>::f13<I<int> > (&a[1], &a[1935]); + check (i >= 1 && i <= 1936 && (i - 1) % 5 == 0); + f9<long, 7> (&b[33], &b[1967]); + check (i >= 33 && i <= 1967 && (i - 33) % 7 == 0); + f10<long, -7> (&b[1939], &b[17]); + check (i >= 21 && i <= 1939 && (i - 21) % 7 == 0); + f11<I<long> > (&b[16], &b[1981]); + check (i >= 16 && i <= 1984 && (i - 16) % 3 == 0); + f12<I<long> > (&b[1761], &b[37]); + check (i > 37 && i <= 1761); + K<5>::f13<I<long> > (&b[1], &b[1935]); + check (i >= 1 && i <= 1936 && (i - 1) % 5 == 0); + return 0; +} diff --git a/gcc/testsuite/g++.dg/cilk-plus/CK/stl_iter.cc b/gcc/testsuite/g++.dg/cilk-plus/CK/stl_iter.cc new file mode 100644 index 0000000000..d68ee7b7e7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cilk-plus/CK/stl_iter.cc @@ -0,0 +1,50 @@ +/* { dg-do run { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-options "-fcilkplus" } */ +/* { dg-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */ + +#include <vector> +#include <cstdio> +#include <iostream> +#include <algorithm> + +using namespace std; + + +int main(void) +{ +vector <int> array; +vector <int> array_serial; + +for (int ii = -1; ii < 10; ii++) +{ + array.push_back(ii); + array_serial.push_back (ii); +} +_Cilk_for (vector<int>::iterator iter = array.begin(); iter != array.end(); + iter++) +{ + if (*iter == 6) + *iter = 13; +} +for (vector<int>::iterator iter = array_serial.begin(); + iter != array_serial.end(); iter++) +{ + if (*iter == 6) + *iter = 13; +} +sort (array.begin(), array.end()); +sort (array_serial.begin(), array_serial.end()); + +vector <int>::iterator iter = array.begin (); +vector <int>::iterator iter_serial = array_serial.begin (); + +while (iter != array.end () && iter_serial != array_serial.end ()) +{ + if (*iter != *iter_serial) + __builtin_abort (); + iter++; + iter_serial++; +} + +return 0; +} diff --git a/gcc/testsuite/g++.dg/cilk-plus/CK/stl_rev_iter.cc b/gcc/testsuite/g++.dg/cilk-plus/CK/stl_rev_iter.cc new file mode 100644 index 0000000000..6eee0d99ed --- /dev/null +++ b/gcc/testsuite/g++.dg/cilk-plus/CK/stl_rev_iter.cc @@ -0,0 +1,68 @@ +/* { dg-do run { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-options "-fcilkplus" } */ +/* { dg-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */ + + +#include <vector> +#include <cstdio> +#include <iostream> +#include <algorithm> + +using namespace std; + + +int main(void) +{ +vector <int> array,array_serial; + +for (int ii = -1; ii < 10; ii++) +{ + array.push_back(ii); + array_serial.push_back(ii); +} +_Cilk_for (vector<int>::reverse_iterator iter4 = array.rbegin(); + iter4 != array.rend(); iter4++) +{ + if (*iter4 == 0x8) { + *iter4 = 9; + } +} + +_Cilk_for (vector<int>::reverse_iterator iter4 = array_serial.rbegin(); + iter4 != array_serial.rend(); iter4++) +{ + if (*iter4 == 0x8) { + *iter4 = 9; + } +} +_Cilk_for (vector<int>::reverse_iterator iter2 = array.rbegin(); + iter2 != array.rend(); + iter2 += 1) +{ + if ((*iter2 == 0x4) || (*iter2 == 0x7)) { + *iter2 = 0x3; + } +} +for (vector<int>::reverse_iterator iter2 = array_serial.rbegin(); + iter2 != array_serial.rend(); + iter2 += 1) +{ + if ((*iter2 == 0x4) || (*iter2 == 0x7)) { + *iter2 = 0x3; + } +} +sort (array.begin(), array.end()); +sort (array_serial.begin(), array_serial.end()); + +vector <int>::iterator iter = array.begin (); +vector <int>::iterator iter_serial = array_serial.begin (); +while (iter != array.end () && iter_serial != array_serial.end ()) +{ + if (*iter != *iter_serial) + __builtin_abort (); + iter++; + iter_serial++; +} + +return 0; +} diff --git a/gcc/testsuite/g++.dg/cilk-plus/CK/stl_test.cc b/gcc/testsuite/g++.dg/cilk-plus/CK/stl_test.cc new file mode 100644 index 0000000000..84518f3434 --- /dev/null +++ b/gcc/testsuite/g++.dg/cilk-plus/CK/stl_test.cc @@ -0,0 +1,50 @@ +/* { dg-do run { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-options "-fcilkplus" } */ +/* { dg-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */ + + +#include <iostream> +#include <cstdio> +#include <cstdlib> +#include <vector> +#include <algorithm> +#include <list> + +using namespace std; + + +int main(int argc, char **argv) +{ + vector <int> number_list, number_list_serial; + int new_number = 0; + int no_elements = 0; + + if (argc != 2) + { + no_elements = 10; + } + + + number_list.clear(); + number_list_serial.clear(); + for (int ii = 0; ii < no_elements; ii++) + { + number_list.push_back(new_number); + number_list_serial.push_back(new_number); + } + + _Cilk_for (int jj = 0; jj < no_elements; jj++) + { + number_list[jj] = jj + no_elements; + } + for (int jj = 0; jj < no_elements; jj++) + { + number_list_serial[jj] = jj + no_elements; + } + + for (int jj = 0; jj < no_elements; jj++) + if (number_list_serial[jj] != number_list[jj]) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp b/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp index 0cb6539cb0..3626a3013d 100644 --- a/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp +++ b/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2014 Free Software Foundation, Inc. +# Copyright (C) 2013-2015 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -26,12 +26,12 @@ if { ![check_effective_target_cilkplus] } { dg-init if [cilkplus_init] { # Run the tests that are shared with C. - g++-dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/PS/*.c]] "" + g++-dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/PS/*.c]] "" "" dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/SE/*.c]] "-O3" " " dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/SE/*.c]] " " " " dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/SE/*.c]] "-g -O2" " " # Run the C++ only tests. - g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] "" + g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] "" "" dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -fcilkplus" " " dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -O1 -fcilkplus" " " diff --git a/gcc/testsuite/g++.dg/cilk-plus/pr60967.C b/gcc/testsuite/g++.dg/cilk-plus/pr60967.C new file mode 100644 index 0000000000..1724424ff0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cilk-plus/pr60967.C @@ -0,0 +1,9 @@ +// PR c++/60967 +// { dg-require-effective-target c++11 } +// { dg-options "-fcilkplus" } + +int container[] = {}; +template <class foo> +void bar() { + for (int &v : container) { } +} diff --git a/gcc/testsuite/g++.dg/compat/break/README b/gcc/testsuite/g++.dg/compat/break/README index adbaf4fced..ba07de4248 100644 --- a/gcc/testsuite/g++.dg/compat/break/README +++ b/gcc/testsuite/g++.dg/compat/break/README @@ -11,7 +11,7 @@ ABI-compliant should also be covered by a test for -Wabi to ensure that there is a warning for the construct. -Copyright (C) 2002-2014 Free Software Foundation, Inc. +Copyright (C) 2002-2015 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright diff --git a/gcc/testsuite/g++.dg/compat/compat.exp b/gcc/testsuite/g++.dg/compat/compat.exp index 1a7cdb8396..12722890c7 100644 --- a/gcc/testsuite/g++.dg/compat/compat.exp +++ b/gcc/testsuite/g++.dg/compat/compat.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2014 Free Software Foundation, Inc. +# Copyright (C) 2002-2015 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -55,6 +55,7 @@ proc compat-use-alt-compiler { } { set ALWAYS_CXXFLAGS "" set ld_library_path $alt_ld_library_path set_ld_library_path_env_vars + restore_gcc_exec_prefix_env_var } } diff --git a/gcc/testsuite/g++.dg/compat/struct-layout-1.exp b/gcc/testsuite/g++.dg/compat/struct-layout-1.exp index 4c7d4c43fd..7777d98a3c 100644 --- a/gcc/testsuite/g++.dg/compat/struct-layout-1.exp +++ b/gcc/testsuite/g++.dg/compat/struct-layout-1.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2014 Free Software Foundation, Inc. +# Copyright (C) 2002-2015 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -60,6 +60,7 @@ proc compat-use-alt-compiler { } { set ALWAYS_CXXFLAGS "" set ld_library_path $alt_ld_library_path set_ld_library_path_env_vars + restore_gcc_exec_prefix_env_var } } diff --git a/gcc/testsuite/g++.dg/conversion/ambig1.C b/gcc/testsuite/g++.dg/conversion/ambig1.C index 85ea1d25f9..1db1667073 100644 --- a/gcc/testsuite/g++.dg/conversion/ambig1.C +++ b/gcc/testsuite/g++.dg/conversion/ambig1.C @@ -6,4 +6,3 @@ struct H { }; int const& ref = H(); // { dg-error "ambiguous" } -// { dg-message "candidate" "candidate note" { target *-*-* } 8 } diff --git a/gcc/testsuite/g++.dg/conversion/err-recover1.C b/gcc/testsuite/g++.dg/conversion/err-recover1.C index 97237893dc..4773b1faeb 100644 --- a/gcc/testsuite/g++.dg/conversion/err-recover1.C +++ b/gcc/testsuite/g++.dg/conversion/err-recover1.C @@ -1,6 +1,6 @@ // PR c++/42219 -void foo(const void); // { dg-error "incomplete|const" } +void foo(const void); // { dg-error "invalid use of cv-qualified" } void bar() { diff --git a/gcc/testsuite/g++.dg/conversion/op1.C b/gcc/testsuite/g++.dg/conversion/op1.C index e0a3e5f46e..dd7ac2f9ce 100644 --- a/gcc/testsuite/g++.dg/conversion/op1.C +++ b/gcc/testsuite/g++.dg/conversion/op1.C @@ -7,5 +7,4 @@ class C int fn (C c) { return C::operator float(c); // { dg-error "operator float.C" } - // { dg-message "candidate" "candidate note" { target *-*-* } 9 } } diff --git a/gcc/testsuite/g++.dg/conversion/op4.C b/gcc/testsuite/g++.dg/conversion/op4.C index 7ef4b6a0c6..cb99a380b4 100644 --- a/gcc/testsuite/g++.dg/conversion/op4.C +++ b/gcc/testsuite/g++.dg/conversion/op4.C @@ -9,11 +9,11 @@ struct X { } }; -void add_one (X & ref) { /* { dg-message "in passing argument" } */ +void add_one (X & ref) { /* { dg-message "argument" } */ ++ ref.x; } void foo() { X const a (2); - add_one(a); /* { dg-error "invalid initialization of reference of type" } */ + add_one(a); /* { dg-error "discards qualifiers" } */ } diff --git a/gcc/testsuite/g++.dg/conversion/op5.C b/gcc/testsuite/g++.dg/conversion/op5.C index 69ef996d5c..0aad9259bf 100644 --- a/gcc/testsuite/g++.dg/conversion/op5.C +++ b/gcc/testsuite/g++.dg/conversion/op5.C @@ -15,6 +15,6 @@ struct B void foo (const B& b) { - const A a = b; // { dg-error "conversion from 'const B' to non-scalar type 'const A' requested" } + const A a = b; // { dg-error "const B" } } diff --git a/gcc/testsuite/g++.dg/conversion/reinterpret1.C b/gcc/testsuite/g++.dg/conversion/reinterpret1.C index aa55f6f4cf..d4567822e2 100644 --- a/gcc/testsuite/g++.dg/conversion/reinterpret1.C +++ b/gcc/testsuite/g++.dg/conversion/reinterpret1.C @@ -3,4 +3,4 @@ struct Y { Y(int &); }; int v; -Y y1(reinterpret_cast<int>(v)); +Y y1(reinterpret_cast<int>(v)); // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/conversion/simd1.C b/gcc/testsuite/g++.dg/conversion/simd1.C index 522d8b5470..7955f68c1a 100644 --- a/gcc/testsuite/g++.dg/conversion/simd1.C +++ b/gcc/testsuite/g++.dg/conversion/simd1.C @@ -18,7 +18,6 @@ extern const vector signed short *cvssp; void foo () { vss = vld(i, vscp); /* { dg-error "no matching function for call" } */ - // { dg-message "candidate" "candidate note" { target *-*-* } 20 } vss = vld(i, vssp); vss = vld(i, cvssp); } diff --git a/gcc/testsuite/g++.dg/cpp/pr23827_cxx11.C b/gcc/testsuite/g++.dg/cpp/pr23827_cxx11.C new file mode 100644 index 0000000000..c1862ceda2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp/pr23827_cxx11.C @@ -0,0 +1,23 @@ +// { dg-do run { target c++11 } } +// { dg-options "-pedantic-errors" } + +#define f ( +#define l ) +#define str(x) #x +#define xstr(x) str(x) + +// C90 and C++98: "0x1p+( 0x1p+)" +// C99 and C++11: "0x1p+f 0x1p+l" +const char *s = xstr(0x1p+f 0x1p+l); + +extern "C" void abort (void); +extern "C" int strcmp (const char *, const char *); + +int +main() +{ + if (strcmp (s, "0x1p+( 0x1p+)")) + return 0; // Correct C99 and C++11 behavior. + else + abort (); // Correct C90 and C++ behavior. +} diff --git a/gcc/testsuite/g++.dg/cpp/pr23827_cxx98.C b/gcc/testsuite/g++.dg/cpp/pr23827_cxx98.C new file mode 100644 index 0000000000..cd4ee22e50 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp/pr23827_cxx98.C @@ -0,0 +1,23 @@ +// { dg-do run { target c++98_only } } +// { dg-options "-ansi -pedantic-errors" } + +#define f ( +#define l ) +#define str(x) #x +#define xstr(x) str(x) + +// C90 and C++98: "0x1p+( 0x1p+)" +// C99 and C++11: "0x1p+f 0x1p+l" +const char *s = xstr(0x1p+f 0x1p+l); + +extern "C" void abort (void); +extern "C" int strcmp (const char *, const char *); + +int +main() +{ + if (strcmp (s, "0x1p+( 0x1p+)")) + abort (); // Correct C99 and C++11 behavior. + else + return 0; // Correct C90 and C++ behavior. +} diff --git a/gcc/testsuite/g++.dg/cpp/pr23827_cxx98_neg.C b/gcc/testsuite/g++.dg/cpp/pr23827_cxx98_neg.C new file mode 100644 index 0000000000..39d9fe4d1e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp/pr23827_cxx98_neg.C @@ -0,0 +1,4 @@ +// { dg-do compile { target c++98_only } } +/* { dg-options "-ansi -pedantic-errors" } */ + +double x = 0x3.1415babep0; // { dg-error "use of C..11 hexadecimal floating constant" } diff --git a/gcc/testsuite/g++.dg/cpp/pr64127.C b/gcc/testsuite/g++.dg/cpp/pr64127.C new file mode 100644 index 0000000000..29c3bf2662 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp/pr64127.C @@ -0,0 +1,4 @@ +/* { dg-do compile { target c++98_only } } */ + +template <0> int __copy_streambufs_eof; // { dg-error "expected identifier|numeric constant|variable templates" } +__copy_streambufs_eof < // { dg-error "template argument|parse error|not name a type" } diff --git a/gcc/testsuite/g++.dg/cpp/ucn-1.C b/gcc/testsuite/g++.dg/cpp/ucn-1.C index b2d4f98fa0..880e899e9e 100644 --- a/gcc/testsuite/g++.dg/cpp/ucn-1.C +++ b/gcc/testsuite/g++.dg/cpp/ucn-1.C @@ -1,6 +1,6 @@ // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2170.html // { dg-do compile { target c++11 } } -// { dg-options "-fextended-identifiers" } +// { dg-options "" } int main() { diff --git a/gcc/testsuite/g++.dg/cpp/ucnid-1.C b/gcc/testsuite/g++.dg/cpp/ucnid-1.C index 7a8f72a5dc..65c8995baa 100644 --- a/gcc/testsuite/g++.dg/cpp/ucnid-1.C +++ b/gcc/testsuite/g++.dg/cpp/ucnid-1.C @@ -1,5 +1,5 @@ /* { dg-do preprocess } */ -/* { dg-options "-std=gnu++98 -pedantic -fextended-identifiers" } */ +/* { dg-options "-std=gnu++98 -pedantic" } */ \u00AA /* { dg-error "not valid in an identifier" } */ \u00AB /* { dg-error "not valid in an identifier" } */ diff --git a/gcc/testsuite/g++.dg/cpp/ucnid-2.C b/gcc/testsuite/g++.dg/cpp/ucnid-2.C new file mode 100644 index 0000000000..2ffb3c97b1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp/ucnid-2.C @@ -0,0 +1,17 @@ +/* Test stringization of identifiers with UCNs preserves spelling. */ +/* { dg-do run } */ + +#include <stdlib.h> +#include <string.h> + +#define h(s) #s +#define str(s) h(s) + +int +main () +{ + if (strcmp (str (str (\u00c1)), "\"\\u00c1\"")) + abort (); + if (strcmp (str (str (\u00C1)), "\"\\u00C1\"")) + abort (); +} diff --git a/gcc/testsuite/g++.dg/cpp/ucnid-3.C b/gcc/testsuite/g++.dg/cpp/ucnid-3.C new file mode 100644 index 0000000000..0db9aaaf71 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp/ucnid-3.C @@ -0,0 +1,16 @@ +/* Test pasting of identifiers with UCNs preserves spelling. */ +/* { dg-do run } */ + +#include <stdlib.h> +#include <string.h> + +#define c(s1, s2) s1 ## s2 +#define h(s) #s +#define str(s) h(s) + +int +main () +{ + if (strcmp (str (str (c (\u00c1, \u00C1))), "\"\\u00c1\\u00C1\"")) + abort (); +} diff --git a/gcc/testsuite/g++.dg/cpp/utf16-pr41698-1.C b/gcc/testsuite/g++.dg/cpp/utf16-pr41698-1.C new file mode 100644 index 0000000000..e60f25b52a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp/utf16-pr41698-1.C @@ -0,0 +1,15 @@ +// PR 41698: off-by-one error in UTF-16 encoding. + +// { dg-do run { target c++11 } } + +extern "C" void abort (void); +extern "C" void exit (int); + +int +main () +{ + char16_t s[] = u"\uffff"; + if (sizeof s != 2 * sizeof (char16_t) || s[0] != 0xffff || s[1] != 0) + abort (); + exit (0); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/Wattributes1.C b/gcc/testsuite/g++.dg/cpp0x/Wattributes1.C new file mode 100644 index 0000000000..d81885152c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/Wattributes1.C @@ -0,0 +1,8 @@ +// PR c++/60373 +// { dg-do compile { target c++11 } } +// { dg-require-visibility "" } + +#include <new> +__attribute__((visibility("hidden")))void*operator new(std::size_t); // { dg-warning "visibility attribute ignored" } + +// { dg-message "previous declaration" "" { target *-*-* } 111 } diff --git a/gcc/testsuite/g++.dg/cpp0x/Wdtor1.C b/gcc/testsuite/g++.dg/cpp0x/Wdtor1.C new file mode 100644 index 0000000000..e376017deb --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/Wdtor1.C @@ -0,0 +1,13 @@ +// PR c++/62232 +// { dg-do compile { target c++11 } } +// { dg-options "-Wnon-virtual-dtor" } + +class base +{ +protected: + ~base () {} + virtual void foo (){}; +}; +class derive final : public base +{ +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/Wnarrowing1.C b/gcc/testsuite/g++.dg/cpp0x/Wnarrowing1.C new file mode 100644 index 0000000000..4df3025547 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/Wnarrowing1.C @@ -0,0 +1,18 @@ +// PR c++/53159 +// { dg-do compile { target c++11 } } +// { dg-options "-Wnarrowing -Wno-overflow" } + +struct X +{ + constexpr operator int() { return __INT_MAX__; } +}; + +int f() { return __INT_MAX__; } + +signed char a { __INT_MAX__ }; // { dg-error "narrowing conversion" } +signed char b { f() }; // { dg-warning "narrowing conversion" } +signed char c { X{} }; // { dg-error "narrowing conversion" } + +signed char ar[] { __INT_MAX__ }; // { dg-error "narrowing conversion" } +signed char br[] { f() }; // { dg-warning "narrowing conversion" } +signed char cr[] { X{} }; // { dg-error "narrowing conversion" } diff --git a/gcc/testsuite/g++.dg/cpp0x/aggr1.C b/gcc/testsuite/g++.dg/cpp0x/aggr1.C new file mode 100644 index 0000000000..0e408e6c68 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/aggr1.C @@ -0,0 +1,16 @@ +// PR c++/49132 +// { dg-do compile { target c++11 } } + +struct A { + const int m; +}; + +A a1 = {}; +A a2{}; + +struct B { + A a; +}; + +B b1 = {}; +B b2{}; diff --git a/gcc/testsuite/g++.dg/cpp0x/aggr2.C b/gcc/testsuite/g++.dg/cpp0x/aggr2.C new file mode 100644 index 0000000000..26e9dd05b6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/aggr2.C @@ -0,0 +1,16 @@ +// PR c++/49132 +// { dg-do compile { target c++11 } } + +struct A { + int& m; +}; + +A a1 = {}; // { dg-error "uninitialized reference" } +A a2{}; // { dg-error "uninitialized reference" } + +struct B { + A a; +}; + +B b1 = {}; // { dg-error "uninitialized reference" } +B b2{}; // { dg-error "uninitialized reference" } diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-2.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-2.C index 0204f6454f..cf59a55eea 100644 --- a/gcc/testsuite/g++.dg/cpp0x/alias-decl-2.C +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-2.C @@ -22,7 +22,7 @@ template<class T> using Vec = Vector<T, Alloc<T> >; template<class T> void g(Vector<T, Alloc<T> >); -template<template<class T> class TT> void h(TT<int>); // { dg-error "provided for" } +template<template<class T> class TT> void h(TT<int>); // { dg-message "provided for" } void bar() diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-4.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-4.C index 60edaf7e53..1232e19a60 100644 --- a/gcc/testsuite/g++.dg/cpp0x/alias-decl-4.C +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-4.C @@ -11,4 +11,4 @@ template <class T> using B = typename A<T>::U; // { dg-error "type" } template <class T> struct A { typedef B<T> U; }; -B<short> b; // { dg-error "invalid type" } +B<short> b; diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-42.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-42.C new file mode 100644 index 0000000000..09a75e45a3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-42.C @@ -0,0 +1,18 @@ +// PR c++/59200 +// { dg-do compile { target c++11 } } + +struct A +{ + static constexpr bool value = true; +}; + +template<typename T> +struct B +{ + template<typename U> + using C = A; +}; + +template<typename T> +template<typename U> + const bool B<T>::C<U>::value; // { dg-error "too many" } diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-43.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-43.C new file mode 100644 index 0000000000..02eb33643a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-43.C @@ -0,0 +1,4 @@ +// PR c++/59120 +// { dg-do compile { target c++11 } } + +template<typename T> using X = int T::T*; // { dg-error "expected" } diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-44.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-44.C new file mode 100644 index 0000000000..bd20b54f14 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-44.C @@ -0,0 +1,43 @@ +// PR c++/63849 +// { dg-do compile { target c++11 } } + +template <class _T, class...> +using First = _T; // we should not use this + // alias with only + // one pack parameter (?) + +template <template <class...> class _Successor, + int, + class... _Xs> +struct Overlay +{ + using O = _Successor<_Xs...>; +}; + +template <class... _Pack> +struct List +{ + template <int _s> + using O = typename Overlay<List, _s, _Pack...>::O; + + template <template <class...> class _S> + using Pass = _S<_Pack...>; + + template <int _i> + using At = typename O<_i> + ::template Pass<First>; +}; + +template <int _i> +using At = typename List<int, char> +::template At<_i>; + +template <int _i> +void func_crash(At<_i>&) {} + +int main(int argc, char *argv[]) +{ + char ccc; + int iii; + func_crash<0>(iii); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-45.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-45.C new file mode 100644 index 0000000000..e3434f51a3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-45.C @@ -0,0 +1,24 @@ +// PR c++/61198 +// { dg-do compile { target c++11 } } + +template<int herp, typename derp_t> +struct broken +{ + template<typename target_t> + using rebind = broken<herp, target_t>; +}; + +template<typename derp_t> +struct broken<2, derp_t> +{ + template<typename target_t> + using rebind = broken<2, target_t>; +}; + +int main(int argc, char **argv) +{ + broken<2, float>::rebind<double> u; + + return 0; +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-46.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-46.C new file mode 100644 index 0000000000..19595ea3cf --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-46.C @@ -0,0 +1,114 @@ +// PR c++/62134 +// { dg-do compile { target c++11 } } + +template<typename... T> struct tuple; +template<__SIZE_TYPE__, typename U> struct tuple_element; + +template<bool, typename T = void> struct enable_if { }; +template<typename T> struct enable_if<true, T> { typedef T type; }; + +template <int V> struct int_t { static constexpr int value = V; }; +template <int V> int constexpr int_t<V>::value; + +template <class A, class Val, int i=0> +struct Index +{ + static int const value = -1; +}; + +template <class ... A, class Val, int i> +struct Index<tuple<Val, A ...>, Val, i> +{ + static int const value = i; +}; + +template <class A0, class ... A, class Val, int i> +struct Index<tuple<A0, A ...>, Val, i> +{ + static int const value = Index<tuple<A ...>, Val, i+1>::value; +}; + +template <class C, class R> struct PermutationSign; + +template <int w, class C, class R> +struct PermutationSignIfFound +{ + static int const value = 0; +}; + +template <class C, class R> +struct PermutationSignIfFound<-1, C, R> +{ + static int const value = 0; +}; + +template <> +struct PermutationSign<tuple<>, tuple<>> +{ + static int const value = 1; +}; + +template <class C> +struct PermutationSign<C, tuple<>> +{ + static int const value = 0; +}; + +template <class R> +struct PermutationSign<tuple<>, R> +{ + static int const value = 0; +}; + +template <class C, class Org> +struct PermutationSign +{ + static int const value + = PermutationSignIfFound + <Index<C, typename tuple_element<0, Org>::type>::value, + C, Org>::value; +}; + +template <class A, template <class> class Pred, int i=0, class Enable=void> +struct IndexIf +{ + static int const value = -1; + using type = tuple<>; +}; + +template <class A0, class ... A, template <class> class Pred, int i> +struct IndexIf<tuple<A0, A ...>, Pred, i, + typename enable_if<Pred<A0>::value>::type> +{ + using type = A0; + static int const value = i; +}; + +template <class A0, class ... A, template <class> class Pred, int i> +struct IndexIf<tuple<A0, A ...>, Pred, i, + typename enable_if<!Pred<A0>::value>::type> +{ + using next = IndexIf<tuple<A ...>, Pred, i+1>; + using type = typename next::type; + static int const value = next::value; +}; + +template <class P> +struct MatchPermutationP +{ + template <class A> using type = PermutationSign<P, A>; +}; + +template <class P, class Plist> struct FindCombination +{ + using type = IndexIf<Plist, MatchPermutationP<P>::template type>; + static int const where = type::value; + static int const sign + = (where>=0) ? PermutationSign<P, typename type::type>::value : 0; +}; + +int main() +{ + using finder = FindCombination<tuple<>, tuple<tuple<>>>; + static_assert(finder::where==0 && finder::sign==+1, "bad"); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-47.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-47.C new file mode 100644 index 0000000000..71611db42c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-47.C @@ -0,0 +1,13 @@ +// PR c++/65333 +// { dg-do compile { target c++11 } } + +template <typename T, T... Values> struct A +{ + using type = int; + template <type... Suffix> using array = A<type, Values..., Suffix...>; + void + m_fn1 () + { + array<>::data; + } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-dr1558.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-dr1558.C new file mode 100644 index 0000000000..2bbb138ec2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-dr1558.C @@ -0,0 +1,14 @@ +// DR 1558 still applies when using void_t as a template-argument. +// { dg-do compile { target c++11 } } + +template<typename...> using void_t = void; +template<class T> struct A { }; +struct B { typedef int foo; }; +template<typename T> A<void_t<typename T::foo>> f(); // { dg-error "int" } +template<typename T> A<void> g(); +int main() +{ + f<B>(); + g<int>(); + f<int>(); // { dg-error "no match" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/auto3.C b/gcc/testsuite/g++.dg/cpp0x/auto3.C index c2e5519ecf..5bfed1be3c 100644 --- a/gcc/testsuite/g++.dg/cpp0x/auto3.C +++ b/gcc/testsuite/g++.dg/cpp0x/auto3.C @@ -19,7 +19,7 @@ A<int> A1; // CWG issue 625 A<auto> A2 = A1; // { dg-error "" } -auto foo() { } // { dg-error "auto" "" { target { ! c++1y } } } +auto foo() { } // { dg-error "auto" "" { target { ! c++14 } } } void bar(auto i) // { dg-error "incomplete|auto" } { diff --git a/gcc/testsuite/g++.dg/cpp0x/auto41.C b/gcc/testsuite/g++.dg/cpp0x/auto41.C index b2a77550fd..b1551e2e58 100644 --- a/gcc/testsuite/g++.dg/cpp0x/auto41.C +++ b/gcc/testsuite/g++.dg/cpp0x/auto41.C @@ -1,5 +1,5 @@ // PR c++/58550 // { dg-do compile { target c++11 } } -auto foo(); // { dg-error "auto" "" { target { ! c++1y } } } -auto fp = foo; // { dg-error "auto" "" { target c++1y } } +auto foo(); // { dg-error "auto" "" { target { ! c++14 } } } +auto fp = foo; // { dg-error "auto" "" { target c++14 } } diff --git a/gcc/testsuite/g++.dg/cpp0x/auto43.C b/gcc/testsuite/g++.dg/cpp0x/auto43.C new file mode 100644 index 0000000000..45a827553d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto43.C @@ -0,0 +1,12 @@ +// PR c++/59114 +// { dg-do compile { target c++11 } } + +template<int> struct A +{ + template<typename T> operator T(); +}; + +void foo() +{ + A<0>().operator auto(); // { dg-error "invalid use of .auto" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/auto44.C b/gcc/testsuite/g++.dg/cpp0x/auto44.C new file mode 100644 index 0000000000..687f154a09 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto44.C @@ -0,0 +1,10 @@ +// PR c++/58614 +// { dg-do compile { target c++11 } } + +#include <initializer_list> + +void foo() +{ + i; // { dg-error "not declared" } + auto j = { i }; // { dg-error "unable to deduce" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/auto9.C b/gcc/testsuite/g++.dg/cpp0x/auto9.C index 205bb960cc..0c0f39f02c 100644 --- a/gcc/testsuite/g++.dg/cpp0x/auto9.C +++ b/gcc/testsuite/g++.dg/cpp0x/auto9.C @@ -15,13 +15,13 @@ const std::type_info &t2 = typeid (auto *); // { dg-error "auto" } struct A { - operator auto (); // { dg-error "auto" "" { target { ! c++1y } } } - operator auto *(); // { dg-error "auto" "" { target { ! c++1y } } } + operator auto (); // { dg-error "auto" "" { target { ! c++14 } } } + operator auto *(); // { dg-error "auto" "" { target { ! c++14 } } } }; struct A2 { - operator auto () -> int; // { dg-error "invalid use of" "" { target { ! c++1y } } } + operator auto () -> int; // { dg-error "invalid use of" "" { target { ! c++14 } } } operator auto *() -> int; // { dg-error "auto" } }; @@ -98,8 +98,8 @@ baz (int i, ...) template <typename T = auto> struct E {}; // { dg-error "invalid use of" } template <class T = auto *> struct F {}; // { dg-error "invalid use of|expected" } -auto fnlate () -> auto; // { dg-error "invalid use of" "" { target { ! c++1y } } } -auto fnlate2 () -> auto *; // { dg-error "invalid use of|expected" "" { target { ! c++1y } } } +auto fnlate () -> auto; // { dg-error "invalid use of" "" { target { ! c++14 } } } +auto fnlate2 () -> auto *; // { dg-error "invalid use of|expected" "" { target { ! c++14 } } } void badthrow () throw (auto) // { dg-error "invalid use of" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-48089.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-48089.C index 88d442691c..31010ed235 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-48089.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-48089.C @@ -10,18 +10,18 @@ // R() is well-formed because i is initialized before j. struct s { - constexpr s() : v(v) { } // { dg-message "" } + constexpr s() : v(v) { } int v; }; -constexpr s bang; // { dg-message "" } +constexpr s bang; // { dg-error "" } struct R { int i,j; - constexpr R() : i(42),j(i) { } // { dg-bogus "" "" { xfail *-*-* } } + constexpr R() : i(42),j(i) { } // { dg-bogus "" } }; -constexpr R r; // { dg-bogus "" "" { xfail *-*-* } } +constexpr R r; // { dg-bogus "" } // Ill-formed (no diagnostic required) struct T { @@ -41,10 +41,10 @@ struct U { constexpr int f(int _i) { return _i; } constexpr int g() { return i; } constexpr U(): i(0), j(0) { } - constexpr U(const U& t) : i(f(t.i)),j(0) { } // { dg-bogus "" "" { xfail *-*-* } } - constexpr U(int _i) : i(_i),j(g()) { } // { dg-bogus "" "" { xfail *-*-* } } + constexpr U(const U& t) : i(f(t.i)),j(0) { } // { dg-bogus "" } + constexpr U(int _i) : i(_i),j(g()) { } // { dg-bogus "" } }; constexpr U u1; -constexpr U u2(u1); // { dg-bogus "" "" { xfail *-*-* } } -constexpr U u3(1); // { dg-bogus "" "" { xfail *-*-* } } +constexpr U u2(u1); // { dg-bogus "" } +constexpr U u3(1); // { dg-bogus "" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-48324.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-48324.C new file mode 100644 index 0000000000..cef464cf9b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-48324.C @@ -0,0 +1,13 @@ +// PR c++/48324 +// { dg-do compile { target c++11 } } + +struct S { + const int val; + constexpr S(int i) : val(i) { } +}; + +constexpr const int& to_ref(int i) { + return S(i).val; // { dg-warning "reference to temporary" } +} + +constexpr int ary[to_ref(98)] = { }; // { dg-error "not an integral" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-51707.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-51707.C new file mode 100644 index 0000000000..ae02a31c54 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-51707.C @@ -0,0 +1,14 @@ +// PR c++/51707 +// { dg-do compile { target c++11 } } + +struct S { + constexpr S() {} +}; + +struct T { + constexpr T(S const& s) : s{s} {} + S const& s; +}; + +constexpr S s {}; +constexpr T t { s }; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-52282-1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-52282-1.C new file mode 100644 index 0000000000..61797f046d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-52282-1.C @@ -0,0 +1,32 @@ +// PR c++/52282 +// { dg-do compile { target c++11 } } + +template <typename T, T V> +struct A + { + static constexpr T a() { return V; } + }; + +template <typename T, T V> +struct B + { + typedef T type; + static constexpr type b() { return V; } + }; + +template <typename T, T V> +struct C + { + static constexpr decltype(V) c() { return V; } + }; +static_assert(A<int, 10>::a() == 10, "oops"); +static_assert(B<int, 10>::b() == 10, "oops"); +static_assert(C<int, 10>::c() == 10, "oops"); + +struct D + { + static constexpr int d() { return 10; } + }; +static_assert((A<int(*)(), &D::d>::a())() == 10, "oops"); +static_assert((B<int(*)(), &D::d>::b())() == 10, "oops"); +static_assert((C<int(*)(), &D::d>::c())() == 10, "oops"); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-52892-1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-52892-1.C new file mode 100644 index 0000000000..91e1ea72c2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-52892-1.C @@ -0,0 +1,28 @@ +// PR c++/52892 +// { dg-do compile { target c++11 } } + +constexpr __SIZE_TYPE__ fibonacci(__SIZE_TYPE__ val) { + return (val <= 2) ? 1 : fibonacci(val - 1) + fibonacci(val - 2); +} + +template <typename Function> +struct Defer { + constexpr Defer(const Function func_) : func(func_) { } + + const Function func; + + template <typename... Args> + constexpr auto operator () (const Args&... args) -> decltype(func(args...)) { + return func(args...); + } +}; + +template <typename Function> +constexpr Defer<Function> make_deferred(const Function f) { + return Defer<Function>(f); +} + +int main() { + constexpr auto deferred = make_deferred(&fibonacci); + static_assert(deferred(25) == 75025, "Static fibonacci call failed"); // { dg-error "no match for call" "" { target c++14 } } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-52892-2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-52892-2.C new file mode 100644 index 0000000000..d2062cee84 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-52892-2.C @@ -0,0 +1,7 @@ +// PR c++/52892 +// { dg-do compile { target c++11 } } + +constexpr bool is_negative(int x) { return x < 0; } +typedef bool (*Function)(int); +constexpr bool check(int x, Function p) { return p(x); } +static_assert(check(-2, is_negative), "Error"); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-54002.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-54002.C new file mode 100644 index 0000000000..125a18d8e9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-54002.C @@ -0,0 +1,7 @@ +// PR c++/54002 +// { dg-do compile { target c++11 } } + +class C1 { + constexpr static int foo(int x) { return x + 1; } + constexpr static int bar = foo(sizeof(int)); // { dg-error "constant expression" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-55942.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-55942.C new file mode 100644 index 0000000000..81f2f34ff4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-55942.C @@ -0,0 +1,11 @@ +// PR c++/55942 +// { dg-do compile { target c++11 } } + +struct A +{ + constexpr explicit A(bool b) : o{flip(b)} { } + + constexpr bool flip(bool b) { return !b; } + + bool o; +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-56991.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-56991.C new file mode 100644 index 0000000000..a6043bce5c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-56991.C @@ -0,0 +1,11 @@ +// PR c++/56991 +// { dg-do compile { target c++11 } } + +#include <initializer_list> + +constexpr std::initializer_list<int> good1 = { 1, 2, 3 }; +struct foo { int a, b; }; +constexpr foo good2 = { 1, 2 }; + +constexpr std::initializer_list<foo> bad1 = { { 1, 2 }, { 3, 4} }; +constexpr std::initializer_list<foo> bad2 = { good2, good2 }; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-57764.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-57764.C new file mode 100644 index 0000000000..b26f4b5044 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-57764.C @@ -0,0 +1,11 @@ +// PR c++/57764 +// { dg-do compile { target c++11 } } + +constexpr int x = 42; + +struct S +{ + static constexpr int const & y = x; +}; + +constexpr int const & S::y; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-59686.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-59686.C new file mode 100644 index 0000000000..8936214562 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-59686.C @@ -0,0 +1,9 @@ +// PR c++/59686 +// { dg-do compile { target c++11 } } + +int main() +{ + static const int x = 5; + const int * const y = &x; + static_assert(y, ""); // { dg-error "non-constant|value" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-59937-1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-59937-1.C new file mode 100644 index 0000000000..d9fbd33c94 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-59937-1.C @@ -0,0 +1,5 @@ +// PR c++/59937 +// { dg-do compile { target c++11 } } + +constexpr const char * const &r = ""; +constexpr const char * const &s = r; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-59937-2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-59937-2.C new file mode 100644 index 0000000000..e67d9467a4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-59937-2.C @@ -0,0 +1,12 @@ +// PR c++/59937 +// { dg-do compile { target c++11 } } + +template<typename T> constexpr bool truth(const T&) { return true; } + +template<typename T> +void test() +{ + int i[1]; + constexpr bool untrue = !truth(i); + static_assert(!untrue, ""); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-59938.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-59938.C new file mode 100644 index 0000000000..560071c69f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-59938.C @@ -0,0 +1,5 @@ +// PR c++/59938 +// { dg-do compile { target c++11 } } + +struct Data { const char* const& name; }; +constexpr Data d = { "" }; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-60199.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-60199.C new file mode 100644 index 0000000000..20dd946c4c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-60199.C @@ -0,0 +1,11 @@ +// PR c++/60199 +// { dg-do compile { target c++11 } } + +void f() {} + +static constexpr void (*g1)() = &f; +static constexpr void (*g2)() = f; +struct S { + static constexpr void (*g3)() = &f; + static constexpr void (*g4)() = f; +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-60245.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-60245.C new file mode 100644 index 0000000000..803a229967 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-60245.C @@ -0,0 +1,8 @@ +// PR c++/60245 +// { dg-do compile { target c++11 } } + +constexpr int Apply(const int in, int (*f)(const int&)) { return f(in); } + +using Foo = int; +static constexpr int id(const Foo& i) { return i; } +static constexpr int results1 = Apply(0, &id); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-60432.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-60432.C new file mode 100644 index 0000000000..37d78d31a3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-60432.C @@ -0,0 +1,8 @@ +// PR c++/60432 +// { dg-do compile { target c++11 } } + +struct A +{ + int a; + static constexpr int A::*p = &A::a; +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-61484.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-61484.C new file mode 100644 index 0000000000..2232beb105 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-61484.C @@ -0,0 +1,10 @@ +// PR c++/61484 +// { dg-do compile { target c++11 } } + +struct S { + constexpr S() { } +}; + +constexpr S s[][1] = { + { S() } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-63265.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-63265.C new file mode 100644 index 0000000000..aa0ce5e7ce --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-63265.C @@ -0,0 +1,19 @@ +// PR c++/63265 +// { dg-do compile { target c++11 } } + +#define LSHIFT (sizeof(unsigned int) * __CHAR_BIT__) + +template <int lshift> +struct SpuriouslyWarns1 { + static constexpr unsigned int v = lshift < LSHIFT ? 1U << lshift : 0; +}; + +static_assert(SpuriouslyWarns1<LSHIFT>::v == 0, "Impossible occurred"); + +template <int lshift> +struct SpuriouslyWarns2 { + static constexpr bool okay = lshift < LSHIFT; + static constexpr unsigned int v = okay ? 1U << lshift : 0; +}; + +static_assert(SpuriouslyWarns2<LSHIFT>::v == 0, "Impossible occurred"); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-64462.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-64462.C new file mode 100644 index 0000000000..69193fd0db --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-64462.C @@ -0,0 +1,10 @@ +// PR c++/64462 +// { dg-do compile { target c++11 } } + +int x = 0; +int z; + +int main() { + constexpr int& y = x; + [=] { z = y; }(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-65080.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-65080.C new file mode 100644 index 0000000000..d4b49482bb --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-65080.C @@ -0,0 +1,18 @@ +// PR c++/65080 +// { dg-do compile { target c++11 } } + +template <typename T> +static constexpr T xxx(){ return T(); } + +template <typename T> +struct foo { + using type = T(*)(); + static constexpr type value[1] = {&xxx<T>}; +}; + +template <typename T> +constexpr typename foo<T>::type foo<T>::value[1]; + +int main() { + constexpr int x = foo<int>::value[0](); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-__func__.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-__func__.C new file mode 100644 index 0000000000..a71ed6c63c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-__func__.C @@ -0,0 +1,6 @@ +// PR c++/55425 +// { dg-do compile { target c++11 } } + +constexpr const char* x() { return __func__; } +constexpr const char* y() { return __FUNCTION__; } +constexpr const char* z() { return __PRETTY_FUNCTION__; } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-abi1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-abi1.C deleted file mode 100644 index 418a202995..0000000000 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-abi1.C +++ /dev/null @@ -1,17 +0,0 @@ -// PR c++/47301 -// { dg-do compile { target c++11 } } -// { dg-options "-fabi-version=1" } - -struct A -{ - constexpr operator int () - { - return 1; - } -}; - -template < int > struct B -{ - static constexpr A a = A(); - int ar[a]; -}; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-array-ptr7.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-array-ptr7.C index 93f9141144..005f5300d6 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-array-ptr7.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-array-ptr7.C @@ -17,4 +17,4 @@ S::foo () constexpr S s = { 0,1,2,3,4,5,6,7,8,9,10 }; #define SA(X) static_assert ((X), #X) -SA(s.foo() == 10); +SA(s.foo() == 10); // { dg-error "discards qualifiers" "" { target c++14 } } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-array10.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-array10.C new file mode 100644 index 0000000000..f7aaa4b943 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-array10.C @@ -0,0 +1,12 @@ +// PR c++/64899 +// { dg-do compile { target c++11 } } + +struct S +{ + int i; + constexpr S (): i(42) {} +}; + +constexpr S sa[2]; +#define SA(X) static_assert((X),#X) +SA(sa[1].i == 42); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-array11.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-array11.C new file mode 100644 index 0000000000..5ecda4d112 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-array11.C @@ -0,0 +1,13 @@ +// PR c++/65513 +// { dg-do compile { target c++11 } } + +template <typename _Tp> struct atomic { + atomic() = default; + atomic(_Tp); +}; + +struct { + atomic<bool> bReadyToFlush; +} + +LogThreadsleLogEntries[10]{}; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-array6.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-array6.C new file mode 100644 index 0000000000..16eacdde44 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-array6.C @@ -0,0 +1,15 @@ +// PR c++/58611 +// { dg-do compile { target c++11 } } + +struct A +{ + int i; + constexpr A() {} // { dg-error "A::i" } +}; + +struct B +{ + A a; +}; + +constexpr B b[] = { {} }; // { dg-error "A::A" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-array8.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-array8.C new file mode 100644 index 0000000000..f4aae4f58d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-array8.C @@ -0,0 +1,22 @@ +// { dg-do run { target c++11 } } + +struct A { int i,j; }; + +struct X { + A a = {1,1}; +}; + +constexpr X table[2][2] = {{ {} }}; + +#define SA(X) static_assert(X,#X) +SA(table[1][1].a.i == 1); + +extern "C" void abort(); + +const int *p = &table[1][1].a.j; + +int main() +{ + if (*p != 1) + abort(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-array9.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-array9.C new file mode 100644 index 0000000000..20ec2559b1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-array9.C @@ -0,0 +1,22 @@ +// { dg-do run { target c++11 } } + +struct A { int i,j; }; + +struct X { + A a = {0,0}; +}; + +constexpr X table[2][2] = {{ {} }}; + +#define SA(X) static_assert(X,#X) +SA(table[1][1].a.i == 0); + +extern "C" void abort(); + +const int *p = &table[1][1].a.j; + +int main() +{ + if (*p != 0) + abort(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-attribute3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-attribute3.C new file mode 100644 index 0000000000..491c2e7a8f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-attribute3.C @@ -0,0 +1,5 @@ +// PR c++/51400 +// { dg-do compile { target c++11 } } + +constexpr int (*f)() __attribute__((noreturn)) = 0; +constexpr int (*g)() __attribute__((const)) = 0; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-compound.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-compound.C index bfe4e13d4a..c23e1483b4 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-compound.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-compound.C @@ -2,8 +2,8 @@ constexpr int f() { - { // { dg-error "" } + { // { dg-error "compound-statement" "" { target { c++11_only } } } return 1; } - { } // { dg-error "" } + { } // { dg-error "compound-statement" "" { target { c++11_only } } } } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-conv1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-conv1.C new file mode 100644 index 0000000000..fd34f23f9e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-conv1.C @@ -0,0 +1,34 @@ +// PR c++/56041 +// { dg-do compile { target c++11 } } + +template< class T, T v > +struct integral_constant +{ + using type = integral_constant<T,v>; + using value_type = T; + static constexpr T value = v; + constexpr operator T ( ) noexcept { return value; } +}; + +using true_type = integral_constant<bool, true>; +using false_type = integral_constant<bool, false>; + +template< bool b, class T = void > struct enable_if { using type = T; }; +template< class T > struct enable_if<false, T> { }; + + +template< class T, + class = typename enable_if< true_type{} // should compile; doesn't + , T>::type + > +T try_it( ) { return T{}; } + +int main( ) +{ + static_assert( true_type{} , "failed test 1!" ); + static_assert( true_type{} , "failed test 2!" ); + static_assert( ! false_type{} , "failed test 3!" ); + static_assert( !! true_type{} , "failed test 4!" ); + + return try_it<int>(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor.C index 659e733cdc..55beda7c49 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor.C @@ -3,5 +3,5 @@ struct A { int i; - constexpr A() { } // { dg-error "uninitialized member .A::i" } + constexpr A() { } // { dg-error "A::i" } }; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor14.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor14.C new file mode 100644 index 0000000000..1730995288 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor14.C @@ -0,0 +1,14 @@ +// { dg-do compile { target c++11 } } + +struct A +{ + void *p; + constexpr A(): p(this) {} +}; + +constexpr A a; +constexpr A b = A(); + +#define SA(X) static_assert ((X), #X) +SA(a.p == &a); +SA(b.p == &b); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor14a.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor14a.C new file mode 100644 index 0000000000..644ae63fe0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor14a.C @@ -0,0 +1,14 @@ +// { dg-do compile { target c++11 } } +// { dg-options "-fno-elide-constructors" } + +struct A +{ + void *p; + constexpr A(): p(this) {} +}; + +constexpr A a; +constexpr A b = A(); // { dg-error "" } + +#define SA(X) static_assert ((X), #X) +SA(a.p == &a); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor15.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor15.C new file mode 100644 index 0000000000..5ad278a6aa --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor15.C @@ -0,0 +1,29 @@ +// PR c++/57694 +// { dg-do compile { target c++11 } } + +class A +{ +private: + int a; + const int* const aptr; + +public: + constexpr A(int _a) : a(_a), aptr(&a) { } +}; + +class Data { } d1; + +class B +{ +private: + Data* dptr1; + +public: + constexpr B(Data* _p) : dptr1(_p) {} +}; + +class Use +{ + static constexpr A a{2}; + static constexpr B b{&d1}; +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor16.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor16.C new file mode 100644 index 0000000000..12aaeebf09 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor16.C @@ -0,0 +1,11 @@ +// PR c++/57820 +// { dg-do compile { target c++11 } } + +struct C +{ + int a = 2; + int b = a + 1; +}; + +C c; +constexpr C d = {}; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor17.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor17.C new file mode 100644 index 0000000000..ed82a14e65 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor17.C @@ -0,0 +1,13 @@ +// PR c++/57820 +// { dg-do compile { target c++11 } } + +struct C +{ + int a = 2; + int b = a + 1; + + constexpr C() {} +}; + +C c; +constexpr C d; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor18.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor18.C new file mode 100644 index 0000000000..fa4ff7cc75 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor18.C @@ -0,0 +1,26 @@ +// PR c++/64994 +// { dg-do compile { target c++11 } } + +class TimeStamp { +public: + constexpr TimeStamp() : mValue() {} + int mValue; +}; + +class A { + class B; + A(bool); +}; +class C { + TimeStamp mFadeBeginTime; +}; +class A::B { +public: + B(int) {} + TimeStamp mPrevEventTime[1]; +}; + +A::A(bool) { + new C; + B(0); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-decltype1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-decltype1.C new file mode 100644 index 0000000000..1ff835036c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-decltype1.C @@ -0,0 +1,99 @@ +// PR c++/52282 +// { dg-do run { target c++11 } } + +template <typename T, T V> +struct W { static constexpr T value() { return V; } }; + +template <typename T, T V> +struct X { typedef T type; static constexpr type value() { return V; } }; + +template <typename T, T V> +struct Y { using type = T; static constexpr type value() { return V; } }; + +template <typename T, T V> +struct Z { static constexpr decltype(V) value() { return V; } }; + +template <typename T, T V> +struct W_ { static constexpr T value = V; }; + +template <typename T, T V> +struct X_ { typedef T type; static constexpr type value = V; }; + +template <typename T, T V> +struct Y_ { using type = T; static constexpr type value = V; }; + +template <typename T, T V> +struct Z_ { static constexpr decltype(V) value = V; }; + + +static_assert(W<int, 10>::value() == 10, "oops"); +static_assert(X<int, 10>::value() == 10, "oops"); +static_assert(Y<int, 10>::value() == 10, "oops"); +static_assert(Z<int, 10>::value() == 10, "oops"); +static_assert(W_<int, 10>::value == 10, "oops"); +static_assert(X_<int, 10>::value == 10, "oops"); +static_assert(Y_<int, 10>::value == 10, "oops"); +static_assert(Z_<int, 10>::value == 10, "oops"); + +extern constexpr int a = 10; +static_assert(*W<const int*, &a>::value() == 10, "oops"); +static_assert(*X<const int*, &a>::value() == 10, "oops"); +static_assert(*Y<const int*, &a>::value() == 10, "oops"); +static_assert(*Z<const int*, &a>::value() == 10, "oops"); // ICE +static_assert(*W_<const int*, &a>::value == 10, "oops"); +static_assert(*X_<const int*, &a>::value == 10, "oops"); +static_assert(*Y_<const int*, &a>::value == 10, "oops"); +static_assert(*Z_<const int*, &a>::value == 10, "oops"); // ICE + +template <int V> constexpr int b() { return V; } +static_assert((W<int(*)(), &b<10>>::value())() == 10, "oops"); +static_assert((X<int(*)(), &b<10>>::value())() == 10, "oops"); // incorrect evaluation +static_assert((Y<int(*)(), &b<10>>::value())() == 10, "oops"); // incorrect evaluation +static_assert((Z<int(*)(), &b<10>>::value())() == 10, "oops"); // ICE +static_assert(W_<int(*)(), &b<10>>::value() == 10, "oops"); +static_assert(X_<int(*)(), &b<10>>::value() == 10, "oops"); +static_assert(Y_<int(*)(), &b<10>>::value() == 10, "oops"); +static_assert(Z_<int(*)(), &b<10>>::value() == 10, "oops"); // ICE + +constexpr struct C { + constexpr int c1() const { return 10; } + static constexpr int c2() { return 10; } +} c; + +static_assert((c.*W<int(C::*)()const, &C::c1>::value())() == 10, "oops"); +static_assert((c.*X<int(C::*)()const, &C::c1>::value())() == 10, "oops"); +static_assert((c.*Y<int(C::*)()const, &C::c1>::value())() == 10, "oops"); +static_assert((c.*Z<int(C::*)()const, &C::c1>::value())() == 10, "oops"); +static_assert((c.*W_<int(C::*)()const, &C::c1>::value)() == 10, "oops"); // incorrect evaluation +static_assert((c.*X_<int(C::*)()const, &C::c1>::value)() == 10, "oops"); // incorrect evaluation +static_assert((c.*Y_<int(C::*)()const, &C::c1>::value)() == 10, "oops"); // incorrect evaluation +static_assert((c.*Z_<int(C::*)()const, &C::c1>::value)() == 10, "oops"); // incorrect evaluation + +static_assert((W<int(*)(), &C::c2>::value())() == 10, "oops"); +static_assert((X<int(*)(), &C::c2>::value())() == 10, "oops"); // incorrect evaluation +static_assert((Y<int(*)(), &C::c2>::value())() == 10, "oops"); // incorrect evaluation +static_assert((Z<int(*)(), &C::c2>::value())() == 10, "oops"); // ICE +static_assert(W_<int(*)(), &C::c2>::value() == 10, "oops"); +static_assert(X_<int(*)(), &C::c2>::value() == 10, "oops"); +static_assert(Y_<int(*)(), &C::c2>::value() == 10, "oops"); +static_assert(Z_<int(*)(), &C::c2>::value() == 10, "oops"); // ICE + + +#include <assert.h> + +template <typename T, T V> +constexpr typename X_<T, V>::type X_<T, V>::value; + +int main() { + C c; + + // correctly evaluates inside method scope + int t1 = X<int(*)(), &b<10>>::value()(); + int t2 = (c.*X_<int(C::*)()const, &C::c1>::value)(); + int t3 = X<int(*)(), &C::c2>::value()(); + + assert(t1 == 10); + assert(t2 == 10); + assert(t3 == 10); + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-diag1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-diag1.C index 34cdb733e5..6b908b6dff 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-diag1.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-diag1.C @@ -5,7 +5,7 @@ template <class T> struct A { T t; - constexpr int f() { return 42; } // { dg-error "enclosing class" } + constexpr int f() const { return 42; } // { dg-error "enclosing class" } }; struct B { B(); operator int(); }; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-diag3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-diag3.C index 2a1897b6bf..580fceb728 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-diag3.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-diag3.C @@ -16,7 +16,7 @@ int main() struct complex // { dg-message "no constexpr constructor" } { complex(double r, double i) : re(r), im(i) { } - constexpr double real() { return re; } // { dg-error "not a literal type" } + constexpr double real() const { return re; } // { dg-error "not a literal type" } double imag() const { return im; } private: diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-diag4.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-diag4.C index 29f574df38..13ca6fa239 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-diag4.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-diag4.C @@ -21,5 +21,5 @@ struct A1 struct B1 { A1 a1; - constexpr B1() {} // { dg-error "uninitialized member" } + constexpr B1() {} // { dg-error "B1::a1" } }; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-diag5.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-diag5.C index c8043e3bdb..708f5f2b3f 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-diag5.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-diag5.C @@ -23,20 +23,20 @@ struct C struct D { - constexpr D() { return;} // { dg-error "does not have empty body" } + constexpr D() { return;} // { dg-error "does not have empty body" "" { target c++11_only } } }; struct D1 { A a; - constexpr D1() { return;} // { dg-error "does not have empty body" } + constexpr D1() { return;} // { dg-error "does not have empty body" "" { target c++11_only } } }; struct D2 { A a; A b; - constexpr D2() { return;} // { dg-error "does not have empty body" } + constexpr D2() { return;} // { dg-error "does not have empty body" "" { target c++11_only } } }; struct D3 @@ -44,5 +44,5 @@ struct D3 A a; A b; A c; - constexpr D3() { return;} // { dg-error "does not have empty body" } + constexpr D3() { return;} // { dg-error "does not have empty body" "" { target c++11_only } } }; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-empty8.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-empty8.C new file mode 100644 index 0000000000..8c1414af55 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-empty8.C @@ -0,0 +1,7 @@ +// PR c++/63924 +// { dg-do compile { target c++11 } } + +struct A { }; +constexpr bool f(A a) { return true; } +template <bool B> constexpr bool g() { return true; } +constexpr bool g(A a) { return g<f(a)>(); } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ex1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ex1.C index e541bf9fbd..c4c052a607 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-ex1.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ex1.C @@ -12,13 +12,13 @@ // 2 defined before first use // NOTE: this is only needed in contexts that require a constant-expression struct S { - constexpr int twice(); - constexpr int t(); // { dg-message "used but never defined" } + constexpr int twice() const; + constexpr int t() const; // { dg-message "used but never defined" } private: static constexpr int val = 7; // constexpr variable }; -constexpr int S::twice() { return val + val; } +constexpr int S::twice() const { return val + val; } constexpr S s = { }; int x1 = s.twice(); // ok int x2 = s.t(); // error: S::t() not defined @@ -44,8 +44,8 @@ const double* p = &x; // the &x forces x into memory // 1 struct complex { constexpr complex(double r, double i) : re(r), im(i) { } - constexpr double real() { return re; } - constexpr double imag() { return im; } + constexpr double real() const { return re; } + constexpr double imag() const { return im; } private: double re; double im; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ex2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ex2.C index 9e99d6da46..34b557ce76 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-ex2.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ex2.C @@ -7,8 +7,8 @@ // p 4 struct A { constexpr A(int i) : val(i) { } - constexpr operator int() { return val; } - constexpr operator long() { return -1; } + constexpr operator int() const { return val; } + constexpr operator long() const { return -1; } private: int val; }; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ex3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ex3.C index 3e2685b1c5..a5893563ee 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-ex3.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ex3.C @@ -6,7 +6,7 @@ struct A { int i; - constexpr A(int _i) { i = _i; } // { dg-error "empty body|uninitialized member" } + constexpr A(int _i) { i = _i; } // { dg-error "empty body|A::i" } }; template <class T> diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ex4.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ex4.C index 7a9086cb7c..43e738842f 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-ex4.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ex4.C @@ -3,7 +3,7 @@ struct A { constexpr A(int) { } - constexpr operator int() { return 1; }; + constexpr operator int() const { return 1; }; }; template <class T> diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-fold1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-fold1.C new file mode 100644 index 0000000000..414a0dacf9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-fold1.C @@ -0,0 +1,65 @@ +// PR c++/65642 +// { dg-do compile { target c++11 } } + +// Check we're able to evaluate these. + +#define SA(X) static_assert((X),#X) + +constexpr char s[] = "abc"; +constexpr int t[] = { 'a', 'b', 'c', '\0' }; + +constexpr char +fn1 (const char *p) +{ + return *(p + 1); +} + +constexpr char +fn2 (const char *p) +{ + return p[1]; +} + +constexpr int +fn3 (const int *p) +{ + return *(p + 1); +} + +constexpr int +fn4 (const int *p) +{ + return p[1]; +} + +constexpr auto c1 = fn1 (&s[0]); +constexpr auto c2 = fn1 (&s[1]); +constexpr auto c3 = fn1 (&s[2]); + +SA (c1 == 'b'); +SA (c2 == 'c'); +SA (c3 == '\0'); + +constexpr auto d1 = fn2 (&s[0]); +constexpr auto d2 = fn2 (&s[1]); +constexpr auto d3 = fn2 (&s[2]); + +SA (d1 == 'b'); +SA (d2 == 'c'); +SA (d3 == '\0'); + +constexpr auto e1 = fn3 (&t[0]); +constexpr auto e2 = fn3 (&t[1]); +constexpr auto e3 = fn3 (&t[2]); + +SA (e1 == 'b'); +SA (e2 == 'c'); +SA (e3 == '\0'); + +constexpr auto f1 = fn4 (&t[0]); +constexpr auto f2 = fn4 (&t[1]); +constexpr auto f3 = fn4 (&t[2]); + +SA (f1 == 'b'); +SA (f2 == 'c'); +SA (f3 == '\0'); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-fold2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-fold2.C new file mode 100644 index 0000000000..98aca2a2ce --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-fold2.C @@ -0,0 +1,30 @@ +// PR c++/65642 +// { dg-do compile { target c++11 } } + +#define SA(X) static_assert((X),#X) + +constexpr char s[] = "abc"; + +constexpr bool +cmp (char const *a, char const *b) +{ + return a == b; +} + +constexpr bool +fn1 (const char *s) +{ + return cmp (s, s + 1); +} + +constexpr bool +fn2 (const char *s) +{ + return cmp (s + 1, s + 1); +} + +constexpr auto c1 = fn1 (&s[0]); +constexpr auto c2 = fn2 (&s[0]); + +SA (!c1); +SA (c2); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-friend.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-friend.C index 55a2329eb5..85dfca4ff1 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-friend.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-friend.C @@ -12,12 +12,14 @@ template <class T> struct C { friend constexpr int f(C) { return 0; } - friend constexpr int g(C, A) { return 0; } // { dg-error "double" } + friend constexpr int g(C, A) { return 0; } constexpr int m(C) { return 0; } - constexpr int m(A) { return 0; } // { dg-error "double" } + constexpr int m(A) { return 0; } }; constexpr int i = f(C<int>()); constexpr int j = C<int>().m(C<int>()); -constexpr int k = C<double>().m(A()); // { dg-error "constexpr" } -constexpr int l = g(C<double>(),A()); // { dg-error "constexpr" } +constexpr int k = C<double>().m(A()); // { dg-error "" } +constexpr int l = g(C<double>(),A()); // { dg-error "" } + +// { dg-prune-output "parameter" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-function2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-function2.C index 8cb32c9ad9..95ee244e56 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-function2.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-function2.C @@ -23,18 +23,18 @@ constexpr int area = squarei(side); // { dg-error "side|argument" } int next(constexpr int x) // { dg-error "parameter" } { return x + 1; } -constexpr void f(int x) // { dg-error "return type .void" } +constexpr void f(int x) // { dg-error "return type .void" "" { target c++11_only } } { /* ... */ } constexpr int prev(int x) -{ return --x; } // { dg-error "--" } +{ return --x; } // { dg-error "--" "" { target c++11_only } } constexpr int g(int x, int n) // error: body not just ‘‘return expr’’ { int r = 1; while (--n > 0) r *= x; return r; -} // { dg-error "not a return-statement" } +} // { dg-error "not a return-statement" "" { target c++11_only } } constexpr int bar(int x, int y) { return x + y + x * y; } // { dg-message "previously" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ice12.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ice12.C index 98f53b14c1..c5483376c3 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-ice12.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ice12.C @@ -3,7 +3,7 @@ struct A { - static constexpr int&& i = 0; // { dg-error "initialization" } + static constexpr int&& i = 0; }; int j = A::i; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-inhctor1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-inhctor1.C new file mode 100644 index 0000000000..ee8757f4dc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-inhctor1.C @@ -0,0 +1,15 @@ +// PR c++/58511 +// { dg-do compile { target c++11 } } + +struct A +{ + constexpr A(int, int = i) {} + static const int i; +}; + +struct B : A +{ + using A::A; // { dg-error "A::i" } +}; + +constexpr B b(0); // { dg-error "B::B" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist.C index 52fc9ea8ca..6b6cf3daca 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist.C @@ -23,11 +23,11 @@ public: template<size_t N> constexpr initializer_list(const E(&array)[N]) : sz(N), start(array) {} - constexpr size_t size() { return sz; } + constexpr size_t size() const { return sz; } - constexpr const E* begin() { return start; } + constexpr const E* begin() const { return start; } - constexpr const E* end() { return start + sz; } + constexpr const E* end() const { return start + sz; } }; template<class E, size_t N> diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-mutable2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-mutable2.C new file mode 100644 index 0000000000..c449c3aabc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-mutable2.C @@ -0,0 +1,10 @@ +// PR c++/58102 +// { dg-do compile { target c++11 } } + +struct S { + mutable int n; + constexpr S() : n() {} +}; + +constexpr S s = {}; +constexpr S s2 = s; // { dg-error "mutable" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-neg1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-neg1.C index fb4c01274d..dfa1d6bf12 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-neg1.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-neg1.C @@ -29,18 +29,18 @@ int next(constexpr int x) { // { dg-error "parameter" } extern constexpr int memsz; // { dg-error "definition" } // error: return type is void -constexpr void f(int x) // { dg-error "void" } +constexpr void f(int x) // { dg-error "void" "" { target c++11_only } } { /* ... */ } // error: use of decrement constexpr int prev(int x) -{ return --x; } // { dg-error "-- x" } +{ return --x; } // { dg-error "-- x" "" { target c++11_only } } // error: body not just return expr constexpr int g(int x, int n) { int r = 1; while (--n > 0) r *= x; return r; -} // { dg-error "body of constexpr function" } +} // { dg-error "body of constexpr function" "" { target c++11_only } } class debug_flag { public: diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-neg3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-neg3.C new file mode 100644 index 0000000000..55bb838a2b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-neg3.C @@ -0,0 +1,15 @@ +// PR c++/58612 +// { dg-do compile { target c++11 } } + +struct A +{ + int foo() const { return 0; } +}; + +template<typename> struct B +{ + A a; + constexpr int bar() { return a.foo(); } // { dg-error "foo" } +}; + +constexpr int i = B<void>().bar(); // { dg-error "bar" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-object1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-object1.C index 41afbe969a..da9e3e4ab3 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-object1.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-object1.C @@ -19,7 +19,7 @@ constexpr A1 a2; // { dg-error "uninitialized const" } const constexpr A1 a3 = A1(); -volatile constexpr A1 a4 = A1(); // { dg-error "both .volatile. and .constexpr. cannot" } +volatile constexpr A1 a4 = A1(); // { dg-bogus "both .volatile. and .constexpr. cannot" } // error: on type declaration constexpr struct pixel diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-object2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-object2.C index d52967a7ed..bd146adb70 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-object2.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-object2.C @@ -3,9 +3,9 @@ constexpr int verysquare(int x) { return x * x; } const double mass = 9.8; -constexpr double energy = mass * verysquare(56.6); // { dg-error "mass" "" { xfail *-*-* } } +constexpr double energy = mass * verysquare(56.6); // { dg-error "mass" } -int arr[(int)mass]; // { dg-error "mass" "" { xfail *-*-* } } +int arr[(int)mass]; // { dg-error "" } float array[verysquare(9)]; // OK -- not C99 VLA diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrcomp1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrcomp1.C new file mode 100644 index 0000000000..2eee1b022e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrcomp1.C @@ -0,0 +1,8 @@ +// PR c++/65509 +// { dg-do compile { target c++11 } } + +const int i1 = 1; +const int i2 = 2; + +#define SA(X) static_assert (X,#X) +SA(&i1 != &i2); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrmem.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrmem.C index c16fb15e7b..a16e5c4591 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrmem.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrmem.C @@ -4,7 +4,7 @@ struct C { // literal type int m; int n; constexpr C(int m) : m(m), n(-m) {} - constexpr bool is_neg() { return m < 0; } + constexpr bool is_neg() const { return m < 0; } }; constexpr bool check1(const C& c, int C:: *pm) { return c.*pm < 0; } // #1 diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrsub.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrsub.C index 18648d92d2..6c7dc302e3 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrsub.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrsub.C @@ -5,7 +5,7 @@ struct array { constexpr array() :x(0) {} - constexpr int const* begin() { return &x; } + constexpr int const* begin() const { return &x; } int x; }; constexpr array aa; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ref4.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ref4.C index ce1ce5235c..be3d48ca6f 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-ref4.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ref4.C @@ -4,8 +4,8 @@ struct S { int s[1]; - constexpr const int &foo (unsigned i) { return (i < 1 ? 0 : throw 1), s[i]; } - constexpr const int &bar (unsigned i) { return i < 1 ? s[i] : (throw 0, s[i]); } + constexpr const int &foo (unsigned i) const { return (i < 1 ? 0 : throw 1), s[i]; } + constexpr const int &bar (unsigned i) const { return i < 1 ? s[i] : (throw 0, s[i]); } }; int diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ref5.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ref5.C new file mode 100644 index 0000000000..230510c4c2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ref5.C @@ -0,0 +1,13 @@ +// PR c++/50473 +// { dg-do compile { target c++11 } } + +constexpr int f() { return 1; } + +template<class T> +struct test +{ + static constexpr const auto& value = f(); + int a[value]; +}; + +test<int> t; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ref6.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ref6.C new file mode 100644 index 0000000000..1cbd651f1e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ref6.C @@ -0,0 +1,6 @@ +// PR c++/60771 +// { dg-do compile { target c++11 } } + +struct A { + static constexpr int const& ref = 5; +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ref7.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ref7.C new file mode 100644 index 0000000000..72c8d089d7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ref7.C @@ -0,0 +1,11 @@ +// PR c++/57654 +// { dg-do compile { target c++11 } } + +int i; + +constexpr int & iref = i; +constexpr int & irefref = iref; + +class A { + static constexpr int & irefref = iref; +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ref8.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ref8.C new file mode 100644 index 0000000000..04de9c7e04 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ref8.C @@ -0,0 +1,61 @@ +// PR c++/63885 +// { dg-do compile { target c++11 } } + +template<class T> struct remove_reference { typedef T type; }; +template<class T> struct remove_reference<T&> { typedef T type; }; +template<class T> struct remove_reference<T&&> { typedef T type; }; + +template<class T> struct is_lvalue_reference { static const bool value = false; }; +template<class T> struct is_lvalue_reference<T&> { static const bool value = true; }; + +template <bool B, class U, class V> struct conditional; +template <class U, class V> struct conditional<true, U, V> { typedef U type; }; +template <class U, class V> struct conditional<false, U, V> { typedef V type; }; + +template<typename _Tp> constexpr _Tp&& +forward(typename remove_reference<_Tp>::type& __t) noexcept +{ return static_cast<_Tp&&>(__t); } + +/////////////////////////////////////////////////////////////////////////////// + +template <typename C> struct member_forward +{ + typedef typename remove_reference <C>::type::type T; + typedef typename conditional + < + is_lvalue_reference <C &&>::value, + T&, + T + >::type type; +}; + +template <typename C> using member_forward_t = typename member_forward <C>::type; + +/////////////////////////////////////////////////////////////////////////////// + +template <int , typename > struct __get; +template < typename T> struct __get <0, T> +{ + constexpr static auto value (T arg) + -> decltype ((forward <member_forward_t <T>> (arg.t))) + { + return forward <member_forward_t <T>> (arg.t); + } +}; + +template <int N, typename T> constexpr auto get (T && arg) + -> decltype (__get <N, T &&>::value (forward <T> (arg))) +{ + return __get <N, T &&>::value (forward <T> (arg)); +} + +/////////////////////////////////////////////////////////////////////////////// + +template <typename T> struct S +{ + typedef T type; + T t; + + template <typename U> constexpr S (U && u) : t (forward <U> (u)) {} +}; +static_assert (get <0> (S <int &&> (1)) == 1, ""); // g++ 4.9 passes, g++ trunk r217559 fails diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-reinterpret1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-reinterpret1.C index 69db98bc77..26c92937f4 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-reinterpret1.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-reinterpret1.C @@ -18,7 +18,7 @@ public: { /* I am surprised this is considered a constexpr */ return *((Inner *)4); - } // { dg-error "reinterpret_cast" } + } // { dg-error "reinterpret_cast" "" { xfail *-*-* } } }; B B::instance; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-rom.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-rom.C index 697203d729..80a571aeb4 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-rom.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-rom.C @@ -1,6 +1,6 @@ // PR c++/49673: check that test_data goes into .rodata // { dg-do compile { target c++11 } } -// { dg-additional-options -G0 { target { { alpha*-*-* frv*-*-* ia64-*-* lm32*-*-* m32r*-*-* microblaze*-*-* mips*-*-* nios2-*-* powerpc*-*-* rs6000*-*-* score*-*-* } && { ! { *-*-darwin* *-*-aix* alpha*-*-*vms* } } } } } +// { dg-additional-options -G0 { target { { alpha*-*-* frv*-*-* ia64-*-* lm32*-*-* m32r*-*-* microblaze*-*-* mips*-*-* nios2-*-* powerpc*-*-* rs6000*-*-* } && { ! { *-*-darwin* *-*-aix* alpha*-*-*vms* } } } } } // { dg-final { scan-assembler "\\.rdata" { target mips*-*-* } } } // { dg-final { scan-assembler "rodata" { target { { *-*-linux-gnu *-*-gnu* *-*-elf } && { ! mips*-*-* } } } } } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-shift1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-shift1.C new file mode 100644 index 0000000000..1f4ee73d1b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-shift1.C @@ -0,0 +1,73 @@ +// { dg-do compile { target c++11 } } + +constexpr int +fn1 (int i, int j) +{ + return i << j; // { dg-error "is negative" } +} + +constexpr int i1 = fn1 (1, -1); + +constexpr int +fn2 (int i, int j) +{ + return i << j; // { dg-error "is >= than the precision of the left operand" } +} + +constexpr int i2 = fn2 (1, 200); + +constexpr int +fn3 (int i, int j) +{ + return i << j; // { dg-error "is negative" } +} + +constexpr int i3 = fn3 (-1, 2); + +constexpr int +fn4 (int i, int j) +{ + return i << j; // { dg-error "overflows" } +} + +constexpr int i4 = fn4 (__INT_MAX__, 2); + +constexpr int +fn5 (int i, int j) +{ + return i << j; +} + +constexpr int i5 = fn5 (__INT_MAX__, 1); + +constexpr int +fn6 (unsigned int i, unsigned int j) +{ + return i << j; // { dg-error "is >= than the precision of the left operand" } +} + +constexpr int i6 = fn6 (1, -1); + +constexpr int +fn7 (int i, int j) +{ + return i >> j; // { dg-error "is negative" } +} + +constexpr int i7 = fn7 (1, -1); + +constexpr int +fn8 (int i, int j) +{ + return i >> j; +} + +constexpr int i8 = fn8 (-1, 1); + +constexpr int +fn9 (int i, int j) +{ + return i >> j; // { dg-error "is >= than the precision of the left operand" } +} + +constexpr int i9 = fn9 (1, 200); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-sizeof1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-sizeof1.C new file mode 100644 index 0000000000..d9a032b392 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-sizeof1.C @@ -0,0 +1,15 @@ +// PR c++/64603 +// { dg-do compile { target c++11 } } + +template <int i> constexpr int find_longest_name() +{ + return sizeof("Main") - 1; +} + +template <int i, int l = find_longest_name<i>()> void create_all_loggers() +{} + +int main() +{ + create_all_loggers<1>(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-static6.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-static6.C index 78065c3068..99e456985b 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-static6.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-static6.C @@ -2,7 +2,7 @@ struct B { - constexpr operator int() { return 4; } + constexpr operator int() const { return 4; } }; template <int I> diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-stmtexpr2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-stmtexpr2.C new file mode 100644 index 0000000000..34ca9fa997 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-stmtexpr2.C @@ -0,0 +1,12 @@ +// { dg-do compile { target c++11 } } +// { dg-options "" } + +#define SA(X) static_assert((X),#X) + +template <class T> +constexpr T f (T t) +{ + return ({ t+1; }); +} + +SA(f(42) == 43); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-targ2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-targ2.C new file mode 100644 index 0000000000..285d6c9c13 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-targ2.C @@ -0,0 +1,40 @@ +// PR c++/65498 +// { dg-do compile { target c++11 } } + +template <typename, typename> +struct is_same +{ + enum { value = false }; + constexpr bool operator()() const noexcept { return value; } +}; + +template <typename T> +struct is_same<T, T> +{ + enum { value = true }; + constexpr bool operator()() const noexcept { return value; } +}; + +template <bool, typename = void> +struct enable_if { }; + +template <typename T> +struct enable_if<true, T> { typedef T type; }; + +struct A; + +template <typename, typename = void> +struct F { }; + +template <typename X> +struct F<X, typename enable_if<is_same<X, A>{}()>::type> { + template <typename MakeDependent> + F(MakeDependent) { + auto ICE_HERE = __func__; + (void)ICE_HERE; // avoid -Wunused-variable + } +}; + +int main() { + F<A>{1}; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-template2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-template2.C index a316b34bd7..12a8d42b31 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-template2.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-template2.C @@ -3,7 +3,7 @@ template <class T> struct A { T t; - constexpr A() { } // { dg-error "uninitialized" } + constexpr A() { } // { dg-error "::t" } }; int main() diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-template8.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-template8.C new file mode 100644 index 0000000000..7b2b9c7555 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-template8.C @@ -0,0 +1,10 @@ +// PR c++/63283 +// { dg-do compile { target c++11 } } + +constexpr int array_length(int (&array)[3]) { return 3; } +int a[] = { 1, 2, 3 }; +template <typename T> int f() { + struct { int e[array_length(a)]; } t; + return sizeof(t); +} +int main() { f<void>(); } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-type-decl1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-type-decl1.C new file mode 100644 index 0000000000..0ef715e883 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-type-decl1.C @@ -0,0 +1,58 @@ +// PR c++/55250 +// { dg-do compile { target c++11 } } + +#define SA(X) static_assert((X),#X) + +struct GS { constexpr operator int() { return 1; } }; +enum GE { y = 1 }; + +constexpr int Test1(int x) { typedef int T; return T(x) + 1; } +constexpr int Test2(int x) { using T = int; return T(x) + 1; } +constexpr int Test3(int x) { typedef GS T; return x + T(); } +constexpr int Test4(int x) { using T = GS; return x + T(); } +constexpr int Test5(int x) { typedef GE T; return x + T::y; } +constexpr int Test6(int x) { using T = GE; return x + T::y; } + +SA(Test1(2) == 3); +SA(Test2(2) == 3); +SA(Test3(2) == 3); +SA(Test4(2) == 3); +SA(Test5(2) == 3); +SA(Test6(2) == 3); + +struct S1 +{ + constexpr S1() { typedef int T; SA(T(1) == 1); } +}; + +struct S2 +{ + constexpr S2() { using T = int; SA(T(1) == 1); } +}; + +struct S3 +{ + constexpr S3() { typedef GS T; SA(T() == 1); } +}; + +struct S4 +{ + constexpr S4() { using T = GS; SA(T() == 1); } +}; + +struct S5 +{ + constexpr S5() { typedef GE T; SA(T::y == 1); } +}; + +struct S6 +{ + constexpr S6() { using T = GE; SA(T::y == 1); } +}; + +S1 s1; +S2 s2; +S3 s3; +S4 s4; +S5 s5; +S6 s6; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-type-def1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-type-def1.C new file mode 100644 index 0000000000..1a72950b8b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-type-def1.C @@ -0,0 +1,44 @@ +// PR c++/55250 +// { dg-do compile { target c++11 } } + +constexpr int Test1(int x) { enum E { y = 1 }; return x; } // { dg-error "not a return-statement" "" { target { c++11_only } } } + +constexpr int Test2(int x) { struct T { }; return x; } // { dg-error "not a return-statement" "" { target { c++11_only } } } + +constexpr int Test3(int x) { typedef enum E { y = 1 } EE; return x; } // { dg-error "not a return-statement" "" { target { c++11_only } } } + +constexpr int Test4(int x) { typedef struct T { } TT; return x; } // { dg-error "not a return-statement" "" { target { c++11_only } } } + +constexpr int Test5(int x) { using EE = enum E { y = 1 }; return x; } // { dg-error "not a return-statement" "" { target { c++11_only } } } + +constexpr int Test6(int x) { using TT = struct T { }; return x; } // { dg-error "not a return-statement" "" { target { c++11_only } } } + +struct S1 +{ + constexpr S1() { enum E { y = 1 }; } // { dg-error "does not have empty body" "" { target { c++11_only } } } +}; + +struct S2 +{ + constexpr S2() { struct T { }; } // { dg-error "does not have empty body" "" { target { c++11_only } } } +}; + +struct S3 +{ + constexpr S3() { typedef enum E { y = 1 } EE; } // { dg-error "does not have empty body" "" { target { c++11_only } } } +}; + +struct S4 +{ + constexpr S4() { typedef struct T { } TT; } // { dg-error "does not have empty body" "" { target { c++11_only } } } +}; + +struct S5 +{ + constexpr S5() { using EE = enum E { y = 1 }; } // { dg-error "does not have empty body" "" { target { c++11_only } } } +}; + +struct S6 +{ + constexpr S6() { using TT = struct T { }; } // { dg-error "does not have empty body" "" { target { c++11_only } } } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-union6.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-union6.C new file mode 100644 index 0000000000..96d48182c3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-union6.C @@ -0,0 +1,10 @@ +// PR c++/60184 +// { dg-do compile { target c++11 } } + +union Test1 { + static constexpr int kConstant = 10; +}; + +union Test2 { + static constexpr const int& kConstant = Test1::kConstant; +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-using3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-using3.C new file mode 100644 index 0000000000..88a14fda10 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-using3.C @@ -0,0 +1,29 @@ +// { dg-do compile { target c++11 } } +// { dg-options "-pedantic" } + +namespace ns { typedef int T; } + +constexpr int Test1(int x) { using ns::T; typedef T U; return U(x); } +constexpr int Test2(int x) { using namespace ns; typedef T U; return U(x); } +constexpr int Test3(int x) { { using ns::T; typedef T U; return U(x); } } // { dg-warning "compound-statement" "" { target { c++11_only } } } +constexpr int Test4(int x) { { using namespace ns; typedef T U; return T(x); } } // { dg-warning "compound-statement" "" { target { c++11_only } } } + +struct S1 +{ + constexpr S1() { using ns::T; typedef T U; } +}; + +struct S2 +{ + constexpr S2() { using namespace ns; typedef T U; } +}; + +struct S3 +{ + constexpr S3() { { using ns::T; typedef T U; } } // { dg-warning "compound-statement" "" { target { c++11_only } } } +}; + +struct S4 +{ + constexpr S4() { { using namespace ns; typedef T U; } } // { dg-warning "compound-statement" "" { target { c++11_only } } } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-volatile.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-volatile.C new file mode 100644 index 0000000000..1203b04aff --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-volatile.C @@ -0,0 +1,26 @@ +// DR 1453 +// { dg-do compile { target c++11 } } + +struct S { + constexpr S() : n{} { } + volatile int n; +}; + +constexpr S s; // { dg-error "literal" } + +struct Z { + volatile int m; +}; + +struct T { + constexpr T() : n{} { } + Z n; +}; + +constexpr T t; // { dg-error "literal" } + +struct U : Z { + constexpr U() : Z{} { } +}; + +constexpr U u; // { dg-error "literal" } diff --git a/gcc/testsuite/g++.dg/cpp0x/cplusplus.C b/gcc/testsuite/g++.dg/cpp0x/cplusplus.C new file mode 100644 index 0000000000..b2f0ccd3d3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/cplusplus.C @@ -0,0 +1,5 @@ +// { dg-do compile { target c++11_only } } + +#if __cplusplus != 201103L +#error "__cplusplus != 201103L" +#endif diff --git a/gcc/testsuite/g++.dg/cpp0x/cplusplus_0x.C b/gcc/testsuite/g++.dg/cpp0x/cplusplus_0x.C new file mode 100644 index 0000000000..6ba2a6cc33 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/cplusplus_0x.C @@ -0,0 +1,6 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +#if __cplusplus != 201103L +#error "__cplusplus != 201103L" +#endif diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype-call1.C b/gcc/testsuite/g++.dg/cpp0x/decltype-call1.C index 2616bb0904..39069ba228 100644 --- a/gcc/testsuite/g++.dg/cpp0x/decltype-call1.C +++ b/gcc/testsuite/g++.dg/cpp0x/decltype-call1.C @@ -2,7 +2,7 @@ // N3276 // { dg-do compile { target c++11 } } -struct A; // { dg-error "forward declaration" } +struct A; // { dg-message "forward declaration" } A f(); decltype(f()) g1(); // OK diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype2.C b/gcc/testsuite/g++.dg/cpp0x/decltype2.C index f316f50a02..29ba2aa97e 100644 --- a/gcc/testsuite/g++.dg/cpp0x/decltype2.C +++ b/gcc/testsuite/g++.dg/cpp0x/decltype2.C @@ -45,7 +45,6 @@ int bar(int); CHECK_DECLTYPE(decltype(foo), int(char)); decltype(bar) z; // { dg-error "overload" "overload" } -// { dg-error "invalid type" "invalid" { target *-*-* } 47 } CHECK_DECLTYPE(decltype(&foo), int(*)(char)); CHECK_DECLTYPE(decltype(*&foo), int(&)(char)); diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype26.C b/gcc/testsuite/g++.dg/cpp0x/decltype26.C index 0d320dadd2..58ba823aca 100644 --- a/gcc/testsuite/g++.dg/cpp0x/decltype26.C +++ b/gcc/testsuite/g++.dg/cpp0x/decltype26.C @@ -10,7 +10,7 @@ decltype(f(T())) f(T t) // { dg-error "depth" } int main() { - f(A()); // { dg-error "no match" } + f(A()); // { dg-message "from here" } } -// { dg-prune-output "note" } +// { dg-prune-output "compilation terminated" } diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype28.C b/gcc/testsuite/g++.dg/cpp0x/decltype28.C index c1c5a1b305..8c26fd7330 100644 --- a/gcc/testsuite/g++.dg/cpp0x/decltype28.C +++ b/gcc/testsuite/g++.dg/cpp0x/decltype28.C @@ -14,3 +14,5 @@ ft (F f, typename enable_if<N==0, int>::type) {} int main() { ft<struct a*, 2> (0, 0); // { dg-message "from here" } } + +// { dg-prune-output "compilation terminated" } diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype29.C b/gcc/testsuite/g++.dg/cpp0x/decltype29.C index d87299cccc..51da8ddd0d 100644 --- a/gcc/testsuite/g++.dg/cpp0x/decltype29.C +++ b/gcc/testsuite/g++.dg/cpp0x/decltype29.C @@ -13,7 +13,7 @@ decltype (ft<F> (F())) // { dg-error "depth" } ft() {} int main() { - ft<struct a*, 0>(); // { dg-error "no match|wrong number" } + ft<struct a*, 0>(); // { dg-message "from here" } } -// { dg-prune-output "note" } +// { dg-prune-output "compilation terminated" } diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype3.C b/gcc/testsuite/g++.dg/cpp0x/decltype3.C index aaff5df598..b2e66243cc 100644 --- a/gcc/testsuite/g++.dg/cpp0x/decltype3.C +++ b/gcc/testsuite/g++.dg/cpp0x/decltype3.C @@ -55,7 +55,7 @@ public: CHECK_DECLTYPE(decltype(aa.*&A::a), int&); decltype(aa.*&A::b) zz; // { dg-error "cannot create pointer to reference member" "cannot" } -// { dg-error "invalid type" "invalid type" { target *-*-* } 57 } + CHECK_DECLTYPE(decltype(caa.*&A::a), const int&); class X { diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype32.C b/gcc/testsuite/g++.dg/cpp0x/decltype32.C index 02c6316e16..1deb964577 100644 --- a/gcc/testsuite/g++.dg/cpp0x/decltype32.C +++ b/gcc/testsuite/g++.dg/cpp0x/decltype32.C @@ -4,10 +4,12 @@ template <typename T> auto make_array(const T& il) -> -decltype(make_array(il)) // { dg-error "not declared|no matching|exceeds" } +decltype(make_array(il)) // { dg-error "not declared|no matching|depth" } { } int main() { int z = make_array(1); // { dg-error "no matching" } } + +// { dg-prune-output "compilation terminated" } diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype58.C b/gcc/testsuite/g++.dg/cpp0x/decltype58.C new file mode 100644 index 0000000000..c3918bf847 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype58.C @@ -0,0 +1,24 @@ +// PR c++/52875 +// { dg-do compile { target c++11 } } + +struct A +{ + friend void swap(A&,A&) {} +}; + +class B +{ + A a; + + template <class T> + friend auto swap(T& x, T& y) -> decltype(swap(x.a,y.a)) + { + swap(x.a,y.a); + } +}; + +int main() +{ + B x, y; + swap(x, y); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype59.C b/gcc/testsuite/g++.dg/cpp0x/decltype59.C new file mode 100644 index 0000000000..93208df95c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype59.C @@ -0,0 +1,41 @@ +// PR c++/57543 +// { dg-do compile { target c++11 } } + +template< typename > struct X +{ + void foo(); + auto bar() -> decltype( X::foo() ); +}; + +template< typename > struct Y +{ + void foo(); + template< typename > + auto bar() -> decltype( Y::foo() ); +}; + +template< typename > struct Z +{ + void foo(); + template< typename T > + auto bar() -> decltype( T::foo() ); +}; + +template< typename > struct K +{ + void foo(); + template< typename T > + auto bar() -> decltype( T::foo() ); +}; + +template<> +template<> +auto K<int>::bar<K<int>>() -> decltype( K<int>::foo() ); + +int main() +{ + X<int>().bar(); + Y<int>().bar<double>(); + Z<int>().bar<Z<int>>(); + K<int>().bar<K<int>>(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype60.C b/gcc/testsuite/g++.dg/cpp0x/decltype60.C new file mode 100644 index 0000000000..504f5d1b62 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype60.C @@ -0,0 +1,7 @@ +// PR c++/59637 +// { dg-do compile { target c++11 } } + +template<typename T> void foo(T* p) +{ + p->decltype(T{})::~X(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype61.C b/gcc/testsuite/g++.dg/cpp0x/decltype61.C new file mode 100644 index 0000000000..0159330d79 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype61.C @@ -0,0 +1,20 @@ +// DR 1510, PR c++/60420 +// { dg-do compile { target c++11 } } + +struct MyIter +{ + int& operator*(); +}; + +void foo(MyIter begin) +{ + auto x = [](const decltype(*begin)) { }; +} + +template<typename Iterator> +void bar(Iterator begin) +{ + auto x = [](const decltype(*begin)) { }; +} + +template void bar<MyIter>(MyIter); diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype62.C b/gcc/testsuite/g++.dg/cpp0x/decltype62.C new file mode 100644 index 0000000000..f2f1606543 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype62.C @@ -0,0 +1,15 @@ +// PR c++/64398 +// { dg-do compile { target c++11 } } + +template<typename T> struct template1; + +template<typename T, typename> // second param required +struct struct1{ + using type1 = decltype(T::x); + using type2 = template1<type1>; +}; + +template<typename T> using alias1 = template1<decltype(T::x)>; + +// just for instantiation: +template<typename T> using alias2 = alias1<T>; diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted14.C b/gcc/testsuite/g++.dg/cpp0x/defaulted14.C index 0c07fa701b..16df8bcc30 100644 --- a/gcc/testsuite/g++.dg/cpp0x/defaulted14.C +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted14.C @@ -14,7 +14,5 @@ int main() { A a; a = B(); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 16 } a = 1.0; // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 18 } } diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted18.C b/gcc/testsuite/g++.dg/cpp0x/defaulted18.C index 6d84a1e881..83e1126dc0 100644 --- a/gcc/testsuite/g++.dg/cpp0x/defaulted18.C +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted18.C @@ -6,5 +6,4 @@ void f(int i, ...); // { dg-message "void f" } int main() { f(1,1); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 8 } } diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted20.C b/gcc/testsuite/g++.dg/cpp0x/defaulted20.C index affda20fdd..2bc4f7fbb5 100644 --- a/gcc/testsuite/g++.dg/cpp0x/defaulted20.C +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted20.C @@ -10,7 +10,7 @@ struct B { B(B&&) = default; // { dg-error "implicitly deleted|use of deleted" } }; -void g(B); // { dg-error "argument 1" } +void g(B); // { dg-message "argument 1" } B&& f(); int main() diff --git a/gcc/testsuite/g++.dg/cpp0x/deleted10.C b/gcc/testsuite/g++.dg/cpp0x/deleted10.C new file mode 100644 index 0000000000..4fbee27c33 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/deleted10.C @@ -0,0 +1,15 @@ +// PR c++/60753 +// { dg-do compile { target c++11 } } + +template<class T> void foo (T); + +template<> void foo<int> (int); +template<> void foo<int> (int) = delete; // { dg-error "deleted" } + +struct S +{ + template<class T> void bar (T); +}; + +template<> void S::bar<int> (int); +template<> void S::bar<int> (int) = delete; // { dg-error "deleted" } diff --git a/gcc/testsuite/g++.dg/cpp0x/deleted11.C b/gcc/testsuite/g++.dg/cpp0x/deleted11.C new file mode 100644 index 0000000000..9c60af09c2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/deleted11.C @@ -0,0 +1,8 @@ +// PR c++/52659 +// { dg-do compile { target c++11 } } + +struct sometype { + sometype(); +}; + +sometype::sometype() = delete; // { dg-error "deleted" } diff --git a/gcc/testsuite/g++.dg/cpp0x/deleted4.C b/gcc/testsuite/g++.dg/cpp0x/deleted4.C new file mode 100644 index 0000000000..22439d4570 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/deleted4.C @@ -0,0 +1,11 @@ +// PR c++/58582 +// { dg-do compile { target c++11 } } + +struct A +{ + template<int> void foo() = delete; +}; + +template<int> void A::foo() { int i; } // { dg-error "redefinition" } + +template void A::foo<0>(); diff --git a/gcc/testsuite/g++.dg/cpp0x/deleted5.C b/gcc/testsuite/g++.dg/cpp0x/deleted5.C new file mode 100644 index 0000000000..51010efda7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/deleted5.C @@ -0,0 +1,11 @@ +// PR c++/58582 +// { dg-do compile { target c++11 } } + +struct A +{ + template<int> void foo() = delete; +}; + +template<int> void A::foo() {} // { dg-error "redefinition" } + +template void A::foo<0>(); diff --git a/gcc/testsuite/g++.dg/cpp0x/deleted6.C b/gcc/testsuite/g++.dg/cpp0x/deleted6.C new file mode 100644 index 0000000000..af25b505db --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/deleted6.C @@ -0,0 +1,9 @@ +// PR c++/58582 +// { dg-do compile { target c++11 } } + +struct A +{ + template<int> void foo() = delete; +}; + +template void A::foo<0>(); diff --git a/gcc/testsuite/g++.dg/cpp0x/deleted7.C b/gcc/testsuite/g++.dg/cpp0x/deleted7.C new file mode 100644 index 0000000000..6afa9f7689 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/deleted7.C @@ -0,0 +1,36 @@ +// PR c++/61080 +// { dg-do compile { target c++11 } } +// { dg-options "-Wreturn-type" } + +struct AAA +{ + int a1, a2, a3; + void *p; +}; + +template <typename K, typename V> +class WeakMapPtr +{ + public: + WeakMapPtr() : ptr(nullptr) {}; + bool init(AAA *cx); + private: + void *ptr; + WeakMapPtr(const WeakMapPtr &wmp) = delete; + WeakMapPtr &operator=(const WeakMapPtr &wmp) = delete; +}; + +template <typename K, typename V> +bool WeakMapPtr<K, V>::init(AAA *cx) +{ + ptr = cx->p; + return true; +} + +struct JSObject +{ + int blah; + float meh; +}; + +template class WeakMapPtr<JSObject*, JSObject*>; diff --git a/gcc/testsuite/g++.dg/cpp0x/deleted8.C b/gcc/testsuite/g++.dg/cpp0x/deleted8.C new file mode 100644 index 0000000000..a16f9fd199 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/deleted8.C @@ -0,0 +1,22 @@ +// PR c++/56633 +// { dg-do compile { target c++11 } } + +struct A { + A(int) { } + A(const A&) = delete; +}; + +struct Test1 { + A value2{0}; // no problem here +}; + +template <typename T> // T is not used +struct Test2 { + A value2{0}; // fails to compile +}; + +int main() { + Test1 test; + Test2<int> test2; + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/deleted9.C b/gcc/testsuite/g++.dg/cpp0x/deleted9.C new file mode 100644 index 0000000000..af97be7c35 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/deleted9.C @@ -0,0 +1,31 @@ +// PR c++/64352 +// { dg-do compile { target c++11 } } + +template<bool B> struct bool_type +{ static constexpr bool value = B; }; + +using true_type = bool_type<true>; +using false_type = bool_type<false>; + +template<typename T> T&& declval(); + +template<typename...> struct void_ { using type = void; }; +template<typename... I> using void_t = typename void_<I...>::type; + +template<typename _Tp, typename = void> +struct _Has_addressof_free: false_type { }; + +template<typename _Tp> +struct _Has_addressof_free +<_Tp, void_t<decltype( operator&(declval<const _Tp&>()) )>> +: true_type { }; + +struct foo {}; +void operator&(foo) = delete; + +int main() +{ + static_assert( !_Has_addressof_free<int>::value, "" ); + // error: use of deleted function 'void operator&(foo)' + static_assert( !_Has_addressof_free<foo>::value, "" ); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/desig1.C b/gcc/testsuite/g++.dg/cpp0x/desig1.C new file mode 100644 index 0000000000..cc527308f0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/desig1.C @@ -0,0 +1,27 @@ +// PR c++/58882 +// { dg-do compile { target c++11 } } + +struct A +{ + constexpr operator int() const { return 0; } +}; + +int a[] = { [A()] = 0 }; + +enum E { e0 }; + +struct B +{ + constexpr operator E() const { return E::e0; } +}; + +int b[] = { [B()] = 0 }; + +enum class SE { se0 }; + +struct C +{ + constexpr operator SE() const { return SE::se0; } +}; + +int c[] = { [C()] = 0 }; // { dg-error "integral constant-expression" } diff --git a/gcc/testsuite/g++.dg/cpp0x/diag2.C b/gcc/testsuite/g++.dg/cpp0x/diag2.C new file mode 100644 index 0000000000..0d01b1de79 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/diag2.C @@ -0,0 +1,19 @@ +// { dg-do compile { target c++11 } } + +struct A {}; + +// We shouldn't arbitarily choose which of these is better. +void f (A&); +void f (const A&&); + +// But do prefer the lvalue overload here. +void g (A&); +void g (A&&); +int main() +{ + const A a; + f(a); // { dg-error "no match" } + // { dg-error "qualifiers" "" { target *-*-* } 15 } + // { dg-error "lvalue" "" { target *-*-* } 15 } + g(a); // { dg-error "qualifiers" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/elision_conv.C b/gcc/testsuite/g++.dg/cpp0x/elision_conv.C new file mode 100644 index 0000000000..d778a0b802 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/elision_conv.C @@ -0,0 +1,18 @@ +// Core 1579 return by converting move constructor +// PR c++/58051 +// { dg-do compile { target c++11 } } + +struct A { + A() = default; + A(A&&) = default; +}; + +struct B { + B(A) { } +}; + +B f() +{ + A a; + return a; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/enum11.C b/gcc/testsuite/g++.dg/cpp0x/enum11.C index a449f1c39a..f15b6cda49 100644 --- a/gcc/testsuite/g++.dg/cpp0x/enum11.C +++ b/gcc/testsuite/g++.dg/cpp0x/enum11.C @@ -4,12 +4,10 @@ template<unsigned int N> struct Pair { }; struct Foo { enum { Mask = 1 }; } foo; -template<typename A, typename B> class Pair<A::Mask | B::Mask> -operator|(const A &, const B &) // { dg-message "substitution" } +template<typename A, typename B> class Pair<A::Mask | B::Mask> // { dg-error "depth" } +operator|(const A &, const B &) { } -Pair<Foo::Mask> f = foo|foo; // { dg-message "no match" } +Pair<Foo::Mask> f = foo|foo; // { dg-message "from here" } -// { dg-prune-output "note" } -// { dg-prune-output "here" } -// { dg-prune-output "instantiation depth" } +// { dg-prune-output "compilation terminated" } diff --git a/gcc/testsuite/g++.dg/cpp0x/enum13.C b/gcc/testsuite/g++.dg/cpp0x/enum13.C index 5e4a532ce7..8335fadd78 100644 --- a/gcc/testsuite/g++.dg/cpp0x/enum13.C +++ b/gcc/testsuite/g++.dg/cpp0x/enum13.C @@ -10,12 +10,10 @@ enum struct A : short { X }; void foo(int x, ...) { va_list vl; __builtin_va_start(vl, x); - enum A t = __builtin_va_arg(vl, enum A); // { dg-warning "promote" } + enum A t = __builtin_va_arg(vl, enum A); // { dg-warning "scoped|promote" } __builtin_va_end(vl); } int main() { - foo(0, A::X); // { dg-warning "will not promote" } + foo(0, A::X); // { dg-warning "scoped" } } - -// { dg-prune-output "note" } diff --git a/gcc/testsuite/g++.dg/cpp0x/enum29.C b/gcc/testsuite/g++.dg/cpp0x/enum29.C new file mode 100644 index 0000000000..f24a6a2a95 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum29.C @@ -0,0 +1,56 @@ +// PR c++/51312 +// { dg-do compile { target c++11 } } + +struct X0 +{ + constexpr operator int() const { return 1; } +}; + +struct X1 +{ + enum RE1 { re1 = 1 }; + constexpr operator RE1() const { return re1; } +}; + +struct X2 +{ + constexpr operator int() const { return __INT_MAX__; } +}; + +struct X3 +{ + enum RE3 { re3 = __INT_MAX__ }; + constexpr operator RE3() const { return re3; } +}; + +struct X4 +{ + constexpr operator double() const { return 1.0; } +}; + +struct X5 +{ + constexpr operator int() const { return __INT_MAX__; } + constexpr operator unsigned() const { return __INT_MAX__ * 2U + 1; } +}; + +enum E0 { e0 = X0() }; +enum E1 { e1 = X1() }; +enum E2 { e2 = X2() }; +enum E3 { e3 = X3() }; +enum E4 { e4 = X4() }; // { dg-error "integer constant" } +enum E5 { e5 = X5() }; // { dg-error "ambiguous" } + +enum F0 : int { f0 = X0() }; +enum F1 : int { f1 = X1() }; +enum F2 : int { f2 = X2() }; +enum F3 : int { f3 = X3() }; +enum F4 : int { f4 = X4() }; // { dg-error "narrowing" } +enum F5 : int { f5 = X5() }; + +enum G0 : signed char { g0 = X0() }; +enum G1 : signed char { g1 = X1() }; +enum G2 : signed char { g2 = X2() }; // { dg-error "narrowing" } +enum G3 : signed char { g3 = X3() }; // { dg-error "narrowing" } +enum G4 : signed char { g4 = X4() }; // { dg-error "narrowing" } +enum G5 : signed char { g5 = X5() }; // { dg-error "ambiguous" } diff --git a/gcc/testsuite/g++.dg/cpp0x/explicit3.C b/gcc/testsuite/g++.dg/cpp0x/explicit3.C index 678076c8e4..6318ade2c0 100644 --- a/gcc/testsuite/g++.dg/cpp0x/explicit3.C +++ b/gcc/testsuite/g++.dg/cpp0x/explicit3.C @@ -45,6 +45,6 @@ int main() f(a); // { dg-error "" } B b2 = { a }; // { dg-error "" } a + true; // { dg-error "5:no match" } - b ? a : true; // { dg-error "5:no match" } - a ? a : true; // { dg-error "5:no match" } + b ? a : true; // { dg-error "5:?:" } + a ? a : true; // { dg-error "5:?:" } } diff --git a/gcc/testsuite/g++.dg/cpp0x/explicit4.C b/gcc/testsuite/g++.dg/cpp0x/explicit4.C index 663878e55a..346a6e2590 100644 --- a/gcc/testsuite/g++.dg/cpp0x/explicit4.C +++ b/gcc/testsuite/g++.dg/cpp0x/explicit4.C @@ -14,5 +14,4 @@ int main() B b; (A(b)); // OK (A(b,1)); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 16 } } diff --git a/gcc/testsuite/g++.dg/cpp0x/explicit8.C b/gcc/testsuite/g++.dg/cpp0x/explicit8.C new file mode 100644 index 0000000000..acacf97451 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/explicit8.C @@ -0,0 +1,22 @@ +// PR c++/60686 +// { dg-do compile { target c++11 } } + +struct A { + explicit operator int() const; +}; + +explicit inline A::operator int() const { return 1; } // { dg-error "'explicit' outside class declaration" } + +struct B { + explicit void f(); // { dg-error "only declarations of constructors and conversion operators can be 'explicit'" } +}; + +explicit void B::f() { } // { dg-error "'explicit' outside class declaration" } + +struct C { + explicit C(int); +}; + +struct D { + explicit friend C::C(int); // { dg-error "'explicit' in friend declaration" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/forw_enum6.C b/gcc/testsuite/g++.dg/cpp0x/forw_enum6.C index ccce13a79b..7d2094df52 100644 --- a/gcc/testsuite/g++.dg/cpp0x/forw_enum6.C +++ b/gcc/testsuite/g++.dg/cpp0x/forw_enum6.C @@ -25,10 +25,10 @@ enum class E3 e3; // { dg-error "scoped enum must not use" } enum struct E3 e4; // { dg-error "scoped enum must not use" } enum E5 : int e5; // { dg-error "expected|invalid type" } -enum E6 : int { a, b, c }; // { dg-error "previous definition" } +enum E6 : int { a, b, c }; // { dg-message "previous definition" } enum E6 : int { a, b, c }; // { dg-error "multiple definition" } -enum class E7 { }; // { dg-error "previous definition" } +enum class E7 { }; // { dg-message "previous definition" } enum class E7 { a, b, c }; // { dg-error "multiple definition" } namespace N1 diff --git a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-36-1.C b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-36-1.C index 2aae9cae00..131af368a2 100644 --- a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-36-1.C +++ b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-36-1.C @@ -6,6 +6,6 @@ typedef int (*F [[gnu::warn_unused_result]]) (int); typedef int (*F2 [[gnu::warn_unused_result]]) (int); -typedef int (S::*F3 [[gnu::warn_unused_result]]) (int); // { dg-warning "only applies to function types" } +typedef int (S::*F3 [[gnu::warn_unused_result]]) (int); typedef int [[gnu::warn_unused_result]] (*F5) (int); // { dg-warning "ignored" } diff --git a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-42.C b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-42.C index ec98ece588..9fcd5560ca 100644 --- a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-42.C +++ b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-42.C @@ -1,5 +1,5 @@ // { dg-options "-pedantic" } -// { dg-do compile { target { i?86-*-* && ilp32 } } } +// { dg-do compile { target { { i?86-*-* x86_64-*-* } && ia32 } } } // { dg-require-effective-target c++11 } struct A { diff --git a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-58.C b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-58.C new file mode 100644 index 0000000000..f760f56082 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-58.C @@ -0,0 +1,5 @@ +// PR c++/58600 +// { dg-do compile { target c++11 } } + +namespace N { int i; } +using namespace N alignas(int); // { dg-warning "ignored" } diff --git a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-59.C b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-59.C new file mode 100644 index 0000000000..c7839fefed --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-59.C @@ -0,0 +1,5 @@ +// PR c++/58600 +// { dg-do compile { target c++11 } } + +namespace N {} +using namespace N alignas(X); // { dg-error "declared" } diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-lifetime1.C b/gcc/testsuite/g++.dg/cpp0x/initlist-lifetime1.C index d3b0fc3609..9b836754f0 100644 --- a/gcc/testsuite/g++.dg/cpp0x/initlist-lifetime1.C +++ b/gcc/testsuite/g++.dg/cpp0x/initlist-lifetime1.C @@ -23,9 +23,11 @@ struct B { const AL& alr; }; +volatile bool always_false = false; + int main(int argc, const char** argv) { - do_throw = (argc > 1); // always false, but optimizer can't tell + do_throw = always_false; // always false, but optimizer can't tell AL ar[] = {{1,2},{3,4}}; B b = {{5,6},{7,8}}; AL3 al3 = {{{1},{2},{3}}}; diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-lifetime2.C b/gcc/testsuite/g++.dg/cpp0x/initlist-lifetime2.C index 77fc961c96..732736691e 100644 --- a/gcc/testsuite/g++.dg/cpp0x/initlist-lifetime2.C +++ b/gcc/testsuite/g++.dg/cpp0x/initlist-lifetime2.C @@ -53,9 +53,11 @@ struct D { D() { ok = true; } }; +volatile bool always_false = false; + int main(int argc, const char** argv) { - do_throw = (argc > 1); // always false, but optimizer can't tell + do_throw = always_false; // always false, but optimizer can't tell ok = false; C c; ok = false; diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-n3922.C b/gcc/testsuite/g++.dg/cpp0x/initlist-n3922.C new file mode 100644 index 0000000000..4dadfc986d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist-n3922.C @@ -0,0 +1,15 @@ +// N3922 +// { dg-do compile { target c++11 } } + +#include <initializer_list> +template <class T, class U> struct same_type; +template <class T> struct same_type<T,T> {}; + +auto x1 = { 1, 2 }; // decltype(x1) is std::initializer_list<int> +same_type<decltype(x1),std::initializer_list<int>> s1; +auto x4 = { 3 }; // decltype(x4) is std::initializer_list<int> +same_type<decltype(x4),std::initializer_list<int>> s4; +auto x5{ 3 }; // decltype(x5) is int +same_type<decltype(x5),int> s5; +auto x2 = { 1, 2.0 }; // { dg-error "initializer_list" } cannot deduce element type +auto x3{ 1, 2 }; // { dg-error "one element" } not a single element diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-vect.C b/gcc/testsuite/g++.dg/cpp0x/initlist-vect.C new file mode 100644 index 0000000000..80a2fbb63f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist-vect.C @@ -0,0 +1,6 @@ +// { dg-do compile { target c++11 } } + +typedef float X __attribute__ ((vector_size (4 * sizeof (float)))); + +X x; +X x2{x}; diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist26.C b/gcc/testsuite/g++.dg/cpp0x/initlist26.C index 81d304f0e9..8fd267f440 100644 --- a/gcc/testsuite/g++.dg/cpp0x/initlist26.C +++ b/gcc/testsuite/g++.dg/cpp0x/initlist26.C @@ -1,6 +1,6 @@ // PR c++/42059 // { dg-do compile { target c++11 } } -// { dg-options "" { target { ! c++1y } } } +// { dg-options "" } void foo (int i) diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist83.C b/gcc/testsuite/g++.dg/cpp0x/initlist83.C new file mode 100644 index 0000000000..4a5eeb6d08 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist83.C @@ -0,0 +1,7 @@ +// DR 1467, c++/51747 +// { dg-do compile { target c++11 } } + +struct X { }; + +X x; +X x2{x}; diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist85.C b/gcc/testsuite/g++.dg/cpp0x/initlist85.C new file mode 100644 index 0000000000..fa4fb617b3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist85.C @@ -0,0 +1,16 @@ +// PR c++/60848 +// { dg-do compile { target c++11 } } + +namespace std +{ + struct initializer_list {}; // { dg-message "initializer_list" } +} + +void foo(std::initializer_list &); + +void f() +{ + foo({1, 2}); +} + +// { dg-prune-output "compilation terminated" } diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist87.C b/gcc/testsuite/g++.dg/cpp0x/initlist87.C new file mode 100644 index 0000000000..fd7586d27d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist87.C @@ -0,0 +1,35 @@ +// PR c++/61723 +// { dg-do compile { target c++11 } } + +namespace std { + template < class > struct initializer_list // { dg-message "initializer_list" } + { +#if BUG1 + int _M_len; +#endif + const int *begin (); + const int *end (); + }; +} + +struct J +{ + J (const int &); + template < typename InputIterator > J (InputIterator, InputIterator); + J (std::initializer_list < int >p1):J (p1.begin (), p1.end ()) { } +}; + +struct L +{ + L ():dim (0) { } + J dim; +}; + +void +fn1 () +{ + L spec; + spec.dim = { }; +} + +// { dg-prune-output "compilation terminated" } diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist88.C b/gcc/testsuite/g++.dg/cpp0x/initlist88.C new file mode 100644 index 0000000000..d0a38fd4f6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist88.C @@ -0,0 +1,4 @@ +// PR c++/60859 +// { dg-do compile { target c++11 } } + +int a[] = { {} }; diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist89.C b/gcc/testsuite/g++.dg/cpp0x/initlist89.C new file mode 100644 index 0000000000..e221664e30 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist89.C @@ -0,0 +1,4 @@ +// PR c++/64029 +// { dg-do compile { target c++11 } } + +const int (&in)[]{1,2,3,4,5}; diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist90.C b/gcc/testsuite/g++.dg/cpp0x/initlist90.C new file mode 100644 index 0000000000..330517af69 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist90.C @@ -0,0 +1,35 @@ +// PR c++/57510 +// { dg-do run { target c++11 } } + +#include <initializer_list> + +struct counter +{ + static int n; + + counter() { ++n; } + counter(const counter&) { ++n; } + ~counter() { --n; } +}; + +int counter::n = 0; + +struct X +{ + X () { if (counter::n > 1) throw 1; } + + counter c; +}; + +int main () +{ + try + { + auto x = { X{}, X{} }; + } + catch (...) + { + if ( counter::n != 0 ) + throw; + } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist91.C b/gcc/testsuite/g++.dg/cpp0x/initlist91.C new file mode 100644 index 0000000000..1387557ab2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist91.C @@ -0,0 +1,8 @@ +// PR c++/64520 +// { dg-do compile { target c++11 } } + +#include <initializer_list> +struct A { + template <typename... B> A(std::initializer_list<B...>); +}; +A a { 0 }; // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist92.C b/gcc/testsuite/g++.dg/cpp0x/initlist92.C new file mode 100644 index 0000000000..81a63182f0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist92.C @@ -0,0 +1,55 @@ +// PR c++/64665, DR 1467 +// { dg-do run { target c++11 } } + +#include <string> +#include <cassert> + +bool Test1(bool) +{ + return true; +} +bool Test1(std::string) +{ + return false; +} + +bool Test2(int) +{ + return false; +} +bool Test2(std::initializer_list<int>) +{ + return true; +} + +struct S +{ + S(int _a) : a(_a) {} +private: + int a; +}; +bool Test3(int) +{ + return true; +} +bool Test3(S) +{ + return false; +} + +bool Test4(bool) +{ + return false; +} +bool Test4(std::initializer_list<std::string>) +{ + return true; +} + +int main () +{ + assert ( Test1({"false"}) ); + assert ( Test2({123}) ); + assert ( Test3({456}) ); + assert ( Test4({"false"}) ); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist93.C b/gcc/testsuite/g++.dg/cpp0x/initlist93.C new file mode 100644 index 0000000000..84a47381f1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist93.C @@ -0,0 +1,13 @@ +// PR c++/65554 +// { dg-do compile { target c++11 } } + +namespace std +{ +template <class> class initializer_list // { dg-error "definition of std::initializer_list does not match" } +{ + int *_M_array; + int _M_len; +}; +} + +// { dg-prune-output "compilation terminated" } diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist94.C b/gcc/testsuite/g++.dg/cpp0x/initlist94.C new file mode 100644 index 0000000000..f83a81d3a4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist94.C @@ -0,0 +1,13 @@ +// PR c++/65554 +// { dg-do compile { target c++11 } } + +typedef decltype (sizeof (int)) size_type; + +namespace std +{ +template <class> class initializer_list +{ + int *_M_array; + size_type _M_len; +}; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-59483.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-59483.C new file mode 100644 index 0000000000..b5b06d2c81 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-59483.C @@ -0,0 +1,31 @@ +// PR c++/59483 +// { dg-do compile { target c++11 } } + +struct X +{ +protected: + int i; +}; + +struct Y : X +{ + Y() + { + [&]{ X::i = 3; }(); + } +}; + +template <class T> +struct Y2 : T +{ + Y2() + { + [&]{ T::i = 3; }(); + } +}; + +int main() +{ + Y y; + Y2<X> y2; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-61148.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-61148.C new file mode 100644 index 0000000000..879030caa0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-61148.C @@ -0,0 +1,33 @@ +// PR c++/61148 +// { dg-do compile { target c++11 } } + +class DB +{ +protected: + void foo() {}; +}; + +class DC : public DB +{ +public: + DC() + { + [this]() {DB::foo();}(); + }; +}; + +template <class T> +class DC2 : public T +{ +public: + DC2() + { + [this]() {T::foo();}(); + }; +}; + +int main(void) +{ + DC x; + DC2<DB> x2; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-62155.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-62155.C new file mode 100644 index 0000000000..76eb2da783 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-62155.C @@ -0,0 +1,8 @@ +// PR c++/62155 +// { dg-do compile { target c++11 } } + +template <typename T> struct S { // { dg-error "cannot convert" } + T i{[this] {}}; +}; + +S<int> s; // { dg-error "cannot convert" } diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-cast1.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-cast1.C new file mode 100644 index 0000000000..e5d49ca43e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-cast1.C @@ -0,0 +1,7 @@ +// PR c++/54891 +// { dg-do compile { target c++11 } } + +int main() +{ + (void)[]{}; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const-this.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const-this.C new file mode 100644 index 0000000000..220ac911cd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const-this.C @@ -0,0 +1,9 @@ +// PR c++/60463 +// PR c++/60755 +// { dg-do compile { target c++11 } } +struct S { + void f(); + void g() const { + [=] { f(); } (); // { dg-error "no match|qualifiers" } + } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const4.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const4.C new file mode 100644 index 0000000000..02ad60224f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const4.C @@ -0,0 +1,21 @@ +// PR c++/63207 +// { dg-do run { target c++11 } } + +template <typename T> +struct Base { + T value; +}; + +template <typename T> +struct Test : Base<T> { + T test() { + const int x = this->value; + return ([&]{ return x; })(); + } +}; + +int main() { + Test<int> t; + t.value = 0; + return t.test(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv9.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv9.C new file mode 100644 index 0000000000..d7955fd40c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv9.C @@ -0,0 +1,27 @@ +// PR c++/65339 +// { dg-do compile { target c++11 } } + +class FuncWrapper { +public: + template <typename Func> void callfunc(Func f) + { + f(); + } +}; + +class Object { + int field; +public: + void Method(); + Object() { field = 555; } + Object(const Object&) { __builtin_abort(); } +}; + +void Object::Method () +{ + FuncWrapper wrap; + wrap.callfunc(*[]() + { + return Object(); + }); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg.C index cefa24d434..7f69ea13ee 100644 --- a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg.C +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg.C @@ -2,5 +2,5 @@ int main() { - [](int a = 1) { return a; }(); // { dg-error "" } + [](int a = 1) { return a; }(); // { dg-error "default argument" "" { target { c++11_only } } } } diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg6.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg6.C new file mode 100644 index 0000000000..fe8767ac60 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg6.C @@ -0,0 +1,9 @@ +// PR c++/58597 +// { dg-do compile { target c++11 } } + +template<typename> struct A +{ + template<typename T> A(T, int = []{ return 0; }()) {} +}; + +A<int> a = 0; diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice13.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice13.C new file mode 100644 index 0000000000..4c611ad8ee --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice13.C @@ -0,0 +1,14 @@ +// PR c++/61088 +// { dg-do compile { target c++11 } } + +void f() +{ + typedef void (*X) (); + X x[] = { [x](){} }; // { dg-error "incomplete type" } +} + +void g() +{ + typedef void (X) (); + X x[] = { [x](){} }; // { dg-error "array of functions|not declared" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice2.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice2.C index 6a31e0a36f..702f18f6ac 100644 --- a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice2.C +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice2.C @@ -12,6 +12,5 @@ int main() auto l = []() { return 5; }; // { dg-message "lambda closure type" } run(l); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 14 } // { dg-error "use of deleted function" "candidate explanation" { target *-*-* } 5 } } diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice3.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice3.C index 03a7a4bb60..fa8a6e63a9 100644 --- a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice3.C +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice3.C @@ -11,7 +11,7 @@ public: bool Klass::dostuff() { auto f = []() -> bool { - if (local & 1) { return true; } // { dg-error "not captured" } + if (local & 1) { return true; } // { dg-error "not captured|non-static" } return false; }; } diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice7.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice7.C index d0ee866110..6f8272aeb6 100644 --- a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice7.C +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice7.C @@ -1,9 +1,9 @@ // PR c++/52487 // { dg-do compile { target c++11 } } -struct A; // { dg-error "forward declaration" } +struct A; // { dg-message "forward declaration" } void foo(A& a) { - [=](){a;}; // { dg-error "invalid use of incomplete type" } + [=](){a;}; // { dg-error "incomplete type" } } diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nsdmi6.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nsdmi6.C new file mode 100644 index 0000000000..98cdbce28b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nsdmi6.C @@ -0,0 +1,23 @@ +// PR c++/58761 +// { dg-do compile { target c++11 } } + +template <class T> +struct X +{ + int x = 42; + int y = [this](){return this->x;}(); +}; + +template <class T> +struct Y +{ + int x = 42; + int y = [this](){return this->x;}(); + Y(int) {} +}; + +int main() +{ + X<int> x; + Y<int> y(42); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nsdmi7.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nsdmi7.C new file mode 100644 index 0000000000..30595ef6c1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nsdmi7.C @@ -0,0 +1,25 @@ +// PR c++/64496 +// { dg-do compile { target c++11 } } + +template <typename> class B; +template <typename W, typename... X> +struct B<W(X...)> { template <typename F> B(F); }; +template <typename W, typename... X> +template <typename F> +B<W(X...)>::B(F) {} + +int +main() +{ + int a; + struct A // { dg-message "lambda in local class" } + { + B<void()> l = [=] { + a; // { dg-error "not captured" } + }; + }; + [] { // { dg-message "capture-default" } + a; // { dg-error "not captured" } + }; + A t; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-sfinae1.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-sfinae1.C index 973f8a7804..40abcb99a5 100644 --- a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-sfinae1.C +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-sfinae1.C @@ -8,9 +8,9 @@ struct AddRvalueReferenceImpl { typedef T type; }; template <typename T> struct AddRvalueReferenceImpl<T, typename BoolSink<false && - [] { + [] { // { dg-error "lambda" } extern T &&tref; - }>::type> { // { dg-error "lambda" } + }>::type> { typedef T &&type; }; @@ -27,9 +27,9 @@ struct IsConstructibleImpl { enum { value = 0 }; }; template <typename T, typename ...Args> struct IsConstructibleImpl<T, typename BoolSink<false && - [] { + [] { // { dg-error "lambda" } T t( ::ImplHelpers::create<Args>() ...); - }>::type, Args ...> { // { dg-error "lambda" } + }>::type, Args ...> { enum { value = 1 }; }; @@ -53,3 +53,4 @@ static_assert(+IsConstructible<int &&, int &&>::value, "error"); // { dg-prune-output "expected" } // { dg-prune-output "does not name a class" } // { dg-prune-output "static assertion" } +// { dg-prune-output "template argument . is invalid" } diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template13.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template13.C index 79ab4107dd..01fe3f66cf 100644 --- a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template13.C +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template13.C @@ -1,6 +1,5 @@ // PR c++/61566 // { dg-do compile { target c++11 } } -// { dg-options "-fabi-version=0" } struct function { @@ -21,5 +20,5 @@ void bar () c.foo (1); } -// { dg-final { scan-assembler "_ZN8functionC1IZN1CIiE3fooIiEEvT_S_Ed_UlvE_EET_" } } +// { dg-final { scan-assembler "_ZN8functionC1IZN1CIiE3fooIiEEvT_S_Ed_UlvE_EES4_" } } // { dg-final { scan-assembler-not "_ZZN1CIiE3fooIiEEvT_8functionEd_NKUlvE_clEv" } } diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this19.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this19.C new file mode 100644 index 0000000000..c4c041f8b3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this19.C @@ -0,0 +1,11 @@ +// PR c++/63320 +// { dg-do compile { target c++11 } } + +class A { + static void addWindow(); + static void activateWindow(void *); +}; +void A::addWindow() { + int* action {}; + [action] { activateWindow(action); }; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this20.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this20.C new file mode 100644 index 0000000000..0d273202bf --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this20.C @@ -0,0 +1,4 @@ +// PR c++/63601 +// { dg-do compile { target c++11 } } + +auto f = []{ sizeof(this); }; // { dg-error "this" } diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept15.C b/gcc/testsuite/g++.dg/cpp0x/noexcept15.C index 909ee9748b..5cbbea8a91 100644 --- a/gcc/testsuite/g++.dg/cpp0x/noexcept15.C +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept15.C @@ -23,12 +23,10 @@ template<class Tp> return single<typename std::decay<Tp>::type>(x); } -class Blob; // { dg-error "forward declaration" } +class Blob; // { dg-message "forward declaration" } void foo(Blob *b) { make_single(*b); } - -// { dg-prune-output "include" } diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept23.C b/gcc/testsuite/g++.dg/cpp0x/noexcept23.C new file mode 100644 index 0000000000..5a01df46c6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept23.C @@ -0,0 +1,14 @@ +// PR c++/53025 +// { dg-do compile { target c++11 } } + +struct A { + A() noexcept {} + A(const A&) noexcept(false) {} +}; + +void a(A) noexcept {} + +void f() +{ + static_assert(!noexcept(a(A{})), ""); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept24.C b/gcc/testsuite/g++.dg/cpp0x/noexcept24.C new file mode 100644 index 0000000000..c17ddfa52a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept24.C @@ -0,0 +1,22 @@ +// PR c++/53025 +// { dg-do compile { target c++11 } } + +template<typename T> +struct A { + A() noexcept {} + A(const A&) noexcept(false) {} +}; + +template<typename T> +void a(A<T>) noexcept {} + +template<typename T> +void f() +{ + static_assert(!noexcept(a(A<T>{})), ""); +} + +void g() +{ + f<int>(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept25.C b/gcc/testsuite/g++.dg/cpp0x/noexcept25.C new file mode 100644 index 0000000000..e79b7863d7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept25.C @@ -0,0 +1,12 @@ +// PR c++/63194 +// { dg-do compile { target c++11 } } + +template <int> +class A { + public: + A() noexcept(noexcept(0)) = default; +}; +class B { + A<0> m_points; +}; +void fn1(A<0>, A<0>) { B(); } diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept26.C b/gcc/testsuite/g++.dg/cpp0x/noexcept26.C new file mode 100644 index 0000000000..7c8b4137b6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept26.C @@ -0,0 +1,11 @@ +// PR c++/55443 +// { dg-do compile { target c++11 } } + +struct X +{ + constexpr X() { } + + void* operator new(__SIZE_TYPE__, void*) noexcept; +}; + +int main() { noexcept(new(0) X); } diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept27.C b/gcc/testsuite/g++.dg/cpp0x/noexcept27.C new file mode 100644 index 0000000000..c44902d862 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept27.C @@ -0,0 +1,15 @@ +// PR c++/55443 +// { dg-do compile { target c++11 } } + +struct X +{ + X() = default; + + X(int); + + void* operator new(__SIZE_TYPE__, void*) noexcept; +}; + +X x; + +bool b = noexcept(new(0) X); diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-defer6.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-defer6.C index 033c14264d..0f06343958 100644 --- a/gcc/testsuite/g++.dg/cpp0x/nsdmi-defer6.C +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi-defer6.C @@ -1,8 +1,8 @@ // { dg-do compile { target c++11 } } -struct A // { dg-error "non-static data member" } +struct A { - int i = (A(), 42); // { dg-message "required here" } + int i = (A(), 42); // { dg-error "constructor required" } }; A a; diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-dr1397.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-dr1397.C new file mode 100644 index 0000000000..061af8b8c2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi-dr1397.C @@ -0,0 +1,7 @@ +// DR 1397 +// { dg-require-effective-target c++11 } + +struct A +{ + int i = sizeof(A{}); // { dg-error "" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-eh1.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-eh1.C index edcf5887db..9bc632c4bc 100644 --- a/gcc/testsuite/g++.dg/cpp0x/nsdmi-eh1.C +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi-eh1.C @@ -1,5 +1,5 @@ // Core issue 1351 -// { dg-do run { xfail *-*-* } } +// { dg-do run } // { dg-require-effective-target c++11 } bool fail; diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-template12.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-template12.C index 52ae257200..5b87f429e8 100644 --- a/gcc/testsuite/g++.dg/cpp0x/nsdmi-template12.C +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi-template12.C @@ -6,10 +6,10 @@ template <class T> struct X {X(std::initializer_list<int>) {}}; -template <class zomg> +template <class zomg> class T { - X<T> x{1}; -}; + X<T> x{1}; +}; int main() { diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-union5.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-union5.C index 57dfd59863..d521b3b762 100644 --- a/gcc/testsuite/g++.dg/cpp0x/nsdmi-union5.C +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi-union5.C @@ -1,6 +1,5 @@ // PR c++/58701 -// { dg-require-effective-target c++11 } -// { dg-final { scan-assembler "7" } } +// { dg-do run { target c++11 } } static union { @@ -9,3 +8,10 @@ static union int i = 7; }; }; + +extern "C" void abort(void); +int main() +{ + if (i != 7) abort(); + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-union6.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-union6.C new file mode 100644 index 0000000000..764fe21d61 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi-union6.C @@ -0,0 +1,56 @@ +// PR c++/58664 +// { dg-do compile { target c++11 } } + +struct F; // { dg-message "forward declaration" } + +union U // { dg-message "not complete" } +{ + U u[1] = { 0 }; // { dg-error "incomplete type" } +}; + +template<typename T> +union UT // { dg-message "not complete" } +{ + UT u[1] = { 0 }; // { dg-error "incomplete type" } +}; + +template union UT<int>; + +union UF +{ + F u[1] = { 0 }; // { dg-error "incomplete type" } +}; + +template<typename T> +union UFT +{ + F u[1] = { 0 }; // { dg-error "incomplete type" } +}; + +template union UFT<int>; + +struct S // { dg-message "not complete" } +{ + S s[1] = { 0 }; // { dg-error "incomplete type" } +}; + +template<typename T> +struct ST // { dg-message "not complete" } +{ + ST s[1] = { 0 }; // { dg-error "incomplete type" } +}; + +template class ST<int>; + +struct SF +{ + F s[1] = { 0 }; // { dg-error "incomplete type" } +}; + +template<typename T> +struct SFT +{ + F s[1] = { 0 }; // { dg-error "incomplete type" } +}; + +template class SFT<int>; diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi10.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi10.C new file mode 100644 index 0000000000..56f9ff08bd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi10.C @@ -0,0 +1,18 @@ +// PR c++/58328 +// { dg-do compile { target c++11 } } + +struct A1 { + struct B1 { + int y1 = 1; + }; + + A1(const B1& opts = B1()) {} // { dg-error "constructor" } +}; + +struct A2 { + struct B2 { + int x2, y2 = 1; + }; + + A2(const B2& opts = B2()) {} // { dg-error "constructor" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi3.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi3.C index a8e8cdf2fe..d2e7439248 100644 --- a/gcc/testsuite/g++.dg/cpp0x/nsdmi3.C +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi3.C @@ -10,9 +10,9 @@ struct B { A a1 = 1; // { dg-error "" } A a2 { 2 }; - A a3 = { 3 }; // { dg-error "" } + A a3 = { 3 }; // { dg-error "explicit" } }; constexpr B b; // { dg-error "B::B" } -// { dg-message "a1. is invalid" "" { target *-*-* } 11 } +// { dg-prune-output "B::a1" } diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi6.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi6.C index e78f50019a..f88a347426 100644 --- a/gcc/testsuite/g++.dg/cpp0x/nsdmi6.C +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi6.C @@ -4,5 +4,5 @@ struct A { typedef int int T; // { dg-error "two or more data types in declaration" } - struct T x[1] = { 0 }; // { dg-error "invalid|forward" } + struct T x[1] = { 0 }; // { dg-error "incomplete type|forward" } }; diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi7.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi7.C index 4b08474aaf..e378360a75 100644 --- a/gcc/testsuite/g++.dg/cpp0x/nsdmi7.C +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi7.C @@ -11,6 +11,7 @@ struct A struct B { + virtual void g(); const int d; // { dg-warning "non-static const member" } int &e; // { dg-warning "non-static reference" } int f = 7; diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr06.C b/gcc/testsuite/g++.dg/cpp0x/nullptr06.C index e933c35287..396ac3a1fd 100644 --- a/gcc/testsuite/g++.dg/cpp0x/nullptr06.C +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr06.C @@ -4,7 +4,7 @@ #define assert_true(b) do { char c[2 * bool(b) - 1]; } while(0) -char* const cp1 = nullptr; +constexpr char* cp1 = nullptr; void fun() { diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr17.C b/gcc/testsuite/g++.dg/cpp0x/nullptr17.C index 96fea44b22..616cd67581 100644 --- a/gcc/testsuite/g++.dg/cpp0x/nullptr17.C +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr17.C @@ -1,6 +1,7 @@ // { dg-do compile { target c++11 } } -// Test that bool is a better overload match than int +// Used to test that bool is a better overload match than int +// Updated for DR 1423 template <typename T, typename U> struct tType_equal; template <typename T> struct tType_equal<T, T> { typedef void type; }; @@ -16,7 +17,7 @@ bool i( bool ); void test_i() { // Overload to bool, not int - type_equal<bool>(i(nullptr)); + type_equal<bool>(i(nullptr)); // { dg-error "direct" } decltype(nullptr) mynull = 0; - type_equal<bool>(i(mynull)); + type_equal<bool>(i(mynull)); // { dg-error "direct" } } diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr19.C b/gcc/testsuite/g++.dg/cpp0x/nullptr19.C index 8b6a0b4289..17c4b7caa3 100644 --- a/gcc/testsuite/g++.dg/cpp0x/nullptr19.C +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr19.C @@ -11,7 +11,5 @@ nullptr_t k( nullptr_t ); /* { dg-message "note" } */ void test_k() { k(0); /* { dg-error "is ambiguous" } */ - // { dg-message "candidate" "candidate note" { target *-*-* } 13 } k(__null); /* { dg-error "is ambiguous" } */ - // { dg-message "candidate" "candidate note" { target *-*-* } 15 } } diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr31.C b/gcc/testsuite/g++.dg/cpp0x/nullptr31.C new file mode 100644 index 0000000000..01b8339b1c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr31.C @@ -0,0 +1,11 @@ +// DR 1423, PR c++/52174 +// { dg-do compile { target c++11 } } + +bool b1 = nullptr; // { dg-error "direct" } + +bool b2(nullptr); +bool b3{nullptr}; + +int i1 = nullptr; // { dg-error "cannot convert" } +int i2(nullptr); // { dg-error "cannot convert" } +int i3{nullptr}; // { dg-error "cannot convert" } diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr32.C b/gcc/testsuite/g++.dg/cpp0x/nullptr32.C new file mode 100644 index 0000000000..a1e6710fd8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr32.C @@ -0,0 +1,21 @@ +// PR c++/63942 +// A mangling alias for the first constructor was conflicting with the second. +// { dg-do compile { target c++11 } } +// { dg-options "-fno-inline" } + +int i; +template <class T> struct A +{ + A(const T&) { i = 42; } + A(const A&) { i = 36; } +}; + +typedef A<decltype(nullptr)> An; + +int main() +{ + An a (nullptr); + if (i != 42) __builtin_abort(); + An a2 (a); + if (i != 36) __builtin_abort(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr33.C b/gcc/testsuite/g++.dg/cpp0x/nullptr33.C new file mode 100644 index 0000000000..75c782ac8f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr33.C @@ -0,0 +1,19 @@ +// PR c++/63757 +// { dg-do compile { target c++11 } } + +typedef decltype(nullptr) nullptr_t; + +void bar(void*) {} + +struct foo +{ + operator nullptr_t() + { + return nullptr; + } +}; + +int main() +{ + bar(foo()); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/overload3.C b/gcc/testsuite/g++.dg/cpp0x/overload3.C index 2d957830c2..0eecabdecc 100644 --- a/gcc/testsuite/g++.dg/cpp0x/overload3.C +++ b/gcc/testsuite/g++.dg/cpp0x/overload3.C @@ -13,5 +13,5 @@ struct wrap int main() { wrap w; - f(w); // { dg-error "lvalue" } + f(w); // { dg-error "" } } diff --git a/gcc/testsuite/g++.dg/cpp0x/overloadn.C b/gcc/testsuite/g++.dg/cpp0x/overloadn.C index 16c39a9ed3..243f83be73 100644 --- a/gcc/testsuite/g++.dg/cpp0x/overloadn.C +++ b/gcc/testsuite/g++.dg/cpp0x/overloadn.C @@ -543,9 +543,9 @@ void ucr1111(const S&&) {} int main() { - l0001(l); // { dg-error "lvalue" } - l0010(l); // { dg-error "lvalue" } - l0011(l); // { dg-error "lvalue" } + l0001(l); // { dg-error "" } + l0010(l); // { dg-error "" } + l0011(l); // { dg-error "" } l0100(l); l0101(l); l0110(l); @@ -564,8 +564,8 @@ int main() cl0101(cl); cl0110(cl); cl0111(cl); - cl1001(cl); // { dg-error "lvalue" } - cl1011(cl); // { dg-error "lvalue" } + cl1001(cl); // { dg-error "" } + cl1011(cl); // { dg-error "" } cl1100(cl); cl1101(cl); cl1110(cl); @@ -617,8 +617,8 @@ int main() ncl0101(ncl); ncl0110(ncl); ncl0111(ncl); - ncl1001(ncl); // { dg-error "lvalue" } - ncl1011(ncl); // { dg-error "lvalue" } + ncl1001(ncl); // { dg-error "" } + ncl1011(ncl); // { dg-error "" } ncl1100(ncl); ncl1101(ncl); ncl1110(ncl); @@ -644,8 +644,8 @@ int main() ncr0101(ncr); ncr0110(ncr); ncr0111(ncr); - ncr1001(ncr); // { dg-error "lvalue" } - ncr1011(ncr); // { dg-error "lvalue" } + ncr1001(ncr); // { dg-error "" } + ncr1011(ncr); // { dg-error "" } ncr1100(ncr); ncr1101(ncr); ncr1110(ncr); @@ -671,8 +671,8 @@ int main() ucl0101(ucl()); ucl0110(ucl()); ucl0111(ucl()); - ucl1001(ucl()); // { dg-error "lvalue" } - ucl1011(ucl()); // { dg-error "lvalue" } + ucl1001(ucl()); // { dg-error "" } + ucl1011(ucl()); // { dg-error "" } ucl1100(ucl()); ucl1101(ucl()); ucl1110(ucl()); diff --git a/gcc/testsuite/g++.dg/cpp0x/override1.C b/gcc/testsuite/g++.dg/cpp0x/override1.C index e05693fc59..7686a286fc 100644 --- a/gcc/testsuite/g++.dg/cpp0x/override1.C +++ b/gcc/testsuite/g++.dg/cpp0x/override1.C @@ -4,8 +4,11 @@ struct B virtual void f() final {} virtual void g() {} virtual void x() const {} + virtual void y() final; }; +void B::y() {} // { dg-error "overriding" } + struct B2 { virtual void h() {} @@ -14,11 +17,12 @@ struct B2 struct D : B { virtual void g() override final {} // { dg-error "overriding" } + virtual void y() override final {} // { dg-error "virtual" } }; template <class T> struct D2 : T { - void h() override {} // { dg-error "marked override, but does not override" } + void h() override {} // { dg-error "marked 'override', but does not override" } }; template <class T> struct D3 : T @@ -38,20 +42,28 @@ struct B3 struct B4 { - void f() final {} // { dg-error "marked final, but is not virtual" } + void f() final {} // { dg-error "marked 'final', but is not virtual" } }; struct D5 : B { - void ff() override {} // { dg-error "marked override, but does not override" } - virtual void fff() override {} // { dg-error "marked override, but does not override" } - virtual void x() override {} // { dg-error "marked override, but does not override" } + void ff() override {} // { dg-error "marked 'override', but does not override" } + virtual void fff() override {} // { dg-error "marked 'override', but does not override" } + virtual void x() override {} // { dg-error "marked 'override', but does not override" } void g() override; }; void D5::g() override {} // { dg-error "not allowed outside a class definition" } void g() override {} // { dg-error "not allowed outside a class definition" } +struct B5 +{ + friend void f() final; // { dg-error "may not have virt-specifiers" } + friend void g() override; // { dg-error "may not have virt-specifiers" } + template <class T> void h() final; // { dg-error "may not have virt-specifiers" } + template <class T> void i() override; // { dg-error "may not have virt-specifiers" } +}; + int main() { D2<B> d; diff --git a/gcc/testsuite/g++.dg/cpp0x/pr31432.C b/gcc/testsuite/g++.dg/cpp0x/pr31432.C index 1f2ea50972..2048077c36 100644 --- a/gcc/testsuite/g++.dg/cpp0x/pr31432.C +++ b/gcc/testsuite/g++.dg/cpp0x/pr31432.C @@ -4,5 +4,5 @@ template<typename..., typename> struct A // { dg-error "parameter pack" } static int i; }; -A<int, int> a; // { dg-error "mismatch|expected|invalid type" } -A<char,int> b; // { dg-error "mismatch|expected|invalid type" } +A<int, int> a; +A<char,int> b; diff --git a/gcc/testsuite/g++.dg/cpp0x/pr31434.C b/gcc/testsuite/g++.dg/cpp0x/pr31434.C index e70bdd17e9..afb719f17c 100644 --- a/gcc/testsuite/g++.dg/cpp0x/pr31434.C +++ b/gcc/testsuite/g++.dg/cpp0x/pr31434.C @@ -8,5 +8,4 @@ template<typename... T> int foo(const T&) // { dg-error "not expanded with|T" } void bar() { foo(0); // { dg-error "no matching" } - // { dg-message "(candidate|cannot convert)" "candidate note" { target *-*-* } 10 } } diff --git a/gcc/testsuite/g++.dg/cpp0x/pr31437.C b/gcc/testsuite/g++.dg/cpp0x/pr31437.C index 5f7010fe6a..7e2ed7a137 100644 --- a/gcc/testsuite/g++.dg/cpp0x/pr31437.C +++ b/gcc/testsuite/g++.dg/cpp0x/pr31437.C @@ -7,4 +7,3 @@ template <typename... T> struct A // { dg-message "candidates|A" } }; A<int> a(0); // { dg-error "no matching" } -// { dg-message "candidate" "candidate note" { target *-*-* } 9 } diff --git a/gcc/testsuite/g++.dg/cpp0x/pr31442.C b/gcc/testsuite/g++.dg/cpp0x/pr31442.C index 7fd20e7ca5..b4c737c603 100644 --- a/gcc/testsuite/g++.dg/cpp0x/pr31442.C +++ b/gcc/testsuite/g++.dg/cpp0x/pr31442.C @@ -6,4 +6,4 @@ struct B template <template <typename...> class C> B(C<int>); }; -B b = A<int>(); // { dg-error "mismatch|expected" } +B b = A<int>(); diff --git a/gcc/testsuite/g++.dg/cpp0x/pr32115.C b/gcc/testsuite/g++.dg/cpp0x/pr32115.C index 5722aa3365..fafa4eed31 100644 --- a/gcc/testsuite/g++.dg/cpp0x/pr32115.C +++ b/gcc/testsuite/g++.dg/cpp0x/pr32115.C @@ -1,4 +1,4 @@ // { dg-do compile { target c++11 } } template<typename ...T, int = 0> struct A {}; // { dg-error "end of" } -A<int> a; // { dg-error "mismatch|expected|invalid" } +A<int> a; diff --git a/gcc/testsuite/g++.dg/cpp0x/pr48453.C b/gcc/testsuite/g++.dg/cpp0x/pr48453.C new file mode 100644 index 0000000000..b0c3da51d6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr48453.C @@ -0,0 +1,22 @@ +// PR c++/48453, DR 1287 +// { dg-do compile { target c++11 } } + +template<class T> +T&& create(); + +template<class T, class Arg> +void test() { + T t(create<Arg>()); + (void) t; +} + +template<class T> +struct To { + explicit operator T(); +}; + +int main() +{ + test<int&, To<int&>>(); + test<int&&, To<int&&>>(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr51226.C b/gcc/testsuite/g++.dg/cpp0x/pr51226.C index 1e048ef2c5..7e52e93e21 100644 --- a/gcc/testsuite/g++.dg/cpp0x/pr51226.C +++ b/gcc/testsuite/g++.dg/cpp0x/pr51226.C @@ -1,7 +1,7 @@ // PR c++/51226 // { dg-do compile { target c++11 } } -template<int> struct A // { dg-error "provided" } +template<int> struct A // { dg-message "provided" } { enum E : int; }; diff --git a/gcc/testsuite/g++.dg/cpp0x/pr54377.C b/gcc/testsuite/g++.dg/cpp0x/pr54377.C new file mode 100644 index 0000000000..07ebd092a0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr54377.C @@ -0,0 +1,7 @@ +// PR c++/54377 +// { dg-do compile { target c++11 } } + +template <typename, typename, typename = void, typename...> +struct foo {}; // { dg-message "provided for" } + +foo<int> f; // { dg-error "at least 2" } diff --git a/gcc/testsuite/g++.dg/cpp0x/pr57101.C b/gcc/testsuite/g++.dg/cpp0x/pr57101.C index 94b576f4b8..c0fc966272 100644 --- a/gcc/testsuite/g++.dg/cpp0x/pr57101.C +++ b/gcc/testsuite/g++.dg/cpp0x/pr57101.C @@ -1,7 +1,7 @@ // { dg-do compile { target c++11 } } // { dg-options "-fcompare-debug" } -typedef long unsigned size_t; +typedef __SIZE_TYPE__ size_t; namespace { template < typename _Tp, _Tp __v > struct integral_constant diff --git a/gcc/testsuite/g++.dg/cpp0x/pr57543-1.C b/gcc/testsuite/g++.dg/cpp0x/pr57543-1.C new file mode 100644 index 0000000000..d77d71e8bd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr57543-1.C @@ -0,0 +1,13 @@ +// DR 1227, PR c++/57543 +// { dg-do compile { target c++11 } } + +template <class T> struct A { using X = typename T::X; }; // { dg-error "not a class" } +template <class T> typename T::X f(typename A<T>::X); +template <class T> void f(...) { } +template <class T> auto g(typename A<T>::X) -> typename T::X; // { dg-message "required" } +template <class T> void g(...) { } + +void h() { + f<int>(0); // OK + g<int>(0); // { dg-message "required" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr57543-2.C b/gcc/testsuite/g++.dg/cpp0x/pr57543-2.C new file mode 100644 index 0000000000..7afa7fe491 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr57543-2.C @@ -0,0 +1,17 @@ +// DR 1227, PR c++/57543 +// { dg-do compile { target c++11 } } + +struct S +{ + template <class T> struct A { using X = typename T::X; }; // { dg-error "not a class" } + template <class T> typename T::X f(typename A<T>::X); + template <class T> void f(...) { } + template <class T> auto g(typename A<T>::X) -> typename T::X; // { dg-message "required" } + template <class T> void g(...) { } + + void h() + { + f<int>(0); // OK + g<int>(0); // { dg-message "required" } + } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/pr57543-3.C b/gcc/testsuite/g++.dg/cpp0x/pr57543-3.C new file mode 100644 index 0000000000..b77fefc8c1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr57543-3.C @@ -0,0 +1,20 @@ +// DR 1227, PR c++/57543 +// { dg-do compile { target c++11 } } + +template <class> +class C +{ + template <class T> struct A { using X = typename T::X; }; // { dg-error "not a class" } + template <class T> typename T::X f(typename A<T>::X); + template <class T> void f(...) { } + template <class T> auto g(typename A<T>::X) -> typename T::X; // { dg-message "required" } + template <class T> void g(...) { } + + void h() + { + f<int>(0); // OK + g<int>(0); // { dg-message "required" } + } +}; + +template class C<int>; // { dg-message "required" } diff --git a/gcc/testsuite/g++.dg/cpp0x/pr57958.C b/gcc/testsuite/g++.dg/cpp0x/pr57958.C new file mode 100644 index 0000000000..d35f9edf2a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr57958.C @@ -0,0 +1,39 @@ +// { dg-do run { target c++11 } } + +#define assert(E) if(!(E))__builtin_abort(); + +int n = 0; + +template <class T> +class Foo { + public: + Foo() { + n--; + } + Foo(const Foo&) { + n--; + } + ~Foo() { + n++; + } +}; + +struct Data {}; + +void a() +{ + Data b; +} + +int main(int argc, char *argv[]) { + auto fn = [] (const Foo<Data>& x) { + return (x); + }; + + { + Foo<Data> a; + fn(a); + } + + assert(n == 0); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr59111.C b/gcc/testsuite/g++.dg/cpp0x/pr59111.C index 4e48854418..62d8e8f86e 100644 --- a/gcc/testsuite/g++.dg/cpp0x/pr59111.C +++ b/gcc/testsuite/g++.dg/cpp0x/pr59111.C @@ -1,5 +1,5 @@ // PR c++/59111 // { dg-do compile { target c++11 } } -auto& foo(); // { dg-error "type specifier without trailing return type" "" { target { ! c++1y } } } +auto& foo(); // { dg-error "type specifier without trailing return type" "" { target { ! c++14 } } } int i = foo(); // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/cpp0x/pr59816.C b/gcc/testsuite/g++.dg/cpp0x/pr59816.C new file mode 100644 index 0000000000..42153252b8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr59816.C @@ -0,0 +1,19 @@ +// PR c++/59816 +// { dg-do compile { target c++11 } } + +class Base { +protected: + template<class... TArgs> + Base(TArgs...) {} +}; + +class Class + : public Base { +public: + template<class... TArgs> + Class(TArgs... args) : Base { args... } {} +}; + +void test() { + Class{}; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr60209-neg.C b/gcc/testsuite/g++.dg/cpp0x/pr60209-neg.C new file mode 100644 index 0000000000..77fd3d8169 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr60209-neg.C @@ -0,0 +1,28 @@ +// PR c++/60209 +// { dg-do compile { target c++11 } } + +// http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1473 + +void operator "" "boo" _ya(unsigned long long); // { dg-error "expected empty string after" } + +void operator "" "boo"_ya(unsigned long long); // { dg-error "expected empty string after" } + +void operator "" u"" _u(unsigned long long); // { dg-error "invalid encoding prefix in literal operator" } + +void operator u"" "" _v(unsigned long long); // { dg-error "invalid encoding prefix in literal operator" } + +void operator U"" "" _w(unsigned long long); // { dg-error "invalid encoding prefix in literal operator" } + +void operator L"" "" _x(unsigned long long); // { dg-error "invalid encoding prefix in literal operator" } + +void operator u8"" "" _y(unsigned long long); // { dg-error "invalid encoding prefix in literal operator" } + +void operator u"" L"" _z(unsigned long long); // { dg-error "unsupported non-standard concatenation of string literals" } + +void operator ""_p ""_q(unsigned long long); // { dg-error "inconsistent user-defined literal suffixes" } + +void operator "" "" while(unsigned long long); // { dg-error "unexpected keyword; remove space between quotes and suffix identifier" } + +void operator "" ""(unsigned long long); // { dg-error "expected suffix identifier" } + +// { dg-error "invalid encoding prefix in literal operator" "invalid" { target *-*-* } 20 } diff --git a/gcc/testsuite/g++.dg/cpp0x/pr60209.C b/gcc/testsuite/g++.dg/cpp0x/pr60209.C new file mode 100644 index 0000000000..6ed26e9bcc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr60209.C @@ -0,0 +1,12 @@ +// PR c++/60209 +// { dg-do compile { target c++11 } } + +// http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1473 + +void operator "" "" _x(unsigned long long); + +void operator "" "" "" _x(unsigned long long); + +void operator "" ""_w(unsigned long long); + +void operator "" ""_w ""(unsigned long long); diff --git a/gcc/testsuite/g++.dg/cpp0x/pr60249.C b/gcc/testsuite/g++.dg/cpp0x/pr60249.C index e650dcb452..35dd459e8c 100644 --- a/gcc/testsuite/g++.dg/cpp0x/pr60249.C +++ b/gcc/testsuite/g++.dg/cpp0x/pr60249.C @@ -2,5 +2,3 @@ // { dg-do compile { target c++11 } } decltype(""_) x; // { dg-error "unable to find string literal operator" } - -// { dg-error "invalid type in declaration before" "invalid" { target *-*-* } 4 } diff --git a/gcc/testsuite/g++.dg/cpp0x/pr61038.C b/gcc/testsuite/g++.dg/cpp0x/pr61038.C new file mode 100644 index 0000000000..6c7a47bae7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr61038.C @@ -0,0 +1,40 @@ +// PR c++/61038 +// { dg-do compile { target c++11 } } + +#include <cstring> +#include <cstdlib> + +void +operator "" _s(const char *, size_t) +{ } + +void +operator "" _t(const char) +{ } + +#define QUOTE(s) #s +#define QQUOTE(s) QUOTE(s) + +int +main() +{ + const char *s = QQUOTE(QUOTE("hello"_s)); + const char *t = QUOTE("\"hello\"_s"); + if (strcmp(s, t) != 0) + abort(); + + const char *c = QQUOTE(QUOTE('"'_t)); + const char *d = QUOTE("'\"'_t"); + if (strcmp(c, d) != 0) + abort(); + + const char *e = QQUOTE(QUOTE('\''_t)); + const char *f = QUOTE("'\\''_t"); + if (strcmp(e, f) != 0) + abort(); + + const char *g = QQUOTE(QUOTE('\\'_t)); + const char *h = QUOTE("'\\\\'_t"); + if (strcmp(g, h) != 0) + abort(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr61924.C b/gcc/testsuite/g++.dg/cpp0x/pr61924.C new file mode 100644 index 0000000000..7730f897e6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr61924.C @@ -0,0 +1,17 @@ +// PR c++/61924 +// { dg-do compile { target c++11 } } + +struct function +{ + template < typename _Functor > function (_Functor); // { dg-error "never defined" } +}; + +template < typename > struct RetryingRpc +{ + template < typename StubType> RetryingRpc (StubType, function =[]{}); +}; + +void fn() +{ + RetryingRpc<int> rpc(0, []{}); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr62024.C b/gcc/testsuite/g++.dg/cpp0x/pr62024.C new file mode 100644 index 0000000000..5f0640ac12 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr62024.C @@ -0,0 +1,7 @@ +// PR c/62024 +// { dg-do compile { target c++11 } } +// { dg-require-effective-target sync_char_short } + +int *p; +static_assert (__atomic_always_lock_free (1, p), ""); +static_assert (__atomic_always_lock_free (1, 0), ""); diff --git a/gcc/testsuite/g++.dg/cpp0x/pr62101.C b/gcc/testsuite/g++.dg/cpp0x/pr62101.C new file mode 100644 index 0000000000..2c05dd5b1a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr62101.C @@ -0,0 +1,32 @@ +// PR c++/62101 +// { dg-do compile { target c++11 } } + +struct X +{ + friend void g(X, int) = 0; // { dg-error "initializer specified for friend function" } + friend void g(X, int) = default; // { dg-error "cannot be defaulted" } + // { dg-prune-output "note" } + friend void f(X, int) = delete; + friend void f(X, double) {} +}; + +struct Y; +void g(Y, int); +void g(Y, double); + +struct Y +{ + // { dg-prune-output "note" } + friend void g(Y, int) = delete; + friend void g(Y, double) {} +}; + +int main() +{ + X x; + f(x, 5.0); + f(x, 5); // { dg-error "use of deleted function" } + Y y; + g(y, 5.0); + g(y, 5); // { dg-error "use of deleted function" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr63904.C b/gcc/testsuite/g++.dg/cpp0x/pr63904.C new file mode 100644 index 0000000000..14f03031a9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr63904.C @@ -0,0 +1,14 @@ +// { dg-do compile { target c++11 } } +// { dg-options "-Wno-pedantic" } + +template<int N> +struct foo { + constexpr foo() : a() {} + int a[N]; +}; + +int main() { + foo< (foo<1>{}).a[0] > f; + return 0; +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/pr65072.C b/gcc/testsuite/g++.dg/cpp0x/pr65072.C new file mode 100644 index 0000000000..b8fa8885dc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr65072.C @@ -0,0 +1,14 @@ +// PR c++/65075 +// { dg-do compile { target c++11 } } +// { dg-options "-Wno-pedantic" } + +template <typename> class C +{ + struct + { + int i; + }; + auto operator*(const C m) -> decltype (m.i); +}; +void fn1 (const C<float>); +C<float> a; diff --git a/gcc/testsuite/g++.dg/cpp0x/pr65075.C b/gcc/testsuite/g++.dg/cpp0x/pr65075.C new file mode 100644 index 0000000000..7d953ff646 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr65075.C @@ -0,0 +1,17 @@ +// PR c++/65075 +// { dg-do compile { target c++11 } } + +typedef void (*E) (); +template <class T> +constexpr E +bar (bool a) +{ + return a ? []() {} : []() {}; +} + +void +foo () +{ + (bar<int> (false)) (); + (bar<int> (true)) (); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr65127.C b/gcc/testsuite/g++.dg/cpp0x/pr65127.C new file mode 100644 index 0000000000..2cdb8ee54d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr65127.C @@ -0,0 +1,16 @@ +// PR c++/65127 +// { dg-do compile { target c++11 } } + +template <int N> +void +foo () +{ + static int i {100}; + struct { int id {i++}; } j; +} + +int +main () +{ + foo<0> (); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr65327.C b/gcc/testsuite/g++.dg/cpp0x/pr65327.C new file mode 100644 index 0000000000..c6cefaba69 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr65327.C @@ -0,0 +1,18 @@ +// PR c++/65327 +// { dg-do compile { target c++11 } } +// DR1688 says that constexpr can be used together with volatile. + +constexpr volatile int i = 10; + +void +foo () +{ + constexpr volatile int j = 5; + static constexpr volatile int k = 5; +} + +constexpr volatile int +bar () +{ + return i; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr65398-2.C b/gcc/testsuite/g++.dg/cpp0x/pr65398-2.C new file mode 100644 index 0000000000..f920b03ded --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr65398-2.C @@ -0,0 +1,38 @@ +// PR c++/65398 +// { dg-do compile { target c++11 } } + +#define SA(X) static_assert((X),#X) + +constexpr char s[] = "abc"; + +SA((&s[0] + 0) == (&s[0] + 0)); +SA((&s[0] + 1) == (&s[1] + 0)); +SA((&s[0] + 2) == (&s[1] + 1)); +SA((&s[0] + 3) == (&s[1] + 2)); +SA((&s[0] + 4) == (&s[1] + 3)); +SA((&s[2] + 0) == (&s[0] + 2)); +SA((&s[2] + 1) == (&s[3] + 0)); +SA((&s[2] + 2) == (&s[3] + 1)); +SA((&s[4] + 0) == (&s[2] + 2)); + +SA((&s[0] + 0) != (&s[1] + 0)); +SA((&s[0] + 2) != (&s[1] + 0)); +SA((&s[2] + 0) != (&s[2] + 1)); +SA((&s[1] + 1) != (&s[0] + 1)); + +constexpr int l[] = { 'c', 'd', 'e', '\0' }; + +SA((&l[0] + 0) == (&l[0] + 0)); +SA((&l[0] + 1) == (&l[1] + 0)); +SA((&l[0] + 2) == (&l[1] + 1)); +SA((&l[0] + 3) == (&l[1] + 2)); +SA((&l[0] + 4) == (&l[1] + 3)); +SA((&l[2] + 0) == (&l[0] + 2)); +SA((&l[2] + 1) == (&l[3] + 0)); +SA((&l[2] + 2) == (&l[3] + 1)); +SA((&l[4] + 0) == (&l[2] + 2)); + +SA((&l[0] + 0) != (&l[1] + 0)); +SA((&l[0] + 2) != (&l[1] + 0)); +SA((&l[2] + 0) != (&l[2] + 1)); +SA((&l[1] + 1) != (&l[0] + 1)); diff --git a/gcc/testsuite/g++.dg/cpp0x/pr65398.C b/gcc/testsuite/g++.dg/cpp0x/pr65398.C new file mode 100644 index 0000000000..a4aeba580f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr65398.C @@ -0,0 +1,70 @@ +// PR c++/65398 +// { dg-do compile { target c++11 } } + +#define SA(X) static_assert((X),#X) + +constexpr char s[] = "abc"; +constexpr char c1 = *(&s[0] + 0); +constexpr char c2 = *(&s[0] + 1); +constexpr char c3 = *(&s[1] + 0); +constexpr char c4 = *(&s[1] + 1); +constexpr char c5 = *(&s[2] + 0); +constexpr char c6 = *(&s[0] + 2); +constexpr char c7 = *(&s[2] + 1); + +constexpr char d1 = *(&s[4] - 0); // { dg-error "array subscript out of bound" } +constexpr char d2 = *(&s[4] - 1); +constexpr char d3 = *(&s[4] - 2); +constexpr char d4 = *(&s[4] - 3); +constexpr char d5 = *(&s[4] - 4); +constexpr char d6 = *(&s[4] - 5); // { dg-error "negative array subscript" } + +/* Don't accept invalid stuff. */ +constexpr char e1 = *(&s[5] - 1); // { dg-error "is not a constant expression" } +constexpr char e2 = *(&s[5] - 2); // { dg-error "is not a constant expression" } +constexpr char e3 = *(&s[5] - 3); // { dg-error "is not a constant expression" } + +SA (c1 == 'a'); +SA (c2 == 'b'); +SA (c3 == 'b'); +SA (c4 == 'c'); +SA (c5 == 'c'); +SA (c6 == 'c'); +SA (c7 == '\0'); +SA (d2 == '\0'); +SA (d3 == 'c'); +SA (d4 == 'b'); +SA (d5 == 'a'); + +constexpr int l[] = { 'c', 'd', 'e', '\0' }; +constexpr int i1 = *(&l[0] + 0); +constexpr int i2 = *(&l[0] + 1); +constexpr int i3 = *(&l[1] + 0); +constexpr int i4 = *(&l[1] + 1); +constexpr int i5 = *(&l[2] + 0); +constexpr int i6 = *(&l[0] + 2); +constexpr int i7 = *(&l[2] + 1); + +constexpr char j1 = *(&l[4] - 0); // { dg-error "array subscript out of bound" } +constexpr char j2 = *(&l[4] - 1); +constexpr char j3 = *(&l[4] - 2); +constexpr char j4 = *(&l[4] - 3); +constexpr char j5 = *(&l[4] - 4); +constexpr char j6 = *(&l[4] - 5); // { dg-error "negative array subscript" } + +/* Don't accept invalid stuff. */ +constexpr char k1 = *(&l[5] - 1); // { dg-error "is not a constant expression" } +constexpr char k2 = *(&l[5] - 2); // { dg-error "is not a constant expression" } +constexpr char k3 = *(&l[5] - 3); // { dg-error "is not a constant expression" } + +SA (i1 == 'c'); +SA (i2 == 'd'); +SA (i3 == 'd'); +SA (i4 == 'e'); +SA (i5 == 'e'); +SA (i6 == 'e'); +SA (i7 == '\0'); +SA (j2 == '\0'); +SA (j3 == 'e'); +SA (j4 == 'd'); +SA (j5 == 'c'); diff --git a/gcc/testsuite/g++.dg/cpp0x/pr65558.C b/gcc/testsuite/g++.dg/cpp0x/pr65558.C new file mode 100644 index 0000000000..5437e509ed --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr65558.C @@ -0,0 +1,6 @@ +// PR c++/65558 +// { dg-do compile { target c++11 } } + +inline namespace __attribute__((__abi_tag__)) +{ // { dg-warning "ignoring .__abi_tag__. attribute on anonymous namespace" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr65736.C b/gcc/testsuite/g++.dg/cpp0x/pr65736.C new file mode 100644 index 0000000000..6e9c7fb990 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr65736.C @@ -0,0 +1,5 @@ +// PR c++/65736 +// { dg-do compile { target c++11 } } + +int a[1]; +char *b[1] { (char *)&a[0] + 1 }; diff --git a/gcc/testsuite/g++.dg/cpp0x/range-for29.C b/gcc/testsuite/g++.dg/cpp0x/range-for29.C new file mode 100644 index 0000000000..64ad950927 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/range-for29.C @@ -0,0 +1,13 @@ +// PR c++/63985 +// { dg-require-effective-target c++11 } + +void foo() +{ + int arr; + + for (int i = 5: arr) // { dg-error "initializer in range-based" } + ; + + for (int i, j: arr) // { dg-error "multiple declarations in range-based" } + ; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/range-for9.C b/gcc/testsuite/g++.dg/cpp0x/range-for9.C index c51cbf9946..6a50ec36c1 100644 --- a/gcc/testsuite/g++.dg/cpp0x/range-for9.C +++ b/gcc/testsuite/g++.dg/cpp0x/range-for9.C @@ -1,7 +1,6 @@ // Test for range-based for loop error in C++98 mode -// { dg-do compile } -// { dg-options "-std=c++98" } +// { dg-do compile { target { ! c++11 } } } void test() { diff --git a/gcc/testsuite/g++.dg/cpp0x/ref-qual16.C b/gcc/testsuite/g++.dg/cpp0x/ref-qual16.C new file mode 100644 index 0000000000..1d7650bb61 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/ref-qual16.C @@ -0,0 +1,12 @@ +// PR c++/64297 +// { dg-do compile { target c++11 } } + +struct A { + typedef int X; + template <int> X m_fn1() const; +}; +template <typename> struct is_function {}; +is_function<int() const &> i; +struct D { + template <typename Y, typename = is_function<Y>> D(Y); +} b(&A::m_fn1<0>); diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-cond2.C b/gcc/testsuite/g++.dg/cpp0x/rv-cond2.C new file mode 100644 index 0000000000..e231b11e1a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv-cond2.C @@ -0,0 +1,11 @@ +// { dg-do compile { target c++11 } } + +template <class T, class U> struct ST; +template <class T> struct ST<T,T> {}; + +int&& f(); +const int&& g(); + +void h(bool b) { + ST<decltype(b ? f() : g()),const int&&>(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-init1.C b/gcc/testsuite/g++.dg/cpp0x/rv-init1.C new file mode 100644 index 0000000000..2e8d4f748e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv-init1.C @@ -0,0 +1,26 @@ +// Core DR 1604/1571/1572 +// { dg-require-effective-target c++11 } + +struct Banana { }; +struct Enigma { operator const Banana(); }; +struct Doof { operator Banana&(); }; +void enigmatic() { + typedef const Banana ConstBanana; + Banana &&banana1 = ConstBanana(); // { dg-error "" } + Banana &&banana2 = Enigma(); // { dg-error "" } + Banana &&banana3 = Doof(); // { dg-error "" } +} + +class A { +public: + operator volatile int &(); +}; +A a; + +const int & ir1a = a.operator volatile int&(); // { dg-error "" } +const int & ir2a = a; // { dg-error "" } + +struct X { + operator int&(); +} x; +int&& rri2 = X(); // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-return.C b/gcc/testsuite/g++.dg/cpp0x/rv-return.C index 12a15aa30c..6d57209b54 100644 --- a/gcc/testsuite/g++.dg/cpp0x/rv-return.C +++ b/gcc/testsuite/g++.dg/cpp0x/rv-return.C @@ -1,5 +1,6 @@ // PR c++/41815 // { dg-do compile { target c++11 } } +// { dg-options "-fno-ipa-icf" } template<typename T, typename U> struct same_type; template<typename T> struct same_type<T, T> {}; diff --git a/gcc/testsuite/g++.dg/cpp0x/rv1n.C b/gcc/testsuite/g++.dg/cpp0x/rv1n.C index 9aa534a653..f5e7568175 100644 --- a/gcc/testsuite/g++.dg/cpp0x/rv1n.C +++ b/gcc/testsuite/g++.dg/cpp0x/rv1n.C @@ -1,8 +1,10 @@ // I, Howard Hinnant, hereby place this code in the public domain. +/* { dg-additional-options "-fno-ipa-icf" } */ // Test overload resolution among reference types // { dg-do compile { target c++11 } } +// { dg-additional-options "-fno-ipa-icf" } template <bool> struct sa; template <> struct sa<true> {}; @@ -37,13 +39,13 @@ int test1_1() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_1_1(ca); // { dg-error "invalid initialization" } - sink_1_1(va); // { dg-error "invalid initialization" } - sink_1_1(cva); // { dg-error "invalid initialization" } - sink_1_1(source()); // { dg-error "invalid initialization" } - sink_1_1(c_source()); // { dg-error "invalid initialization" } - sink_1_1(v_source()); // { dg-error "invalid initialization" } - sink_1_1(cv_source()); // { dg-error "invalid initialization" } + sink_1_1(ca); // { dg-error "" } + sink_1_1(va); // { dg-error "" } + sink_1_1(cva); // { dg-error "" } + sink_1_1(source()); // { dg-error "" } + sink_1_1(c_source()); // { dg-error "" } + sink_1_1(v_source()); // { dg-error "" } + sink_1_1(cv_source()); // { dg-error "" } return 0; } @@ -55,10 +57,10 @@ int test1_2() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_1_2(va); // { dg-error "invalid initialization" } - sink_1_2(cva); // { dg-error "invalid initialization" } - sink_1_2(v_source()); // { dg-error "invalid initialization" } - sink_1_2(cv_source()); // { dg-error "invalid initialization" } + sink_1_2(va); // { dg-error "" } + sink_1_2(cva); // { dg-error "" } + sink_1_2(v_source()); // { dg-error "" } + sink_1_2(cv_source()); // { dg-error "" } return 0; } @@ -70,12 +72,12 @@ int test1_3() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_1_3(ca); // { dg-error "invalid initialization" } - sink_1_3(cva); // { dg-error "invalid initialization" } - sink_1_3(source()); // { dg-error "invalid initialization" } - sink_1_3(c_source()); // { dg-error "invalid initialization" } - sink_1_3(v_source()); // { dg-error "invalid initialization" } - sink_1_3(cv_source()); // { dg-error "invalid initialization" } + sink_1_3(ca); // { dg-error "" } + sink_1_3(cva); // { dg-error "" } + sink_1_3(source()); // { dg-error "" } + sink_1_3(c_source()); // { dg-error "" } + sink_1_3(v_source()); // { dg-error "" } + sink_1_3(cv_source()); // { dg-error "" } return 0; } @@ -87,10 +89,10 @@ int test1_4() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_1_4(source()); // { dg-error "invalid initialization" } - sink_1_4(c_source()); // { dg-error "invalid initialization" } - sink_1_4(v_source()); // { dg-error "invalid initialization" } - sink_1_4(cv_source()); // { dg-error "invalid initialization" } + sink_1_4(source()); // { dg-error "" } + sink_1_4(c_source()); // { dg-error "" } + sink_1_4(v_source()); // { dg-error "" } + sink_1_4(cv_source()); // { dg-error "" } return 0; } @@ -103,12 +105,12 @@ int test1_5() volatile A va; const volatile A cva = a; // { dg-error "deleted" } sink_1_5(a); // { dg-error "lvalue" } - sink_1_5(ca); // { dg-error "invalid initialization" } - sink_1_5(va); // { dg-error "invalid initialization" } - sink_1_5(cva); // { dg-error "invalid initialization" } - sink_1_5(c_source()); // { dg-error "invalid initialization" } - sink_1_5(v_source()); // { dg-error "invalid initialization" } - sink_1_5(cv_source()); // { dg-error "invalid initialization" } + sink_1_5(ca); // { dg-error "" } + sink_1_5(va); // { dg-error "" } + sink_1_5(cva); // { dg-error "" } + sink_1_5(c_source()); // { dg-error "" } + sink_1_5(v_source()); // { dg-error "" } + sink_1_5(cv_source()); // { dg-error "" } return 0; } @@ -122,10 +124,10 @@ int test1_6() const volatile A cva = a; // { dg-error "deleted" } sink_1_6(a); // { dg-error "lvalue" } sink_1_6(ca); // { dg-error "lvalue" } - sink_1_6(va); // { dg-error "invalid initialization" } - sink_1_6(cva); // { dg-error "invalid initialization" } - sink_1_6(v_source()); // { dg-error "invalid initialization" } - sink_1_6(cv_source()); // { dg-error "invalid initialization" } + sink_1_6(va); // { dg-error "" } + sink_1_6(cva); // { dg-error "" } + sink_1_6(v_source()); // { dg-error "" } + sink_1_6(cv_source()); // { dg-error "" } return 0; } @@ -138,11 +140,11 @@ int test1_7() volatile A va; const volatile A cva = a; // { dg-error "deleted" } sink_1_7(a); // { dg-error "lvalue" } - sink_1_7(ca); // { dg-error "invalid initialization" } + sink_1_7(ca); // { dg-error "" } sink_1_7(va); // { dg-error "lvalue" } - sink_1_7(cva); // { dg-error "invalid initialization" } - sink_1_7(c_source()); // { dg-error "invalid initialization" } - sink_1_7(cv_source()); // { dg-error "invalid initialization" } + sink_1_7(cva); // { dg-error "" } + sink_1_7(c_source()); // { dg-error "" } + sink_1_7(cv_source()); // { dg-error "" } return 0; } diff --git a/gcc/testsuite/g++.dg/cpp0x/rv1p.C b/gcc/testsuite/g++.dg/cpp0x/rv1p.C index e4c0ab16dd..e87ec0e91f 100644 --- a/gcc/testsuite/g++.dg/cpp0x/rv1p.C +++ b/gcc/testsuite/g++.dg/cpp0x/rv1p.C @@ -4,6 +4,7 @@ // { dg-do compile { target c++11 } } // { dg-skip-if "packed attribute missing for struct one/three/five/seven" { "epiphany-*-*" } { "*" } { "" } } +// { dg-additional-options "-fno-ipa-icf" } template <bool> struct sa; template <> struct sa<true> {}; diff --git a/gcc/testsuite/g++.dg/cpp0x/rv2n.C b/gcc/testsuite/g++.dg/cpp0x/rv2n.C index 289cffb181..663a66b6d9 100644 --- a/gcc/testsuite/g++.dg/cpp0x/rv2n.C +++ b/gcc/testsuite/g++.dg/cpp0x/rv2n.C @@ -3,7 +3,7 @@ // Test overload resolution among reference types // { dg-do compile { target c++11 } } -// { dg-options "" } +// { dg-options "-fno-ipa-icf" } template <bool> struct sa; template <> struct sa<true> {}; @@ -30,8 +30,8 @@ const volatile A cv_source(); // 2 at a time -one sink_2_12( A&); // { dg-message "note|argument" } -two sink_2_12(const A&); // { dg-message "note|argument" } +one sink_2_12( A&); +two sink_2_12(const A&); int test2_12() { @@ -39,19 +39,15 @@ int test2_12() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_2_12(va); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 42 } - sink_2_12(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 44 } - sink_2_12(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 46 } - sink_2_12(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 48 } + sink_2_12(va); // { dg-error "" } + sink_2_12(cva); // { dg-error "" } + sink_2_12(v_source()); // { dg-error "" } + sink_2_12(cv_source()); // { dg-error "" } return 0; } -one sink_2_13( A&); // { dg-message "note|argument" } -three sink_2_13(volatile A&); // { dg-message "note|argument" } +one sink_2_13( A&); +three sink_2_13(volatile A&); int test2_13() { @@ -59,23 +55,17 @@ int test2_13() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_2_13(ca); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 62 } - sink_2_13(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 64 } - sink_2_13(source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 66 } - sink_2_13(c_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 68 } - sink_2_13(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 70 } - sink_2_13(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 72 } + sink_2_13(ca); // { dg-error "" } + sink_2_13(cva); // { dg-error "" } + sink_2_13(source()); // { dg-error "" } + sink_2_13(c_source()); // { dg-error "" } + sink_2_13(v_source()); // { dg-error "" } + sink_2_13(cv_source()); // { dg-error "" } return 0; } -one sink_2_14( A&); // { dg-message "note|argument" } -four sink_2_14(const volatile A&); // { dg-message "note|argument" } +one sink_2_14( A&); +four sink_2_14(const volatile A&); int test2_14() { @@ -83,19 +73,15 @@ int test2_14() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_2_14(source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 86 } - sink_2_14(c_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 88 } - sink_2_14(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 90 } - sink_2_14(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 92 } + sink_2_14(source()); // { dg-error "" } + sink_2_14(c_source()); // { dg-error "" } + sink_2_14(v_source()); // { dg-error "" } + sink_2_14(cv_source()); // { dg-error "" } return 0; } -one sink_2_15( A&); // { dg-message "note|argument" } -five sink_2_15( A&&); // { dg-message "note|argument" } +one sink_2_15( A&); +five sink_2_15( A&&); int test2_15() { @@ -103,23 +89,17 @@ int test2_15() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_2_15(ca); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 106 } - sink_2_15(va); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 108 } - sink_2_15(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 110 } - sink_2_15(c_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 112 } - sink_2_15(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 114 } - sink_2_15(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 116 } + sink_2_15(ca); // { dg-error "" } + sink_2_15(va); // { dg-error "" } + sink_2_15(cva); // { dg-error "" } + sink_2_15(c_source()); // { dg-error "" } + sink_2_15(v_source()); // { dg-error "" } + sink_2_15(cv_source()); // { dg-error "" } return 0; } -one sink_2_16( A&); // { dg-message "note|argument" } -six sink_2_16(const A&&); // { dg-message "note|argument" } +one sink_2_16( A&); +six sink_2_16(const A&&); int test2_16() { @@ -127,20 +107,16 @@ int test2_16() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_2_16(ca); // { dg-error "lvalue" } - sink_2_16(va); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 131 } - sink_2_16(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 133 } - sink_2_16(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 135 } - sink_2_16(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 137 } + sink_2_16(ca); // { dg-error "" } + sink_2_16(va); // { dg-error "" } + sink_2_16(cva); // { dg-error "" } + sink_2_16(v_source()); // { dg-error "" } + sink_2_16(cv_source()); // { dg-error "" } return 0; } -one sink_2_17( A&); // { dg-message "note|argument" } -seven sink_2_17(volatile A&&); // { dg-message "note|argument" } +one sink_2_17( A&); +seven sink_2_17(volatile A&&); int test2_17() { @@ -148,20 +124,16 @@ int test2_17() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_2_17(ca); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 151 } - sink_2_17(va); // { dg-error "lvalue" } - sink_2_17(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 154 } - sink_2_17(c_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 156 } - sink_2_17(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 158 } + sink_2_17(ca); // { dg-error "" } + sink_2_17(va); // { dg-error "" } + sink_2_17(cva); // { dg-error "" } + sink_2_17(c_source()); // { dg-error "" } + sink_2_17(cv_source()); // { dg-error "" } return 0; } one sink_2_18( A&); -eight sink_2_18(const volatile A&&); // { dg-message "argument" } +eight sink_2_18(const volatile A&&); int test2_18() { @@ -169,13 +141,13 @@ int test2_18() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_2_18(ca); // { dg-error "lvalue" } - sink_2_18(va); // { dg-error "lvalue" } - sink_2_18(cva); // { dg-error "lvalue" } + sink_2_18(ca); // { dg-error "" } + sink_2_18(va); // { dg-error "" } + sink_2_18(cva); // { dg-error "" } } -two sink_2_23(const A&); // { dg-message "note|argument" } -three sink_2_23(volatile A&); // { dg-message "note|argument" } +two sink_2_23(const A&); +three sink_2_23(volatile A&); int test2_23() { @@ -184,18 +156,14 @@ int test2_23() volatile A va; const volatile A cva = a; // { dg-error "deleted" } sink_2_23(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 186 } - sink_2_23(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 188 } - sink_2_23(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 190 } - sink_2_23(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 192 } + sink_2_23(cva); // { dg-error "" } + sink_2_23(v_source()); // { dg-error "" } + sink_2_23(cv_source()); // { dg-error "" } return 0; } -two sink_2_24(const A&); // { dg-message "note|argument" } -four sink_2_24(const volatile A&); // { dg-message "note|argument" } +two sink_2_24(const A&); +four sink_2_24(const volatile A&); int test2_24() { @@ -203,15 +171,13 @@ int test2_24() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_2_24(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 206 } - sink_2_24(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 208 } + sink_2_24(v_source()); // { dg-error "" } + sink_2_24(cv_source()); // { dg-error "" } return 0; } -three sink_2_34(volatile A&); // { dg-message "three sink_2_34|no known conversion" } -four sink_2_34(const volatile A&); // { dg-message "note|argument" } +three sink_2_34(volatile A&); +four sink_2_34(const volatile A&); int test2_34() { @@ -219,19 +185,15 @@ int test2_34() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_2_34(source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 222 } - sink_2_34(c_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 224 } - sink_2_34(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 226 } - sink_2_34(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 228 } + sink_2_34(source()); // { dg-error "" } + sink_2_34(c_source()); // { dg-error "" } + sink_2_34(v_source()); // { dg-error "" } + sink_2_34(cv_source()); // { dg-error "" } return 0; } -two sink_2_25(const A&); // { dg-message "two sink_2_25|no known conversion" } -five sink_2_25( A&&); // { dg-message "note|argument" } +two sink_2_25(const A&); +five sink_2_25( A&&); int test2_25() { @@ -239,19 +201,15 @@ int test2_25() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_2_25(va); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 242 } - sink_2_25(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 244 } - sink_2_25(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 246 } - sink_2_25(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 248 } + sink_2_25(va); // { dg-error "" } + sink_2_25(cva); // { dg-error "" } + sink_2_25(v_source()); // { dg-error "" } + sink_2_25(cv_source()); // { dg-error "" } return 0; } -two sink_2_26(const A&); // { dg-message "two sink_2_26|no known conversion" } -six sink_2_26(const A&&); // { dg-message "note|argument" } +two sink_2_26(const A&); +six sink_2_26(const A&&); int test2_26() { @@ -259,19 +217,15 @@ int test2_26() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_2_26(va); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 262 } - sink_2_26(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 264 } - sink_2_26(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 266 } - sink_2_26(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 268 } + sink_2_26(va); // { dg-error "" } + sink_2_26(cva); // { dg-error "" } + sink_2_26(v_source()); // { dg-error "" } + sink_2_26(cv_source()); // { dg-error "" } return 0; } -two sink_2_27(const A&); // { dg-message "two sink_2_27|no known conversion" } -seven sink_2_27(volatile A&&); // { dg-message "note|argument" } +two sink_2_27(const A&); +seven sink_2_27(volatile A&&); int test2_27() { @@ -279,16 +233,14 @@ int test2_27() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_2_27(va); // { dg-error "lvalue" } - sink_2_27(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 283 } - sink_2_27(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 285 } + sink_2_27(va); // { dg-error "" } + sink_2_27(cva); // { dg-error "" } + sink_2_27(cv_source()); // { dg-error "" } return 0; } two sink_2_28(const A&); -eight sink_2_28(const volatile A&&); // { dg-message "argument" } +eight sink_2_28(const volatile A&&); int test2_28() { @@ -296,12 +248,12 @@ int test2_28() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_2_28(va); // { dg-error "lvalue" } - sink_2_28(cva); // { dg-error "lvalue" } + sink_2_28(va); // { dg-error "" } + sink_2_28(cva); // { dg-error "" } } -three sink_2_35(volatile A&); // { dg-message "three sink_2_35|no known conversion" } -five sink_2_35( A&&); // { dg-message "note|argument" } +three sink_2_35(volatile A&); +five sink_2_35( A&&); int test2_35() { @@ -309,21 +261,16 @@ int test2_35() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_2_35(ca); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 312 } - sink_2_35(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 314 } - sink_2_35(c_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 316 } - sink_2_35(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 318 } - sink_2_35(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 320 } + sink_2_35(ca); // { dg-error "" } + sink_2_35(cva); // { dg-error "" } + sink_2_35(c_source()); // { dg-error "" } + sink_2_35(v_source()); // { dg-error "" } + sink_2_35(cv_source()); // { dg-error "" } return 0; } -three sink_2_36(volatile A&); // { dg-message "three sink_2_36|no known conversion" } -six sink_2_36(const A&&); // { dg-message "note|argument" } +three sink_2_36(volatile A&); +six sink_2_36(const A&&); int test2_36() { @@ -331,18 +278,15 @@ int test2_36() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_2_36(ca); // { dg-error "lvalue" } - sink_2_36(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 335 } - sink_2_36(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 337 } - sink_2_36(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 339 } + sink_2_36(ca); // { dg-error "" } + sink_2_36(cva); // { dg-error "" } + sink_2_36(v_source()); // { dg-error "" } + sink_2_36(cv_source()); // { dg-error "" } return 0; } -three sink_2_37(volatile A&); // { dg-message "three sink_2_37|no known conversion" } -seven sink_2_37(volatile A&&); // { dg-message "note|argument" } +three sink_2_37(volatile A&); +seven sink_2_37(volatile A&&); int test2_37() { @@ -350,19 +294,15 @@ int test2_37() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_2_37(ca); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 353 } - sink_2_37(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 355 } - sink_2_37(c_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 357 } - sink_2_37(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 359 } + sink_2_37(ca); // { dg-error "" } + sink_2_37(cva); // { dg-error "" } + sink_2_37(c_source()); // { dg-error "" } + sink_2_37(cv_source()); // { dg-error "" } return 0; } three sink_2_38(volatile A&); -eight sink_2_38(const volatile A&&); // { dg-message "argument" } +eight sink_2_38(const volatile A&&); int test2_38() { @@ -370,12 +310,12 @@ int test2_38() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_2_38(ca); // { dg-error "lvalue" } - sink_2_38(cva); // { dg-error "lvalue" } + sink_2_38(ca); // { dg-error "" } + sink_2_38(cva); // { dg-error "" } } -four sink_2_45(const volatile A&); // { dg-message "note" } -five sink_2_45( A&&); // { dg-message "note|argument" } +four sink_2_45(const volatile A&); +five sink_2_45( A&&); int test2_45() { @@ -383,17 +323,14 @@ int test2_45() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_2_45(c_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 386 } - sink_2_45(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 388 } - sink_2_45(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 390 } + sink_2_45(c_source()); // { dg-error "" } + sink_2_45(v_source()); // { dg-error "" } + sink_2_45(cv_source()); // { dg-error "" } return 0; } -four sink_2_46(const volatile A&); // { dg-message "note" } -six sink_2_46(const A&&); // { dg-message "note|argument" } +four sink_2_46(const volatile A&); +six sink_2_46(const A&&); int test2_46() { @@ -401,15 +338,13 @@ int test2_46() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_2_46(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 404 } - sink_2_46(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 406 } + sink_2_46(v_source()); // { dg-error "" } + sink_2_46(cv_source()); // { dg-error "" } return 0; } -four sink_2_47(const volatile A&); // { dg-message "note" } -seven sink_2_47(volatile A&&); // { dg-message "note|argument" } +four sink_2_47(const volatile A&); +seven sink_2_47(volatile A&&); int test2_47() { @@ -417,15 +352,13 @@ int test2_47() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_2_47(c_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 420 } - sink_2_47(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 422 } + sink_2_47(c_source()); // { dg-error "" } + sink_2_47(cv_source()); // { dg-error "" } return 0; } -five sink_2_56( A&&); // { dg-message "note|argument" } -six sink_2_56(const A&&); // { dg-message "note|argument" } +five sink_2_56( A&&); +six sink_2_56(const A&&); int test2_56() { @@ -433,21 +366,17 @@ int test2_56() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_2_56(a); // { dg-error "lvalue" } - sink_2_56(ca); // { dg-error "lvalue" } - sink_2_56(va); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 438 } - sink_2_56(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 440 } - sink_2_56(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 442 } - sink_2_56(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 444 } + sink_2_56(a); // { dg-error "" } + sink_2_56(ca); // { dg-error "" } + sink_2_56(va); // { dg-error "" } + sink_2_56(cva); // { dg-error "" } + sink_2_56(v_source()); // { dg-error "" } + sink_2_56(cv_source()); // { dg-error "" } return 0; } -five sink_2_57( A&&); // { dg-message "note|argument" } -seven sink_2_57(volatile A&&); // { dg-message "note|argument" } +five sink_2_57( A&&); +seven sink_2_57(volatile A&&); int test2_57() { @@ -455,21 +384,17 @@ int test2_57() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_2_57(a); // { dg-error "lvalue" } - sink_2_57(va); // { dg-error "lvalue" } - sink_2_57(ca); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 460 } - sink_2_57(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 462 } - sink_2_57(c_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 464 } - sink_2_57(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 466 } + sink_2_57(a); // { dg-error "" } + sink_2_57(va); // { dg-error "" } + sink_2_57(ca); // { dg-error "" } + sink_2_57(cva); // { dg-error "" } + sink_2_57(c_source()); // { dg-error "" } + sink_2_57(cv_source()); // { dg-error "" } return 0; } -five sink_2_58( A&&); // { dg-message "argument" } -eight sink_2_58(const volatile A&&); // { dg-message "argument" } +five sink_2_58( A&&); +eight sink_2_58(const volatile A&&); int test2_58() { @@ -477,14 +402,14 @@ int test2_58() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_2_58(a); // { dg-error "lvalue" } - sink_2_58(ca); // { dg-error "lvalue" } - sink_2_58(va); // { dg-error "lvalue" } - sink_2_58(cva); // { dg-error "lvalue" } + sink_2_58(a); // { dg-error "" } + sink_2_58(ca); // { dg-error "" } + sink_2_58(va); // { dg-error "" } + sink_2_58(cva); // { dg-error "" } } -six sink_2_67(const A&&); // { dg-message "note|argument" } -seven sink_2_67(volatile A&&); // { dg-message "note|argument" } +six sink_2_67(const A&&); +seven sink_2_67(volatile A&&); int test2_67() { @@ -492,21 +417,17 @@ int test2_67() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_2_67(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 495 } - sink_2_67(ca); // { dg-error "lvalue" } - sink_2_67(va); // { dg-error "lvalue" } - sink_2_67(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 499 } - sink_2_67(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 501 } - sink_2_67(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 503 } + sink_2_67(a); // { dg-error "" } + sink_2_67(ca); // { dg-error "" } + sink_2_67(va); // { dg-error "" } + sink_2_67(cva); // { dg-error "" } + sink_2_67(source()); // { dg-error "" } + sink_2_67(cv_source()); // { dg-error "" } return 0; } -six sink_2_68(const A&&); // { dg-message "argument" } -eight sink_2_68(const volatile A&&); // { dg-message "argument" } +six sink_2_68(const A&&); +eight sink_2_68(const volatile A&&); int test2_68() { @@ -514,14 +435,14 @@ int test2_68() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_2_68(a); // { dg-error "lvalue" } - sink_2_68(ca); // { dg-error "lvalue" } - sink_2_68(va); // { dg-error "lvalue" } - sink_2_68(cva); // { dg-error "lvalue" } + sink_2_68(a); // { dg-error "" } + sink_2_68(ca); // { dg-error "" } + sink_2_68(va); // { dg-error "" } + sink_2_68(cva); // { dg-error "" } } -seven sink_2_78(volatile A&&); // { dg-message "argument" } -eight sink_2_78(const volatile A&&); // { dg-message "argument" } +seven sink_2_78(volatile A&&); +eight sink_2_78(const volatile A&&); int test2_78() { @@ -529,10 +450,10 @@ int test2_78() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_2_78(a); // { dg-error "lvalue" } - sink_2_78(ca); // { dg-error "lvalue" } - sink_2_78(va); // { dg-error "lvalue" } - sink_2_78(cva); // { dg-error "lvalue" } + sink_2_78(a); // { dg-error "" } + sink_2_78(ca); // { dg-error "" } + sink_2_78(va); // { dg-error "" } + sink_2_78(cva); // { dg-error "" } } int main() diff --git a/gcc/testsuite/g++.dg/cpp0x/rv3n.C b/gcc/testsuite/g++.dg/cpp0x/rv3n.C index 765dfbc7f2..b7c1d7a234 100644 --- a/gcc/testsuite/g++.dg/cpp0x/rv3n.C +++ b/gcc/testsuite/g++.dg/cpp0x/rv3n.C @@ -3,7 +3,7 @@ // Test overload resolution among reference types // { dg-do compile { target c++11 } } -// { dg-options "" } +// { dg-options "-fno-ipa-icf" } template <bool> struct sa; template <> struct sa<true> {}; @@ -30,9 +30,9 @@ const volatile A cv_source(); // 3 at a time -one sink_3_123( A&); // { dg-message "one sink_3_123|no known conversion" } -two sink_3_123(const A&); // { dg-message "two sink_3_123|no known conversion" } -three sink_3_123(volatile A&); // { dg-message "three sink_3_123|no known conversion" } +one sink_3_123( A&); +two sink_3_123(const A&); +three sink_3_123(volatile A&); int test3_123() { @@ -40,22 +40,19 @@ int test3_123() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_123(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 43 } - sink_3_123(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 45 } - sink_3_123(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 47 } + sink_3_123(cva); // { dg-error "" } + sink_3_123(v_source()); // { dg-error "" } + sink_3_123(cv_source()); // { dg-error "" } return 0; } -one sink_3_125( A&); // { dg-message "one sink_3_125|no known conversion" } -two sink_3_125(const A&); // { dg-message "two sink_3_125|no known conversion" } -five sink_3_125( A&&); // { dg-message "five sink_3_125|no known conversion" } +one sink_3_125( A&); +two sink_3_125(const A&); +five sink_3_125( A&&); -one sink_3_124( A&); // { dg-message "one sink_3_124|no known conversion" } -two sink_3_124(const A&); // { dg-message "two sink_3_124|no known conversion" } -four sink_3_124(const volatile A&); // { dg-message "four sink_3_124|no known conversion" } +one sink_3_124( A&); +two sink_3_124(const A&); +four sink_3_124(const volatile A&); int test3_124() { @@ -63,10 +60,8 @@ int test3_124() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_124(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 66 } - sink_3_124(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 68 } + sink_3_124(v_source()); // { dg-error "" } + sink_3_124(cv_source()); // { dg-error "" } return 0; } @@ -76,20 +71,16 @@ int test3_125() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_125(va); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 79 } - sink_3_125(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 81 } - sink_3_125(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 83 } - sink_3_125(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 85 } + sink_3_125(va); // { dg-error "" } + sink_3_125(cva); // { dg-error "" } + sink_3_125(v_source()); // { dg-error "" } + sink_3_125(cv_source()); // { dg-error "" } return 0; } -one sink_3_126( A&); // { dg-message "one sink_3_126|no known conversion" } -two sink_3_126(const A&); // { dg-message "two sink_3_126|no known conversion" } -six sink_3_126(const A&&); // { dg-message "six sink_3_126|no known conversion" } +one sink_3_126( A&); +two sink_3_126(const A&); +six sink_3_126(const A&&); int test3_126() { @@ -97,20 +88,16 @@ int test3_126() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_126(va); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 100 } - sink_3_126(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 102 } - sink_3_126(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 104 } - sink_3_126(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 106 } + sink_3_126(va); // { dg-error "" } + sink_3_126(cva); // { dg-error "" } + sink_3_126(v_source()); // { dg-error "" } + sink_3_126(cv_source()); // { dg-error "" } return 0; } -one sink_3_127( A&); // { dg-message "one sink_3_127|no known conversion" } -two sink_3_127(const A&); // { dg-message "two sink_3_127|no known conversion" } -seven sink_3_127(volatile A&&); // { dg-message "seven sink_3_127|no known conversion" } +one sink_3_127( A&); +two sink_3_127(const A&); +seven sink_3_127(volatile A&&); int test3_127() { @@ -118,17 +105,15 @@ int test3_127() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_127(va); // { dg-error "lvalue" } - sink_3_127(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 122 } - sink_3_127(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 124 } + sink_3_127(va); // { dg-error "" } + sink_3_127(cva); // { dg-error "" } + sink_3_127(cv_source()); // { dg-error "" } return 0; } one sink_3_128( A&); two sink_3_128(const A&); -eight sink_3_128(const volatile A&&); // { dg-message "" } +eight sink_3_128(const volatile A&&); int test3_128() { @@ -137,13 +122,13 @@ int test3_128() volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_128(va); // { dg-error "lvalue" } - sink_3_128(cva); // { dg-error "lvalue" } + sink_3_128(va); // { dg-error "" } + sink_3_128(cva); // { dg-error "" } } -one sink_3_134( A&); // { dg-message "one sink_3_134|no known conversion" } -three sink_3_134(volatile A&); // { dg-message "three sink_3_134|no known conversion" } -four sink_3_134(const volatile A&); // { dg-message "four sink_3_134|no known conversion" } +one sink_3_134( A&); +three sink_3_134(volatile A&); +four sink_3_134(const volatile A&); int test3_134() { @@ -151,20 +136,16 @@ int test3_134() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_134(source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 154 } - sink_3_134(c_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 156 } - sink_3_134(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 158 } - sink_3_134(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 160 } + sink_3_134(source()); // { dg-error "" } + sink_3_134(c_source()); // { dg-error "" } + sink_3_134(v_source()); // { dg-error "" } + sink_3_134(cv_source()); // { dg-error "" } return 0; } -one sink_3_135( A&); // { dg-message "one sink_3_135|no known conversion" } -three sink_3_135(volatile A&); // { dg-message "three sink_3_135|no known conversion" } -five sink_3_135( A&&); // { dg-message "five sink_3_135|no known conversion" } +one sink_3_135( A&); +three sink_3_135(volatile A&); +five sink_3_135( A&&); int test3_135() { @@ -172,22 +153,17 @@ int test3_135() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_135(ca); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 175 } - sink_3_135(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 177 } - sink_3_135(c_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 179 } - sink_3_135(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 181 } - sink_3_135(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 183 } + sink_3_135(ca); // { dg-error "" } + sink_3_135(cva); // { dg-error "" } + sink_3_135(c_source()); // { dg-error "" } + sink_3_135(v_source()); // { dg-error "" } + sink_3_135(cv_source()); // { dg-error "" } return 0; } -one sink_3_136( A&); // { dg-message "one sink_3_136|no known conversion" } -three sink_3_136(volatile A&); // { dg-message "note" } -six sink_3_136(const A&&); // { dg-message "" } +one sink_3_136( A&); +three sink_3_136(volatile A&); +six sink_3_136(const A&&); int test3_136() { @@ -195,19 +171,16 @@ int test3_136() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_136(ca); // { dg-error "lvalue" } - sink_3_136(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 199 } - sink_3_136(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 201 } - sink_3_136(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 203 } + sink_3_136(ca); // { dg-error "" } + sink_3_136(cva); // { dg-error "" } + sink_3_136(v_source()); // { dg-error "" } + sink_3_136(cv_source()); // { dg-error "" } return 0; } -one sink_3_137( A&); // { dg-message "one sink_3_137|no known conversion" } -three sink_3_137(volatile A&); // { dg-message "note" } -seven sink_3_137(volatile A&&); // { dg-message "note" } +one sink_3_137( A&); +three sink_3_137(volatile A&); +seven sink_3_137(volatile A&&); int test3_137() { @@ -215,20 +188,16 @@ int test3_137() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_137(ca); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 218 } - sink_3_137(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 220 } - sink_3_137(c_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 222 } - sink_3_137(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 224 } + sink_3_137(ca); // { dg-error "" } + sink_3_137(cva); // { dg-error "" } + sink_3_137(c_source()); // { dg-error "" } + sink_3_137(cv_source()); // { dg-error "" } return 0; } one sink_3_138( A&); three sink_3_138(volatile A&); -eight sink_3_138(const volatile A&&); // { dg-message "" } +eight sink_3_138(const volatile A&&); int test3_138() { @@ -236,14 +205,14 @@ int test3_138() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_138(ca); // { dg-error "lvalue" } - sink_3_138(cva); // { dg-error "lvalue" } + sink_3_138(ca); // { dg-error "" } + sink_3_138(cva); // { dg-error "" } return 0; } -one sink_3_145( A&); // { dg-message "one sink_3_145|no known conversion" } -four sink_3_145(const volatile A&); // { dg-message "note" } -five sink_3_145( A&&); // { dg-message "note" } +one sink_3_145( A&); +four sink_3_145(const volatile A&); +five sink_3_145( A&&); int test3_145() { @@ -251,18 +220,15 @@ int test3_145() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_145(c_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 254 } - sink_3_145(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 256 } - sink_3_145(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 258 } + sink_3_145(c_source()); // { dg-error "" } + sink_3_145(v_source()); // { dg-error "" } + sink_3_145(cv_source()); // { dg-error "" } return 0; } -one sink_3_146( A&); // { dg-message "one sink_3_146|no known conversion" } -four sink_3_146(const volatile A&); // { dg-message "note" } -six sink_3_146(const A&&); // { dg-message "note" } +one sink_3_146( A&); +four sink_3_146(const volatile A&); +six sink_3_146(const A&&); int test3_146() { @@ -270,16 +236,14 @@ int test3_146() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_146(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 273 } - sink_3_146(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 275 } + sink_3_146(v_source()); // { dg-error "" } + sink_3_146(cv_source()); // { dg-error "" } return 0; } -one sink_3_147( A&); // { dg-message "one sink_3_147|no known conversion" } -four sink_3_147(const volatile A&); // { dg-message "note" } -seven sink_3_147(volatile A&&); // { dg-message "note" } +one sink_3_147( A&); +four sink_3_147(const volatile A&); +seven sink_3_147(volatile A&&); int test3_147() { @@ -287,16 +251,14 @@ int test3_147() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_147(c_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 290 } - sink_3_147(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 292 } + sink_3_147(c_source()); // { dg-error "" } + sink_3_147(cv_source()); // { dg-error "" } return 0; } -one sink_3_156( A&); // { dg-message "one sink_3_156|no known conversion" } -five sink_3_156( A&&); // { dg-message "note" } -six sink_3_156(const A&&); // { dg-message "" } +one sink_3_156( A&); +five sink_3_156( A&&); +six sink_3_156(const A&&); int test3_156() { @@ -304,21 +266,17 @@ int test3_156() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_156(ca); // { dg-error "lvalue" } - sink_3_156(va); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 308 } - sink_3_156(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 310 } - sink_3_156(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 312 } - sink_3_156(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 314 } + sink_3_156(ca); // { dg-error "" } + sink_3_156(va); // { dg-error "" } + sink_3_156(cva); // { dg-error "" } + sink_3_156(v_source()); // { dg-error "" } + sink_3_156(cv_source()); // { dg-error "" } return 0; } -one sink_3_157( A&); // { dg-message "one sink_3_157|no known conversion" } -five sink_3_157( A&&); // { dg-message "note" } -seven sink_3_157(volatile A&&); // { dg-message "" } +one sink_3_157( A&); +five sink_3_157( A&&); +seven sink_3_157(volatile A&&); int test3_157() { @@ -326,21 +284,17 @@ int test3_157() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_157(ca); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 329 } - sink_3_157(va); // { dg-error "lvalue" } - sink_3_157(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 332 } - sink_3_157(c_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 334 } - sink_3_157(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 336 } + sink_3_157(ca); // { dg-error "" } + sink_3_157(va); // { dg-error "" } + sink_3_157(cva); // { dg-error "" } + sink_3_157(c_source()); // { dg-error "" } + sink_3_157(cv_source()); // { dg-error "" } return 0; } one sink_3_158( A&); five sink_3_158( A&&); -eight sink_3_158(const volatile A&&); // { dg-message "" } +eight sink_3_158(const volatile A&&); int test3_158() { @@ -348,15 +302,15 @@ int test3_158() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_158(ca); // { dg-error "lvalue" } - sink_3_158(va); // { dg-error "lvalue" } - sink_3_158(cva); // { dg-error "lvalue" } + sink_3_158(ca); // { dg-error "" } + sink_3_158(va); // { dg-error "" } + sink_3_158(cva); // { dg-error "" } return 0; } -one sink_3_167( A&); // { dg-message "one sink_3_167|no known conversion" } -six sink_3_167(const A&&); // { dg-message "" } -seven sink_3_167(volatile A&&); // { dg-message "" } +one sink_3_167( A&); +six sink_3_167(const A&&); +seven sink_3_167(volatile A&&); int test3_167() { @@ -364,20 +318,17 @@ int test3_167() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_167(ca); // { dg-error "lvalue" } - sink_3_167(va); // { dg-error "lvalue" } - sink_3_167(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 369 } - sink_3_167(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 371 } - sink_3_167(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 373 } + sink_3_167(ca); // { dg-error "" } + sink_3_167(va); // { dg-error "" } + sink_3_167(cva); // { dg-error "" } + sink_3_167(source()); // { dg-error "" } + sink_3_167(cv_source()); // { dg-error "" } return 0; } one sink_3_168( A&); -six sink_3_168(const A&&); // { dg-message "" } -eight sink_3_168(const volatile A&&); // { dg-message "" } +six sink_3_168(const A&&); +eight sink_3_168(const volatile A&&); int test3_168() { @@ -385,15 +336,15 @@ int test3_168() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_168(ca); // { dg-error "lvalue" } - sink_3_168(va); // { dg-error "lvalue" } - sink_3_168(cva); // { dg-error "lvalue" } + sink_3_168(ca); // { dg-error "" } + sink_3_168(va); // { dg-error "" } + sink_3_168(cva); // { dg-error "" } return 0; } one sink_3_178( A&); -seven sink_3_178(volatile A&&); // { dg-message "" } -eight sink_3_178(const volatile A&&); // { dg-message "" } +seven sink_3_178(volatile A&&); +eight sink_3_178(const volatile A&&); int test3_178() { @@ -401,15 +352,15 @@ int test3_178() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_178(ca); // { dg-error "lvalue" } - sink_3_178(va); // { dg-error "lvalue" } - sink_3_178(cva); // { dg-error "lvalue" } + sink_3_178(ca); // { dg-error "" } + sink_3_178(va); // { dg-error "" } + sink_3_178(cva); // { dg-error "" } return 0; } -two sink_3_234(const A&); // { dg-message "two sink_3_234|no known conversion" } -three sink_3_234(volatile A&); // { dg-message "note" } -four sink_3_234(const volatile A&); // { dg-message "note" } +two sink_3_234(const A&); +three sink_3_234(volatile A&); +four sink_3_234(const volatile A&); int test3_234() { @@ -417,18 +368,15 @@ int test3_234() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_234(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 420 } - sink_3_234(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 422 } - sink_3_234(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 424 } + sink_3_234(a); // { dg-error "" } + sink_3_234(v_source()); // { dg-error "" } + sink_3_234(cv_source()); // { dg-error "" } return 0; } -two sink_3_235(const A&); // { dg-message "two sink_3_235|no known conversion" } -three sink_3_235(volatile A&); // { dg-message "note" } -five sink_3_235( A&&); // { dg-message "note" } +two sink_3_235(const A&); +three sink_3_235(volatile A&); +five sink_3_235( A&&); int test3_235() { @@ -436,20 +384,16 @@ int test3_235() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_235(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 439 } - sink_3_235(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 441 } - sink_3_235(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 443 } - sink_3_235(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 445 } + sink_3_235(a); // { dg-error "" } + sink_3_235(cva); // { dg-error "" } + sink_3_235(v_source()); // { dg-error "" } + sink_3_235(cv_source()); // { dg-error "" } return 0; } -two sink_3_236(const A&); // { dg-message "two sink_3_236|no known conversion" } -three sink_3_236(volatile A&); // { dg-message "note" } -six sink_3_236(const A&&); // { dg-message "note" } +two sink_3_236(const A&); +three sink_3_236(volatile A&); +six sink_3_236(const A&&); int test3_236() { @@ -457,20 +401,16 @@ int test3_236() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_236(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 460 } - sink_3_236(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 462 } - sink_3_236(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 464 } - sink_3_236(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 466 } + sink_3_236(a); // { dg-error "" } + sink_3_236(cva); // { dg-error "" } + sink_3_236(v_source()); // { dg-error "" } + sink_3_236(cv_source()); // { dg-error "" } return 0; } -two sink_3_237(const A&); // { dg-message "two sink_3_237|no known conversion" } -three sink_3_237(volatile A&); // { dg-message "note" } -seven sink_3_237(volatile A&&); // { dg-message "note" } +two sink_3_237(const A&); +three sink_3_237(volatile A&); +seven sink_3_237(volatile A&&); int test3_237() { @@ -478,18 +418,15 @@ int test3_237() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_237(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 481 } - sink_3_237(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 483 } - sink_3_237(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 485 } + sink_3_237(a); // { dg-error "" } + sink_3_237(cva); // { dg-error "" } + sink_3_237(cv_source()); // { dg-error "" } return 0; } -two sink_3_238(const A&); // { dg-message "two sink_3_238|no known conversion" } -three sink_3_238(volatile A&); // { dg-message "three sink_3_238|no known conversion" } -eight sink_3_238(const volatile A&&); // { dg-message "eight sink_3_238|no known conversion" } +two sink_3_238(const A&); +three sink_3_238(volatile A&); +eight sink_3_238(const volatile A&&); int test3_238() { @@ -497,15 +434,14 @@ int test3_238() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_238(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 500 } - sink_3_238(cva); // { dg-error "lvalue" } + sink_3_238(a); // { dg-error "" } + sink_3_238(cva); // { dg-error "" } return 0; } -two sink_3_245(const A&); // { dg-message "two sink_3_245|no known conversion" } -four sink_3_245(const volatile A&); // { dg-message "four sink_3_245|no known conversion" } -five sink_3_245( A&&); // { dg-message "five sink_3_245|no known conversion" } +two sink_3_245(const A&); +four sink_3_245(const volatile A&); +five sink_3_245( A&&); int test3_245() { @@ -513,16 +449,14 @@ int test3_245() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_245(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 516 } - sink_3_245(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 518 } + sink_3_245(v_source()); // { dg-error "" } + sink_3_245(cv_source()); // { dg-error "" } return 0; } -two sink_3_246(const A&); // { dg-message "two sink_3_246|no known conversion" } -four sink_3_246(const volatile A&); // { dg-message "four sink_3_246|no known conversion" } -six sink_3_246(const A&&); // { dg-message "six sink_3_246|no known conversion" } +two sink_3_246(const A&); +four sink_3_246(const volatile A&); +six sink_3_246(const A&&); int test3_246() { @@ -530,16 +464,14 @@ int test3_246() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_246(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 533 } - sink_3_246(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 535 } + sink_3_246(v_source()); // { dg-error "" } + sink_3_246(cv_source()); // { dg-error "" } return 0; } -two sink_3_247(const A&); // { dg-message "two sink_3_247|no known conversion" } -four sink_3_247(const volatile A&); // { dg-message "four sink_3_247|no known conversion" } -seven sink_3_247(volatile A&&); // { dg-message "seven sink_3_247|no known conversion" } +two sink_3_247(const A&); +four sink_3_247(const volatile A&); +seven sink_3_247(volatile A&&); int test3_247() { @@ -547,14 +479,13 @@ int test3_247() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_247(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 550 } + sink_3_247(cv_source()); // { dg-error "" } return 0; } -two sink_3_256(const A&); // { dg-message "two sink_3_256|no known conversion" } -five sink_3_256( A&&); // { dg-message "five sink_3_256|no known conversion" } -six sink_3_256(const A&&); // { dg-message "six sink_3_256|no known conversion" } +two sink_3_256(const A&); +five sink_3_256( A&&); +six sink_3_256(const A&&); int test3_256() { @@ -562,20 +493,16 @@ int test3_256() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_256(va); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 565 } - sink_3_256(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 567 } - sink_3_256(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 569 } - sink_3_256(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 571 } + sink_3_256(va); // { dg-error "" } + sink_3_256(cva); // { dg-error "" } + sink_3_256(v_source()); // { dg-error "" } + sink_3_256(cv_source()); // { dg-error "" } return 0; } -two sink_3_257(const A&); // { dg-message "two sink_3_257|no known conversion" } -five sink_3_257( A&&); // { dg-message "five sink_3_257|no known conversion" } -seven sink_3_257(volatile A&&); // { dg-message "seven sink_3_257|no known conversion" } +two sink_3_257(const A&); +five sink_3_257( A&&); +seven sink_3_257(volatile A&&); int test3_257() { @@ -583,17 +510,15 @@ int test3_257() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_257(va); // { dg-error "lvalue" } - sink_3_257(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 587 } - sink_3_257(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 589 } + sink_3_257(va); // { dg-error "" } + sink_3_257(cva); // { dg-error "" } + sink_3_257(cv_source()); // { dg-error "" } return 0; } two sink_3_258(const A&); five sink_3_258( A&&); -eight sink_3_258(const volatile A&&); // { dg-message "" } +eight sink_3_258(const volatile A&&); int test3_258() { @@ -601,14 +526,14 @@ int test3_258() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_258(va); // { dg-error "lvalue" } - sink_3_258(cva); // { dg-error "lvalue" } + sink_3_258(va); // { dg-error "" } + sink_3_258(cva); // { dg-error "" } return 0; } -two sink_3_267(const A&); // { dg-message "two sink_3_267|no known conversion" } -six sink_3_267(const A&&); // { dg-message "six sink_3_267|no known conversion" } -seven sink_3_267(volatile A&&); // { dg-message "seven sink_3_267|no known conversion" } +two sink_3_267(const A&); +six sink_3_267(const A&&); +seven sink_3_267(volatile A&&); int test3_267() { @@ -616,19 +541,16 @@ int test3_267() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_267(va); // { dg-error "lvalue" } - sink_3_267(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 620 } - sink_3_267(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 622 } - sink_3_267(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 624 } + sink_3_267(va); // { dg-error "" } + sink_3_267(cva); // { dg-error "" } + sink_3_267(source()); // { dg-error "" } + sink_3_267(cv_source()); // { dg-error "" } return 0; } two sink_3_268(const A&); six sink_3_268(const A&&); -eight sink_3_268(const volatile A&&); // { dg-message "" } +eight sink_3_268(const volatile A&&); int test3_268() { @@ -636,14 +558,14 @@ int test3_268() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_268(va); // { dg-error "lvalue" } - sink_3_268(cva); // { dg-error "lvalue" } + sink_3_268(va); // { dg-error "" } + sink_3_268(cva); // { dg-error "" } return 0; } two sink_3_278(const A&); -seven sink_3_278(volatile A&&); // { dg-message "" } -eight sink_3_278(const volatile A&&); // { dg-message "" } +seven sink_3_278(volatile A&&); +eight sink_3_278(const volatile A&&); int test3_278() { @@ -651,14 +573,14 @@ int test3_278() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_278(va); // { dg-error "lvalue" } - sink_3_278(cva); // { dg-error "lvalue" } + sink_3_278(va); // { dg-error "" } + sink_3_278(cva); // { dg-error "" } return 0; } -three sink_3_345(volatile A&); // { dg-message "three sink_3_345|no known conversion" } -four sink_3_345(const volatile A&); // { dg-message "four sink_3_345|no known conversion" } -five sink_3_345( A&&); // { dg-message "five sink_3_345|no known conversion" } +three sink_3_345(volatile A&); +four sink_3_345(const volatile A&); +five sink_3_345( A&&); int test3_345() { @@ -666,18 +588,15 @@ int test3_345() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_345(c_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 669 } - sink_3_345(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 671 } - sink_3_345(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 673 } + sink_3_345(c_source()); // { dg-error "" } + sink_3_345(v_source()); // { dg-error "" } + sink_3_345(cv_source()); // { dg-error "" } return 0; } -three sink_3_346(volatile A&); // { dg-message "three sink_3_346|no known conversion" } -four sink_3_346(const volatile A&); // { dg-message "four sink_3_346|no known conversion" } -six sink_3_346(const A&&); // { dg-message "six sink_3_346|no known conversion" } +three sink_3_346(volatile A&); +four sink_3_346(const volatile A&); +six sink_3_346(const A&&); int test3_346() { @@ -685,16 +604,14 @@ int test3_346() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_346(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 688 } - sink_3_346(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 690 } + sink_3_346(v_source()); // { dg-error "" } + sink_3_346(cv_source()); // { dg-error "" } return 0; } -three sink_3_347(volatile A&); // { dg-message "three sink_3_347|no known conversion" } -four sink_3_347(const volatile A&); // { dg-message "four sink_3_347|no known conversion" } -seven sink_3_347(volatile A&&); // { dg-message "seven sink_3_347|no known conversion" } +three sink_3_347(volatile A&); +four sink_3_347(const volatile A&); +seven sink_3_347(volatile A&&); int test3_347() { @@ -702,16 +619,14 @@ int test3_347() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_347(c_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 705 } - sink_3_347(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 707 } + sink_3_347(c_source()); // { dg-error "" } + sink_3_347(cv_source()); // { dg-error "" } return 0; } -three sink_3_356(volatile A&); // { dg-message "three sink_3_356|no known conversion" } -five sink_3_356( A&&); // { dg-message "five sink_3_356|no known conversion" } -six sink_3_356(const A&&); // { dg-message "six sink_3_356|no known conversion" } +three sink_3_356(volatile A&); +five sink_3_356( A&&); +six sink_3_356(const A&&); int test3_356() { @@ -719,19 +634,16 @@ int test3_356() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_356(ca); // { dg-error "lvalue" } - sink_3_356(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 723 } - sink_3_356(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 725 } - sink_3_356(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 727 } + sink_3_356(ca); // { dg-error "" } + sink_3_356(cva); // { dg-error "" } + sink_3_356(v_source()); // { dg-error "" } + sink_3_356(cv_source()); // { dg-error "" } return 0; } -three sink_3_357(volatile A&); // { dg-message "three sink_3_357|no known conversion" } -five sink_3_357( A&&); // { dg-message "five sink_3_357|no known conversion" } -seven sink_3_357(volatile A&&); // { dg-message "seven sink_3_357|no known conversion" } +three sink_3_357(volatile A&); +five sink_3_357( A&&); +seven sink_3_357(volatile A&&); int test3_357() { @@ -739,20 +651,16 @@ int test3_357() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_357(ca); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 742 } - sink_3_357(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 744 } - sink_3_357(c_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 746 } - sink_3_357(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 748 } + sink_3_357(ca); // { dg-error "" } + sink_3_357(cva); // { dg-error "" } + sink_3_357(c_source()); // { dg-error "" } + sink_3_357(cv_source()); // { dg-error "" } return 0; } three sink_3_358(volatile A&); five sink_3_358( A&&); -eight sink_3_358(const volatile A&&); // { dg-message "" } +eight sink_3_358(const volatile A&&); int test3_358() { @@ -760,14 +668,14 @@ int test3_358() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_358(ca); // { dg-error "lvalue" } - sink_3_358(cva); // { dg-error "lvalue" } + sink_3_358(ca); // { dg-error "" } + sink_3_358(cva); // { dg-error "" } return 0; } -three sink_3_367(volatile A&); // { dg-message "three sink_3_367|no known conversion" } -six sink_3_367(const A&&); // { dg-message "six sink_3_367|no known conversion" } -seven sink_3_367(volatile A&&); // { dg-message "seven sink_3_367|no known conversion" } +three sink_3_367(volatile A&); +six sink_3_367(const A&&); +seven sink_3_367(volatile A&&); int test3_367() { @@ -775,19 +683,16 @@ int test3_367() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_367(ca); // { dg-error "lvalue" } - sink_3_367(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 779 } - sink_3_367(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 781 } - sink_3_367(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 783 } + sink_3_367(ca); // { dg-error "" } + sink_3_367(cva); // { dg-error "" } + sink_3_367(source()); // { dg-error "" } + sink_3_367(cv_source()); // { dg-error "" } return 0; } three sink_3_368(volatile A&); -six sink_3_368(const A&&); // { dg-message "" } -eight sink_3_368(const volatile A&&); // { dg-message "" } +six sink_3_368(const A&&); +eight sink_3_368(const volatile A&&); int test3_368() { @@ -795,14 +700,14 @@ int test3_368() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_368(ca); // { dg-error "lvalue" } - sink_3_368(cva); // { dg-error "lvalue" } + sink_3_368(ca); // { dg-error "" } + sink_3_368(cva); // { dg-error "" } return 0; } three sink_3_378(volatile A&); seven sink_3_378(volatile A&&); -eight sink_3_378(const volatile A&&); // { dg-message "" } +eight sink_3_378(const volatile A&&); int test3_378() { @@ -810,14 +715,14 @@ int test3_378() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_378(ca); // { dg-error "lvalue" } - sink_3_378(cva); // { dg-error "lvalue" } + sink_3_378(ca); // { dg-error "" } + sink_3_378(cva); // { dg-error "" } return 0; } -four sink_3_456(const volatile A&); // { dg-message "note" } -five sink_3_456( A&&); // { dg-message "note" } -six sink_3_456(const A&&); // { dg-message "note" } +four sink_3_456(const volatile A&); +five sink_3_456( A&&); +six sink_3_456(const A&&); int test3_456() { @@ -825,16 +730,14 @@ int test3_456() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_456(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 828 } - sink_3_456(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 830 } + sink_3_456(v_source()); // { dg-error "" } + sink_3_456(cv_source()); // { dg-error "" } return 0; } -four sink_3_457(const volatile A&); // { dg-message "note" } -five sink_3_457( A&&); // { dg-message "note" } -seven sink_3_457(volatile A&&); // { dg-message "note" } +four sink_3_457(const volatile A&); +five sink_3_457( A&&); +seven sink_3_457(volatile A&&); int test3_457() { @@ -842,16 +745,14 @@ int test3_457() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_457(c_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 845 } - sink_3_457(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 847 } + sink_3_457(c_source()); // { dg-error "" } + sink_3_457(cv_source()); // { dg-error "" } return 0; } -four sink_3_467(const volatile A&); // { dg-message "note" } -six sink_3_467(const A&&); // { dg-message "note" } -seven sink_3_467(volatile A&&); // { dg-message "note" } +four sink_3_467(const volatile A&); +six sink_3_467(const A&&); +seven sink_3_467(volatile A&&); int test3_467() { @@ -859,16 +760,14 @@ int test3_467() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_467(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 862 } - sink_3_467(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 864 } + sink_3_467(source()); // { dg-error "" } + sink_3_467(cv_source()); // { dg-error "" } return 0; } -five sink_3_567( A&&); // { dg-message "five sink_3_567|no known conversion" } -six sink_3_567(const A&&); // { dg-message "six sink_3_567|no known conversion" } -seven sink_3_567(volatile A&&); // { dg-message "seven sink_3_567|no known conversion" } +five sink_3_567( A&&); +six sink_3_567(const A&&); +seven sink_3_567(volatile A&&); int test3_567() { @@ -876,19 +775,17 @@ int test3_567() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_567(a); // { dg-error "lvalue" } - sink_3_567(ca); // { dg-error "lvalue" } - sink_3_567(va); // { dg-error "lvalue" } - sink_3_567(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 882 } - sink_3_567(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 884 } + sink_3_567(a); // { dg-error "" } + sink_3_567(ca); // { dg-error "" } + sink_3_567(va); // { dg-error "" } + sink_3_567(cva); // { dg-error "" } + sink_3_567(cv_source()); // { dg-error "" } return 0; } -five sink_3_568( A&&); // { dg-message "" } -six sink_3_568(const A&&); // { dg-message "" } -eight sink_3_568(const volatile A&&); // { dg-message "" } +five sink_3_568( A&&); +six sink_3_568(const A&&); +eight sink_3_568(const volatile A&&); int test3_568() { @@ -896,16 +793,16 @@ int test3_568() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_568(a); // { dg-error "lvalue" } - sink_3_568(ca); // { dg-error "lvalue" } - sink_3_568(va); // { dg-error "lvalue" } - sink_3_568(cva); // { dg-error "lvalue" } + sink_3_568(a); // { dg-error "" } + sink_3_568(ca); // { dg-error "" } + sink_3_568(va); // { dg-error "" } + sink_3_568(cva); // { dg-error "" } return 0; } -five sink_3_578( A&&); // { dg-message "" } -seven sink_3_578(volatile A&&); // { dg-message "" } -eight sink_3_578(const volatile A&&); // { dg-message "" } +five sink_3_578( A&&); +seven sink_3_578(volatile A&&); +eight sink_3_578(const volatile A&&); int test3_578() { @@ -913,16 +810,16 @@ int test3_578() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_578(a); // { dg-error "lvalue" } - sink_3_578(ca); // { dg-error "lvalue" } - sink_3_578(va); // { dg-error "lvalue" } - sink_3_578(cva); // { dg-error "lvalue" } + sink_3_578(a); // { dg-error "" } + sink_3_578(ca); // { dg-error "" } + sink_3_578(va); // { dg-error "" } + sink_3_578(cva); // { dg-error "" } return 0; } -six sink_3_678(const A&&); // { dg-message "six sink_3_678|no known conversion" } -seven sink_3_678(volatile A&&); // { dg-message "seven sink_3_678|no known conversion" } -eight sink_3_678(const volatile A&&); // { dg-message "eight sink_3_678|no known conversion" } +six sink_3_678(const A&&); +seven sink_3_678(volatile A&&); +eight sink_3_678(const volatile A&&); int test3_678() { @@ -930,13 +827,11 @@ int test3_678() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_3_678(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 933 } - sink_3_678(ca); // { dg-error "lvalue" } - sink_3_678(va); // { dg-error "lvalue" } - sink_3_678(cva); // { dg-error "lvalue" } - sink_3_678(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 938 } + sink_3_678(a); // { dg-error "" } + sink_3_678(ca); // { dg-error "" } + sink_3_678(va); // { dg-error "" } + sink_3_678(cva); // { dg-error "" } + sink_3_678(source()); // { dg-error "" } return 0; } diff --git a/gcc/testsuite/g++.dg/cpp0x/rv4n.C b/gcc/testsuite/g++.dg/cpp0x/rv4n.C index dc56afeba4..29deb3fc81 100644 --- a/gcc/testsuite/g++.dg/cpp0x/rv4n.C +++ b/gcc/testsuite/g++.dg/cpp0x/rv4n.C @@ -3,7 +3,7 @@ // Test overload resolution among reference types // { dg-do compile { target c++11 } } -// { dg-options "" } +// { dg-options "-fno-ipa-icf" } template <bool> struct sa; template <> struct sa<true> {}; @@ -30,10 +30,10 @@ const volatile A cv_source(); // 4 at a time -one sink_4_1234( A&); // { dg-message "one sink_4_1234|no known conversion" } -two sink_4_1234(const A&); // { dg-message "note" } -three sink_4_1234(volatile A&); // { dg-message "note" } -four sink_4_1234(const volatile A&); // { dg-message "note" } +one sink_4_1234( A&); +two sink_4_1234(const A&); +three sink_4_1234(volatile A&); +four sink_4_1234(const volatile A&); int test4_1234() { @@ -41,17 +41,15 @@ int test4_1234() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_1234(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 44 } - sink_4_1234(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 46 } + sink_4_1234(v_source()); // { dg-error "" } + sink_4_1234(cv_source()); // { dg-error "" } return 0; } -one sink_4_1235( A&); // { dg-message "one sink_4_1235|no known conversion" } -two sink_4_1235(const A&); // { dg-message "note" } -three sink_4_1235(volatile A&); // { dg-message "note" } -five sink_4_1235( A&&); // { dg-message "note" } +one sink_4_1235( A&); +two sink_4_1235(const A&); +three sink_4_1235(volatile A&); +five sink_4_1235( A&&); int test4_1235() { @@ -59,19 +57,16 @@ int test4_1235() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_1235(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 62 } - sink_4_1235(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 64 } - sink_4_1235(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 66 } + sink_4_1235(cva); // { dg-error "" } + sink_4_1235(v_source()); // { dg-error "" } + sink_4_1235(cv_source()); // { dg-error "" } return 0; } -one sink_4_1236( A&); // { dg-message "one sink_4_1236|no known conversion" } -two sink_4_1236(const A&); // { dg-message "note" } -three sink_4_1236(volatile A&); // { dg-message "note" } -six sink_4_1236(const A&&); // { dg-message "note" } +one sink_4_1236( A&); +two sink_4_1236(const A&); +three sink_4_1236(volatile A&); +six sink_4_1236(const A&&); int test4_1236() { @@ -79,19 +74,16 @@ int test4_1236() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_1236(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 82 } - sink_4_1236(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 84 } - sink_4_1236(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 86 } + sink_4_1236(cva); // { dg-error "" } + sink_4_1236(v_source()); // { dg-error "" } + sink_4_1236(cv_source()); // { dg-error "" } return 0; } -one sink_4_1237( A&); // { dg-message "one sink_4_1237|no known conversion" } -two sink_4_1237(const A&); // { dg-message "note" } -three sink_4_1237(volatile A&); // { dg-message "note" } -seven sink_4_1237(volatile A&&); // { dg-message "note" } +one sink_4_1237( A&); +two sink_4_1237(const A&); +three sink_4_1237(volatile A&); +seven sink_4_1237(volatile A&&); int test4_1237() { @@ -99,10 +91,8 @@ int test4_1237() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_1237(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 102 } - sink_4_1237(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 104 } + sink_4_1237(cva); // { dg-error "" } + sink_4_1237(cv_source()); // { dg-error "" } return 0; } @@ -117,14 +107,14 @@ int test4_1238() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_1238(cva); // { dg-error "lvalue" } + sink_4_1238(cva); // { dg-error "" } return 0; } -one sink_4_1245( A&); // { dg-message "one sink_4_1245|no known conversion" } -two sink_4_1245(const A&); // { dg-message "note" } -four sink_4_1245(const volatile A&); // { dg-message "note" } -five sink_4_1245( A&&); // { dg-message "note" } +one sink_4_1245( A&); +two sink_4_1245(const A&); +four sink_4_1245(const volatile A&); +five sink_4_1245( A&&); int test4_1245() { @@ -132,17 +122,15 @@ int test4_1245() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_1245(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 135 } - sink_4_1245(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 137 } + sink_4_1245(v_source()); // { dg-error "" } + sink_4_1245(cv_source()); // { dg-error "" } return 0; } -one sink_4_1246( A&); // { dg-message "one sink_4_1246|no known conversion" } -two sink_4_1246(const A&); // { dg-message "note" } -four sink_4_1246(const volatile A&); // { dg-message "note" } -six sink_4_1246(const A&&); // { dg-message "note" } +one sink_4_1246( A&); +two sink_4_1246(const A&); +four sink_4_1246(const volatile A&); +six sink_4_1246(const A&&); int test4_1246() { @@ -150,17 +138,15 @@ int test4_1246() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_1246(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 153 } - sink_4_1246(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 155 } + sink_4_1246(v_source()); // { dg-error "" } + sink_4_1246(cv_source()); // { dg-error "" } return 0; } -one sink_4_1247( A&); // { dg-message "one sink_4_1247|no known conversion" } -two sink_4_1247(const A&); // { dg-message "note" } -four sink_4_1247(const volatile A&); // { dg-message "note" } -seven sink_4_1247(volatile A&&); // { dg-message "note" } +one sink_4_1247( A&); +two sink_4_1247(const A&); +four sink_4_1247(const volatile A&); +seven sink_4_1247(volatile A&&); int test4_1247() { @@ -168,15 +154,14 @@ int test4_1247() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_1247(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 171 } + sink_4_1247(cv_source()); // { dg-error "" } return 0; } -one sink_4_1256( A&); // { dg-message "one sink_4_1256|no known conversion" } -two sink_4_1256(const A&); // { dg-message "note" } -five sink_4_1256( A&&); // { dg-message "note" } -six sink_4_1256(const A&&); // { dg-message "note" } +one sink_4_1256( A&); +two sink_4_1256(const A&); +five sink_4_1256( A&&); +six sink_4_1256(const A&&); int test4_1256() { @@ -184,21 +169,17 @@ int test4_1256() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_1256(va); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 187 } - sink_4_1256(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 189 } - sink_4_1256(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 191 } - sink_4_1256(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 193 } + sink_4_1256(va); // { dg-error "" } + sink_4_1256(cva); // { dg-error "" } + sink_4_1256(v_source()); // { dg-error "" } + sink_4_1256(cv_source()); // { dg-error "" } return 0; } -one sink_4_1257( A&); // { dg-message "one sink_4_1257|no known conversion" } -two sink_4_1257(const A&); // { dg-message "note" } -five sink_4_1257( A&&); // { dg-message "note" } -seven sink_4_1257(volatile A&&); // { dg-message "" } +one sink_4_1257( A&); +two sink_4_1257(const A&); +five sink_4_1257( A&&); +seven sink_4_1257(volatile A&&); int test4_1257() { @@ -206,11 +187,9 @@ int test4_1257() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_1257(va); // { dg-error "lvalue" } - sink_4_1257(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 210 } - sink_4_1257(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 212 } + sink_4_1257(va); // { dg-error "" } + sink_4_1257(cva); // { dg-error "" } + sink_4_1257(cv_source()); // { dg-error "" } return 0; } @@ -225,15 +204,15 @@ int test4_1258() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_1258(va); // { dg-error "lvalue" } - sink_4_1258(cva); // { dg-error "lvalue" } + sink_4_1258(va); // { dg-error "" } + sink_4_1258(cva); // { dg-error "" } return 0; } -one sink_4_1267( A&); // { dg-message "one sink_4_1267|no known conversion" } -two sink_4_1267(const A&); // { dg-message "note" } -six sink_4_1267(const A&&); // { dg-message "note" } -seven sink_4_1267(volatile A&&); // { dg-message "" } +one sink_4_1267( A&); +two sink_4_1267(const A&); +six sink_4_1267(const A&&); +seven sink_4_1267(volatile A&&); int test4_1267() { @@ -241,13 +220,10 @@ int test4_1267() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_1267(va); // { dg-error "lvalue" } - sink_4_1267(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 245 } - sink_4_1267(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 247 } - sink_4_1267(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 249 } + sink_4_1267(va); // { dg-error "" } + sink_4_1267(cva); // { dg-error "" } + sink_4_1267(source()); // { dg-error "" } + sink_4_1267(cv_source()); // { dg-error "" } return 0; } @@ -262,8 +238,8 @@ int test4_1268() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_1268(va); // { dg-error "lvalue" } - sink_4_1268(cva); // { dg-error "lvalue" } + sink_4_1268(va); // { dg-error "" } + sink_4_1268(cva); // { dg-error "" } return 0; } @@ -278,15 +254,15 @@ int test4_1278() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_1278(va); // { dg-error "lvalue" } - sink_4_1278(cva); // { dg-error "lvalue" } + sink_4_1278(va); // { dg-error "" } + sink_4_1278(cva); // { dg-error "" } return 0; } -one sink_4_1345( A&); // { dg-message "one sink_4_1345|no known conversion" } -three sink_4_1345(volatile A&); // { dg-message "note" } -four sink_4_1345(const volatile A&); // { dg-message "note" } -five sink_4_1345( A&&); // { dg-message "note" } +one sink_4_1345( A&); +three sink_4_1345(volatile A&); +four sink_4_1345(const volatile A&); +five sink_4_1345( A&&); int test4_1345() { @@ -294,19 +270,16 @@ int test4_1345() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_1345(c_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 297 } - sink_4_1345(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 299 } - sink_4_1345(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 301 } + sink_4_1345(c_source()); // { dg-error "" } + sink_4_1345(v_source()); // { dg-error "" } + sink_4_1345(cv_source()); // { dg-error "" } return 0; } -one sink_4_1346( A&); // { dg-message "one sink_4_1346|no known conversion" } -three sink_4_1346(volatile A&); // { dg-message "note" } -four sink_4_1346(const volatile A&); // { dg-message "note" } -six sink_4_1346(const A&&); // { dg-message "note" } +one sink_4_1346( A&); +three sink_4_1346(volatile A&); +four sink_4_1346(const volatile A&); +six sink_4_1346(const A&&); int test4_1346() { @@ -314,17 +287,15 @@ int test4_1346() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_1346(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 317 } - sink_4_1346(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 319 } + sink_4_1346(v_source()); // { dg-error "" } + sink_4_1346(cv_source()); // { dg-error "" } return 0; } -one sink_4_1347( A&); // { dg-message "one sink_4_1347|no known conversion" } -three sink_4_1347(volatile A&); // { dg-message "note" } -four sink_4_1347(const volatile A&); // { dg-message "note" } -seven sink_4_1347(volatile A&&); // { dg-message "note" } +one sink_4_1347( A&); +three sink_4_1347(volatile A&); +four sink_4_1347(const volatile A&); +seven sink_4_1347(volatile A&&); int test4_1347() { @@ -332,17 +303,15 @@ int test4_1347() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_1347(c_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 335 } - sink_4_1347(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 337 } + sink_4_1347(c_source()); // { dg-error "" } + sink_4_1347(cv_source()); // { dg-error "" } return 0; } -one sink_4_1356( A&); // { dg-message "one sink_4_1356|no known conversion" } -three sink_4_1356(volatile A&); // { dg-message "note" } -five sink_4_1356( A&&); // { dg-message "note" } -six sink_4_1356(const A&&); // { dg-message "" } +one sink_4_1356( A&); +three sink_4_1356(volatile A&); +five sink_4_1356( A&&); +six sink_4_1356(const A&&); int test4_1356() { @@ -350,20 +319,17 @@ int test4_1356() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_1356(ca); // { dg-error "lvalue" } - sink_4_1356(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 354 } - sink_4_1356(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 356 } - sink_4_1356(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 358 } + sink_4_1356(ca); // { dg-error "" } + sink_4_1356(cva); // { dg-error "" } + sink_4_1356(v_source()); // { dg-error "" } + sink_4_1356(cv_source()); // { dg-error "" } return 0; } -one sink_4_1357( A&); // { dg-message "one sink_4_1357|no known conversion" } -three sink_4_1357(volatile A&); // { dg-message "note" } -five sink_4_1357( A&&); // { dg-message "note" } -seven sink_4_1357(volatile A&&); // { dg-message "note" } +one sink_4_1357( A&); +three sink_4_1357(volatile A&); +five sink_4_1357( A&&); +seven sink_4_1357(volatile A&&); int test4_1357() { @@ -371,14 +337,10 @@ int test4_1357() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_1357(ca); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 374 } - sink_4_1357(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 376 } - sink_4_1357(c_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 378 } - sink_4_1357(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 380 } + sink_4_1357(ca); // { dg-error "" } + sink_4_1357(cva); // { dg-error "" } + sink_4_1357(c_source()); // { dg-error "" } + sink_4_1357(cv_source()); // { dg-error "" } return 0; } @@ -393,15 +355,15 @@ int test4_1358() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_1358(ca); // { dg-error "lvalue" } - sink_4_1358(cva); // { dg-error "lvalue" } + sink_4_1358(ca); // { dg-error "" } + sink_4_1358(cva); // { dg-error "" } return 0; } -one sink_4_1367( A&); // { dg-message "one sink_4_1367|no known conversion" } -three sink_4_1367(volatile A&); // { dg-message "note" } -six sink_4_1367(const A&&); // { dg-message "" } -seven sink_4_1367(volatile A&&); // { dg-message "note" } +one sink_4_1367( A&); +three sink_4_1367(volatile A&); +six sink_4_1367(const A&&); +seven sink_4_1367(volatile A&&); int test4_1367() { @@ -409,13 +371,10 @@ int test4_1367() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_1367(ca); // { dg-error "lvalue" } - sink_4_1367(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 413 } - sink_4_1367(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 415 } - sink_4_1367(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 417 } + sink_4_1367(ca); // { dg-error "" } + sink_4_1367(cva); // { dg-error "" } + sink_4_1367(source()); // { dg-error "" } + sink_4_1367(cv_source()); // { dg-error "" } return 0; } @@ -430,8 +389,8 @@ int test4_1368() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_1368(ca); // { dg-error "lvalue" } - sink_4_1368(cva); // { dg-error "lvalue" } + sink_4_1368(ca); // { dg-error "" } + sink_4_1368(cva); // { dg-error "" } return 0; } @@ -446,15 +405,15 @@ int test4_1378() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_1378(ca); // { dg-error "lvalue" } - sink_4_1378(cva); // { dg-error "lvalue" } + sink_4_1378(ca); // { dg-error "" } + sink_4_1378(cva); // { dg-error "" } return 0; } -one sink_4_1456( A&); // { dg-message "one sink_4_1456|no known conversion" } -four sink_4_1456(const volatile A&); // { dg-message "note" } -five sink_4_1456( A&&); // { dg-message "note" } -six sink_4_1456(const A&&); // { dg-message "note" } +one sink_4_1456( A&); +four sink_4_1456(const volatile A&); +five sink_4_1456( A&&); +six sink_4_1456(const A&&); int test4_1456() { @@ -462,17 +421,15 @@ int test4_1456() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_1456(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 465 } - sink_4_1456(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 467 } + sink_4_1456(v_source()); // { dg-error "" } + sink_4_1456(cv_source()); // { dg-error "" } return 0; } -one sink_4_1457( A&); // { dg-message "one sink_4_1457|no known conversion" } -four sink_4_1457(const volatile A&); // { dg-message "note" } -five sink_4_1457( A&&); // { dg-message "note" } -seven sink_4_1457(volatile A&&); // { dg-message "note" } +one sink_4_1457( A&); +four sink_4_1457(const volatile A&); +five sink_4_1457( A&&); +seven sink_4_1457(volatile A&&); int test4_1457() { @@ -480,17 +437,15 @@ int test4_1457() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_1457(c_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 483 } - sink_4_1457(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 485 } + sink_4_1457(c_source()); // { dg-error "" } + sink_4_1457(cv_source()); // { dg-error "" } return 0; } -one sink_4_1467( A&); // { dg-message "one sink_4_1467|no known conversion" } -four sink_4_1467(const volatile A&); // { dg-message "note" } -six sink_4_1467(const A&&); // { dg-message "note" } -seven sink_4_1467(volatile A&&); // { dg-message "note" } +one sink_4_1467( A&); +four sink_4_1467(const volatile A&); +six sink_4_1467(const A&&); +seven sink_4_1467(volatile A&&); int test4_1467() { @@ -498,17 +453,15 @@ int test4_1467() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_1467(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 501 } - sink_4_1467(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 503 } + sink_4_1467(source()); // { dg-error "" } + sink_4_1467(cv_source()); // { dg-error "" } return 0; } -one sink_4_1567( A&); // { dg-message "one sink_4_1567|no known conversion" } -five sink_4_1567( A&&); // { dg-message "note" } -six sink_4_1567(const A&&); // { dg-message "" } -seven sink_4_1567(volatile A&&); // { dg-message "" } +one sink_4_1567( A&); +five sink_4_1567( A&&); +six sink_4_1567(const A&&); +seven sink_4_1567(volatile A&&); int test4_1567() { @@ -516,12 +469,10 @@ int test4_1567() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_1567(ca); // { dg-error "lvalue" } - sink_4_1567(va); // { dg-error "lvalue" } - sink_4_1567(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 521 } - sink_4_1567(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 523 } + sink_4_1567(ca); // { dg-error "" } + sink_4_1567(va); // { dg-error "" } + sink_4_1567(cva); // { dg-error "" } + sink_4_1567(cv_source()); // { dg-error "" } return 0; } @@ -536,9 +487,9 @@ int test4_1568() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_1568(ca); // { dg-error "lvalue" } - sink_4_1568(va); // { dg-error "lvalue" } - sink_4_1568(cva); // { dg-error "lvalue" } + sink_4_1568(ca); // { dg-error "" } + sink_4_1568(va); // { dg-error "" } + sink_4_1568(cva); // { dg-error "" } return 0; } @@ -553,16 +504,16 @@ int test4_1578() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_1578(ca); // { dg-error "lvalue" } - sink_4_1578(va); // { dg-error "lvalue" } - sink_4_1578(cva); // { dg-error "lvalue" } + sink_4_1578(ca); // { dg-error "" } + sink_4_1578(va); // { dg-error "" } + sink_4_1578(cva); // { dg-error "" } return 0; } one sink_4_1678( A&); -six sink_4_1678(const A&&); // { dg-message "" } -seven sink_4_1678(volatile A&&); // { dg-message "" } -eight sink_4_1678(const volatile A&&); // { dg-message "" } +six sink_4_1678(const A&&); +seven sink_4_1678(volatile A&&); +eight sink_4_1678(const volatile A&&); int test4_1678() { @@ -570,18 +521,17 @@ int test4_1678() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_1678(ca); // { dg-error "lvalue" } - sink_4_1678(va); // { dg-error "lvalue" } - sink_4_1678(cva); // { dg-error "lvalue" } - sink_4_1678(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 576 } + sink_4_1678(ca); // { dg-error "" } + sink_4_1678(va); // { dg-error "" } + sink_4_1678(cva); // { dg-error "" } + sink_4_1678(source()); // { dg-error "" } return 0; } -two sink_4_2345(const A&); // { dg-message "two sink_4_2345|no known conversion" } -three sink_4_2345(volatile A&); // { dg-message "note" } -four sink_4_2345(const volatile A&); // { dg-message "note" } -five sink_4_2345( A&&); // { dg-message "note" } +two sink_4_2345(const A&); +three sink_4_2345(volatile A&); +four sink_4_2345(const volatile A&); +five sink_4_2345( A&&); int test4_2345() { @@ -589,19 +539,16 @@ int test4_2345() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_2345(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 592 } - sink_4_2345(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 594 } - sink_4_2345(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 596 } + sink_4_2345(a); // { dg-error "" } + sink_4_2345(v_source()); // { dg-error "" } + sink_4_2345(cv_source()); // { dg-error "" } return 0; } -two sink_4_2346(const A&); // { dg-message "two sink_4_2346|no known conversion" } -three sink_4_2346(volatile A&); // { dg-message "note" } -four sink_4_2346(const volatile A&); // { dg-message "note" } -six sink_4_2346(const A&&); // { dg-message "note" } +two sink_4_2346(const A&); +three sink_4_2346(volatile A&); +four sink_4_2346(const volatile A&); +six sink_4_2346(const A&&); int test4_2346() { @@ -609,19 +556,16 @@ int test4_2346() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_2346(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 612 } - sink_4_2346(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 614 } - sink_4_2346(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 616 } + sink_4_2346(a); // { dg-error "" } + sink_4_2346(v_source()); // { dg-error "" } + sink_4_2346(cv_source()); // { dg-error "" } return 0; } -two sink_4_2347(const A&); // { dg-message "two sink_4_2347|no known conversion" } -three sink_4_2347(volatile A&); // { dg-message "note" } -four sink_4_2347(const volatile A&); // { dg-message "note" } -seven sink_4_2347(volatile A&&); // { dg-message "note" } +two sink_4_2347(const A&); +three sink_4_2347(volatile A&); +four sink_4_2347(const volatile A&); +seven sink_4_2347(volatile A&&); int test4_2347() { @@ -629,17 +573,15 @@ int test4_2347() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_2347(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 632 } - sink_4_2347(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 634 } + sink_4_2347(a); // { dg-error "" } + sink_4_2347(cv_source()); // { dg-error "" } return 0; } -two sink_4_2348(const A&); // { dg-message "note" } -three sink_4_2348(volatile A&); // { dg-message "note" } -four sink_4_2348(const volatile A&); // { dg-message "note" } -eight sink_4_2348(const volatile A&&); // { dg-message "note" } +two sink_4_2348(const A&); +three sink_4_2348(volatile A&); +four sink_4_2348(const volatile A&); +eight sink_4_2348(const volatile A&&); int test4_2348() { @@ -647,15 +589,14 @@ int test4_2348() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_2348(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 650 } + sink_4_2348(a); // { dg-error "" } return 0; } -two sink_4_2356(const A&); // { dg-message "two sink_4_2356|no known conversion" } -three sink_4_2356(volatile A&); // { dg-message "note" } -five sink_4_2356( A&&); // { dg-message "note" } -six sink_4_2356(const A&&); // { dg-message "note" } +two sink_4_2356(const A&); +three sink_4_2356(volatile A&); +five sink_4_2356( A&&); +six sink_4_2356(const A&&); int test4_2356() { @@ -663,21 +604,17 @@ int test4_2356() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_2356(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 666 } - sink_4_2356(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 668 } - sink_4_2356(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 670 } - sink_4_2356(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 672 } + sink_4_2356(a); // { dg-error "" } + sink_4_2356(cva); // { dg-error "" } + sink_4_2356(v_source()); // { dg-error "" } + sink_4_2356(cv_source()); // { dg-error "" } return 0; } -two sink_4_2357(const A&); // { dg-message "two sink_4_2357|no known conversion" } -three sink_4_2357(volatile A&); // { dg-message "note" } -five sink_4_2357( A&&); // { dg-message "note" } -seven sink_4_2357(volatile A&&); // { dg-message "note" } +two sink_4_2357(const A&); +three sink_4_2357(volatile A&); +five sink_4_2357( A&&); +seven sink_4_2357(volatile A&&); int test4_2357() { @@ -685,19 +622,16 @@ int test4_2357() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_2357(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 688 } - sink_4_2357(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 690 } - sink_4_2357(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 692 } + sink_4_2357(a); // { dg-error "" } + sink_4_2357(cva); // { dg-error "" } + sink_4_2357(cv_source()); // { dg-error "" } return 0; } -two sink_4_2358(const A&); // { dg-message "note" } -three sink_4_2358(volatile A&); // { dg-message "note" } -five sink_4_2358( A&&); // { dg-message "note" } -eight sink_4_2358(const volatile A&&); // { dg-message "" } +two sink_4_2358(const A&); +three sink_4_2358(volatile A&); +five sink_4_2358( A&&); +eight sink_4_2358(const volatile A&&); int test4_2358() { @@ -705,16 +639,15 @@ int test4_2358() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_2358(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 708 } - sink_4_2358(cva); // { dg-error "lvalue" } + sink_4_2358(a); // { dg-error "" } + sink_4_2358(cva); // { dg-error "" } return 0; } -two sink_4_2367(const A&); // { dg-message "two sink_4_2367|no known conversion" } -three sink_4_2367(volatile A&); // { dg-message "note" } -six sink_4_2367(const A&&); // { dg-message "note" } -seven sink_4_2367(volatile A&&); // { dg-message "note" } +two sink_4_2367(const A&); +three sink_4_2367(volatile A&); +six sink_4_2367(const A&&); +seven sink_4_2367(volatile A&&); int test4_2367() { @@ -722,21 +655,17 @@ int test4_2367() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_2367(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 725 } - sink_4_2367(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 727 } - sink_4_2367(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 729 } - sink_4_2367(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 731 } + sink_4_2367(a); // { dg-error "" } + sink_4_2367(cva); // { dg-error "" } + sink_4_2367(source()); // { dg-error "" } + sink_4_2367(cv_source()); // { dg-error "" } return 0; } -two sink_4_2368(const A&); // { dg-message "note" } -three sink_4_2368(volatile A&); // { dg-message "note" } -six sink_4_2368(const A&&); // { dg-message "note" } -eight sink_4_2368(const volatile A&&); // { dg-message "" } +two sink_4_2368(const A&); +three sink_4_2368(volatile A&); +six sink_4_2368(const A&&); +eight sink_4_2368(const volatile A&&); int test4_2368() { @@ -744,16 +673,15 @@ int test4_2368() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_2368(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 747 } - sink_4_2368(cva); // { dg-error "lvalue" } + sink_4_2368(a); // { dg-error "" } + sink_4_2368(cva); // { dg-error "" } return 0; } -two sink_4_2378(const A&); // { dg-message "note" } -three sink_4_2378(volatile A&); // { dg-message "note" } -seven sink_4_2378(volatile A&&); // { dg-message "note" } -eight sink_4_2378(const volatile A&&); // { dg-message "" } +two sink_4_2378(const A&); +three sink_4_2378(volatile A&); +seven sink_4_2378(volatile A&&); +eight sink_4_2378(const volatile A&&); int test4_2378() { @@ -761,16 +689,15 @@ int test4_2378() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_2378(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 764 } - sink_4_2378(cva); // { dg-error "lvalue" } + sink_4_2378(a); // { dg-error "" } + sink_4_2378(cva); // { dg-error "" } return 0; } -two sink_4_2456(const A&); // { dg-message "two sink_4_2456|no known conversion" } -four sink_4_2456(const volatile A&); // { dg-message "note" } -five sink_4_2456( A&&); // { dg-message "note" } -six sink_4_2456(const A&&); // { dg-message "note" } +two sink_4_2456(const A&); +four sink_4_2456(const volatile A&); +five sink_4_2456( A&&); +six sink_4_2456(const A&&); int test4_2456() { @@ -778,17 +705,15 @@ int test4_2456() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_2456(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 781 } - sink_4_2456(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 783 } + sink_4_2456(v_source()); // { dg-error "" } + sink_4_2456(cv_source()); // { dg-error "" } return 0; } -two sink_4_2457(const A&); // { dg-message "two sink_4_2457|no known conversion" } -four sink_4_2457(const volatile A&); // { dg-message "note" } -five sink_4_2457( A&&); // { dg-message "note" } -seven sink_4_2457(volatile A&&); // { dg-message "note" } +two sink_4_2457(const A&); +four sink_4_2457(const volatile A&); +five sink_4_2457( A&&); +seven sink_4_2457(volatile A&&); int test4_2457() { @@ -796,15 +721,14 @@ int test4_2457() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_2457(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 799 } + sink_4_2457(cv_source()); // { dg-error "" } return 0; } -two sink_4_2467(const A&); // { dg-message "two sink_4_2467|no known conversion" } -four sink_4_2467(const volatile A&); // { dg-message "note" } -six sink_4_2467(const A&&); // { dg-message "note" } -seven sink_4_2467(volatile A&&); // { dg-message "note" } +two sink_4_2467(const A&); +four sink_4_2467(const volatile A&); +six sink_4_2467(const A&&); +seven sink_4_2467(volatile A&&); int test4_2467() { @@ -812,17 +736,15 @@ int test4_2467() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_2467(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 815 } - sink_4_2467(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 817 } + sink_4_2467(source()); // { dg-error "" } + sink_4_2467(cv_source()); // { dg-error "" } return 0; } -two sink_4_2567(const A&); // { dg-message "two sink_4_2567|no known conversion" } -five sink_4_2567( A&&); // { dg-message "note" } -six sink_4_2567(const A&&); // { dg-message "note" } -seven sink_4_2567(volatile A&&); // { dg-message "" } +two sink_4_2567(const A&); +five sink_4_2567( A&&); +six sink_4_2567(const A&&); +seven sink_4_2567(volatile A&&); int test4_2567() { @@ -830,11 +752,9 @@ int test4_2567() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_2567(va); // { dg-error "lvalue" } - sink_4_2567(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 834 } - sink_4_2567(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 836 } + sink_4_2567(va); // { dg-error "" } + sink_4_2567(cva); // { dg-error "" } + sink_4_2567(cv_source()); // { dg-error "" } return 0; } @@ -849,8 +769,8 @@ int test4_2568() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_2568(va); // { dg-error "lvalue" } - sink_4_2568(cva); // { dg-error "lvalue" } + sink_4_2568(va); // { dg-error "" } + sink_4_2568(cva); // { dg-error "" } return 0; } @@ -865,15 +785,15 @@ int test4_2578() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_2578(va); // { dg-error "lvalue" } - sink_4_2578(cva); // { dg-error "lvalue" } + sink_4_2578(va); // { dg-error "" } + sink_4_2578(cva); // { dg-error "" } return 0; } -two sink_4_2678(const A&); // { dg-message "note" } -six sink_4_2678(const A&&); // { dg-message "note" } -seven sink_4_2678(volatile A&&); // { dg-message "" } -eight sink_4_2678(const volatile A&&); // { dg-message "" } +two sink_4_2678(const A&); +six sink_4_2678(const A&&); +seven sink_4_2678(volatile A&&); +eight sink_4_2678(const volatile A&&); int test4_2678() { @@ -881,17 +801,16 @@ int test4_2678() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_2678(va); // { dg-error "lvalue" } - sink_4_2678(cva); // { dg-error "lvalue" } - sink_4_2678(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 886 } + sink_4_2678(va); // { dg-error "" } + sink_4_2678(cva); // { dg-error "" } + sink_4_2678(source()); // { dg-error "" } return 0; } -three sink_4_3456(volatile A&); // { dg-message "three sink_4_3456|no known conversion" } -four sink_4_3456(const volatile A&); // { dg-message "note" } -five sink_4_3456( A&&); // { dg-message "note" } -six sink_4_3456(const A&&); // { dg-message "note" } +three sink_4_3456(volatile A&); +four sink_4_3456(const volatile A&); +five sink_4_3456( A&&); +six sink_4_3456(const A&&); int test4_3456() { @@ -899,17 +818,15 @@ int test4_3456() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_3456(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 902 } - sink_4_3456(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 904 } + sink_4_3456(v_source()); // { dg-error "" } + sink_4_3456(cv_source()); // { dg-error "" } return 0; } -three sink_4_3457(volatile A&); // { dg-message "three sink_4_3457|no known conversion" } -four sink_4_3457(const volatile A&); // { dg-message "note" } -five sink_4_3457( A&&); // { dg-message "note" } -seven sink_4_3457(volatile A&&); // { dg-message "note" } +three sink_4_3457(volatile A&); +four sink_4_3457(const volatile A&); +five sink_4_3457( A&&); +seven sink_4_3457(volatile A&&); int test4_3457() { @@ -917,17 +834,15 @@ int test4_3457() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_3457(c_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 920 } - sink_4_3457(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 922 } + sink_4_3457(c_source()); // { dg-error "" } + sink_4_3457(cv_source()); // { dg-error "" } return 0; } -three sink_4_3467(volatile A&); // { dg-message "three sink_4_3467|no known conversion" } -four sink_4_3467(const volatile A&); // { dg-message "note" } -six sink_4_3467(const A&&); // { dg-message "note" } -seven sink_4_3467(volatile A&&); // { dg-message "note" } +three sink_4_3467(volatile A&); +four sink_4_3467(const volatile A&); +six sink_4_3467(const A&&); +seven sink_4_3467(volatile A&&); int test4_3467() { @@ -935,17 +850,15 @@ int test4_3467() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_3467(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 938 } - sink_4_3467(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 940 } + sink_4_3467(source()); // { dg-error "" } + sink_4_3467(cv_source()); // { dg-error "" } return 0; } -three sink_4_3567(volatile A&); // { dg-message "three sink_4_3567|no known conversion" } -five sink_4_3567( A&&); // { dg-message "note" } -six sink_4_3567(const A&&); // { dg-message "" } -seven sink_4_3567(volatile A&&); // { dg-message "note" } +three sink_4_3567(volatile A&); +five sink_4_3567( A&&); +six sink_4_3567(const A&&); +seven sink_4_3567(volatile A&&); int test4_3567() { @@ -953,11 +866,9 @@ int test4_3567() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_3567(ca); // { dg-error "lvalue" } - sink_4_3567(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 957 } - sink_4_3567(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 959 } + sink_4_3567(ca); // { dg-error "" } + sink_4_3567(cva); // { dg-error "" } + sink_4_3567(cv_source()); // { dg-error "" } return 0; } @@ -972,8 +883,8 @@ int test4_3568() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_3568(ca); // { dg-error "lvalue" } - sink_4_3568(cva); // { dg-error "lvalue" } + sink_4_3568(ca); // { dg-error "" } + sink_4_3568(cva); // { dg-error "" } return 0; } @@ -988,15 +899,15 @@ int test4_3578() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_3578(ca); // { dg-error "lvalue" } - sink_4_3578(cva); // { dg-error "lvalue" } + sink_4_3578(ca); // { dg-error "" } + sink_4_3578(cva); // { dg-error "" } return 0; } three sink_4_3678(volatile A&); -six sink_4_3678(const A&&); // { dg-message "" } -seven sink_4_3678(volatile A&&); // { dg-message "note" } -eight sink_4_3678(const volatile A&&); // { dg-message "" } +six sink_4_3678(const A&&); +seven sink_4_3678(volatile A&&); +eight sink_4_3678(const volatile A&&); int test4_3678() { @@ -1004,17 +915,16 @@ int test4_3678() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_3678(ca); // { dg-error "lvalue" } - sink_4_3678(cva); // { dg-error "lvalue" } - sink_4_3678(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 1009 } + sink_4_3678(ca); // { dg-error "" } + sink_4_3678(cva); // { dg-error "" } + sink_4_3678(source()); // { dg-error "" } return 0; } -four sink_4_4567(const volatile A&); // { dg-message "note" } -five sink_4_4567( A&&); // { dg-message "note" } -six sink_4_4567(const A&&); // { dg-message "note" } -seven sink_4_4567(volatile A&&); // { dg-message "note" } +four sink_4_4567(const volatile A&); +five sink_4_4567( A&&); +six sink_4_4567(const A&&); +seven sink_4_4567(volatile A&&); int test4_4567() { @@ -1022,15 +932,14 @@ int test4_4567() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_4567(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 1025 } + sink_4_4567(cv_source()); // { dg-error "" } return 0; } four sink_4_4678(const volatile A&); -six sink_4_4678(const A&&); // { dg-message "note" } -seven sink_4_4678(volatile A&&); // { dg-message "note" } -eight sink_4_4678(const volatile A&&); // { dg-message "note" } +six sink_4_4678(const A&&); +seven sink_4_4678(volatile A&&); +eight sink_4_4678(const volatile A&&); int test4_4678() { @@ -1038,8 +947,7 @@ int test4_4678() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_4678(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 1041 } + sink_4_4678(source()); // { dg-error "" } return 0; } @@ -1054,10 +962,10 @@ int test4_5678() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_4_5678(a); // { dg-error "lvalue" } - sink_4_5678(ca); // { dg-error "lvalue" } - sink_4_5678(va); // { dg-error "lvalue" } - sink_4_5678(cva); // { dg-error "lvalue" } + sink_4_5678(a); // { dg-error "" } + sink_4_5678(ca); // { dg-error "" } + sink_4_5678(va); // { dg-error "" } + sink_4_5678(cva); // { dg-error "" } return 0; } diff --git a/gcc/testsuite/g++.dg/cpp0x/rv5n.C b/gcc/testsuite/g++.dg/cpp0x/rv5n.C index ca179cd822..f11d07a392 100644 --- a/gcc/testsuite/g++.dg/cpp0x/rv5n.C +++ b/gcc/testsuite/g++.dg/cpp0x/rv5n.C @@ -3,7 +3,7 @@ // Test overload resolution among reference types // { dg-do compile { target c++11 } } -// { dg-options "" } +// { dg-options "-fno-ipa-icf" } template <bool> struct sa; template <> struct sa<true> {}; @@ -31,10 +31,10 @@ const volatile A cv_source(); // 5 at a time one sink_5_12345( A&); // { dg-message "one sink_5_12345|no known conversion" } -two sink_5_12345(const A&); // { dg-message "note" } -three sink_5_12345(volatile A&); // { dg-message "note" } -four sink_5_12345(const volatile A&); // { dg-message "note" } -five sink_5_12345( A&&); // { dg-message "note" } +two sink_5_12345(const A&); +three sink_5_12345(volatile A&); +four sink_5_12345(const volatile A&); +five sink_5_12345( A&&); int test5_12345() { @@ -42,18 +42,16 @@ int test5_12345() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_12345(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 45 } - sink_5_12345(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 47 } + sink_5_12345(v_source()); // { dg-error "" } + sink_5_12345(cv_source()); // { dg-error "" } return 0; } one sink_5_12346( A&); // { dg-message "one sink_5_12346|no known conversion" } -two sink_5_12346(const A&); // { dg-message "note" } -three sink_5_12346(volatile A&); // { dg-message "note" } -four sink_5_12346(const volatile A&); // { dg-message "note" } -six sink_5_12346(const A&&); // { dg-message "note" } +two sink_5_12346(const A&); +three sink_5_12346(volatile A&); +four sink_5_12346(const volatile A&); +six sink_5_12346(const A&&); int test5_12346() { @@ -61,18 +59,16 @@ int test5_12346() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_12346(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 64 } - sink_5_12346(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 66 } + sink_5_12346(v_source()); // { dg-error "" } + sink_5_12346(cv_source()); // { dg-error "" } return 0; } one sink_5_12347( A&); // { dg-message "one sink_5_12347|no known conversion" } -two sink_5_12347(const A&); // { dg-message "note" } -three sink_5_12347(volatile A&); // { dg-message "note" } -four sink_5_12347(const volatile A&); // { dg-message "note" } -seven sink_5_12347(volatile A&&); // { dg-message "note" } +two sink_5_12347(const A&); +three sink_5_12347(volatile A&); +four sink_5_12347(const volatile A&); +seven sink_5_12347(volatile A&&); int test5_12347() { @@ -80,16 +76,15 @@ int test5_12347() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_12347(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 83 } + sink_5_12347(cv_source()); // { dg-error "" } return 0; } one sink_5_12356( A&); // { dg-message "one sink_5_12356|no known conversion" } -two sink_5_12356(const A&); // { dg-message "note" } -three sink_5_12356(volatile A&); // { dg-message "note" } -five sink_5_12356( A&&); // { dg-message "note" } -six sink_5_12356(const A&&); // { dg-message "note" } +two sink_5_12356(const A&); +three sink_5_12356(volatile A&); +five sink_5_12356( A&&); +six sink_5_12356(const A&&); int test5_12356() { @@ -97,20 +92,17 @@ int test5_12356() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_12356(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 100 } - sink_5_12356(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 102 } - sink_5_12356(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 104 } + sink_5_12356(cva); // { dg-error "" } + sink_5_12356(v_source()); // { dg-error "" } + sink_5_12356(cv_source()); // { dg-error "" } return 0; } one sink_5_12357( A&); // { dg-message "one sink_5_12357|no known conversion" } -two sink_5_12357(const A&); // { dg-message "note" } -three sink_5_12357(volatile A&); // { dg-message "note" } -five sink_5_12357( A&&); // { dg-message "note" } -seven sink_5_12357(volatile A&&); // { dg-message "note" } +two sink_5_12357(const A&); +three sink_5_12357(volatile A&); +five sink_5_12357( A&&); +seven sink_5_12357(volatile A&&); int test5_12357() { @@ -118,10 +110,8 @@ int test5_12357() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_12357(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 121 } - sink_5_12357(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 123 } + sink_5_12357(cva); // { dg-error "" } + sink_5_12357(cv_source()); // { dg-error "" } return 0; } @@ -137,15 +127,15 @@ int test5_12358() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_12358(cva); // { dg-error "lvalue" } + sink_5_12358(cva); // { dg-error "" } return 0; } one sink_5_12367( A&); // { dg-message "one sink_5_12367|no known conversion" } -two sink_5_12367(const A&); // { dg-message "note" } -three sink_5_12367(volatile A&); // { dg-message "note" } -six sink_5_12367(const A&&); // { dg-message "note" } -seven sink_5_12367(volatile A&&); // { dg-message "note" } +two sink_5_12367(const A&); +three sink_5_12367(volatile A&); +six sink_5_12367(const A&&); +seven sink_5_12367(volatile A&&); int test5_12367() { @@ -153,12 +143,9 @@ int test5_12367() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_12367(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 156 } - sink_5_12367(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 158 } - sink_5_12367(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 160 } + sink_5_12367(cva); // { dg-error "" } + sink_5_12367(source()); // { dg-error "" } + sink_5_12367(cv_source()); // { dg-error "" } return 0; } @@ -174,7 +161,7 @@ int test5_12368() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_12368(cva); // { dg-error "lvalue" } + sink_5_12368(cva); // { dg-error "" } return 0; } @@ -190,15 +177,15 @@ int test5_12378() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_12378(cva); // { dg-error "lvalue" } + sink_5_12378(cva); // { dg-error "" } return 0; } one sink_5_12456( A&); // { dg-message "one sink_5_12456|no known conversion" } -two sink_5_12456(const A&); // { dg-message "note" } -four sink_5_12456(const volatile A&); // { dg-message "note" } -five sink_5_12456( A&&); // { dg-message "note" } -six sink_5_12456(const A&&); // { dg-message "note" } +two sink_5_12456(const A&); +four sink_5_12456(const volatile A&); +five sink_5_12456( A&&); +six sink_5_12456(const A&&); int test5_12456() { @@ -206,18 +193,16 @@ int test5_12456() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_12456(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 209 } - sink_5_12456(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 211 } + sink_5_12456(v_source()); // { dg-error "" } + sink_5_12456(cv_source()); // { dg-error "" } return 0; } one sink_5_12457( A&); // { dg-message "one sink_5_12457|no known conversion" } -two sink_5_12457(const A&); // { dg-message "note" } -four sink_5_12457(const volatile A&); // { dg-message "note" } -five sink_5_12457( A&&); // { dg-message "note" } -seven sink_5_12457(volatile A&&); // { dg-message "note" } +two sink_5_12457(const A&); +four sink_5_12457(const volatile A&); +five sink_5_12457( A&&); +seven sink_5_12457(volatile A&&); int test5_12457() { @@ -225,16 +210,15 @@ int test5_12457() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_12457(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 228 } + sink_5_12457(cv_source()); // { dg-error "" } return 0; } one sink_5_12467( A&); // { dg-message "one sink_5_12467|no known conversion" } -two sink_5_12467(const A&); // { dg-message "note" } -four sink_5_12467(const volatile A&); // { dg-message "note" } -six sink_5_12467(const A&&); // { dg-message "note" } -seven sink_5_12467(volatile A&&); // { dg-message "note" } +two sink_5_12467(const A&); +four sink_5_12467(const volatile A&); +six sink_5_12467(const A&&); +seven sink_5_12467(volatile A&&); int test5_12467() { @@ -242,17 +226,15 @@ int test5_12467() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_12467(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 245 } - sink_5_12467(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 247 } + sink_5_12467(source()); // { dg-error "" } + sink_5_12467(cv_source()); // { dg-error "" } return 0; } one sink_5_12567( A&); // { dg-message "one sink_5_12567|no known conversion" } -two sink_5_12567(const A&); // { dg-message "note" } -five sink_5_12567( A&&); // { dg-message "note" } -six sink_5_12567(const A&&); // { dg-message "note" } +two sink_5_12567(const A&); +five sink_5_12567( A&&); +six sink_5_12567(const A&&); seven sink_5_12567(volatile A&&); // { dg-message "" } int test5_12567() @@ -261,11 +243,9 @@ int test5_12567() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_12567(va); // { dg-error "lvalue" } - sink_5_12567(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 265 } - sink_5_12567(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 267 } + sink_5_12567(va); // { dg-error "" } + sink_5_12567(cva); // { dg-error "" } + sink_5_12567(cv_source()); // { dg-error "" } return 0; } @@ -281,8 +261,8 @@ int test5_12568() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_12568(va); // { dg-error "lvalue" } - sink_5_12568(cva); // { dg-error "lvalue" } + sink_5_12568(va); // { dg-error "" } + sink_5_12568(cva); // { dg-error "" } return 0; } @@ -298,14 +278,14 @@ int test5_12578() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_12578(va); // { dg-error "lvalue" } - sink_5_12578(cva); // { dg-error "lvalue" } + sink_5_12578(va); // { dg-error "" } + sink_5_12578(cva); // { dg-error "" } return 0; } one sink_5_12678( A&); -two sink_5_12678(const A&); // { dg-message "note" } -six sink_5_12678(const A&&); // { dg-message "note" } +two sink_5_12678(const A&); +six sink_5_12678(const A&&); seven sink_5_12678(volatile A&&); // { dg-message "" } eight sink_5_12678(const volatile A&&); // { dg-message "" } @@ -315,18 +295,17 @@ int test5_12678() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_12678(va); // { dg-error "lvalue" } - sink_5_12678(cva); // { dg-error "lvalue" } - sink_5_12678(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 320 } + sink_5_12678(va); // { dg-error "" } + sink_5_12678(cva); // { dg-error "" } + sink_5_12678(source()); // { dg-error "" } return 0; } one sink_5_13456( A&); // { dg-message "one sink_5_13456|no known conversion" } -three sink_5_13456(volatile A&); // { dg-message "note" } -four sink_5_13456(const volatile A&); // { dg-message "note" } -five sink_5_13456( A&&); // { dg-message "note" } -six sink_5_13456(const A&&); // { dg-message "note" } +three sink_5_13456(volatile A&); +four sink_5_13456(const volatile A&); +five sink_5_13456( A&&); +six sink_5_13456(const A&&); int test5_13456() { @@ -334,18 +313,16 @@ int test5_13456() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_13456(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 337 } - sink_5_13456(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 339 } + sink_5_13456(v_source()); // { dg-error "" } + sink_5_13456(cv_source()); // { dg-error "" } return 0; } one sink_5_13457( A&); // { dg-message "one sink_5_13457|no known conversion" } -three sink_5_13457(volatile A&); // { dg-message "note" } -four sink_5_13457(const volatile A&); // { dg-message "note" } -five sink_5_13457( A&&); // { dg-message "note" } -seven sink_5_13457(volatile A&&); // { dg-message "note" } +three sink_5_13457(volatile A&); +four sink_5_13457(const volatile A&); +five sink_5_13457( A&&); +seven sink_5_13457(volatile A&&); int test5_13457() { @@ -353,18 +330,16 @@ int test5_13457() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_13457(c_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 356 } - sink_5_13457(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 358 } + sink_5_13457(c_source()); // { dg-error "" } + sink_5_13457(cv_source()); // { dg-error "" } return 0; } one sink_5_13467( A&); // { dg-message "one sink_5_13467|no known conversion" } -three sink_5_13467(volatile A&); // { dg-message "note" } -four sink_5_13467(const volatile A&); // { dg-message "note" } -six sink_5_13467(const A&&); // { dg-message "note" } -seven sink_5_13467(volatile A&&); // { dg-message "note" } +three sink_5_13467(volatile A&); +four sink_5_13467(const volatile A&); +six sink_5_13467(const A&&); +seven sink_5_13467(volatile A&&); int test5_13467() { @@ -372,18 +347,16 @@ int test5_13467() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_13467(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 375 } - sink_5_13467(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 377 } + sink_5_13467(source()); // { dg-error "" } + sink_5_13467(cv_source()); // { dg-error "" } return 0; } one sink_5_13567( A&); // { dg-message "one sink_5_13567|no known conversion" } -three sink_5_13567(volatile A&); // { dg-message "note" } -five sink_5_13567( A&&); // { dg-message "note" } +three sink_5_13567(volatile A&); +five sink_5_13567( A&&); six sink_5_13567(const A&&); // { dg-message "" } -seven sink_5_13567(volatile A&&); // { dg-message "note" } +seven sink_5_13567(volatile A&&); int test5_13567() { @@ -391,11 +364,9 @@ int test5_13567() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_13567(ca); // { dg-error "lvalue" } - sink_5_13567(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 395 } - sink_5_13567(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 397 } + sink_5_13567(ca); // { dg-error "" } + sink_5_13567(cva); // { dg-error "" } + sink_5_13567(cv_source()); // { dg-error "" } return 0; } @@ -411,8 +382,8 @@ int test5_13568() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_13568(ca); // { dg-error "lvalue" } - sink_5_13568(cva); // { dg-error "lvalue" } + sink_5_13568(ca); // { dg-error "" } + sink_5_13568(cva); // { dg-error "" } return 0; } @@ -428,15 +399,15 @@ int test5_13578() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_13578(ca); // { dg-error "lvalue" } - sink_5_13578(cva); // { dg-error "lvalue" } + sink_5_13578(ca); // { dg-error "" } + sink_5_13578(cva); // { dg-error "" } return 0; } one sink_5_13678( A&); three sink_5_13678(volatile A&); six sink_5_13678(const A&&); // { dg-message "" } -seven sink_5_13678(volatile A&&); // { dg-message "note" } +seven sink_5_13678(volatile A&&); eight sink_5_13678(const volatile A&&); // { dg-message "" } int test5_13678() @@ -445,18 +416,17 @@ int test5_13678() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_13678(ca); // { dg-error "lvalue" } - sink_5_13678(cva); // { dg-error "lvalue" } - sink_5_13678(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 450 } + sink_5_13678(ca); // { dg-error "" } + sink_5_13678(cva); // { dg-error "" } + sink_5_13678(source()); // { dg-error "" } return 0; } one sink_5_14567( A&); // { dg-message "one sink_5_14567|no known conversion" } -four sink_5_14567(const volatile A&); // { dg-message "note" } -five sink_5_14567( A&&); // { dg-message "note" } -six sink_5_14567(const A&&); // { dg-message "note" } -seven sink_5_14567(volatile A&&); // { dg-message "note" } +four sink_5_14567(const volatile A&); +five sink_5_14567( A&&); +six sink_5_14567(const A&&); +seven sink_5_14567(volatile A&&); int test5_14567() { @@ -464,16 +434,15 @@ int test5_14567() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_14567(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 467 } + sink_5_14567(cv_source()); // { dg-error "" } return 0; } one sink_5_14678( A&); four sink_5_14678(const volatile A&); -six sink_5_14678(const A&&); // { dg-message "note" } -seven sink_5_14678(volatile A&&); // { dg-message "note" } -eight sink_5_14678(const volatile A&&); // { dg-message "note" } +six sink_5_14678(const A&&); +seven sink_5_14678(volatile A&&); +eight sink_5_14678(const volatile A&&); int test5_14678() { @@ -481,8 +450,7 @@ int test5_14678() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_14678(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 484 } + sink_5_14678(source()); // { dg-error "" } return 0; } @@ -498,17 +466,17 @@ int test5_15678() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_15678(ca); // { dg-error "lvalue" } - sink_5_15678(va); // { dg-error "lvalue" } - sink_5_15678(cva); // { dg-error "lvalue" } + sink_5_15678(ca); // { dg-error "" } + sink_5_15678(va); // { dg-error "" } + sink_5_15678(cva); // { dg-error "" } return 0; } two sink_5_23456(const A&); // { dg-message "two sink_5_23456|no known conversion" } -three sink_5_23456(volatile A&); // { dg-message "note" } -four sink_5_23456(const volatile A&); // { dg-message "note" } -five sink_5_23456( A&&); // { dg-message "note" } -six sink_5_23456(const A&&); // { dg-message "note" } +three sink_5_23456(volatile A&); +four sink_5_23456(const volatile A&); +five sink_5_23456( A&&); +six sink_5_23456(const A&&); int test5_23456() { @@ -516,20 +484,17 @@ int test5_23456() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_23456(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 519 } - sink_5_23456(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 521 } - sink_5_23456(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 523 } + sink_5_23456(a); // { dg-error "" } + sink_5_23456(v_source()); // { dg-error "" } + sink_5_23456(cv_source()); // { dg-error "" } return 0; } two sink_5_23457(const A&); // { dg-message "two sink_5_23457|no known conversion" } -three sink_5_23457(volatile A&); // { dg-message "note" } -four sink_5_23457(const volatile A&); // { dg-message "note" } -five sink_5_23457( A&&); // { dg-message "note" } -seven sink_5_23457(volatile A&&); // { dg-message "note" } +three sink_5_23457(volatile A&); +four sink_5_23457(const volatile A&); +five sink_5_23457( A&&); +seven sink_5_23457(volatile A&&); int test5_23457() { @@ -537,18 +502,16 @@ int test5_23457() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_23457(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 540 } - sink_5_23457(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 542 } + sink_5_23457(a); // { dg-error "" } + sink_5_23457(cv_source()); // { dg-error "" } return 0; } -two sink_5_23458(const A&); // { dg-message "note" } -three sink_5_23458(volatile A&); // { dg-message "note" } -four sink_5_23458(const volatile A&); // { dg-message "note" } -five sink_5_23458( A&&); // { dg-message "note" } -eight sink_5_23458(const volatile A&&); // { dg-message "note" } +two sink_5_23458(const A&); +three sink_5_23458(volatile A&); +four sink_5_23458(const volatile A&); +five sink_5_23458( A&&); +eight sink_5_23458(const volatile A&&); int test5_23458() { @@ -556,16 +519,15 @@ int test5_23458() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_23458(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 559 } + sink_5_23458(a); // { dg-error "" } return 0; } two sink_5_23467(const A&); // { dg-message "two sink_5_23467|no known conversion" } -three sink_5_23467(volatile A&); // { dg-message "note" } -four sink_5_23467(const volatile A&); // { dg-message "note" } -six sink_5_23467(const A&&); // { dg-message "note" } -seven sink_5_23467(volatile A&&); // { dg-message "note" } +three sink_5_23467(volatile A&); +four sink_5_23467(const volatile A&); +six sink_5_23467(const A&&); +seven sink_5_23467(volatile A&&); int test5_23467() { @@ -573,20 +535,17 @@ int test5_23467() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_23467(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 576 } - sink_5_23467(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 578 } - sink_5_23467(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 580 } + sink_5_23467(a); // { dg-error "" } + sink_5_23467(source()); // { dg-error "" } + sink_5_23467(cv_source()); // { dg-error "" } return 0; } -two sink_5_23468(const A&); // { dg-message "note" } -three sink_5_23468(volatile A&); // { dg-message "note" } -four sink_5_23468(const volatile A&); // { dg-message "note" } -six sink_5_23468(const A&&); // { dg-message "note" } -eight sink_5_23468(const volatile A&&); // { dg-message "note" } +two sink_5_23468(const A&); +three sink_5_23468(volatile A&); +four sink_5_23468(const volatile A&); +six sink_5_23468(const A&&); +eight sink_5_23468(const volatile A&&); int test5_23468() { @@ -594,16 +553,15 @@ int test5_23468() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_23468(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 597 } + sink_5_23468(a); // { dg-error "" } return 0; } -two sink_5_23478(const A&); // { dg-message "note" } -three sink_5_23478(volatile A&); // { dg-message "note" } -four sink_5_23478(const volatile A&); // { dg-message "note" } -seven sink_5_23478(volatile A&&); // { dg-message "note" } -eight sink_5_23478(const volatile A&&); // { dg-message "note" } +two sink_5_23478(const A&); +three sink_5_23478(volatile A&); +four sink_5_23478(const volatile A&); +seven sink_5_23478(volatile A&&); +eight sink_5_23478(const volatile A&&); int test5_23478() { @@ -611,16 +569,15 @@ int test5_23478() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_23478(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 614 } + sink_5_23478(a); // { dg-error "" } return 0; } two sink_5_23567(const A&); // { dg-message "two sink_5_23567|no known conversion" } -three sink_5_23567(volatile A&); // { dg-message "note" } -five sink_5_23567( A&&); // { dg-message "note" } -six sink_5_23567(const A&&); // { dg-message "note" } -seven sink_5_23567(volatile A&&); // { dg-message "note" } +three sink_5_23567(volatile A&); +five sink_5_23567( A&&); +six sink_5_23567(const A&&); +seven sink_5_23567(volatile A&&); int test5_23567() { @@ -628,20 +585,17 @@ int test5_23567() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_23567(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 631 } - sink_5_23567(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 633 } - sink_5_23567(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 635 } + sink_5_23567(a); // { dg-error "" } + sink_5_23567(cva); // { dg-error "" } + sink_5_23567(cv_source()); // { dg-error "" } return 0; } -two sink_5_23568(const A&); // { dg-message "note" } -three sink_5_23568(volatile A&); // { dg-message "note" } -five sink_5_23568( A&&); // { dg-message "note" } -six sink_5_23568(const A&&); // { dg-message "note" } -eight sink_5_23568(const volatile A&&); // { dg-message "" } +two sink_5_23568(const A&); +three sink_5_23568(volatile A&); +five sink_5_23568( A&&); +six sink_5_23568(const A&&); +eight sink_5_23568(const volatile A&&); int test5_23568() { @@ -649,16 +603,15 @@ int test5_23568() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_23568(cva); // { dg-error "lvalue" } - sink_5_23568(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 653 } + sink_5_23568(cva); // { dg-error "" } + sink_5_23568(a); // { dg-error "" } return 0; } -two sink_5_23578(const A&); // { dg-message "note" } -three sink_5_23578(volatile A&); // { dg-message "note" } -five sink_5_23578( A&&); // { dg-message "note" } -seven sink_5_23578(volatile A&&); // { dg-message "note" } +two sink_5_23578(const A&); +three sink_5_23578(volatile A&); +five sink_5_23578( A&&); +seven sink_5_23578(volatile A&&); eight sink_5_23578(const volatile A&&); // { dg-message "" } int test5_23578() @@ -667,16 +620,15 @@ int test5_23578() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_23578(cva); // { dg-error "lvalue" } - sink_5_23578(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 671 } + sink_5_23578(cva); // { dg-error "" } + sink_5_23578(a); // { dg-error "" } return 0; } -two sink_5_23678(const A&); // { dg-message "note" } -three sink_5_23678(volatile A&); // { dg-message "note" } -six sink_5_23678(const A&&); // { dg-message "note" } -seven sink_5_23678(volatile A&&); // { dg-message "note" } +two sink_5_23678(const A&); +three sink_5_23678(volatile A&); +six sink_5_23678(const A&&); +seven sink_5_23678(volatile A&&); eight sink_5_23678(const volatile A&&); // { dg-message "" } int test5_23678() @@ -685,19 +637,17 @@ int test5_23678() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_23678(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 688 } - sink_5_23678(cva); // { dg-error "lvalue" } - sink_5_23678(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 691 } + sink_5_23678(a); // { dg-error "" } + sink_5_23678(cva); // { dg-error "" } + sink_5_23678(source()); // { dg-error "" } return 0; } two sink_5_24567(const A&); // { dg-message "two sink_5_24567|no known conversion" } -four sink_5_24567(const volatile A&); // { dg-message "note" } -five sink_5_24567( A&&); // { dg-message "note" } -six sink_5_24567(const A&&); // { dg-message "note" } -seven sink_5_24567(volatile A&&); // { dg-message "note" } +four sink_5_24567(const volatile A&); +five sink_5_24567( A&&); +six sink_5_24567(const A&&); +seven sink_5_24567(volatile A&&); int test5_24567() { @@ -705,16 +655,15 @@ int test5_24567() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_24567(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 708 } + sink_5_24567(cv_source()); // { dg-error "" } return 0; } -two sink_5_24678(const A&); // { dg-message "note" } +two sink_5_24678(const A&); four sink_5_24678(const volatile A&); -six sink_5_24678(const A&&); // { dg-message "note" } -seven sink_5_24678(volatile A&&); // { dg-message "note" } -eight sink_5_24678(const volatile A&&); // { dg-message "note" } +six sink_5_24678(const A&&); +seven sink_5_24678(volatile A&&); +eight sink_5_24678(const volatile A&&); int test5_24678() { @@ -722,8 +671,7 @@ int test5_24678() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_24678(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 725 } + sink_5_24678(source()); // { dg-error "" } return 0; } @@ -739,16 +687,16 @@ int test5_25678() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_25678(va); // { dg-error "lvalue" } - sink_5_25678(cva); // { dg-error "lvalue" } + sink_5_25678(va); // { dg-error "" } + sink_5_25678(cva); // { dg-error "" } return 0; } three sink_5_34567(volatile A&); // { dg-message "three sink_5_34567|no known conversion" } -four sink_5_34567(const volatile A&); // { dg-message "note" } -five sink_5_34567( A&&); // { dg-message "note" } -six sink_5_34567(const A&&); // { dg-message "note" } -seven sink_5_34567(volatile A&&); // { dg-message "note" } +four sink_5_34567(const volatile A&); +five sink_5_34567( A&&); +six sink_5_34567(const A&&); +seven sink_5_34567(volatile A&&); int test5_34567() { @@ -756,16 +704,15 @@ int test5_34567() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_34567(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 759 } + sink_5_34567(cv_source()); // { dg-error "" } return 0; } three sink_5_34678(volatile A&); four sink_5_34678(const volatile A&); -six sink_5_34678(const A&&); // { dg-message "note" } -seven sink_5_34678(volatile A&&); // { dg-message "note" } -eight sink_5_34678(const volatile A&&); // { dg-message "note" } +six sink_5_34678(const A&&); +seven sink_5_34678(volatile A&&); +eight sink_5_34678(const volatile A&&); int test5_34678() { @@ -773,8 +720,7 @@ int test5_34678() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_34678(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 776 } + sink_5_34678(source()); // { dg-error "" } return 0; } @@ -790,8 +736,8 @@ int test5_35678() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_5_35678(ca); // { dg-error "lvalue" } - sink_5_35678(cva); // { dg-error "lvalue" } + sink_5_35678(ca); // { dg-error "" } + sink_5_35678(cva); // { dg-error "" } return 0; } diff --git a/gcc/testsuite/g++.dg/cpp0x/rv6n.C b/gcc/testsuite/g++.dg/cpp0x/rv6n.C index d00c1e242b..0ebbe33e1d 100644 --- a/gcc/testsuite/g++.dg/cpp0x/rv6n.C +++ b/gcc/testsuite/g++.dg/cpp0x/rv6n.C @@ -3,7 +3,7 @@ // Test overload resolution among reference types // { dg-do compile { target c++11 } } -// { dg-options "" } +// { dg-options "-fno-ipa-icf" } template <bool> struct sa; template <> struct sa<true> {}; @@ -31,11 +31,11 @@ const volatile A cv_source(); // 6 at a time one sink_6_123456( A&); // { dg-message "one sink_6_123456|no known conversion" } -two sink_6_123456(const A&); // { dg-message "note" } -three sink_6_123456(volatile A&); // { dg-message "note" } -four sink_6_123456(const volatile A&); // { dg-message "note" } -five sink_6_123456( A&&); // { dg-message "note" } -six sink_6_123456(const A&&); // { dg-message "note" } +two sink_6_123456(const A&); +three sink_6_123456(volatile A&); +four sink_6_123456(const volatile A&); +five sink_6_123456( A&&); +six sink_6_123456(const A&&); int test6_123456() { @@ -43,19 +43,17 @@ int test6_123456() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_6_123456(v_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 46 } - sink_6_123456(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 48 } + sink_6_123456(v_source()); // { dg-error "" } + sink_6_123456(cv_source()); // { dg-error "" } return 0; } one sink_6_123457( A&); // { dg-message "one sink_6_123457|no known conversion" } -two sink_6_123457(const A&); // { dg-message "note" } -three sink_6_123457(volatile A&); // { dg-message "note" } -four sink_6_123457(const volatile A&); // { dg-message "note" } -five sink_6_123457( A&&); // { dg-message "note" } -seven sink_6_123457(volatile A&&); // { dg-message "note" } +two sink_6_123457(const A&); +three sink_6_123457(volatile A&); +four sink_6_123457(const volatile A&); +five sink_6_123457( A&&); +seven sink_6_123457(volatile A&&); int test6_123457() { @@ -63,16 +61,15 @@ int test6_123457() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_6_123457(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 66 } + sink_6_123457(cv_source()); // { dg-error "" } return 0; } -two sink_6_235678(const A&); // { dg-message "note" } -three sink_6_235678(volatile A&); // { dg-message "note" } -five sink_6_235678( A&&); // { dg-message "note" } -six sink_6_235678(const A&&); // { dg-message "note" } -seven sink_6_235678(volatile A&&); // { dg-message "note" } +two sink_6_235678(const A&); +three sink_6_235678(volatile A&); +five sink_6_235678( A&&); +six sink_6_235678(const A&&); +seven sink_6_235678(volatile A&&); eight sink_6_235678(const volatile A&&); // { dg-message "" } int test6_235678() @@ -81,18 +78,17 @@ int test6_235678() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_6_235678(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 84 } - sink_6_235678(cva); // { dg-error "lvalue" } + sink_6_235678(a); // { dg-error "" } + sink_6_235678(cva); // { dg-error "" } return 0; } -two sink_6_234678(const A&); // { dg-message "note" } -three sink_6_234678(volatile A&); // { dg-message "note" } -four sink_6_234678(const volatile A&); // { dg-message "note" } -six sink_6_234678(const A&&); // { dg-message "note" } -seven sink_6_234678(volatile A&&); // { dg-message "note" } -eight sink_6_234678(const volatile A&&); // { dg-message "note" } +two sink_6_234678(const A&); +three sink_6_234678(volatile A&); +four sink_6_234678(const volatile A&); +six sink_6_234678(const A&&); +seven sink_6_234678(volatile A&&); +eight sink_6_234678(const volatile A&&); int test6_234678() { @@ -100,19 +96,17 @@ int test6_234678() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_6_234678(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 103 } - sink_6_234678(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 105 } + sink_6_234678(a); // { dg-error "" } + sink_6_234678(source()); // { dg-error "" } return 0; } -two sink_6_234578(const A&); // { dg-message "note" } -three sink_6_234578(volatile A&); // { dg-message "note" } -four sink_6_234578(const volatile A&); // { dg-message "note" } -five sink_6_234578( A&&); // { dg-message "note" } -seven sink_6_234578(volatile A&&); // { dg-message "note" } -eight sink_6_234578(const volatile A&&); // { dg-message "note" } +two sink_6_234578(const A&); +three sink_6_234578(volatile A&); +four sink_6_234578(const volatile A&); +five sink_6_234578( A&&); +seven sink_6_234578(volatile A&&); +eight sink_6_234578(const volatile A&&); int test6_234578() { @@ -120,17 +114,16 @@ int test6_234578() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_6_234578(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 123 } + sink_6_234578(a); // { dg-error "" } return 0; } -two sink_6_234568(const A&); // { dg-message "note" } -three sink_6_234568(volatile A&); // { dg-message "note" } -four sink_6_234568(const volatile A&); // { dg-message "note" } -five sink_6_234568( A&&); // { dg-message "note" } -six sink_6_234568(const A&&); // { dg-message "note" } -eight sink_6_234568(const volatile A&&); // { dg-message "note" } +two sink_6_234568(const A&); +three sink_6_234568(volatile A&); +four sink_6_234568(const volatile A&); +five sink_6_234568( A&&); +six sink_6_234568(const A&&); +eight sink_6_234568(const volatile A&&); int test6_234568() { @@ -138,17 +131,16 @@ int test6_234568() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_6_234568(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 141 } + sink_6_234568(a); // { dg-error "" } return 0; } two sink_6_234567(const A&); // { dg-message "two sink_6_234567|no known conversion" } -three sink_6_234567(volatile A&); // { dg-message "note" } -four sink_6_234567(const volatile A&); // { dg-message "note" } -five sink_6_234567( A&&); // { dg-message "note" } -six sink_6_234567(const A&&); // { dg-message "note" } -seven sink_6_234567(volatile A&&); // { dg-message "note" } +three sink_6_234567(volatile A&); +four sink_6_234567(const volatile A&); +five sink_6_234567( A&&); +six sink_6_234567(const A&&); +seven sink_6_234567(volatile A&&); int test6_234567() { @@ -156,19 +148,17 @@ int test6_234567() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_6_234567(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 159 } - sink_6_234567(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 161 } + sink_6_234567(a); // { dg-error "" } + sink_6_234567(cv_source()); // { dg-error "" } return 0; } one sink_6_134678( A&); three sink_6_134678(volatile A&); four sink_6_134678(const volatile A&); -six sink_6_134678(const A&&); // { dg-message "note" } -seven sink_6_134678(volatile A&&); // { dg-message "note" } -eight sink_6_134678(const volatile A&&); // { dg-message "note" } +six sink_6_134678(const A&&); +seven sink_6_134678(volatile A&&); +eight sink_6_134678(const volatile A&&); int test6_134678() { @@ -176,17 +166,16 @@ int test6_134678() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_6_134678(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 179 } + sink_6_134678(source()); // { dg-error "" } return 0; } one sink_6_124678( A&); -two sink_6_124678(const A&); // { dg-message "note" } +two sink_6_124678(const A&); four sink_6_124678(const volatile A&); -six sink_6_124678(const A&&); // { dg-message "note" } -seven sink_6_124678(volatile A&&); // { dg-message "note" } -eight sink_6_124678(const volatile A&&); // { dg-message "note" } +six sink_6_124678(const A&&); +seven sink_6_124678(volatile A&&); +eight sink_6_124678(const volatile A&&); int test6_124678() { @@ -194,16 +183,15 @@ int test6_124678() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_6_124678(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 197 } + sink_6_124678(source()); // { dg-error "" } return 0; } one sink_6_123678( A&); -two sink_6_123678(const A&); // { dg-message "note" } +two sink_6_123678(const A&); three sink_6_123678(volatile A&); -six sink_6_123678(const A&&); // { dg-message "note" } -seven sink_6_123678(volatile A&&); // { dg-message "note" } +six sink_6_123678(const A&&); +seven sink_6_123678(volatile A&&); eight sink_6_123678(const volatile A&&); // { dg-message "" } int test6_123678() @@ -212,18 +200,17 @@ int test6_123678() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_6_123678(cva); // { dg-error "lvalue" } - sink_6_123678(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 216 } + sink_6_123678(cva); // { dg-error "" } + sink_6_123678(source()); // { dg-error "" } return 0; } one sink_6_123567( A&); // { dg-message "one sink_6_123567|no known conversion" } -two sink_6_123567(const A&); // { dg-message "note" } -three sink_6_123567(volatile A&); // { dg-message "note" } -five sink_6_123567( A&&); // { dg-message "note" } -six sink_6_123567(const A&&); // { dg-message "note" } -seven sink_6_123567(volatile A&&); // { dg-message "note" } +two sink_6_123567(const A&); +three sink_6_123567(volatile A&); +five sink_6_123567( A&&); +six sink_6_123567(const A&&); +seven sink_6_123567(volatile A&&); int test6_123567() { @@ -231,10 +218,8 @@ int test6_123567() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_6_123567(cva); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 234 } - sink_6_123567(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 236 } + sink_6_123567(cva); // { dg-error "" } + sink_6_123567(cv_source()); // { dg-error "" } return 0; } @@ -251,7 +236,7 @@ int test6_123568() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_6_123568(cva); // { dg-error "lvalue" } + sink_6_123568(cva); // { dg-error "" } return 0; } @@ -268,16 +253,16 @@ int test6_123578() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_6_123578(cva); // { dg-error "lvalue" } + sink_6_123578(cva); // { dg-error "" } return 0; } one sink_6_123467( A&); // { dg-message "one sink_6_123467|no known conversion" } -two sink_6_123467(const A&); // { dg-message "note" } -three sink_6_123467(volatile A&); // { dg-message "note" } -four sink_6_123467(const volatile A&); // { dg-message "note" } -six sink_6_123467(const A&&); // { dg-message "note" } -seven sink_6_123467(volatile A&&); // { dg-message "note" } +two sink_6_123467(const A&); +three sink_6_123467(volatile A&); +four sink_6_123467(const volatile A&); +six sink_6_123467(const A&&); +seven sink_6_123467(volatile A&&); int test6_123467() { @@ -285,19 +270,17 @@ int test6_123467() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_6_123467(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 288 } - sink_6_123467(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 290 } + sink_6_123467(source()); // { dg-error "" } + sink_6_123467(cv_source()); // { dg-error "" } return 0; } one sink_6_124567( A&); // { dg-message "one sink_6_124567|no known conversion" } -two sink_6_124567(const A&); // { dg-message "note" } -four sink_6_124567(const volatile A&); // { dg-message "note" } -five sink_6_124567( A&&); // { dg-message "note" } -six sink_6_124567(const A&&); // { dg-message "note" } -seven sink_6_124567(volatile A&&); // { dg-message "note" } +two sink_6_124567(const A&); +four sink_6_124567(const volatile A&); +five sink_6_124567( A&&); +six sink_6_124567(const A&&); +seven sink_6_124567(volatile A&&); int test6_124567() { @@ -305,8 +288,7 @@ int test6_124567() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_6_124567(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 308 } + sink_6_124567(cv_source()); // { dg-error "" } return 0; } @@ -323,17 +305,17 @@ int test6_125678() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_6_125678(va); // { dg-error "lvalue" } - sink_6_125678(cva); // { dg-error "lvalue" } + sink_6_125678(va); // { dg-error "" } + sink_6_125678(cva); // { dg-error "" } return 0; } one sink_6_134567( A&); // { dg-message "one sink_6_134567|no known conversion" } -three sink_6_134567(volatile A&); // { dg-message "note" } -four sink_6_134567(const volatile A&); // { dg-message "note" } -five sink_6_134567( A&&); // { dg-message "note" } -six sink_6_134567(const A&&); // { dg-message "note" } -seven sink_6_134567(volatile A&&); // { dg-message "note" } +three sink_6_134567(volatile A&); +four sink_6_134567(const volatile A&); +five sink_6_134567( A&&); +six sink_6_134567(const A&&); +seven sink_6_134567(volatile A&&); int test6_134567() { @@ -341,8 +323,7 @@ int test6_134567() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_6_134567(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 344 } + sink_6_134567(cv_source()); // { dg-error "" } return 0; } @@ -359,8 +340,8 @@ int test6_135678() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_6_135678(ca); // { dg-error "lvalue" } - sink_6_135678(cva); // { dg-error "lvalue" } + sink_6_135678(ca); // { dg-error "" } + sink_6_135678(cva); // { dg-error "" } return 0; } diff --git a/gcc/testsuite/g++.dg/cpp0x/rv7n.C b/gcc/testsuite/g++.dg/cpp0x/rv7n.C index 7e7a6648e2..d9e371b8ad 100644 --- a/gcc/testsuite/g++.dg/cpp0x/rv7n.C +++ b/gcc/testsuite/g++.dg/cpp0x/rv7n.C @@ -3,7 +3,7 @@ // Test overload resolution among reference types // { dg-do compile { target c++11 } } -// { dg-options "" } +// { dg-options "-fno-ipa-icf" } template <bool> struct sa; template <> struct sa<true> {}; @@ -31,12 +31,12 @@ const volatile A cv_source(); // 7 at a time one sink_7_1234567( A&); // { dg-message "one sink_7_1234567|no known conversion" } -two sink_7_1234567(const A&); // { dg-message "note" } -three sink_7_1234567(volatile A&); // { dg-message "note" } -four sink_7_1234567(const volatile A&); // { dg-message "note" } -five sink_7_1234567( A&&); // { dg-message "note" } -six sink_7_1234567(const A&&); // { dg-message "note" } -seven sink_7_1234567(volatile A&&); // { dg-message "note" } +two sink_7_1234567(const A&); +three sink_7_1234567(volatile A&); +four sink_7_1234567(const volatile A&); +five sink_7_1234567( A&&); +six sink_7_1234567(const A&&); +seven sink_7_1234567(volatile A&&); int test7_1234567() { @@ -44,8 +44,7 @@ int test7_1234567() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_7_1234567(cv_source()); // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 47 } + sink_7_1234567(cv_source()); // { dg-error "" } return 0; } @@ -63,17 +62,17 @@ int test7_1235678() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_7_1235678(cva); // { dg-error "lvalue" } + sink_7_1235678(cva); // { dg-error "" } return 0; } -two sink_7_2345678(const A&); // { dg-message "note" } -three sink_7_2345678(volatile A&); // { dg-message "note" } -four sink_7_2345678(const volatile A&); // { dg-message "note" } -five sink_7_2345678( A&&); // { dg-message "note" } -six sink_7_2345678(const A&&); // { dg-message "note" } -seven sink_7_2345678(volatile A&&); // { dg-message "note" } -eight sink_7_2345678(const volatile A&&); // { dg-message "note" } +two sink_7_2345678(const A&); +three sink_7_2345678(volatile A&); +four sink_7_2345678(const volatile A&); +five sink_7_2345678( A&&); +six sink_7_2345678(const A&&); +seven sink_7_2345678(volatile A&&); +eight sink_7_2345678(const volatile A&&); int test7_2345678() { @@ -81,18 +80,17 @@ int test7_2345678() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_7_2345678(a); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 84 } + sink_7_2345678(a); // { dg-error "" } return 0; } one sink_7_1234678( A&); -two sink_7_1234678(const A&); // { dg-message "note" } +two sink_7_1234678(const A&); three sink_7_1234678(volatile A&); four sink_7_1234678(const volatile A&); -six sink_7_1234678(const A&&); // { dg-message "note" } -seven sink_7_1234678(volatile A&&); // { dg-message "note" } -eight sink_7_1234678(const volatile A&&); // { dg-message "note" } +six sink_7_1234678(const A&&); +seven sink_7_1234678(volatile A&&); +eight sink_7_1234678(const volatile A&&); int test7_1234678() { @@ -100,8 +98,7 @@ int test7_1234678() const A ca = a; // { dg-error "deleted" } volatile A va; const volatile A cva = a; // { dg-error "deleted" } - sink_7_1234678(source()); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 103 } + sink_7_1234678(source()); // { dg-error "" } return 0; } diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae-nullptr1.C b/gcc/testsuite/g++.dg/cpp0x/sfinae-nullptr1.C new file mode 100644 index 0000000000..7f3c5c4eb3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae-nullptr1.C @@ -0,0 +1,18 @@ +// DR 1423, PR c++/52174 +// { dg-do compile { target c++11 } } + +template<class T> +T&& make(); + +template<class T> +void sink(T); + +template<class T1, class T2, + class = decltype(sink<T2>(make<T1>())) +> +auto f(int) -> char(&)[1]; + +template<class, class> +auto f(...) -> char(&)[2]; + +static_assert(sizeof(f<decltype(nullptr), bool>(0)) != 1, ""); diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae51.C b/gcc/testsuite/g++.dg/cpp0x/sfinae51.C new file mode 100644 index 0000000000..380811dce0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae51.C @@ -0,0 +1,28 @@ +// PR c++/59705 +// { dg-do compile { target c++11 } } + +struct HasIter { + typedef int * const_iterator; +}; + +struct NoIter { +}; + +template <typename T> +constexpr bool foo(const T &, typename T::const_iterator *) +{ + return true; +} + +template <typename T> +constexpr bool foo(const T &, ...) +{ + return false; +} + +HasIter has_iter; +NoIter no_iter; + +static_assert (!foo(no_iter, 0), ""); +static_assert (foo(has_iter, 0), ""); +static_assert (foo<HasIter>(has_iter, 0), ""); diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae52.C b/gcc/testsuite/g++.dg/cpp0x/sfinae52.C new file mode 100644 index 0000000000..f255ee120c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae52.C @@ -0,0 +1,21 @@ +// PR c++/62072 +// { dg-do compile { target c++11 } } + +template<typename T> struct tuple_size {}; +template<typename T> struct tuple_size<T const> : tuple_size<T> {}; + +template<typename T, typename = void> +struct query { + static constexpr bool value = false; +}; +template<typename T> +struct query<T, typename tuple_size<T>::type> { + static constexpr bool value = true; +}; + +// fine +static_assert( !query<int>::value, "" ); +static_assert( !query<int const>::value, "" ); + +// error: invalid use of incomplete type 'struct tuple_size<void()>' +static_assert( !query<void()>::value, "" ); diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae53.C b/gcc/testsuite/g++.dg/cpp0x/sfinae53.C new file mode 100644 index 0000000000..19b00cf0c5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae53.C @@ -0,0 +1,23 @@ +// PR c++/59204 +// { dg-do compile { target c++11 } } + +template< class T > + using void_t = void; + +template< class T, class = void > + struct has_type +{ constexpr static bool value = false; }; + +template< class T > + struct has_type<T, void_t<typename T::type>> +{ constexpr static bool value = true; }; + +struct yes { using type = int; }; +struct no { }; + +int +main( ) +{ + static_assert( has_type<yes>::value, "false negative!" ); + static_assert( not has_type<no >::value, "false positive!" ); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae54.C b/gcc/testsuite/g++.dg/cpp0x/sfinae54.C new file mode 100644 index 0000000000..f681fa7fa3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae54.C @@ -0,0 +1,41 @@ +// PR c++/63723 +// { dg-do compile { target c++11 } } + +template<typename Tp> Tp declval(); + +template<typename Tp, Tp v> +struct integral_constant +{ + static constexpr Tp value = v; + typedef Tp value_type; + typedef integral_constant<Tp, v> type; + constexpr operator value_type() const { return value; } +}; + +typedef integral_constant<bool, true> true_type; +typedef integral_constant<bool, false> false_type; + +template <typename From, typename To> +class is_list_convertible_helper +{ + template <typename To2> + static void requires_conversion(To2 t); + + template <typename From2, typename To2, + typename = decltype(requires_conversion<To2>({declval<From2>()}))> + static true_type helper(int); + + template <typename From2, typename To2> + static false_type helper(...); + +public: + using type = decltype(helper<From, To>(0)); +}; + +template <typename From, typename To> +class is_list_convertible + : public is_list_convertible_helper<From, To>::type +{ }; + +static_assert(!is_list_convertible<double, int>::value, + "double -> int is narrowing!"); diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae55.C b/gcc/testsuite/g++.dg/cpp0x/sfinae55.C new file mode 100644 index 0000000000..7b6557ee7d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae55.C @@ -0,0 +1,33 @@ +// PR c++/64970 +// { dg-do compile { target c++11 } } + +template<typename T> +T && declval(); + +template<typename T> +struct void_ { using type = void; }; + +template<typename T> +using void_t = typename void_<T>::type; + +template<class A, class B> +struct Outer +{ + template<class C, class D> + using Inner = decltype(true ? declval<C>() : declval<D>()); +}; + +template<class A, class B, typename Enable = void> +struct S +{}; + +template<class A, class B> +struct S<A, B, void_t<typename Outer<A, B>::template Inner<A, B>>> +{}; + +struct A{}; +struct B{}; +int main() +{ + S<A, B> s; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/static_assert10.C b/gcc/testsuite/g++.dg/cpp0x/static_assert10.C index 216f2595b6..e7f728e3f4 100644 --- a/gcc/testsuite/g++.dg/cpp0x/static_assert10.C +++ b/gcc/testsuite/g++.dg/cpp0x/static_assert10.C @@ -4,5 +4,5 @@ template<typename T> bool foo(T) { int i; - static_assert(foo(i), "Error"); // { dg-error "non-constant condition|not usable" } + static_assert(foo(i), "Error"); // { dg-error "non-constant condition|not usable|non-constexpr" } } diff --git a/gcc/testsuite/g++.dg/cpp0x/trailing2.C b/gcc/testsuite/g++.dg/cpp0x/trailing2.C index 888d6f958f..bfc2712a74 100644 --- a/gcc/testsuite/g++.dg/cpp0x/trailing2.C +++ b/gcc/testsuite/g++.dg/cpp0x/trailing2.C @@ -3,14 +3,14 @@ // { dg-do compile { target c++11 } } auto f1 () -> int; -auto f2 (); // { dg-error "without trailing return type" "" { target { ! c++1y } } } +auto f2 (); // { dg-error "without trailing return type" "" { target { ! c++14 } } } int f3 () -> int; // { dg-error "trailing return type" } auto *f4 () -> int; // { dg-error "trailing return type" } struct A { auto f5 () const -> int; - auto f6 (); // { dg-error "without trailing return type" "" { target { ! c++1y } } } + auto f6 (); // { dg-error "without trailing return type" "" { target { ! c++14 } } } int f7 () -> int; // { dg-error "trailing return type" } auto *f8 () -> int; // { dg-error "trailing return type" } }; diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-namespace-ambiguous.C b/gcc/testsuite/g++.dg/cpp0x/udlit-namespace-ambiguous.C new file mode 100644 index 0000000000..c67be390f8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-namespace-ambiguous.C @@ -0,0 +1,10 @@ +// { dg-do compile { target c++11 } } + +int operator""_t (long long unsigned); // { dg-message "note: candidate"} + +namespace foo { + int operator""_t (long long unsigned); // { dg-message "note: candidate"} +} + +using namespace foo; +int var = 10_t; // { dg-error "call of overloaded | is ambiguous" } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-namespace-using-directive.C b/gcc/testsuite/g++.dg/cpp0x/udlit-namespace-using-directive.C new file mode 100644 index 0000000000..bd1f2066ea --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-namespace-using-directive.C @@ -0,0 +1,16 @@ +// { dg-do compile { target c++11 } } + +int operator""_t(long long unsigned) { + return 0; +} + +namespace foo { + int operator""_t(long long unsigned) { + return 0; + } +} + +int main() { + using foo::operator""_t; + 10_t; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-resolve.C b/gcc/testsuite/g++.dg/cpp0x/udlit-resolve.C index 4241d0a803..c1ceef7577 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-resolve.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-resolve.C @@ -17,15 +17,10 @@ int operator"" _foo(const char32_t*, std::size_t) { return 10; } template<char...> int operator"" _foo2() { return 20; } int operator"" _foo2(unsigned long long int) { return 21; } -namespace bar { -int operator"" _foo(unsigned long long int) { return 101; } -} -using namespace bar; - int main() { - assert(123_foo == 101); + assert(123_foo == 1); assert(0.123_foo == 2); assert('c'_foo == 3); assert(L'c'_foo == 4); diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-sfinae-neg.C b/gcc/testsuite/g++.dg/cpp0x/udlit-sfinae-neg.C new file mode 100644 index 0000000000..6b84eba31d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-sfinae-neg.C @@ -0,0 +1,21 @@ +// { dg-do compile { target c++11 } } +// { dg-prune-output "note:" } + +template<bool, typename _Tp = void> struct enable_if { }; +template<typename _Tp> struct enable_if<true, _Tp> { typedef _Tp type; }; + +template <char... c> +constexpr typename enable_if<sizeof...(c) == 2, int>::type operator""_t () // { dg-error "no type named|in" } +{ + return 2; +} + +template <char... c> +constexpr typename enable_if<sizeof...(c) == 1, int>::type operator""_t () // { dg-error "no type named|in" } +{ + return 1; +} + +int a = 45_t; +int b = 4_t; +int c = 100000_t; // { dg-error "no matching function for call to" } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-sfinae.C b/gcc/testsuite/g++.dg/cpp0x/udlit-sfinae.C new file mode 100644 index 0000000000..e24b79d9f0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-sfinae.C @@ -0,0 +1,38 @@ +// { dg-do run { target c++11 } } + +#include <cassert> + +template<bool, typename _Tp = void> struct enable_if { }; +template<typename _Tp> struct enable_if<true, _Tp> { typedef _Tp type; }; + + +template <char... c> +constexpr typename enable_if<sizeof...(c) == 2, int>::type operator""_t () +{ + return 2; +} + +template <char... c> +constexpr typename enable_if<sizeof...(c) == 1, int>::type operator""_t () +{ + return 1; +} + +template <char... c> +constexpr typename enable_if<sizeof...(c) >= 3, int>::type operator""_t () +{ + return 100; +} + +int operator""_t (long double) +{ + return 200; +} + +int main () +{ + assert (45_t == 2); + assert (4_t == 1); + assert (100000_t == 100); + assert (200.0_t == 200); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/union6.C b/gcc/testsuite/g++.dg/cpp0x/union6.C new file mode 100644 index 0000000000..1706da9db5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/union6.C @@ -0,0 +1,20 @@ +// PR c++/60184 +// { dg-do compile { target c++11 } } + +union Test1 { + static int kConstant; +}; + +union Test2 { + static const int kConstant; +}; + +const int Test2::kConstant = 10; + +union Test3 { + int& kConstant; +}; + +union Test4 { + const int& kConstant = 10; +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/using-enum-1.C b/gcc/testsuite/g++.dg/cpp0x/using-enum-1.C new file mode 100644 index 0000000000..9904d59aaa --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/using-enum-1.C @@ -0,0 +1,20 @@ +// PR c++/60265 +// { dg-do compile { target c++11 } } + +namespace A +{ + enum E { V }; + + using E::V; +} + +void foo() +{ + using A::E::V; +} + +using A::E::V; + +enum F { U }; + +using F::U; diff --git a/gcc/testsuite/g++.dg/cpp0x/using-enum-2.C b/gcc/testsuite/g++.dg/cpp0x/using-enum-2.C new file mode 100644 index 0000000000..0738c802b3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/using-enum-2.C @@ -0,0 +1,20 @@ +// PR c++/60265 +// { dg-do compile { target c++11 } } + +namespace A +{ + enum class E { V }; + + using E::V; // { dg-error "not a namespace or unscoped enum" } +} + +void foo() +{ + using A::E::V; // { dg-error "not a namespace or unscoped enum" } +} + +using A::E::V; // { dg-error "not a namespace or unscoped enum" } + +enum class F { U }; + +using F::U; // { dg-error "not a namespace or unscoped enum" } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex10.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex10.C index 3df356aaf3..f4216a46d5 100644 --- a/gcc/testsuite/g++.dg/cpp0x/variadic-ex10.C +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex10.C @@ -5,5 +5,4 @@ Tuple<> t0; // Types contains no arguments Tuple<int> t1; // Types contains one argument: int Tuple<int, float> t2; // Types contains two arguments: int and float Tuple<0> error; // { dg-error "mismatch" "mismatch" } -// { dg-error "expected a type" "expected a type" { target *-*-* } 7 } -// { dg-error "in declaration" "in declaration" { target *-*-* } 7 } +// { dg-message "expected a type" "expected a type" { target *-*-* } 7 } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex14.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex14.C index 600b798684..e301e7ac38 100644 --- a/gcc/testsuite/g++.dg/cpp0x/variadic-ex14.C +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex14.C @@ -9,11 +9,9 @@ template<template<class...> class Q> class Y { /* ... */ }; X<A> xA; // okay X<B> xB; // { dg-error "mismatch" "mismatch" } -// { dg-error "expected a template" "expected" { target *-*-* } 11 } -// { dg-error "invalid type" "invalid" { target *-*-* } 11 } +// { dg-message "expected a template" "expected" { target *-*-* } 11 } X<C> xC; // { dg-error "mismatch" "mismatch" } -// { dg-error "expected a template" "expected" { target *-*-* } 14 } -// { dg-error "invalid type" "invalid" { target *-*-* } 14 } +// { dg-message "expected a template" "expected" { target *-*-* } 13 } Y<A> yA; Y<B> yB; Y<C> yC; // okay diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex2.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex2.C index 015d9d8403..a887e33984 100644 --- a/gcc/testsuite/g++.dg/cpp0x/variadic-ex2.C +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex2.C @@ -1,5 +1,5 @@ // { dg-do compile { target c++11 } } -template<class... Types> struct B { // { dg-error "declaration of" } +template<class... Types> struct B { // { dg-message "declaration of" } void f3(); void f4(); }; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic157.C b/gcc/testsuite/g++.dg/cpp0x/variadic157.C new file mode 100644 index 0000000000..40aa3801d0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic157.C @@ -0,0 +1,28 @@ +// PR c++/58353 +// { dg-do compile { target c++11 } } + +template<class E, E V, int CNT> +struct seq_t +{ + template<E... Es> struct seq{}; + + template<int N, E... Es> + struct gen : gen<N - 1, V, Es...>{}; + + template<E... Es> + struct gen<0, Es...> : seq<Es...>{}; + + struct bits_t{ E e[CNT]; }; + + template<E... Es> + static bits_t init(seq<Es...>) {return {{Es...}};} + + static bits_t init() {return init(gen<CNT>{});} +}; + +typedef seq_t<int, 123, 5> wow; + +int main() +{ + wow::init(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic163.C b/gcc/testsuite/g++.dg/cpp0x/variadic163.C new file mode 100644 index 0000000000..1f3d90956d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic163.C @@ -0,0 +1,21 @@ +// PR c++/63786 +// { dg-do compile { target c++11 } } +// { dg-options "" } + +template <int... Is> +int f(int i) { + switch (i) { + case Is: // { dg-error "not expanded" } + return 0; + } + + switch (i) { + case 0 ...Is: // { dg-error "not expanded" } + return 0; + } + return 0; +} + +int main() { + f<1,2,3>(1); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic164.C b/gcc/testsuite/g++.dg/cpp0x/variadic164.C new file mode 100644 index 0000000000..8f9cdb18c2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic164.C @@ -0,0 +1,12 @@ +// PR c++/63522 +// { dg-do compile { target c++11 } } + +template <typename...> struct tuple; +template <typename...> void slice(); +template <int Index, typename...> using slice_result = decltype(slice<Index>); +template <typename Tuple, typename... Tuples, int... ElementIndices, + typename = + typename tuple<slice_result<ElementIndices, Tuples...>, + slice_result<ElementIndices, Tuples...>...>::type> // { dg-error "parameter pack" } +void zip_with(Tuple...); +decltype(zip_with(0)) d; // { dg-error "no match" } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic165.C b/gcc/testsuite/g++.dg/cpp0x/variadic165.C new file mode 100644 index 0000000000..862931f661 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic165.C @@ -0,0 +1,17 @@ +// PR c++/64514 +// { dg-do compile { target c++11 } } + +template<typename... T> +struct Functor +{ + template <T...> + struct Inner + {}; +}; + +template struct Functor<>::Inner<>; + +int main() +{ + +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic2.C b/gcc/testsuite/g++.dg/cpp0x/variadic2.C index 3d127ea513..65c79bda78 100644 --- a/gcc/testsuite/g++.dg/cpp0x/variadic2.C +++ b/gcc/testsuite/g++.dg/cpp0x/variadic2.C @@ -6,10 +6,9 @@ template<typename... = int> // { dg-error "default argument" } class tuple3; template<typename T1, typename T2, typename... Rest> -struct two_or_more {}; // { dg-error "provided for" } +struct two_or_more {}; // { dg-message "provided for" } -typedef two_or_more<int> bad; // { dg-error "2 or more" "2 or more" } -// { dg-error "invalid type" "invalid type" { target *-*-* } 11 } +typedef two_or_more<int> bad; // { dg-error "at least 2" "at least 2" } void f() { diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic20.C b/gcc/testsuite/g++.dg/cpp0x/variadic20.C index 5b5a234642..4932e66be1 100644 --- a/gcc/testsuite/g++.dg/cpp0x/variadic20.C +++ b/gcc/testsuite/g++.dg/cpp0x/variadic20.C @@ -13,25 +13,25 @@ struct metatuple<add_pointer> { }; template<template<class T> class Meta> -struct metatuple<Meta, Meta> { // { dg-error "candidates" } +struct metatuple<Meta, Meta> { // { dg-message "candidates" } static const int value = 2; }; template<template<class T> class... Metafunctions> -struct metatuple<add_pointer, Metafunctions...> { // { dg-error "" } +struct metatuple<add_pointer, Metafunctions...> { // { dg-message "" } static const int value = 3; }; template<template<class T> class First, template<class T> class... Metafunctions> -struct metatuple<First, Metafunctions...> { // { dg-error "struct" } +struct metatuple<First, Metafunctions...> { // { dg-message "struct" } static const int value = 4; }; template<template<class T> class First, template<class T> class Second, template<class T> class... Metafunctions> -struct metatuple<First, Second, Metafunctions...> { // { dg-error "struct" } +struct metatuple<First, Second, Metafunctions...> { // { dg-message "struct" } static const int value = 5; }; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic40.C b/gcc/testsuite/g++.dg/cpp0x/variadic40.C index e4df9b8bde..e62d62cc1b 100644 --- a/gcc/testsuite/g++.dg/cpp0x/variadic40.C +++ b/gcc/testsuite/g++.dg/cpp0x/variadic40.C @@ -1,3 +1,3 @@ // { dg-do compile { target c++11 } } -template<typename... Values, typename T> -struct backward_tuple {}; // { dg-error "end" } +template<typename... Values, typename T> // { dg-error "end" } +struct backward_tuple {}; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic74.C b/gcc/testsuite/g++.dg/cpp0x/variadic74.C index 1af6531796..b86380b4e2 100644 --- a/gcc/testsuite/g++.dg/cpp0x/variadic74.C +++ b/gcc/testsuite/g++.dg/cpp0x/variadic74.C @@ -20,9 +20,7 @@ A<int*, float*>::X<&i, &f> apple1; B<int, float>::X<&i, &f> banana1; A<int*, float*>::X<&i> apple2; // { dg-error "wrong number of template arguments" "wrong number" } -// { dg-error "invalid type" "invalid" { target *-*-* } 22 } A<int*, float*>::X<&i, &f, &f> apple3; // { dg-error "wrong number of template arguments" "wrong number" } -// { dg-error "invalid type" "invalid" { target *-*-* } 24 } A<int, float> apple4; // { dg-prune-output "provided for" } diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-34052.C b/gcc/testsuite/g++.dg/cpp0x/vt-34052.C index 1036537eb9..31d283131a 100644 --- a/gcc/testsuite/g++.dg/cpp0x/vt-34052.C +++ b/gcc/testsuite/g++.dg/cpp0x/vt-34052.C @@ -1,8 +1,8 @@ // { dg-do compile { target c++11 } } -template<typename... T, typename = T> struct A {}; // { dg-error "must be at the end" } +template<typename... T, typename = T> struct A {}; // { dg-error "parameter pack" } -template<template<typename... T, typename = T> class U> struct B // { dg-error "must be at the end" } +template<template<typename... T, typename = T> class U> struct B // { dg-error "parameter pack" } { - template<int> U<int> foo(); // { dg-error "mismatch|constant|invalid|invalid" } + template<int> U<int> foo(); // { dg-error "mismatch|constant|wrong|invalid" } }; diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-35147.C b/gcc/testsuite/g++.dg/cpp0x/vt-35147.C index 0827beee6a..577b027b23 100644 --- a/gcc/testsuite/g++.dg/cpp0x/vt-35147.C +++ b/gcc/testsuite/g++.dg/cpp0x/vt-35147.C @@ -9,7 +9,6 @@ template<typename... Args> void g(Args&&... args) { f(forward<Args...>(args...)); // { dg-error "no matching" } - // { dg-message "candidate" "candidate note" { target *-*-* } 11 } } void h() diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-57397-1.C b/gcc/testsuite/g++.dg/cpp0x/vt-57397-1.C new file mode 100644 index 0000000000..1d9a1e0761 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-57397-1.C @@ -0,0 +1,22 @@ +// PR c++/57397 +// { dg-do compile { target c++11 } } + +template<class T1, class... Tn> +void foo(T1, Tn...); + +template<class T1, class T2, class... Tn> +void bar(T1, T2, Tn...); + +int main() +{ + foo(); // { dg-error "no matching" } + // { dg-message "candidate expects at least 1 argument, 0 provided" "" { target *-*-* } 12 } + foo(1); + foo(1, 2); + bar(); // { dg-error "no matching" } + // { dg-message "candidate expects at least 2 arguments, 0 provided" "" { target *-*-* } 16 } + bar(1); // { dg-error "no matching" } + // { dg-message "candidate expects at least 2 arguments, 1 provided" "" { target *-*-* } 18 } + bar(1, 2); + bar(1, 2, 3); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-57397-2.C b/gcc/testsuite/g++.dg/cpp0x/vt-57397-2.C new file mode 100644 index 0000000000..d217008fbf --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-57397-2.C @@ -0,0 +1,24 @@ +// PR c++/57397 +// { dg-do compile { target c++11 } } + +template<class T1, class... Tn, class... Tm> +void foo(T1, Tn..., Tm...); + +template<class T1, class T2, class... Tn, class... Tm> +void bar(T1, T2, Tn..., Tm...); + +int main() +{ + foo(); // { dg-error "no matching" } + // { dg-message "candidate expects at least 1 argument, 0 provided" "" { target *-*-* } 12 } + foo(1); + foo(1, 2); + foo(1, 2, 3); + bar(); // { dg-error "no matching" } + // { dg-message "candidate expects at least 2 arguments, 0 provided" "" { target *-*-* } 17 } + bar(1); // { dg-error "no matching" } + // { dg-message "candidate expects at least 2 arguments, 1 provided" "" { target *-*-* } 19 } + bar(1, 2); + bar(1, 2, 3); + bar(1, 2, 3, 4); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-57626.C b/gcc/testsuite/g++.dg/cpp0x/vt-57626.C new file mode 100644 index 0000000000..ca6b7c5196 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-57626.C @@ -0,0 +1,14 @@ +// PR c++/57626 +// { dg-do compile { target c++11 } } + +struct symbol_set{}; + +template <typename T, template <typename ...> class TT, typename ... Args> +using bar = void(T::*)(TT<Args...> &, const symbol_set &); + +struct converter +{ + template <typename Term, typename ... Args, + typename = decltype(bar<Term,Args...>(&Term::multiply))> // { dg-error "pack expansion" } + converter(const Term &); +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-59361.C b/gcc/testsuite/g++.dg/cpp0x/vt-59361.C new file mode 100644 index 0000000000..519ae35dda --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-59361.C @@ -0,0 +1,20 @@ +// PR c++/59361 +// { dg-do compile { target c++11 } } + +template<bool ...Bs> +struct and_ +{ + constexpr static bool value{true}; +}; + +template<typename T> +struct true_ +{ + constexpr operator bool() const { return true; } +}; + +template<typename ...Ts> +constexpr bool foo(Ts...) +{ + return and_<(true_<Ts>())...>::value; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-59988.C b/gcc/testsuite/g++.dg/cpp0x/vt-59988.C new file mode 100644 index 0000000000..ab611f5d86 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-59988.C @@ -0,0 +1,28 @@ +// PR c++/59988 +// { dg-do compile { target c++11 } } + +template<template<typename...> class C, typename... T> +struct is_valid_specialization { + typedef struct { char _; } yes; + typedef struct { yes _[2]; } no; + + template<template<typename...> class D, typename... U> + static yes test(D<U...>*); + template<template<typename...> class D, typename... U> + static no test(...); + + constexpr static bool value = (sizeof(test<C, T...>(0)) == sizeof(yes)); +}; + +template<typename T> +struct Test1 { }; + +template<typename T1, typename T2> +struct Test2 { }; + +template<typename...> +struct TestV { }; + +static_assert(!is_valid_specialization<Test1, int>::value, ""); +static_assert(!is_valid_specialization<Test2, int>::value, ""); +static_assert(!is_valid_specialization<TestV, int>::value, ""); diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-60130.C b/gcc/testsuite/g++.dg/cpp0x/vt-60130.C new file mode 100644 index 0000000000..50662dbe07 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-60130.C @@ -0,0 +1,21 @@ +// PR c++/60130 +// { dg-do compile { target c++11 } } + +#include <tuple> + +template <class S, class F, class... T> +S f1(F f, T... x) +{ + return std::get<0>(std::make_tuple(f(x)...)); +} + +template <class... T> +int f2(const T... x) +{ + return std::get<0>(std::make_tuple(f1<T>([](int n){return n;}, x)...)); +} + +int main() +{ + return f2(42); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-62276.C b/gcc/testsuite/g++.dg/cpp0x/vt-62276.C new file mode 100644 index 0000000000..cd411ecd17 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-62276.C @@ -0,0 +1,9 @@ +// PR c++/62276 +// { dg-do compile { target c++11 } } + +template <typename T> using bar = T; + +template <template <typename...> class F = bar> +void foo() {} + +int main() { foo(); } diff --git a/gcc/testsuite/g++.dg/cpp1y/attr-deprecated-neg.C b/gcc/testsuite/g++.dg/cpp1y/attr-deprecated-neg.C index 134b3b89c0..369f3df996 100644 --- a/gcc/testsuite/g++.dg/cpp1y/attr-deprecated-neg.C +++ b/gcc/testsuite/g++.dg/cpp1y/attr-deprecated-neg.C @@ -1,23 +1,24 @@ // { dg-do compile { target c++11_only } } +// { dg-options "-pedantic" } -class [[deprecated]] A // { dg-warning "attribute directive ignored" } +class [[deprecated]] A // { dg-warning "'deprecated' is a C..14 feature" } { }; -[[deprecated]] +[[deprecated]] // { dg-warning "'deprecated' is a C..14 feature" } int -foo(int n) // { dg-warning "attribute directive ignored" } +foo(int n) { return 42 + n; } -class [[deprecated("B has been superceded by C")]] B // { dg-warning "attribute directive ignored" } +class [[deprecated("B has been superceded by C")]] B // { dg-warning "'deprecated' is a C..14 feature" } { }; -[[deprecated("bar is unsafe; use foobar instead")]] +[[deprecated("bar is unsafe; use foobar instead")]] // { dg-warning "'deprecated' is a C..14 feature" } int -bar(int n) // { dg-warning "attribute directive ignored" } +bar(int n) { return 42 + n - 1; } @@ -47,12 +48,12 @@ foobar(int n) int main() { - A aaa; - int n = foo(12); + A aaa; // { dg-warning "is deprecated" } + int n = foo(12); // { dg-warning "is deprecated" } - B bbb; - int m = bar(666); + B bbb; // { dg-warning "is deprecated" } + int m = bar(666); // { dg-warning "is deprecated" } - C ccc; - int l = foobar(8); + C ccc; // { dg-warning "is deprecated" "" { target { c++14 } } } + int l = foobar(8); // { dg-warning "is deprecated" "" { target { c++14 } } } } diff --git a/gcc/testsuite/g++.dg/cpp1y/attr-deprecated.C b/gcc/testsuite/g++.dg/cpp1y/attr-deprecated.C index 698268a776..ec6f232b85 100644 --- a/gcc/testsuite/g++.dg/cpp1y/attr-deprecated.C +++ b/gcc/testsuite/g++.dg/cpp1y/attr-deprecated.C @@ -1,4 +1,4 @@ -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } class [[deprecated]] A { diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-dtor1.C b/gcc/testsuite/g++.dg/cpp1y/auto-dtor1.C index 0a109fe8a1..9d90a0f202 100644 --- a/gcc/testsuite/g++.dg/cpp1y/auto-dtor1.C +++ b/gcc/testsuite/g++.dg/cpp1y/auto-dtor1.C @@ -1,5 +1,5 @@ // DR 1586 -// { dg-do run { target c++1y } } +// { dg-do run { target c++14 } } template <class T> void f (T* p) diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn1.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn1.C index 7a5b4908ad..0df09ab7ab 100644 --- a/gcc/testsuite/g++.dg/cpp1y/auto-fn1.C +++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn1.C @@ -1,4 +1,4 @@ -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } constexpr auto f() { return (char)42; } #define SA(X) static_assert ((X),#X) diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn10.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn10.C index 890cfda120..8e08911465 100644 --- a/gcc/testsuite/g++.dg/cpp1y/auto-fn10.C +++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn10.C @@ -1,6 +1,6 @@ // A template declared with auto should be declared with auto in an // explicit instantiation or explicit specialization, too. -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } template <class T> auto f(T t) { return t; } diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn11.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn11.C index 132f959db2..b6a4b324b7 100644 --- a/gcc/testsuite/g++.dg/cpp1y/auto-fn11.C +++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn11.C @@ -1,4 +1,4 @@ -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } auto f() { return; } // OK, return type is void auto* g() { return; } // { dg-error "no value" } diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn12.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn12.C index 04ea81929d..224f2789bc 100644 --- a/gcc/testsuite/g++.dg/cpp1y/auto-fn12.C +++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn12.C @@ -1,4 +1,4 @@ -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-final { scan-assembler "_ZN1AIiEcvDaEv" } } template <class T> diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn13.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn13.C index 8f4e105019..96b4b0c64a 100644 --- a/gcc/testsuite/g++.dg/cpp1y/auto-fn13.C +++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn13.C @@ -1,4 +1,4 @@ -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } struct A { template <class T> diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn14.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn14.C index f17c0e289c..d82b21fc96 100644 --- a/gcc/testsuite/g++.dg/cpp1y/auto-fn14.C +++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn14.C @@ -1,5 +1,5 @@ // PR c++/56177 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } auto f (); auto f () { return 33; } diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn15.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn15.C index 987aa96b7b..ba9f3579f6 100644 --- a/gcc/testsuite/g++.dg/cpp1y/auto-fn15.C +++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn15.C @@ -1,4 +1,4 @@ -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-options "-Wno-return-local-addr" } template<class,class> struct same_type; diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn16.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn16.C index 233f26f811..46177239dd 100644 --- a/gcc/testsuite/g++.dg/cpp1y/auto-fn16.C +++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn16.C @@ -1,4 +1,4 @@ -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } template<class,class> struct ST; template<class T> struct ST<T,T> {}; diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn17.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn17.C index ee668b626a..1647107e54 100644 --- a/gcc/testsuite/g++.dg/cpp1y/auto-fn17.C +++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn17.C @@ -1,4 +1,4 @@ -// { dg-do run { target c++1y } } +// { dg-do run { target c++14 } } int c; int d; diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn18.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn18.C index ca1b0b0337..528d3d45ed 100644 --- a/gcc/testsuite/g++.dg/cpp1y/auto-fn18.C +++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn18.C @@ -1,4 +1,4 @@ -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } struct A { diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn19.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn19.C index ecd8b91e88..28cea11286 100644 --- a/gcc/testsuite/g++.dg/cpp1y/auto-fn19.C +++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn19.C @@ -1,4 +1,4 @@ -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } template <class T> auto f() { return T::i; } diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn2.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn2.C index f89c86ce31..0d39551ff2 100644 --- a/gcc/testsuite/g++.dg/cpp1y/auto-fn2.C +++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn2.C @@ -1,3 +1,3 @@ -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } auto f() { return f(); } // { dg-error "auto" } diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn20.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn20.C index 818b6f5da6..a516bcfb0e 100644 --- a/gcc/testsuite/g++.dg/cpp1y/auto-fn20.C +++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn20.C @@ -1,4 +1,4 @@ -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } template <class T> auto f(T) { return 42; } diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn21.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn21.C index df23a81486..4db1c86c8d 100644 --- a/gcc/testsuite/g++.dg/cpp1y/auto-fn21.C +++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn21.C @@ -1,5 +1,5 @@ // N3638: decltype(auto) must stand alone -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } void f(); decltype(auto) g1() { return &f; } diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn22.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn22.C index 0077b89e4c..b16a7644c0 100644 --- a/gcc/testsuite/g++.dg/cpp1y/auto-fn22.C +++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn22.C @@ -1,4 +1,4 @@ -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } struct A { diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn23.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn23.C index f153e2a7fa..896318ceb0 100644 --- a/gcc/testsuite/g++.dg/cpp1y/auto-fn23.C +++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn23.C @@ -1,5 +1,5 @@ // PR c++/58561 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-options "-g" } auto foo(); diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn24.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn24.C index dfff2029c1..e9bbc735b4 100644 --- a/gcc/testsuite/g++.dg/cpp1y/auto-fn24.C +++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn24.C @@ -1,5 +1,5 @@ // PR c++/60314 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-options "-g" } // fine diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn25.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn25.C index 24680f16d0..fdad465356 100644 --- a/gcc/testsuite/g++.dg/cpp1y/auto-fn25.C +++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn25.C @@ -1,5 +1,5 @@ // PR c++/60574 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-require-effective-target lto } // { dg-options "-flto" } diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn3.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn3.C index 73ec5a7c8d..4436e84bcd 100644 --- a/gcc/testsuite/g++.dg/cpp1y/auto-fn3.C +++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn3.C @@ -1,4 +1,4 @@ -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } bool b; auto f() diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn4.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn4.C index 4c3227a0e1..c2e1893523 100644 --- a/gcc/testsuite/g++.dg/cpp1y/auto-fn4.C +++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn4.C @@ -1,4 +1,4 @@ -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } template <class T> constexpr auto f(T t) { return t+1; } diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn5.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn5.C index b857140026..17ce4d2912 100644 --- a/gcc/testsuite/g++.dg/cpp1y/auto-fn5.C +++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn5.C @@ -1,4 +1,4 @@ -// { dg-do run { target c++1y } } +// { dg-do run { target c++14 } } int i; auto& f() { return i; } diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn6.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn6.C index 123132ddf0..17ca6f22c5 100644 --- a/gcc/testsuite/g++.dg/cpp1y/auto-fn6.C +++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn6.C @@ -1,4 +1,4 @@ -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } template <class T, class U> struct ST; template <class T> struct ST<T,T> {}; diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn7.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn7.C index deb664c3bd..3bef5987ac 100644 --- a/gcc/testsuite/g++.dg/cpp1y/auto-fn7.C +++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn7.C @@ -1,4 +1,4 @@ -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } auto f(); diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn8.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn8.C index 1badd6a5e8..651c66cb29 100644 --- a/gcc/testsuite/g++.dg/cpp1y/auto-fn8.C +++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn8.C @@ -1,4 +1,4 @@ -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } auto f() { return 42; } // { dg-message "old declaration .auto" } auto f(); // OK diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn9.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn9.C index 018d42cce6..54cfa0de4e 100644 --- a/gcc/testsuite/g++.dg/cpp1y/auto-fn9.C +++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn9.C @@ -1,4 +1,4 @@ -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-final { scan-assembler "_Z1fIiERDaRKT_S1_" } } template <class T> diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-mangle1.C b/gcc/testsuite/g++.dg/cpp1y/auto-mangle1.C index 0ea437ca46..0cb44599ff 100644 --- a/gcc/testsuite/g++.dg/cpp1y/auto-mangle1.C +++ b/gcc/testsuite/g++.dg/cpp1y/auto-mangle1.C @@ -1,5 +1,5 @@ // Mangling for decltype(auto) -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } void f(); diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-neg1.C b/gcc/testsuite/g++.dg/cpp1y/auto-neg1.C index a6f31f63de..e1973e5d9a 100644 --- a/gcc/testsuite/g++.dg/cpp1y/auto-neg1.C +++ b/gcc/testsuite/g++.dg/cpp1y/auto-neg1.C @@ -1,5 +1,5 @@ // PR c++/60312 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } template<typename> struct A; diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-assert1.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-assert1.C new file mode 100644 index 0000000000..df2a31539f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-assert1.C @@ -0,0 +1,10 @@ +// PR c++/59329 +// { dg-do compile { target c++14 } } + +#include <cassert> + +inline constexpr int exampleFunction(int min, int max) +{ + assert(min <= max); + return min + max; +} diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-incr1.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-incr1.C new file mode 100644 index 0000000000..ecd7c047c8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-incr1.C @@ -0,0 +1,23 @@ +// { dg-do compile { target c++14 } } +#define SA(X) static_assert((X),#X) + +constexpr int f (int i) +{ + ++i; + int x = i; + ++x; + return x; +} + +constexpr int* g (int* p) +{ + ++p; + return p; +} + +constexpr int i = f(42); +SA(i==44); + +int array[4]; +constexpr int* p = g(array); +SA(p == &array[1]); diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-initlist1.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-initlist1.C new file mode 100644 index 0000000000..bdef8a101a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-initlist1.C @@ -0,0 +1,22 @@ +// PR c++/64333 +// { dg-do compile { target c++14 } } +#include <initializer_list> + +constexpr int max(std::initializer_list<int> ints) +{ + int ret = *(ints.begin()); + for (int i = 0; i < ints.size(); ++i) { + if (*(ints.begin()+i) > ret) { + ret = *(ints.begin()+i); + } + } + return ret; +} + +int main() +{ + constexpr int z = max({7,6,5,4,3,2,1}); + constexpr int z2 = max({5,4,3,2,1}); + static_assert(z == 7, ""); + static_assert(z2 == 5, ""); +} diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-local-compound1.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-local-compound1.C new file mode 100644 index 0000000000..b72d13569a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-local-compound1.C @@ -0,0 +1,14 @@ +// { dg-do compile { target c++14 } } + +#define SA(X) static_assert((X),#X) + +constexpr int f(int i) { { int j = i+1; return j; } } + +constexpr int i = f(41); + +struct S +{ + constexpr S() { { constexpr int j = 17; SA(j == 17); } } +}; + +SA(i==42); diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-local1.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-local1.C new file mode 100644 index 0000000000..8412f63ded --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-local1.C @@ -0,0 +1,14 @@ +// { dg-do compile { target c++14 } } + +#define SA(X) static_assert((X),#X) + +constexpr int f(int i) { int j = i+1; return j; } + +constexpr int i = f(41); + +struct S +{ + constexpr S() { constexpr int j = 17; SA(j == 17); } +}; + +SA(i==42); diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-local2.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-local2.C new file mode 100644 index 0000000000..fd6143b091 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-local2.C @@ -0,0 +1,22 @@ +// PR c++/64356 +// { dg-do compile { target c++14 } } + +typedef unsigned long size_t; + +template<size_t N> +constexpr size_t f(const char (&x)[N]) { + size_t s = 0; + for(size_t c : x) + s += c; + return s; +} + +template<size_t N> +constexpr size_t g(const char (&x)[N]) { + char y[N] = {0}; + for(size_t i = 0; i < N; ++i) + y[i] = x[i]; + return f(y); +} + +constexpr auto x = g(__DATE__); diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-local3.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-local3.C new file mode 100644 index 0000000000..76d4b55c41 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-local3.C @@ -0,0 +1,20 @@ +// PR c++/64647 +// { dg-do compile { target c++14 } } + +template<typename T> +constexpr T foo(T t) +{ + T tt = t; + return tt; +} + +struct X +{ + X() { } +}; + +int main() +{ + X x; + foo(x); +} diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-loop1.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-loop1.C new file mode 100644 index 0000000000..fc5d4f81af --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-loop1.C @@ -0,0 +1,13 @@ +// { dg-do compile { target c++14 } } + +constexpr int f (int i) +{ + int j = 0; + for (; i > 0; --i) + ++j; + return j; +} + +constexpr int i = f(42); +#define SA(X) static_assert((X),#X) +SA(i==42); diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-loop2.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-loop2.C new file mode 100644 index 0000000000..2e53e4831d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-loop2.C @@ -0,0 +1,12 @@ +// { dg-do compile { target c++14 } } + +constexpr int f(int* p) { return *p; } +constexpr int g(int n) +{ + int sum = 0; + for (int i = 1; i <= n; ++i) + sum += f(&i); + return sum; +} + +static_assert(g(3) == 3+2+1,""); diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-neg1.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-neg1.C new file mode 100644 index 0000000000..ae3dcc69cf --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-neg1.C @@ -0,0 +1,17 @@ +// { dg-do compile { target c++14 } } + +struct A { A(); }; + +constexpr int f(int i) { + static int j = i; // { dg-error "static" } + thread_local int l = i; // { dg-error "thread_local" } + goto foo; // { dg-error "goto" } + foo: + asm("foo"); // { dg-error "asm" } + int k; // { dg-error "uninitialized" } + A a; // { dg-error "non-literal" } + return i; +} + +// FIXME remove +// { dg-prune-output "return" } diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-ref1.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-ref1.C new file mode 100644 index 0000000000..6f88f82c0b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-ref1.C @@ -0,0 +1,9 @@ +// PR c++/64080 +// { dg-do compile { target c++14 } } + +constexpr void foo (int&& i) { i = 0; } + +void bar(int&& i) +{ + bool b = noexcept(foo(static_cast<int&&>(i))); +} diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-return1.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-return1.C new file mode 100644 index 0000000000..b114e21488 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-return1.C @@ -0,0 +1,11 @@ +// { dg-do compile { target c++14 } } + +constexpr int f (int i) +{ + return 24; + return 36; +} + +constexpr int i = f(42); +#define SA(X) static_assert((X),#X) +SA(i==24); diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-return2.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-return2.C new file mode 100644 index 0000000000..ae2628d800 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-return2.C @@ -0,0 +1,7 @@ +// { dg-do compile { target c++14 } } + +constexpr int f (int i) +{ +} + +constexpr int i = f(42); // { dg-error "flows off the end" } diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-shift1.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-shift1.C new file mode 100644 index 0000000000..a739fd2dfa --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-shift1.C @@ -0,0 +1,9 @@ +// { dg-do compile { target c++14 } } + +constexpr int p = 1; +constexpr __PTRDIFF_TYPE__ bar (int a) +{ + return ((__PTRDIFF_TYPE__) &p) << a; // { dg-error "is not a constant expression" } +} +constexpr __PTRDIFF_TYPE__ r = bar (2); +constexpr __PTRDIFF_TYPE__ s = bar (0); // { dg-error "conversion from pointer" } diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-switch1.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-switch1.C new file mode 100644 index 0000000000..add732320f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-switch1.C @@ -0,0 +1,16 @@ +// { dg-do compile { target c++14 } } + +constexpr int f (int i) +{ + switch (i) + { + case 1: + return 42; + default: + return 0; + } +} + +constexpr int i = f(1); +#define SA(X) static_assert((X),#X) +SA(i==42); diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-switch2.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-switch2.C new file mode 100644 index 0000000000..a459a5efce --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-switch2.C @@ -0,0 +1,20 @@ +// { dg-do compile { target c++14 } } + +constexpr int f (int i) +{ + int j = 0; + switch (i) + { + case 1: + j = 42; + break; + default: + j = 24; + break; + } + return j; +} + +constexpr int i = f(1); +#define SA(X) static_assert((X),#X) +SA(i==42); diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-switch3.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-switch3.C new file mode 100644 index 0000000000..1aa1cf6bba --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-switch3.C @@ -0,0 +1,20 @@ +// { dg-do compile { target c++14 } } + +constexpr int f (int i) +{ + int j = 0; + switch (i) + { + case 1: + j = 42; + break; + default: + j = 24; + break; + } + return j; +} + +constexpr int i = f(2); +#define SA(X) static_assert((X),#X) +SA(i==24); diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-type-def-compound1.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-type-def-compound1.C new file mode 100644 index 0000000000..aace610255 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-type-def-compound1.C @@ -0,0 +1,60 @@ +// PR c++/55250 +// { dg-do compile { target c++14 } } + +#define SA(X) static_assert((X),#X) + +constexpr int Test1(int x) { { enum E { y = 1 }; return x + y; } } + +constexpr int Test2(int x) { { struct T { constexpr operator int() { return 1; } }; return x + T(); } } + +constexpr int Test3(int x) { { typedef enum E { y = 1 } EE; return x + EE::y; } } + +constexpr int Test4(int x) { { typedef struct T { constexpr operator int() { return 1; } } TT; return x + TT(); } } + +constexpr int Test5(int x) { { using EE = enum E { y = 1 }; return x + EE::y; } } + +constexpr int Test6(int x) { { using TT = struct T { constexpr operator int() { return 1; } }; return x + TT(); } } + +SA(Test1(2) == 3); +SA(Test2(2) == 3); +SA(Test3(2) == 3); +SA(Test4(2) == 3); +SA(Test5(2) == 3); +SA(Test6(2) == 3); + +struct S1 +{ + constexpr S1() { { enum E { y = 1 }; SA(y == 1); } } +}; + +struct S2 +{ + constexpr S2() { { struct T { constexpr operator int() { return 1; } }; SA(T() == 1); } } +}; + +struct S3 +{ + constexpr S3() { { typedef enum E { y = 1} EE; SA(EE::y == 1); } } +}; + +struct S4 +{ + constexpr S4() { { typedef struct T { constexpr operator int() { return 1; } } TT; SA(TT() == 1); } } +}; + +struct S5 +{ + constexpr S5() { { using EE = enum E { y = 1}; SA(EE::y == 1); } } +}; + +struct S6 +{ + constexpr S6() { { using TT = struct T { constexpr operator int() { return 1; } }; SA(TT() == 1); } } +}; + +S1 s1; +S2 s2; +S3 s3; +S4 s4; +S5 s5; +S6 s6; diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-type-def1.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-type-def1.C new file mode 100644 index 0000000000..648e09c993 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-type-def1.C @@ -0,0 +1,60 @@ +// PR c++/55250 +// { dg-do compile { target c++14 } } + +#define SA(X) static_assert((X),#X) + +constexpr int Test1(int x) { enum E { y = 1 }; return x + y; } + +constexpr int Test2(int x) { struct T { constexpr operator int() { return 1; } }; return x + T(); } + +constexpr int Test3(int x) { typedef enum E { y = 1 } EE; return x + EE::y; } + +constexpr int Test4(int x) { typedef struct T { constexpr operator int() { return 1; } } TT; return x + TT(); } + +constexpr int Test5(int x) { using EE = enum E { y = 1 }; return x + EE::y; } + +constexpr int Test6(int x) { using TT = struct T { constexpr operator int() { return 1; } }; return x + TT(); } + +SA(Test1(2) == 3); +SA(Test2(2) == 3); +SA(Test3(2) == 3); +SA(Test4(2) == 3); +SA(Test5(2) == 3); +SA(Test6(2) == 3); + +struct S1 +{ + constexpr S1() { enum E { y = 1 }; SA(y == 1); } +}; + +struct S2 +{ + constexpr S2() { struct T { constexpr operator int() { return 1; } }; SA(T() == 1); } +}; + +struct S3 +{ + constexpr S3() { typedef enum E { y = 1} EE; SA(EE::y == 1); } +}; + +struct S4 +{ + constexpr S4() { typedef struct T { constexpr operator int() { return 1; } } TT; SA(TT() == 1); } +}; + +struct S5 +{ + constexpr S5() { using EE = enum E { y = 1}; SA(EE::y == 1); } +}; + +struct S6 +{ + constexpr S6() { using TT = struct T { constexpr operator int() { return 1; } }; SA(TT() == 1); } +}; + +S1 s1; +S2 s2; +S3 s3; +S4 s4; +S5 s5; +S6 s6; diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-void1.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-void1.C new file mode 100644 index 0000000000..10ef5bc8a6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-void1.C @@ -0,0 +1,13 @@ +// { dg-do compile { target c++14 } } + +struct S +{ + int i = 20; + + constexpr void + foo (void) + { + if (i > 20) + __builtin_abort (); + } +}; diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-void2.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-void2.C new file mode 100644 index 0000000000..321a35ed29 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-void2.C @@ -0,0 +1,21 @@ +// PR c++/64547 +// { dg-do compile { target c++14 } } + +struct X +{ + int x; + constexpr int get() const {return x;} + constexpr void set(int foo) {x = foo;} +}; + +constexpr int bar() +{ + X x{42}; + x.set(666); + return x.get(); +} + +int main() +{ + constexpr int foo = bar(); +} diff --git a/gcc/testsuite/g++.dg/cpp1y/cplusplus.C b/gcc/testsuite/g++.dg/cpp1y/cplusplus.C index 2cfd84fada..7c07d6c8b0 100644 --- a/gcc/testsuite/g++.dg/cpp1y/cplusplus.C +++ b/gcc/testsuite/g++.dg/cpp1y/cplusplus.C @@ -1,5 +1,5 @@ -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14_only } } -#if __cplusplus <= 201103L -#error +#if __cplusplus != 201402L +#error "__cplusplus != 201402L" #endif diff --git a/gcc/testsuite/g++.dg/cpp1y/cplusplus_1y.C b/gcc/testsuite/g++.dg/cpp1y/cplusplus_1y.C new file mode 100644 index 0000000000..0e8f3eeb8a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/cplusplus_1y.C @@ -0,0 +1,6 @@ +// { dg-do compile } +// { dg-options "-std=c++1y" } + +#if __cplusplus != 201402L +#error "__cplusplus != 201402L" +#endif diff --git a/gcc/testsuite/g++.dg/cpp1y/digit-sep-cxx11-neg.C b/gcc/testsuite/g++.dg/cpp1y/digit-sep-cxx11-neg.C index 453fe106a2..411ba52b52 100644 --- a/gcc/testsuite/g++.dg/cpp1y/digit-sep-cxx11-neg.C +++ b/gcc/testsuite/g++.dg/cpp1y/digit-sep-cxx11-neg.C @@ -1,4 +1,4 @@ -// { dg-do compile { target { ! c++1y } } } +// { dg-do compile { target { ! c++14 } } } #define assert(E) if(!(E))__builtin_abort(); diff --git a/gcc/testsuite/g++.dg/cpp1y/digit-sep-neg.C b/gcc/testsuite/g++.dg/cpp1y/digit-sep-neg.C index 6c342a7a41..54e5ed19cd 100644 --- a/gcc/testsuite/g++.dg/cpp1y/digit-sep-neg.C +++ b/gcc/testsuite/g++.dg/cpp1y/digit-sep-neg.C @@ -1,4 +1,4 @@ -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } int main() @@ -7,10 +7,10 @@ main() i = 1048''576; // { dg-error "adjacent digit separators" } i = 0X'100000; // { dg-error "digit separator after base indicator" } i = 0x'100000; // { dg-error "digit separator after base indicator" } - i = 0004''000'000); // { dg-error "adjacent digit separators" } + i = 0004''000'000; // { dg-error "adjacent digit separators" } i = 0B1'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0; // OK i = 0b'0001'0000'0000'0000'0000'0000; // { dg-error "digit separator after base indicator" } - i = 0b0001'0000'0000'0000'0000'0000'; // { dg-error "digit separator outside digit sequence" } + i = 0b0001'0000'0000'0000'0000'0000'; // { dg-error "missing terminating" } unsigned u = 0b0001'0000'0000'0000'0000'0000'U; // { dg-error "digit separator outside digit sequence" } double d = 0.0; @@ -18,9 +18,13 @@ main() d = 1.'602'176'565e-19; // { dg-error "digit separator adjacent to decimal point" } d = 1.602''176'565e-19; // { dg-error "adjacent digit separators" } d = 1.602'176'565'e-19; // { dg-error "digit separator adjacent to exponent" } - d = 1.602'176'565e'-19; // { dg-error "digit separator adjacent to exponent" } + d = 1.602'176'565e'-19; // { dg-error "missing terminating" } d = 1.602'176'565e-'19; // { dg-error "digit separator adjacent to exponent" } d = 1.602'176'565e-1'9; // OK - d = 1.602'176'565e-19'; // { dg-error "digit separator outside digit sequence" } + d = 1.602'176'565e-19'; // { dg-error "missing terminating" } float f = 1.602'176'565e-19'F; // { dg-error "digit separator outside digit sequence" } } + +// { dg-error "exponent has no digits" "exponent has no digits" { target *-*-* } 21 } +// { dg-error "expected ';' before" "expected ';' before" { target *-*-* } 14 } +// { dg-error "expected ';' before" "expected ';' before" { target *-*-* } 25 } diff --git a/gcc/testsuite/g++.dg/cpp1y/digit-sep.C b/gcc/testsuite/g++.dg/cpp1y/digit-sep.C index cc670fe06d..111e7a55d7 100644 --- a/gcc/testsuite/g++.dg/cpp1y/digit-sep.C +++ b/gcc/testsuite/g++.dg/cpp1y/digit-sep.C @@ -1,4 +1,4 @@ -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } #define assert(E) if(!(E))__builtin_abort(); diff --git a/gcc/testsuite/g++.dg/cpp1y/feat-cxx11-neg.C b/gcc/testsuite/g++.dg/cpp1y/feat-cxx11-neg.C index 8719577c5c..81daa04b4d 100644 --- a/gcc/testsuite/g++.dg/cpp1y/feat-cxx11-neg.C +++ b/gcc/testsuite/g++.dg/cpp1y/feat-cxx11-neg.C @@ -1,7 +1,6 @@ // { dg-do compile { target c++11_only } } -// { dg-options "-pedantic-errors" } -// These *are* defined in C++14 onwards. +// C++14 features: #ifndef __cpp_binary_literals # error "__cpp_binary_literals" // { dg-error "error" } @@ -23,6 +22,10 @@ # error "__cpp_return_type_deduction" // { dg-error "error" } #endif +#ifndef __cpp_aggregate_nsdmi +# error "__cpp_aggregate_nsdmi" // { dg-error "error" } +#endif + #ifndef __cpp_variable_templates # error "__cpp_variable_templates" // { dg-error "error" } #endif @@ -31,10 +34,23 @@ # error "__cpp_digit_separators" // { dg-error "error" } #endif -#ifndef __cpp_attribute_deprecated -# error "__cpp_attribute_deprecated" // { dg-error "error" } +#ifndef __cpp_sized_deallocation +# error "__cpp_sized_deallocation" // { dg-error "error" } #endif +// Array TS features: + #ifndef __cpp_runtime_arrays # error "__cpp_runtime_arrays" // { dg-error "error" } #endif + +// C++14 attributes: + +// Attribute [[deprecated]] is allowed in C++11 as an extension (with pedwarn). +//#ifdef __has_cpp_attribute +//# if __has_cpp_attribute(deprecated) == 201309 +//# error "__has_cpp_attribute(deprecated)" // { } +//# endif +//#else +//# error "__has_cpp_attribute" +//#endif diff --git a/gcc/testsuite/g++.dg/cpp1y/feat-cxx11.C b/gcc/testsuite/g++.dg/cpp1y/feat-cxx11.C index 606a5cec61..67f75a7254 100644 --- a/gcc/testsuite/g++.dg/cpp1y/feat-cxx11.C +++ b/gcc/testsuite/g++.dg/cpp1y/feat-cxx11.C @@ -1,6 +1,22 @@ // { dg-do compile } // { dg-options "-std=gnu++11" } +// C++98 features: + +#ifndef __cpp_rtti +# error "__cpp_rtti" +#elif __cpp_rtti != 199711 +# error "__cpp_rtti != 199711" +#endif + +#ifndef __cpp_exceptions +# error "__cpp_exceptions" +#elif __cpp_exceptions != 199711 +# error "__cpp_exceptions != 199711" +#endif + +// C++11 features: + #ifndef __cpp_unicode_characters # error "__cpp_unicode_characters" #elif __cpp_unicode_characters != 200704 @@ -37,6 +53,12 @@ # error "__cpp_constexpr != 200704" #endif +#ifndef __cpp_range_based_for +# error "__cpp_range_based_for" +#elif __cpp_range_based_for != 200907 +# error "__cpp_range_based_for != 200907" +#endif + #ifndef __cpp_static_assert # error "__cpp_static_assert" #elif __cpp_static_assert != 200410 @@ -67,15 +89,90 @@ # error "__cpp_variadic_templates != 200704" #endif +#ifndef __cpp_initializer_lists +# error "__cpp_initializer_lists" +#elif __cpp_initializer_lists != 200806 +# error "__cpp_initializer_lists != 200806" +#endif + +#ifndef __cpp_delegating_constructors +# error "__cpp_delegating_constructors" +#elif __cpp_delegating_constructors != 200604 +# error "__cpp_delegating_constructors != 200604" +#endif + +#ifndef __cpp_nsdmi +# error "__cpp_nsdmi" +#elif __cpp_nsdmi != 200809 +# error "__cpp_nsdmi != 200809" +#endif + +#ifndef __cpp_inheriting_constructors +# error "__cpp_inheriting_constructors" +#elif __cpp_inheriting_constructors!= 200802 +# error "__cpp_inheriting_constructors != 200802" +#endif + +#ifndef __cpp_ref_qualifiers +# error "__cpp_ref_qualifiers" +#elif __cpp_ref_qualifiers != 200710 +# error "__cpp_ref_qualifiers != 200710" +#endif + #ifndef __cpp_alias_templates # error "__cpp_alias_templates" #elif __cpp_alias_templates != 200704 # error "__cpp_alias_templates != 200704" #endif -// These C++14 features are allowed in C++11 in non-ANSI modes. +// C++14 features allowed in C++11 in non-ANSI modes: + #ifndef __cpp_binary_literals # error "__cpp_binary_literals" #elif __cpp_binary_literals != 201304 # error "__cpp_binary_literals != 201304" #endif + +// GNU VLA support: + +#ifndef __cpp_runtime_arrays +# error "__cpp_runtime_arrays" +#elif __cpp_runtime_arrays != 198712 +# error "__cpp_runtime_arrays != 198712" +#endif + +// C++11 attributes: + +#ifdef __has_cpp_attribute +# if ! __has_cpp_attribute(noreturn) +# error "__has_cpp_attribute(noreturn)" +# elif __has_cpp_attribute(noreturn) != 200809 +# error "__has_cpp_attribute(noreturn) != 200809" +# endif +#else +# error "__has_cpp_attribute" +#endif + +#ifdef __has_cpp_attribute +// Attribute carries_dependency not in yet. +//# if ! __has_cpp_attribute(carries_dependency) +//# error "__has_cpp_attribute(carries_dependency)" +//# elif __has_cpp_attribute(carries_dependency) != 200809 +//# error "__has_cpp_attribute(carries_dependency) != 200809" +//# endif +#else +# error "__has_cpp_attribute" +#endif + +// C++14 attributes: + +// Attribute [[deprecated]] is allowed in C++11 as an extension (with pedwarn). +#ifdef __has_cpp_attribute +# if ! __has_cpp_attribute(deprecated) +# error "__has_cpp_attribute(deprecated)" +# elif __has_cpp_attribute(deprecated) != 201309 +# error "__has_cpp_attribute(deprecated) != 201309" +# endif +#else +# error "__has_cpp_attribute" +#endif diff --git a/gcc/testsuite/g++.dg/cpp1y/feat-cxx14.C b/gcc/testsuite/g++.dg/cpp1y/feat-cxx14.C index 8a05f66606..129296664c 100644 --- a/gcc/testsuite/g++.dg/cpp1y/feat-cxx14.C +++ b/gcc/testsuite/g++.dg/cpp1y/feat-cxx14.C @@ -1,7 +1,21 @@ -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-options "-I${srcdir}/g++.dg/cpp1y -I${srcdir}/g++.dg/cpp1y/testinc" } -// Begin C++11 tests. +// C++98 features: + +#ifndef __cpp_rtti +# error "__cpp_rtti" +#elif __cpp_rtti != 199711 +# error "__cpp_rtti != 199711" +#endif + +#ifndef __cpp_exceptions +# error "__cpp_exceptions" +#elif __cpp_exceptions != 199711 +# error "__cpp_exceptions != 199711" +#endif + +// C++11 features: #ifndef __cpp_unicode_characters # error "__cpp_unicode_characters" @@ -33,10 +47,10 @@ # error "__cpp_lambdas != 200907" #endif -#ifndef __cpp_constexpr -# error "__cpp_constexpr" -#elif __cpp_constexpr != 200704 -# error "__cpp_constexpr != 200704" +#ifndef __cpp_range_based_for +# error "__cpp_range_based_for" +#elif __cpp_range_based_for != 200907 +# error "__cpp_range_based_for != 200907" #endif #ifndef __cpp_static_assert @@ -69,13 +83,43 @@ # error "__cpp_variadic_templates != 200704" #endif +#ifndef __cpp_initializer_lists +# error "__cpp_initializer_lists" +#elif __cpp_initializer_lists != 200806 +# error "__cpp_initializer_lists != 200806" +#endif + +#ifndef __cpp_delegating_constructors +# error "__cpp_delegating_constructors" +#elif __cpp_delegating_constructors != 200604 +# error "__cpp_delegating_constructors != 200604" +#endif + +#ifndef __cpp_nsdmi +# error "__cpp_nsdmi" +#elif __cpp_nsdmi != 200809 +# error "__cpp_nsdmi != 200809" +#endif + +#ifndef __cpp_inheriting_constructors +# error "__cpp_inheriting_constructors" +#elif __cpp_inheriting_constructors!= 200802 +# error "__cpp_inheriting_constructors != 200802" +#endif + +#ifndef __cpp_ref_qualifiers +# error "__cpp_ref_qualifiers" +#elif __cpp_ref_qualifiers != 200710 +# error "__cpp_ref_qualifiers != 200710" +#endif + #ifndef __cpp_alias_templates # error "__cpp_alias_templates" #elif __cpp_alias_templates != 200704 # error "__cpp_alias_templates != 200704" #endif -// Begin C++14 tests. +// C++14 features: #ifndef __cpp_binary_literals # error "__cpp_binary_literals" @@ -95,11 +139,10 @@ # error "__cpp_generic_lambdas != 201304" #endif -// TODO: Change 200704 to 201304 when C++14 constexpr goes in. #ifndef __cpp_constexpr # error "__cpp_constexpr" -#elif __cpp_constexpr != 200704 -# error "__cpp_constexpr != 200704" +#elif __cpp_constexpr != 201304 +# error "__cpp_constexpr != 201304" #endif #ifndef __cpp_decltype_auto @@ -114,20 +157,16 @@ # error "__cpp_return_type_deduction != 201304" #endif -#ifndef __cpp_runtime_arrays -# error "__cpp_runtime_arrays" -#elif __cpp_runtime_arrays != 201304 -# error "__cpp_runtime_arrays != 201304" -#endif - -// Aggregate initializers not in yet. -#ifdef __cpp_aggregate_nsdmi +#ifndef __cpp_aggregate_nsdmi # error "__cpp_aggregate_nsdmi" +#elif __cpp_aggregate_nsdmi != 201304 +# error "__cpp_aggregate_nsdmi != 201304" #endif -// Variable templates not in yet. -#ifdef __cpp_variable_templates +#ifndef __cpp_variable_templates # error "__cpp_variable_templates" +#elif __cpp_variable_templates != 201304 +# error "__cpp_variable_templates != 201304" #endif #ifndef __cpp_digit_separators @@ -136,18 +175,56 @@ # error "__cpp_digit_separators != 201309" #endif -#ifndef __cpp_attribute_deprecated -# error "__cpp_attribute_deprecated" -#elif __cpp_attribute_deprecated != 201309 -# error "__cpp_attribute_deprecated != 201309" +#ifndef __cpp_sized_deallocation +# error "__cpp_sized_deallocation" +#elif __cpp_sized_deallocation != 201309 +# error "__cpp_sized_deallocation != 201309" #endif -// Sized deallocation not in yet. -#ifdef __cpp_sized_deallocation -# error "__cpp_sized_deallocation" +// GNU VLA support: + +#ifndef __cpp_runtime_arrays +# error "__cpp_runtime_arrays" +#elif __cpp_runtime_arrays != 198712 +# error "__cpp_runtime_arrays != 198712" +#endif + +// C++11 attributes: + +#ifdef __has_cpp_attribute +# if ! __has_cpp_attribute(noreturn) +# error "__has_cpp_attribute(noreturn)" +# elif __has_cpp_attribute(noreturn) != 200809 +# error "__has_cpp_attribute(noreturn) != 200809" +# endif +#else +# error "__has_cpp_attribute" +#endif + +// Attribute carries_dependency not in yet. +//#ifdef __has_cpp_attribute +//# if ! __has_cpp_attribute(carries_dependency) +//# error "__has_cpp_attribute(carries_dependency)" +//# elif __has_cpp_attribute(carries_dependency) != 200809 +//# error "__has_cpp_attribute(carries_dependency) != 200809" +//# endif +//#else +//# error "__has_cpp_attribute" +//#endif + +// C++14 attributes: + +#ifdef __has_cpp_attribute +# if ! __has_cpp_attribute(deprecated) +# error "__has_cpp_attribute(deprecated)" +# elif __has_cpp_attribute(deprecated) != 201309 +# error "__has_cpp_attribute(deprecated) != 201309" +# endif +#else +# error "__has_cpp_attribute" #endif -// Begin include checks. +// Include checks: // Check for __has_include macro. #ifndef __has_include diff --git a/gcc/testsuite/g++.dg/cpp1y/feat-cxx98-neg.C b/gcc/testsuite/g++.dg/cpp1y/feat-cxx98-neg.C index b99b57efe0..9c25fc3780 100644 --- a/gcc/testsuite/g++.dg/cpp1y/feat-cxx98-neg.C +++ b/gcc/testsuite/g++.dg/cpp1y/feat-cxx98-neg.C @@ -1,5 +1,6 @@ // { dg-do compile { target c++98_only } } -// { dg-options "-ansi" } + +// C++11 features: #ifndef __cpp_runtime_arrays # error "__cpp_runtime_arrays" // { dg-error "error" } @@ -49,13 +50,33 @@ # error "__cpp_variadic_templates" // { dg-error "error" } #endif +#ifndef __cpp_initializer_lists +# error "__cpp_initializer_lists" // { dg-error "error" } +#endif + +#ifndef __cpp_delegating_constructors +# error "__cpp_delegating_constructors" // { dg-error "error" } +#endif + +#ifndef __cpp_nsdmi +# error "__cpp_nsdmi" // { dg-error "error" } +#endif + +#ifndef __cpp_inheriting_constructors +# error "__cpp_inheriting_constructors" // { dg-error "error" } +#endif + +#ifndef __cpp_ref_qualifiers +# error "__cpp_ref_qualifiers" // { dg-error "error" } +#endif + #ifndef __cpp_alias_templates # error "__cpp_alias_templates" // { dg-error "error" } #endif -// C++14 +// C++14 features: -// C++98 gets binary literals. +// C++98 gets binary literals in non-ANSI modes. //#ifndef __cpp_binary_literals //# error "__cpp_binary_literals" //#endif @@ -76,10 +97,9 @@ # error "__cpp_return_type_deduction" // { dg-error "error" } #endif -// Aggregate initializers not in yet. -//#ifdef __cpp_aggregate_nsdmi -//# error "__cpp_aggregate_nsdmi" -//#endif +#ifndef __cpp_aggregate_nsdmi +# error "__cpp_aggregate_nsdmi" // { dg-error "error" } +#endif #ifndef __cpp_variable_templates # error "__cpp_variable_templates" // { dg-error "error" } @@ -89,11 +109,36 @@ # error "__cpp_digit_separators" // { dg-error "error" } #endif -#ifndef __cpp_attribute_deprecated -# error "__cpp_attribute_deprecated" // { dg-error "error" } +#ifndef __cpp_sized_deallocation +# error "__cpp_sized_deallocation" // { dg-error "error" } #endif -// Sized deallocation not in yet. -//#ifdef __cpp_sized_deallocation -//# error "__cpp_sized_deallocation" +// C++11 attributes: + +#ifdef __has_cpp_attribute +# if __has_cpp_attribute(noreturn) == 200809 +# error "__has_cpp_attribute(noreturn) == 200809" // { dg-error "error" } +# endif +#else +# error "__has_cpp_attribute" +#endif + +// Attribute carries_dependency not in yet. +//#ifdef __has_cpp_attribute +//# if __has_cpp_attribute(carries_dependency) == 200809 +//# error "__has_cpp_attribute(carries_dependency) == 200809" // { } +//# endif +//#else +//# error "__has_cpp_attribute" +//#endif + +// C++14 attributes: + +// Attribute [[deprecated]] is allowed in C++11 as an extension (with pedwarn). +//#ifdef __has_cpp_attribute +//# if __has_cpp_attribute(deprecated) == 201309 +//# error "__has_cpp_attribute(deprecated)" // { } +//# endif +//#else +//# error "__has_cpp_attribute" //#endif diff --git a/gcc/testsuite/g++.dg/cpp1y/feat-cxx98.C b/gcc/testsuite/g++.dg/cpp1y/feat-cxx98.C index a0a2b75e30..d15e7aadce 100644 --- a/gcc/testsuite/g++.dg/cpp1y/feat-cxx98.C +++ b/gcc/testsuite/g++.dg/cpp1y/feat-cxx98.C @@ -1,9 +1,32 @@ // { dg-do compile { target c++98_only } } // { dg-options "" } -// These C++14 features are allowed in C++98 in non-ANSI modes. +// C++98 features: + +#ifndef __cpp_rtti +# error "__cpp_rtti" +#elif __cpp_rtti != 199711 +# error "__cpp_rtti != 199711" +#endif + +#ifndef __cpp_exceptions +# error "__cpp_exceptions" +#elif __cpp_exceptions != 199711 +# error "__cpp_exceptions != 199711" +#endif + +// C++14 features allowed in C++98 in non-ANSI modes: + #ifndef __cpp_binary_literals # error "__cpp_binary_literals" #elif __cpp_binary_literals != 201304 # error "__cpp_binary_literals != 201304" #endif + +// GNU VLA support: + +#ifndef __cpp_runtime_arrays +# error "__cpp_runtime_arrays" +#elif __cpp_runtime_arrays != 198712 +# error "__cpp_runtime_arrays != 198712" +#endif diff --git a/gcc/testsuite/g++.dg/cpp1y/feat-neg.C b/gcc/testsuite/g++.dg/cpp1y/feat-neg.C new file mode 100644 index 0000000000..9f4a041240 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/feat-neg.C @@ -0,0 +1,12 @@ +// { dg-do compile } +// { dg-options "-fno-rtti -fno-exceptions" } + +// C++98 features with explicit opt-out: + +#ifndef __cpp_rtti +# error "__cpp_rtti" // { dg-error "error" } +#endif + +#ifndef __cpp_exceptions +# error "__cpp_exceptions" // { dg-error "error" } +#endif diff --git a/gcc/testsuite/g++.dg/cpp1y/feat-sized-dealloc-neg.C b/gcc/testsuite/g++.dg/cpp1y/feat-sized-dealloc-neg.C new file mode 100644 index 0000000000..b1a3dc5e15 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/feat-sized-dealloc-neg.C @@ -0,0 +1,6 @@ +// { dg-do compile { target c++14 } } +// { dg-options "-fno-sized-deallocation" } + +#ifndef __cpp_sized_deallocation +# error "__cpp_sized_deallocation" // { dg-error "error" } +#endif diff --git a/gcc/testsuite/g++.dg/cpp1y/feat-sized-dealloc.C b/gcc/testsuite/g++.dg/cpp1y/feat-sized-dealloc.C new file mode 100644 index 0000000000..a91246ff5a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/feat-sized-dealloc.C @@ -0,0 +1,10 @@ +// { dg-do compile { target c++11_only } } +// { dg-options "-fsized-deallocation" } + +// C++14 features: + +#ifndef __cpp_sized_deallocation +# error "__cpp_sized_deallocation" +#elif __cpp_sized_deallocation != 201309 +# error "__cpp_sized_deallocation != 201309" +#endif diff --git a/gcc/testsuite/g++.dg/cpp1y/feat-vla.C b/gcc/testsuite/g++.dg/cpp1y/feat-vla.C new file mode 100644 index 0000000000..e313dd8710 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/feat-vla.C @@ -0,0 +1,5 @@ +// We shouldn't define this feature macro when we complain about VLAs. + +#ifdef __cpp_runtime_arrays +# error "__cpp_runtime_arrays" +#endif diff --git a/gcc/testsuite/g++.dg/cpp1y/fn-generic-member-ool.C b/gcc/testsuite/g++.dg/cpp1y/fn-generic-member-ool.C index 1d7c812d06..60ac52eff5 100644 --- a/gcc/testsuite/g++.dg/cpp1y/fn-generic-member-ool.C +++ b/gcc/testsuite/g++.dg/cpp1y/fn-generic-member-ool.C @@ -1,5 +1,5 @@ // Out-of-line generic member function definitions. -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-options "" } struct A { diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-deduce-mult.C b/gcc/testsuite/g++.dg/cpp1y/lambda-deduce-mult.C index 478d6a50ba..f1c7ba9482 100644 --- a/gcc/testsuite/g++.dg/cpp1y/lambda-deduce-mult.C +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-deduce-mult.C @@ -1,7 +1,7 @@ // Testcase for an extension to allow return type deduction when the lambda // contains more than just a single return-statement. -// { dg-do run { target c++1y } } +// { dg-do run { target c++14 } } bool b; template <class T> diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-cfun.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-cfun.C index 0069a6eaed..dd64d560cc 100644 --- a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-cfun.C +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-cfun.C @@ -1,5 +1,5 @@ // Generic lambda conversion to function ptr test from N3690 5.1.2.6 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-options "" } void f1(int (*)(int)) { } diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-dep.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-dep.C index c22bb97eca..dbf8b70f86 100644 --- a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-dep.C +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-dep.C @@ -1,5 +1,5 @@ // Generic lambda type dependence test part from N3690 5.1.2.12 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } void f(int, const int (&)[2] = {}) { } // #1 void f(const int&, const int (&)[1]) { } // #2 diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-ice1.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-ice1.C new file mode 100644 index 0000000000..0e40e62b32 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-ice1.C @@ -0,0 +1,42 @@ +// PR c++/64227 +// { dg-do compile { target c++14 } } + +template<typename T> +struct remove_reference +{ typedef T type; }; + +template<typename T> +struct remove_reference<T&> +{ typedef T type; }; + +template<typename T> +struct remove_reference<T&&> +{ typedef T type; }; + +template<typename T> +constexpr T&& +forward(typename remove_reference<T>::type& t) noexcept +{ return static_cast<T&&>(t); } + +template<typename T> +constexpr T&& +forward(typename remove_reference<T>::type&& t) noexcept +{ return static_cast<T&&>(t); } + +template<typename T> +auto greater_than(T&& t) +{ + return [val = forward<T&&>(t)] (const auto& arg) { return arg > val; }; +} + +template<typename Functor> +void g(Functor f) +{ + for (int i = 0; i < 100000; i++) + f(i); +} + +int main() +{ + g(greater_than(10)); +} diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-mixed.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-mixed.C index 3e67ebd16f..59b5ccaa95 100644 --- a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-mixed.C +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-mixed.C @@ -1,5 +1,5 @@ // Mixed explicit and implicit generic lambda test. -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } int main() { diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-udt.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-udt.C index f0e9a5bbe6..3597fa8053 100644 --- a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-udt.C +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-udt.C @@ -1,6 +1,6 @@ // Ensure that generic lambdas properly construct and destroy user types. // { dg-options "-DUSE_AUTO_SYNTAX" } -// { dg-do run { target c++1y } } +// { dg-do run { target c++14 } } int i = 3; diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-uneval1.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-uneval1.C new file mode 100644 index 0000000000..113eacf843 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-uneval1.C @@ -0,0 +1,17 @@ +// PR c++/64834 +// { dg-do compile { target c++14 } } + +template <typename F> +void e(F f) +{ + f(1); +} + +template <int I> +void bar() { + int x; + e([&] (const int& y) { (void)sizeof(x); }); + e([&] (const auto& y) { (void)sizeof(x); }); +} + +void baz() { bar<1>(); } diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic.C index 7065ac606f..6d2d250f39 100644 --- a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic.C +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic.C @@ -1,5 +1,5 @@ // Basic generic lambda test -// { dg-do run { target c++1y } } +// { dg-do run { target c++14 } } template <typename T, typename U> struct pair {}; template <typename... T> struct tuple {}; diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic2.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic2.C new file mode 100644 index 0000000000..c70cc8d774 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic2.C @@ -0,0 +1,23 @@ +// PR c++/64105 +// This test was ICEing in C++11 mode. +// { dg-do compile { target c++11 } } + +#include <functional> + +using F = std::function<void(void)>; + +struct X +{ + template <typename T> + static void f(T t) + { + g(t); + } + + static void g(F) {} +}; + +int main() +{ + X::f([](auto... xs){}); // { dg-error "" "" { target { ! c++14 } } } +} diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-vla1.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-vla1.C index f646b85b5b..4cabccb27b 100644 --- a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-vla1.C +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-vla1.C @@ -1,5 +1,6 @@ // PR c++/59271 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } +// { dg-options "-Wno-vla" } extern "C" int printf (const char *, ...); diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-x.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-x.C index b722aa7b23..5334091ef5 100644 --- a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-x.C +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-x.C @@ -1,5 +1,5 @@ // Explicit generic lambda test from N3690 5.1.2.5 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } #include <iostream> diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-xcfun.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-xcfun.C index fbd74220d4..d8f5ec15ae 100644 --- a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-xcfun.C +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-xcfun.C @@ -1,5 +1,5 @@ // Explicit generic lambda conversion to function ptr test from N3690 5.1.2.6 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-options "" } void f1(int (*)(int)) { } diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-xudt.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-xudt.C index f6e9e5bffc..b3492dd85d 100644 --- a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-xudt.C +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-xudt.C @@ -1,5 +1,5 @@ // Ensure that generic lambdas properly construct and destroy user types. -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-options "-DUSE_EXPLICIT_TEMPLATE_SYNTAX" } #include "lambda-generic-udt.C" diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic.C index 9721e87d96..9bd744c362 100644 --- a/gcc/testsuite/g++.dg/cpp1y/lambda-generic.C +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic.C @@ -1,5 +1,5 @@ // Generic lambda test from N3690 5.1.2.5 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } #include <iostream> diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-init.C b/gcc/testsuite/g++.dg/cpp1y/lambda-init.C index f9a80059bd..b474893be8 100644 --- a/gcc/testsuite/g++.dg/cpp1y/lambda-init.C +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-init.C @@ -1,5 +1,5 @@ -// Test for the explicit initializer extension of C++1y -// { dg-do compile { target c++1y } } +// Test for the explicit initializer extension of C++14 +// { dg-do compile { target c++14 } } int main() { diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-init1.C b/gcc/testsuite/g++.dg/cpp1y/lambda-init1.C index 2525464141..e9105fc129 100644 --- a/gcc/testsuite/g++.dg/cpp1y/lambda-init1.C +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-init1.C @@ -1,6 +1,6 @@ // N3648: capture init // { dg-options "-w" } -// { dg-do run { target c++1y } } +// { dg-do run { target c++14 } } int main() { diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-init10.C b/gcc/testsuite/g++.dg/cpp1y/lambda-init10.C new file mode 100644 index 0000000000..230b3d173e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-init10.C @@ -0,0 +1,8 @@ +// PR c++/61857 +// { dg-do compile { target c++14 } } + +struct A { + A(int val) {} +}; + +A a{ [x=123]{ return x; }() }; diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-init11.C b/gcc/testsuite/g++.dg/cpp1y/lambda-init11.C new file mode 100644 index 0000000000..f7525d8664 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-init11.C @@ -0,0 +1,20 @@ +// PR c++/61402 +// { dg-do run { target c++14 } } + +extern "C" void abort(); + +template<typename T> +void foo(T t) { + auto test = [ i = ++t ](T v) { + if (i != v) + abort(); + }; + test(t); +} + +int main(){ + foo(3.14f); + foo(0); + foo('a'); + foo(false); +} diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-init12.C b/gcc/testsuite/g++.dg/cpp1y/lambda-init12.C new file mode 100644 index 0000000000..97e90dd647 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-init12.C @@ -0,0 +1,15 @@ +// PR c++/62241 +// { dg-do compile { target c++14 } } + +template<typename Signature> +struct function +{ + template<typename Functor> + function(Functor) { } +}; + +int main () +{ + int bar = 0; + function<void ()> { [foo = bar] { } }; +} diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-init13.C b/gcc/testsuite/g++.dg/cpp1y/lambda-init13.C new file mode 100644 index 0000000000..9b1d139c6d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-init13.C @@ -0,0 +1,18 @@ +// PR c++/64085 +// { dg-do compile { target c++14 } } + +template<typename T> +struct reference_wrapper +{ + T& get() const noexcept; +}; + +template<class T> +auto make_monad(reference_wrapper<T> arg) { + return [&captive = arg.get()](auto&&) { return 1; }; +} + +int main() +{ + make_monad(reference_wrapper<int&>()); +} diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-init2.C b/gcc/testsuite/g++.dg/cpp1y/lambda-init2.C index 83ec57e675..e4f31cfa2d 100644 --- a/gcc/testsuite/g++.dg/cpp1y/lambda-init2.C +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-init2.C @@ -1,5 +1,5 @@ // N3648: redundancy and capture init -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } int main() { diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-init3.C b/gcc/testsuite/g++.dg/cpp1y/lambda-init3.C index 4337228467..49ebde7ff6 100644 --- a/gcc/testsuite/g++.dg/cpp1y/lambda-init3.C +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-init3.C @@ -1,6 +1,6 @@ // N3648: capture init at non-block scope // { dg-options "-w" } -// { dg-do run { target c++1y } } +// { dg-do run { target c++14 } } int i = 42; int j = [x=i]{ return x; }(); diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-init4.C b/gcc/testsuite/g++.dg/cpp1y/lambda-init4.C index 0affb31bd5..787ffc0476 100644 --- a/gcc/testsuite/g++.dg/cpp1y/lambda-init4.C +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-init4.C @@ -1,5 +1,5 @@ // N3648: capture init example from paper -// { dg-do run { target c++1y } } +// { dg-do run { target c++14 } } int x = 4; auto y = [&r = x, x = x+1]()->int { diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-init5.C b/gcc/testsuite/g++.dg/cpp1y/lambda-init5.C index b136f45ea7..1b287a1688 100644 --- a/gcc/testsuite/g++.dg/cpp1y/lambda-init5.C +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-init5.C @@ -1,10 +1,10 @@ // Test for paren and brace initializers -// { dg-do run { target c++1y } } +// { dg-do run { target c++14 } } #include <initializer_list> int main() { if ([x(42)]{ return x; }() != 42) __builtin_abort(); - if ([x{1,2}]{ return x.begin()[0]; }() != 1) __builtin_abort(); + if ([x{24}]{ return x; }() != 24) __builtin_abort(); } diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-init6.C b/gcc/testsuite/g++.dg/cpp1y/lambda-init6.C index 2b82bca457..d6c1587487 100644 --- a/gcc/testsuite/g++.dg/cpp1y/lambda-init6.C +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-init6.C @@ -1,12 +1,10 @@ -// Test that simple captures are not named in the closure type, but -// initialized captures are named. -// { dg-do compile { target c++1y } } +// Test that captures are not named in the closure type. +// { dg-do compile { target c++14 } } int main() { int i; auto lam = [i,j=42]{}; - lam.j; - lam.j.foo; // { dg-error "::j" } + lam.j; // { dg-error "no member" } lam.i; // { dg-error "no member" } } diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-init7.C b/gcc/testsuite/g++.dg/cpp1y/lambda-init7.C index 224cd1a61b..c943c48dfb 100644 --- a/gcc/testsuite/g++.dg/cpp1y/lambda-init7.C +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-init7.C @@ -1,5 +1,5 @@ // PR c++/59349 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } int foo () { [bar()]{}; // { dg-error "empty initializer" } diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-init8.C b/gcc/testsuite/g++.dg/cpp1y/lambda-init8.C new file mode 100644 index 0000000000..21933bd3e1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-init8.C @@ -0,0 +1,26 @@ +// DR1760: "no additional copy and destruction is performed" +// { dg-do run { target c++14 } } + +#include <cassert> + +int copy_count = 0; +int dtor_count = 0; + +struct X +{ + X() = default; + X(const X&) { ++copy_count; } + ~X() { ++dtor_count; } +}; + +int main() +{ + { + X x; + auto z = [y = x](){}; + X x2; + auto z2 = [x2](){}; + assert(copy_count == 2); + } + assert(dtor_count == 4); +} diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-init9.C b/gcc/testsuite/g++.dg/cpp1y/lambda-init9.C new file mode 100644 index 0000000000..a86f03e0f1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-init9.C @@ -0,0 +1,6 @@ +// { dg-do compile { target c++14 } } + +void f() +{ + [&x=1]{}; // { dg-error "cannot capture|invalid initialization" } +} diff --git a/gcc/testsuite/g++.dg/cpp1y/mangle1.C b/gcc/testsuite/g++.dg/cpp1y/mangle1.C index 0642f14798..092b2fa768 100644 --- a/gcc/testsuite/g++.dg/cpp1y/mangle1.C +++ b/gcc/testsuite/g++.dg/cpp1y/mangle1.C @@ -1,5 +1,5 @@ // Test that the parens don't show up in the mangling -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-options "-Wno-return-local-addr" } // { dg-final { scan-assembler "_Z1gI1AEDTdtfp_1iET_" } } diff --git a/gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr1.C b/gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr1.C new file mode 100644 index 0000000000..97bcc056b4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr1.C @@ -0,0 +1,41 @@ +// { dg-do run { target c++14 } } + +struct S { int a; const char* b; int c; int d = b[a]; void *p = this+1; }; +constexpr S ss = S(S{ 1, "asdf" }); + +#define SA(X) static_assert ((X),#X) + +SA(ss.a==1); +SA(ss.b[0] == 'a' && ss.b[1] == 's' && ss.b[2] == 'd' && ss.b[3] == 'f'); +SA(ss.d == 's'); +SA(ss.p == &ss+1); + +struct A +{ + struct B { + int i; + int j = i+1; + } b; + int a = b.j+1; +}; + +extern constexpr A a = { }; +SA(a.b.i == 0 && a.b.j == 1 && a.a == 2); + +int f(const A& ar) { return ar.a; } + +int main() +{ + S ss2 = { 1, "asdf" }; + if (ss2.a != 1 + || __builtin_strcmp(ss2.b,"asdf") != 0 + || ss2.c != int() + || ss2.d != 's' + || ss2.p != &ss2+1) + __builtin_abort(); + + A a = {}; + int i = f(A{}); + if (a.a != 2 || i != 2) + __builtin_abort(); +} diff --git a/gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr2.C b/gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr2.C new file mode 100644 index 0000000000..83cb6c2439 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr2.C @@ -0,0 +1,10 @@ +// { dg-do compile { target c++14 } } + +struct S { int a; const char* b; int c; int d = b[a]; }; + +constexpr int f(const S& s) { return s.a; } + +int main() +{ + constexpr int i = f(S{ 1, "asdf" }); +} diff --git a/gcc/testsuite/g++.dg/cpp1y/pr57640.C b/gcc/testsuite/g++.dg/cpp1y/pr57640.C index b9debe1455..0c76a08aec 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr57640.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr57640.C @@ -1,4 +1,4 @@ -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } #include <chrono> diff --git a/gcc/testsuite/g++.dg/cpp1y/pr57644.C b/gcc/testsuite/g++.dg/cpp1y/pr57644.C index 080572168d..ec595a21b7 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr57644.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr57644.C @@ -1,4 +1,4 @@ -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } struct Foo { diff --git a/gcc/testsuite/g++.dg/cpp1y/pr58500.C b/gcc/testsuite/g++.dg/cpp1y/pr58500.C index ec7d564b4b..bb68cbc199 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr58500.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr58500.C @@ -1,5 +1,5 @@ // PR c++/58500 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-options "" } struct A {}; diff --git a/gcc/testsuite/g++.dg/cpp1y/pr58533.C b/gcc/testsuite/g++.dg/cpp1y/pr58533.C index 34d43aabdc..c8a93d3388 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr58533.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr58533.C @@ -1,5 +1,5 @@ // PR c++/58533 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } void foo() { diff --git a/gcc/testsuite/g++.dg/cpp1y/pr58534.C b/gcc/testsuite/g++.dg/cpp1y/pr58534.C index dd5073182c..e38e1f3f66 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr58534.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr58534.C @@ -1,5 +1,5 @@ // PR c++/58534 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-options "" } template<typename> void foo(const auto&) {} diff --git a/gcc/testsuite/g++.dg/cpp1y/pr58535.C b/gcc/testsuite/g++.dg/cpp1y/pr58535.C index e0718480b3..b36be8f4a4 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr58535.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr58535.C @@ -1,5 +1,5 @@ // PR c++/58535 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-options "" } struct A diff --git a/gcc/testsuite/g++.dg/cpp1y/pr58536.C b/gcc/testsuite/g++.dg/cpp1y/pr58536.C index 05c00b362d..a4b6f553ef 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr58536.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr58536.C @@ -1,5 +1,5 @@ // PR c++/58536 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-options "" } struct A diff --git a/gcc/testsuite/g++.dg/cpp1y/pr58548.C b/gcc/testsuite/g++.dg/cpp1y/pr58548.C index 122b96f500..6a78de46c3 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr58548.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr58548.C @@ -1,5 +1,5 @@ // PR c++/58548 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-options "" } void foo(auto) diff --git a/gcc/testsuite/g++.dg/cpp1y/pr58549.C b/gcc/testsuite/g++.dg/cpp1y/pr58549.C index 1b54af4a67..2f76399d8d 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr58549.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr58549.C @@ -1,5 +1,5 @@ // PR c++/58549 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-options "" } void foo(auto) diff --git a/gcc/testsuite/g++.dg/cpp1y/pr58637.C b/gcc/testsuite/g++.dg/cpp1y/pr58637.C index ecc9258114..caa60af630 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr58637.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr58637.C @@ -1,4 +1,4 @@ // PR c++/58637 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } template<> void foo(auto); // { dg-error "auto|not a template" } diff --git a/gcc/testsuite/g++.dg/cpp1y/pr58708.C b/gcc/testsuite/g++.dg/cpp1y/pr58708.C index 226b318f65..6fc374f1e5 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr58708.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr58708.C @@ -1,4 +1,4 @@ -// { dg-do run { target c++1y } } +// { dg-do run { target c++14 } } template<typename, typename> struct is_same diff --git a/gcc/testsuite/g++.dg/cpp1y/pr59110.C b/gcc/testsuite/g++.dg/cpp1y/pr59110.C index c78d645cc3..dba9cea0dc 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr59110.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr59110.C @@ -1,4 +1,4 @@ // PR c++/59110 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } int i = *(auto*)0; // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/cpp1y/pr59112.C b/gcc/testsuite/g++.dg/cpp1y/pr59112.C index bc9d99eb3f..fc67e3820d 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr59112.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr59112.C @@ -1,5 +1,5 @@ // PR c++/59112 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } void foo() { diff --git a/gcc/testsuite/g++.dg/cpp1y/pr59113.C b/gcc/testsuite/g++.dg/cpp1y/pr59113.C index 8d2bf7fbf7..3d7dd61ac9 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr59113.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr59113.C @@ -1,5 +1,5 @@ // PR c++/59113 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } void foo() { diff --git a/gcc/testsuite/g++.dg/cpp1y/pr59629.C b/gcc/testsuite/g++.dg/cpp1y/pr59629.C index b6e561f2e0..f66e64eb6a 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr59629.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr59629.C @@ -1,4 +1,4 @@ // PR c++/59629 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } void foo(int i = []{ auto 0; }()); // { dg-error "expected|could not convert" } diff --git a/gcc/testsuite/g++.dg/cpp1y/pr59635.C b/gcc/testsuite/g++.dg/cpp1y/pr59635.C index 80d9f4de43..9af99397dc 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr59635.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr59635.C @@ -1,5 +1,5 @@ // PR c++/59635 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } auto f = [] (auto, ...) { return 0; }; diff --git a/gcc/testsuite/g++.dg/cpp1y/pr59636.C b/gcc/testsuite/g++.dg/cpp1y/pr59636.C index 6128753e08..847cecdf5a 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr59636.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr59636.C @@ -1,4 +1,4 @@ // PR c++/59636 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } auto f = []() { return []<>() {}; }; // { dg-error "expected identifier" } diff --git a/gcc/testsuite/g++.dg/cpp1y/pr59638.C b/gcc/testsuite/g++.dg/cpp1y/pr59638.C index 0125bdcbb7..a34b657186 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr59638.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr59638.C @@ -1,12 +1,12 @@ // PR c++/59638 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-options "" } -void (*a)(auto); // { dg-error "template declaration" } +void (*a)(auto); // { dg-error "" } -void (*b)(auto) = 0; // { dg-error "template declaration" } +void (*b)(auto) = 0; // { dg-error "" } -typedef void (*f)(auto); // { dg-error "template declaration" } +typedef void (*f)(auto); // { dg-error "" } struct A { diff --git a/gcc/testsuite/g++.dg/cpp1y/pr59867.C b/gcc/testsuite/g++.dg/cpp1y/pr59867.C index 91d025964c..2c4f1d046b 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr59867.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr59867.C @@ -1,7 +1,6 @@ // PR c++/59867 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } -#include <iostream> using namespace std; // constant diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60033.C b/gcc/testsuite/g++.dg/cpp1y/pr60033.C index f918d33fdd..c083facb43 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr60033.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr60033.C @@ -1,5 +1,5 @@ // PR c++/60033 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } template <typename... T> auto f(T&&... ts) diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60052.C b/gcc/testsuite/g++.dg/cpp1y/pr60052.C index 6ac7720204..25d20acdf8 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr60052.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr60052.C @@ -1,5 +1,5 @@ // PR c++/60052 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-options "" } struct A diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60053.C b/gcc/testsuite/g++.dg/cpp1y/pr60053.C index 846039052f..a8f5ba1ca3 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr60053.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr60053.C @@ -1,5 +1,5 @@ // PR c++/60053 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-options "" } struct A diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60054.C b/gcc/testsuite/g++.dg/cpp1y/pr60054.C new file mode 100644 index 0000000000..f51120f642 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/pr60054.C @@ -0,0 +1,11 @@ +// PR c++/60054 +// { dg-do compile { target c++14 } } + +template<typename T> T fooA(T); +template<typename T> decltype(T{}) fooB(T); + +void bar() +{ + fooA((auto*)0); // { dg-error "invalid use" } + fooB((auto*)0); // { dg-error "invalid use" } +} diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60064.C b/gcc/testsuite/g++.dg/cpp1y/pr60064.C index e61704e8ec..add3f05cbb 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr60064.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr60064.C @@ -1,5 +1,5 @@ // PR c++/60064 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-options "" } class A diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60065.C b/gcc/testsuite/g++.dg/cpp1y/pr60065.C index 2cf8da12bc..56505b7bc0 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr60065.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr60065.C @@ -1,5 +1,5 @@ // PR c++/60065 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-options "" } template <int> void foo(auto... x); diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60190.C b/gcc/testsuite/g++.dg/cpp1y/pr60190.C index 9a5b484a66..9e439ceb9e 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr60190.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr60190.C @@ -1,4 +1,4 @@ // PR c++/60190 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } auto f = []<int>() -> int() {}; // { dg-error "returning a function|expected" } diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60311.C b/gcc/testsuite/g++.dg/cpp1y/pr60311.C index 001e99327e..6d32831f86 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr60311.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr60311.C @@ -1,5 +1,5 @@ // PR c++/60311 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } template<void(*)(auto)> struct A {}; // { dg-error "auto" } diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60332.C b/gcc/testsuite/g++.dg/cpp1y/pr60332.C index c0a67a9f6c..e75ab8584e 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr60332.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr60332.C @@ -1,5 +1,5 @@ // PR c++/60332 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } void foo(); diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60376.C b/gcc/testsuite/g++.dg/cpp1y/pr60376.C index 51d088a2a9..9585dd2ca7 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr60376.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr60376.C @@ -1,5 +1,5 @@ // PR c++/60376 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } struct A { diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60377.C b/gcc/testsuite/g++.dg/cpp1y/pr60377.C index 6d1d416ec8..ab35ba9b17 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr60377.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr60377.C @@ -1,5 +1,5 @@ // PR c++/60377 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-options "" } void foo(auto, void (f*)()); // { dg-error "expected" } diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60384.C b/gcc/testsuite/g++.dg/cpp1y/pr60384.C index f206647e64..44806cd69e 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr60384.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr60384.C @@ -1,5 +1,5 @@ // PR c++/60384 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } template<typename> int foo(); diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60390.C b/gcc/testsuite/g++.dg/cpp1y/pr60390.C index 5cd5539f82..38d0e4bd6c 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr60390.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr60390.C @@ -1,5 +1,5 @@ // PR c++/60390 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-options "" } struct A diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60391.C b/gcc/testsuite/g++.dg/cpp1y/pr60391.C index 68746aedf3..7e3570498b 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr60391.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr60391.C @@ -1,5 +1,5 @@ // PR c++/60391 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-options "" } namespace N diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60393.C b/gcc/testsuite/g++.dg/cpp1y/pr60393.C index 8e89be4993..27fe2b7229 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr60393.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr60393.C @@ -1,5 +1,5 @@ // PR c++/60393 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-options "" } void (*f)(auto) + 0; // { dg-error "expected" } diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60573.C b/gcc/testsuite/g++.dg/cpp1y/pr60573.C index 2f607071c4..da730f80f0 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr60573.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr60573.C @@ -1,5 +1,5 @@ // PR c++/60573 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-options "" } struct A diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60626.C b/gcc/testsuite/g++.dg/cpp1y/pr60626.C index 39ea438159..311464472d 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr60626.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr60626.C @@ -1,7 +1,7 @@ // PR c++/60626 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-options "" } struct A {}; -void (*A::p)(auto) = 0; // { dg-error "static member|non-template" } +void (*A::p)(auto) = 0; // { dg-error "static data member|template" } diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60627.C b/gcc/testsuite/g++.dg/cpp1y/pr60627.C index 9e2116e9cb..64eb635922 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr60627.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr60627.C @@ -1,5 +1,5 @@ // PR c++/60627 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-options "" } template<typename T> void foo(T) {} diff --git a/gcc/testsuite/g++.dg/cpp1y/pr63996.C b/gcc/testsuite/g++.dg/cpp1y/pr63996.C new file mode 100644 index 0000000000..8f66cdc389 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/pr63996.C @@ -0,0 +1,10 @@ +// { dg-do compile { target c++14 } } + +constexpr int +foo (int i) +{ + int a[i] = { }; // { dg-error "forbids variable length" } +} + +constexpr int j = foo (1); // { dg-error "flows off the end" } + diff --git a/gcc/testsuite/g++.dg/cpp1y/pr64626-1.C b/gcc/testsuite/g++.dg/cpp1y/pr64626-1.C new file mode 100644 index 0000000000..07af9f0a01 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/pr64626-1.C @@ -0,0 +1,20 @@ +// PR c++/64626 +// { dg-do compile { target c++14 } } + +#define STR(s) #s +int +main() +{ + int i = 1'2; + const char *s[3] + { + STR(1' '), + STR(..), + STR(%:%), + }; +} +#if 0 +1' ' +.. +%:% +#endif diff --git a/gcc/testsuite/g++.dg/cpp1y/pr64626-2.C b/gcc/testsuite/g++.dg/cpp1y/pr64626-2.C new file mode 100644 index 0000000000..62c3546718 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/pr64626-2.C @@ -0,0 +1,11 @@ +// PR c++/64626 +// { dg-do compile { target c++14 } } + +0''; // { dg-error "empty character constant" } + +123'''; // { dg-error "empty character constant" } + +// { dg-error "expected unqualified-id" "expected unqualified-id" { target *-*-* } 4 } + +// { dg-error "missing terminating" "missing terminating" { target *-*-* } 6 } +// { dg-error "expected unqualified-id" "expected unqualified-id" { target *-*-* } 6 } diff --git a/gcc/testsuite/g++.dg/cpp1y/pr65202.C b/gcc/testsuite/g++.dg/cpp1y/pr65202.C new file mode 100644 index 0000000000..602b264b30 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/pr65202.C @@ -0,0 +1,26 @@ +// // PR c++/65202 +// { dg-do compile { target c++14 } } + +template <typename T> struct is_move_constructible; +template <typename T> struct is_move_assignable; +template <int, typename T> using enable_if_t = int; +namespace adl { +template < + typename L, typename R, + enable_if_t<is_move_constructible<L>() && is_move_assignable<L>(), int>...> +constexpr auto adl_swap(L &l, R &r) -> decltype(swap(l, r)) { + return; +} +template <typename L, typename R> +auto swap(L &l, R &r) noexcept(noexcept(adl::adl_swap(l, r))) + -> decltype(adl::adl_swap(l, r)); +namespace ns { +template <typename T> struct foo {}; +template <typename T> void swap(foo<T> &, foo<T> &); +struct bar; + +int main() +{ + foo<ns::bar> f; + adl::swap(f, f) +} // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/cpp1y/pr65340.C b/gcc/testsuite/g++.dg/cpp1y/pr65340.C new file mode 100644 index 0000000000..848eff965e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/pr65340.C @@ -0,0 +1,19 @@ +// PR c++/65340 +// { dg-do compile { target c++14 } } + +template <typename Type> Type constant; +namespace reflect { +namespace functors { + struct recurse { auto operator()(, ); }; // { dg-error "expected" } +} + auto &recurse = constant < functors :: recurse > ; +} +namespace functors { +struct traverse { + template <typename Algo, typename Value> + auto operator()(Algo, Value) -> decltype(reflect + :: recurse(0, 0)); // { dg-error "use of" } +}; +} +auto &traverse = constant < functors :: traverse > ; +operator()()->decltype(traverse(0, 0)) // { dg-error "no match|expected" } diff --git a/gcc/testsuite/g++.dg/cpp1y/regress1.C b/gcc/testsuite/g++.dg/cpp1y/regress1.C index 5bb804258e..d4566d0a21 100644 --- a/gcc/testsuite/g++.dg/cpp1y/regress1.C +++ b/gcc/testsuite/g++.dg/cpp1y/regress1.C @@ -1,5 +1,5 @@ // PR c++/60409 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } struct A { diff --git a/gcc/testsuite/g++.dg/cpp1y/sized-dealloc1.C b/gcc/testsuite/g++.dg/cpp1y/sized-dealloc1.C new file mode 100644 index 0000000000..846fce6199 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/sized-dealloc1.C @@ -0,0 +1,75 @@ +// Test for C++14 sized deallocation. The operators delete defined below +// should be called only in C++14 mode and above. +// { dg-do run } + +extern "C" void abort(); +typedef __SIZE_TYPE__ size_t; +#include <new> + +bool called; +void operator delete[] (void *p, size_t s) throw() +{ + called = true; + operator delete[] (p); +} + +void operator delete (void *p, size_t s) throw() +{ + called = true; + operator delete (p); +} + +void operator delete[] (void *p, size_t s, const std::nothrow_t &) throw() +{ + called = true; + operator delete[] (p); +} + +void operator delete (void *p, size_t s, const std::nothrow_t &) throw() +{ + called = true; + operator delete (p); +} + +struct A { ~A(){} }; + +struct B { }; + +struct C; + +struct D { ~D(){}; D() { throw 1; } }; + +int main() +{ + /* * If the type is complete and if, for the second alternative (delete + array) only, the operand is a pointer to a class type with a + non-trivial destructor or a (possibly multi-dimensional) array + thereof, the function with two parameters is selected. + + * Otherwise, it is unspecified which of the two deallocation functions + is selected. */ + delete new int; + if (called != (__cplusplus >= 201402L)) abort(); called = false; + + delete new A; + if (called != (__cplusplus >= 201402L)) abort(); called = false; + + delete[] new A[2]; + if (called != (__cplusplus >= 201402L)) abort(); called = false; + + delete new B; + if (called != (__cplusplus >= 201402L)) abort(); called = false; + + /* N3778 added the sized placement deallocation functions, but the core + language rules don't provide any way they would be called. */ + try { new (std::nothrow) D; } catch (int) {} + if (called) abort(); + + try { new (std::nothrow) D[2]; } catch (int) {} + if (called) abort(); + + /* Make sure we don't try to use the size of an array that doesn't have a + cookie. */ + delete[] new B[2]; + if (called) abort(); +} diff --git a/gcc/testsuite/g++.dg/cpp1y/sized-dealloc2.C b/gcc/testsuite/g++.dg/cpp1y/sized-dealloc2.C new file mode 100644 index 0000000000..a3ab64c26a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/sized-dealloc2.C @@ -0,0 +1,5 @@ +// Test that -Wc++14-compat warns about the change in meaning. +// { dg-options "-Wall" } + +typedef __SIZE_TYPE__ size_t; +void operator delete[] (void *p, size_t s) throw(); // { dg-warning "usual" "" { target { ! c++14 } } } diff --git a/gcc/testsuite/g++.dg/cpp1y/sized-dealloc3.C b/gcc/testsuite/g++.dg/cpp1y/sized-dealloc3.C new file mode 100644 index 0000000000..e5bfe7cdde --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/sized-dealloc3.C @@ -0,0 +1,3 @@ +// { dg-options "-Wsized-deallocation" } + +void operator delete (void *p) throw() { __builtin_free(p); } // { dg-warning "sized" "" { target c++14 } } diff --git a/gcc/testsuite/g++.dg/cpp1y/system-binary-constants-1.C b/gcc/testsuite/g++.dg/cpp1y/system-binary-constants-1.C index 951fa3c5f1..ec2d5858ea 100644 --- a/gcc/testsuite/g++.dg/cpp1y/system-binary-constants-1.C +++ b/gcc/testsuite/g++.dg/cpp1y/system-binary-constants-1.C @@ -1,5 +1,5 @@ // Origin: Dodji Seketeli <dodji@redhat.com> -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } #include "../system-binary-constants-1.h" @@ -9,5 +9,5 @@ foo (void) #if BINARY_INT_CONSTANT_IN_SYSTEM_HEADER return 23; #endif - return 0b1101; // { dg-bogus "binary constants are a C..1y feature or GCC extension" } + return 0b1101; // { dg-bogus "binary constants are a C..14 feature or GCC extension" } } diff --git a/gcc/testsuite/g++.dg/cpp1y/udlit-char-template-neg.C b/gcc/testsuite/g++.dg/cpp1y/udlit-char-template-neg.C index c99b2f7278..e77ea45890 100644 --- a/gcc/testsuite/g++.dg/cpp1y/udlit-char-template-neg.C +++ b/gcc/testsuite/g++.dg/cpp1y/udlit-char-template-neg.C @@ -1,4 +1,4 @@ -// { dg-do compile { target { c++11 && { ! c++1y } } } } +// { dg-do compile { target { c++11 && { ! c++14 } } } } template<typename CharT, CharT... String> int diff --git a/gcc/testsuite/g++.dg/cpp1y/udlit-char-template-sfinae-neg.C b/gcc/testsuite/g++.dg/cpp1y/udlit-char-template-sfinae-neg.C new file mode 100644 index 0000000000..b74900101a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/udlit-char-template-sfinae-neg.C @@ -0,0 +1,20 @@ +// { dg-do compile { target c++14 } } +// { dg-prune-output "note:" } + +template<bool, typename _Tp = void>struct enable_if {}; +template<typename _Tp> struct enable_if<true, _Tp> { typedef _Tp type; }; + + +template<typename CharT, CharT... String> +typename enable_if<sizeof...(String) == 1, int>::type operator"" _script () { // { dg-error "no type named|in" } + return 1; +} + +template<typename CharT, CharT... String> +typename enable_if<sizeof...(String) == 2, int>::type operator"" _script () { // { dg-error "no type named|in" } + return 2; +} + +int a = "1"_script; +int b = "22"_script; +int c = "333"_script; // { dg-error "no matching function for call to"} diff --git a/gcc/testsuite/g++.dg/cpp1y/udlit-char-template-sfinae.C b/gcc/testsuite/g++.dg/cpp1y/udlit-char-template-sfinae.C new file mode 100644 index 0000000000..a9c577fd11 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/udlit-char-template-sfinae.C @@ -0,0 +1,29 @@ +// { dg-do run { target c++14 } } + +#include <cassert> + +template<bool, typename _Tp = void>struct enable_if {}; +template<typename _Tp> struct enable_if<true, _Tp> { typedef _Tp type; }; + + +template<typename CharT, CharT... String> +typename enable_if<sizeof...(String) == 6, int>::type operator"" _script () { + return 5; +} + +template<typename CharT, CharT... String> +typename enable_if<sizeof...(String) == 3, int>::type operator"" _script () { + return 3; +} + +template<typename CharT, CharT... String> +typename enable_if<sizeof...(String) != 3 && sizeof...(String) != 6, int>::type operator"" _script () { + return 1; +} + +int main () +{ + assert ("hello!"_script == 5); + assert (u8"hi!"_script == 3); + assert ("hey!"_script == 1); +} diff --git a/gcc/testsuite/g++.dg/cpp1y/udlit-char-template-vs-std-literal-operator.C b/gcc/testsuite/g++.dg/cpp1y/udlit-char-template-vs-std-literal-operator.C new file mode 100644 index 0000000000..6e3ffe4ecd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/udlit-char-template-vs-std-literal-operator.C @@ -0,0 +1,19 @@ +// { dg-do run { target c++14 } } + +#include <cassert> + +typedef decltype(sizeof(0)) size_type; + +template<typename CharT, CharT... String> +int operator"" _script () { + return 1; +} + +int operator"" _script (const char*, size_type) { + return 2; +} + +int main () +{ + assert ("123"_script == 2); +} diff --git a/gcc/testsuite/g++.dg/cpp1y/udlit-char-template.C b/gcc/testsuite/g++.dg/cpp1y/udlit-char-template.C index d6b44d9c0f..989b9babd1 100644 --- a/gcc/testsuite/g++.dg/cpp1y/udlit-char-template.C +++ b/gcc/testsuite/g++.dg/cpp1y/udlit-char-template.C @@ -1,4 +1,4 @@ -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } template<typename CharT, CharT... String> int diff --git a/gcc/testsuite/g++.dg/cpp1y/udlit-empty-string-neg.C b/gcc/testsuite/g++.dg/cpp1y/udlit-empty-string-neg.C index 7c23641e62..1b7f4fa255 100644 --- a/gcc/testsuite/g++.dg/cpp1y/udlit-empty-string-neg.C +++ b/gcc/testsuite/g++.dg/cpp1y/udlit-empty-string-neg.C @@ -1,21 +1,21 @@ -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } int operator "*"_s(unsigned long long) // { dg-error "expected empty string after 'operator'" } { return 0; } int -operator L"*"_Ls(unsigned long long) // { dg-error "invalid encoding prefix in literal operator" } +operator L"*"_Ls(unsigned long long) // { dg-error "expected empty string after 'operator'" } { return 0; } int -operator u"*"_s16(unsigned long long) // { dg-error "invalid encoding prefix in literal operator" } +operator u"*"_s16(unsigned long long) // { dg-error "expected empty string after 'operator'" } { return 0; } int -operator U"*"_s32(unsigned long long) // { dg-error "invalid encoding prefix in literal operator" } +operator U"*"_s32(unsigned long long) // { dg-error "expected empty string after 'operator'" } { return 0; } int -operator u8"*"_u8s(unsigned long long) // { dg-error "invalid encoding prefix in literal operator" } +operator u8"*"_u8s(unsigned long long) // { dg-error "expected empty string after 'operator'" } { return 0; } diff --git a/gcc/testsuite/g++.dg/cpp1y/udlit-enc-prefix-neg.C b/gcc/testsuite/g++.dg/cpp1y/udlit-enc-prefix-neg.C index 51def3aca3..039ab2fb45 100644 --- a/gcc/testsuite/g++.dg/cpp1y/udlit-enc-prefix-neg.C +++ b/gcc/testsuite/g++.dg/cpp1y/udlit-enc-prefix-neg.C @@ -1,4 +1,4 @@ -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } int operator L""_Ls(unsigned long long) // { dg-error "invalid encoding prefix in literal operator" } diff --git a/gcc/testsuite/g++.dg/cpp1y/udlit-userdef-string.C b/gcc/testsuite/g++.dg/cpp1y/udlit-userdef-string.C index f6c3baec92..cad4a1dfc6 100644 --- a/gcc/testsuite/g++.dg/cpp1y/udlit-userdef-string.C +++ b/gcc/testsuite/g++.dg/cpp1y/udlit-userdef-string.C @@ -1,4 +1,4 @@ -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } #include "complex_literals.h" diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ1.C b/gcc/testsuite/g++.dg/cpp1y/var-templ1.C new file mode 100644 index 0000000000..89b3c8f312 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/var-templ1.C @@ -0,0 +1,18 @@ +// { dg-do compile { target c++14 } } + +template<int A, int B> + struct S1 + { + static constexpr int a = A; + static constexpr int b = B; + }; + +template<typename T> + constexpr int var = T::a + T::b; + +int main () +{ + static_assert(var<S1<11, 100>> == var<S1<199, 23>>/2 + && var<S1<50, 120>> == var<S1<150, var<S1<10, 10>>>> + && var<S1<53, 23>> != 222, ""); +} diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ10.C b/gcc/testsuite/g++.dg/cpp1y/var-templ10.C new file mode 100644 index 0000000000..ece2eb2802 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/var-templ10.C @@ -0,0 +1,16 @@ +// { dg-do compile { target c++14 } } + +template <class T> +struct Y +{ + template <class U> static U x; +}; + +template <class T> +template <class U> +U Y<T>::x = U(); + +int main() +{ + int y = Y<int>::x<int>; +} diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ11.C b/gcc/testsuite/g++.dg/cpp1y/var-templ11.C new file mode 100644 index 0000000000..5d6e0d0dcf --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/var-templ11.C @@ -0,0 +1,67 @@ +// PR c++/63201 +// { dg-do compile { target c++14 } } + +template <class T> +struct Y +{ + template <class U> static U x; +}; + +template <class T> +template <class U> +U Y<T>::x = U(); + +template <> +template <class U> +U Y<int>::x = 42; + +template <> +template <class U> +// odd diagnostic +U Y<float>::x<U> = 42; // { dg-error "partial specialization" } + +template <> +template <> +int Y<float>::x<int> = 42; // { dg-bogus "non-member-template declaration" } + +template <class T> +struct Z +{ + template <class U> struct ZZ + { + template <class V> static V x; + }; +}; + +template <class T> +template <class U> +template <class V> +V Z<T>::ZZ<U>::x = V(); + +template <> +template <> +template <class V> +V Z<int>::ZZ<int>::x = V(); + +template <> +template <class U> +struct Z<float>::ZZ +{ + template <class V> static V x; +}; + +template <> +template <class U> +template <class V> +V Z<float>::ZZ<U>::x = V(); + +template <> +template <> +template <> +int Z<float>::ZZ<int>::x<int> = 42; // { dg-bogus "non-member-template declaration" } + +int main() +{ + int y = Y<int>::x<int>; + int z = Z<float>::ZZ<int>::x<int>; +} diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ12.C b/gcc/testsuite/g++.dg/cpp1y/var-templ12.C new file mode 100644 index 0000000000..49ea588cc5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/var-templ12.C @@ -0,0 +1,10 @@ +// { dg-do compile { target c++14 } } +// { dg-options "-Wall" } + +template <class T> T x; +template <> int x<int> = 0; + +int main() +{ + return x<int>; +} diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ13.C b/gcc/testsuite/g++.dg/cpp1y/var-templ13.C new file mode 100644 index 0000000000..e398d22fdd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/var-templ13.C @@ -0,0 +1,5 @@ +// { dg-do compile { target c++14 } } + +template <class T> T x; +template <> int x<int> = 0; +template <> int x<int> = 0; // { dg-error "x<int>" } diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ14.C b/gcc/testsuite/g++.dg/cpp1y/var-templ14.C new file mode 100644 index 0000000000..c3c50d1266 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/var-templ14.C @@ -0,0 +1,15 @@ +// PR c++/63528 +// { dg-do compile { target c++14 } } + +template<class...> +struct X +{ + constexpr static bool value = true; +}; + +static_assert(X<int>::value, ""); + +template <class... Args> +constexpr bool X_v = X<Args...>::value; + +static_assert(X_v<int>, ""); diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ15.C b/gcc/testsuite/g++.dg/cpp1y/var-templ15.C new file mode 100644 index 0000000000..7dd2dcdcf9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/var-templ15.C @@ -0,0 +1,5 @@ +// PR c++/63588 +// { dg-do compile { target c++14 } } + +template <class T> T elements; +int i = elements <>; // { dg-error "arguments" } diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ16.C b/gcc/testsuite/g++.dg/cpp1y/var-templ16.C new file mode 100644 index 0000000000..9fd560891b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/var-templ16.C @@ -0,0 +1,6 @@ +// { dg-do compile { target c++14 } } + +template <class T> T t = 42; +template <class T> T* t<T*> = nullptr; + +void *p = t<void*>; diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ17.C b/gcc/testsuite/g++.dg/cpp1y/var-templ17.C new file mode 100644 index 0000000000..c6d97ebb36 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/var-templ17.C @@ -0,0 +1,9 @@ +// DR 1727: a specialization doesn't need to have the same type +// { dg-do compile { target c++14 } } + +template <class T> T t = 42; +template<> void* t<int> = 0; + +template<class T, class U> struct same; +template<class T> struct same<T,T> {}; +same<void*,decltype(t<int>)> s; diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ18.C b/gcc/testsuite/g++.dg/cpp1y/var-templ18.C new file mode 100644 index 0000000000..415a7d5e84 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/var-templ18.C @@ -0,0 +1,9 @@ +// DR 1727: a specialization doesn't need to have the same type +// { dg-do compile { target c++14 } } + +template <class T> T t = 42; +template <class T> int t<T*> = 0; + +template<class T, class U> struct same; +template<class T> struct same<T,T> {}; +same<int,decltype(t<void*>)> s; diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ19.C b/gcc/testsuite/g++.dg/cpp1y/var-templ19.C new file mode 100644 index 0000000000..862752ad33 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/var-templ19.C @@ -0,0 +1,18 @@ +// { dg-do compile { target c++14 } } + +template <class T> T t1 = 42; +template <class T> T* t1<T> = nullptr; // { dg-error "partial" } + +template <class T> T t2 = 42; +template <class T> T* t2<T*> = nullptr; +template <class T> T* t2<T*> = nullptr; // { dg-error "redefinition" } + +template <class T, class U> T t3 = U(); +template <class T> T t3<T,int> = 42; +template <class U> int t3<int,U> = U(); + +int i = t3<int,int>; // { dg-error "ambiguous" } + +template <class T> T t4 = T(); +void *p = t4<void*>; +template <class T> T* t4<T*> = nullptr; // { dg-error "after instantiation" } diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ2.C b/gcc/testsuite/g++.dg/cpp1y/var-templ2.C new file mode 100644 index 0000000000..c734f41314 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/var-templ2.C @@ -0,0 +1,33 @@ +// { dg-do compile { target c++14 } } + +// Template variables and static member variables of template classes are +// often confused. + +template<typename T> + struct S1 + { + static int n; + static int arr[]; + }; + +template<typename T> + constexpr int var = sizeof (T); + +template<typename T> + int S1<T>::n = sizeof (T); + +template<typename T> + int S1<T>::arr[sizeof (T)]; + +template<> + int S1<int>::n = 8; + +template<> + int S1<int>::arr[8]; + +int main () +{ + S1<int> v1; + var<S1<int>>; + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ20.C b/gcc/testsuite/g++.dg/cpp1y/var-templ20.C new file mode 100644 index 0000000000..38bd3705d1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/var-templ20.C @@ -0,0 +1,12 @@ +// { dg-do compile { target c++14 } } + +template <bool> struct Sink {}; +template <class T> void fn(); +template <class T> T var = T(); + +template <class T> void f() +{ + Sink<fn<T>::value>(); // { dg-error "function" } + Sink<var<T>::value>(); // { dg-error "variable" } +} +// { dg-prune-output "template argument" } diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ21.C b/gcc/testsuite/g++.dg/cpp1y/var-templ21.C new file mode 100644 index 0000000000..a7b0899583 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/var-templ21.C @@ -0,0 +1,25 @@ +// PR c++/64455 +// { dg-do compile { target c++14 } } + +template<typename Type> +constexpr bool IsType = true; + +template <bool b, class T> struct Test +{ +}; + +template <class T> +struct Test<true, T> +{ + typedef T type; +}; + +template<class T> +struct X { + typedef typename Test<IsType<T>,T>::type type; +}; + +int main() +{ + X<int>::type t; +} diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ22.C b/gcc/testsuite/g++.dg/cpp1y/var-templ22.C new file mode 100644 index 0000000000..9ddc925e97 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/var-templ22.C @@ -0,0 +1,14 @@ +// PR c++/63889 +// { dg-do compile { target c++14 } } + +template<class T> +struct A +{ + template<class> + static constexpr bool is_ok = true; + + template<bool v = is_ok<T>> + A(T) { } +}; + +A<int> p(42); diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ23.C b/gcc/testsuite/g++.dg/cpp1y/var-templ23.C new file mode 100644 index 0000000000..a5b19d28d6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/var-templ23.C @@ -0,0 +1,7 @@ +// PR c++/65625 +// { dg-do compile { target c++14 } } + +namespace std { + template <typename T> int declval; + typename std::declval<> d; // { dg-error "not a type" } +} diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ3.C b/gcc/testsuite/g++.dg/cpp1y/var-templ3.C new file mode 100644 index 0000000000..254f388ace --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/var-templ3.C @@ -0,0 +1,16 @@ +// { dg-do compile { target c++14 } } + +template<typename T> + constexpr int var = sizeof (T); + +template<typename T> + struct S1 + { + template<typename U> + static constexpr int a = sizeof (U) + sizeof (T); + }; + +int main () +{ + static_assert(var<int> + var<char> == S1<int>::a<char>, ""); +} diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ4.C b/gcc/testsuite/g++.dg/cpp1y/var-templ4.C new file mode 100644 index 0000000000..3cd84a892c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/var-templ4.C @@ -0,0 +1,12 @@ +// { dg-do compile { target c++14 } } + +template<typename T> + constexpr int var = sizeof (T); + +template<> + constexpr int var<int> = 100000; + +int main () +{ + static_assert(var<int> == 100000 && var<char> == sizeof(char), ""); +} diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ5.C b/gcc/testsuite/g++.dg/cpp1y/var-templ5.C new file mode 100644 index 0000000000..a8bc7f69b0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/var-templ5.C @@ -0,0 +1,19 @@ +// { dg-do compile { target c++14 } } + +template<int A, int B> + struct S1 + { + static constexpr int a = A; + static constexpr int b = B; + }; + +template<class T> + constexpr int var = T::a + T::b; + +template<template<int,int> class T, int A> + constexpr int var2 = var<T<A, A>> + A; + +int main () +{ + static_assert(var2<S1, 40> == 120, ""); +} diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ6.C b/gcc/testsuite/g++.dg/cpp1y/var-templ6.C new file mode 100644 index 0000000000..23ebfbe74f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/var-templ6.C @@ -0,0 +1,12 @@ +// { dg-do compile { target c++14 } } + +template<typename T> + constexpr bool Class = __is_class(T); + +template<typename T> + constexpr bool Test = Class<T>; + +struct S { }; + +static_assert(!Test<int>, ""); +static_assert(Test<S>, ""); diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ7.C b/gcc/testsuite/g++.dg/cpp1y/var-templ7.C new file mode 100644 index 0000000000..07453af796 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/var-templ7.C @@ -0,0 +1,8 @@ +// { dg-do compile { target c++14 } } + +template <class T> T var = 0; + +int main() +{ + var<int> = 42; +} diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ8.C b/gcc/testsuite/g++.dg/cpp1y/var-templ8.C new file mode 100644 index 0000000000..8e3d34a7b8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/var-templ8.C @@ -0,0 +1,15 @@ +// { dg-do compile { target c++14 } } +// { dg-final { scan-assembler "_ZN1X1xIiEE" } } + +struct X +{ + template <class T> static T x; +}; + +template <class T> +T X::x = T(); + +int main() +{ + int x = X::x<int>; +} diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ9.C b/gcc/testsuite/g++.dg/cpp1y/var-templ9.C new file mode 100644 index 0000000000..2ffb007add --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/var-templ9.C @@ -0,0 +1,15 @@ +// { dg-do compile { target c++14 } } + +struct X +{ + template <class T> static int x; +}; + +int X::x = 42; // { dg-error "template" } + +struct Y +{ + static int y; +}; + +template <class T> int Y::y = 42; // { dg-error "template" } diff --git a/gcc/testsuite/g++.dg/cpp1y/vla-initlist1.C b/gcc/testsuite/g++.dg/cpp1y/vla-initlist1.C index b642ed4158..8f5709dbc3 100644 --- a/gcc/testsuite/g++.dg/cpp1y/vla-initlist1.C +++ b/gcc/testsuite/g++.dg/cpp1y/vla-initlist1.C @@ -1,4 +1,5 @@ -// { dg-do run { target c++1y } } +// { dg-do run { target c++11 } } +// { dg-options "-Wno-vla" } #include <initializer_list> diff --git a/gcc/testsuite/g++.dg/cpp1y/vla1.C b/gcc/testsuite/g++.dg/cpp1y/vla1.C deleted file mode 100644 index 5708cf84e2..0000000000 --- a/gcc/testsuite/g++.dg/cpp1y/vla1.C +++ /dev/null @@ -1,40 +0,0 @@ -// { dg-do compile { target c++1y } } - -#include <typeinfo> - -void f(int n) -{ - int a[n]; - int aa[n][n]; // { dg-error "" } - &a; // { dg-error "" } - sizeof a; // { dg-error "" } - typeid(a); // { dg-error "" } - decltype(a) a2; // { dg-error "" } - typedef int at[n]; // { dg-error "" } - int (*p)[n]; // { dg-error "" } - int (&r)[n] = a; // { dg-error "" } - struct A - { - int a[n]; // { dg-error "" } - }; -} - -template <class T> -void g(int n) -{ - int a[n]; - int aa[n][n]; // { dg-error "" } - &a; // { dg-error "" } - sizeof a; // { dg-error "" } - typeid(a); // { dg-error "" } - decltype(a) a2; // { dg-error "" } - typedef int at[n]; // { dg-error "" } - int (*p)[n]; // { dg-error "" } - int (&r)[n] = a; // { dg-error "" } - struct A - { - int a[n]; // { dg-error "" } - }; -} - -template void g<int>(int); diff --git a/gcc/testsuite/g++.dg/cpp1y/vla10.C b/gcc/testsuite/g++.dg/cpp1y/vla10.C index c3f71b5c20..f81ab9bd1c 100644 --- a/gcc/testsuite/g++.dg/cpp1y/vla10.C +++ b/gcc/testsuite/g++.dg/cpp1y/vla10.C @@ -1,5 +1,6 @@ // PR c++/57402 -// { dg-do compile { target c++1y } } +// { dg-do run } +// { dg-options "" } int i = 2; diff --git a/gcc/testsuite/g++.dg/cpp1y/vla11.C b/gcc/testsuite/g++.dg/cpp1y/vla11.C deleted file mode 100644 index c84b0bbb9a..0000000000 --- a/gcc/testsuite/g++.dg/cpp1y/vla11.C +++ /dev/null @@ -1,8 +0,0 @@ -// PR c++/60251 -// { dg-do compile { target c++1y } } - -void foo(int n) -{ - int x[n]; - [&x]() { decltype(x) y; }; // { dg-error "decltype of array of runtime bound" } -} diff --git a/gcc/testsuite/g++.dg/cpp1y/vla12.C b/gcc/testsuite/g++.dg/cpp1y/vla12.C deleted file mode 100644 index d605e72a48..0000000000 --- a/gcc/testsuite/g++.dg/cpp1y/vla12.C +++ /dev/null @@ -1,7 +0,0 @@ -// PR c++/60250 -// { dg-do compile { target c++1y } } - -template<typename> void foo() -{ - typedef int T[ ([](){ return 1; }()) ]; // { dg-error "runtime bound" } -} diff --git a/gcc/testsuite/g++.dg/cpp1y/vla13.C b/gcc/testsuite/g++.dg/cpp1y/vla13.C deleted file mode 100644 index 9b69452d1d..0000000000 --- a/gcc/testsuite/g++.dg/cpp1y/vla13.C +++ /dev/null @@ -1,8 +0,0 @@ -// PR c++/60227 -// { dg-do compile { target c++1y } } - -void foo(int n) -{ - int a[n]; - int (&r)[n] = {}; // { dg-error "" } -} diff --git a/gcc/testsuite/g++.dg/cpp1y/vla2.C b/gcc/testsuite/g++.dg/cpp1y/vla2.C index 6aa5fcfe95..07c300884a 100644 --- a/gcc/testsuite/g++.dg/cpp1y/vla2.C +++ b/gcc/testsuite/g++.dg/cpp1y/vla2.C @@ -1,5 +1,6 @@ // N3639 allows initialization and capture of VLAs -// { dg-do run { target c++1y } } +// { dg-do run { target c++11 } } +// { dg-options "-Wno-vla" } void f(int n) { diff --git a/gcc/testsuite/g++.dg/cpp1y/vla3.C b/gcc/testsuite/g++.dg/cpp1y/vla3.C deleted file mode 100644 index 75470365a7..0000000000 --- a/gcc/testsuite/g++.dg/cpp1y/vla3.C +++ /dev/null @@ -1,29 +0,0 @@ -// Test for throwing bad_array_length on invalid array length -// { dg-do run { target c++1y } } - -#include <new> - -int f(int i) -{ - int ar[i]{1,2,3,4}; - return ar[i-1]; -} - -void g(int i) -{ - int ar[i]; - ar[0] = 42; -} - -int main() -{ - int ok = 0; - f(4); // OK - try { f(3); } // too small - catch (std::bad_array_length) { ++ok; } - try { g(-24); } // negative - catch (std::bad_array_length) { ++ok; } - - if (ok != 2) - __builtin_abort (); -} diff --git a/gcc/testsuite/g++.dg/cpp1y/vla4.C b/gcc/testsuite/g++.dg/cpp1y/vla4.C index 9de1d28fef..74bf66a07d 100644 --- a/gcc/testsuite/g++.dg/cpp1y/vla4.C +++ b/gcc/testsuite/g++.dg/cpp1y/vla4.C @@ -1,5 +1,6 @@ // Test for range-based for with VLAs. -// { dg-do run { target c++1y } } +// { dg-do run { target c++11 } } +// { dg-options "-Wno-vla" } #include <new> diff --git a/gcc/testsuite/g++.dg/cpp1y/vla5.C b/gcc/testsuite/g++.dg/cpp1y/vla5.C index 5f0dfdf302..6bfbece917 100644 --- a/gcc/testsuite/g++.dg/cpp1y/vla5.C +++ b/gcc/testsuite/g++.dg/cpp1y/vla5.C @@ -1,5 +1,6 @@ // PR c++/55149 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++11 } } +// { dg-options "-Wno-vla" } void test(int n) { int r[n]; diff --git a/gcc/testsuite/g++.dg/cpp1y/vla8.C b/gcc/testsuite/g++.dg/cpp1y/vla8.C index 5077ae343f..68cafe585e 100644 --- a/gcc/testsuite/g++.dg/cpp1y/vla8.C +++ b/gcc/testsuite/g++.dg/cpp1y/vla8.C @@ -1,5 +1,6 @@ // PR c++/55149 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++11 } } +// { dg-options "-Wno-vla" } template<unsigned int TA> struct SA diff --git a/gcc/testsuite/g++.dg/cpp1y/vla9.C b/gcc/testsuite/g++.dg/cpp1y/vla9.C index 5f49d11e91..939de30a3c 100644 --- a/gcc/testsuite/g++.dg/cpp1y/vla9.C +++ b/gcc/testsuite/g++.dg/cpp1y/vla9.C @@ -1,5 +1,6 @@ // PR c++/57408 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++11 } } +// { dg-options "-Wno-vla" } template<typename Callable> struct Impl @@ -19,7 +20,7 @@ extern "C" int printf(const char*, ...); int main(){ int y = 2; - float fa[2][y]; // { dg-error "array of array of runtime bound" } + float fa[2][y]; fa[0][0]=0.8; fa[0][1]=1.8; auto fx=[&](){ diff --git a/gcc/testsuite/g++.dg/cpp1z/cplusplus.C b/gcc/testsuite/g++.dg/cpp1z/cplusplus.C new file mode 100644 index 0000000000..e4b84fd646 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/cplusplus.C @@ -0,0 +1,6 @@ +// { dg-do compile } +// { dg-options "-std=c++1z" } + +#if __cplusplus <= 201402L +#error "__cplusplus <= 201402L" +#endif diff --git a/gcc/testsuite/g++.dg/cpp1z/range-for1.C b/gcc/testsuite/g++.dg/cpp1z/range-for1.C new file mode 100644 index 0000000000..7e6d05580c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/range-for1.C @@ -0,0 +1,12 @@ +// { dg-options "-std=c++1z -pedantic-errors" } + +extern "C" int printf (const char *, ...); +#include <initializer_list> + +int main() +{ + for (i : {1,2}) + { + printf ("%d ", i); + } +} diff --git a/gcc/testsuite/g++.dg/cpp1z/typename-tmpl-tmpl-parm-neg.C b/gcc/testsuite/g++.dg/cpp1z/typename-tmpl-tmpl-parm-neg.C new file mode 100644 index 0000000000..29c699d0fd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/typename-tmpl-tmpl-parm-neg.C @@ -0,0 +1,11 @@ +// { dg-do compile } +// { dg-options "" } + +template<template<typename> struct X> // { dg-error "expected .class. or .typename. before" } + struct D {}; + +template<template<typename> X> // { dg-error "expected .class. or .typename. before" } + struct E {}; + +// { dg-error "expected identifier" "expected" { target *-*-* } 4 } +// { dg-error "expected .>." "expected" { target *-*-* } 4 } diff --git a/gcc/testsuite/g++.dg/cpp1z/typename-tmpl-tmpl-parm-ped-neg.C b/gcc/testsuite/g++.dg/cpp1z/typename-tmpl-tmpl-parm-ped-neg.C new file mode 100644 index 0000000000..abd118b633 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/typename-tmpl-tmpl-parm-ped-neg.C @@ -0,0 +1,28 @@ +// { dg-do compile { target c++14_down } } +// { dg-options "-pedantic" } + +template<typename T> + struct A {}; + +#if __cplusplus >= 201103L +template<typename T> + using B = int; +#endif + +template<template<typename> class X> + struct C {}; + +C<A> ca; + +#if __cplusplus >= 201103L +C<B> cb; +#endif + +template<template<typename> typename X> // { dg-warning "ISO C.. forbids typename key in template template parameter" } + struct D {}; + +D<A> da; + +#if __cplusplus >= 201103L +D<B> db; +#endif diff --git a/gcc/testsuite/g++.dg/cpp1z/typename-tmpl-tmpl-parm.C b/gcc/testsuite/g++.dg/cpp1z/typename-tmpl-tmpl-parm.C new file mode 100644 index 0000000000..4c3eae1120 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/typename-tmpl-tmpl-parm.C @@ -0,0 +1,28 @@ +// { dg-do compile } +// { dg-options "" } + +template<typename T> + struct A {}; + +#if __cplusplus >= 201103L +template<typename T> + using B = int; +#endif + +template<template<typename> class X> + struct C {}; + +C<A> ca; + +#if __cplusplus >= 201103L +C<B> cb; +#endif + +template<template<typename> typename X> + struct D {}; + +D<A> da; + +#if __cplusplus >= 201103L +D<B> db; +#endif diff --git a/gcc/testsuite/g++.dg/debug/debug.exp b/gcc/testsuite/g++.dg/debug/debug.exp index 3840f02e6c..fd0ea62117 100644 --- a/gcc/testsuite/g++.dg/debug/debug.exp +++ b/gcc/testsuite/g++.dg/debug/debug.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2014 Free Software Foundation, Inc. +# Copyright (C) 2002-2015 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/gcc/testsuite/g++.dg/debug/dwarf2-2.C b/gcc/testsuite/g++.dg/debug/dwarf2-2.C deleted file mode 100644 index 9e6dbd2169..0000000000 --- a/gcc/testsuite/g++.dg/debug/dwarf2-2.C +++ /dev/null @@ -1,17 +0,0 @@ -// PR debug/27057 -// { dg-do compile } -// { dg-options "-g -feliminate-dwarf2-dups" } - -namespace N -{ -} - -struct A -{ - void foo (); -}; - -void A::foo () -{ - using namespace N; -} diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/auto1.C b/gcc/testsuite/g++.dg/debug/dwarf2/auto1.C index aef29ee5d9..e38334bd23 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/auto1.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/auto1.C @@ -1,5 +1,5 @@ // PR c++/53756 -// { dg-do compile { target c++1y } } +// { dg-do compile { target c++14 } } // { dg-options "-g -dA -fno-debug-types-section" } // We're looking for something like diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C b/gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C index e3bddab0e9..bfa5d9292f 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C @@ -14,4 +14,4 @@ main() K k; } -// { dg-final {scan-assembler-times " DW_AT_\[MIPS_\]*linkage_name" 2 } } +// { dg-final {scan-assembler-times " DW_AT_\[MIPS_\]*linkage_name" 4 } } diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/deallocator.C b/gcc/testsuite/g++.dg/debug/dwarf2/deallocator.C index 405739311a..0fcd08ea6f 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/deallocator.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/deallocator.C @@ -41,6 +41,6 @@ void foo(int i) return; } // { dg-final { scan-assembler "deallocator.C:29" } } -// { dg-final { scan-assembler "deallocator.C:31" } } -// { dg-final { scan-assembler "deallocator.C:38" } } -// { dg-final { scan-assembler "deallocator.C:41" } } +// { dg-final { scan-assembler "deallocator.C:24" } } +// { dg-final { scan-assembler "deallocator.C:34" } } +// { dg-final { scan-assembler "deallocator.C:21" } } diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/deleted-member-function.C b/gcc/testsuite/g++.dg/debug/dwarf2/deleted-member-function.C new file mode 100644 index 0000000000..a81028f6f6 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/deleted-member-function.C @@ -0,0 +1,17 @@ +// { dg-do compile } +// { dg-options "-O -std=c++11 -g -dA -gno-strict-dwarf" } +// { dg-final { scan-assembler-times " DW_AT_GNU_deleted" 2 } } + +struct Foo +{ + Foo () {} + // Make non-copyable + Foo (const Foo&) = delete; + Foo & operator=(const Foo&) = delete; +}; + +void +bar () +{ + Foo foo; +} diff --git a/gcc/testsuite/g++.dg/debug/dwarf2-1.C b/gcc/testsuite/g++.dg/debug/dwarf2/dwarf2-1.C index e90d51030c..d0176bae6f 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2-1.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/dwarf2-1.C @@ -4,7 +4,7 @@ // PR 24824 // Origin: wanderer@rsu.ru -// { dg-options "-feliminate-dwarf2-dups" } +// { dg-options "-gdwarf -feliminate-dwarf2-dups" } namespace N { @@ -20,3 +20,5 @@ namespace N } N::Derived thing; + +/* { dg-bogus "-feliminate-dwarf2-dups is broken for C\\+\\+, ignoring" "broken -feliminate-dwarf2-dups" { xfail *-*-* } 1 } */ diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/dwarf2-2.C b/gcc/testsuite/g++.dg/debug/dwarf2/dwarf2-2.C new file mode 100644 index 0000000000..23175c666a --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/dwarf2-2.C @@ -0,0 +1,19 @@ +// PR debug/27057 +// { dg-do compile } +// { dg-options "-gdwarf -feliminate-dwarf2-dups" } + +namespace N +{ +} + +struct A +{ + void foo (); +}; + +void A::foo () +{ + using namespace N; +} + +/* { dg-bogus "-feliminate-dwarf2-dups is broken for C\\+\\+, ignoring" "broken -feliminate-dwarf2-dups" { xfail *-*-* } 1 } */ diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/dwarf2.exp b/gcc/testsuite/g++.dg/debug/dwarf2/dwarf2.exp index d947a0eaf5..18883fde6c 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/dwarf2.exp +++ b/gcc/testsuite/g++.dg/debug/dwarf2/dwarf2.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2007-2014 Free Software Foundation, Inc. +# Copyright (C) 2007-2015 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -36,7 +36,7 @@ if { ! [string match "*: target system does not support the * debug format*" \ $comp_output] } { remove-build-file "trivial.S" g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C $srcdir/c-c++-common/dwarf2/*.c]] \ - $DEFAULT_CFLAGS + "" $DEFAULT_CFLAGS } # All done. diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/dwarf4-nested.C b/gcc/testsuite/g++.dg/debug/dwarf2/dwarf4-nested.C new file mode 100644 index 0000000000..160694c3c9 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/dwarf4-nested.C @@ -0,0 +1,55 @@ +// { dg-do compile } +// { dg-options "--std=c++11 -dA -gdwarf-4 -fdebug-types-section -fno-merge-debug-strings" } + +// Check that -fdebug-types-sections does not copy a full referenced type +// into a type unit. + +// Checks that at least one type unit is generated. +// +// { dg-final { scan-assembler "DIE \\(\[^\n\]*\\) DW_TAG_type_unit" } } +// +// Check that func is declared exactly once in the debug info (in the +// compile unit). +// +// { dg-final { scan-assembler-times "\\.ascii \"func\\\\0\"\[^\n\]*DW_AT_name" 1 } } +// +// Check to make sure that no type unit contains a DIE with DW_AT_low_pc +// or DW_AT_ranges. These patterns assume that the compile unit is always +// emitted after all type units. +// +// { dg-final { scan-assembler-not "\\.quad\[^\n\]*DW_AT_low_pc.*DIE \\(\[^\n\]*\\) DW_TAG_compile_unit" } } +// { dg-final { scan-assembler-not "\\.quad\[^\n\]*DW_AT_ranges.*DIE \\(\[^\n\]*\\) DW_TAG_compile_unit" } } + +struct A { + A(); + virtual ~A(); + virtual void foo(); + private: + int data; +}; + +struct B { + B(); + virtual ~B(); +}; + +extern B* table[]; + +struct D { + template <typename T> + T* get(int i) + { + B*& cell = table[i]; + if (cell == 0) + cell = new T(); + return static_cast<T*>(cell); + } +}; + +void func(D* d) +{ + struct C : B { + A a; + }; + d->get<C>(0)->a.foo(); +} diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/dwarf4-typedef.C b/gcc/testsuite/g++.dg/debug/dwarf2/dwarf4-typedef.C index c5520fa72b..89a6bb44e1 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/dwarf4-typedef.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/dwarf4-typedef.C @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-gdwarf-4" } */ +/* { dg-options "-gdwarf-4 -fdebug-types-section" } */ /* Regression test for an ICE in output_die when using -gdwarf-4. */ diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp11.C b/gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp11.C new file mode 100644 index 0000000000..8079c0e175 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp11.C @@ -0,0 +1,6 @@ +// { dg-do compile } +// { dg-options "-O -std=c++11 -gdwarf-5 -dA" } +// DW_LANG_C_plus_plus_11 = 0x001a +// { dg-final { scan-assembler "0x1a.*DW_AT_language" } } */ + +int version; diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp14.C b/gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp14.C new file mode 100644 index 0000000000..448ec7c0a3 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp14.C @@ -0,0 +1,6 @@ +// { dg-do compile } +// { dg-options "-O -std=c++14 -gdwarf-5 -dA" } +// DW_LANG_C_plus_plus_14 = 0x0021 +// { dg-final { scan-assembler "0x21.*DW_AT_language" } } */ + +int version; diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp98.C b/gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp98.C new file mode 100644 index 0000000000..065cc18264 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp98.C @@ -0,0 +1,6 @@ +// { dg-do compile } +// { dg-options "-O -std=c++98 -g -dA" } +// DW_LANG_C_plus_plus = 0x0004 +// { dg-final { scan-assembler "0x4.*DW_AT_language" } } */ + +int version; diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/localclass3.C b/gcc/testsuite/g++.dg/debug/dwarf2/localclass3.C index be28a19716..b4baaa1f7e 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/localclass3.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/localclass3.C @@ -4,8 +4,11 @@ void f() { - struct A { int i; } *ap; - ap->i = 42; + int j = 5; + { + struct A { int i; } *ap; + ap->i = 42; + } } // { dg-final { scan-assembler "DW_TAG_pointer_type.\[^)\]*. DW_TAG_structure_type" } } diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/nested-4.C b/gcc/testsuite/g++.dg/debug/dwarf2/nested-4.C index 784c7534f8..188e1ca10e 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/nested-4.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/nested-4.C @@ -1,6 +1,6 @@ // PR debug/53235 // { dg-options "-gdwarf-4 -fdebug-types-section" } -// { dg-final { scan-assembler-times "debug_types" 2 { xfail *-*-darwin* } } } +// { dg-final { scan-assembler-times "debug_types" 2 { xfail { *-*-darwin* || { *-*-solaris2.1[1-9]* && { ! gas } } } } } } namespace E { class O {}; diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/noreturn-function.C b/gcc/testsuite/g++.dg/debug/dwarf2/noreturn-function.C new file mode 100644 index 0000000000..73a0af49ca --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/noreturn-function.C @@ -0,0 +1,16 @@ +// { dg-do compile } +// { dg-options "-O -std=c++11 -g -dA -gno-strict-dwarf" } +// Expect DW_AT_noreturn once in .debug_info and once in .debug_abbrev +// { dg-final { scan-assembler-times "DW_AT_noreturn" 2 } } + +class Foo +{ + int i; + void bar [[noreturn]] (int j); +}; + +void +Foo::bar (int j) +{ + while (1) { ; } +} diff --git a/gcc/testsuite/g++.dg/debug/pr46123.C b/gcc/testsuite/g++.dg/debug/dwarf2/pr46123-2.C index 9e115cd06d..b262034eaf 100644 --- a/gcc/testsuite/g++.dg/debug/pr46123.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/pr46123-2.C @@ -45,3 +45,5 @@ int main () return 1; return 0; } + +/* { dg-bogus "-feliminate-dwarf2-dups is broken for C\\+\\+, ignoring" "broken -feliminate-dwarf2-dups" { xfail *-*-* } 1 } */ diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/redeclaration-1.C b/gcc/testsuite/g++.dg/debug/dwarf2/redeclaration-1.C index 8aaff8ef2e..325647e13f 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/redeclaration-1.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/redeclaration-1.C @@ -9,10 +9,12 @@ namespace S int f() { - int i = 42; { - extern int i; - return i; + int i = 42; + { + extern int i; + return i; + } } } } diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/typedef5.C b/gcc/testsuite/g++.dg/debug/dwarf2/typedef5.C index d9d058c9c8..b742c1dfd4 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/typedef5.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/typedef5.C @@ -8,3 +8,5 @@ typedef struct } A; A a; + +/* { dg-bogus "-feliminate-dwarf2-dups is broken for C\\+\\+, ignoring" "broken -feliminate-dwarf2-dups" { xfail *-*-* } 1 } */ diff --git a/gcc/testsuite/g++.dg/debug/pr65678.C b/gcc/testsuite/g++.dg/debug/pr65678.C new file mode 100644 index 0000000000..d99c73bf1b --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/pr65678.C @@ -0,0 +1,35 @@ +// PR debug/65678 +// { dg-do compile } + +long long v; + +static int +bar (double x) +{ +#if __SIZEOF_DOUBLE__ == __SIZEOF_LONG_LONG__ + __builtin_memmove (&v, &x, sizeof v); +#else + (void) x; + v = 0; +#endif + return v; +} + +struct A +{ + A (double x) : a (bar (x)) {} + int m1 (); + int m2 () { int b = a; return b; } + int a; +}; + +void foo (); + +void +baz (double x) +{ + int c = A (x).m2 (); + int d = A (x).m1 (); + if (d) + foo (); +} diff --git a/gcc/testsuite/g++.dg/dfp/dfp.exp b/gcc/testsuite/g++.dg/dfp/dfp.exp index fceb12605a..4eeb0b6042 100644 --- a/gcc/testsuite/g++.dg/dfp/dfp.exp +++ b/gcc/testsuite/g++.dg/dfp/dfp.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2005-2014 Free Software Foundation, Inc. +# Copyright (C) 2005-2015 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -50,10 +50,10 @@ dg-init # Main loop. Run the tests that are specific to C++. g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[C]] \ - $DEFAULT_CXXFLAGS + "" $DEFAULT_CXXFLAGS # Run tests that are shared with C testing. g++-dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/dfp/*.c]] \ - $DEFAULT_CXXFLAGS + "" $DEFAULT_CXXFLAGS # All done. dg-finish diff --git a/gcc/testsuite/g++.dg/dg.exp b/gcc/testsuite/g++.dg/dg.exp index aeae8f373b..b77c3c5904 100644 --- a/gcc/testsuite/g++.dg/dg.exp +++ b/gcc/testsuite/g++.dg/dg.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2000-2014 Free Software Foundation, Inc. +# Copyright (C) 2000-2015 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,6 +18,7 @@ # Load support procs. load_lib g++-dg.exp +load_lib mpx-dg.exp # If a testcase doesn't have special options, use these. global DEFAULT_CXXFLAGS @@ -57,14 +58,14 @@ set tests [prune $tests $srcdir/$subdir/ubsan/*] set tests [prune $tests $srcdir/$subdir/tsan/*] # Main loop. -g++-dg-runtest $tests $DEFAULT_CXXFLAGS +g++-dg-runtest $tests "" $DEFAULT_CXXFLAGS # C/C++ common tests. g++-dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/*.\[cSi\]]] \ - "" + "" "" g++-dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cpp/*.\[cS\]]] \ - "" + "" "" # All done. diff --git a/gcc/testsuite/g++.dg/diagnostic/pr13981.C b/gcc/testsuite/g++.dg/diagnostic/pr13981.C new file mode 100644 index 0000000000..1b8a028d94 --- /dev/null +++ b/gcc/testsuite/g++.dg/diagnostic/pr13981.C @@ -0,0 +1,12 @@ +// PR c++/13981 + +struct A {}; +struct B; // { dg-message "is incomplete" } + +void func( A *a ); + +int main() +{ + B *b = 0; + func(b); // { dg-error "cannot convert" } +} diff --git a/gcc/testsuite/g++.dg/diagnostic/pr60862.C b/gcc/testsuite/g++.dg/diagnostic/pr60862.C new file mode 100644 index 0000000000..cc5279cde6 --- /dev/null +++ b/gcc/testsuite/g++.dg/diagnostic/pr60862.C @@ -0,0 +1,10 @@ +// PR c++/60862 +// { dg-do compile } + +extern void **bar (int, void *, int); + +void +foo (int x, int y) +{ + int **s = bar (x, &x, y); // { dg-error "17:invalid conversion" } +} diff --git a/gcc/testsuite/g++.dg/diagnostic/pr61004.C b/gcc/testsuite/g++.dg/diagnostic/pr61004.C new file mode 100644 index 0000000000..3bf66bed7a --- /dev/null +++ b/gcc/testsuite/g++.dg/diagnostic/pr61004.C @@ -0,0 +1,11 @@ +// { dg-do compile } +// { dg-options "-O2 -Wall" } + +struct A{ }; +struct B:A{}; +void f(A const&); +int main() +{ + B b; + f(b); // { dg-bogus "strict-aliasing" } +} diff --git a/gcc/testsuite/g++.dg/diagnostic/ref1.C b/gcc/testsuite/g++.dg/diagnostic/ref1.C new file mode 100644 index 0000000000..36368ded01 --- /dev/null +++ b/gcc/testsuite/g++.dg/diagnostic/ref1.C @@ -0,0 +1,7 @@ +// PR c++/20332 + +struct bar {}; +void foo1() { + bar& b = bar(); // { dg-error "rvalue" } +} +void foo(bar& b = bar()) {} // { dg-error "rvalue" } diff --git a/gcc/testsuite/g++.dg/diagnostic/ref2.C b/gcc/testsuite/g++.dg/diagnostic/ref2.C new file mode 100644 index 0000000000..ded35e0d3a --- /dev/null +++ b/gcc/testsuite/g++.dg/diagnostic/ref2.C @@ -0,0 +1,9 @@ +// PR c++/21631 + +int f(int&); +int f(); + +int g(void) +{ + return f(1); // { dg-error "rvalue" } +} diff --git a/gcc/testsuite/g++.dg/eh/goto2.C b/gcc/testsuite/g++.dg/eh/goto2.C index de06d50b6e..e9f1ca515a 100644 --- a/gcc/testsuite/g++.dg/eh/goto2.C +++ b/gcc/testsuite/g++.dg/eh/goto2.C @@ -3,10 +3,11 @@ void f() try { - goto l2; // { dg-error "from here" } + goto l2; // { dg-message "from here" } l1: ; // { dg-error "jump to label 'l1'" } } catch (...) { - l2: ; // { dg-error "jump to label 'l2'|enters catch block" } - goto l1; // { dg-error "from here|enters try block" } + l2: ; // { dg-error "jump to label 'l2'" } + // { dg-message "enters catch block" "" { target *-*-*} 10 } + goto l1; // { dg-message "from here|enters try block" } } diff --git a/gcc/testsuite/g++.dg/eh/scope1.C b/gcc/testsuite/g++.dg/eh/scope1.C index 276e0d6e58..8d553d8295 100644 --- a/gcc/testsuite/g++.dg/eh/scope1.C +++ b/gcc/testsuite/g++.dg/eh/scope1.C @@ -31,7 +31,7 @@ void f3 () void f4 () { - switch (C br = C()) + switch (C br = C()) /* { dg-warning "switch condition has" } */ { default: abort (); diff --git a/gcc/testsuite/g++.dg/eh/spec6.C b/gcc/testsuite/g++.dg/eh/spec6.C index eb1177b07f..d6d8176289 100644 --- a/gcc/testsuite/g++.dg/eh/spec6.C +++ b/gcc/testsuite/g++.dg/eh/spec6.C @@ -3,7 +3,7 @@ // { dg-options "-fpermissive -w" } -struct A; // { dg-error "" } +struct A; // { dg-message "" } struct B { diff --git a/gcc/testsuite/g++.dg/expr/cast1.C b/gcc/testsuite/g++.dg/expr/cast1.C index ee1adcc3d2..2f0e94fc69 100644 --- a/gcc/testsuite/g++.dg/expr/cast1.C +++ b/gcc/testsuite/g++.dg/expr/cast1.C @@ -1,3 +1,3 @@ -struct S; // { dg-error "forward" } +struct S; // { dg-message "forward" } void f(S* p) { ((S) (*p)); } // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/expr/cond10.C b/gcc/testsuite/g++.dg/expr/cond10.C new file mode 100644 index 0000000000..892576fa8b --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/cond10.C @@ -0,0 +1,17 @@ +// PR c++/32019 + +struct C +{ + C(const char *); + operator const char *(); +}; + +extern C c; +extern const char * s; + +void +foo (bool b) +{ + b ? c : s; // { dg-error "?:" } + // { dg-message "convert" "" { target *-*-* } 15 } +} diff --git a/gcc/testsuite/g++.dg/expr/cond11.C b/gcc/testsuite/g++.dg/expr/cond11.C new file mode 100644 index 0000000000..7bd122ddac --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/cond11.C @@ -0,0 +1,20 @@ +struct A; +struct C +{ + operator A(); +}; + +struct A +{ + A(C); +}; + +extern A a; +extern C c; + +void +foo (bool b) +{ + b ? c : a; // { dg-error "?:" } + // { dg-message "ambiguous" "" { target *-*-* } 18 } +} diff --git a/gcc/testsuite/g++.dg/expr/cond13.C b/gcc/testsuite/g++.dg/expr/cond13.C new file mode 100644 index 0000000000..90ae904a5d --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/cond13.C @@ -0,0 +1,9 @@ +// PR c++/54348 + +struct A {} a; +struct B {} b; + +void f() +{ + false ? a : b; // { dg-error "different types" } +} diff --git a/gcc/testsuite/g++.dg/expr/cond14.C b/gcc/testsuite/g++.dg/expr/cond14.C new file mode 100644 index 0000000000..5276287942 --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/cond14.C @@ -0,0 +1,6 @@ +// DR 587 +// PR c++/51317 + +int x = 1; +int const y = 2; +int const *p = &(1 ? x : y); // error: lvalue required as unary '&' operand diff --git a/gcc/testsuite/g++.dg/expr/cond6.C b/gcc/testsuite/g++.dg/expr/cond6.C index 943aa85a96..8f7f084ce5 100644 --- a/gcc/testsuite/g++.dg/expr/cond6.C +++ b/gcc/testsuite/g++.dg/expr/cond6.C @@ -1,10 +1,11 @@ // { dg-do run } extern "C" void abort (); +bool ok = false; struct B { B() {} - B(const B& b) { abort (); } + B(const B& b) { ok = true; } }; struct D : public B { @@ -21,4 +22,5 @@ D f() { int main () { b = (true ? f() : b); + return !ok; } diff --git a/gcc/testsuite/g++.dg/expr/cond8.C b/gcc/testsuite/g++.dg/expr/cond8.C index 3e089537ff..11b090dfc5 100644 --- a/gcc/testsuite/g++.dg/expr/cond8.C +++ b/gcc/testsuite/g++.dg/expr/cond8.C @@ -1,13 +1,12 @@ // PR c++/22434 -// { dg-options "" } struct A { - A(void*); // { dg-message "initializing" } + A(void*); ~A(); }; void foo(const int i, bool b) { - b ? A(0) : i; // { dg-error "conversion" } + b ? A(0) : i; // { dg-error "" } } diff --git a/gcc/testsuite/g++.dg/expr/cond9.C b/gcc/testsuite/g++.dg/expr/cond9.C index e8e1397c06..b344c1f683 100644 --- a/gcc/testsuite/g++.dg/expr/cond9.C +++ b/gcc/testsuite/g++.dg/expr/cond9.C @@ -1,12 +1,10 @@ // PR c++/27666 struct A { // { dg-message "A" } - A(int); // { dg-message "A" } + A(int); }; void foo(volatile A a) { - 1 ? a : 0; // { dg-error "match|temporary" } - // { dg-message "candidate" "candidate note" { target *-*-* } 8 } - 1 ? 0 : a; // { dg-error "match|temporary" } - // { dg-message "candidate" "candidate note" { target *-*-* } 10 } + 1 ? a : 0; // { dg-error "qualifiers|lvalue|no match" } + 1 ? 0 : a; // { dg-error "qualifiers|lvalue|no match" } } diff --git a/gcc/testsuite/g++.dg/expr/dtor1.C b/gcc/testsuite/g++.dg/expr/dtor1.C index 0775a93c91..5570f786a6 100644 --- a/gcc/testsuite/g++.dg/expr/dtor1.C +++ b/gcc/testsuite/g++.dg/expr/dtor1.C @@ -1,4 +1,4 @@ -class Foo; // { dg-error "" } +class Foo; // { dg-message "" } void bar(void* p) diff --git a/gcc/testsuite/g++.dg/expr/pmf-1.C b/gcc/testsuite/g++.dg/expr/pmf-1.C index 3dd01c6b90..90f3431410 100644 --- a/gcc/testsuite/g++.dg/expr/pmf-1.C +++ b/gcc/testsuite/g++.dg/expr/pmf-1.C @@ -15,6 +15,5 @@ struct A void (A::*p)() = &A::f; void (A::*q)() = &(A::f); // { dg-error "parenthesized" "" } foo(&g<int>); // { dg-error "no matching" "" } - // { dg-message "candidate" "candidate note" { target *-*-* } 17 } } }; diff --git a/gcc/testsuite/g++.dg/expr/ptr-arith1.C b/gcc/testsuite/g++.dg/expr/ptr-arith1.C new file mode 100644 index 0000000000..71e97f72b7 --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/ptr-arith1.C @@ -0,0 +1,7 @@ +// PR c++/65054 + +const char * +foo (void) +{ + return ((char *const) "abc" + 1); +} diff --git a/gcc/testsuite/g++.dg/ext/alignof2.C b/gcc/testsuite/g++.dg/ext/alignof2.C index 8bc8a9c01a..912863ea16 100644 --- a/gcc/testsuite/g++.dg/ext/alignof2.C +++ b/gcc/testsuite/g++.dg/ext/alignof2.C @@ -3,6 +3,7 @@ // wrong for some fields. // { dg-do run } +// { dg-xfail-run-if "AIX ABI increases struct alignment for first member double" { powerpc-ibm-aix* } { "*" } { "" } } extern "C" void abort(); diff --git a/gcc/testsuite/g++.dg/ext/atomic-2.C b/gcc/testsuite/g++.dg/ext/atomic-2.C new file mode 100644 index 0000000000..ac363eb16d --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/atomic-2.C @@ -0,0 +1,14 @@ +// PR c++/57926 + +long Mutex[1]; + +int AcquireLogMutex(void) +{ + return __atomic_exchange_n(Mutex, 1, __ATOMIC_SEQ_CST); +} + +void ReleaseLogMutex(void) +{ + long i = 0; + __atomic_store(Mutex, &i, __ATOMIC_SEQ_CST); +} diff --git a/gcc/testsuite/g++.dg/ext/attr-deprecated-1.C b/gcc/testsuite/g++.dg/ext/attr-deprecated-1.C new file mode 100644 index 0000000000..31a76903cb --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/attr-deprecated-1.C @@ -0,0 +1,15 @@ +// PR c++/33911 + +template<typename T> struct __attribute__ ((deprecated)) S {}; +S<int> s; // { dg-warning "deprecated" } + +template <template <class> class T> struct A { }; +A<S> a; // { dg-warning "deprecated" } + +template <class T> void f() __attribute__ ((deprecated)); + +int main() +{ + f<int>(); // { dg-warning "deprecated" } + void (*p)() = f<char>; // { dg-warning "deprecated" } +} diff --git a/gcc/testsuite/g++.dg/ext/attrib42.C b/gcc/testsuite/g++.dg/ext/attrib42.C index d0c7ad7235..307a5d6b51 100644 --- a/gcc/testsuite/g++.dg/ext/attrib42.C +++ b/gcc/testsuite/g++.dg/ext/attrib42.C @@ -1,4 +1,4 @@ -// { dg-do compile { target { i?86-*-* && ilp32 } } } +// { dg-do compile { target { { i?86-*-* x86_64-*-* } && ia32 } } } struct A { __attribute__((fastcall)) diff --git a/gcc/testsuite/g++.dg/ext/attrib49.C b/gcc/testsuite/g++.dg/ext/attrib49.C new file mode 100644 index 0000000000..99c6154f1a --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/attrib49.C @@ -0,0 +1,20 @@ +// PR c++/60765 +// { dg-options "-Wall -Wunused-parameter" } + +struct foo +{ +} x; + +void (foo::*g) (int *) __attribute__ ((nonnull (2))); + +void +fun1 (void (foo::*f) (int *) __attribute__ ((nonnull (2)))) +{ + (x.*f) ((int *) 0); // { dg-warning "null argument" } +} + +void +fun2 (void (foo::*f) () __attribute__ ((nonnull, unused))) // { dg-bogus "unused" } +{ + (x.*g) ((int *) 0); // { dg-warning "null argument" } +} diff --git a/gcc/testsuite/g++.dg/ext/desig7.C b/gcc/testsuite/g++.dg/ext/desig7.C new file mode 100644 index 0000000000..44358eccd7 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/desig7.C @@ -0,0 +1,8 @@ +// PR c++/61046 + +struct A +{ + int ary[4]; +}; +const int i = 0; +A bar = { [i] = 0 }; // { dg-error "designated" } diff --git a/gcc/testsuite/g++.dg/ext/desig8.C b/gcc/testsuite/g++.dg/ext/desig8.C new file mode 100644 index 0000000000..98e7bfdca4 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/desig8.C @@ -0,0 +1,3 @@ +// PR c++/58882 + +int a[] = { [0.] = 0 }; // { dg-error "integral constant-expression" } diff --git a/gcc/testsuite/g++.dg/ext/fnname4.C b/gcc/testsuite/g++.dg/ext/fnname4.C new file mode 100644 index 0000000000..65409875ec --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/fnname4.C @@ -0,0 +1,14 @@ +// PR c++/59004 + +template<int z> class A {}; + +template<int x> +class B { +public: + static const int y = (x != -1 ? 0 : 0); + + template<int z> void g(const A<y> &a) { + const char *x2 = __func__; + } +}; +template void B<0>::g<0>(const A<0> &); diff --git a/gcc/testsuite/g++.dg/ext/is_base_of_diagnostic.C b/gcc/testsuite/g++.dg/ext/is_base_of_diagnostic.C index 4ccc72b9e9..aac6cfba48 100644 --- a/gcc/testsuite/g++.dg/ext/is_base_of_diagnostic.C +++ b/gcc/testsuite/g++.dg/ext/is_base_of_diagnostic.C @@ -1,7 +1,7 @@ class A { }; -class B; // { dg-error "forward declaration" } +class B; // { dg-message "forward declaration" } union C { }; diff --git a/gcc/testsuite/g++.dg/ext/is_class_error2.C b/gcc/testsuite/g++.dg/ext/is_class_error2.C index 8649dc4410..b8c0385d3d 100644 --- a/gcc/testsuite/g++.dg/ext/is_class_error2.C +++ b/gcc/testsuite/g++.dg/ext/is_class_error2.C @@ -13,7 +13,6 @@ template<int> void foo() __is_abstract(int)(); // { dg-error "'__is_abstract\\(int\\)' cannot be used" } __is_base_of(int, float)(); // { dg-error "'__is_base_of\\(int, float\\)' cannot be used" } __is_class(int)(); // { dg-error "'__is_class\\(int\\)' cannot be used" } - __is_convertible_to(int, float)(); // { dg-message "unimplemented" } __is_empty(int)(); // { dg-error "'__is_empty\\(int\\)' cannot be used" } __is_enum(int)(); // { dg-error "'__is_enum\\(int\\)' cannot be used" } __is_pod(int)(); // { dg-error "'__is_pod\\(int\\)' cannot be used" } diff --git a/gcc/testsuite/g++.dg/ext/is_literal_type2.C b/gcc/testsuite/g++.dg/ext/is_literal_type2.C new file mode 100644 index 0000000000..8a0632b125 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/is_literal_type2.C @@ -0,0 +1,26 @@ +// DR 1453 +// { dg-do compile { target c++11 } } + +struct S { + constexpr S() : n{} { } + volatile int n; +}; + +static_assert(!__is_literal_type(S), ""); + +struct Z { + volatile int m; +}; + +struct T { + constexpr T() : n{} { } + Z n; +}; + +static_assert(!__is_literal_type(T), ""); + +struct U : Z { + constexpr U() : Z{} { } +}; + +static_assert(!__is_literal_type(U), ""); diff --git a/gcc/testsuite/g++.dg/ext/is_trivially_constructible1.C b/gcc/testsuite/g++.dg/ext/is_trivially_constructible1.C new file mode 100644 index 0000000000..a5bac7b482 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/is_trivially_constructible1.C @@ -0,0 +1,43 @@ +// { dg-do compile { target c++11 } } + +struct A { }; +struct B { B(); operator int(); }; +struct C { + C() = default; + C(const C&); + C(C&&) = default; + C& operator=(C&&); + C& operator= (const C&) = default; +}; +struct D { ~D() {} }; + +#define SA(X) static_assert((X),#X) + +SA(__is_trivially_constructible(A)); +SA(__is_trivially_constructible(A,A)); +SA(!__is_trivially_constructible(B)); +SA(__is_trivially_constructible(B,B)); + +SA(!__is_trivially_constructible(A,B)); +SA(!__is_trivially_constructible(B,A)); + +SA(__is_trivially_constructible(C)); +SA(__is_trivially_constructible(C,C)); +SA(!__is_trivially_constructible(C,C&)); +SA(__is_trivially_assignable(C,C&)); +SA(!__is_trivially_assignable(C,C)); +SA(!__is_trivially_assignable(C,C&&)); + +SA(__is_trivially_constructible(int,int)); +SA(__is_trivially_constructible(int,double)); +SA(!__is_trivially_constructible(int,B)); + +SA(!__is_trivially_constructible(D)); + +SA(__is_trivially_copyable(int)); +SA(!__is_trivially_copyable(volatile int)); + +struct E1 {const int val;}; +SA(__is_trivially_copyable(E1)); +struct E2 {int& val;}; +SA(__is_trivially_copyable(E2)); diff --git a/gcc/testsuite/g++.dg/ext/is_trivially_constructible2.C b/gcc/testsuite/g++.dg/ext/is_trivially_constructible2.C new file mode 100644 index 0000000000..4e0a657eaf --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/is_trivially_constructible2.C @@ -0,0 +1,15 @@ +// { dg-do compile { target c++11 } } + +struct X { + X() = default; + template<class... U> X(U...); +}; + +struct Y { + template<class... U> Y(U...); +}; + +#define SA(X) static_assert((X),#X) + +SA(__is_trivially_constructible(X)); +SA(!__is_trivially_constructible(Y)); diff --git a/gcc/testsuite/g++.dg/ext/is_trivially_constructible3.C b/gcc/testsuite/g++.dg/ext/is_trivially_constructible3.C new file mode 100644 index 0000000000..02a678a8ab --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/is_trivially_constructible3.C @@ -0,0 +1,8 @@ +// { dg-do compile { target c++11 } } + +template <class T, class... Args> void bar() { + static_assert(__is_trivially_constructible(T, Args...), ""); +} + +template void bar<int>(); +template void bar<int,int>(); diff --git a/gcc/testsuite/g++.dg/ext/is_trivially_constructible4.C b/gcc/testsuite/g++.dg/ext/is_trivially_constructible4.C new file mode 100644 index 0000000000..c6d17586e8 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/is_trivially_constructible4.C @@ -0,0 +1,12 @@ +// { dg-do compile { target c++11 } } + +#define SA(X) static_assert((X),#X) + +void f() +{ + int x; + auto l = [=]{ return x; }; + typedef decltype(l) C; + SA(__is_trivially_copyable(C)); + SA(__is_trivially_constructible(C,C)); +} diff --git a/gcc/testsuite/g++.dg/ext/mv14.C b/gcc/testsuite/g++.dg/ext/mv14.C index e36e08d50c..1e7a161969 100644 --- a/gcc/testsuite/g++.dg/ext/mv14.C +++ b/gcc/testsuite/g++.dg/ext/mv14.C @@ -1,7 +1,7 @@ /* Test case to check if Multiversioning works. */ /* { dg-do run { target i?86-*-* x86_64-*-* } } */ /* { dg-require-ifunc "" } */ -/* { dg-options "-O2 -fPIC" } */ +/* { dg-options "-O2 -fPIC -march=x86-64" } */ #include <assert.h> diff --git a/gcc/testsuite/g++.dg/ext/mv15.C b/gcc/testsuite/g++.dg/ext/mv15.C index 42e39d24c6..c0beadf16e 100644 --- a/gcc/testsuite/g++.dg/ext/mv15.C +++ b/gcc/testsuite/g++.dg/ext/mv15.C @@ -1,7 +1,7 @@ /* Test case to check if Multiversioning works. */ /* { dg-do run { target i?86-*-* x86_64-*-* } } */ /* { dg-require-ifunc "" } */ -/* { dg-options "-O2 -fPIC" } */ +/* { dg-options "-O2 -fPIC -march=x86-64" } */ #include <assert.h> diff --git a/gcc/testsuite/g++.dg/ext/mv17.C b/gcc/testsuite/g++.dg/ext/mv17.C new file mode 100644 index 0000000000..87c13246ed --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/mv17.C @@ -0,0 +1,93 @@ +// Test case to check if Multiversioning works for BMI and BMI2. + +// { dg-do run { target i?86-*-* x86_64-*-* } } +// { dg-require-ifunc "" } +// { dg-options "-O2" } + +#include <assert.h> + +// Check BMI feature selection works +int foo () __attribute__((target("default"))); +int foo () __attribute__((target("bmi"))); +int foo () __attribute__((target("bmi2"))); + +// Check specialized versions for archs with BMI is chosen over generic BMI versions. +int bar () __attribute__((target("default"))); +int bar () __attribute__((target("bmi"))); +int bar () __attribute__((target("bmi2"))); +int bar () __attribute__((target("arch=btver2"))); +int bar () __attribute__((target("arch=haswell"))); + +int main () +{ + int val = foo (); + + if (__builtin_cpu_supports ("bmi2")) + assert (val == 2); + else if (__builtin_cpu_supports ("bmi")) + assert (val == 1); + else + assert (val == 0); + + val = bar (); + + if (__builtin_cpu_is ("btver2")) + assert (val == 5); + else if (__builtin_cpu_is ("haswell")) + assert (val == 6); + else if (__builtin_cpu_supports ("bmi2")) + assert (val == 2); + else if (__builtin_cpu_supports ("bmi")) + assert (val == 1); + else + assert (val == 0); + + return 0; +} + +int __attribute__ ((target("default"))) +foo () +{ + return 0; +} + +int __attribute__ ((target("bmi"))) +foo () +{ + return 1; +} +int __attribute__ ((target("bmi2"))) +foo () +{ + return 2; +} + +int __attribute__ ((target("default"))) +bar () +{ + return 0; +} + +int __attribute__ ((target("bmi"))) +bar () +{ + return 1; +} +int __attribute__ ((target("bmi2"))) +bar () +{ + return 2; +} + +int __attribute__ ((target("arch=btver2"))) +bar () +{ + return 5; +} + +int __attribute__ ((target("arch=haswell"))) +bar () +{ + return 6; +} + diff --git a/gcc/testsuite/g++.dg/ext/mv2.C b/gcc/testsuite/g++.dg/ext/mv2.C index 869e99b4fa..d4f1f92c61 100644 --- a/gcc/testsuite/g++.dg/ext/mv2.C +++ b/gcc/testsuite/g++.dg/ext/mv2.C @@ -20,31 +20,34 @@ int foo () __attribute__ ((target ("sse4.2"))); int foo () __attribute__ ((target ("popcnt"))); int foo () __attribute__ ((target ("avx"))); int foo () __attribute__ ((target ("avx2"))); +int foo () __attribute__ ((target ("avx512f"))); int main () { int val = foo (); - if (__builtin_cpu_supports ("avx2")) - assert (val == 1); + if (__builtin_cpu_supports ("avx512f")) + assert (val == 11); + else if (__builtin_cpu_supports ("avx2")) + assert (val == 10); else if (__builtin_cpu_supports ("avx")) - assert (val == 2); + assert (val == 9); else if (__builtin_cpu_supports ("popcnt")) - assert (val == 3); + assert (val == 8); else if (__builtin_cpu_supports ("sse4.2")) - assert (val == 4); + assert (val == 7); else if (__builtin_cpu_supports ("sse4.1")) - assert (val == 5); - else if (__builtin_cpu_supports ("ssse3")) assert (val == 6); + else if (__builtin_cpu_supports ("ssse3")) + assert (val == 5); else if (__builtin_cpu_supports ("sse3")) - assert (val == 7); + assert (val == 4); else if (__builtin_cpu_supports ("sse2")) - assert (val == 8); + assert (val == 3); else if (__builtin_cpu_supports ("sse")) - assert (val == 9); + assert (val == 2); else if (__builtin_cpu_supports ("mmx")) - assert (val == 10); + assert (val == 1); else assert (val == 0); @@ -60,59 +63,65 @@ foo () int __attribute__ ((target("mmx"))) foo () { - return 10; + return 1; } int __attribute__ ((target("sse"))) foo () { - return 9; + return 2; } int __attribute__ ((target("sse2"))) foo () { - return 8; + return 3; } int __attribute__ ((target("sse3"))) foo () { - return 7; + return 4; } int __attribute__ ((target("ssse3"))) foo () { - return 6; + return 5; } int __attribute__ ((target("sse4.1"))) foo () { - return 5; + return 6; } int __attribute__ ((target("sse4.2"))) foo () { - return 4; + return 7; } int __attribute__ ((target("popcnt"))) foo () { - return 3; + return 8; } int __attribute__ ((target("avx"))) foo () { - return 2; + return 9; } int __attribute__ ((target("avx2"))) foo () { - return 1; + return 10; +} + +int __attribute__ ((target("avx512f"))) +foo () +{ + return 11; } diff --git a/gcc/testsuite/g++.dg/ext/stmtexpr17.C b/gcc/testsuite/g++.dg/ext/stmtexpr17.C new file mode 100644 index 0000000000..c1640e4fd2 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/stmtexpr17.C @@ -0,0 +1,9 @@ +// PR c++/64701 +// { dg-options "" } + +enum { A }; +void +foo () +{ + int x = ({ do {} while (0); A; }); +} diff --git a/gcc/testsuite/g++.dg/ext/unary_trait_incomplete.C b/gcc/testsuite/g++.dg/ext/unary_trait_incomplete.C index ecc5ec224b..b60ce84dcb 100644 --- a/gcc/testsuite/g++.dg/ext/unary_trait_incomplete.C +++ b/gcc/testsuite/g++.dg/ext/unary_trait_incomplete.C @@ -1,6 +1,6 @@ // PR c++/39475 -struct I; // { dg-error "forward declaration" } +struct I; // { dg-message "forward declaration" } struct C { }; bool nas1 = __has_nothrow_assign(I); // { dg-error "incomplete type" } diff --git a/gcc/testsuite/g++.dg/ext/varargs1.C b/gcc/testsuite/g++.dg/ext/varargs1.C new file mode 100644 index 0000000000..b67d788e1b --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/varargs1.C @@ -0,0 +1,34 @@ +// Test that passing an object with non-trivial copy constructor and +// destructor is (conditionally) supported and has sensible semantics. + +#include <stdarg.h> +extern "C" void abort(); + +void *as[5]; +int i; + +struct A { + A() { as[i++] = this; } + A(const A& a) { + if (&a != as[i-1]) + abort(); + as[i++] = this; + } + ~A() { + if (this != as[--i]) + abort(); + } +}; + +void f(int i, ...) { + va_list ap; + va_start (ap, i); + A ar = va_arg (ap, A); +} + +int main() +{ + f(42,A()); + if (i != 0) + abort(); +} diff --git a/gcc/testsuite/g++.dg/ext/vector23.C b/gcc/testsuite/g++.dg/ext/vector23.C index 461d8a9e96..a50b2860e8 100644 --- a/gcc/testsuite/g++.dg/ext/vector23.C +++ b/gcc/testsuite/g++.dg/ext/vector23.C @@ -1,4 +1,4 @@ -/* { dg-do compile { target c++1y } } */ +/* { dg-do compile { target c++14 } } */ /* { dg-options "-Wsign-conversion" } */ // Ignore warning on some powerpc-linux configurations. // { dg-prune-output "non-standard ABI extension" } diff --git a/gcc/testsuite/g++.dg/ext/vector27.C b/gcc/testsuite/g++.dg/ext/vector27.C index 288e13c558..2f29577a4f 100644 --- a/gcc/testsuite/g++.dg/ext/vector27.C +++ b/gcc/testsuite/g++.dg/ext/vector27.C @@ -1,7 +1,13 @@ -// PR c++/58845 +/* { dg-do compile } */ -void foo() +typedef int veci __attribute__ ((vector_size (4 * sizeof (int)))); +typedef float vecf __attribute__ ((vector_size (4 * sizeof (float)))); + +void f (veci *a, veci *b, int c) +{ + *a = !*a || *b < ++c; +} +void g (vecf *a, vecf *b) { - int v __attribute__((vector_size(8))); - v = v || v; // { dg-bogus "" "" { xfail *-*-* } } + *a = (*a < 1 && !(*b > 2)) ? *a + *b : 3; } diff --git a/gcc/testsuite/g++.dg/ext/vector28.C b/gcc/testsuite/g++.dg/ext/vector28.C new file mode 100644 index 0000000000..ea48c96124 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/vector28.C @@ -0,0 +1,10 @@ +/* { dg-do compile } */ + +typedef int veci __attribute__ ((vector_size (4 * sizeof (int)))); +typedef float vecf __attribute__ ((vector_size (4 * sizeof (float)))); + +void f (veci *a, vecf *b, int c) +{ + *a = c || *b; + *a = *a || c; +} diff --git a/gcc/testsuite/g++.dg/ext/vector9.C b/gcc/testsuite/g++.dg/ext/vector9.C index 52b3f17144..b1216c2b37 100644 --- a/gcc/testsuite/g++.dg/ext/vector9.C +++ b/gcc/testsuite/g++.dg/ext/vector9.C @@ -6,5 +6,6 @@ typedef int v4i __attribute__((vector_size(8))); void foo() { v4f v; - !(v4i)v; // { dg-error "v4i|argument" } + !(v4i)v; + !v; } diff --git a/gcc/testsuite/g++.dg/ext/visibility/anon1.C b/gcc/testsuite/g++.dg/ext/visibility/anon1.C index 16647b2281..1f3be3b774 100644 --- a/gcc/testsuite/g++.dg/ext/visibility/anon1.C +++ b/gcc/testsuite/g++.dg/ext/visibility/anon1.C @@ -3,6 +3,7 @@ // { dg-do compile } // { dg-final { scan-assembler-not "globl.*_ZN.*1fEv" } } +// { dg-require-visibility "" } namespace { diff --git a/gcc/testsuite/g++.dg/ext/visibility/anon2.C b/gcc/testsuite/g++.dg/ext/visibility/anon2.C index 1d8e479b9f..4902296312 100644 --- a/gcc/testsuite/g++.dg/ext/visibility/anon2.C +++ b/gcc/testsuite/g++.dg/ext/visibility/anon2.C @@ -2,6 +2,7 @@ // { dg-do compile } // { dg-final { scan-assembler-not "globl.*_Z1fv" } } +// { dg-require-visibility "" } namespace { diff --git a/gcc/testsuite/g++.dg/ext/visibility/arm1.C b/gcc/testsuite/g++.dg/ext/visibility/arm1.C index 2c2e3d0664..d718de5cd2 100644 --- a/gcc/testsuite/g++.dg/ext/visibility/arm1.C +++ b/gcc/testsuite/g++.dg/ext/visibility/arm1.C @@ -1,4 +1,4 @@ -// { dg-do compile { target arm*-*-eabi* arm*-*-symbianelf* } } +// { dg-do compile { target arm_eabi } } // { dg-require-dll "" } // { dg-options "-fvisibility=hidden" } // Most class data should be exported. diff --git a/gcc/testsuite/g++.dg/ext/visibility/arm2.C b/gcc/testsuite/g++.dg/ext/visibility/arm2.C index 7eed18d7f8..a0a36010dc 100644 --- a/gcc/testsuite/g++.dg/ext/visibility/arm2.C +++ b/gcc/testsuite/g++.dg/ext/visibility/arm2.C @@ -1,4 +1,4 @@ -// { dg-do compile { target arm*-*-*eabi* arm*-*-symbianelf* } } +// { dg-do compile { target arm_eabi } } // Class data should be exported. // { dg-final { scan-not-hidden "_ZTV1S" } } // { dg-final { scan-not-hidden "_ZTI1S" } } diff --git a/gcc/testsuite/g++.dg/ext/visibility/arm3.C b/gcc/testsuite/g++.dg/ext/visibility/arm3.C index 9be7082ce1..52a935fc0c 100644 --- a/gcc/testsuite/g++.dg/ext/visibility/arm3.C +++ b/gcc/testsuite/g++.dg/ext/visibility/arm3.C @@ -1,4 +1,4 @@ -// { dg-do compile { target arm*-*-*eabi* } } +// { dg-do compile { target arm_eabi } } // { dg-require-dll "" } // { dg-options "-fvisibility=hidden" } diff --git a/gcc/testsuite/g++.dg/ext/visibility/redecl1.C b/gcc/testsuite/g++.dg/ext/visibility/redecl1.C index b53335ef58..a85e6c38e9 100644 --- a/gcc/testsuite/g++.dg/ext/visibility/redecl1.C +++ b/gcc/testsuite/g++.dg/ext/visibility/redecl1.C @@ -3,5 +3,5 @@ struct __attribute((visibility("hidden"))) B; struct __attribute((visibility("default"))) B; // { dg-error "visibility" } -__attribute ((visibility ("hidden"))) void f(); // { dg-warning "previous" } +__attribute ((visibility ("hidden"))) void f(); // { dg-message "previous" } __attribute ((visibility ("default"))) void f(); // { dg-warning "visibility" } diff --git a/gcc/testsuite/g++.dg/ext/visibility/visibility-7.C b/gcc/testsuite/g++.dg/ext/visibility/visibility-7.C index ae4589397b..0a6e4ba637 100644 --- a/gcc/testsuite/g++.dg/ext/visibility/visibility-7.C +++ b/gcc/testsuite/g++.dg/ext/visibility/visibility-7.C @@ -4,7 +4,7 @@ extern int __attribute__((visibility ("hidden"))) -xyzzy; /* { dg-warning "previous declaration here" "" } */ +xyzzy; /* { dg-message "previous declaration" "" } */ int __attribute__((visibility ("protected"))) diff --git a/gcc/testsuite/g++.dg/ext/vla11.C b/gcc/testsuite/g++.dg/ext/vla11.C index e448be325f..e733f481f3 100644 --- a/gcc/testsuite/g++.dg/ext/vla11.C +++ b/gcc/testsuite/g++.dg/ext/vla11.C @@ -1,6 +1,6 @@ // Test that auto works with VLAs. // { dg-do compile { target c++11 } } -// { dg-options "" { target { ! c++1y } } } +// { dg-options "-Wno-vla" } void bar(int n) { diff --git a/gcc/testsuite/g++.dg/ext/vla14.C b/gcc/testsuite/g++.dg/ext/vla14.C index 278cb63b93..5824ab37d8 100644 --- a/gcc/testsuite/g++.dg/ext/vla14.C +++ b/gcc/testsuite/g++.dg/ext/vla14.C @@ -4,8 +4,8 @@ void f (int n) { - goto label; // { dg-error "from here" } - int a[n]; // { dg-error "crosses initialization" } + goto label; // { dg-message "from here" } + int a[n]; // { dg-message "crosses initialization" } label: // { dg-error "jump to label" } ; } @@ -16,7 +16,7 @@ g (int n) switch (1) { case 1: - int (*a)[n]; // { dg-error "crosses initialization" } + int (*a)[n]; // { dg-message "crosses initialization" } default: // { dg-error "jump to case label" } ; } diff --git a/gcc/testsuite/g++.dg/fstack-protector-strong.C b/gcc/testsuite/g++.dg/fstack-protector-strong.C index a4f0f81631..ae6d2fdb8d 100644 --- a/gcc/testsuite/g++.dg/fstack-protector-strong.C +++ b/gcc/testsuite/g++.dg/fstack-protector-strong.C @@ -3,6 +3,11 @@ /* { dg-do compile { target i?86-*-* x86_64-*-* } } */ /* { dg-options "-O2 -fstack-protector-strong" } */ +/* This test checks the presence of __stack_chk_fail function in assembler. + * Compiler generates _stack_chk_fail_local (wrapper) calls instead for PIC. + */ +/* { dg-require-effective-target nonpic } */ + class A { public: @@ -32,4 +37,52 @@ int foo2 () return global_func (a); } -/* { dg-final { scan-assembler-times "stack_chk_fail" 2 } } */ +/* Frame addressed exposed through return slot. */ + +struct B +{ + /* Discourage passing this struct in registers. */ + int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10; + int method (); + B return_slot(); +}; + +B global_func (); +void noop (); + +int foo3 () +{ + return global_func ().a1; +} + +int foo4 () +{ + try { + noop (); + return 0; + } catch (...) { + return global_func ().a1; + } +} + +int foo5 () +{ + try { + return global_func ().a1; + } catch (...) { + return 0; + } +} + +int foo6 () +{ + B b; + return b.method (); +} + +int foo7 (B *p) +{ + return p->return_slot ().a1; +} + +/* { dg-final { scan-assembler-times "stack_chk_fail" 7 } } */ diff --git a/gcc/testsuite/g++.dg/gcov/gcov-14.C b/gcc/testsuite/g++.dg/gcov/gcov-14.C index 8f8e3882d8..b069d0e188 100644 --- a/gcc/testsuite/g++.dg/gcov/gcov-14.C +++ b/gcc/testsuite/g++.dg/gcov/gcov-14.C @@ -14,3 +14,8 @@ int main () } /* { dg-final { run-gcov gcov-14.C } } */ +/* run-gcov cleanups up after itself, but doesn't find all created gcov files. + We could try to grep for ^Created in the exec log, but since there's only one + testcase where we create these extra gcov files, do a local cleanup for + now. */ +/* { dg-final { remote_file target delete iostream.gcov ostream.gcov locale_facets.h.gcov } } */ diff --git a/gcc/testsuite/g++.dg/gcov/gcov-15.C b/gcc/testsuite/g++.dg/gcov/gcov-15.C new file mode 100644 index 0000000000..fcd16b00b1 --- /dev/null +++ b/gcc/testsuite/g++.dg/gcov/gcov-15.C @@ -0,0 +1,26 @@ +// PR gcov-profile/64634 +// { dg-options "-fprofile-arcs -ftest-coverage" } +// { dg-do run { target native } } + +void catchEx () // count(1) +{ + __builtin_exit (0); // count(1) + try + {} + catch (int) + {} +} + +int main () // count(1) +{ + try + { + throw 5; // count(1) + } + catch (...) // count(1) + { + catchEx (); // count(1) + } +} + +// { dg-final { run-gcov gcov-15.C } } diff --git a/gcc/testsuite/g++.dg/gcov/gcov-2.C b/gcc/testsuite/g++.dg/gcov/gcov-2.C index 66d8af39bc..6d002f5d2c 100644 --- a/gcc/testsuite/g++.dg/gcov/gcov-2.C +++ b/gcc/testsuite/g++.dg/gcov/gcov-2.C @@ -20,7 +20,7 @@ private: void foo() { - C c; /* count(1) */ + C c; /* count(2) */ c.seti (1); /* count(1) */ } diff --git a/gcc/testsuite/g++.dg/gcov/gcov.exp b/gcc/testsuite/g++.dg/gcov/gcov.exp index 892baa8274..447ed75b80 100644 --- a/gcc/testsuite/g++.dg/gcov/gcov.exp +++ b/gcc/testsuite/g++.dg/gcov/gcov.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1997-2014 Free Software Foundation, Inc. +# Copyright (C) 1997-2015 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -39,6 +39,6 @@ if { $files != "" } { } # Main loop. -g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] "" +g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] "" "" dg-finish diff --git a/gcc/testsuite/g++.dg/goacc-gomp/goacc-gomp.exp b/gcc/testsuite/g++.dg/goacc-gomp/goacc-gomp.exp new file mode 100644 index 0000000000..7e74d2ba06 --- /dev/null +++ b/gcc/testsuite/g++.dg/goacc-gomp/goacc-gomp.exp @@ -0,0 +1,36 @@ +# Copyright (C) 2006-2015 Free Software Foundation, Inc. +# +# This file is part of GCC. +# +# GCC is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GCC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. + +# Load support procs. +load_lib g++-dg.exp + +if { ![check_effective_target_fopenacc] \ + || ![check_effective_target_fopenmp] } { + return +} + +# Initialize `dg'. +dg-init + +# Main loop. +g++-dg-runtest [lsort [concat \ + [find $srcdir/$subdir *.C] \ + [find $srcdir/c-c++-common/goacc-gomp *.c]]] "" "-fopenacc -fopenmp" + +# All done. +dg-finish diff --git a/gcc/testsuite/g++.dg/goacc/goacc.exp b/gcc/testsuite/g++.dg/goacc/goacc.exp new file mode 100644 index 0000000000..0e96dfaafa --- /dev/null +++ b/gcc/testsuite/g++.dg/goacc/goacc.exp @@ -0,0 +1,35 @@ +# Copyright (C) 2006-2015 Free Software Foundation, Inc. +# +# This file is part of GCC. +# +# GCC is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GCC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. + +# Load support procs. +load_lib g++-dg.exp + +if ![check_effective_target_fopenacc] { + return +} + +# Initialize `dg'. +dg-init + +# Main loop. +g++-dg-runtest [lsort [concat \ + [find $srcdir/$subdir *.C] \ + [find $srcdir/c-c++-common/goacc *.c]]] "" "-fopenacc" + +# All done. +dg-finish diff --git a/gcc/testsuite/g++.dg/gomp/block-1.C b/gcc/testsuite/g++.dg/gomp/block-1.C index d2b86645af..b0704ac7fa 100644 --- a/gcc/testsuite/g++.dg/gomp/block-1.C +++ b/gcc/testsuite/g++.dg/gomp/block-1.C @@ -4,12 +4,13 @@ void foo() { bad1: // { dg-error "jump to label" } #pragma omp parallel - goto bad1; // { dg-error "from here|exits OpenMP" } + goto bad1; // { dg-message "from here|exits OpenMP" } - goto bad2; // { dg-error "from here" } + goto bad2; // { dg-message "from here" } #pragma omp parallel { - bad2: ; // { dg-error "jump to label|enters OpenMP" } + bad2: ; // { dg-error "jump to label" } + // { dg-message "enters OpenMP" "" { target *-*-* } 12 } } #pragma omp parallel @@ -21,5 +22,5 @@ void foo() } } -// { dg-message "error: invalid branch to/from an OpenMP structured block" "" { target *-*-* } 7 } +// { dg-message "error: invalid branch to/from OpenMP structured block" "" { target *-*-* } 7 } // { dg-message "error: invalid entry to OpenMP structured block" "" { target *-*-* } 9 } diff --git a/gcc/testsuite/g++.dg/gomp/block-2.C b/gcc/testsuite/g++.dg/gomp/block-2.C index 17d98d845a..5336c5a30a 100644 --- a/gcc/testsuite/g++.dg/gomp/block-2.C +++ b/gcc/testsuite/g++.dg/gomp/block-2.C @@ -11,13 +11,14 @@ void foo() bad1: // { dg-error "jump to label" } #pragma omp for for (i = 0; i < 10; ++i) - goto bad1; // { dg-error "from here|exits OpenMP" } + goto bad1; // { dg-message "from here|exits OpenMP" } - goto bad2; // { dg-error "from here" } + goto bad2; // { dg-message "from here" } #pragma omp for for (i = 0; i < 10; ++i) { - bad2: ; // { dg-error "jump|enters OpenMP" } + bad2: ; // { dg-error "jump" } + // { dg-message "enters OpenMP" "" { target *-*-* } 20 } } #pragma omp for @@ -31,5 +32,5 @@ void foo() continue; } -// { dg-message "error: invalid branch to/from an OpenMP structured block" "" { target *-*-* } 14 } +// { dg-message "error: invalid branch to/from OpenMP structured block" "" { target *-*-* } 14 } // { dg-message "error: invalid entry to OpenMP structured block" "" { target *-*-* } 16 } diff --git a/gcc/testsuite/g++.dg/gomp/block-3.C b/gcc/testsuite/g++.dg/gomp/block-3.C index ff28175284..23f97268ed 100644 --- a/gcc/testsuite/g++.dg/gomp/block-3.C +++ b/gcc/testsuite/g++.dg/gomp/block-3.C @@ -18,19 +18,21 @@ void foo() #pragma omp section { bad1: ; } // { dg-error "jump to label" } #pragma omp section - goto bad1; // { dg-error "from here|enters OpenMP" } + goto bad1; // { dg-message "from here|enters OpenMP" } } #pragma omp sections { - goto bad2; // { dg-error "from here" } + goto bad2; // { dg-message "from here" } } - bad2:; // { dg-error "jump|exits OpenMP" } + bad2:; // { dg-error "jump" } + // { dg-message "exits OpenMP" "" { target *-*-* } 28 } - goto bad3; // { dg-error "from here" } + goto bad3; // { dg-message "from here" } #pragma omp sections { - bad3: ; // { dg-error "jump|enters OpenMP" } + bad3: ; // { dg-error "jump" } + // { dg-message "enters OpenMP" "" { target *-*-* } 34 } } #pragma omp sections @@ -58,6 +60,6 @@ void foo() } } -// { dg-message "error: invalid branch to/from an OpenMP structured block" "" { target *-*-* } 21 } -// { dg-message "error: invalid branch to/from an OpenMP structured block" "" { target *-*-* } 26 } -// { dg-message "error: invalid entry to OpenMP structured block" "" { target *-*-* } 30 } +// { dg-message "error: invalid branch to/from OpenMP structured block" "" { target *-*-* } 21 } +// { dg-message "error: invalid branch to/from OpenMP structured block" "" { target *-*-* } 26 } +// { dg-message "error: invalid entry to OpenMP structured block" "" { target *-*-* } 31 } diff --git a/gcc/testsuite/g++.dg/gomp/block-5.C b/gcc/testsuite/g++.dg/gomp/block-5.C index 391f8b660a..d6d28c4b4c 100644 --- a/gcc/testsuite/g++.dg/gomp/block-5.C +++ b/gcc/testsuite/g++.dg/gomp/block-5.C @@ -4,14 +4,15 @@ void foo() { #pragma omp master { - goto bad1; // { dg-error "from here" } + goto bad1; // { dg-message "from here" } } #pragma omp master { - bad1: // { dg-error "jump|exits OpenMP" } + bad1: // { dg-error "jump" } + // { dg-message "exits OpenMP" "" { target *-*-* } 12 } return; // { dg-error "invalid exit" } } } -// { dg-message "error: invalid branch to/from an OpenMP structured block" "" { target *-*-* } 7 } +// { dg-message "error: invalid branch to/from OpenMP structured block" "" { target *-*-* } 7 } diff --git a/gcc/testsuite/g++.dg/gomp/gomp.exp b/gcc/testsuite/g++.dg/gomp/gomp.exp index bcb9ae3859..9a7f88150c 100644 --- a/gcc/testsuite/g++.dg/gomp/gomp.exp +++ b/gcc/testsuite/g++.dg/gomp/gomp.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2006-2014 Free Software Foundation, Inc. +# Copyright (C) 2006-2015 Free Software Foundation, Inc. # # This file is part of GCC. # @@ -29,7 +29,7 @@ dg-init # Main loop. g++-dg-runtest [lsort [concat \ [find $srcdir/$subdir *.C] \ - [find $srcdir/c-c++-common/gomp *.c]]] "-fopenmp" + [find $srcdir/c-c++-common/gomp *.c]]] "" "-fopenmp" # All done. dg-finish diff --git a/gcc/testsuite/g++.dg/gomp/openmp-simd-3.C b/gcc/testsuite/g++.dg/gomp/openmp-simd-3.C new file mode 100644 index 0000000000..eba9de27d9 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/openmp-simd-3.C @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-fopenmp-simd -fdump-tree-original" } */ + +/* PR c/65586 */ + +void foo() { } + +int main() { +#pragma omp for collapse(1) + for (int i = 1; i <= 151; i+=31) + foo(); +} + +/* { dg-final { scan-tree-dump-not "omp" "original" } } */ +/* { dg-final { cleanup-tree-dump "original" } } */ diff --git a/gcc/testsuite/g++.dg/gomp/pr26690-1.C b/gcc/testsuite/g++.dg/gomp/pr26690-1.C index 17e01b3d55..403ff52e83 100644 --- a/gcc/testsuite/g++.dg/gomp/pr26690-1.C +++ b/gcc/testsuite/g++.dg/gomp/pr26690-1.C @@ -11,6 +11,5 @@ foo () { A a(0); #pragma omp parallel private (a) // { dg-error "no matching function" } - // { dg-message "candidate" "candidate note" { target *-*-* } 13 } ; } diff --git a/gcc/testsuite/g++.dg/gomp/pr26690-2.C b/gcc/testsuite/g++.dg/gomp/pr26690-2.C index ca01a3a595..ec93cd11a2 100644 --- a/gcc/testsuite/g++.dg/gomp/pr26690-2.C +++ b/gcc/testsuite/g++.dg/gomp/pr26690-2.C @@ -12,6 +12,5 @@ foo () { A a(6); #pragma omp parallel private (a) // { dg-error "call of overloaded" } - // { dg-message "candidate" "candidate note" { target *-*-* } 14 } ; } diff --git a/gcc/testsuite/g++.dg/gomp/pr49223-2.C b/gcc/testsuite/g++.dg/gomp/pr49223-2.C index 95397733eb..b367b0419b 100644 --- a/gcc/testsuite/g++.dg/gomp/pr49223-2.C +++ b/gcc/testsuite/g++.dg/gomp/pr49223-2.C @@ -3,7 +3,7 @@ // { dg-require-effective-target tls } // { dg-options "-fopenmp" } -struct S; // { dg-error "forward declaration" } +struct S; // { dg-message "forward declaration" } extern __thread struct S s; // { dg-error "has incomplete type" } struct T; extern __thread struct T t; diff --git a/gcc/testsuite/g++.dg/gomp/pr59628.C b/gcc/testsuite/g++.dg/gomp/pr59628.C new file mode 100644 index 0000000000..518200b9c2 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr59628.C @@ -0,0 +1,13 @@ +// PR c++/59628 +// { dg-do compile } +// { dg-options "-fopenmp" } + +struct A { int i; }; + +void foo() +{ + A a; + #pragma omp declare reduction (+: A: omp_out.i +: omp_in.i) // { dg-error "expected" } + #pragma omp parallel reduction (+: a) + ; +} diff --git a/gcc/testsuite/g++.dg/gomp/target-1.C b/gcc/testsuite/g++.dg/gomp/target-1.C index b6ed4f89cd..bcdac61ee3 100644 --- a/gcc/testsuite/g++.dg/gomp/target-1.C +++ b/gcc/testsuite/g++.dg/gomp/target-1.C @@ -5,12 +5,13 @@ foo (int x) { bad1: // { dg-error "jump to label" } #pragma omp target - goto bad1; // { dg-error "from here|exits OpenMP" } + goto bad1; // { dg-message "from here|exits OpenMP" } - goto bad2; // { dg-error "from here" } + goto bad2; // { dg-message "from here" } #pragma omp target { - bad2: ; // { dg-error "jump to label|enters OpenMP" } + bad2: ; // { dg-error "jump to label" } + // { dg-message "enters OpenMP" "" { target *-*-* } 13 } } #pragma omp target @@ -24,9 +25,10 @@ foo (int x) switch (x) { #pragma omp target - { case 0:; } // { dg-error "jump|enters" } + { case 0:; } // { dg-error "jump" } + // { dg-message "enters" "" { target *-*-* } 28 } } } -// { dg-error "invalid branch to/from an OpenMP structured block" "" { target *-*-* } 8 } +// { dg-error "invalid branch to/from OpenMP structured block" "" { target *-*-* } 8 } // { dg-error "invalid entry to OpenMP structured block" "" { target *-*-* } 10 } diff --git a/gcc/testsuite/g++.dg/gomp/target-2.C b/gcc/testsuite/g++.dg/gomp/target-2.C index 6a14f53cff..273f8d50fe 100644 --- a/gcc/testsuite/g++.dg/gomp/target-2.C +++ b/gcc/testsuite/g++.dg/gomp/target-2.C @@ -5,12 +5,13 @@ foo (int x, int y) { bad1: // { dg-error "jump to label" } #pragma omp target data map(tofrom: y) - goto bad1; // { dg-error "from here|exits OpenMP" } + goto bad1; // { dg-message "from here|exits OpenMP" } - goto bad2; // { dg-error "from here" } + goto bad2; // { dg-message "from here" } #pragma omp target data map(tofrom: y) { - bad2: ; // { dg-error "jump to label|enters OpenMP" } + bad2: ; // { dg-error "jump to label" } + // { dg-message "enters OpenMP" "" { target *-*-* } 13 } } #pragma omp target data map(tofrom: y) @@ -24,9 +25,10 @@ foo (int x, int y) switch (x) { #pragma omp target data map(tofrom: y) - { case 0:; } // { dg-error "jump|enters" } + { case 0:; } // { dg-error "jump" } + // { dg-message "enters" "" { target *-*-* } 28 } } } -// { dg-error "invalid branch to/from an OpenMP structured block" "" { target *-*-* } 8 } +// { dg-error "invalid branch to/from OpenMP structured block" "" { target *-*-* } 8 } // { dg-error "invalid entry to OpenMP structured block" "" { target *-*-* } 10 } diff --git a/gcc/testsuite/g++.dg/gomp/taskgroup-1.C b/gcc/testsuite/g++.dg/gomp/taskgroup-1.C index dcab0bb646..e15d59d947 100644 --- a/gcc/testsuite/g++.dg/gomp/taskgroup-1.C +++ b/gcc/testsuite/g++.dg/gomp/taskgroup-1.C @@ -5,12 +5,13 @@ foo (int x) { bad1: // { dg-error "jump to label" } #pragma omp taskgroup - goto bad1; // { dg-error "from here|exits OpenMP" } + goto bad1; // { dg-message "from here|exits OpenMP" } - goto bad2; // { dg-error "from here" } + goto bad2; // { dg-message "from here" } #pragma omp taskgroup { - bad2: ; // { dg-error "jump to label|enters OpenMP" } + bad2: ; // { dg-error "jump to label" } + // { dg-message "enters OpenMP" "" { target *-*-* } 13 } } #pragma omp taskgroup @@ -24,9 +25,10 @@ foo (int x) switch (x) { #pragma omp taskgroup - { case 0:; } // { dg-error "jump|enters" } + { case 0:; } // { dg-error "jump" } + // { dg-message "enters" "" { target *-*-* } 28 } } } -// { dg-error "invalid branch to/from an OpenMP structured block" "" { target *-*-* } 8 } +// { dg-error "invalid branch to/from OpenMP structured block" "" { target *-*-* } 8 } // { dg-error "invalid entry to OpenMP structured block" "" { target *-*-* } 10 } diff --git a/gcc/testsuite/g++.dg/gomp/teams-1.C b/gcc/testsuite/g++.dg/gomp/teams-1.C index ce40b55ca1..2b00bb6147 100644 --- a/gcc/testsuite/g++.dg/gomp/teams-1.C +++ b/gcc/testsuite/g++.dg/gomp/teams-1.C @@ -5,12 +5,13 @@ foo (int x) { bad1: // { dg-error "jump to label" } #pragma omp target teams - goto bad1; // { dg-error "from here|exits OpenMP" } + goto bad1; // { dg-message "from here|exits OpenMP" } - goto bad2; // { dg-error "from here" } + goto bad2; // { dg-message "from here" } #pragma omp target teams { - bad2: ; // { dg-error "jump to label|enters OpenMP" } + bad2: ; // { dg-error "jump to label" } + // { dg-message "enters OpenMP" "" { target *-*-* } 13 } } #pragma omp target teams @@ -24,7 +25,8 @@ foo (int x) switch (x) { #pragma omp target teams - { case 0:; } // { dg-error "jump|enters" } + { case 0:; } // { dg-error "jump" } + // { dg-message "enters" "" { target *-*-* } 28 } } } @@ -34,13 +36,14 @@ bar (int x) bad1: // { dg-error "jump to label" } #pragma omp target #pragma omp teams - goto bad1; // { dg-error "from here|exits OpenMP" } + goto bad1; // { dg-message "from here|exits OpenMP" } - goto bad2; // { dg-error "from here" } + goto bad2; // { dg-message "from here" } #pragma omp target #pragma omp teams { - bad2: ; // { dg-error "jump to label|enters OpenMP" } + bad2: ; // { dg-error "jump to label" } + // { dg-message "enters OpenMP" "" { target *-*-* } 45 } } #pragma omp target @@ -56,11 +59,12 @@ bar (int x) { #pragma omp target #pragma omp teams - { case 0:; } // { dg-error "jump|enters" } + { case 0:; } // { dg-error "jump" } + // { dg-message "enters" "" { target *-*-* } 62 } } } -// { dg-error "invalid branch to/from an OpenMP structured block" "" { target *-*-* } 8 } +// { dg-error "invalid branch to/from OpenMP structured block" "" { target *-*-* } 8 } // { dg-error "invalid entry to OpenMP structured block" "" { target *-*-* } 10 } -// { dg-error "invalid branch to/from an OpenMP structured block" "" { target *-*-* } 37 } -// { dg-error "invalid entry to OpenMP structured block" "" { target *-*-* } 39 } +// { dg-error "invalid branch to/from OpenMP structured block" "" { target *-*-* } 39 } +// { dg-error "invalid entry to OpenMP structured block" "" { target *-*-* } 41 } diff --git a/gcc/testsuite/g++.dg/gomp/tls-5.C b/gcc/testsuite/g++.dg/gomp/tls-5.C index 3679593af0..e83ff1179e 100644 --- a/gcc/testsuite/g++.dg/gomp/tls-5.C +++ b/gcc/testsuite/g++.dg/gomp/tls-5.C @@ -1,6 +1,6 @@ // The reference temp should be TLS, not normal data. // { dg-require-effective-target c++11 } -// { dg-final { scan-assembler-not "\\.data" { target tls_native } } } +// { dg-final { scan-assembler-not "\\.data" { target tls_native xfail powerpc-*-aix* } } } extern int&& ir; #pragma omp threadprivate (ir) diff --git a/gcc/testsuite/g++.dg/gomp/udr-4.C b/gcc/testsuite/g++.dg/gomp/udr-4.C index f1b388bbd9..566d7d1321 100644 --- a/gcc/testsuite/g++.dg/gomp/udr-4.C +++ b/gcc/testsuite/g++.dg/gomp/udr-4.C @@ -1,6 +1,6 @@ // { dg-do compile } -struct S; // { dg-error "forward declaration" } +struct S; // { dg-message "forward declaration" } #pragma omp declare reduction (+:S:omp_out.s += omp_in.s) // { dg-error "invalid use of incomplete type" } struct S { int s; S () : s (1) {} }; #pragma omp declare reduction (*:S:omp_out.s *= omp_in.s) diff --git a/gcc/testsuite/g++.dg/graphite/graphite.exp b/gcc/testsuite/g++.dg/graphite/graphite.exp index 7079634e70..594d065af8 100644 --- a/gcc/testsuite/g++.dg/graphite/graphite.exp +++ b/gcc/testsuite/g++.dg/graphite/graphite.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2009-2014 Free Software Foundation, Inc. +# Copyright (C) 2009-2015 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -46,14 +46,14 @@ set block_files [lsort [glob -nocomplain $srcdir/$subdir/block-*.C ] ] # Tests to be compiled. set dg-do-what-default compile -g++-dg-runtest $scop_files "-O2 -fgraphite -fdump-tree-graphite-all" -g++-dg-runtest $id_files "-O2 -fgraphite-identity -ffast-math" +g++-dg-runtest $scop_files "" "-O2 -fgraphite -fdump-tree-graphite-all" +g++-dg-runtest $id_files "" "-O2 -fgraphite-identity -ffast-math" # Tests to be run. set dg-do-what-default run -g++-dg-runtest $run_id_files "-O2 -fgraphite-identity" -g++-dg-runtest $interchange_files "-O2 -floop-interchange -fno-loop-block -fno-loop-strip-mine -ffast-math -fdump-tree-graphite-all" -g++-dg-runtest $block_files "-O2 -floop-block -fno-loop-strip-mine -fno-loop-interchange -ffast-math -fdump-tree-graphite-all" +g++-dg-runtest $run_id_files "" "-O2 -fgraphite-identity" +g++-dg-runtest $interchange_files "" "-O2 -floop-interchange -fno-loop-block -fno-loop-strip-mine -ffast-math -fdump-tree-graphite-all" +g++-dg-runtest $block_files "" "-O2 -floop-block -fno-loop-strip-mine -fno-loop-interchange -ffast-math -fdump-tree-graphite-all" # The default action for the rest of the files is 'compile'. set dg-do-what-default compile @@ -62,7 +62,7 @@ foreach f $id_files {lremove wait_to_run_files $f} foreach f $run_id_files {lremove wait_to_run_files $f} foreach f $interchange_files {lremove wait_to_run_files $f} foreach f $block_files {lremove wait_to_run_files $f} -g++-dg-runtest $wait_to_run_files " -pedantic-errors" +g++-dg-runtest $wait_to_run_files "" "-pedantic-errors" # Clean up. set dg-do-what-default ${save-dg-do-what-default} diff --git a/gcc/testsuite/g++.dg/guality/guality.exp b/gcc/testsuite/g++.dg/guality/guality.exp index 3ff7f2f77e..5bffd9df1a 100644 --- a/gcc/testsuite/g++.dg/guality/guality.exp +++ b/gcc/testsuite/g++.dg/guality/guality.exp @@ -5,7 +5,7 @@ load_lib gcc-gdb-test.exp # Disable on darwin until radr://7264615 is resolved. if { [istarget *-*-darwin*] } { - return + return } if { [istarget "powerpc-ibm-aix*"] } { @@ -14,6 +14,11 @@ if { [istarget "powerpc-ibm-aix*"] } { } proc check_guality {args} { + # Don't count check_guality as PASS, or FAIL etc., that would make + # the total PASS count dependent on how many parallel runtest invocations + # ran guality.exp. So save the counts first and restore them afterwards. + global test_counts + array set saved_test_counts [array get test_counts] set result [eval check_compile guality_check executable $args "-g -O0"] set lines [lindex $result 0] set output [lindex $result 1] @@ -23,6 +28,7 @@ proc check_guality {args} { set ret [string match "*1 PASS, 0 FAIL, 0 UNRESOLVED*" $execout] } remote_file build delete $output + array set test_counts [array get saved_test_counts] return $ret } @@ -47,8 +53,8 @@ if {[check_guality " return 0; } "]} { - gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.C]] "" - gcc-dg-runtest [lsort [glob $srcdir/c-c++-common/guality/*.c]] "" + gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.C]] "" "" + gcc-dg-runtest [lsort [glob $srcdir/c-c++-common/guality/*.c]] "" "" } if [info exists guality_gdb_name] { diff --git a/gcc/testsuite/g++.dg/guality/pr55541.C b/gcc/testsuite/g++.dg/guality/pr55541.C new file mode 100644 index 0000000000..c8ec19365d --- /dev/null +++ b/gcc/testsuite/g++.dg/guality/pr55541.C @@ -0,0 +1,11 @@ +// PR debug/55541 +// { dg-do run } +// { dg-options "-g" } + +int +main () +{ + int vari; + vari = 10; + vari = vari + 5; +} // { dg-final { gdb-test 11 "vari" "15" } } diff --git a/gcc/testsuite/g++.dg/inherit/using8.C b/gcc/testsuite/g++.dg/inherit/using8.C new file mode 100644 index 0000000000..b7677c8f68 --- /dev/null +++ b/gcc/testsuite/g++.dg/inherit/using8.C @@ -0,0 +1,15 @@ +// PR c++/65061 + +struct B +{ + template<typename T> + struct S {}; +}; + +struct D : B +{ + using B::S; + + template<typename T> + void doIt(/*struct*/ S<T>&); +}; diff --git a/gcc/testsuite/g++.dg/init/aggr11.C b/gcc/testsuite/g++.dg/init/aggr11.C new file mode 100644 index 0000000000..0da3f410a5 --- /dev/null +++ b/gcc/testsuite/g++.dg/init/aggr11.C @@ -0,0 +1,13 @@ +// PR c++/49132 + +struct A { + const int m; +}; + +A a1 = {}; + +struct B { + A a; +}; + +B b1 = {}; diff --git a/gcc/testsuite/g++.dg/init/aggr12.C b/gcc/testsuite/g++.dg/init/aggr12.C new file mode 100644 index 0000000000..0c4bd3a205 --- /dev/null +++ b/gcc/testsuite/g++.dg/init/aggr12.C @@ -0,0 +1,13 @@ +// PR c++/49132 + +struct A { + int& m; +}; + +A a1 = {}; // { dg-error "uninitialized reference" } + +struct B { + A a; +}; + +B b1 = {}; // { dg-error "uninitialized reference" } diff --git a/gcc/testsuite/g++.dg/init/aggr4.C b/gcc/testsuite/g++.dg/init/aggr4.C index 7120e68cd7..b0eae2ef3d 100644 --- a/gcc/testsuite/g++.dg/init/aggr4.C +++ b/gcc/testsuite/g++.dg/init/aggr4.C @@ -4,4 +4,4 @@ struct A }; A a1 = { 1 }; // ok -A a2 = { a1 }; // { dg-error "cannot convert" } +A a2 = { a1 }; // { dg-error "cannot convert" "" { target { ! c++11 } } } diff --git a/gcc/testsuite/g++.dg/init/array38.C b/gcc/testsuite/g++.dg/init/array38.C new file mode 100644 index 0000000000..bf097742d9 --- /dev/null +++ b/gcc/testsuite/g++.dg/init/array38.C @@ -0,0 +1,8 @@ +// PR c++/64314 +// { dg-do compile { target c++11 } } + +struct C { C(); ~C(); }; +struct A { + int i; + C c[1]; +} a {}; diff --git a/gcc/testsuite/g++.dg/init/array39.C b/gcc/testsuite/g++.dg/init/array39.C new file mode 100644 index 0000000000..2fd8937716 --- /dev/null +++ b/gcc/testsuite/g++.dg/init/array39.C @@ -0,0 +1,46 @@ +// PR c++/65154 +// { dg-do run { target c++11 } } + +int cnt1 = 0, + cnt2 = 0; + +struct S_empty +{ + S_empty () { + cnt1++; + }; +}; + +struct C1 +{ + S_empty s; +}; + +struct S_init +{ + S_init () : i(42) + { + cnt2++; + }; + int i; +}; + +struct C2 +{ + S_init a, b; +}; + +int +main () +{ + C1 c1[5]{}; + C2 c2[1]{}; + + if (c2[0].a.i != 42 || c2[0].b.i != 42) + return 1; + + if (cnt1 != 5 || cnt2 != 2) + return 1; + + return 0; +} diff --git a/gcc/testsuite/g++.dg/init/delete1.C b/gcc/testsuite/g++.dg/init/delete1.C index 304dca1caf..8236abcd6f 100644 --- a/gcc/testsuite/g++.dg/init/delete1.C +++ b/gcc/testsuite/g++.dg/init/delete1.C @@ -1,6 +1,6 @@ // PR c++/19811 -class C; // { dg-warning "forward" } +class C; // { dg-message "forward" } void foo(void *p) { delete [] ((C*)p) ; // { dg-warning "problem|incomplete" } diff --git a/gcc/testsuite/g++.dg/init/goto2.C b/gcc/testsuite/g++.dg/init/goto2.C index 3f4ecc04cf..f95214f387 100644 --- a/gcc/testsuite/g++.dg/init/goto2.C +++ b/gcc/testsuite/g++.dg/init/goto2.C @@ -3,8 +3,8 @@ bool f(); void g(int i) { - if (i) goto bad; // { dg-error "from" } - bool a = f(); // { dg-error "initialization" } + if (i) goto bad; // { dg-message "from" } + bool a = f(); // { dg-message "initialization" } bad: // { dg-error "jump" } ; } diff --git a/gcc/testsuite/g++.dg/init/goto3.C b/gcc/testsuite/g++.dg/init/goto3.C new file mode 100644 index 0000000000..4c5ceaba3e --- /dev/null +++ b/gcc/testsuite/g++.dg/init/goto3.C @@ -0,0 +1,25 @@ +// PR c++/63558 +// { dg-options "-fpermissive -w" } + +extern int abs(int); +static long int n_ants; +enum enum_var_types + { VAR_NONE, VAR_DELTA, VAR_SWITCH }; + +static enum enum_var_types option_var_n_ants; +void +adapt_parameters_next_iteration(void) +{ + switch(option_var_n_ants) { + + case VAR_NONE: break; + + case VAR_DELTA: + int trunc_n_ants = 0; + n_ants += trunc_n_ants; + break; + case VAR_SWITCH: + break; + default: break; + } +} diff --git a/gcc/testsuite/g++.dg/init/pr43453.C b/gcc/testsuite/g++.dg/init/pr43453.C new file mode 100644 index 0000000000..4c91282d42 --- /dev/null +++ b/gcc/testsuite/g++.dg/init/pr43453.C @@ -0,0 +1,33 @@ +// PR c++/43453 + +struct A { + char x[4]; + A() : x("bug") { }; +}; + +char x [4] ("bug"); + +struct CA { + const char cx[4]; + CA() : cx("bug") { }; +}; + +const char cx [4] ("bug"); + +struct B { + char y[4]; + B() : y("bu") { }; +}; + +char y [4] ("bu"); + +struct C { + char z[4]; + C() : z("bugs") { }; // { dg-error "too long" } +}; + +char z [4] ("bugs"); // { dg-error "too long" } + +char k [] ("bug"); + +const char ck [] ("bug"); diff --git a/gcc/testsuite/g++.dg/init/ref14.C b/gcc/testsuite/g++.dg/init/ref14.C index 6ac42415b4..2e522c1956 100644 --- a/gcc/testsuite/g++.dg/init/ref14.C +++ b/gcc/testsuite/g++.dg/init/ref14.C @@ -4,7 +4,7 @@ union A { - int &i; // { dg-error "may not have reference type" } + int &i; // { dg-error "may not have reference type" "" { target { ! c++11 } } } }; void foo() diff --git a/gcc/testsuite/g++.dg/init/synth2.C b/gcc/testsuite/g++.dg/init/synth2.C index ed50467155..cc6cce0e4a 100644 --- a/gcc/testsuite/g++.dg/init/synth2.C +++ b/gcc/testsuite/g++.dg/init/synth2.C @@ -1,12 +1,11 @@ // PR c++/34180 struct G { - G(); // { dg-message "" "candidate" } + G(); G(G&); // { dg-message "" "candidate" } }; class A // { dg-error "" } -// { dg-message "candidate" "candidate note" { target *-*-* } 8 } { const G g; }; diff --git a/gcc/testsuite/g++.dg/init/union1.C b/gcc/testsuite/g++.dg/init/union1.C index 0049f44291..ea88346ebe 100644 --- a/gcc/testsuite/g++.dg/init/union1.C +++ b/gcc/testsuite/g++.dg/init/union1.C @@ -1,5 +1,5 @@ // PR c++/14401 union U { - int& i; // { dg-error "" } + int& i; // { dg-error "reference type" "" { target { ! c++11 } } } }; diff --git a/gcc/testsuite/g++.dg/ipa/comdat.C b/gcc/testsuite/g++.dg/ipa/comdat.C new file mode 100644 index 0000000000..40a607f936 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/comdat.C @@ -0,0 +1,15 @@ +/* { dg-do compile { target *-*-linux* *-*-gnu* } } */ +/* { dg-options "-O2 -fdump-ipa-comdats" } */ +#include <stdio.h> +__attribute__ ((noinline)) +static int q(void) +{ + return printf ("test"); +} +inline int t(void) +{ + return q(); +} +int (*f)()=t; +/* { dg-final { scan-ipa-dump-times "Localizing symbol" 1 "comdats" } } */ +/* { dg-final { cleanup-ipa-dump "comdats" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/devirt-10.C b/gcc/testsuite/g++.dg/ipa/devirt-10.C index 658442e345..e29d33fa95 100644 --- a/gcc/testsuite/g++.dg/ipa/devirt-10.C +++ b/gcc/testsuite/g++.dg/ipa/devirt-10.C @@ -27,8 +27,6 @@ struct wxBufferedPaintDC : public wxBufferedDC { void OnPaint(wxPaintEvent & event) { wxBufferedPaintDC dc; } -/* IPA-CP should really discover both cases, but for time being the second is handled by inliner. */ -/* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a known target" 1 "inline" } } */ -/* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a known target" 1 "cp" } } */ +/* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a known target" 2 "cp" } } */ /* { dg-final { cleanup-ipa-dump "inline" } } */ /* { dg-final { cleanup-ipa-dump "cp" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/devirt-11.C b/gcc/testsuite/g++.dg/ipa/devirt-11.C index 2b6bdcba0d..7a698f1696 100644 --- a/gcc/testsuite/g++.dg/ipa/devirt-11.C +++ b/gcc/testsuite/g++.dg/ipa/devirt-11.C @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-ipa-inline -fno-devirtualize-speculatively" } */ +/* { dg-options "-O2 -fno-ipa-cp -fdump-ipa-inline -fno-devirtualize-speculatively" } */ int baz (); struct A { @@ -42,8 +42,5 @@ bar () baz (); c + d; } -/* While inlining function called once we should devirtualize a new call to fn2 - and two to fn3. While doing so the new symbol for fn2 needs to be - introduced. */ /* { dg-final { scan-ipa-dump "Discovered a virtual call to a known target" "inline" } } */ /* { dg-final { cleanup-ipa-dump "inline" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/devirt-15.C b/gcc/testsuite/g++.dg/ipa/devirt-15.C index 2ea85f487f..fd8389466e 100644 --- a/gcc/testsuite/g++.dg/ipa/devirt-15.C +++ b/gcc/testsuite/g++.dg/ipa/devirt-15.C @@ -1,7 +1,9 @@ /* Check that we speculatively devirutalize call to FOO to B::foo becuase A is noreturn. */ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-ipa-devirt -fdump-tree-optimized" } */ +/* { dg-options "-O2 -fdump-ipa-devirt-details -fdump-tree-optimized" } */ +/* { dg-add-options bind_pic_locally } */ + class A { public: virtual int foo(void) @@ -33,7 +35,7 @@ main() m(); } -/* { dg-final { scan-ipa-dump "Speculatively devirtualizing call" "devirt"} } */ +/* { dg-final { scan-ipa-dump "speculatively devirtualizing call" "devirt"} } */ /* { dg-final { cleanup-ipa-dump "devirt" } } */ /* Match if (PROF_6 == foo) to verify that the speculation survived. */ /* { dg-final { scan-tree-dump "== foo" "optimized"} } */ diff --git a/gcc/testsuite/g++.dg/ipa/devirt-16.C b/gcc/testsuite/g++.dg/ipa/devirt-16.C index 85567867ff..99a1ea6ec4 100644 --- a/gcc/testsuite/g++.dg/ipa/devirt-16.C +++ b/gcc/testsuite/g++.dg/ipa/devirt-16.C @@ -1,7 +1,7 @@ /* We shall devirtualize to unreachable. No anonymous type method should surivve reachability. */ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-ipa-whole-program" } */ +/* { dg-options "-O2 -fdump-ipa-whole-program-details" } */ namespace { class B { public: @@ -32,7 +32,6 @@ main() return b->foo(); } -/* { dg-final { scan-ipa-dump "Devirtualizing" "whole-program"} } */ /* { dg-final { scan-ipa-dump "builtin_unreachable" "whole-program"} } */ /* { dg-final { scan-ipa-dump-not "A::foo" "whole-program"} } */ /* { dg-final { scan-ipa-dump-not "A::foo" "whole-program"} } */ diff --git a/gcc/testsuite/g++.dg/ipa/devirt-17.C b/gcc/testsuite/g++.dg/ipa/devirt-17.C index 9edfd73af5..df10c48104 100644 --- a/gcc/testsuite/g++.dg/ipa/devirt-17.C +++ b/gcc/testsuite/g++.dg/ipa/devirt-17.C @@ -1,7 +1,7 @@ /* We shall devirtualize to B::foo since it is the only live candidate of an anonymous type. */ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-ipa-whole-program" } */ +/* { dg-options "-O2 -fdump-ipa-whole-program-details" } */ namespace { class B { public: @@ -37,7 +37,6 @@ main() return b->foo(); } -/* { dg-final { scan-ipa-dump "Devirtualizing" "whole-program"} } */ /* { dg-final { scan-ipa-dump-not "builtin_unreachable" "whole-program"} } */ /* { dg-final { scan-ipa-dump "B::foo" "whole-program"} } */ /* { dg-final { scan-ipa-dump-not "A::foo" "whole-program"} } */ diff --git a/gcc/testsuite/g++.dg/ipa/devirt-21.C b/gcc/testsuite/g++.dg/ipa/devirt-21.C index 675bd08d78..99f60afe33 100644 --- a/gcc/testsuite/g++.dg/ipa/devirt-21.C +++ b/gcc/testsuite/g++.dg/ipa/devirt-21.C @@ -37,5 +37,5 @@ main() { class C c; } -/* { dg-final { scan-ipa-dump "Discovered a virtual call to" "cp" { xfail *-*-* } } } */ +/* { dg-final { scan-ipa-dump "Discovered a virtual call to" "cp" } } */ /* { dg-final { cleanup-ipa-dump "cp" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/devirt-24.C b/gcc/testsuite/g++.dg/ipa/devirt-24.C index 01bfdc2ec5..6ac4b606d8 100644 --- a/gcc/testsuite/g++.dg/ipa/devirt-24.C +++ b/gcc/testsuite/g++.dg/ipa/devirt-24.C @@ -36,7 +36,7 @@ C *b = new (C); sort(f, *b); } } -/* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a known target" 1 "inline" } } */ +/* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a known target" 1 "inline" { xfail *-*-* } } } */ /* { dg-final { cleanup-ipa-dump "inline" } } */ /* { dg-final { scan-ipa-dump-times "Aggregate passed by reference" 1 "cp" } } */ /* { dg-final { cleanup-ipa-dump "cp" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/devirt-25.C b/gcc/testsuite/g++.dg/ipa/devirt-25.C index 1da44f5d11..5a8a04faf1 100644 --- a/gcc/testsuite/g++.dg/ipa/devirt-25.C +++ b/gcc/testsuite/g++.dg/ipa/devirt-25.C @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O3 -fdump-ipa-cp" } */ +/* { dg-add-options bind_pic_locally } */ class ert_RefCounter { protected: diff --git a/gcc/testsuite/g++.dg/ipa/devirt-26.C b/gcc/testsuite/g++.dg/ipa/devirt-26.C index 2df429c345..1787fee867 100644 --- a/gcc/testsuite/g++.dg/ipa/devirt-26.C +++ b/gcc/testsuite/g++.dg/ipa/devirt-26.C @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O3 -fdump-ipa-devirt" } */ +/* { dg-options "-O3 -fdump-tree-ccp1" } */ struct A { int a; @@ -23,7 +23,6 @@ int test(void) return d->foo()+b->foo(); } /* The call to b->foo() is perfectly devirtualizable because C can not be in construction - when &c was used, but we can not analyze that so far. Test that we at least speculate - that type is in the construction. */ -/* { dg-final { scan-ipa-dump "Speculatively devirtualizing" "devirt" } } */ -/* { dg-final { cleanup-ipa-dump "devirt" } } */ + when &c was used. */ +/* { dg-final { scan-tree-dump-not "OBJ_TYPE_REF" "ccp1" } } */ +/* { dg-final { cleanup-tree-dump "ccp1" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/devirt-31.C b/gcc/testsuite/g++.dg/ipa/devirt-31.C index 64c44ba1e9..49ad33e3e6 100644 --- a/gcc/testsuite/g++.dg/ipa/devirt-31.C +++ b/gcc/testsuite/g++.dg/ipa/devirt-31.C @@ -1,23 +1,16 @@ -/* { dg-options "-O2 -std=c++11 -fdump-ipa-inline" } */ -#include <new> - -class EmbeddedObject { -public: - virtual int val() { return 2; } -}; - -class Container { - alignas(EmbeddedObject) char buffer[sizeof(EmbeddedObject)]; -public: - EmbeddedObject *obj() { return (EmbeddedObject*)buffer; } - Container() { new (buffer) EmbeddedObject(); } +// { dg-options "-O3 -fdump-tree-ssa" } +inline void t() +{ + struct A {virtual void q() {}}; + static struct A *a; + if (!a) + a = new(A); + a->q(); }; - -Container o; - -int main() +void +m() { - __builtin_printf("%d\n", o.obj()->val()); + t(); } -/* { dg-final { scan-ipa-dump-not "__builtin_unreachable" "inline" } } */ -/* { dg-final { cleanup-ipa-dump "inline" } } */ +// { dg-final { scan-tree-dump-not "OBJ_TYPE_REF" "ssa" } } +// { dg-final { cleanup-tree-dump "ssa" } } diff --git a/gcc/testsuite/g++.dg/ipa/devirt-32.C b/gcc/testsuite/g++.dg/ipa/devirt-32.C new file mode 100644 index 0000000000..64c44ba1e9 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/devirt-32.C @@ -0,0 +1,23 @@ +/* { dg-options "-O2 -std=c++11 -fdump-ipa-inline" } */ +#include <new> + +class EmbeddedObject { +public: + virtual int val() { return 2; } +}; + +class Container { + alignas(EmbeddedObject) char buffer[sizeof(EmbeddedObject)]; +public: + EmbeddedObject *obj() { return (EmbeddedObject*)buffer; } + Container() { new (buffer) EmbeddedObject(); } +}; + +Container o; + +int main() +{ + __builtin_printf("%d\n", o.obj()->val()); +} +/* { dg-final { scan-ipa-dump-not "__builtin_unreachable" "inline" } } */ +/* { dg-final { cleanup-ipa-dump "inline" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/devirt-33.C b/gcc/testsuite/g++.dg/ipa/devirt-33.C new file mode 100644 index 0000000000..970a96b88d --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/devirt-33.C @@ -0,0 +1,78 @@ +/* Verify we do not devirtualize wrongly to __cxa_pure_virtual */ + +/* { dg-do run } */ +/* { dg-options "-O2 -std=c++11" } */ + + +inline void* operator new(__SIZE_TYPE__ s, void* buf) throw() { + return buf; +} + +class A { + +private: + struct Base { + virtual ~Base() {} + virtual Base *Clone(void *buf) const = 0; + virtual float *Allocate(__SIZE_TYPE__ count) = 0; + }; + + struct Value : Base { + virtual ~Value (){} + Base *Clone(void* buf) const override { + return new (buf) Value(); + } + + float *Allocate(__SIZE_TYPE__ count) override { + return new float[count]; + } + }; + +public: + A() { + new (buffer_) Value(); + } + A(const A& other) { + other.ptr()->Clone(buffer_); + } + + float *Allocate() { + return ptr()->Allocate(100); + } + const Base *ptr() const { return reinterpret_cast<const Base*>(buffer_);} + Base *ptr() { return reinterpret_cast< Base*>(buffer_);} + +private: + alignas(16) char buffer_[1024]; +}; + + +struct B { + B (const A& a) : a_(a) { + buff_ = a_.Allocate(); + } + + float *buff_; + A a_; +}; + +struct Dummy { + int i; +}; + +struct D : public Dummy { + __attribute__((noinline)) D( const A&a); + + B b_; +}; + +D::D(const A&a) : b_(a) {} + +int main() +{ + A a; + D d(a); + + return 0; +} + diff --git a/gcc/testsuite/g++.dg/ipa/devirt-34.C b/gcc/testsuite/g++.dg/ipa/devirt-34.C new file mode 100644 index 0000000000..6487f8ee3d --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/devirt-34.C @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-ipa-devirt" } */ +struct A {virtual int t(){return 42;}}; +struct B:A {virtual int t(){return 1;}}; + +struct A aa; +struct B bb; +int +t(struct B *b) +{ + struct A *a=b; + a->t(); +} + +/* We should guess that the pointer of type B probably points to an instance + of B or its derivates and exclude A::t from list of likely targets. */ + +/* { dg-final { scan-ipa-dump "Speculative targets" "devirt" } } */ +/* { dg-final { scan-ipa-dump "1 speculatively devirtualized" "devirt" } } */ +/* { dg-final { cleanup-ipa-dump "devirt" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/devirt-35.C b/gcc/testsuite/g++.dg/ipa/devirt-35.C new file mode 100644 index 0000000000..07383ed795 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/devirt-35.C @@ -0,0 +1,23 @@ +/* { dg-options "-O2 -fdump-ipa-devirt-details -fdump-tree-fre1-details" } */ +struct A {virtual int t(void) {return 1;}}; +struct B:A {B(); virtual int t(void) {return 2;}}; +void test2(struct A *); +int +m(struct B *b) +{ + struct A *a = new (B); + a->t(); // This call should be devirtualized by + // FRE because we know type from ctor call + ((struct B *)a)->B::t(); // Make devirt possible + // C++ FE won't produce inline body without this + test2(a); + return a->t(); // This call should be devirtualized speculatively because + // test2 may change the type of A by placement new. + // C++ standard is bit imprecise about this. +} +/* { dg-final { scan-tree-dump "converting indirect call to function virtual int B::t" "fre1" } } */ +/* { dg-final { scan-ipa-dump "to virtual int B::t" "devirt" } } */ +/* { dg-final { scan-ipa-dump "1 speculatively devirtualized" "devirt" } } */ +/* { dg-final { cleanup-ipa-dump "devirt" } } */ +/* { dg-final { cleanup-tree-dump "fre1" } } */ + diff --git a/gcc/testsuite/g++.dg/ipa/devirt-36.C b/gcc/testsuite/g++.dg/ipa/devirt-36.C new file mode 100644 index 0000000000..6d7206c116 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/devirt-36.C @@ -0,0 +1,25 @@ +/* { dg-options "-O2 -fdump-ipa-devirt-details -fdump-tree-fre1-details" } */ +struct A {virtual int t(void) {return 1;}}; +struct B:A {B(); virtual int t(void) {return 2;}}; +struct C {int a; struct B b;}; +void test2(struct A *); +int +m(struct B *b) +{ + struct C *c = new (C); + struct A *a = &c->b; + a->t(); // This call should be devirtualized by + // FRE because we know type from ctor call + ((struct B *)a)->B::t(); // Make devirt possible + // C++ FE won't produce inline body without this + test2(a); + return a->t(); // This call should be devirtualized speculatively because + // test2 may change the type of A by placement new. + // C++ standard is bit imprecise about this. +} +/* { dg-final { scan-tree-dump "converting indirect call to function virtual int B::t" "fre1" } } */ +/* { dg-final { scan-ipa-dump "to virtual int B::t" "devirt" } } */ +/* { dg-final { scan-ipa-dump "1 speculatively devirtualized" "devirt" } } */ +/* { dg-final { cleanup-ipa-dump "devirt" } } */ +/* { dg-final { cleanup-tree-dump "fre1" } } */ + diff --git a/gcc/testsuite/g++.dg/ipa/devirt-37.C b/gcc/testsuite/g++.dg/ipa/devirt-37.C new file mode 100644 index 0000000000..7e1acdc986 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/devirt-37.C @@ -0,0 +1,37 @@ +/* { dg-options "-fpermissive -O2 -fno-indirect-inlining -fno-devirtualize-speculatively -fdump-tree-fre2-details -fno-early-inlining" } */ +#include <stdlib.h> +struct A {virtual void test() {abort ();}}; +struct B:A + {virtual void test() {} + B(); + B(void (*test)(struct A *));}; + +void extcall(void); + +inline void tt(struct A *a) +{ + a->test(); +} + +__attribute__ ((always_inline)) +inline +B::B (void (*test)(struct A *)) +{ + struct B c; + struct A *a=this; + extcall(); + test(a); +} +void +t() +{ + struct B b(tt); +} +/* After inlining the call within constructor needs to be checked to not go into a basetype. + We should see the vtbl store and we should notice extcall as possibly clobbering the + type but ignore it because b is in static storage. */ +/* { dg-final { scan-tree-dump "No dynamic type change found." "fre2" } } */ +/* { dg-final { scan-tree-dump "Checking vtbl store:" "fre2" } } */ +/* { dg-final { scan-tree-dump "Function call may change dynamic type:extcall" "fre2" } } */ +/* { dg-final { scan-tree-dump "converting indirect call to function virtual void" "fre2" } } */ +/* { dg-final { cleanup-tree-dump "fre2" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/devirt-38.C b/gcc/testsuite/g++.dg/ipa/devirt-38.C new file mode 100644 index 0000000000..2d95bf7416 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/devirt-38.C @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ccp1" } */ +class SnmpSyntax +{ +public: + virtual SnmpSyntax *m_fn1 () const; + ~SnmpSyntax () {} + virtual SnmpSyntax &operator=(const SnmpSyntax &); +}; + +class A : public SnmpSyntax +{ +public: + A (int); + SnmpSyntax *m_fn1 () const {} + SnmpSyntax &operator=(const SnmpSyntax &); +}; +int a; +void fn1 () +{ + for (;; a++) + switch (0) + case 0: + { + A b (0); + SnmpSyntax &c = b; + c.m_fn1 (); + } +} +/* { dg-final { scan-tree-dump-not "OBJ_TYPE_REF" "ccp1" } } */ +/* { dg-final { cleanup-tree-dump "ccp1" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/devirt-39.C b/gcc/testsuite/g++.dg/ipa/devirt-39.C index 8cd734d77c..050b1d3055 100644 --- a/gcc/testsuite/g++.dg/ipa/devirt-39.C +++ b/gcc/testsuite/g++.dg/ipa/devirt-39.C @@ -1,5 +1,5 @@ // PR c++/61214 -/* { dg-options "-O2" } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ struct Base { @@ -24,4 +24,6 @@ int main() return 0; } +/* { dg-final { scan-tree-dump-not "OBJ_TYPE_REF" "optimized" } } */ /* { dg-final { scan-assembler-not "_ZN3Foo5cloneEv" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/devirt-40.C b/gcc/testsuite/g++.dg/ipa/devirt-40.C index 9c3bdf5e9d..79cb1297f2 100644 --- a/gcc/testsuite/g++.dg/ipa/devirt-40.C +++ b/gcc/testsuite/g++.dg/ipa/devirt-40.C @@ -1,21 +1,23 @@ -// PR c++/62224 -// { dg-options "-O2" } -// For 4.9, we don't want to devirtualize f and thus create a reference to g. - -struct A +/* { dg-options "-O2 -fdump-tree-fre2-details" } */ +typedef enum +{ +} UErrorCode; +class UnicodeString { - virtual void f () = 0; +public: + UnicodeString (); + virtual ~UnicodeString (); }; - -class B : A +class A { - virtual void f () { g(); } - void g(); + UnicodeString &m_fn1 (UnicodeString &, int &p2, UErrorCode &) const; }; - -void h (A *a) +UnicodeString::UnicodeString () {} +UnicodeString & +A::m_fn1 (UnicodeString &, int &p2, UErrorCode &) const { - a->f (); + UnicodeString a[2]; } -// { dg-final { scan-assembler-not "_ZN1B1gEv" } } +/* { dg-final { scan-tree-dump-not "\\n OBJ_TYPE_REF" "fre2" } } */ +/* { dg-final { cleanup-tree-dump "fre2" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/devirt-41.C b/gcc/testsuite/g++.dg/ipa/devirt-41.C new file mode 100644 index 0000000000..926c3c4981 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/devirt-41.C @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-ipa-inline-details -fno-early-inlining -fno-ipa-cp" } */ +struct A {virtual int foo () {return 1;}}; +struct B:A {virtual int foo () {return 2;}}; + +void dostuff(struct A *); + +static void +test (struct A *a) +{ + dostuff (a); + if (a->foo ()!= 2) + __builtin_abort (); +} + +main() +{ + struct B a; + dostuff (&a); + test (&a); +} +/* Inlining of dostuff into main should combine polymorphic context + specifying Outer type:struct B offset 0 + with Outer type (dynamic):struct A (or a derived type) offset 0 + and enable devirtualization. + + Because the type is in static storage, we know it won't change type in dostuff + and from callstack we can tell that is is not in construction/destruction. */ +/* { dg-final { scan-ipa-dump "Second type is base of first" "inline" } } */ +/* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a known target" 1 "inline" } } */ +/* { dg-final { cleanup-ipa-dump "inline" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/devirt-42.C b/gcc/testsuite/g++.dg/ipa/devirt-42.C new file mode 100644 index 0000000000..d7b1b3cd7b --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/devirt-42.C @@ -0,0 +1,38 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-ipa-cp -fdump-ipa-inline-details -fno-early-inlining -fdump-tree-optimized" } */ +struct A { + virtual int foo () {return 1;} + int bar () {return foo();} + int barbar (); +}; +namespace { + struct B:A {virtual int foo () {return 2;} + int barbar () {return bar();}}; +} + +int +A::barbar() +{ + return static_cast<B*>(this)->barbar(); +} + +main() +{ + struct B b; + struct A *a = &b; + return a->barbar (); +} + +/* Inlining everything into main makes type clear from type of variable b. + However devirtualization is also possible for offline copy of A::barbar. Invoking + B's barbar makes it clear the type is at least B and B is an anonymous + namespace type and therefore we know it has no derivations. */ +/* { dg-final { scan-ipa-dump "First type is base of second" "inline" } } */ +/* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a known target" 2 "inline" } } */ + +/* Verify that speculation is optimized by late optimizers. */ +/* { dg-final { scan-tree-dump-times "return 2" 3 "optimized" } } */ +/* { dg-final { scan-tree-dump-not "OBJ_TYPE_REF" "optimized" } } */ + +/* { dg-final { cleanup-ipa-dump "inline" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/devirt-43.C b/gcc/testsuite/g++.dg/ipa/devirt-43.C new file mode 100644 index 0000000000..be1aaa8675 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/devirt-43.C @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-ipa-inline-details -fno-ipa-cp -fno-early-inlining" } */ +struct A {virtual int foo () {return 1;}}; +struct B {int i; struct A a;}; +struct C:A {virtual int foo () {return 2;}}; + +void dostuff(struct A *); + +static void +test (struct A *a) +{ + dostuff (a); + if (a->foo ()!= 2) + __builtin_abort (); +} + +void +t(struct B *b) +{ + test(&b->a); +} +/* Here b comes externally, but we take speculative hint from type of the pointer that it is + of type B. This makes A fully specified and we know C::foo is unlikely. + FIXME: We could most probably can devirtualize unconditonally because dereference of b in + &b->a makes the type known. GIMPLE does not represent this. */ +/* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a speculative target" 1 "inline" { xfail *-*-* } } } */ +/* { dg-final { cleanup-ipa-dump "inline" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/devirt-44.C b/gcc/testsuite/g++.dg/ipa/devirt-44.C new file mode 100644 index 0000000000..214cf95d6e --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/devirt-44.C @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-ipa-cp -fdump-ipa-inline-details -fno-early-inlining" } */ +struct A { + virtual int foo () {return 1;} + int wrapfoo () {foo();} + A() {wrapfoo();} +}; +struct B:A {virtual int foo () {return 2;}}; + +void dostuff(struct A *); + +static void +test (struct A *a) +{ + dostuff (a); + if (a->foo ()!= 2) + __builtin_abort (); +} + +main() +{ + struct B a; + dostuff (&a); + test (&a); +} +/* Here one invocation of foo is while type is in construction, while other is not. + Check that we handle that. */ + +/* { dg-final { scan-ipa-dump "Second type is base of first" "inline" } } */ +/* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a known target\[^\\n\]*A::foo" 1 "inline" } } */ +/* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a known target\[^\\n\]*B::foo" 1 "inline" } } */ +/* { dg-final { cleanup-ipa-dump "inline" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/devirt-45.C b/gcc/testsuite/g++.dg/ipa/devirt-45.C new file mode 100644 index 0000000000..4616c951d9 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/devirt-45.C @@ -0,0 +1,42 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-ipa-cp -fdump-ipa-inline-details -fno-early-inlining" } */ +struct A { + virtual int foo () {return 1;} + int wrapfoo () {foo();} + A() {wrapfoo();} +}; +inline void* operator new(__SIZE_TYPE__ s, void* buf) throw() { + return buf; +} +struct B:A {virtual int foo () {return 2;}}; + +void dostuff(struct A *); + +static void +test2 (struct A *a) +{ + dostuff (a); + if (a->foo ()!= 2) + __builtin_abort (); +} + +static void +test (struct A *a) +{ + dostuff (a); + static_cast<B*>(a)->~B(); + new(a) B(); + test2(a); +} + +main() +{ + struct B a; + dostuff (&a); + test (&a); +} + +/* One invocation is A::foo () other is B::foo () even though the type is destroyed and rebuilt in test() */ +/* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a known target\[^\\n\]*A::foo" 1 "inline" } } */ +/* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a known target\[^\\n\]*B::foo" 1 "inline" } } */ +/* { dg-final { cleanup-ipa-dump "inline" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/devirt-46.C b/gcc/testsuite/g++.dg/ipa/devirt-46.C new file mode 100644 index 0000000000..bce7109c84 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/devirt-46.C @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-ipa-cp -fdump-ipa-inline-details -fno-early-inlining -fdump-tree-optimized" } */ +struct A { + virtual int foo(){return 1;} +}; +struct B:A { + virtual int foo(){return 2;} +}; +static void +test (struct A *a) +{ + if (a->foo() != 2) + __builtin_abort (); +} +int +m() +{ + struct A *a = new B; + test (a); + return 0; +} + +/* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a known target\[^\\n\]*B::foo" 1 "inline" } } */ +/* { dg-final { scan-tree-dump-not "OBJ_TYPE_REF" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "abort" "optimized" } } */ +/* { dg-final { cleanup-ipa-dump "inline" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/devirt-47.C b/gcc/testsuite/g++.dg/ipa/devirt-47.C new file mode 100644 index 0000000000..81dc5e69d6 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/devirt-47.C @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-ipa-cp -fdump-ipa-inline-details -fno-early-inlining -fdump-tree-optimized" } */ +struct A { + virtual int foo(){return 1;} +}; +struct B { + virtual int bar(){return 4;} +}; +struct C:B,A { + virtual int foo(){return 2;} +}; +static void +test (struct A *a) +{ + if (a->foo() != 2) + __builtin_abort (); +} +int +m() +{ + struct A *a = new C; + test (a); + return 0; +} + +/* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a known target\[^\\n\]*C::_ZTh" 1 "inline" } } */ +/* { dg-final { scan-tree-dump-not "OBJ_TYPE_REF" "optimized" } } */ +/* FIXME: We ought to inline thunk. */ +/* { dg-final { scan-tree-dump "C::_ZThn" "optimized" } } */ +/* { dg-final { cleanup-ipa-dump "inline" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/devirt-48.C b/gcc/testsuite/g++.dg/ipa/devirt-48.C new file mode 100644 index 0000000000..e1ed27477a --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/devirt-48.C @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-ipa-cp -fdump-ipa-inline-details -fno-early-inlining" } */ +struct A { + virtual int foo(){return 1;} +}; +struct B:A { + virtual int foo(){return 2;} + int callfoo(){foo();} +}; +struct C:A { + virtual int foo(){return 3;} +}; +struct D:B { + virtual int foo(){return 4;} + int callfoo(){foo();} +}; +static void +test (struct A *a) +{ + if (a->foo() != 2) + __builtin_abort (); +} +int +m() +{ + struct A *a = new C; + static_cast<B*>(a)->callfoo(); + return 0; +} + +/* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a known target\[^\\n\]*__builtin_unreachable" 1 "inline" } } */ +/* { dg-final { cleanup-ipa-dump "inline" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/devirt-7.C b/gcc/testsuite/g++.dg/ipa/devirt-7.C index 1c59122303..30df64a370 100644 --- a/gcc/testsuite/g++.dg/ipa/devirt-7.C +++ b/gcc/testsuite/g++.dg/ipa/devirt-7.C @@ -2,6 +2,7 @@ comes from a method that has been early-inlined into a descendant. */ /* { dg-do run } */ /* { dg-options "-O3 -fdump-ipa-cp" } */ +/* { dg-add-options bind_pic_locally } */ extern "C" void abort (void); diff --git a/gcc/testsuite/g++.dg/ipa/devirt-g-1.C b/gcc/testsuite/g++.dg/ipa/devirt-g-1.C index 175f24efbb..1530fdbaa0 100644 --- a/gcc/testsuite/g++.dg/ipa/devirt-g-1.C +++ b/gcc/testsuite/g++.dg/ipa/devirt-g-1.C @@ -1,5 +1,5 @@ // { dg-do compile } -// { dg-options "-O2 -fdump-ipa-cp -fdump-tree-optimized" } +// { dg-options "-O2 -fdump-ipa-cp -fno-ipa-icf -fdump-tree-optimized" } struct S { S(); virtual void xyzzy(); void otherstuff(); }; struct R { int a; S s; R(); }; diff --git a/gcc/testsuite/g++.dg/ipa/imm-devirt-1.C b/gcc/testsuite/g++.dg/ipa/imm-devirt-1.C index 32f7258a45..85f1a8f0d2 100644 --- a/gcc/testsuite/g++.dg/ipa/imm-devirt-1.C +++ b/gcc/testsuite/g++.dg/ipa/imm-devirt-1.C @@ -1,7 +1,7 @@ /* Verify that virtual calls are folded even early inlining puts them into one function with the definition. */ /* { dg-do run } */ -/* { dg-options "-O2 -fdump-tree-fre1-details" } */ +/* { dg-options "-O2 -fdump-tree-einline" } */ extern "C" void abort (void); @@ -58,5 +58,10 @@ int main (int argc, char *argv[]) return 0; } -/* { dg-final { scan-tree-dump "Replacing call target with foo" "fre1" } } */ -/* { dg-final { cleanup-tree-dump "fre1" } } */ +/* middleman_2 gets early inlined and the virtual call should get turned to + a direct call. */ +/* { dg-final { scan-tree-dump "Inlining int middleman_1" "einline" } } */ +/* { dg-final { scan-tree-dump "Inlining int middleman_2" "einline" } } */ +/* { dg-final { scan-tree-dump "B::foo \\(" "einline" } } */ +/* { dg-final { scan-tree-dump-times "OBJ_TYPE_REF" 2 "einline" } } */ +/* { dg-final { cleanup-tree-dump "einline" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/imm-devirt-2.C b/gcc/testsuite/g++.dg/ipa/imm-devirt-2.C index 5bddc2fcb2..fc75b3e308 100644 --- a/gcc/testsuite/g++.dg/ipa/imm-devirt-2.C +++ b/gcc/testsuite/g++.dg/ipa/imm-devirt-2.C @@ -1,7 +1,7 @@ /* Verify that virtual calls are folded even early inlining puts them into one function with the definition. */ /* { dg-do run } */ -/* { dg-options "-O2 -fdump-tree-fre1-details" } */ +/* { dg-options "-O2 -fdump-tree-einline" } */ extern "C" void abort (void); @@ -91,5 +91,6 @@ int main (int argc, char *argv[]) return 0; } -/* { dg-final { scan-tree-dump "Replacing call target" "fre1" } } */ -/* { dg-final { cleanup-tree-dump "fre1" } } */ +/* We fold into thunk of C. Eventually we should inline the thunk. */ +/* { dg-final { scan-tree-dump "C::_ZThn\[0-9\]+_N1C3fooEi \\(" "einline" } } */ +/* { dg-final { cleanup-tree-dump "einline" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/inline-1.C b/gcc/testsuite/g++.dg/ipa/inline-1.C index dbbfb4e33b..3a6a041805 100644 --- a/gcc/testsuite/g++.dg/ipa/inline-1.C +++ b/gcc/testsuite/g++.dg/ipa/inline-1.C @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-ipa-inline --param max-early-inliner-iterations=1" } */ +/* { dg-options "-O2 -fdump-ipa-inline -fno-ipa-icf --param max-early-inliner-iterations=1" } */ /* { dg-add-options bind_pic_locally } */ namespace std { diff --git a/gcc/testsuite/g++.dg/ipa/inline-2.C b/gcc/testsuite/g++.dg/ipa/inline-2.C index fd284a1e23..d1e46c0839 100644 --- a/gcc/testsuite/g++.dg/ipa/inline-2.C +++ b/gcc/testsuite/g++.dg/ipa/inline-2.C @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-ipa-inline --param max-early-inliner-iterations=1" } */ +/* { dg-options "-O2 -fdump-ipa-inline -fno-ipa-icf --param max-early-inliner-iterations=1" } */ /* { dg-add-options bind_pic_locally } */ namespace std { diff --git a/gcc/testsuite/g++.dg/ipa/inline-3.C b/gcc/testsuite/g++.dg/ipa/inline-3.C index 8d5f905cf4..7315bf5396 100644 --- a/gcc/testsuite/g++.dg/ipa/inline-3.C +++ b/gcc/testsuite/g++.dg/ipa/inline-3.C @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-ipa-inline --param max-early-inliner-iterations=1" } */ +/* { dg-options "-O2 -fdump-ipa-inline -fno-ipa-icf --param max-early-inliner-iterations=1" } */ /* { dg-add-options bind_pic_locally } */ #include <algorithm> diff --git a/gcc/testsuite/g++.dg/ipa/ipa-icf-1.C b/gcc/testsuite/g++.dg/ipa/ipa-icf-1.C new file mode 100644 index 0000000000..d27abf47a2 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/ipa-icf-1.C @@ -0,0 +1,43 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-ipa-icf" } */ + +class A +{ +public: + __attribute__ ((noinline)) + virtual int Foo2() + { + return v; + } + + float f; + int v; +}; + +class B +{ +public: + __attribute__ ((noinline)) + int Bar2() + { + return v; + } + + float f, aaa; + int v; +}; + +int main() +{ + A a; + B b; + + a.Foo2(); + b.Bar2(); + + return 12345; +} + +/* { dg-final { scan-ipa-dump-not "Semantic equality hit:" "icf" } } */ +/* { dg-final { scan-ipa-dump "Equal symbols: 0" "icf" } } */ +/* { dg-final { cleanup-ipa-dump "icf" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/ipa-icf-2.C b/gcc/testsuite/g++.dg/ipa/ipa-icf-2.C new file mode 100644 index 0000000000..48badd740f --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/ipa-icf-2.C @@ -0,0 +1,40 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-ipa-icf" } */ + +class A +{ +public: + __attribute__ ((noinline)) + int Foo2() + { + return 1; + } + + int v; + float f; +}; + +class B +{ +public: + __attribute__ ((noinline)) + int Bar2() + { + return 1; + } + + int v; + float f, aaa; +}; + +int main() +{ + A a; + B b; + + return a.Foo2() + b.Bar2(); +} + +/* { dg-final { scan-ipa-dump "Semantic equality hit:" "icf" } } */ +/* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf" } } */ +/* { dg-final { cleanup-ipa-dump "icf" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/ipa-icf-3.C b/gcc/testsuite/g++.dg/ipa/ipa-icf-3.C new file mode 100644 index 0000000000..042f789f66 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/ipa-icf-3.C @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-ipa-icf" } */ + +__attribute__ ((noinline)) +int zero() +{ + return 0; +} + +__attribute__ ((noinline)) +int nula() +{ + return 0; +} + +__attribute__ ((noinline)) +int foo() +{ + return zero(); +} + +__attribute__ ((noinline)) +int bar() +{ + return nula(); +} + +int main() +{ + return foo() + bar(); +} + +/* { dg-final { scan-ipa-dump "Semantic equality hit:.*bar.*->.*foo.*" "icf" } } */ +/* { dg-final { scan-ipa-dump "Semantic equality hit:.*nula.*->.*zero.*" "icf" } } */ +/* { dg-final { scan-ipa-dump "Equal symbols: 2" "icf" } } */ +/* { dg-final { cleanup-ipa-dump "icf" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/ipa-icf-4.C b/gcc/testsuite/g++.dg/ipa/ipa-icf-4.C new file mode 100644 index 0000000000..e5d3123fe6 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/ipa-icf-4.C @@ -0,0 +1,48 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-ipa-icf -fno-inline" } */ + +namespace { +struct A +{ + virtual void foo(void) {} +}; +struct B: virtual A +{ + virtual void foo(void) {} +}; +struct C: virtual A +{ + virtual void bar(void) {} +}; +struct D: virtual A +{ + virtual void sparta(void) {} +}; +struct E: B,C,D +{ + virtual void foo(void) {} + virtual void barbar(void) {} +}; +} // anonymous namespace + +int main() +{ + struct A a; + struct B b; + struct C c; + struct D d; + struct E e; + + a.foo(); + b.foo(); + c.bar(); + d.foo(); + d.sparta(); + e.barbar(); + + return 123; +} + +/* { dg-final { scan-ipa-dump "\(Unified; Variable alias has been created\)|\(Symbol aliases are not supported by target\)" "icf" } } */ +/* { dg-final { scan-ipa-dump "Equal symbols: \[67\]" "icf" } } */ +/* { dg-final { cleanup-ipa-dump "icf" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/ipa-icf-5.C b/gcc/testsuite/g++.dg/ipa/ipa-icf-5.C new file mode 100644 index 0000000000..57dcb782fc --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/ipa-icf-5.C @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-require-visibility "" } */ +/* { dg-require-alias "" } */ +/* { dg-options "-O2 -fdump-ipa-icf" } */ + +struct test +{ + int a; + float b; +}; + +extern const struct test myarray __attribute__ ((visibility("hidden"))); +extern const struct test myarray_alias __attribute__ ((visibility("hidden"))); + +const struct test myarray = {1, 1.5f}; + +extern const struct test myarray_alias __attribute__ ((alias ("myarray"))); + +int main() +{ + return myarray.a - myarray_alias.a; +} + +/* { dg-final { scan-ipa-dump "Equal symbols: 0" "icf" } } */ +/* { dg-final { cleanup-ipa-dump "icf" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/ipa-icf-6.C b/gcc/testsuite/g++.dg/ipa/ipa-icf-6.C new file mode 100644 index 0000000000..933ab5dcf0 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/ipa-icf-6.C @@ -0,0 +1,37 @@ +/* { dg-do run } */ +/* { dg-options "-O3 -fdump-ipa-icf" } */ + +struct A { + A() {ptr=&b;} + A(const A &a) {ptr = &b;} + void test() { if (ptr != &b) __builtin_abort ();} + int b; + int *ptr; +}; + +A test1(A a) +{ + a.test(); + return a; +} +A test2(A a) +{ + a.test(); + return a; +} +__attribute__ ((noinline)) +static void +test_me (A (*t)(A)) +{ + struct A a, b=t(a); + b.test (); +} +int +main() +{ + test_me (test1); + test_me (test2); + return 0; +} +/* { dg-final { scan-ipa-dump-times "Unified; Wrapper has been created" 1 "icf" } } */ +/* { dg-final { cleanup-ipa-dump "icf" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/polymorphic-call-1.C b/gcc/testsuite/g++.dg/ipa/polymorphic-call-1.C new file mode 100644 index 0000000000..2b5b544783 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/polymorphic-call-1.C @@ -0,0 +1,49 @@ +// { dg-do compile } +// { dg-options "-O2" } +class A; +class B +{ + A *mRawPtr; + +public: + void *StartAssignment___trans_tmp_2; + A ** + m_fn1 () + { + StartAssignment___trans_tmp_2 = &mRawPtr; + return reinterpret_cast<A **> (StartAssignment___trans_tmp_2); + } +}; +class C +{ +public: + C (B &p1) : mTargetSmartPtr (p1) {} + operator A **() { return mTargetSmartPtr.m_fn1 (); } + B &mTargetSmartPtr; +}; +class A +{ +public: + A (); +}; +class D +{ + D (bool); + B mNewEntry; + virtual int m_fn2 (); +}; +C +fn1 (B &p1) +{ + return p1; +} +void +fn2 (bool, A **) +{ + new A; +} +D::D (bool p1) +{ + A **a = fn1 (mNewEntry); + fn2 (p1, a); +} diff --git a/gcc/testsuite/g++.dg/ipa/pr60600.C b/gcc/testsuite/g++.dg/ipa/pr60600.C index 0753931930..8f6cd7aed1 100644 --- a/gcc/testsuite/g++.dg/ipa/pr60600.C +++ b/gcc/testsuite/g++.dg/ipa/pr60600.C @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O3 -fdump-ipa-cp" } */ +/* { dg-add-options bind_pic_locally } */ struct data { data(int); diff --git a/gcc/testsuite/g++.dg/ipa/pr61160-1.C b/gcc/testsuite/g++.dg/ipa/pr61160-1.C index 69bd6a61d4..a0fbb5f42b 100644 --- a/gcc/testsuite/g++.dg/ipa/pr61160-1.C +++ b/gcc/testsuite/g++.dg/ipa/pr61160-1.C @@ -27,6 +27,5 @@ void *test (MMixin & anExample) int main () { CExample c; - test (c); - return 0; + return (test (c) != &c); } diff --git a/gcc/testsuite/g++.dg/ipa/pr61160-3.C b/gcc/testsuite/g++.dg/ipa/pr61160-3.C index 8184ec2cd3..d7a3afb804 100644 --- a/gcc/testsuite/g++.dg/ipa/pr61160-3.C +++ b/gcc/testsuite/g++.dg/ipa/pr61160-3.C @@ -33,5 +33,6 @@ void *test (MMixin & anExample) int main () { CExample c; - return (test (c) != &c); + test (c); + return 0; } diff --git a/gcc/testsuite/g++.dg/ipa/pr61800.C b/gcc/testsuite/g++.dg/ipa/pr61800.C new file mode 100644 index 0000000000..3bc796f990 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr61800.C @@ -0,0 +1,68 @@ +/* PR ipa/61800 */ +/* { dg-do compile } */ +/* { dg-require-visibility "" } */ +/* { dg-options "-O2" } */ + +#pragma GCC visibility push(hidden) +class A +{ +public: + unsigned long m_fn1 () const; +}; +class B; +class C +{ +public: + ; + virtual bool m_fn2 (void) = 0; +}; +class D +{ + virtual bool m_fn3 (const int &p1, B *p2) = 0; +}; +class F : public D +{ + bool m_fn3 (const int &p1, B *p2); + A mPredicates; +}; +class B +{ +}; +class G : public B +{ + virtual unsigned int m_fn4 () = 0; +}; +class H : public G +{ +public: + int txNodeSetContext_aContextNodeSet; + H (B *p1) {} + int + m_fn5 () + { + return mPosition < m_fn4 (); + } + unsigned int m_fn4 (); + unsigned int mPosition; +}; + +unsigned int a; +C *b; +bool +F::m_fn3 (const int &p1, B *p2) +{ + if (!b->m_fn2 ()) + return false; + unsigned int c = mPredicates.m_fn1 (); + for (1; 1 < c; ++a) + { + H d (p2); + while (d.m_fn5 ()) + { + do + { + } + while (0); + } + } +} diff --git a/gcc/testsuite/g++.dg/ipa/pr63470.C b/gcc/testsuite/g++.dg/ipa/pr63470.C new file mode 100644 index 0000000000..e6fa73bcd4 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr63470.C @@ -0,0 +1,54 @@ +/* PR ipa/63470.C */ +/* { dg-do compile } */ +/* { dg-options "-O2 -finline-functions" } */ + +class A +{ +public: + virtual bool m_fn1 (); + virtual const char **m_fn2 (int); + virtual int m_fn3 (); +}; +class FTjackSupport : A +{ + ~FTjackSupport (); + bool m_fn1 (); + bool m_fn4 (); + const char ** + m_fn2 (int) + { + } + int _inited; + int *_jackClient; + int _activePathCount; +} + +* a; +void fn1 (...); +void fn2 (void *); +int fn3 (int *); +FTjackSupport::~FTjackSupport () { m_fn4 (); } + +bool +FTjackSupport::m_fn1 () +{ + if (!_jackClient) + return 0; + for (int i=0; _activePathCount; ++i) + if (m_fn2 (i)) + fn2 (a); + if (m_fn3 ()) + fn2 (a); + if (fn3 (_jackClient)) + fn1 (0); +} + +bool +FTjackSupport::m_fn4 () +{ + if (_inited && _jackClient) + { + m_fn1 (); + return 0; + } +} diff --git a/gcc/testsuite/g++.dg/ipa/pr63574.C b/gcc/testsuite/g++.dg/ipa/pr63574.C new file mode 100644 index 0000000000..59b82d53ba --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr63574.C @@ -0,0 +1,47 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +class test +{ +public: + test (int val, int *p) + { + int_val = *p; + bool_val = (val != int_val); + } + + ~test () + { + if (!bool_val) + return; + } + + int get_int_val () const + { + return int_val; + } + +private: + bool bool_val; + int int_val; +}; + +static int __attribute__ ((noinline)) +f1 (int i, int *p) +{ + test obj (i, p); + return obj.get_int_val (); +} + +static int __attribute__ ((noinline)) +f2 (int i, int *p) +{ + test obj (i, p); + return obj.get_int_val (); +} + +int +f (int i, int *p) +{ + return f1 (i, p) + f2 (i, p); +} diff --git a/gcc/testsuite/g++.dg/ipa/pr63580.C b/gcc/testsuite/g++.dg/ipa/pr63580.C new file mode 100644 index 0000000000..904195a70b --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr63580.C @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-ipa-icf" } */ + +struct A +{ +}; +template <class L, class R> A operator%(L, R); +template <class A0, class A1, class A2, class A3> +void make_tuple (A0 &, A1, A2, A3); +A +bar (int p1, char p2, int p3, double p4) +{ + A a; + make_tuple (p1, p2, p3, p4); + return "int; char; string; double; " % a; +} +A +foo (int p1, char p2, int p3, double p4) +{ + A b; + make_tuple (p1, p2, p3, p4); + return "int; char; string; double; " % b; +} + +/* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf" } } */ +/* { dg-final { cleanup-ipa-dump "icf" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/pr63587-1.C b/gcc/testsuite/g++.dg/ipa/pr63587-1.C new file mode 100644 index 0000000000..cbf872e296 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr63587-1.C @@ -0,0 +1,92 @@ +// PR ipa/63587 +// { dg-do compile { target c++11 } } +// { dg-options "-O2 -fno-strict-aliasing" } + +template <class> struct A +{ +}; +template <typename> struct B +{ + template <typename> struct C; +}; +class D; +template <typename> class F; +struct G +{ + void operator()(const D &, D); +}; +class D +{ +public: + D (int); +}; +struct H +{ + H (int); +}; +template <typename _Key, typename, typename, typename _Compare, typename> +class I +{ + typedef _Key key_type; + template <typename _Key_compare> struct J + { + _Key_compare _M_key_compare; + }; + J<_Compare> _M_impl; + +public: + A<int> _M_get_insert_unique_pos (const key_type &); + A<int> _M_get_insert_hint_unique_pos (H &); + template <typename... _Args> int _M_emplace_hint_unique (H, _Args &&...); +}; +template <typename _Key, typename _Tp, typename _Compare = G, + typename _Alloc = F<A<_Tp> > > +class K +{ + typedef _Key key_type; + typedef _Key value_type; + typedef typename B<_Alloc>::template C<value_type> _Pair_alloc_type; + I<key_type, value_type, int, _Compare, _Pair_alloc_type> _M_t; + +public: + void operator[](key_type) + { + _M_t._M_emplace_hint_unique (0); + } +}; +template <typename _Key, typename _Val, typename _KeyOfValue, + typename _Compare, typename _Alloc> +A<int> +I<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_unique_pos ( + const key_type &p1) +{ + _M_impl._M_key_compare (p1, 0); +} +template <typename _Key, typename _Val, typename _KeyOfValue, + typename _Compare, typename _Alloc> +A<int> +I<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_hint_unique_pos ( + H &) +{ + _M_get_insert_unique_pos (0); +} +template <typename _Key, typename _Val, typename _KeyOfValue, + typename _Compare, typename _Alloc> +template <typename... _Args> +int +I<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_emplace_hint_unique ( + H p1, _Args &&...) +{ + _M_get_insert_hint_unique_pos (p1); +} +namespace { +struct L; +} +void +fn1 () +{ + K<D, L> a; + a[0]; + K<D, int> b; + b[0]; +} diff --git a/gcc/testsuite/g++.dg/ipa/pr63587-2.C b/gcc/testsuite/g++.dg/ipa/pr63587-2.C new file mode 100644 index 0000000000..f31c5bdee4 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr63587-2.C @@ -0,0 +1,250 @@ +// PR ipa/63587 +// { dg-do compile { target c++11 } } +// { dg-options "-O2" } + +namespace boost { +class basic_cstring +{ +public: + basic_cstring (char *); +}; +template <typename> struct identity +{ +}; +struct make_identity; +struct function_buffer +{ +}; +template <typename FunctionObj> struct function_obj_invoker0 +{ + static int + invoke (function_buffer &) + { + FunctionObj f; + f (); + } +}; +template <typename FunctionObj> struct get_function_obj_invoker0 +{ + typedef function_obj_invoker0<FunctionObj> type; +}; +template <typename FunctionObj> struct apply +{ + typedef typename get_function_obj_invoker0<FunctionObj>::type invoker_type; +}; +struct basic_vtable0 +{ + typedef int (*invoker_type)(function_buffer &); + template <typename F> void assign_to (F, function_buffer); + invoker_type invoker; +}; +class function0 +{ +public: + template <typename Functor> function0 (Functor) + { + typedef typename apply<Functor>::invoker_type invoker_type; + basic_vtable0 stored_vtable { invoker_type::invoke }; + stored_vtable.assign_to (0, functor); + } + function_buffer functor; +}; +class function : function0 +{ +public: + template <typename Functor> function (Functor f) : function0 (f) {} +}; +class test_unit_generator +{ +}; +class test_case +{ +public: + test_case (basic_cstring, basic_cstring, int, function); +}; +struct auto_test_unit_registrar +{ + auto_test_unit_registrar (test_unit_generator); +}; +template <typename F> F unwrap (F, int); +struct for_each_impl +{ + template <typename Iterator, typename LastIterator, typename TransformFunc, + typename F> + static void + execute (Iterator, LastIterator, TransformFunc, F f) + { + identity<char> __trans_tmp_1; + unwrap (f, 0)(__trans_tmp_1); + } +}; +template <typename, typename, typename F> +void +for_each (F f) +{ + for_each_impl::execute (0, 0, 0, f); +} +template <typename TestCaseTemplate> class test_case_template_invoker +{ +public: + void operator()() + { + TestCaseTemplate::run (0); + } +}; +template <typename Generator, typename TestCaseTemplate> +struct generate_test_case_4_type +{ + generate_test_case_4_type (basic_cstring, basic_cstring, int, Generator G) + : m_test_case_name (0), m_test_case_file (0), m_holder (G) + { + } + template <typename TestType> void operator()(identity<TestType>) + { + test_case (0, 0, 0, test_case_template_invoker<TestCaseTemplate> ()); + } + basic_cstring m_test_case_name; + basic_cstring m_test_case_file; + Generator m_holder; +}; +template <typename TestCaseTemplate> +class template_test_case_gen : public test_unit_generator +{ +public: + template_test_case_gen (basic_cstring, basic_cstring, int) + { + for_each<int, make_identity> ( + generate_test_case_4_type<template_test_case_gen, TestCaseTemplate> ( + 0, 0, 0, *this)); + } +}; +class attribute_name +{ + int m_id; + +public: + attribute_name (char); +}; +template <typename> struct term; +namespace exprns_ { +template <typename> struct expr; +} +using exprns_::expr; +template <typename T> struct Trans_NS_proto_terminal +{ + typedef expr<term<T> > type; +}; +namespace exprns_ { +template <typename Arg0> struct expr<term<Arg0> > +{ + Arg0 child0; +}; +} +template <typename Expr> struct actor +{ + typename Trans_NS_proto_terminal<Expr>::type proto_expr_; +}; +template <template <typename> class Actor = actor> struct terminal +{ + typedef Actor<int> type; +}; +namespace log { +struct to_log_fun +{ +}; +class value_extractor; +template <typename, typename = value_extractor, typename = void, + template <typename> class = actor> +class attribute_actor; +class attribute_terminal +{ +public: + attribute_name m_name; + attribute_name + get_name () + { + return m_name; + } +}; +template <typename, typename, typename, template <typename> class ActorT> +class attribute_actor : ActorT<attribute_terminal> +{ +public: + typedef int value_type; + attribute_name + get_name () + { + return this->proto_expr_.child0.get_name (); + } +}; +template <typename AttributeValueT> +attribute_actor<AttributeValueT> attr (attribute_name); +terminal<>::type stream; +template <typename LeftT, typename ImplT> class attribute_output_terminal +{ +public: + template <typename U> + attribute_output_terminal (LeftT, attribute_name, ImplT, U); +}; +template <typename LeftT> struct make_output_expression +{ + typedef attribute_output_terminal<LeftT, to_log_fun> type; + template <typename RightT> + static type + make (LeftT left, RightT &right) + { + type (left, right.get_name (), to_log_fun (), 0); + } +}; +template <typename, typename RightT, typename = typename RightT::value_type> +struct make_output_actor; +template <template <typename> class ActorT, typename LeftExprT, + typename RightT, typename ValueT> +struct make_output_actor<ActorT<LeftExprT>, RightT, ValueT> +{ + typedef make_output_expression<ActorT<LeftExprT> > make_expression; + typedef ActorT<typename make_expression::type> type; + static type + make (ActorT<LeftExprT> left, RightT &right) + { + type { make_expression::make (left, right) }; + } +}; +template <typename LeftExprT, typename T, typename FallbackPolicyT, + typename TagT> +typename make_output_actor<actor<LeftExprT>, attribute_actor<TagT> >::type +operator<<(actor<LeftExprT> left, + attribute_actor<T, FallbackPolicyT, TagT> right) +{ + make_output_actor<actor<LeftExprT>, attribute_actor<T> >::make (left, right); +} +} +} +namespace logging = boost::log; +namespace expr = logging; +namespace { +class my_class; +} +template <typename> struct default_formatting +{ + void test_method (); +}; +struct default_formatting_invoker +{ + static void + run (void *) + { + default_formatting<int> t; + t.test_method (); + } +}; +boost::auto_test_unit_registrar default_formatting_registrar56 ( + boost::template_test_case_gen<default_formatting_invoker> (0, 0, 0)); +template <typename CharT> +void +default_formatting<CharT>::test_method () +{ + expr::stream << expr::attr<my_class> (0); + expr::stream << expr::attr<int> (0) << expr::attr<int> (0) + << expr::attr<int> (0); +} diff --git a/gcc/testsuite/g++.dg/ipa/pr63595.C b/gcc/testsuite/g++.dg/ipa/pr63595.C new file mode 100644 index 0000000000..48ba4193b7 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr63595.C @@ -0,0 +1,80 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-ipa-icf-details" } */ + +template <int dim> class B; +template <int, int dim> class TriaObjectAccessor; +template <int, typename Accessor> class A; +template <int dim> class TriaDimensionInfo { +public: + typedef A<3, TriaObjectAccessor<2, 3> > raw_quad_iterator; + typedef A<3, B<3> > raw_hex_iterator; + typedef raw_hex_iterator raw_cell_iterator; +}; +template <int dim> class Triangulation : public TriaDimensionInfo<1> { + public: + typedef typename TriaDimensionInfo<dim>::raw_quad_iterator raw_quad_iterator; + TriaDimensionInfo::raw_cell_iterator end() const; + raw_quad_iterator end_quad() const { + return raw_quad_iterator(const_cast<Triangulation *>(this), 0, 0); + } +}; +template <int dim> class TriaAccessor { +public: + typedef void AccessorData; + TriaAccessor(const Triangulation<dim> * = 0); + Triangulation<1> *tria; + + int a, b, c; +}; +template <int dim> class TriaObjectAccessor<2, dim> : public TriaAccessor<dim> { +public: + typedef typename TriaAccessor<dim>::AccessorData AccessorData; + TriaObjectAccessor(const Triangulation<dim> * = 0); +}; +template <int dim> class TriaObjectAccessor<3, dim> : public TriaAccessor<dim> { +public: + typedef typename TriaAccessor<dim>::AccessorData AccessorData; + TriaObjectAccessor(const Triangulation<dim> * = 0); +}; +template <int dim> class B : public TriaObjectAccessor<dim, dim> { +public: + typedef typename TriaObjectAccessor<dim, dim>::AccessorData AccessorData; + B(const Triangulation<dim> * = 0); +}; +template <int dim, typename Accessor> class A { +public: + A(const A &); + A(const Triangulation<dim> *, int, int); + Accessor accessor; +}; +template class Triangulation<3>; +template <int dim, typename Accessor> +A<dim, Accessor>::A(const Triangulation<dim> *, int, int) {} +template <int dim> +TriaAccessor<dim>::TriaAccessor(const Triangulation<dim> *) + : tria(), a(-1), b(-2), c(-3) {} +template <int dim> +TriaObjectAccessor<2, dim>::TriaObjectAccessor(const Triangulation<dim> *) {} +template <int dim> +TriaObjectAccessor<3, dim>::TriaObjectAccessor(const Triangulation<dim> *) {} +template <int dim> B<dim>::B(const Triangulation<dim> *) {} +template <> +TriaDimensionInfo<3>::raw_cell_iterator Triangulation<3>::end() const { + return raw_hex_iterator(const_cast<Triangulation *>(this), 0, 0); +} + +#pragma GCC optimize ("-O0") +int main() +{ + Triangulation <3> t; + Triangulation<3>::raw_quad_iterator i1 = t.end_quad(); + TriaDimensionInfo<3>::raw_cell_iterator i2 = t.end(); + + if(i2.accessor.c != -3) + return 1; + + return 0; +} + +/* { dg-final { scan-ipa-dump "Equal symbols: 0" "icf" } } */ +/* { dg-final { cleanup-ipa-dump "icf" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/pr63621.C b/gcc/testsuite/g++.dg/ipa/pr63621.C new file mode 100644 index 0000000000..3fe3f2f2c4 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr63621.C @@ -0,0 +1,30 @@ +// { dg-do compile } +// { dg-require-effective-target named_sections } + class A +{ + public: + int __attribute__((section("a"))) f1(bool); + int f2(void *); + int f3(bool); +}; + +inline int A::f1(bool b) +{ + static int c; + if (c) + ; + return 0; +} + +inline int A::f3(bool b) +{ + static __attribute__((section(""))) int c; + if (c) + ; + return 0; +} + +int A::f2(void *c) +{ + return f1(c) + f3(c); +} diff --git a/gcc/testsuite/g++.dg/ipa/pr63814.C b/gcc/testsuite/g++.dg/ipa/pr63814.C new file mode 100644 index 0000000000..15a7dda20b --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr63814.C @@ -0,0 +1,29 @@ +// { dg-do run { target fpic } } +// { dg-options "-O3 -fpic" } + +struct CBase { + virtual void BaseFunc () {} +}; + +struct MMixin { + virtual void * MixinFunc (int, int) = 0; +}; + +struct CExample: CBase, public MMixin +{ + void *MixinFunc (int arg, int arg2) + { + return this; + } +}; + +void *test (MMixin & anExample) +{ + return anExample.MixinFunc (0, 0); +} + +int main () +{ + CExample c; + return (test (c) != &c); +} diff --git a/gcc/testsuite/g++.dg/ipa/pr63838.C b/gcc/testsuite/g++.dg/ipa/pr63838.C new file mode 100644 index 0000000000..d673649008 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr63838.C @@ -0,0 +1,56 @@ +// PR ipa/63838 +// { dg-do run } +// { dg-options "-O2 -fdump-ipa-pure-const" } +// { dg-final { scan-ipa-dump-not "Function found to be nothrow: void foo" "pure-const" } } +// { dg-final { scan-ipa-dump-not "Function found to be nothrow: void bar" "pure-const" } } +// { dg-final { cleanup-ipa-dump "pure-const" } } + +__attribute__((noinline, noclone)) static void bar (int); +volatile int v; +void (*fn) (); +struct S { S () { v++; } ~S () { v++; } }; + +__attribute__((noinline, noclone)) static void +foo (int x) +{ + v++; + if (x == 5) + bar (x); +} + +__attribute__((noinline, noclone)) static void +bar (int x) +{ + v++; + if (x == 6) + foo (x); + else if (x == 5) + fn (); +} + +__attribute__((noinline, noclone)) int +baz (int x) +{ + S s; + foo (x); +} + +void +throw0 () +{ + throw 0; +} + +int +main () +{ + fn = throw0; + asm volatile ("" : : : "memory"); + try + { + baz (5); + } + catch (int) + { + } +} diff --git a/gcc/testsuite/g++.dg/ipa/pr63894.C b/gcc/testsuite/g++.dg/ipa/pr63894.C new file mode 100644 index 0000000000..5440975275 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr63894.C @@ -0,0 +1,46 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +struct A +{ + void *operator new(__SIZE_TYPE__, int); +}; +class C +{ +public: + C (int); +}; +class D +{ +public: + enum Type + { + BOX + }; + D (int, Type, C); +}; +class F +{ +public: + virtual void m_fn1 (int, D); +}; +class G : public F, public A +{ +}; +class K : public G +{ +public: + K (C, D); +}; +class J +{ + D m_fn2 (int); + bool m_fn3 (G *); +}; +bool +J::m_fn3 (G *p1) +{ + p1->m_fn1 (0, D (0, D::BOX, 0)); + K *d = new (0) K (0, m_fn2 (0)); + m_fn3 (d); +} diff --git a/gcc/testsuite/g++.dg/ipa/pr64049-1.C b/gcc/testsuite/g++.dg/ipa/pr64049-1.C new file mode 100644 index 0000000000..3b2d7b6b70 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr64049-1.C @@ -0,0 +1,37 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-ipa-inline" } */ + +#include "pr64049.h" + +EnumStatusCode +ValueHelper::getLocalizedText (const ValueStruct* pValueStruct, LocalizedText& target) +{ + if (pValueStruct && pValueStruct->dataType == 0 && pValueStruct->arrayType == 0) + { + _ASSERTION (pValueStruct->value.LocalizedText, "Unexpected null pointer"); + return LocalizedTextSet (target.getInternHandle (), pValueStruct->value.LocalizedText); + } + else + { + return StatusCode::ERROR; + } +} + +LocalizedText +ValueHelper::getLocalizedText (const ValueStruct* pValueStruct) +{ + LocalizedText returnValue; + EnumStatusCode status = getLocalizedText (pValueStruct, returnValue); + _ASSERTION (StatusCode::isSUCCEEDED (status), "Conversion failed"); + return returnValue; +} + +EnumStatusCode +LocalizedTextSet (LocalizedTextStruct* pTarget, LocalizedTextStruct* pSource) +{ + __builtin_strcpy (pTarget->getT (), pSource->getT ()); + return StatusCode::SUCCESS; +} + +/* { dg-final { scan-ipa-dump-not "__builtin_unreachable" "inline" } } */ +/* { dg-final { cleanup-ipa-dump "inline" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/pr64049-2.C b/gcc/testsuite/g++.dg/ipa/pr64049-2.C new file mode 100644 index 0000000000..94493753c8 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr64049-2.C @@ -0,0 +1,23 @@ +/* { dg-do run } */ +/* { dg-options "-O3 ${srcdir}/g++.dg/ipa/pr64049-1.C" } */ + +#include "pr64049.h" + +int +main () +{ + ValueStruct v; + v.arrayType = 0; + v.dataType = 0; + v.value.LocalizedText = new LocalizedTextStruct ("Localized Text"); + LocalizedText t = ValueHelper::getLocalizedText (&v); + if (__builtin_strcmp (t.getInternHandle ()->getT (), "Localized Text")) + __builtin_abort (); + return 0; +} + +LocalizedTextStruct* +LocalizedText::getInternHandle () +{ + return &t; +} diff --git a/gcc/testsuite/g++.dg/ipa/pr64049.h b/gcc/testsuite/g++.dg/ipa/pr64049.h new file mode 100644 index 0000000000..9e28999344 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr64049.h @@ -0,0 +1,53 @@ +#define _ASSERTION(expr, message) { if (!(expr)) __builtin_abort (); } (void)0 + +typedef unsigned int EnumStatusCode; + +class StatusCode +{ +public: + static const EnumStatusCode ERROR = 0x8000; + static const EnumStatusCode SUCCESS = 0x0000; + static bool isSUCCEEDED (EnumStatusCode res) { return (res == SUCCESS); } +}; + +class LocalizedTextStruct +{ +public: + LocalizedTextStruct () {} + LocalizedTextStruct (const char *val) + { + __builtin_strcpy (t, val); + } + char *getT () { return t; } +private: + char t[99]; +}; + +typedef union tagValueUnion +{ + LocalizedTextStruct* LocalizedText; +} ValueStructUnion; + +typedef struct ValueStruct +{ + unsigned char arrayType; + unsigned short dataType; + ValueStructUnion value; +} ValueStruct; + +class LocalizedText +{ +public: + virtual LocalizedTextStruct* getInternHandle (); +private: + LocalizedTextStruct t; +}; + +class ValueHelper +{ +public: + static EnumStatusCode getLocalizedText (const ValueStruct* pValueStruct, LocalizedText& target); + static LocalizedText getLocalizedText (const ValueStruct* pValueStruct); +}; + +EnumStatusCode LocalizedTextSet (LocalizedTextStruct* pTarget, LocalizedTextStruct* pSource); diff --git a/gcc/testsuite/g++.dg/ipa/pr64059.C b/gcc/testsuite/g++.dg/ipa/pr64059.C new file mode 100644 index 0000000000..0269b45458 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr64059.C @@ -0,0 +1,56 @@ +// { dg-options "-r -nostdlib -O2 -flto -fno-devirtualize" } +// { dg-require-effective-target lto } + +class A; +class B +{ +public: + A *operator->(); +}; +class C +{ +public: + virtual void m_fn1 (); +}; +class A +{ +public: + C *m_fn2 (); +}; +class D +{ +public: + void + m_fn3 () + { + list_m->m_fn2 ()->m_fn1 (); + } + B list_m; +}; + +class F +{ +public: + D m_fn4 (); +}; +class G +{ +public: + F m_fn5 (int, int); +}; +class H +{ +public: + void + m_fn6 () + { + fieldEngine_m.m_fn5 (0, 0).m_fn4 ().m_fn3 (); + } + G fieldEngine_m; +}; + +void +fn1 (H a) +{ + a.m_fn6 (); +} diff --git a/gcc/testsuite/g++.dg/ipa/pr64068.C b/gcc/testsuite/g++.dg/ipa/pr64068.C new file mode 100644 index 0000000000..95288836c3 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr64068.C @@ -0,0 +1,49 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef int PROV_ENUMALGS_EX, PCCRYPT_OID_INFO; +class A { + int m_fn2(); + virtual bool m_fn1(PCCRYPT_OID_INFO); +}; +int fn1(); +void fn2(); +int A::m_fn2() { m_fn1(0); } + +bool fn3() { + for (;;) { + if (fn1()) { + if (fn1() != 259) + fn2(); + break; + } + return 1; + } + return 0; +} + +class B { +public: + B() { fn3(); } +}; +class C : A { + bool m_fn1(PCCRYPT_OID_INFO) { m_fn3(); } + int isSupportedByProvider_algId; + PROV_ENUMALGS_EX isSupportedByProvider_outEnumAlgs; + PROV_ENUMALGS_EX isSupportedByProvider_enumAlgs; + bool m_fn3() { + while (1) { + if (fn1()) { + if (fn1() != 259) + fn2(); + break; + } + if (isSupportedByProvider_algId) + isSupportedByProvider_outEnumAlgs = isSupportedByProvider_enumAlgs; + return 1; + } + return 0; + } +}; + +void fn4() { B(); } diff --git a/gcc/testsuite/g++.dg/ipa/pr64146.C b/gcc/testsuite/g++.dg/ipa/pr64146.C new file mode 100644 index 0000000000..773d1c1afc --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr64146.C @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-require-alias "" } */ +/* { dg-require-effective-target fpic } */ +/* { dg-options "-fpic -fdump-ipa-icf-details -fipa-icf" } */ + +extern "C" const char* +foo() +{ + return "original"; +} + +const char* +test_foo() +{ + return foo(); +} + +extern "C" const char* +bar() +{ + return "original"; +} + +const char* +test_bar() +{ + return bar(); +} + +int main (int argc, char **argv) +{ + test_foo (); + test_bar (); + + return 0; +} + +/* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf" } } */ +/* { dg-final { cleanup-ipa-dump "icf" } } */ diff --git a/gcc/testsuite/g++.dg/ipa/pr64612.C b/gcc/testsuite/g++.dg/ipa/pr64612.C new file mode 100644 index 0000000000..b6fe39a374 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr64612.C @@ -0,0 +1,66 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -std=c++11" } */ +/* { dg-final { scan-assembler "_ZN5QListI7QStringED1Ev" { target comdat_group } } } */ + +class A +{ +public: + bool deref (); +}; +class QString; +struct B +{ + A ref; +}; +template <typename> class QList +{ + B d; +public: + ~QList (); + class const_iterator + { + }; + const_iterator constBegin (); + void clear (); + void dealloc (); +}; +template <typename T> QList<T>::~QList () +{ + if (d.ref.deref ()) + dealloc (); +} +template <typename T> +void +QList<T>::clear () +{ + QList (); +} +class A1 : public QList<QString> +{ +}; +class B1 +{ +public: + B1 (A1); +}; +struct F +{ + void addMatch (const QString &&); + A1 m_matchingMimeTypes; +}; +class G +{ + A1 matchingGlobs (const QString &) const; +}; +void +F::addMatch (const QString &&) +{ + m_matchingMimeTypes.clear (); +} +A1 +G::matchingGlobs (const QString &) const +{ + A1 a; + for (B1 b (a);;) + ; +} diff --git a/gcc/testsuite/g++.dg/ipa/pr64858.C b/gcc/testsuite/g++.dg/ipa/pr64858.C new file mode 100644 index 0000000000..c03feaf656 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr64858.C @@ -0,0 +1,93 @@ +// { dg-do compile } +// { dg-options "-O2 -std=gnu++11" } + +template <class reference_type> class A +{ + reference_type *m_pBody; +public: + A (const A &) { m_pBody->acquire (); } +}; +class B; +class C +{ +protected: + B *_pInterface; +}; +template <class interface_type> class I : C +{ +public: + I (interface_type *); +}; +class B +{ +public: + virtual void acquire (); +}; +class D +{ +protected: + void acquire (); +}; +template <class Ifc1> class J : D, public Ifc1 +{ + void + acquire () + { + D::acquire (); + } +}; +class K : B +{ +}; +class L; +class F +{ + A<L> m_pDocument; + F (A<L> const &, int &&); +}; +class XUnoTunnel; +class XEventTarget; +template <class, class> class WeakImplHelper3 : D, B +{ + void + acquire () + { + D::acquire (); + } +}; +template <class> class G +{ +public: + void + acquire () + { + WeakImplHelper3<XUnoTunnel, XEventTarget> (); + } +}; +struct H +{ + H () + : mxAttribList (new J<B>), mxCurrentHandler (0), mxDocHandler (0), + mxTokenHandler (0) + { + } + I<J<B> > mxAttribList; + I<int> mxCurrentHandler; + I<int> mxDocHandler; + I<int> mxTokenHandler; +}; +class L : public G<int> +{ +}; +class M : public J<K> +{ +public: + M (); +}; +template <class interface_type> I<interface_type>::I (interface_type *p1) +{ + B *a = static_cast<B *> (static_cast<void *> (p1)); + _pInterface = a; + _pInterface->acquire (); +} +F::F (A<L> const &p1, int &&) : m_pDocument (p1) { I<K> (new M); } diff --git a/gcc/testsuite/g++.dg/ipa/pr64896.C b/gcc/testsuite/g++.dg/ipa/pr64896.C new file mode 100644 index 0000000000..0a78220be8 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr64896.C @@ -0,0 +1,29 @@ +// PR ipa/64896 +// { dg-do compile } +// { dg-options "-O2" } + +struct A { int a, b; }; +struct B { A c; int d; }; +struct C { virtual B fn1 () const; }; +struct D { B fn2 () const; int fn3 () const; C *fn4 () const; }; + +int +D::fn3 () const +{ + fn4 ()->fn1 (); +} + +B +D::fn2 () const +{ + return B (); +} + +class F : C +{ + B + fn1 () const + { + return B (); + } +}; diff --git a/gcc/testsuite/g++.dg/ipa/pr65002.C b/gcc/testsuite/g++.dg/ipa/pr65002.C new file mode 100644 index 0000000000..ac7c66bd19 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr65002.C @@ -0,0 +1,26 @@ +/* PR tree-optimization/65002 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +namespace fastmath { + template <typename T> float floor(const T &) __attribute__((const)); + template <typename T> float floor(const T &p1) { return p1; } +} +using fastmath::floor; +class A { +public: + A(int, int); + virtual int m_fn1(float) const; +}; +class B : A { +public: + B(int, int p2) : A(entity, p2) {} + int m_fn1(float p1) const { long b(floor(p1)); } + int entity; +}; + +int a; +void Convert() { + if (int *c = 0) + B(*c, a); +} diff --git a/gcc/testsuite/g++.dg/ipa/pr65008.C b/gcc/testsuite/g++.dg/ipa/pr65008.C new file mode 100644 index 0000000000..29b3a2f161 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr65008.C @@ -0,0 +1,19 @@ +// PR ipa/65008 +// { dg-do compile } +// { dg-options "-O2" } + +struct A +{ + A (); + virtual void foo () {} +}; + +static inline int __attribute__ ((always_inline)) call_foo (A *a) +{ + a->foo (); +} + +A::A () +{ + call_foo (this); +} diff --git a/gcc/testsuite/g++.dg/ipa/pr65034.C b/gcc/testsuite/g++.dg/ipa/pr65034.C new file mode 100644 index 0000000000..cb33d5056c --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr65034.C @@ -0,0 +1,40 @@ +// PR ipa/65034 +// { dg-do compile } +// { dg-options "-g -O2" } + +enum B { C }; +enum D { E }; +struct A { A (B, D) { } }; +struct F { unsigned g, h, i, j; } a; + +void +foo (unsigned x, unsigned y) +{ + switch (x) + { + case 6: + a.i = y; + break; + case 7: + a.j = y; + break; + default: + A (C, E); + } +} + +void +bar (unsigned x, unsigned y) +{ + switch (x) + { + case 6: + a.i = y; + break; + case 7: + a.j = y; + break; + default: + A (C, E); + } +} diff --git a/gcc/testsuite/g++.dg/ipa/pr65263.C b/gcc/testsuite/g++.dg/ipa/pr65263.C new file mode 100644 index 0000000000..34459a2667 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr65263.C @@ -0,0 +1,49 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -c -w" } */ + +template <class> class A; +template <class R> struct VirtualMatrice { + virtual bool m_fn1(int) const { return true; } + struct B { + A<R> x; + B(VirtualMatrice *p1, A<R> p2) : x(p2) { p1->m_fn1(0) ?: throw; } + }; + void operator*(A<R> p1) { B(this, p1); } + ~VirtualMatrice(); +} +; +template <class> class A { +public: + operator int *(); + A(int *, long); +}; + +class G : public A<int> { +public: + G(long); +}; +int typedef Complex; +template <class> class H : VirtualMatrice<int> {}; +template <class> class C; +template <> class C<int> : H<Complex>, VirtualMatrice<Complex> { + bool m_fn1(int) const { return true; } +}; +template <class K, class Mat> +void DoIdoAction(int, int, A<K> p3, A<K>, A<K>, A<K>, Mat, Mat &p8) { + p8 *p3; +} + +class D { + typedef int K; + class F { + int operator()() const; + }; +}; +int D::F::operator()() const { + VirtualMatrice<K> *a; + VirtualMatrice<K> b, &B = *a; + G c(0), g(1); + int d, e, f; + A<K> h(&g[f], 0), i(&g[e], 0), j(&g[d], 0); + DoIdoAction(0, 3, h, i, j, c, b, B); +} diff --git a/gcc/testsuite/g++.dg/ipa/pr65465.C b/gcc/testsuite/g++.dg/ipa/pr65465.C new file mode 100644 index 0000000000..436d88f743 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr65465.C @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +struct A {}; +struct B { virtual A foo () const; }; +struct C { A foo () const; }; +struct D : virtual B { A foo () const {} }; +struct F : D { virtual int bar () const; }; +int F::bar () const { return 0; } +A C::foo () const { return A (); } diff --git a/gcc/testsuite/g++.dg/ipa/pr65557.C b/gcc/testsuite/g++.dg/ipa/pr65557.C new file mode 100644 index 0000000000..2250bb079b --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr65557.C @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-ipa-icf-details" } */ + +struct S0 +{ + S0 () + { + } +}; + +struct S1 +{ + S1 () + { + } +}; + +S0 s0; +S1 s1; diff --git a/gcc/testsuite/g++.dg/ipa/pr65722.C b/gcc/testsuite/g++.dg/ipa/pr65722.C new file mode 100644 index 0000000000..ee4ea24c25 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr65722.C @@ -0,0 +1,21 @@ +// { dg-do compile } +// { dg-options "-O -fipa-icf -fno-rtti" } + +struct A +{ + virtual void f () + { + __builtin_abort (); + } + virtual void g (); +}; + +struct B : virtual A { }; +struct C : B, virtual A { }; + +void foo() +{ + C c; + C *p = &c; + p->f (); +} diff --git a/gcc/testsuite/g++.dg/ipa/pr65765.C b/gcc/testsuite/g++.dg/ipa/pr65765.C new file mode 100644 index 0000000000..ff8dc33a1a --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr65765.C @@ -0,0 +1,45 @@ +// PR ipa/65765 +// { dg-do run } +// { dg-options "-O2" } + +int a, b, c, d, e; +unsigned char h[] = { 1, 1 }; + +__attribute__ ((cold)) int ModRM_Mode () { return a; } + +int +ModRM_RM (int p1) +{ + return p1; +} + +__attribute__ ((cold)) static bool ModRM_hasSIB (unsigned char p1) +{ + return ModRM_Mode () != 1 && ModRM_RM (p1); +} + +__attribute__ ((cold)) static bool ModRM_hasRIP (unsigned char p1) +{ + return ModRM_Mode () && ModRM_RM (p1); +} + +unsigned char * +DisassembleHeapAccess (unsigned char *p1) +{ + b = *p1++; + if (ModRM_hasSIB (b)) + c = *p1++; + int f = c, g = 0; + d = ModRM_hasRIP (g); + e = f == 0; + if (e) + p1 += sizeof 0; + return p1; +} + +int +main () +{ + if (DisassembleHeapAccess (h) != h + 2) + __builtin_abort (); +} diff --git a/gcc/testsuite/g++.dg/lookup/conv-1.C b/gcc/testsuite/g++.dg/lookup/conv-1.C index 0c4393e8a4..b861c6036d 100644 --- a/gcc/testsuite/g++.dg/lookup/conv-1.C +++ b/gcc/testsuite/g++.dg/lookup/conv-1.C @@ -22,6 +22,5 @@ struct B : A1, A2 int Foo (B const &b) { return b; // { dg-error "ambiguous" "" } - // { dg-message "candidate" "candidate note" { target *-*-* } 24 } } diff --git a/gcc/testsuite/g++.dg/lookup/new1.C b/gcc/testsuite/g++.dg/lookup/new1.C index 11a6d97ddf..3c3b02b3d8 100644 --- a/gcc/testsuite/g++.dg/lookup/new1.C +++ b/gcc/testsuite/g++.dg/lookup/new1.C @@ -6,7 +6,6 @@ int main() { int i; void* operator new(__SIZE_TYPE__ s, int* p); int* e = new(&i) int; // { dg-error "no matching function" } - // { dg-message "candidate" "candidate note" { target *-*-* } 8 } int* f = new int; return 0; } diff --git a/gcc/testsuite/g++.dg/lookup/scoped8.C b/gcc/testsuite/g++.dg/lookup/scoped8.C index 2764f75c13..c5645ee372 100644 --- a/gcc/testsuite/g++.dg/lookup/scoped8.C +++ b/gcc/testsuite/g++.dg/lookup/scoped8.C @@ -7,12 +7,12 @@ struct A { - int i; // { dg-error "non-static" } + int i; // { dg-message "" } }; template <int> struct B { - int foo() { return A::i; } // { dg-error "this location" } + int foo() { return A::i; } // { dg-error "non-static" } }; template struct B<0>; diff --git a/gcc/testsuite/g++.dg/lookup/two-stage4.C b/gcc/testsuite/g++.dg/lookup/two-stage4.C index bbb44afa0d..7d971094d1 100644 --- a/gcc/testsuite/g++.dg/lookup/two-stage4.C +++ b/gcc/testsuite/g++.dg/lookup/two-stage4.C @@ -3,15 +3,15 @@ template<class T> struct wrap {}; -template<typename T> bool& operator==(wrap<T>, wrap<T>); +template<typename T> bool operator==(wrap<T>, wrap<T>); template<typename T> void g(T, wrap<wrap<int> > x) { - bool& b = x == x; // { dg-bogus "invalid initialization of reference" "" { xfail *-*-*} } + bool b = x == x; // { dg-bogus "" "" { xfail *-*-* } } } -template<typename T> int& operator==(wrap<wrap<T> >, wrap<wrap<T> >); +template<typename T> void operator==(wrap<wrap<T> >, wrap<wrap<T> >); void h() { diff --git a/gcc/testsuite/g++.dg/lookup/using54.C b/gcc/testsuite/g++.dg/lookup/using54.C new file mode 100644 index 0000000000..680bdadaa2 --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/using54.C @@ -0,0 +1,16 @@ +// PR c++/60894 + +struct B +{ + struct S {}; +}; + +struct D : B +{ + using B::S; + void doIt(struct S&); +}; + +void D::doIt(struct S&) +{ +} diff --git a/gcc/testsuite/g++.dg/lookup/using9.C b/gcc/testsuite/g++.dg/lookup/using9.C index fd3e788638..7b0ccd1f60 100644 --- a/gcc/testsuite/g++.dg/lookup/using9.C +++ b/gcc/testsuite/g++.dg/lookup/using9.C @@ -20,7 +20,6 @@ void h() using C::f; f('h'); f(1); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 22 } void f(int); // { dg-error "previous declaration" } } diff --git a/gcc/testsuite/g++.dg/lto/lto.exp b/gcc/testsuite/g++.dg/lto/lto.exp index 4d7d727b98..f165362227 100644 --- a/gcc/testsuite/g++.dg/lto/lto.exp +++ b/gcc/testsuite/g++.dg/lto/lto.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2009-2014 Free Software Foundation, Inc. +# Copyright (C) 2009-2015 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/gcc/testsuite/g++.dg/lto/pr54625-1_0.c b/gcc/testsuite/g++.dg/lto/pr54625-1_0.c index 5ab90dddde..48bbdf02de 100644 --- a/gcc/testsuite/g++.dg/lto/pr54625-1_0.c +++ b/gcc/testsuite/g++.dg/lto/pr54625-1_0.c @@ -3,6 +3,7 @@ float a; double sin (); +void speex_resampler_init_frac () { a = sin (0); diff --git a/gcc/testsuite/g++.dg/lto/pr54625-2_0.c b/gcc/testsuite/g++.dg/lto/pr54625-2_0.c index 6511ba5cc6..3e67d4f5b4 100644 --- a/gcc/testsuite/g++.dg/lto/pr54625-2_0.c +++ b/gcc/testsuite/g++.dg/lto/pr54625-2_0.c @@ -3,6 +3,7 @@ float a; double sin (); +void update_filter () { a = sin (0); diff --git a/gcc/testsuite/g++.dg/lto/pr63166_0.ii b/gcc/testsuite/g++.dg/lto/pr63166_0.ii new file mode 100644 index 0000000000..f8ef712086 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr63166_0.ii @@ -0,0 +1,37 @@ +// { dg-lto-do compile } +extern "C" +{ + extern long unsigned int strlen (__const char *__s); +} +class Cstring +{ +}; +class Foobar_Out +{ + virtual void put_to_buf (const char *str, long unsigned int msg_len); + void put_to_buf (const char *str) + { + put_to_buf (str, strlen (str)); + } + Foobar_Out & operator << (const char *str); + Foobar_Out & operator << (const Cstring & cstring); +}; + +class Foobar_Log:public Foobar_Out +{ + Foobar_Log (int channel); + virtual void put_to_buf (const char *str, long unsigned int msg_len); +}; +Foobar_Out & Foobar_Out::operator << (const char *str) +{ + put_to_buf (str); +} + +Foobar_Out & Foobar_Out::operator << (const Cstring & cstring) +{ + return *this; +} + +Foobar_Log::Foobar_Log (int ch) +{ +} diff --git a/gcc/testsuite/g++.dg/lto/pr63166_1.ii b/gcc/testsuite/g++.dg/lto/pr63166_1.ii new file mode 100644 index 0000000000..29438fe5ed --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr63166_1.ii @@ -0,0 +1,108 @@ +class EIdent { }; +class Cstring { }; +template < class KEY, class VALUE, class HASHER > class HashMapIterator +{ +public: + virtual ~ HashMapIterator () { } +}; + +class ECell; +class ECell_ptr +{ + ECell *mp_element; +public: + ECell * operator -> () const + { + return (mp_element); + } +} +sicat_cmd_status; +class CellListIterator; +class ECellList +{ +public: + virtual CellListIterator * createIterator () const = 0; + virtual ECell_ptr Find (const EIdent & anIdent) = 0; +}; +class Foobar_Out +{ + virtual int get_channel () { } +public: + Foobar_Out & operator << (const char *str); + Foobar_Out & operator << (const Cstring & cstring); +}; + +class Foobar_Log:public Foobar_Out { }; +extern Foobar_Log Foobar_LOG; +template < class KEY > class BagIterator +{ +public: + inline const KEY & operator * () const; + inline int atEnd () const; +}; + +class EMaskView; +class ECell +{ +public: + virtual const EMaskView & getMaskView () const = 0; +}; +class FoobarDatabase +{ +public: + const Cstring & getName (const EIdent & id) const; + ECellList *getCellList (); +}; +inline FoobarDatabase & +DB () { } + +class EMaskView +{ +public: + inline BagIterator < EIdent > getCallerIterator () const; +}; +struct DBHashFunctions +{ +}; +class CellListIterator:public HashMapIterator < EIdent, ECell *, + DBHashFunctions > +{ +}; +class IdentSet +{ +public: + unsigned int getSize () const { } + int isEmpty () const { } +}; +class IdentSetIterator +{ +public: + IdentSetIterator (const IdentSet * p_source) { } + int atEnd () const { } + EIdent operator* () const { } +}; +void +validate () +{ + IdentSet complete_cell_ids; + IdentSet incomplete_cell_ids; + CellListIterator *p_cl_it = DB ().getCellList ()->createIterator (); + delete p_cl_it; + while (!incomplete_cell_ids.isEmpty ()) + { + if (incomplete_cell_ids.getSize () < complete_cell_ids.getSize ()) + { + IdentSetIterator complete_cell_it (&complete_cell_ids); + while (!complete_cell_it.atEnd ()) + { + BagIterator < EIdent > caller_it = + DB ().getCellList ()->Find (*complete_cell_it)-> + getMaskView ().getCallerIterator (); + while (!caller_it.atEnd ()) + { + Foobar_LOG << DB ().getName (*caller_it) << " "; + } + } + } + } +} diff --git a/gcc/testsuite/g++.dg/lto/pr63270.h b/gcc/testsuite/g++.dg/lto/pr63270.h new file mode 100644 index 0000000000..a0a0f58370 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr63270.h @@ -0,0 +1,68 @@ +typedef unsigned long uintptr_t; +namespace v8 { +class Extension; +namespace internal { +class A { +public: + A(int) {}; +}; +class B { +public: + B(int) {}; +}; +class Scanner; +class FuncNameInferrer; +template <typename Traits> class ParserBase : Traits { + class FunctionState; + bool parenthesized_function_; + typename Traits::Type::Scope *scope_; + FunctionState *function_state_; + v8::Extension *extension_; + FuncNameInferrer *fni_; + Scanner *scanner_; + uintptr_t stack_limit_; + bool stack_overflow_; + bool allow_lazy_; + bool allow_natives_syntax_; + bool allow_generators_; + bool allow_for_of_; + typename Traits::Type::Zone *zone_; +}; +class PreParserScope; +class F; +class PreParserTraits { +public: + struct Type { + typedef PreParserScope Scope; + typedef void Zone; + }; + +private: + F *pre_parser_; +}; +class F : ParserBase<PreParserTraits> {}; +class C { +public: + struct Type { + typedef v8::internal::FuncNameInferrer Scope; + typedef int Zone; + }; +}; +class G : ParserBase<C> { +public: + static int m_fn1(); + static int test(); + F reusable_preparser_; +}; +class D { +public: + D(int a) : function_(0), context_(0), nested_scope_chain_(0) { G::test(); } + B function_; + B context_; + A nested_scope_chain_; +}; +} +} + + + diff --git a/gcc/testsuite/g++.dg/lto/pr63270_0.C b/gcc/testsuite/g++.dg/lto/pr63270_0.C new file mode 100644 index 0000000000..924b238499 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr63270_0.C @@ -0,0 +1,9 @@ +// { dg-lto-do link } +// { dg-lto-options {{-flto -O2 -Wno-odr}} } + +#include "pr63270.h" + +int main() +{ + return 0; +} diff --git a/gcc/testsuite/g++.dg/lto/pr63270_1.C b/gcc/testsuite/g++.dg/lto/pr63270_1.C new file mode 100644 index 0000000000..a842e5cfcc --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr63270_1.C @@ -0,0 +1,53 @@ +typedef unsigned long uintptr_t; +namespace v8 +{ + + int kPointerSize = 0; + + class Extension; + namespace internal + { + class Token; + class Scanner; + int kCodeOffset = 0; + int kOptimizedCodeMapOffset = 0; + int kScopeInfoOffset = 0; + + class FuncNameInferrer; + template < typename Traits > class ParserBase:Traits + { + class FunctionState; + bool parenthesized_function_; + typename Traits::Type::Scope * scope_; + FunctionState *function_state_; + v8::Extension * extension_; + FuncNameInferrer *fni_; + Scanner *scanner_; + uintptr_t stack_limit_; + bool stack_overflow_; + bool allow_lazy_; + bool allow_natives_syntax_; + bool allow_generators_; + bool allow_for_of_; + typename Traits::Type::Zone * zone_; + }; + class PreParserScope; + class PreParser; + class PreParserTraits + { + public:struct Type + { + typedef PreParserScope Scope; + typedef void Zone; + }; + PreParser *pre_parser_; + }; + class PreParser:ParserBase < PreParserTraits > + { + int ParseMemberWithNewPrefixesExpression ( bool * ); + }; + int PreParser::ParseMemberWithNewPrefixesExpression ( bool * ) + { + } + } +} diff --git a/gcc/testsuite/g++.dg/lto/pr63270_2.C b/gcc/testsuite/g++.dg/lto/pr63270_2.C new file mode 100644 index 0000000000..e45ae68602 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr63270_2.C @@ -0,0 +1,8 @@ +// { dg-options "-fno-lto" } + +#include "pr63270.h" + +int v8::internal::G::test() +{ + return 2; +} diff --git a/gcc/testsuite/g++.dg/lto/pr64043_0.C b/gcc/testsuite/g++.dg/lto/pr64043_0.C new file mode 100644 index 0000000000..9cc5596c35 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr64043_0.C @@ -0,0 +1,14 @@ +// { dg-lto-do link } +// { dg-lto-options { { -flto -std=c++11 } } } +// { dg-extra-ld-options "-r -nostdlib -O2" } +class Validator +{ +public: + virtual ~Validator (); +}; +class FooWriter +{ + Validator *validator; + ~FooWriter (); +}; +FooWriter::~FooWriter () { delete validator; } diff --git a/gcc/testsuite/g++.dg/lto/pr64076.H b/gcc/testsuite/g++.dg/lto/pr64076.H new file mode 100644 index 0000000000..6afe37acc9 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr64076.H @@ -0,0 +1,20 @@ +struct Base { + virtual void f() = 0; +}; + +struct X : public Base { }; +struct Y : public Base { }; +struct Z : public Base { }; +struct T : public Base { }; + +struct S : public X, public Y, public Z +#ifdef XXX +, public T +#endif +{ + void f() +#ifdef XXX + { } +#endif + ; +}; diff --git a/gcc/testsuite/g++.dg/lto/pr64076_0.C b/gcc/testsuite/g++.dg/lto/pr64076_0.C new file mode 100644 index 0000000000..fb9b060e32 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr64076_0.C @@ -0,0 +1,10 @@ +// { dg-lto-do link } + +#define XXX +#include "pr64076.H" + +int main() +{ + S s; + return 0; +} diff --git a/gcc/testsuite/g++.dg/lto/pr64076_1.C b/gcc/testsuite/g++.dg/lto/pr64076_1.C new file mode 100644 index 0000000000..4bd00817b1 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr64076_1.C @@ -0,0 +1,5 @@ +// { dg-options -fno-lto } + +#include "pr64076.H" + +void S::f() { } diff --git a/gcc/testsuite/g++.dg/lto/pr65193_0.C b/gcc/testsuite/g++.dg/lto/pr65193_0.C new file mode 100644 index 0000000000..d778fcabb7 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr65193_0.C @@ -0,0 +1,71 @@ +/* { dg-lto-do link } */ +/* { dg-require-effective-target fpic } */ +/* { dg-lto-options {{-fPIC -r -nostdlib -flto -O2 -g}} } */ + +void frexp (int, int *); +namespace std +{ + int ldexp (int, int); + struct A + { + }; + template <class T> T get_min_shift_value (); + template <class> struct min_shift_initializer + { + struct B + { + B () { get_min_shift_value<long double> (); } + } static const b; + static void + m_fn1 () + { + b; + } + }; + template <class T> + const typename min_shift_initializer<T>::B min_shift_initializer<T>::b; + template <class T> + inline T + get_min_shift_value () + { + using std::ldexp; + static T c = ldexp (0, 0); + min_shift_initializer<T>::m_fn1; + } + template <class T, class Policy> + void + float_next_imp (T p1, Policy p2) + { + using std::ldexp; + int d; + float_next (0, p2); + frexp (p1, &d); + } + template <class T, class Policy> + int + float_next (const T &p1, Policy &p2) + { + float_next_imp (p1, p2); + } + template <class T, class Policy> void float_prior_imp (T, Policy) + { + get_min_shift_value<T> (); + } + template <class T, class Policy> int float_prior (T, Policy) + { + float_prior_imp (static_cast<T> (0), 0); + } + template <class T, class U, class Policy> + void + nextafter (T p1, U p2, Policy p3) + { + p2 ? float_next (0, p3) : float_prior (p1, 0); + } + long double e; + int f; + void + nextafter () + { + nextafter (e, f, A ()); + } +} diff --git a/gcc/testsuite/g++.dg/lto/pr65276_0.C b/gcc/testsuite/g++.dg/lto/pr65276_0.C new file mode 100644 index 0000000000..c8e96999dc --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr65276_0.C @@ -0,0 +1,61 @@ +// { dg-lto-do link } +// { dg-lto-options {{-flto -O0 -std=c++11}} } + +/* pr65276_0.C should get compiled with -O0, while the _1.C file + should get compiled with -O2, and the entire thing should be linked + with -O0. Test that we don't get an ICE. */ + +extern "C++" +{ + namespace std + { + class exception + { + public: + virtual ~ exception () noexcept; + }; + } +} +namespace std +{ + struct __cow_string + { + union + { + const char *_M_p; + char _M_bytes[sizeof (const char *)]; + }; + }; + class runtime_error:public exception + { + __cow_string _M_msg; + }; +} +namespace std +{ + class system_error:public std::runtime_error + { + }; + enum _Ios_Fmtflags + { + }; + inline constexpr _Ios_Fmtflags operator& (_Ios_Fmtflags __a, + _Ios_Fmtflags __b) + { + return _Ios_Fmtflags (); + } + enum _Ios_Openmode + { + }; + class ios_base + { + public: + class __attribute ((__abi_tag__ ("cxx11"))) failure:public system_error + { + }; + class Init + { + }; + }; + static ios_base::Init __ioinit; +} diff --git a/gcc/testsuite/g++.dg/lto/pr65276_1.C b/gcc/testsuite/g++.dg/lto/pr65276_1.C new file mode 100644 index 0000000000..ee49752f0f --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr65276_1.C @@ -0,0 +1,34 @@ +// { dg-options "-O2" } +#pragma implementation +#pragma interface +extern "C++" +{ + namespace std + { + class exception + { + public: + virtual ~ exception () noexcept; + }; + } +} +namespace std +{ + struct __cow_string + { + union + { + const char *_M_p; + char _M_bytes[sizeof (const char *)]; + }; + }; + class runtime_error:public exception + { + __cow_string _M_msg; + }; +} + +int main() +{ + return 0; +} diff --git a/gcc/testsuite/g++.dg/lto/pr65302_0.C b/gcc/testsuite/g++.dg/lto/pr65302_0.C new file mode 100644 index 0000000000..2298afd9d9 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr65302_0.C @@ -0,0 +1,99 @@ +// { dg-lto-do link } +// { dg-lto-options { { -flto -O2 } } } +// { dg-extra-ld-options "-r -nostdlib -O0" } + +class CstringStorageReference { + public: + ~CstringStorageReference (); +}; +class Cstring { + CstringStorageReference m_stringRef; + public: + Cstring (const char *str, int l = 0); + unsigned int getLength () const; +}; +class ZEvent_Component { }; +class ZEvent_Data { }; +class ZEvent_Interrupt { }; +class ZEvent_Mouse { }; +class ZEvent_Key { }; +class ZEventHandler { + virtual void HandleEvent (const ZEvent_Component & event); + virtual void HandleEvent (const ZEvent_Mouse & event); + virtual void HandleEvent (const ZEvent_Key & event); + virtual void HandleEvent (const ZEvent_Interrupt & event); + virtual void HandleEvent (const ZEvent_Data & event); +}; +enum ZHorizontalAlignment { HA_Left }; +enum ZVerticalAlignment { VA_Baseline }; +struct ZDevicePointStruct { }; +struct ZDeviceRectangleStruct { }; +struct ZDeviceCircleStruct { }; +class ZOutputDevice; +class Foo; +class ZRubberBand { + public: + ZOutputDevice * getOutputDevice (); +}; +class ZRubberBand2P : public ZRubberBand { + virtual void Init (); + Foo *mp_graphicContext; + int m_textAscent; + int m_OkButtonWidth; + int m_OkButtonHeight; +}; +class ZColor { }; +class ZViewPort2D { }; +class ZCursor; +class ZPixmap; +class ZOutputDevice:public ZEventHandler { +public: + typedef ZHorizontalAlignment THorizontalAlignment; + typedef ZVerticalAlignment TVerticalAlignment; + virtual const char *MyName () const { return ""; } + virtual ~ ZOutputDevice (); + virtual Cstring getTitle () const; + virtual void setTitle (const Cstring &) { } + virtual void Init (); + virtual void shutdown (); + virtual void minimize (); + virtual void normalize (); + virtual void raiseToTop (); + virtual ZViewPort2D GetViewPort () const; + virtual void setBackgroundColor (const ZColor & color) = 0; + virtual void Clear () = 0; + virtual void Flush (int forced) = 0; + virtual void dismissCache () { } + virtual int GetDeviceWidth () const = 0; + virtual int GetDeviceHeight () const = 0; + virtual Foo *CreateGraphicContext () = 0; + virtual ZCursor *createCursor (const ZPixmap &, int, int) { return __null; } + virtual void DrawLine (const Foo & gc, int x1, int y1, int x2, int y2) = 0; + virtual void DrawLines (const Foo & gc, const ZDevicePointStruct * points, unsigned int count) = 0; + virtual void FillPolygon (const Foo & gc, const ZDevicePointStruct * points, unsigned int count) = 0; + virtual void DrawPoint (const Foo & gc, int x1, int y1) = 0; + virtual void DrawPoints (const Foo & gc, const ZDevicePointStruct * points, unsigned int count) = 0; + virtual void DrawRectangle (const Foo & gc, int x, int y, int width, int height) = 0; + virtual void DrawRectangles (const Foo & gc, const ZDeviceRectangleStruct * rectangles, unsigned int count) = 0; + virtual void FillRectangle (const Foo & gc, int x, int y, int width, int height) = 0; + virtual void FillRectangles (const Foo & gc, const ZDeviceRectangleStruct * rectangles, unsigned int count) = 0; + virtual void DrawCircle (const Foo & gc, int x, int y, int radius) = 0; + virtual void DrawCircles (const Foo & gc, const ZDeviceCircleStruct * circle, unsigned int count) = 0; + virtual void FillCircle (const Foo & gc, int x, int y, int radius) = 0; + virtual void FillCircles (const Foo & gc, const ZDeviceCircleStruct * circle, unsigned int count) = 0; + virtual void DrawString (const Foo & gc, int xx, int yy, const Cstring & theString, THorizontalAlignment horAlign = HA_Left, TVerticalAlignment verAlign = VA_Baseline) = 0; + virtual void getStringBounds (const Foo & gc, const Cstring & theString, int & width, int & height, int & ascent) const; +}; +template < class T > class EMaskContentVector +{ + signed m_freelist_idx:32; + EMaskContentVector (const EMaskContentVector < T > &, void *buf); +}; +template < class T > EMaskContentVector < + T >::EMaskContentVector (const EMaskContentVector < T > &elem, void *buf): +m_freelist_idx (-1) +{ +} +void ZRubberBand2P::Init () { + getOutputDevice ()->getStringBounds (*mp_graphicContext, Cstring ("Ok"), m_OkButtonWidth, m_OkButtonHeight, m_textAscent); +} diff --git a/gcc/testsuite/g++.dg/lto/pr65302_1.C b/gcc/testsuite/g++.dg/lto/pr65302_1.C new file mode 100644 index 0000000000..b2ccc2a90b --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr65302_1.C @@ -0,0 +1,83 @@ +#pragma implementation +#pragma interface +class CstringStorageReference { + public: + ~CstringStorageReference (); +}; +class Cstring { + CstringStorageReference m_stringRef; + public: + Cstring (const char *str, int l = 0); + unsigned int getLength () const; +}; +inline unsigned int +Cstring::getLength () const { }; +class ZEvent_Component { }; +class ZEvent_Data { }; +class ZEvent_Interrupt { }; +class ZEvent_Mouse { }; +class ZEvent_Key { }; +class ZEventHandler +{ + virtual void HandleEvent (const ZEvent_Component & event); + virtual void HandleEvent (const ZEvent_Mouse & event); + virtual void HandleEvent (const ZEvent_Key & event); + virtual void HandleEvent (const ZEvent_Interrupt & event); + virtual void HandleEvent (const ZEvent_Data & event); +}; +class ZColor { }; +class ZViewPort2D { }; +enum ZVerticalAlignment { VA_Baseline }; +struct ZDevicePointStruct { }; +class ZCursor; +class ZPixmap; +class Foo; +class ZOutputDevice : public ZEventHandler { + public: + typedef ZVerticalAlignment TVerticalAlignment; + virtual const char *MyName () const { } + virtual ~ ZOutputDevice (); + virtual Cstring getTitle () const; + virtual void setTitle (const Cstring &) { } + virtual void Init (); + virtual void shutdown (); + virtual void minimize (); + virtual void normalize (); + virtual void raiseToTop (); + virtual ZViewPort2D GetViewPort () const; + virtual void setBackgroundColor (const ZColor & color) = 0; + virtual void Clear () = 0; + virtual void Flush (int forced) = 0; + virtual void dismissCache () { } + virtual int GetDeviceWidth () const = 0; + virtual int GetDeviceHeight () const = 0; + virtual Foo *CreateGraphicContext () = 0; + virtual ZCursor *createCursor (const ZPixmap &, int, int) { } + virtual void DrawLine (const Foo & gc, int x1, int y2) = 0; + virtual void DrawLines (const Foo & gc, const ZDevicePointStruct * points, + unsigned int count) = 0; +}; +class ZOutputDevicePS :public ZOutputDevice +{ + virtual void FillPolygon (const Foo & gc, unsigned int count); + virtual void DrawPoint (const Foo & gc, int x1, int y1); + virtual void DrawPoints (const Foo & gc, const ZDevicePointStruct * points, + unsigned int count); + virtual void DrawRectangle (const Foo & gc, int x, int height); + virtual void DrawRectangles (const Foo & gc, unsigned int count); + virtual void FillRectangle (const Foo & gc, int x, int height); + virtual void FillRectangles (const Foo & gc, unsigned int count); + virtual void DrawCircle (const Foo & gc, int x, int y, int radius); + virtual void DrawCircles (const Foo & gc, unsigned int count); + virtual void FillCircle (const Foo & gc, int x, int y, int radius); + virtual void FillCircles (const Foo & gc, unsigned int count); + virtual void DrawString (const Foo & gc, int xx, int yy, + TVerticalAlignment verAlign); + virtual void getStringBounds (const Foo & gc, const Cstring & theString, + int & width, int & height, int & acsent) const; +}; +void +ZOutputDevicePS::getStringBounds (const Foo &, const Cstring & theString, + int & width, int & height, int & ascent) const { + width = theString.getLength () * 8; +} diff --git a/gcc/testsuite/g++.dg/lto/pr65316_0.C b/gcc/testsuite/g++.dg/lto/pr65316_0.C new file mode 100644 index 0000000000..cccd0db7d8 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr65316_0.C @@ -0,0 +1,142 @@ +// { dg-lto-do link } +// { dg-lto-options { { -flto -std=c++11 -g2 -fno-lto-odr-type-merging -O2 } } } +// { dg-extra-ld-options "-r -nostdlib -O2 -fno-lto-odr-type-merging" } +namespace std +{ + typedef long unsigned int size_t; +} +extern "C" +{ + typedef struct + { + } __mbstate_t; +} +namespace std __attribute__ ((__visibility__ ("default"))) +{ + template < class _CharT > struct char_traits; +} + +typedef __mbstate_t mbstate_t; +namespace std __attribute__ ((__visibility__ ("default"))) +{ + template < typename _CharT, typename _Traits = + char_traits < _CharT > >class basic_ostream; + typedef basic_ostream < char >ostream; +} + +using namespace std; +class Cstring +{ +public: + Cstring (const char *str, int l = 0); +}; +extern ostream & operator << (ostream & os, const Cstring & string); +class Foo_Log_Handler +{ + virtual int write_message (const char *msg, size_t msg_len, int channel, + int level) = 0; +}; +class Foo_Log_Handler_Stream:public Foo_Log_Handler +{ + virtual int write_message (const char *msg, size_t msg_len, int channel, + int level) override; + Cstring m_filename; +}; +namespace std __attribute__ ((__visibility__ ("default"))) +{ + template <> struct char_traits <char > + { + typedef mbstate_t state_type; + }; + enum _Ios_Fmtflags + { + }; + enum _Ios_Iostate + { + }; + class ios_base + { + public: + typedef _Ios_Iostate iostate; + }; +} + +namespace std __attribute__ ((__visibility__ ("default"))) +{ + template < typename _CharT > class __ctype_abstract_base + { + }; + template < typename _CharT > class ctype + { + public: + typedef char char_type; + mutable char _M_widen_ok; + char_type widen (char __c) const + { + if (_M_widen_ok) + return this->do_widen (__c); + } + virtual char_type do_widen (char __c) const + { + } + }; + template < typename _Facet > + inline const _Facet & __check_facet (const _Facet * __f) + { + } +template < typename _CharT, typename _Traits > class basic_ios:public + ios_base + { + typedef _CharT char_type; + typedef ctype < _CharT > __ctype_type; + const __ctype_type *_M_ctype; + public: + iostate rdstate ()const + { + } + bool good () const + { + } + char_type widen (char __c) const + { + return __check_facet (_M_ctype).widen (__c); + } + }; +template < typename _CharT, typename _Traits > class basic_ostream:virtual public basic_ios < _CharT, + _Traits + > + { + public: + typedef _CharT char_type; + typedef _Traits traits_type; + typedef basic_ostream < _CharT, _Traits > __ostream_type; + __ostream_type & operator<< (__ostream_type & (*__pf) (__ostream_type &)) + { + return __pf (*this); + } + __ostream_type & put (char_type __c); + }; + template < typename _CharT, + typename _Traits > inline basic_ostream < _CharT, + _Traits > &endl (basic_ostream < _CharT, _Traits > &__os) + { + return flush (__os.put (__os.widen ('\n'))); + } + template < typename _CharT, + typename _Traits > inline basic_ostream < _CharT, + _Traits > &flush (basic_ostream < _CharT, _Traits > &__os) + { + } + extern ostream cerr; +} + +int +Foo_Log_Handler_Stream::write_message (const char *msg, size_t msg_len, int, + int level) +{ + { + { + cerr << "FATAL: cannot write into log file: " << m_filename << endl; + } + } +} diff --git a/gcc/testsuite/g++.dg/lto/pr65316_1.C b/gcc/testsuite/g++.dg/lto/pr65316_1.C new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr65316_1.C diff --git a/gcc/testsuite/g++.dg/lto/pr65475_0.C b/gcc/testsuite/g++.dg/lto/pr65475_0.C new file mode 100644 index 0000000000..3c8665c92a --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr65475_0.C @@ -0,0 +1,9 @@ +/* { dg-lto-do link } */ +/* { dg-lto-options "-O2 -Wno-odr" } */ +/* { dg-extra-ld-options { -O2 -Wno-odr -r -nostdlib } } */ +namespace std { +class ios_base { + struct A {}; + class __attribute((__abi_tag__("cxx11"))) failure : A {}; +} a; +} diff --git a/gcc/testsuite/g++.dg/lto/pr65475_1.C b/gcc/testsuite/g++.dg/lto/pr65475_1.C new file mode 100644 index 0000000000..642a4137f2 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr65475_1.C @@ -0,0 +1,27 @@ +namespace std { +template <typename, typename = int> class Trans_NS___cxx11_basic_ostringstream; +class ios_base { + class __attribute((__abi_tag__("cxx11"))) failure { + virtual char m_fn2(); + }; +}; +class B : virtual ios_base {}; +template <typename, typename> class Trans_NS___cxx11_basic_ostringstream : B { +public: + void m_fn1(); +}; +} + +class A { +public: + A(int) { + std::Trans_NS___cxx11_basic_ostringstream<wchar_t> a; + a.m_fn1(); + } +}; +int b; +void fn1() { (A(b)); } +int +main() +{ +} diff --git a/gcc/testsuite/g++.dg/lto/pr65475b_0.C b/gcc/testsuite/g++.dg/lto/pr65475b_0.C new file mode 100644 index 0000000000..0e5a95c8ee --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr65475b_0.C @@ -0,0 +1,9 @@ +/* { dg-lto-do link } */ +/* { dg-lto-options "-O2 -Wno-odr" } */ +/* { dg-extra-ld-options { -O2 -Wno-odr -r -nostdlib } } */ +namespace std { +class exception {}; +class runtime_error : exception { + virtual char m_fn1(); +} a; +} diff --git a/gcc/testsuite/g++.dg/lto/pr65475b_1.C b/gcc/testsuite/g++.dg/lto/pr65475b_1.C new file mode 100644 index 0000000000..29cb461992 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr65475b_1.C @@ -0,0 +1,7 @@ +namespace std { +class exception { + virtual char m_fn1(); +}; +class runtime_error : exception { +} b; +} diff --git a/gcc/testsuite/g++.dg/lto/pr65475c_0.C b/gcc/testsuite/g++.dg/lto/pr65475c_0.C new file mode 100644 index 0000000000..8e1d8bcc83 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr65475c_0.C @@ -0,0 +1,156 @@ +/* { dg-lto-do link } */ +/* { dg-lto-options "-O2 -w" } */ +/* { dg-extra-ld-options { -O2 -Wno-odr -r -nostdlib } } */ +namespace std +{ +template < class > struct char_traits; +typedef long streamsize; +template < typename, typename > class basic_streambuf; +template < typename > class A; +template < typename, typename > class basic_ostream; +template < typename _CharT, typename = + char_traits < _CharT > >class istreambuf_iterator; +template < typename _CharT, typename = + char_traits < _CharT > >class ostreambuf_iterator; +template < typename > class ctype; +template < typename _CharT, typename = + istreambuf_iterator < _CharT > >class num_get; +template < typename _CharT, typename = + ostreambuf_iterator < _CharT > >class num_put; +} +typedef int _Atomic_word; +namespace std +{ +class locale +{ + class facet; + class _Impl; + _Impl *_M_impl; +}; +class locale::facet +{ + _Atomic_word _M_refcount; +protected: + virtual ~ facet (); +}; +enum _Ios_Fmtflags +{ _S_boolalpha = 1, _S_dec, _S_fixed = 1 << 2, _S_hex = + 1 << 3, _S_internal = 1 << 4, _S_left = 1 << 5, _S_oct = + 1 << 6, _S_right = 1 << 7, _S_scientific = 1 << 8, _S_showbase = + 1 << 9, _S_showpoint = 1 << 10, _S_showpos = 1 << 11, _S_skipws = + 1 << 12, _S_unitbuf = 1 << 13, _S_uppercase = 1 << 14, _S_adjustfield = + _S_left | _S_right | _S_internal, _S_basefield = + _S_dec | _S_oct | _S_hex, _S_floatfield = + _S_scientific | _S_fixed, _S_ios_fmtflags_end = 1 << 16 +}; +enum _Ios_Iostate +{ _S_goodbit, _S_badbit, _S_eofbit, _S_failbit = + 1 << 2, _S_ios_iostate_end = 1 << 16 +}; +class ios_base +{ + typedef _Ios_Fmtflags fmtflags; + typedef _Ios_Iostate iostate; + streamsize _M_precision; + streamsize _M_width; + fmtflags _M_flags; + iostate _M_exception; + iostate _M_streambuf_state; + struct _Callback_list; + _Callback_list *_M_callbacks; + struct _Words + { + void *_M_pword; + long _M_iword; + } _M_word_zero; + enum + { _S_local_word_size = 8 }; + _Words _M_local_word[_S_local_word_size]; + int _M_word_size; + _Words *_M_word; + locale _M_ios_locale; + virtual ~ ios_base (); +}; +template < typename, typename > class istreambuf_iterator +{ + typedef A < char_traits < wchar_t > >istream_type; +}; +template < typename, typename > class ostreambuf_iterator +{ + typedef basic_ostream < wchar_t, char_traits < wchar_t > >ostream_type; +}; +template < typename, typename > class num_get:locale::facet +{ +public: + typedef istreambuf_iterator < wchar_t > iter_type; +}; +template < typename, typename > class num_put:locale::facet +{ +public: + typedef ostreambuf_iterator < wchar_t > iter_type; +}; +template < typename, typename > class basic_ios:ios_base +{ + typedef wchar_t char_type; + basic_ostream < wchar_t, char_traits < wchar_t > >*_M_tie; + char_type _M_fill; + bool _M_fill_init; + basic_streambuf < wchar_t, char_traits < wchar_t > >*_M_streambuf; + ctype < wchar_t > *_M_ctype; + num_put < wchar_t > *_M_num_put; + num_get < wchar_t > *_M_num_get; +}; +template < typename, typename > class basic_ostream:virtual basic_ios < wchar_t, + char_traits < wchar_t > + > +{ + typedef basic_ios __ios_type; +}; +template < typename > class A:basic_ios < wchar_t, int > +{ +}; +class B:A < char_traits < wchar_t > >, basic_ostream < wchar_t, + char_traits < wchar_t > > +{ +}; +} + +class C: + std::num_put < + wchar_t > +{ +public: + C (int); + iter_type + do_put_out; +}; +class + D: + std::num_get < + wchar_t > +{ +public: + D (int); + iter_type + do_get_in; +}; +template < typename > void +install_formatting_facets (std::locale, int p2) +{ + (C (p2)); +} + +template < typename > void +install_parsing_facets (std::locale, int p2) +{ + (D (p2)); +} + +std::locale a; +int b; +void +create_formatting () +{ + install_formatting_facets < wchar_t > (a, b); + install_parsing_facets < wchar_t > (a, b); +} diff --git a/gcc/testsuite/g++.dg/lto/pr65475c_1.C b/gcc/testsuite/g++.dg/lto/pr65475c_1.C new file mode 100644 index 0000000000..b63ff9b225 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr65475c_1.C @@ -0,0 +1,234 @@ +namespace std +{ + template < class _CharT > struct char_traits; + typedef long streamsize; + template < typename _CharT, typename _Traits = + char_traits < _CharT > >class basic_ostream; + template < typename _CharT, typename _Traits = + char_traits < _CharT > >class Trans_NS___cxx11_basic_ostringstream; + template < typename _CharT, typename _Traits = + char_traits < _CharT > >class istreambuf_iterator; + template < typename _CharT, typename _Traits = + char_traits < _CharT > >class ostreambuf_iterator; +} +namespace std +{ + template < typename _CharT, typename _InIter = + istreambuf_iterator < _CharT > >class num_get; + template < typename _CharT, typename _OutIter = + ostreambuf_iterator < _CharT > >class num_put; + struct iterator + { + }; +} +typedef int _Atomic_word; +namespace std +{ + class locale + { + public:class facet; + class _Impl; + template < typename _Facet > locale ( const locale & __other, + _Facet * __f ); + private: _Impl * _M_impl; + }; + class locale::facet + { + mutable _Atomic_word _M_refcount; + protected: explicit facet ( void ) throw ( ); + virtual ~ facet ( ); + }; + enum _Ios_Fmtflags + { + _S_boolalpha = 1 << 0, _S_dec, _S_fixed = 1 << 2, _S_hex = + 1 << 3, _S_internal = 1 << 4, _S_left = 1 << 5, _S_oct = + 1 << 6, _S_right = 1 << 7, _S_scientific = 1 << 8, _S_showbase = + 1 << 9, _S_showpoint = 1 << 10, _S_showpos = 1 << 11, _S_skipws = + 1 << 12, _S_unitbuf = 1 << 13, _S_uppercase = 1 << 14, _S_adjustfield = + _S_left | _S_right | _S_internal, _S_basefield = + _S_dec | _S_oct | _S_hex, _S_floatfield = + _S_scientific | _S_fixed, _S_ios_fmtflags_end = 1 << 16 + }; + enum _Ios_Openmode + { + _S_out + }; + enum _Ios_Iostate + { + _S_goodbit, _S_badbit, _S_eofbit, _S_failbit = + 1 << 2, _S_ios_iostate_end = 1 << 16 + }; + class ios_base + { + public:typedef _Ios_Fmtflags fmtflags; + typedef _Ios_Iostate iostate; + protected: streamsize _M_precision; + streamsize _M_width; + fmtflags _M_flags; + iostate _M_exception; + iostate _M_streambuf_state; + struct _Callback_list; + _Callback_list *_M_callbacks; + struct _Words + { + void *_M_pword; + long _M_iword; + }; + _Words _M_word_zero; + enum + { + _S_local_word_size = 8 + }; + _Words _M_local_word[_S_local_word_size]; + int _M_word_size; + _Words *_M_word; + locale _M_ios_locale; + virtual ~ ios_base ( ); + }; + template < typename _CharT, typename _Traits > class basic_streambuf; +template < typename _CharT, typename _Traits > class ostreambuf_iterator:public + iterator + { + typedef basic_ostream < wchar_t, _Traits > ostream_type; + }; + class __ctype_abstract_base:public locale::facet + { + }; +template < typename _CharT > class ctype:public __ctype_abstract_base + { + }; + class Trans_NS___cxx11_numpunct:public locale::facet + { + }; +template < typename _CharT, typename _InIter > class num_get:public locale:: + facet + { + }; +template < typename _CharT, typename _OutIter > class num_put:public locale:: + facet + { + public:typedef int char_type; + typedef std::ostreambuf_iterator < wchar_t, + std::char_traits < wchar_t > >iter_type; + }; +template < typename _CharT, typename _Traits > class basic_ios:public + ios_base + { + public:typedef wchar_t char_type; + typedef num_get < wchar_t, istreambuf_iterator < wchar_t, + _Traits > >__num_get_type; + protected:basic_ostream < wchar_t, _Traits > *_M_tie; + mutable char_type _M_fill; + mutable bool _M_fill_init; + basic_streambuf < wchar_t, _Traits > *_M_streambuf; + const ctype < wchar_t > *_M_ctype; + const num_put < wchar_t, ostreambuf_iterator < wchar_t, + _Traits > >*_M_num_put; + const __num_get_type *_M_num_get; + }; +template < typename _CharT, typename _Traits > class basic_ostream:virtual public basic_ios < wchar_t, + _Traits + > + { + }; +} +typedef enum +{ + posix +} +value_type; +static const unsigned int wchar_t_facet = 1 << 1; +class shared_ptr +{ +}; +namespace std +{ +template < typename _CharT, typename _Traits > class Trans_NS___cxx11_basic_ostringstream:public basic_ostream < wchar_t, + _Traits + > + { + public:explicit Trans_NS___cxx11_basic_ostringstream ( void ); + }; +} +class base_num_format:public + std::num_put < + wchar_t > +{ +public:typedef typename + std::num_put < + wchar_t >::iter_type + iter_type; + typedef wchar_t + char_type; + base_num_format ( unsigned long refs = 0 ); + iter_type + do_put_out; + std::ios_base & + do_put_ios; + char_type + do_put_fill; + unsigned long long + do_put_val; + virtual iter_type + do_put ( void ) const + { + return + do_real_put ( do_put_out, do_put_ios, do_put_fill, do_put_val ); + } +private:template < + typename + ValueType > + iter_type + do_real_put ( iter_type out, std::ios_base & ios, char_type fill, + ValueType val ) const + { + switch ( 0 ) + case posix: + { + typedef + std::Trans_NS___cxx11_basic_ostringstream < + char_type > + sstream_type; + sstream_type + ss; + } + } +}; +class + base_num_parse: + public + std::num_get < + wchar_t > +{ +private:}; +class + num_format: + public + base_num_format +{ +public:typedef wchar_t + iter_type; + num_format ( shared_ptr lc, unsigned long refs = 0 ) + { + } +}; +class + num_punct_posix: + public + std::Trans_NS___cxx11_numpunct +{ +}; +template < typename CharType > + std::locale create_formatting_impl ( std::locale const &in, shared_ptr lc ) +{ + std::locale tmp = std::locale ( tmp, new num_format ( lc ) ); +} +shared_ptr create_formatting_lc; +unsigned int create_formatting_type; +void +create_formatting ( std::locale const &in ) +{ + switch ( create_formatting_type ) + case wchar_t_facet: + create_formatting_impl < wchar_t > ( in, create_formatting_lc ); +} diff --git a/gcc/testsuite/g++.dg/opt/declone2.C b/gcc/testsuite/g++.dg/opt/declone2.C new file mode 100644 index 0000000000..e725d8ebda --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/declone2.C @@ -0,0 +1,10 @@ +// PR c++/61623 +// { dg-options "-Os" } + +struct C {}; +struct B : virtual C {}; +struct A : B { + A (int) {} +}; + +A a (0); diff --git a/gcc/testsuite/g++.dg/opt/dump1.C b/gcc/testsuite/g++.dg/opt/dump1.C index d90061feee..d263f18e99 100644 --- a/gcc/testsuite/g++.dg/opt/dump1.C +++ b/gcc/testsuite/g++.dg/opt/dump1.C @@ -1,7 +1,7 @@ // PR c++/57102 // { dg-options "-O2 -fno-inline -fdump-final-insns" } // { dg-do compile { target c++11 } } -// { dg-final cleanup-saved-temps } +// { dg-final cleanup-final-insns-dump } namespace std { diff --git a/gcc/testsuite/g++.dg/opt/flifetime-dse1.C b/gcc/testsuite/g++.dg/opt/flifetime-dse1.C new file mode 100644 index 0000000000..733d28a794 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/flifetime-dse1.C @@ -0,0 +1,23 @@ +// { dg-options "-O3 -fno-lifetime-dse" } +// { dg-do run } + +typedef __SIZE_TYPE__ size_t; +inline void * operator new (size_t, void *p) { return p; } + +struct A +{ + int i; + A() {} + ~A() {} +}; + +int main() +{ + int ar[1]; + + A* ap = new(ar) A; + ap->i = 42; + ap->~A(); + + if (ar[0] != 42) __builtin_abort(); +} diff --git a/gcc/testsuite/g++.dg/opt/pr30965.C b/gcc/testsuite/g++.dg/opt/pr30965.C index 91bb55c05d..45393fd6b5 100644 --- a/gcc/testsuite/g++.dg/opt/pr30965.C +++ b/gcc/testsuite/g++.dg/opt/pr30965.C @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O3 -fdump-tree-optimized" } */ +/* { dg-options "-O3 -fno-ipa-icf -fdump-tree-optimized" } */ #include <tr1/functional> #include <algorithm> diff --git a/gcc/testsuite/g++.dg/opt/pr44919.C b/gcc/testsuite/g++.dg/opt/pr44919.C index e90851be31..a4aeec822b 100644 --- a/gcc/testsuite/g++.dg/opt/pr44919.C +++ b/gcc/testsuite/g++.dg/opt/pr44919.C @@ -1,4 +1,4 @@ -// { dg-do compile { target powerpc*-*-* ia64-*-* x86_64-*-* } } +// { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } // { dg-options "-O3 -fselective-scheduling2" } namespace std { diff --git a/gcc/testsuite/g++.dg/opt/pr46640.C b/gcc/testsuite/g++.dg/opt/pr46640.C index 0892c9ac86..1c25778e8d 100644 --- a/gcc/testsuite/g++.dg/opt/pr46640.C +++ b/gcc/testsuite/g++.dg/opt/pr46640.C @@ -1,4 +1,4 @@ -// { dg-do compile { target x86_64-*-* } } +// { dg-do compile { target i?86-*-* x86_64-*-* } } // { dg-options "-fschedule-insns2 -fsel-sched-pipelining -fselective-scheduling2 -fno-exceptions -O" } struct QBasicAtomicInt diff --git a/gcc/testsuite/g++.dg/opt/pr46649.C b/gcc/testsuite/g++.dg/opt/pr46649.C index 1428e8bddb..55e9650518 100644 --- a/gcc/testsuite/g++.dg/opt/pr46649.C +++ b/gcc/testsuite/g++.dg/opt/pr46649.C @@ -1,4 +1,4 @@ -// { dg-do compile { target powerpc*-*-* ia64-*-* x86_64-*-* } } +// { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } // { dg-options "-fschedule-insns -fselective-scheduling" } void foo () diff --git a/gcc/testsuite/g++.dg/opt/pr47036.C b/gcc/testsuite/g++.dg/opt/pr47036.C index d6d5adc6a4..94444c3873 100644 --- a/gcc/testsuite/g++.dg/opt/pr47036.C +++ b/gcc/testsuite/g++.dg/opt/pr47036.C @@ -1,4 +1,4 @@ -// { dg-do compile { target powerpc*-*-* ia64-*-* x86_64-*-* } } +// { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } // { dg-options "-fschedule-insns -fselective-scheduling -fno-dce" } diff --git a/gcc/testsuite/g++.dg/opt/pr48273.C b/gcc/testsuite/g++.dg/opt/pr48273.C index 4c5108bdd2..340e3a1019 100644 --- a/gcc/testsuite/g++.dg/opt/pr48273.C +++ b/gcc/testsuite/g++.dg/opt/pr48273.C @@ -1,4 +1,4 @@ -// { dg-do compile { target x86_64-*-* } } +// { dg-do compile { target i?86-*-* x86_64-*-* } } // { dg-options "-fschedule-insns2 -fsel-sched-pipelining -fselective-scheduling2 -funroll-all-loops -march=core2" } void bar (); diff --git a/gcc/testsuite/g++.dg/opt/pr48302.C b/gcc/testsuite/g++.dg/opt/pr48302.C index fd51ba412e..9d939713ff 100644 --- a/gcc/testsuite/g++.dg/opt/pr48302.C +++ b/gcc/testsuite/g++.dg/opt/pr48302.C @@ -1,4 +1,4 @@ -// { dg-do compile { target powerpc*-*-* ia64-*-* x86_64-*-* } } +// { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } // { dg-options "-O -fcrossjumping -fgcse -fschedule-insns2 -fsel-sched-pipelining -fsel-sched-pipelining-outer-loops -fselective-scheduling2 --param lim-expensive=320 --param min-crossjump-insns=1" } struct S diff --git a/gcc/testsuite/g++.dg/opt/pr60002.C b/gcc/testsuite/g++.dg/opt/pr60002.C index 753f579dd9..8a1799584e 100644 --- a/gcc/testsuite/g++.dg/opt/pr60002.C +++ b/gcc/testsuite/g++.dg/opt/pr60002.C @@ -1,6 +1,7 @@ // PR tree-optimization/60002 // { dg-do compile } // { dg-options "-O2 -fcompare-debug -fdeclone-ctor-dtor -fipa-cp-clone" } +// { dg-xfail-if "" { powerpc-ibm-aix* } { "*" } { "" } } struct A {}; diff --git a/gcc/testsuite/g++.dg/opt/pr62078.C b/gcc/testsuite/g++.dg/opt/pr62078.C new file mode 100644 index 0000000000..8730432d3b --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr62078.C @@ -0,0 +1,36 @@ +/* PR rtl-optimization/62078 */ +/* { dg-do compile } */ +/* { dg-options "-Og -fdelete-dead-exceptions -fnon-call-exceptions" } */ + +struct A { virtual ~A (); }; +struct B : A {}; +struct C : B {}; +struct D : C {}; +struct E : D {}; +struct F : E {}; +struct G : F {}; +struct H : G {}; +struct I : H {}; +struct J : I {}; +struct K : J {}; +struct L : K {}; +struct M : L {}; +struct N : M {}; +struct O : N {}; +struct P : O {}; +struct Q : P {}; +struct R : Q {}; +struct S : R {}; +struct T : S {}; +struct U : T {}; +struct V : U {}; +struct W : V {}; +struct X : W {}; +struct Y : X {}; +struct Z : Y {}; + +void +foo () +{ + Z z; +} diff --git a/gcc/testsuite/g++.dg/opt/pr64338.C b/gcc/testsuite/g++.dg/opt/pr64338.C new file mode 100644 index 0000000000..699d38ccea --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr64338.C @@ -0,0 +1,29 @@ +// PR target/64338 +// { dg-do compile } +// { dg-options "-O2" } +// { dg-additional-options "-mtune=nehalem -march=i586" { target { { i?86-*-* x86_64-*-* } && ia32 } } } + +enum O {}; +struct A { A (); }; +struct B { int fn1 (); }; +struct C { struct D; D *fn2 (); void fn3 (); int fn4 (); }; +struct F { void fn5 (const int & = 0); }; +struct G { F *fn6 (); }; +struct H { int h; }; +struct C::D { friend class C; G *fn7 (); }; +O a; + +void +C::fn3 () +{ + int b = a; + H c; + if (b) + fn2 ()->fn7 ()->fn6 ()->fn5 (); + double d; + if (fn4 ()) + d = c.h > 0; + A e (b ? A () : A ()); + B f; + f.fn1 () && d && fn2 (); +} diff --git a/gcc/testsuite/g++.dg/opt/pr65003.C b/gcc/testsuite/g++.dg/opt/pr65003.C new file mode 100644 index 0000000000..5d131afaed --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr65003.C @@ -0,0 +1,31 @@ +// PR middle-end/65003 +// { dg-do compile } +// { dg-options "-O2" } +// { dg-additional-options "-fpic" { target fpic } } + +struct A +{ + void operator= (A &); + A (); +}; +struct B +{ + A b; +}; +struct C +{ + virtual bool foo (int &, bool) const; +}; +struct D : virtual C +{ + bool foo (int &, bool) const; + B e; +}; +struct F : D +{ + F (int &, const int &, const A &); + bool foo (int &, bool) const; +}; +bool D::foo (int &, bool) const {} +F::F (int &, const int &, const A &) {} +bool F::foo (int &, bool) const {} diff --git a/gcc/testsuite/g++.dg/opt/pr65074.C b/gcc/testsuite/g++.dg/opt/pr65074.C new file mode 100644 index 0000000000..01c5926e66 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr65074.C @@ -0,0 +1,19 @@ +// PR middle-end/65074 +// { dg-do link { target pie } } +// { dg-options "-pie -fpie -O2" } + +#include <fstream> + +using namespace std; + +__attribute__((noinline, noclone)) void +foo (const char *fname) +{ + ifstream f (fname); +} + +int +main () +{ + foo ("foobar"); +} diff --git a/gcc/testsuite/g++.dg/opt/pr65554.C b/gcc/testsuite/g++.dg/opt/pr65554.C new file mode 100644 index 0000000000..1519964d1f --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr65554.C @@ -0,0 +1,124 @@ +// PR middle-end/65554 +// { dg-do compile { target c++11 } } +// { dg-options "-O" } + +namespace std +{ + struct B { enum { __value }; }; + template <typename _Iterator> struct C + { + static _Iterator _S_base (_Iterator p1) { return p1; } + }; + template <typename> using _RequireInputIter = int; + template <typename _Iterator> _Iterator __niter_base (_Iterator p1) + { + return std::C <_Iterator>::_S_base (p1); + } + template <typename _Iterator> _Iterator __miter_base (_Iterator p1) + { + return std::C <_Iterator>::_S_base (p1); + } + struct D + { + template <typename _Tp> static _Tp *__copy_m (_Tp * p1, _Tp * p2, _Tp *) + { + int _Num = p2 - p1; + __builtin_memmove (0, p1, sizeof (_Tp) * _Num); + } + }; + template <int, typename _II, typename _OI> void __copy_move_a (_II p1, _II p2, _OI p3) + { + D::__copy_m (p1, p2, p3); + } + template <int, typename _II, typename _OI> void __copy_move_a2 (_II p1, _II p2, _OI p3) + { + __copy_move_a <0> (std::__niter_base (p1), std::__niter_base (p2), std::__niter_base (p3)); + } + template <typename _II, typename _OI> void copy (_II p1, _II p2, _OI p3) + { + __copy_move_a2 <B::__value> (std::__miter_base (p1), std::__miter_base (p2), p3); + } +} +template <typename _Tp> struct F { typedef _Tp *pointer; }; +namespace std +{ + template <typename _Tp> using __allocator_base = F <_Tp>; + template <typename _Tp> struct allocator:__allocator_base <_Tp> {}; + template <class _E> struct initializer_list + { + typedef _E *const_iterator; + _E *_M_array; + __SIZE_TYPE__ _M_len; + const_iterator begin () { return _M_array; } + const_iterator end () { return begin () + 1; } + }; + template <typename _Alloc> struct allocator_traits + { + template <typename _Tp> static typename _Tp::pointer _S_pointer_helper (_Tp *); + typedef decltype (_S_pointer_helper ((_Alloc *) 0)) __pointer; + typedef __pointer pointer; + }; +} +template <typename> struct __alloc_traits: +std::allocator_traits <std::allocator <const char *>> {}; +namespace std +{ + struct G + { + template <typename _InputIterator, typename _ForwardIterator> static _ForwardIterator __uninit_copy (_InputIterator p1, _InputIterator p2, _ForwardIterator p3) + { + copy (p1, p2, p3); + } + }; + template <typename _InputIterator, typename _ForwardIterator> void + uninitialized_copy (_InputIterator p1, _InputIterator p2, _ForwardIterator p3) + { + G::__uninit_copy (p1, p2, p3); + } + template <typename _InputIterator, typename _ForwardIterator, typename _Tp> void __uninitialized_copy_a (_InputIterator p1, _InputIterator p2, _ForwardIterator p3, allocator <_Tp> &) + { + uninitialized_copy (p1, p2, p3); + } + struct H + { + typedef std::allocator <int *> _Tp_alloc_type; + typedef __alloc_traits <_Tp_alloc_type>::pointer pointer; + _Tp_alloc_type & _M_get_Tp_allocator (); + }; + template <typename _Tp, typename = std::allocator <_Tp>> struct J: H + { + void operator= (initializer_list <_Tp> p1) + { + this->assign (p1.begin (), p1.end ()); + } + template <typename _InputIterator, typename = std::_RequireInputIter <_InputIterator>> void assign (_InputIterator p1, _InputIterator p2) + { + _M_assign_dispatch (p1, p2, 0); + } + pointer _M_allocate_and_copy___result; + template <typename _ForwardIterator> void _M_allocate_and_copy (int, _ForwardIterator p2, _ForwardIterator p3) + { + __uninitialized_copy_a (p2, p3, _M_allocate_and_copy___result, _M_get_Tp_allocator ()); + } + template <typename _InputIterator> void _M_assign_dispatch (_InputIterator p1, _InputIterator p2, int) + { + _M_assign_aux (p1, p2, 0); + } + template <typename _ForwardIterator> void _M_assign_aux (_ForwardIterator, _ForwardIterator, int); + }; + template <typename _Tp, typename _Alloc> + template <typename _ForwardIterator> void J <_Tp, _Alloc>::_M_assign_aux (_ForwardIterator p1, _ForwardIterator p2, int) + { + _M_allocate_and_copy (0, p1, p2); + } + class I + { + void tabCompletion (std::J <int>&) const; + }; + void + I::tabCompletion (J <int>&) const + { + J <const char *> extra; + extra = { "foo" }; + } +} diff --git a/gcc/testsuite/g++.dg/opt/vt2.C b/gcc/testsuite/g++.dg/opt/vt2.C index a77db38755..780f58775c 100644 --- a/gcc/testsuite/g++.dg/opt/vt2.C +++ b/gcc/testsuite/g++.dg/opt/vt2.C @@ -1,5 +1,6 @@ // PR c++/34949 // { dg-options "-O3" } +// { dg-add-options bind_pic_locally } // { dg-final { scan-assembler-not "mov\[^\n\]*_ZTV" { target i?86-*-* x86_64-*-* } } } class Foo diff --git a/gcc/testsuite/g++.dg/opt/vt4.C b/gcc/testsuite/g++.dg/opt/vt4.C index c8d04cffc1..98378da00f 100644 --- a/gcc/testsuite/g++.dg/opt/vt4.C +++ b/gcc/testsuite/g++.dg/opt/vt4.C @@ -1,6 +1,7 @@ // PR c++/50243 // { dg-do compile } // { dg-options "-O" } +// { dg-add-options bind_pic_locally } // { dg-final { scan-assembler-not "_ZTV.A" } } void foo (); diff --git a/gcc/testsuite/g++.dg/other/anon5.C b/gcc/testsuite/g++.dg/other/anon5.C index 81e9def537..4e4cc44864 100644 --- a/gcc/testsuite/g++.dg/other/anon5.C +++ b/gcc/testsuite/g++.dg/other/anon5.C @@ -3,6 +3,8 @@ // { dg-options "-g" } // Ignore additional message on powerpc-ibm-aix // { dg-prune-output "obtain more information" } */ +// Ignore additional messages on Linux/x86 with PIE +// { dg-prune-output "Bad value" } */ namespace { struct c diff --git a/gcc/testsuite/g++.dg/other/crash-2.C b/gcc/testsuite/g++.dg/other/crash-2.C index 961a18a238..b8645b0930 100644 --- a/gcc/testsuite/g++.dg/other/crash-2.C +++ b/gcc/testsuite/g++.dg/other/crash-2.C @@ -3,7 +3,7 @@ // Contributed by Hans Buchmann <hans dot buchmann at fhso dot ch> // PR c++/14033: ICE while inlining a function with incomplete parameter -struct A; // { dg-error "forward declaration" } +struct A; // { dg-message "forward declaration" } void foo(A a) {} // { dg-error "incomplete" } struct A {}; diff --git a/gcc/testsuite/g++.dg/other/default10.C b/gcc/testsuite/g++.dg/other/default10.C new file mode 100644 index 0000000000..1c9731e2fa --- /dev/null +++ b/gcc/testsuite/g++.dg/other/default10.C @@ -0,0 +1,4 @@ +// PR c++/15339 + +template<typename> void g3(int, int); +template<typename> void g3(int = 0, int) { } // { dg-error "may not have default arguments|default argument missing" } diff --git a/gcc/testsuite/g++.dg/other/default11.C b/gcc/testsuite/g++.dg/other/default11.C new file mode 100644 index 0000000000..e747c44a11 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/default11.C @@ -0,0 +1,11 @@ +// PR c++/65370 + +template <typename> class C +{ + template <typename U> + C(const C<U>&, bool = false); +}; + +template <> +template <typename U> +C<int>::C(const C<U>&, bool); diff --git a/gcc/testsuite/g++.dg/other/default12.C b/gcc/testsuite/g++.dg/other/default12.C new file mode 100644 index 0000000000..3d7ba5497d --- /dev/null +++ b/gcc/testsuite/g++.dg/other/default12.C @@ -0,0 +1,16 @@ +// PR c++/65370 + +template <typename> class C +{ + template <typename U> + C(const C<U>&, bool = false); +}; + +template<> +class C<int> +{ + template <typename U> + C(const C<U>&, bool); +}; + +template <typename U> C<int>::C(const C<U>&, bool = false) { } // { dg-error "default arguments" } diff --git a/gcc/testsuite/g++.dg/other/default3.C b/gcc/testsuite/g++.dg/other/default3.C index 42c1fe4892..025d2c1b46 100644 --- a/gcc/testsuite/g++.dg/other/default3.C +++ b/gcc/testsuite/g++.dg/other/default3.C @@ -25,7 +25,7 @@ template<typename> void g3(int, int); template<typename> void g3(int = 0, int); // { dg-error "default" } template<typename> void g4(int, int); -template<typename> void g4(int = 0, int) {} // { dg-error "default" "" { xfail *-*-* } } +template<typename> void g4(int = 0, int) {} // { dg-error "default" } template<typename> void g5(); template<typename> void g5(int = 0, int); // { dg-error "default" } diff --git a/gcc/testsuite/g++.dg/other/default9.C b/gcc/testsuite/g++.dg/other/default9.C new file mode 100644 index 0000000000..62f0a79152 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/default9.C @@ -0,0 +1,18 @@ +// PR c++/15339 + +template<typename> void fun(int); +template<typename> void fun(int = 0); // { dg-error "default arguments" } + +class A +{ + template<typename> void fun(int); +}; + +template<typename> void A::fun(int = 0) { } // { dg-error "default arguments" } + +class B +{ + void fun(int); +}; + +void B::fun(int = 0) { } diff --git a/gcc/testsuite/g++.dg/other/dump-ada-spec-3.C b/gcc/testsuite/g++.dg/other/dump-ada-spec-3.C new file mode 100644 index 0000000000..ae4985cb59 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/dump-ada-spec-3.C @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-ada-spec" } */ + +using namespace std; + +class Base { + public: + int My_V; + virtual void Primitive (); + + Base (); +}; + +void Base::Primitive () { +} + +Base::Base () { +} + +void Dispatch (Base * B) { + B->Primitive (); +} + +/* { dg-final { cleanup-ada-spec } } */ diff --git a/gcc/testsuite/g++.dg/other/empty-class.C b/gcc/testsuite/g++.dg/other/empty-class.C new file mode 100644 index 0000000000..a14c4372a8 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/empty-class.C @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-gimple" } */ + +/* Test that we return retval directly, instead of going through an + intermediate temporary, when returning an empty class. */ + +class obj { + public: + obj(int); +}; + +obj funky(){ + return obj(555); +} + +/* { dg-final { scan-tree-dump-times "return <retval>;" 1 "gimple" } } */ +/* { dg-final { cleanup-tree-dump "gimple" } } */ diff --git a/gcc/testsuite/g++.dg/other/error13.C b/gcc/testsuite/g++.dg/other/error13.C index 4ee935ad60..efda086329 100644 --- a/gcc/testsuite/g++.dg/other/error13.C +++ b/gcc/testsuite/g++.dg/other/error13.C @@ -7,6 +7,5 @@ struct A // { dg-message "note" } }; struct B : A {}; // { dg-error "no matching function for call|deleted" } -// { dg-message "candidate" "candidate note" { target *-*-* } 9 } B b; // { dg-message "synthesized method|deleted" } diff --git a/gcc/testsuite/g++.dg/other/error20.C b/gcc/testsuite/g++.dg/other/error20.C index bb7d7b3b07..dab6de40e4 100644 --- a/gcc/testsuite/g++.dg/other/error20.C +++ b/gcc/testsuite/g++.dg/other/error20.C @@ -9,5 +9,4 @@ struct A // { dg-message "operator=|no known conversion" } void bar (A& a) { a.foo () = 0; // { dg-error "operand types are 'A' and 'int'" } - // { dg-message "candidate" "candidate note" { target *-*-* } 11 } } diff --git a/gcc/testsuite/g++.dg/other/error23.C b/gcc/testsuite/g++.dg/other/error23.C index 959fe4075e..c60603e8ff 100644 --- a/gcc/testsuite/g++.dg/other/error23.C +++ b/gcc/testsuite/g++.dg/other/error23.C @@ -2,4 +2,4 @@ // { dg-do compile } int v __attribute ((vector_size (8))); -bool b = !(v - v); // { dg-error "could not convert .\\(__vector.2. int\\)\\{0, 0\\}. from .__vector.2. int. to .bool.|in argument to unary" } +bool b = !(v - v); // { dg-error "not convert .__vector.2. int. to .bool. in initialization" } diff --git a/gcc/testsuite/g++.dg/other/error31.C b/gcc/testsuite/g++.dg/other/error31.C index 95c9d73741..fd428bf46d 100644 --- a/gcc/testsuite/g++.dg/other/error31.C +++ b/gcc/testsuite/g++.dg/other/error31.C @@ -10,5 +10,4 @@ foo () { A a; a = ({ { 1; } }); // { dg-error "no match for" } - // { dg-message "candidate" "candidate note" { target *-*-* } 12 } } diff --git a/gcc/testsuite/g++.dg/other/i386-2.C b/gcc/testsuite/g++.dg/other/i386-2.C index 2f8650a66b..4f77dd7277 100644 --- a/gcc/testsuite/g++.dg/other/i386-2.C +++ b/gcc/testsuite/g++.dg/other/i386-2.C @@ -1,5 +1,5 @@ /* { dg-do compile { target i?86-*-* x86_64-*-* } } */ -/* { dg-options "-O -pedantic-errors -march=k8 -msse4a -m3dnow -mavx -mavx2 -mfma4 -mxop -maes -mpclmul -mpopcnt -mabm -mlzcnt -mbmi -mbmi2 -mtbm -mlwp -mfsgsbase -mrdrnd -mf16c -mfma -mrtm -mrdseed -mprfchw -madx -mfxsr -mxsaveopt -mavx512f -mavx512er -mavx512cd -mavx512pf -msha -mprefetchwt1" } */ +/* { dg-options "-O -pedantic-errors -march=k8 -msse4a -m3dnow -mavx -mavx2 -mfma4 -mxop -maes -mpclmul -mpopcnt -mabm -mlzcnt -mbmi -mbmi2 -mtbm -mlwp -mfsgsbase -mrdrnd -mf16c -mfma -mrtm -mrdseed -mprfchw -madx -mfxsr -mxsaveopt -mavx512f -mavx512er -mavx512cd -mavx512pf -msha -mprefetchwt1 -mxsavec -mxsaves -mclflushopt -mavx512dq -mavx512bw -mavx512vl -mavx512ifma -mavx512vbmi -mclwb -mpcommit" } */ /* Test that {,x,e,p,t,s,w,a,b,i}mmintrin.h, mm3dnow.h, fma4intrin.h, xopintrin.h, abmintrin.h, bmiintrin.h, tbmintrin.h, lwpintrin.h, diff --git a/gcc/testsuite/g++.dg/other/i386-3.C b/gcc/testsuite/g++.dg/other/i386-3.C index df0bd27979..53b90b8e13 100644 --- a/gcc/testsuite/g++.dg/other/i386-3.C +++ b/gcc/testsuite/g++.dg/other/i386-3.C @@ -1,5 +1,5 @@ /* { dg-do compile { target i?86-*-* x86_64-*-* } } */ -/* { dg-options "-O -fkeep-inline-functions -march=k8 -msse4a -m3dnow -mavx -mavx2 -mfma4 -mxop -maes -mpclmul -mpopcnt -mabm -mlzcnt -mbmi -mbmi2 -mtbm -mlwp -mfsgsbase -mrdrnd -mf16c -mfma -mrtm -mrdseed -mprfchw -madx -mfxsr -mxsaveopt -mavx512f -mavx512er -mavx512cd -mavx512pf -msha -mprefetchwt1" } */ +/* { dg-options "-O -fkeep-inline-functions -march=k8 -msse4a -m3dnow -mavx -mavx2 -mfma4 -mxop -maes -mpclmul -mpopcnt -mabm -mlzcnt -mbmi -mbmi2 -mtbm -mlwp -mfsgsbase -mrdrnd -mf16c -mfma -mrtm -mrdseed -mprfchw -madx -mfxsr -mxsaveopt -mavx512f -mavx512er -mavx512cd -mavx512pf -msha -mprefetchwt1 -mxsavec -mxsaves -mclflushopt -mavx512dq -mavx512bw -mavx512vl -mavx512ifma -mavx512vbmi -mclwb -mpcommit" } */ /* Test that {,x,e,p,t,s,w,a,b,i}mmintrin.h, mm3dnow.h, fma4intrin.h, xopintrin.h, abmintrin.h, bmiintrin.h, tbmintrin.h, lwpintrin.h, diff --git a/gcc/testsuite/g++.dg/other/offsetof3.C b/gcc/testsuite/g++.dg/other/offsetof3.C index 5946c812ce..8d98242656 100644 --- a/gcc/testsuite/g++.dg/other/offsetof3.C +++ b/gcc/testsuite/g++.dg/other/offsetof3.C @@ -1,7 +1,6 @@ -/* Verify that offsetof warns if given a non-standard-layout class */ +/* Verify that offsetof complains if given a non-standard-layout class. */ /* Copyright (C) 2003 Free Software Foundation, Inc. */ /* Contributed by Matt Austern <austern@apple.com> 15 May 2003 */ -/* { dg-do compile } */ struct X { @@ -13,5 +12,4 @@ protected: typedef X* pX; typedef __SIZE_TYPE__ size_t; -size_t yoff = size_t(&(pX(0)->y)); /* { dg-warning "invalid access" "" } */ -/* { dg-warning "macro was used incorrectly" "macro" { target *-*-* } 16 } */ +size_t yoff = __builtin_offsetof (X, y); /* { dg-error "35:non-standard-layout" } */ diff --git a/gcc/testsuite/g++.dg/other/offsetof5.C b/gcc/testsuite/g++.dg/other/offsetof5.C index b53b06ffb5..86b1448824 100644 --- a/gcc/testsuite/g++.dg/other/offsetof5.C +++ b/gcc/testsuite/g++.dg/other/offsetof5.C @@ -9,14 +9,14 @@ struct A int &i; }; -int j = offsetof (A, i); // { dg-warning "invalid access|offsetof" } +int j = offsetof (A, i); // { dg-error "offsetof" } template <typename T> struct S { T h; T &i; - static const int j = offsetof (S, i); // { dg-warning "invalid access|offsetof" } + static const int j = offsetof (S, i); // { dg-error "offsetof" } }; int k = S<int>::j; // { dg-message "required from here" } diff --git a/gcc/testsuite/g++.dg/other/operator3.C b/gcc/testsuite/g++.dg/other/operator3.C new file mode 100644 index 0000000000..5c0968d812 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/operator3.C @@ -0,0 +1,7 @@ +// PR c++/33972 + +struct s +{ + typedef void f(void); + f operator(); +}; diff --git a/gcc/testsuite/g++.dg/other/pr28114.C b/gcc/testsuite/g++.dg/other/pr28114.C index 63ecbf51f4..d54fec9608 100644 --- a/gcc/testsuite/g++.dg/other/pr28114.C +++ b/gcc/testsuite/g++.dg/other/pr28114.C @@ -6,5 +6,4 @@ template<int> void foo(struct {}*); // { dg-message "" } void bar() { foo<0>(0); // { dg-error "" } - // { dg-message "candidate" "candidate note" { target *-*-* } 8 } } diff --git a/gcc/testsuite/g++.dg/other/pr63815.C b/gcc/testsuite/g++.dg/other/pr63815.C new file mode 100644 index 0000000000..fce6226bb7 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr63815.C @@ -0,0 +1,50 @@ +// PR target/63815 +// { dg-do run { target { { i?86-*-linux* x86_64-*-linux* } && lp64 } } } +// { dg-options "-mcmodel=large" } +// { dg-additional-options "-fpic" { target fpic } } + +struct ICCStringClass +{ + virtual int CreateString (int) = 0; +}; + +struct AGSCCDynamicObject +{ + virtual void Unserialize () = 0; +}; + +struct ScriptString:AGSCCDynamicObject, ICCStringClass +{ + virtual int CreateString (int); + virtual void Unserialize (); +}; + +int +__attribute__ ((noinline)) +CreateNewScriptString (int fromText, bool reAllocate = true) +{ + return fromText; +} + +int +__attribute__ ((noinline)) +ScriptString::CreateString (int fromText) +{ + return CreateNewScriptString (fromText); +} + +void +__attribute__ ((noinline)) +ScriptString::Unserialize () +{ +} + +int +main () +{ + ICCStringClass *x = new ScriptString; + + if (x->CreateString (1) != 1) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/g++.dg/other/ptrmem2.C b/gcc/testsuite/g++.dg/other/ptrmem2.C index d267df15be..335f492c58 100644 --- a/gcc/testsuite/g++.dg/other/ptrmem2.C +++ b/gcc/testsuite/g++.dg/other/ptrmem2.C @@ -8,7 +8,7 @@ struct D { - int &m; // { dg-error "invalid use of non-static data member" "" } + int &m; // { dg-message "" } static int &s; int Foo (); @@ -29,7 +29,7 @@ int D::Foo () int Foo () { f1( &D::m); // { dg-error "cannot create pointer to ref" "" } - f1( &(D::m)); // { dg-error "from this location" "" } + f1( &(D::m)); // { dg-error "non-static" } f2( &D::s); // ok f2( &(D::s)); // ok return 0; diff --git a/gcc/testsuite/g++.dg/other/redecl3.C b/gcc/testsuite/g++.dg/other/redecl3.C new file mode 100644 index 0000000000..6d35bf53e9 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/redecl3.C @@ -0,0 +1,9 @@ +// PR c++/22556 + +extern int foo[]; // OK +int foo[] = {1,2,3}; +extern int foo[]; // OK + +void bar(){ + extern int foo[]; // g++: ERROR -- SHOULD BE OK +} diff --git a/gcc/testsuite/g++.dg/other/ucnid-1.C b/gcc/testsuite/g++.dg/other/ucnid-1.C index 9a2728f25b..95a31cb80f 100644 --- a/gcc/testsuite/g++.dg/other/ucnid-1.C +++ b/gcc/testsuite/g++.dg/other/ucnid-1.C @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-fextended-identifiers" } */ +/* { dg-options "" } */ /* { dg-xfail-if "" { powerpc-ibm-aix* } { "*" } { "" } } */ /* { dg-skip-if "" { ! ucn } { "*" } { "" } } */ #include <cstdlib> diff --git a/gcc/testsuite/g++.dg/other/virtual3.C b/gcc/testsuite/g++.dg/other/virtual3.C new file mode 100644 index 0000000000..55c8185571 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/virtual3.C @@ -0,0 +1,25 @@ +// PR c++/58923 + +struct A +{ + virtual void do_it() const = 0; +}; + +struct B : A +{ + virtual void do_it() const {} +}; + +struct C +{ + operator B() const { return B(); } +}; + +void do_it(const A& a) { a.do_it(); } + +int main() +{ + C c; + do_it(c); + return 0; +} diff --git a/gcc/testsuite/g++.dg/other/void1.C b/gcc/testsuite/g++.dg/other/void1.C index 691e6f7824..3f6b1dbfe8 100644 --- a/gcc/testsuite/g++.dg/other/void1.C +++ b/gcc/testsuite/g++.dg/other/void1.C @@ -4,13 +4,13 @@ typedef void VOID; int foo(void); -int bar(VOID); // { dg-error "type|invalid use" } +int bar(VOID); template<int> int foo(void); -template<int> int bar(VOID); // { dg-error "type|invalid use" } +template<int> int bar(VOID); struct A { int foo(void); - int bar(VOID); // { dg-error "type|invalid use" } + int bar(VOID); }; diff --git a/gcc/testsuite/g++.dg/other/void3.C b/gcc/testsuite/g++.dg/other/void3.C new file mode 100644 index 0000000000..48a6609915 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/void3.C @@ -0,0 +1,4 @@ +// PR c++/33101 + +typedef void v; +typedef v (*pf)(v); diff --git a/gcc/testsuite/g++.dg/overload/ambig1.C b/gcc/testsuite/g++.dg/overload/ambig1.C index d11e00a187..21948bf314 100644 --- a/gcc/testsuite/g++.dg/overload/ambig1.C +++ b/gcc/testsuite/g++.dg/overload/ambig1.C @@ -20,5 +20,4 @@ void f(B); // { dg-message "note" "candidate" } int main() { f (42); // { dg-error "ambiguous" "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 22 } } diff --git a/gcc/testsuite/g++.dg/overload/arg3.C b/gcc/testsuite/g++.dg/overload/arg3.C index 34624cd22e..1684fccf5c 100644 --- a/gcc/testsuite/g++.dg/overload/arg3.C +++ b/gcc/testsuite/g++.dg/overload/arg3.C @@ -10,14 +10,13 @@ struct A {}; struct B : A { - B(int); // { dg-message "B::B|no known conversion" "" } + B(int); B(B&); // { dg-message "note" "" } }; -void foo(B); // { dg-error "initializing" } +void foo(B); // { dg-message "initializing" } void bar() { - foo(0); // { dg-error "no matching function" "no matching" } - // { dg-message "candidate" "candidate note" { target *-*-* } 21 } + foo(0); // { dg-error "" } } diff --git a/gcc/testsuite/g++.dg/overload/builtin1.C b/gcc/testsuite/g++.dg/overload/builtin1.C index fdd208135c..72080ea444 100644 --- a/gcc/testsuite/g++.dg/overload/builtin1.C +++ b/gcc/testsuite/g++.dg/overload/builtin1.C @@ -14,5 +14,4 @@ int main () A a; a + a; // { dg-error "ambiguous" "ambiguous" } // { dg-message "operator" "match candidate text" { target *-*-* } 15 } - // { dg-message "candidates" "candidates" { target *-*-* } 15 } } diff --git a/gcc/testsuite/g++.dg/overload/conv-op1.C b/gcc/testsuite/g++.dg/overload/conv-op1.C index 6a63cbaeb8..cd8d9f481e 100644 --- a/gcc/testsuite/g++.dg/overload/conv-op1.C +++ b/gcc/testsuite/g++.dg/overload/conv-op1.C @@ -11,7 +11,7 @@ void f() { const int i = 42; A()(i); // { dg-message "<conversion>" } + // { dg-error "qualifiers" "" { target *-*-* } 13 } } // { dg-prune-output "no match" } -// { dg-prune-output "candidate" } diff --git a/gcc/testsuite/g++.dg/overload/copy1.C b/gcc/testsuite/g++.dg/overload/copy1.C index f0ec385fc9..5c7922f833 100644 --- a/gcc/testsuite/g++.dg/overload/copy1.C +++ b/gcc/testsuite/g++.dg/overload/copy1.C @@ -4,18 +4,17 @@ struct A; struct B { - B (A const &); // { dg-message "note" } + B (A const &); B (B &); // { dg-message "note" } }; struct A { - A (B); // { dg-error "initializing" } + A (B); // { dg-message "initializing" } }; B f (B const& b) { - return b; // { dg-error "matching" "matching" } - // { dg-message "candidate" "candidate note" { target *-*-* } 19 } + return b; // { dg-error "" } } diff --git a/gcc/testsuite/g++.dg/overload/defarg9.C b/gcc/testsuite/g++.dg/overload/defarg9.C new file mode 100644 index 0000000000..401fe0e324 --- /dev/null +++ b/gcc/testsuite/g++.dg/overload/defarg9.C @@ -0,0 +1,11 @@ +// PR c++/62115 + +struct A {}; +struct B : A {}; + +struct C +{ + C(A& a = B()) {} // { dg-error "rvalue" } +}; + +C c; // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/overload/ellipsis1.C b/gcc/testsuite/g++.dg/overload/ellipsis1.C index 3dedaa6be4..1dde2bc1d2 100644 --- a/gcc/testsuite/g++.dg/overload/ellipsis1.C +++ b/gcc/testsuite/g++.dg/overload/ellipsis1.C @@ -1,5 +1,6 @@ // PR c++/15142 // Bug: We were aborting after giving a warning about passing a non-POD. +// { dg-options "-Wconditionally-supported" } struct B { B() throw() { } @@ -14,5 +15,5 @@ struct X { struct S { S(...); }; void SillyFunc() { - throw S(X()); // { dg-error "copy" } + throw S(X()); // { dg-message "copy" } } diff --git a/gcc/testsuite/g++.dg/overload/ellipsis2.C b/gcc/testsuite/g++.dg/overload/ellipsis2.C index d9118ba643..c226e1c5e5 100644 --- a/gcc/testsuite/g++.dg/overload/ellipsis2.C +++ b/gcc/testsuite/g++.dg/overload/ellipsis2.C @@ -1,4 +1,5 @@ // PR c++/60253 +// { dg-options "-Wconditionally-supported" } struct A { @@ -10,4 +11,4 @@ struct B B(...); }; -B b(0, A()); // { dg-error "cannot pass" } +B b(0, A()); // { dg-message "pass" } diff --git a/gcc/testsuite/g++.dg/overload/ellipsis3.C b/gcc/testsuite/g++.dg/overload/ellipsis3.C new file mode 100644 index 0000000000..e7d34d6df4 --- /dev/null +++ b/gcc/testsuite/g++.dg/overload/ellipsis3.C @@ -0,0 +1,9 @@ +struct A { + A(...); +}; + +int main() +{ + volatile A a; + volatile A a2(a); // { dg-error "volatile" } +} diff --git a/gcc/testsuite/g++.dg/overload/new1.C b/gcc/testsuite/g++.dg/overload/new1.C index bf2190b8e0..0cfbfc4bf1 100644 --- a/gcc/testsuite/g++.dg/overload/new1.C +++ b/gcc/testsuite/g++.dg/overload/new1.C @@ -16,6 +16,5 @@ void f(X *x = new X[4]); // { dg-error "" } void f(X *x = new (3) X(6)); // { dg-error "" } void f(X *x = new (2) X[10]); // { dg-error "" } -// { dg-message "candidate" "candidate note" { target *-*-* } 18 } void f(X *x = new X[10][5]); // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/overload/template4.C b/gcc/testsuite/g++.dg/overload/template4.C index 8f00d4171d..7c49c6d364 100644 --- a/gcc/testsuite/g++.dg/overload/template4.C +++ b/gcc/testsuite/g++.dg/overload/template4.C @@ -16,9 +16,6 @@ void test () { foo <0> (0); // { dg-error "is ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 18 } bar <1> (0, 1); // { dg-error "is ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 20 } baz (0); // { dg-error "is ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 22 } } diff --git a/gcc/testsuite/g++.dg/overload/using2.C b/gcc/testsuite/g++.dg/overload/using2.C index d1824548ad..579e4e6a4d 100644 --- a/gcc/testsuite/g++.dg/overload/using2.C +++ b/gcc/testsuite/g++.dg/overload/using2.C @@ -73,12 +73,10 @@ int main () { exit (0); _exit (0); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 75 } abort (); c1 (); C1 (); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 80 } c2 (); C2 (); // one might expect an ambiguous call error here as well, but @@ -86,7 +84,6 @@ int main () { c3 (); C3 (); // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 88 } C3 (0); C3 (0l); } diff --git a/gcc/testsuite/g++.dg/overload/volatile1.C b/gcc/testsuite/g++.dg/overload/volatile1.C index baf467d818..0426b8f361 100644 --- a/gcc/testsuite/g++.dg/overload/volatile1.C +++ b/gcc/testsuite/g++.dg/overload/volatile1.C @@ -1,14 +1,13 @@ // PR c++/48118 -// { dg-prune-output "note" } struct A { }; -void f (A); // { dg-error "argument 1" } +void f (A); // { dg-message "" } void (*g)(A); int main() { volatile A a; - f(a); // { dg-error "no match" } - g(a); // { dg-error "no match" } + f(a); // { dg-error "" } + g(a); // { dg-error "" } } diff --git a/gcc/testsuite/g++.dg/parse/assign1.C b/gcc/testsuite/g++.dg/parse/assign1.C new file mode 100644 index 0000000000..c0138c1449 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/assign1.C @@ -0,0 +1,22 @@ +// PR c++/65525 + +struct A +{ + int x; + char y; // Actually, short and bool (types smaller than int?) trigger this ICE too + // Also: the problem doesn't occur if you put the smaller type first, e.g. "char x; int y;" + + A(int x) {} // custom ctor needed for ICE +}; + +int main() +{ + A a(0), x(1), y(2); + + x = a; // OK + y = a; // OK + x = y = a; // ICE: sorry, unimplemented: unexpected AST of kind mem_ref + // internal compiler error: in potential_constant_expression_1, at cp/constexpr.c:4432 + + return 0; +} diff --git a/gcc/testsuite/g++.dg/parse/crash24.C b/gcc/testsuite/g++.dg/parse/crash24.C index fdc4f1e7c9..d0804b1338 100644 --- a/gcc/testsuite/g++.dg/parse/crash24.C +++ b/gcc/testsuite/g++.dg/parse/crash24.C @@ -1,6 +1,6 @@ // PR c++/20461 // { dg-do compile } -class C; // { dg-error "forward declaration" } +class C; // { dg-message "forward declaration" } C::C() : f() {} // { dg-error "invalid use|does not have" } diff --git a/gcc/testsuite/g++.dg/parse/crash25.C b/gcc/testsuite/g++.dg/parse/crash25.C index d7f20c62f2..f0d8ffd721 100644 --- a/gcc/testsuite/g++.dg/parse/crash25.C +++ b/gcc/testsuite/g++.dg/parse/crash25.C @@ -4,7 +4,7 @@ struct yyguts_t { - class TestScanner* yyextra_r; // { dg-error "forward declaration" } + class TestScanner* yyextra_r; // { dg-message "forward declaration" } }; TestScanner::TestScanner() {} // { dg-error "invalid use" } diff --git a/gcc/testsuite/g++.dg/parse/crash31.C b/gcc/testsuite/g++.dg/parse/crash31.C index b0a7e1877c..e7d6bdc146 100644 --- a/gcc/testsuite/g++.dg/parse/crash31.C +++ b/gcc/testsuite/g++.dg/parse/crash31.C @@ -1,4 +1,4 @@ -struct A // { dg-error "forward declaration" } +struct A // { dg-message "not complete" } { A : A; // { dg-error "expected|incomplete" } A : B; // { dg-error "not declared|incomplete" } diff --git a/gcc/testsuite/g++.dg/parse/crash41.C b/gcc/testsuite/g++.dg/parse/crash41.C index 746dbbca8a..c14fbadff9 100644 --- a/gcc/testsuite/g++.dg/parse/crash41.C +++ b/gcc/testsuite/g++.dg/parse/crash41.C @@ -5,4 +5,4 @@ struct A A(int)(); // { dg-error "declared" } }; -template<int> void foo(bool b, A a) { b ? a : 0; } // { dg-error "no match" } +template<int> void foo(bool b, A a) { b ? a : 0; } // { dg-error "?:" } diff --git a/gcc/testsuite/g++.dg/parse/crash49.C b/gcc/testsuite/g++.dg/parse/crash49.C index 07d7c3b2f9..a922ef3cfc 100644 --- a/gcc/testsuite/g++.dg/parse/crash49.C +++ b/gcc/testsuite/g++.dg/parse/crash49.C @@ -1,7 +1,7 @@ // PR c++/37552 // { dg-do compile } -extern struct A a[1]; // { dg-error "forward declaration" } +extern struct A a[1]; // { dg-message "forward declaration" } void foo () diff --git a/gcc/testsuite/g++.dg/parse/crash5.C b/gcc/testsuite/g++.dg/parse/crash5.C index 0ac7029799..d51f8ed7a5 100644 --- a/gcc/testsuite/g++.dg/parse/crash5.C +++ b/gcc/testsuite/g++.dg/parse/crash5.C @@ -8,8 +8,6 @@ class QString { }; // { dg-error "redefinition" } const QString q () { QString z; // { dg-error "matching" } - // { dg-message "candidate" "candidate note" { target *-*-* } 10 } int x; return x ? QString () : QString (); // { dg-error "matching" } - // { dg-message "candidate" "candidate note" { target *-*-* } 13 } } diff --git a/gcc/testsuite/g++.dg/parse/crash50.C b/gcc/testsuite/g++.dg/parse/crash50.C index 711048de16..630eb25a94 100644 --- a/gcc/testsuite/g++.dg/parse/crash50.C +++ b/gcc/testsuite/g++.dg/parse/crash50.C @@ -2,7 +2,7 @@ // Origin PR c++/38636 // { dg-do compile } -struct A; // { dg-error "forward declaration of 'struct A'" } +struct A; // { dg-message "forward declaration of 'struct A'" } A::A( diff --git a/gcc/testsuite/g++.dg/parse/crash54.C b/gcc/testsuite/g++.dg/parse/crash54.C index 222082ab79..89d59ef2c1 100644 --- a/gcc/testsuite/g++.dg/parse/crash54.C +++ b/gcc/testsuite/g++.dg/parse/crash54.C @@ -1,6 +1,6 @@ // PR c++/42057 -struct A; // { dg-error "forward declaration" } +struct A; // { dg-message "forward declaration" } struct B { diff --git a/gcc/testsuite/g++.dg/parse/dtor7.C b/gcc/testsuite/g++.dg/parse/dtor7.C index a809512666..343b2e42c2 100644 --- a/gcc/testsuite/g++.dg/parse/dtor7.C +++ b/gcc/testsuite/g++.dg/parse/dtor7.C @@ -1,4 +1,4 @@ // PR c++/25856 -struct A; // { dg-error "forward" } +struct A; // { dg-message "forward" } A::~A() {} // { dg-error "incomplete" } diff --git a/gcc/testsuite/g++.dg/parse/error10.C b/gcc/testsuite/g++.dg/parse/error10.C index c2cd7e26ba..46c9eff7bb 100644 --- a/gcc/testsuite/g++.dg/parse/error10.C +++ b/gcc/testsuite/g++.dg/parse/error10.C @@ -14,6 +14,4 @@ template <typename T> void foo() enum typename A<T>::E e4; } -// Here, columns nums are not very accurate either. Still acceptable though -// { dg-error "30:invalid type in declaration before ';' token" "invalid" { target *-*-* } 14 } -// { dg-error "30:two or more data types in declaration of 'e4'" "2 or more" { target *-*-* } 14 } +// { dg-error "28:two or more data types in declaration of 'e4'" "2 or more" { target *-*-* } 14 } diff --git a/gcc/testsuite/g++.dg/parse/error11.C b/gcc/testsuite/g++.dg/parse/error11.C index 319e6acf2b..846e676c9c 100644 --- a/gcc/testsuite/g++.dg/parse/error11.C +++ b/gcc/testsuite/g++.dg/parse/error11.C @@ -33,7 +33,7 @@ template <int N> struct Foo2 {}; template struct Foo2<::B>; // { dg-error "21:'<::' cannot begin" "begin" { target { ! c++11 } } } // { dg-message "21:'<:' is an alternate" "alt" { target { ! c++11 } } 33 } // { dg-message "25:type/value mismatch" "mismatch" { target *-*-* } 33 } -// { dg-error "25:expected a constant" "const" { target *-*-* } 33 } +// { dg-message "25:expected a constant" "const" { target *-*-* } 33 } int value = 0; diff --git a/gcc/testsuite/g++.dg/parse/error15.C b/gcc/testsuite/g++.dg/parse/error15.C index deba54aca1..be002412ef 100644 --- a/gcc/testsuite/g++.dg/parse/error15.C +++ b/gcc/testsuite/g++.dg/parse/error15.C @@ -16,7 +16,6 @@ N::C::INVALID f4; // { dg-error "7:'INVALID' in 'struct N::C' does not name N::K f6; // { dg-error "4:'K' in namespace 'N' does not name a type" } typename N::A f7; // { dg-error "13:invalid use of template-name 'N::A' without an argument list" "13" { target *-*-* } 17 } -// { dg-error "17:invalid type in declaration before ';' token" "17" { target *-*-* } 17 } struct B { @@ -25,7 +24,7 @@ struct B N::C::INVALID f4; // { dg-error "9:'INVALID' in 'struct N::C' does not name a type" } N::K f6; // { dg-error "6:'K' in namespace 'N' does not name a type" } typename N::A f7; -// { dg-error "15:invalid use of template-name 'N::A' without an argument list" "15" { target *-*-* } 27 } +// { dg-error "15:invalid use of template-name 'N::A' without an argument list" "15" { target *-*-* } 26 } }; template <int> diff --git a/gcc/testsuite/g++.dg/parse/error19.C b/gcc/testsuite/g++.dg/parse/error19.C index 6d84f71424..a06d3e0c45 100644 --- a/gcc/testsuite/g++.dg/parse/error19.C +++ b/gcc/testsuite/g++.dg/parse/error19.C @@ -1,7 +1,7 @@ // { dg-options "-fshow-column -fmessage-length=0 -ansi -pedantic-errors -Wno-long-long " } // PR C++/17867 -struct A // { dg-message "8:operator=|no known conversion for implicit" } +struct A // { dg-message "8:operator=" } { A(int); }; @@ -10,6 +10,5 @@ const A& foo(); void bar() { - foo()=A(0); // { dg-error "8:no match for 'operator='" } - // { dg-message "candidate" "candidate note" { target *-*-* } 13 } + foo()=A(0); // { dg-error "8:no match|const" } } diff --git a/gcc/testsuite/g++.dg/parse/error2.C b/gcc/testsuite/g++.dg/parse/error2.C index 713957a319..ac7a14cb9d 100644 --- a/gcc/testsuite/g++.dg/parse/error2.C +++ b/gcc/testsuite/g++.dg/parse/error2.C @@ -12,4 +12,3 @@ Foo<func(g)> f; // { dg-error "5:'int func.double.' cannot appear in a constant- // { dg-error "10:'g' cannot appear in a constant-expression" "g" { target *-*-* } 11 } // { dg-error "11:a function call cannot appear in a constant-expression" "call" { target *-*-* } 11 } // { dg-error "12:template argument 1 is invalid" "invalid template argument" { target *-*-* } 11 } -// { dg-error "15:invalid type in declaration before ';' token" "invalid type" { target *-*-* } 11 } diff --git a/gcc/testsuite/g++.dg/parse/error28.C b/gcc/testsuite/g++.dg/parse/error28.C index 3ca210aa6b..8a8f22afc0 100644 --- a/gcc/testsuite/g++.dg/parse/error28.C +++ b/gcc/testsuite/g++.dg/parse/error28.C @@ -7,6 +7,5 @@ struct der : public virtual virt { // { dg-message "8:der::der|candidate expects }; struct top : public der { top () {} // { dg-bogus "der\\(const" } - // { dg-message "candidate" "candidate note" { target *-*-* } 9 } }; // { dg-error "10:no matching function for call to 'der" "" { target *-*-* } 9 } diff --git a/gcc/testsuite/g++.dg/parse/error40.C b/gcc/testsuite/g++.dg/parse/error40.C index 9ab7552ae8..643f1f56c5 100644 --- a/gcc/testsuite/g++.dg/parse/error40.C +++ b/gcc/testsuite/g++.dg/parse/error40.C @@ -1,7 +1,7 @@ // PR c++/31489 -class foo; // { dg-error "'class foo'" } -struct bar; // { dg-error "'struct bar'" } +class foo; // { dg-message "'class foo'" } +struct bar; // { dg-message "'struct bar'" } int main() { diff --git a/gcc/testsuite/g++.dg/parse/error50.C b/gcc/testsuite/g++.dg/parse/error50.C index dbd8958c36..f9c42dd7e4 100644 --- a/gcc/testsuite/g++.dg/parse/error50.C +++ b/gcc/testsuite/g++.dg/parse/error50.C @@ -15,4 +15,4 @@ struct B static T i; }; -template<> template <> int B<int>::i; // { dg-error "should be 1" } +template<> template <> int B<int>::i; // { dg-error "template|should be 1" } diff --git a/gcc/testsuite/g++.dg/parse/error54.C b/gcc/testsuite/g++.dg/parse/error54.C new file mode 100644 index 0000000000..b49c76b005 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/error54.C @@ -0,0 +1,19 @@ +// PR c++/51640 + +class ex {}; + +namespace t +{ + class ex2 : public ex {}; +} + +class ex2 : public ex {}; + +void bar() +{ + using namespace t; + + try { + } catch (ex2&) { // { dg-error "reference to 'ex2' is ambiguous" } + } +} diff --git a/gcc/testsuite/g++.dg/parse/error55.C b/gcc/testsuite/g++.dg/parse/error55.C new file mode 100644 index 0000000000..24cca50b2c --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/error55.C @@ -0,0 +1,7 @@ +// PR c++/60845 + +class A { }; +typedef A B; +void foo (B &a) { + a.x(); // { dg-error "'B {aka class A}' has no member named 'x'" } +} diff --git a/gcc/testsuite/g++.dg/parse/error56.C b/gcc/testsuite/g++.dg/parse/error56.C new file mode 100644 index 0000000000..7c81ab4488 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/error56.C @@ -0,0 +1,5 @@ +// PR c++/64129 + +template <0> int __copy_streambufs_eof; // { dg-error "" } +class { + friend __copy_streambufs_eof <> ( // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/parse/fnname1.C b/gcc/testsuite/g++.dg/parse/fnname1.C new file mode 100644 index 0000000000..2c18c30f8d --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/fnname1.C @@ -0,0 +1,17 @@ +// PR c++/64222 + +class A +{ +public: + A (const char *, void *); +}; +class B +{ +public: + B (A); +}; +void +fn1 () +{ + B a (A (__func__, 0)); +} diff --git a/gcc/testsuite/g++.dg/parse/fnname2.C b/gcc/testsuite/g++.dg/parse/fnname2.C new file mode 100644 index 0000000000..7fc0f82707 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/fnname2.C @@ -0,0 +1,19 @@ +// PR c++/64248 + +class A +{ +public: + A(const char* str) {}; +}; + +class B +{ +public: + B(A a) {}; +}; + +int main() +{ + B b(A(__func__)); + return 0; +} diff --git a/gcc/testsuite/g++.dg/parse/friend10.C b/gcc/testsuite/g++.dg/parse/friend10.C new file mode 100644 index 0000000000..16c2e0a7f3 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/friend10.C @@ -0,0 +1,9 @@ +// PR c++/19200 + +namespace N { + void S(); +} + +struct S { + friend void N::S(); +}; diff --git a/gcc/testsuite/g++.dg/parse/friend11.C b/gcc/testsuite/g++.dg/parse/friend11.C new file mode 100644 index 0000000000..61aae4ed63 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/friend11.C @@ -0,0 +1,6 @@ +// PR c++/19200 + +struct S { + struct T{}; + template<typename> friend void S(T); +}; diff --git a/gcc/testsuite/g++.dg/parse/friend12.C b/gcc/testsuite/g++.dg/parse/friend12.C new file mode 100644 index 0000000000..f0e28a8527 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/friend12.C @@ -0,0 +1,7 @@ +// PR c++/58650 + +struct A +{ + friend int i = 0; // { dg-error "cannot be declared friend" } +// { dg-error "non-static data member" "" { target { ! c++11 } } 5 } +}; diff --git a/gcc/testsuite/g++.dg/parse/friend7.C b/gcc/testsuite/g++.dg/parse/friend7.C index 668fd35d37..72ab430ef1 100644 --- a/gcc/testsuite/g++.dg/parse/friend7.C +++ b/gcc/testsuite/g++.dg/parse/friend7.C @@ -17,16 +17,16 @@ struct B struct C { - friend int C (); // { dg-error "return type|in friend decl" } + friend int C (); friend int ~C (); // { dg-error "return type|in friend decl" } - friend int C (const C &); // { dg-error "return type|in friend decl" } + friend int C (const C &); }; struct D { - friend int D () {} // { dg-error "return type|in friend decl" } + friend int D () {} friend int ~D () {} // { dg-error "return type|in friend decl" } - friend int D (const D &) {} // { dg-error "return type|in friend decl" } + friend int D (const D &) {} }; struct E diff --git a/gcc/testsuite/g++.dg/parse/friend9.C b/gcc/testsuite/g++.dg/parse/friend9.C new file mode 100644 index 0000000000..dd6729f17a --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/friend9.C @@ -0,0 +1,6 @@ +// PR c++/19200 + +struct S { + struct T{}; + friend void S(T); +}; diff --git a/gcc/testsuite/g++.dg/parse/fused-params1.C b/gcc/testsuite/g++.dg/parse/fused-params1.C index 33732fc287..ebb226befb 100644 --- a/gcc/testsuite/g++.dg/parse/fused-params1.C +++ b/gcc/testsuite/g++.dg/parse/fused-params1.C @@ -2,7 +2,7 @@ // Origin: Alexander Zvyagin <Alexander.Zviagine@cern.ch> // { dg-do compile } -template <int N,typename T> struct A // { dg-error "" } +template <int N,typename T> struct A // { dg-message "" } { typedef T X; template <int M> void foo (const A<M,X>&); diff --git a/gcc/testsuite/g++.dg/parse/ivdep-2.C b/gcc/testsuite/g++.dg/parse/ivdep-2.C new file mode 100644 index 0000000000..2b90109a81 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/ivdep-2.C @@ -0,0 +1,9 @@ +// PR c++/60211 + +void foo() +{} + int i; +#pragma GCC ivdep // { dg-error "must be inside a function" } + for (i = 0; i < 2; ++i) // { dg-error "expected|type" } + ; +} // { dg-error "expected" } diff --git a/gcc/testsuite/g++.dg/parse/ivdep-3.C b/gcc/testsuite/g++.dg/parse/ivdep-3.C new file mode 100644 index 0000000000..6d8541e36f --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/ivdep-3.C @@ -0,0 +1,8 @@ +// PR c++/60211 + +void foo() +{} +#pragma GCC ivdep // { dg-error "must be inside a function" } + for (int i = 0; i < 2; ++i) // { dg-error "expected|type" } + ; +} // { dg-error "expected" } diff --git a/gcc/testsuite/g++.dg/parse/new1.C b/gcc/testsuite/g++.dg/parse/new1.C index d61c44633c..d8c376617d 100644 --- a/gcc/testsuite/g++.dg/parse/new1.C +++ b/gcc/testsuite/g++.dg/parse/new1.C @@ -1,4 +1,4 @@ -struct T; // { dg-error "forward" } +struct T; // { dg-message "forward" } T* manage(T* t); template <class Obj> struct ObjectSlot0_ { void create() { diff --git a/gcc/testsuite/g++.dg/parse/pr34049.C b/gcc/testsuite/g++.dg/parse/pr34049.C new file mode 100644 index 0000000000..701a119ba1 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/pr34049.C @@ -0,0 +1,12 @@ +// PR c++/34049 + +struct foo +{ + int operator[](int) const { return 0; } +}; + +int main() +{ + (foo()[0]); + return 0; +} diff --git a/gcc/testsuite/g++.dg/parse/pr56961.C b/gcc/testsuite/g++.dg/parse/pr56961.C new file mode 100644 index 0000000000..c60cfdb17c --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/pr56961.C @@ -0,0 +1,16 @@ +// PR c++/56961 + +struct foo { }; + +typedef struct +{ + volatile foo fields; +} CSPHandleState; + +CSPHandleState a; + +void fn1 () +{ + CSPHandleState b; + b.fields = foo(); // { dg-error "discards qualifiers" } +} diff --git a/gcc/testsuite/g++.dg/parse/pr58664.C b/gcc/testsuite/g++.dg/parse/pr58664.C new file mode 100644 index 0000000000..489259a14a --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/pr58664.C @@ -0,0 +1,66 @@ +// PR c++/58664 +// { dg-do compile { target c++11 } } + +struct F; // { dg-message "forward declaration" } + +union U // { dg-message "not complete" } +{ + U u; // { dg-error "field 'u' has incomplete type 'U'" } +}; + +union CU // { dg-message "not complete" } +{ + const CU u; // { dg-error "incomplete type" } +}; + +template<typename T> +union UT // { dg-message "not complete" } +{ + UT u; // { dg-error "incomplete type" } +}; + +template union UT<int>; + +union UF +{ + F u; // { dg-error "field 'u' has incomplete type 'F'" } +}; + +template<typename T> +union UFT +{ + F u; // { dg-error "incomplete type" } +}; + +template union UFT<int>; + +struct S // { dg-message "not complete" } +{ + S s; // { dg-error "field 's' has incomplete type 'S'" } +}; + +struct VS // { dg-message "not complete" } +{ + volatile VS s; // { dg-error "incomplete type" } +}; + +template<typename T> +struct ST // { dg-message "not complete" } +{ + ST s; // { dg-error "incomplete type" } +}; + +template class ST<int>; + +struct SF +{ + F s; // { dg-error "field 's' has incomplete type 'F'" } +}; + +template<typename T> +struct SFT +{ + F s; // { dg-error "incomplete type" } +}; + +template class SFT<int>; diff --git a/gcc/testsuite/g++.dg/parse/pr58898.C b/gcc/testsuite/g++.dg/parse/pr58898.C new file mode 100644 index 0000000000..e788c913c6 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/pr58898.C @@ -0,0 +1,16 @@ +// PR c++/58898 + +template <typename = int> +struct Foo +{ + Foo() + { + int t(int()); // Error + } +}; + +int main() +{ + int t(int()); // OK + Foo<> a; // Error +} diff --git a/gcc/testsuite/g++.dg/parse/pr61804.C b/gcc/testsuite/g++.dg/parse/pr61804.C new file mode 100644 index 0000000000..898dc09984 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/pr61804.C @@ -0,0 +1,9 @@ +// PR c++/61804 + +struct T { void operator++(int); }; +void f() { (T())++; } + +struct U { void operator--(int); }; +void g() { (U())--; } + +void h() { int a; (int)++a; (int)--a; } diff --git a/gcc/testsuite/g++.dg/parse/too-many-tmpl-args1.C b/gcc/testsuite/g++.dg/parse/too-many-tmpl-args1.C index 4d98e75463..121bea2346 100644 --- a/gcc/testsuite/g++.dg/parse/too-many-tmpl-args1.C +++ b/gcc/testsuite/g++.dg/parse/too-many-tmpl-args1.C @@ -2,7 +2,7 @@ // Origin: Wolfgang Bangerth <bangerth@ticam.utexas.edu> // { dg-do compile } -template <typename T> class A // { dg-error "" } +template <typename T> class A // { dg-message "" } { struct B; template <typename U> friend typename A<U,void>::B foo(); // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/pch/pch.exp b/gcc/testsuite/g++.dg/pch/pch.exp index dd7466354b..0a1ffa4b2c 100644 --- a/gcc/testsuite/g++.dg/pch/pch.exp +++ b/gcc/testsuite/g++.dg/pch/pch.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1997-2014 Free Software Foundation, Inc. +# Copyright (C) 1997-2015 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/gcc/testsuite/g++.dg/plugin/dumb_plugin.c b/gcc/testsuite/g++.dg/plugin/dumb_plugin.c index e197d66725..3ed622d877 100644 --- a/gcc/testsuite/g++.dg/plugin/dumb_plugin.c +++ b/gcc/testsuite/g++.dg/plugin/dumb_plugin.c @@ -44,20 +44,6 @@ handle_end_of_compilation_unit (void *event_data, void *data) } -static unsigned int -execute_dumb_plugin_example (void) -{ - warning (0, G_("Analyze function %s"), - IDENTIFIER_POINTER (DECL_NAME (current_function_decl))); - return 0; -} - -static bool -gate_dumb_plugin_example (void) -{ - return true; -} - namespace { const pass_data pass_data_dumb_plugin_example = @@ -65,8 +51,6 @@ const pass_data pass_data_dumb_plugin_example = GIMPLE_PASS, /* type */ "dumb_plugin_example", /* name */ OPTGROUP_NONE, /* optinfo_flags */ - true, /* has_gate */ - true, /* has_execute */ TV_NONE, /* tv_id */ PROP_cfg, /* properties_required */ 0, /* properties_provided */ @@ -83,11 +67,18 @@ public: {} /* opt_pass methods: */ - bool gate () { return gate_dumb_plugin_example (); } - unsigned int execute () { return execute_dumb_plugin_example (); } + virtual unsigned int execute (function *); }; // class pass_dumb_plugin_example +unsigned int +pass_dumb_plugin_example::execute (function *) +{ + warning (0, G_("Analyze function %s"), + IDENTIFIER_POINTER (DECL_NAME (current_function_decl))); + return 0; +} + } // anon namespace static gimple_opt_pass * diff --git a/gcc/testsuite/g++.dg/plugin/plugin.exp b/gcc/testsuite/g++.dg/plugin/plugin.exp index e97fb76a27..1051207a1b 100644 --- a/gcc/testsuite/g++.dg/plugin/plugin.exp +++ b/gcc/testsuite/g++.dg/plugin/plugin.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2009-2014 Free Software Foundation, Inc. +# Copyright (C) 2009-2015 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -44,6 +44,15 @@ if $tracelevel then { # Load support procs. load_lib plugin-support.exp +# These tests don't run runtest_file_p consistently if it +# doesn't return the same values, so disable parallelization +# of this *.exp file. The first parallel runtest to reach +# this will run all the tests serially. +if ![gcc_parallel_test_run_p plugin] { + return +} +gcc_parallel_test_enable 0 + # Specify the plugin source file and the associated test files in a list. # plugin_test_list={ {plugin1 test1 test2 ...} {plugin2 test1 ...} ... } set plugin_test_list [list \ @@ -68,3 +77,5 @@ foreach plugin_test $plugin_test_list { set plugin_input_tests [lreplace $plugin_test 0 0] plugin-test-execute $plugin_src $plugin_input_tests } + +gcc_parallel_test_enable 1 diff --git a/gcc/testsuite/g++.dg/plugin/selfassign.c b/gcc/testsuite/g++.dg/plugin/selfassign.c index 041f25dce3..cfddada9e5 100644 --- a/gcc/testsuite/g++.dg/plugin/selfassign.c +++ b/gcc/testsuite/g++.dg/plugin/selfassign.c @@ -11,7 +11,6 @@ #include "stringpool.h" #include "toplev.h" #include "basic-block.h" -#include "pointer-set.h" #include "hash-table.h" #include "vec.h" #include "ggc.h" @@ -253,31 +252,6 @@ warn_self_assign (gimple stmt) } } -/* Entry point for the self-assignment detection pass. */ - -static unsigned int -execute_warn_self_assign (void) -{ - gimple_stmt_iterator gsi; - basic_block bb; - - FOR_EACH_BB_FN (bb, cfun) - { - for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) - warn_self_assign (gsi_stmt (gsi)); - } - - return 0; -} - -/* Pass gate function. Currently always returns true. */ - -static bool -gate_warn_self_assign (void) -{ - return true; -} - namespace { const pass_data pass_data_warn_self_assign = @@ -285,8 +259,6 @@ const pass_data pass_data_warn_self_assign = GIMPLE_PASS, /* type */ "warn_self_assign", /* name */ OPTGROUP_NONE, /* optinfo_flags */ - true, /* has_gate */ - true, /* has_execute */ TV_NONE, /* tv_id */ PROP_ssa, /* properties_required */ 0, /* properties_provided */ @@ -303,11 +275,26 @@ public: {} /* opt_pass methods: */ - bool gate () { return gate_warn_self_assign (); } - unsigned int execute () { return execute_warn_self_assign (); } + bool gate (function *) { return true; } + virtual unsigned int execute (function *); }; // class pass_warn_self_assign +unsigned int +pass_warn_self_assign::execute (function *fun) +{ + gimple_stmt_iterator gsi; + basic_block bb; + + FOR_EACH_BB_FN (bb, fun) + { + for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + warn_self_assign (gsi_stmt (gsi)); + } + + return 0; +} + } // anon namespace static gimple_opt_pass * diff --git a/gcc/testsuite/g++.dg/pr45788.C b/gcc/testsuite/g++.dg/pr45788.C index de3340df33..0f4db20c76 100644 --- a/gcc/testsuite/g++.dg/pr45788.C +++ b/gcc/testsuite/g++.dg/pr45788.C @@ -1,4 +1,4 @@ -// { dg-do compile { target x86_64-*-* } } +// { dg-do compile { target i?86-*-* x86_64-*-* } } // { dg-options "-O3 -fwhole-program -msse2" } typedef long unsigned int __darwin_size_t; diff --git a/gcc/testsuite/g++.dg/pr48484.C b/gcc/testsuite/g++.dg/pr48484.C index 3f17f39a0a..1380c452fa 100644 --- a/gcc/testsuite/g++.dg/pr48484.C +++ b/gcc/testsuite/g++.dg/pr48484.C @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O -finline-functions -finline-small-functions -Wuninitialized" } */ - +/* { dg-add-options bind_pic_locally } */ struct SQObjectPtr { diff --git a/gcc/testsuite/g++.dg/pr54442.C b/gcc/testsuite/g++.dg/pr54442.C new file mode 100644 index 0000000000..a489565616 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr54442.C @@ -0,0 +1,12 @@ +/* { dg-do compile } */ + +struct S +{ + void s (int) const throw (); + void s (int) throw (); +}; + +typedef int index_t; + +void (S::*f) (index_t) = &S::s; +void (S::*g) (index_t) const = &S::s; diff --git a/gcc/testsuite/g++.dg/pr57662.C b/gcc/testsuite/g++.dg/pr57662.C index 1354790e97..bd5793dcae 100644 --- a/gcc/testsuite/g++.dg/pr57662.C +++ b/gcc/testsuite/g++.dg/pr57662.C @@ -1,4 +1,4 @@ -/* { dg-do compile { target powerpc*-*-* ia64-*-* x86_64-*-* } } */ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ /* { dg-options "-O2 -fselective-scheduling2 -fsel-sched-pipelining" } */ extern "C" { diff --git a/gcc/testsuite/g++.dg/pr58123.C b/gcc/testsuite/g++.dg/pr58123.C new file mode 100644 index 0000000000..7fe1a27651 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr58123.C @@ -0,0 +1,18 @@ +// { dg-do compile } +// { dg-options "-fdump-tree-gimple-lineno" } + +// Test that the TRY block's location is the definition of "C a". + +class C { +public: + C() {} + ~C() {} + int m() { return 0; } +}; +int main() { + C a; + return a.m(); +} + +// { dg-final { scan-tree-dump-times "pr58123.C:13\.6\] try" 1 "gimple" } } +// { dg-final { cleanup-tree-dump "gimple" } } diff --git a/gcc/testsuite/g++.dg/pr61289-2.c b/gcc/testsuite/g++.dg/pr61289-2.C index 4cc3ebe468..4cc3ebe468 100644 --- a/gcc/testsuite/g++.dg/pr61289-2.c +++ b/gcc/testsuite/g++.dg/pr61289-2.C diff --git a/gcc/testsuite/g++.dg/pr61324.C b/gcc/testsuite/g++.dg/pr61324.C new file mode 100644 index 0000000000..610257436b --- /dev/null +++ b/gcc/testsuite/g++.dg/pr61324.C @@ -0,0 +1,13 @@ +// { dg-do compile } +// { dg-options "-O -fkeep-inline-functions -fno-use-cxa-atexit" } +void foo (); + +struct S +{ + ~S () + { + foo (); + } +}; + +S s; diff --git a/gcc/testsuite/g++.dg/pr63766.C b/gcc/testsuite/g++.dg/pr63766.C new file mode 100644 index 0000000000..1414fbe52b --- /dev/null +++ b/gcc/testsuite/g++.dg/pr63766.C @@ -0,0 +1,48 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c++11 -O2" } */ + +class A +{ + public: + void + getValueType () + { + } + void getTypeClass (); +}; +template <typename ImplClass> class B +{ + public: + void + Visit (A *p1) + { + p1->getTypeClass (); + static_cast<ImplClass *> (0)->VisitAtomicType (0); + } +}; +class C : B<C> +{ + template <typename Fn> + void + dumpChild (Fn p1) + { + p1 (); + } + + public: + void dumpTypeAsChild (int); + void + VisitAtomicType (A *p1) + { + p1->getValueType (); + dumpTypeAsChild (0); + } +}; +void +C::dumpTypeAsChild (int) +{ + dumpChild ([=] + { + Visit (0); + }); +} diff --git a/gcc/testsuite/g++.dg/pr63995-1.C b/gcc/testsuite/g++.dg/pr63995-1.C new file mode 100644 index 0000000000..82e76063ef --- /dev/null +++ b/gcc/testsuite/g++.dg/pr63995-1.C @@ -0,0 +1,16 @@ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-require-effective-target mpx } */ +/* { dg-options "-O2 -g -fcheck-pointer-bounds -mmpx" } */ + +int test1 (int i) +{ + extern const int arr[10]; + return arr[i]; +} + +extern const int arr[10]; + +int test2 (int i) +{ + return arr[i]; +} diff --git a/gcc/testsuite/g++.dg/pr64037.C b/gcc/testsuite/g++.dg/pr64037.C new file mode 100644 index 0000000000..e5cd0e2ee1 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr64037.C @@ -0,0 +1,27 @@ +// { dg-do run { target i?86-*-* x86_64-*-* } } +// { dg-options "-std=c++11 -Os" } + +enum class X : unsigned char { + V = 2, +}; + +static void +__attribute__((noinline,noclone)) +foo(unsigned &out, unsigned a, X b) +{ + out = static_cast<unsigned>(b); +} + +int main() +{ + unsigned deadbeef = 0xDEADBEEF; + asm volatile ("" : "+d" (deadbeef), "+c" (deadbeef)); + + unsigned out; + foo(out, 2, X::V); + + if (out != 2) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/g++.dg/pr64191.C b/gcc/testsuite/g++.dg/pr64191.C new file mode 100644 index 0000000000..e40a62d084 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr64191.C @@ -0,0 +1,25 @@ +// { dg-do compile } +// { dg-options "-O2 -fdump-tree-cddce1" } + +struct Bar +{ + int i; + ~Bar() { } +}; +void bar_dtor_loop(Bar* p, unsigned int n) +{ + if (p) { + Bar* e = p + n; + while (e > p) { + --e; + e->~Bar(); + } + } +} + +// The clobber in ~Bar should persist but those inlined into +// bar_dtor_loop not, nor should the loop therein + +// { dg-final { scan-tree-dump-times "CLOBBER" 1 "cddce1" } } +// { dg-final { scan-tree-dump-times "if" 0 "cddce1" } } +// { dg-final { cleanup-tree-dump "cddce1" } } diff --git a/gcc/testsuite/g++.dg/pr64353.C b/gcc/testsuite/g++.dg/pr64353.C new file mode 100644 index 0000000000..7859918cf5 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr64353.C @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +class C +{ + int y, x; + void i (); + bool __attribute__((const)) xx () { return x; } +}; + +void C::i () +{ + if (xx ()) + x = 1; +} diff --git a/gcc/testsuite/g++.dg/pr64688-2.C b/gcc/testsuite/g++.dg/pr64688-2.C new file mode 100644 index 0000000000..c4a22b8076 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr64688-2.C @@ -0,0 +1,136 @@ +// { dg-do compile { target i?86-*-* x86_64-*-* } } +// { dg-options "-std=c++11 -O3 -march=westmere" } + +template <int> struct int_ {}; +template <typename> struct add_const { typedef int type; }; +template <typename> struct add_reference { typedef int type; }; +template <typename T> struct next { typedef typename T::next type; }; +template <typename> struct size_impl; +template <typename T> struct msvc_eti_base : T {}; +template <int N> struct long_ { + static const int value = N; + typedef long_<N + 1> next; +}; +template <typename Sequence> +struct size : msvc_eti_base<typename size_impl< +typename Sequence::tag>::template apply<Sequence>> {}; +template <typename Base> struct v_item : Base { + typedef typename next<typename Base::size>::type size; +}; +template <typename = int> struct vector0 { + typedef int tag; + typedef long_<0> size; +}; +template <> struct size_impl<int> { + template <typename Vector> struct apply : Vector::size {}; +}; +template <typename> struct vector3 : v_item<v_item<v_item<vector0<>>>> {}; +template <typename> struct layout { typedef vector3<int> color_space_t; }; +template <typename> struct kth_element_const_reference_type; +template <typename> struct iterator_adaptor_get_base; +template <typename, typename, int> struct homogeneous_color_base; +template <typename> struct element_const_reference_type; +template <typename Element, typename Layout> + struct homogeneous_color_base<Element, Layout, 3> { + Element _v0, _v1, _v2; + typename element_const_reference_type<homogeneous_color_base>::type + at(int_<0>) { + return _v0; + } + typename element_const_reference_type<homogeneous_color_base>::type + at(int_<1>) { + return _v1; + } + typename element_const_reference_type<homogeneous_color_base>::type + at(int_<2>) { + return _v2; + } +}; +template <typename Element, typename Layout, int K1> + struct kth_element_const_reference_type< + homogeneous_color_base<Element, Layout, K1>> + : add_reference<typename add_const<Element>::type> {}; +template <int K, typename E, typename L, int N> + typename add_reference<typename add_const<E>::type>::type + at_c(homogeneous_color_base<E, L, N> p1) { + return p1.at(int_<K>()); +} +template <typename> class memory_based_step_iterator; +template <typename> class memory_based_2d_locator; +template <typename> class image_view; +template <typename, typename> struct pixel; +struct iterator_type_from_pixel { + typedef pixel<unsigned char, layout<vector3<int>>> *type; +}; +template <typename XIterator> struct type_from_x_iterator { + typedef image_view< + memory_based_2d_locator<memory_based_step_iterator<XIterator>>> view_t; +}; +template <typename> +struct element_const_reference_type +: kth_element_const_reference_type< +homogeneous_color_base<unsigned, layout<int>, 3>> {}; +template <typename, typename> + struct pixel : homogeneous_color_base<unsigned char, layout<int>, + size<layout<int>::color_space_t>::value> { +}; +template <typename Iterator> +struct iterator_adaptor_get_base<memory_based_step_iterator<Iterator>> { + typedef Iterator type; +}; +template <typename> class memory_based_2d_locator { + public: + typedef iterator_adaptor_get_base<memory_based_step_iterator< + pixel<unsigned, layout<vector3<int>>> *>>::type x_iterator; +}; +template <typename> class image_view { + public: + typedef memory_based_2d_locator<int>::x_iterator x_iterator; + x_iterator row_begin___trans_tmp_2; + x_iterator row_begin(int) { return row_begin___trans_tmp_2; } +}; +template <typename, bool, typename = int> class image { + public: + typedef type_from_x_iterator<iterator_type_from_pixel::type>::view_t view_t; + image(int); +}; +template <typename Pixel, bool IsPlanar, typename Alloc> + typename image<Pixel, 0>::view_t view(image<Pixel, IsPlanar, Alloc>); +template <typename Op> void measure_time(Op p1) { + for (;;) + p1(); +} +template <typename, typename> struct fill_nongil_t; +template <typename T, typename P> + struct fill_nongil_t< + image_view<memory_based_2d_locator< + memory_based_step_iterator<pixel<T, layout<vector3<int>>> *>>>, + P> { + typedef image_view<memory_based_2d_locator< + memory_based_step_iterator<pixel<T, layout<vector3<int>>> *>>> View; + View _v; + P _p; + fill_nongil_t(View p1, P) : _v(p1) {} + void operator()() { + T *first = (T *)_v.row_begin(0); + T last; + while (first != &last) { + first[0] = at_c<0>(_p); + first[1] = at_c<1>(_p); + first[2] = at_c<2>(_p); + first += 3; + } + } +}; +template <typename, typename> void test_fill(int) { + image<int, 0>::view_t __trans_tmp_1; + image<int, 0> im(0); + __trans_tmp_1 = view(im); + measure_time(fill_nongil_t< + image_view<memory_based_2d_locator<memory_based_step_iterator< + pixel<unsigned char, layout<vector3<int>>> *>>>, + pixel<unsigned, int>>(__trans_tmp_1, pixel<unsigned, int>())); +} +void performance_testtest_method() { + test_fill<image_view<int>, pixel<unsigned, int>>(0); +} diff --git a/gcc/testsuite/g++.dg/pr64688.C b/gcc/testsuite/g++.dg/pr64688.C new file mode 100644 index 0000000000..3525e49b73 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr64688.C @@ -0,0 +1,71 @@ +// { dg-do compile { target i?86-*-* x86_64-*-* } } +// { dg-options "-std=c++11 -O3 -march=westmere" } + +template <typename T> struct A { typedef typename T::next type; }; +template <typename> struct B; +template <typename T> struct N : T {}; +template <int N> struct C { + static const int value = N; + typedef C<N + 1> next; +}; +template <typename Sequence> +struct R : N<typename B<typename Sequence::tag>::template P<Sequence>> {}; +template <typename Base> struct O : Base { + typedef typename A<typename Base::size>::type size; +}; +template <typename = int> struct D { + typedef int tag; + typedef C<0> size; +}; +template <> struct B<int> { + template <typename> struct P : O<O<O<D<>>>>::size {}; +}; +template <typename> struct F; +template <typename> struct G; +template <typename, typename, int> struct H; +template <typename Element, typename Layout> struct H<Element, Layout, 3> {}; +template <int, typename E, typename L, int N> unsigned char at_c(H<E, L, N>) {} +template <typename> class I; +template <typename> class J; +template <typename> class K; +template <typename, typename> struct Q; +struct L { + typedef Q<unsigned char, F<O<O<O<D<>>>>>> *type; +}; +template <typename XIterator> struct M { typedef K<J<I<XIterator>>> view_t; }; +template <typename, typename> +struct Q : H<unsigned, F<int>, R<O<O<O<D<>>>>>::value> {}; +template <typename Iterator> struct G<I<Iterator>> { typedef Iterator type; }; +template <typename> class J { +public: + typedef G<I<Q<unsigned, int> *>>::type x_iterator; +}; +template <typename> class K { +public: + J<int>::x_iterator row_begin(int); +}; +template <typename Op> void measure_time(Op p1) { p1(); } +template <typename, typename> struct fill_nongil_t; +template <typename T, typename P> +struct fill_nongil_t<K<J<I<Q<T, F<O<O<O<D<>>>>>> *>>>, P> { + typedef K<J<I<Q<T, F<O<O<O<D<>>>>>> *>>> View; + View _v; + P _p; + fill_nongil_t(View, P); + void operator()() { + T *first = (T *)_v.row_begin(0); + T last; + while (first != &last) { + first[0] = first[1] = at_c<1>(_p); + first[2] = at_c<2>(_p); + first += 3; + } + } +}; +template <typename, typename> void test_fill(int) { + M<L::type>::view_t __trans_tmp_1; + measure_time(fill_nongil_t<K<J<I<Q<unsigned char, F<O<O<O<D<>>>>>> *>>>, + Q<unsigned char, F<O<O<O<D<>>>>>>>( + __trans_tmp_1, Q<unsigned char, F<O<O<O<D<>>>>>>())); +} +void performance_testtest_method() { test_fill<K<int>, Q<unsigned, int>>(0); } diff --git a/gcc/testsuite/g++.dg/pr65032.C b/gcc/testsuite/g++.dg/pr65032.C new file mode 100644 index 0000000000..a62f50b49b --- /dev/null +++ b/gcc/testsuite/g++.dg/pr65032.C @@ -0,0 +1,87 @@ +// { dg-do compile { target i?86-*-* x86_64-*-* } } +// { dg-options "-Os -std=c++11 -fPIC -fstack-protector-strong -fomit-frame-pointer" } + +#pragma GCC visibility push(hidden) +#pragma GCC visibility push(default) +extern "C" { + typedef int int64_t __attribute__ ((__mode__ (__DI__))); +} +enum class nsresult; +#pragma GCC visibility pop +class A +{ + float mRawPtr; + + public: + A (float *); +}; +class B +{ + public: + B (int64_t, int, int); +}; +typedef struct +{ + int channels; +} vorbis_info; +template <typename _Key> class C +{ + public: + typedef int size_type; + size_type erase (_Key &); +}; + +template <typename _Key> class D +{ + public: + typedef _Key key_type; + typedef C<key_type> _Rep_type; + _Rep_type _M_t; + typename _Rep_type::size_type + erase (key_type p1) + { + return _M_t.erase (p1); + } +}; + +class F +{ + public: + vorbis_info mInfo; + D<int *> mVorbisPacketSamples; + void ValidateVorbisPacketSamples (int *); + int64_t Time (int64_t); +}; +class G +{ + nsresult DecodeVorbis (int *); + F *mVorbisState; + int64_t mDecodedAudioFrames; +}; +int fn1 (float ***); +void fn2 (int); +void +F::ValidateVorbisPacketSamples (int *p1) +{ + mVorbisPacketSamples.erase (p1); +} + +nsresult +G::DecodeVorbis (int *p1) +{ + float **a; + int b; + long long c; + while ((b = fn1 (&a))) + { + mVorbisState->ValidateVorbisPacketSamples (p1); + A (new float); + for (; mVorbisState->mInfo.channels;) + { + } + int64_t d = mVorbisState->Time (c - b); + (B (d, b, mVorbisState->mInfo.channels)); + mDecodedAudioFrames -= b; + fn2 (b); + } +} diff --git a/gcc/testsuite/g++.dg/pr65049.C b/gcc/testsuite/g++.dg/pr65049.C new file mode 100644 index 0000000000..7ced500a6f --- /dev/null +++ b/gcc/testsuite/g++.dg/pr65049.C @@ -0,0 +1,19 @@ +// PR middle-end/65409 +// Reported by Ignacy Gawedzki <bugs@qult.net> + +struct Foo +{ + Foo() {} + int a; + int b; + char c; +}; + +Foo copy_foo(Foo); + +struct Bar : Foo +{ + Bar(Foo t) : Foo(copy_foo(t)) {} +}; + +Bar a = Foo(); diff --git a/gcc/testsuite/g++.dg/pr65240-1.C b/gcc/testsuite/g++.dg/pr65240-1.C new file mode 100644 index 0000000000..3282b8e5ee --- /dev/null +++ b/gcc/testsuite/g++.dg/pr65240-1.C @@ -0,0 +1,9 @@ +/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */ +/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */ +/* { dg-require-effective-target powerpc_p8vector_ok } */ +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */ +/* { dg-options "-mcpu=power8 -O3 -ffast-math -mcmodel=small -mno-fp-in-toc" } */ + +/* target/65240, compiler got a 'insn does not satisfy its constraints' error. */ + +#include "pr65240.h" diff --git a/gcc/testsuite/g++.dg/pr65240-2.C b/gcc/testsuite/g++.dg/pr65240-2.C new file mode 100644 index 0000000000..80cb82f82f --- /dev/null +++ b/gcc/testsuite/g++.dg/pr65240-2.C @@ -0,0 +1,9 @@ +/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */ +/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */ +/* { dg-require-effective-target powerpc_p8vector_ok } */ +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */ +/* { dg-options "-mcpu=power8 -O3 -ffast-math -mcmodel=small -mfp-in-toc" } */ + +/* target/65240, compiler got a 'insn does not satisfy its constraints' error. */ + +#include "pr65240.h" diff --git a/gcc/testsuite/g++.dg/pr65240-3.C b/gcc/testsuite/g++.dg/pr65240-3.C new file mode 100644 index 0000000000..57f0b80169 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr65240-3.C @@ -0,0 +1,9 @@ +/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */ +/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */ +/* { dg-require-effective-target powerpc_p8vector_ok } */ +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */ +/* { dg-options "-mcpu=power8 -O3 -ffast-math -mcmodel=medium" } */ + +/* target/65240, compiler got a 'insn does not satisfy its constraints' error. */ + +#include "pr65240.h" diff --git a/gcc/testsuite/g++.dg/pr65240-4.C b/gcc/testsuite/g++.dg/pr65240-4.C new file mode 100644 index 0000000000..b6a1007a84 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr65240-4.C @@ -0,0 +1,9 @@ +/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */ +/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */ +/* { dg-require-effective-target powerpc_vsx_ok } */ +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power7" } } */ +/* { dg-options "-mcpu=power7 -O3 -ffast-math" } */ + +/* target/65240, compiler got a 'insn does not satisfy its constraints' error. */ + +#include "pr65240.h" diff --git a/gcc/testsuite/g++.dg/pr65240.h b/gcc/testsuite/g++.dg/pr65240.h new file mode 100644 index 0000000000..6b9c8c0469 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr65240.h @@ -0,0 +1,5518 @@ +// -*- C++ -*- + +#include <stdio.h> +#include <stddef.h> +#include <stdint.h> +#include <ctype.h> +#include <unistd.h> +#include <string.h> +#include <stdlib.h> +#include <math.h> +#include <sys/types.h> +#include <time.h> +#include <signal.h> +#include <pthread.h> + +void xmlCheckVersion (int version); +typedef unsigned char xmlChar; +xmlChar *xmlStrdup (const xmlChar * cur); +xmlChar *xmlStrndup (const xmlChar * cur, int len); +xmlChar *xmlCharStrndup (const char *cur, int len); +xmlChar *xmlCharStrdup (const char *cur); +xmlChar *xmlStrsub (const xmlChar * str, int start, int len); +const xmlChar *xmlStrchr (const xmlChar * str, xmlChar val); +const xmlChar *xmlStrstr (const xmlChar * str, const xmlChar * val); +const xmlChar *xmlStrcasestr (const xmlChar * str, const xmlChar * val); +int xmlStrcmp (const xmlChar * str1, const xmlChar * str2); +int xmlStrncmp (const xmlChar * str1, const xmlChar * str2, int len); +int xmlStrcasecmp (const xmlChar * str1, const xmlChar * str2); +int xmlStrncasecmp (const xmlChar * str1, const xmlChar * str2, int len); +int xmlStrEqual (const xmlChar * str1, const xmlChar * str2); +int xmlStrQEqual (const xmlChar * pref, + const xmlChar * name, const xmlChar * str); +int xmlStrlen (const xmlChar * str); +xmlChar *xmlStrcat (xmlChar * cur, const xmlChar * add); +xmlChar *xmlStrncat (xmlChar * cur, const xmlChar * add, int len); +xmlChar *xmlStrncatNew (const xmlChar * str1, const xmlChar * str2, int len); +int xmlStrPrintf (xmlChar * buf, int len, const xmlChar * msg, ...); +int xmlStrVPrintf (xmlChar * buf, int len, const xmlChar * msg, va_list ap); +int xmlGetUTF8Char (const unsigned char *utf, int *len); +int xmlCheckUTF8 (const unsigned char *utf); +int xmlUTF8Strsize (const xmlChar * utf, int len); +xmlChar *xmlUTF8Strndup (const xmlChar * utf, int len); +const xmlChar *xmlUTF8Strpos (const xmlChar * utf, int pos); +int xmlUTF8Strloc (const xmlChar * utf, const xmlChar * utfchar); +xmlChar *xmlUTF8Strsub (const xmlChar * utf, int start, int len); +int xmlUTF8Strlen (const xmlChar * utf); +int xmlUTF8Size (const xmlChar * utf); +int xmlUTF8Charcmp (const xmlChar * utf1, const xmlChar * utf2); + +typedef struct _xmlParserInputBuffer xmlParserInputBuffer; +typedef xmlParserInputBuffer *xmlParserInputBufferPtr; +typedef struct _xmlOutputBuffer xmlOutputBuffer; +typedef xmlOutputBuffer *xmlOutputBufferPtr; +typedef struct _xmlParserInput xmlParserInput; +typedef xmlParserInput *xmlParserInputPtr; +typedef struct _xmlParserCtxt xmlParserCtxt; +typedef xmlParserCtxt *xmlParserCtxtPtr; +typedef struct _xmlSAXLocator xmlSAXLocator; +typedef xmlSAXLocator *xmlSAXLocatorPtr; +typedef struct _xmlSAXHandler xmlSAXHandler; +typedef xmlSAXHandler *xmlSAXHandlerPtr; +typedef struct _xmlEntity xmlEntity; +typedef xmlEntity *xmlEntityPtr; + +typedef enum +{ + XML_BUFFER_ALLOC_DOUBLEIT, + XML_BUFFER_ALLOC_EXACT, + XML_BUFFER_ALLOC_IMMUTABLE, + XML_BUFFER_ALLOC_IO, + XML_BUFFER_ALLOC_HYBRID +} xmlBufferAllocationScheme; + +typedef struct _xmlBuffer xmlBuffer; +typedef xmlBuffer *xmlBufferPtr; + +struct _xmlBuffer +{ + xmlChar *content; + unsigned int use; + unsigned int size; + xmlBufferAllocationScheme alloc; + xmlChar *contentIO; +}; + +typedef struct _xmlBuf xmlBuf; +typedef xmlBuf *xmlBufPtr; + +xmlChar *xmlBufContent (const xmlBuf * buf); +xmlChar *xmlBufEnd (xmlBufPtr buf); +size_t xmlBufUse (const xmlBufPtr buf); +size_t xmlBufShrink (xmlBufPtr buf, size_t len); + +typedef enum +{ + XML_ELEMENT_NODE = 1, + XML_ATTRIBUTE_NODE = 2, + XML_TEXT_NODE = 3, + XML_CDATA_SECTION_NODE = 4, + XML_ENTITY_REF_NODE = 5, + XML_ENTITY_NODE = 6, + XML_PI_NODE = 7, + XML_COMMENT_NODE = 8, + XML_DOCUMENT_NODE = 9, + XML_DOCUMENT_TYPE_NODE = 10, + XML_DOCUMENT_FRAG_NODE = 11, + XML_NOTATION_NODE = 12, + XML_HTML_DOCUMENT_NODE = 13, + XML_DTD_NODE = 14, + XML_ELEMENT_DECL = 15, + XML_ATTRIBUTE_DECL = 16, + XML_ENTITY_DECL = 17, + XML_NAMESPACE_DECL = 18, + XML_XINCLUDE_START = 19, + XML_XINCLUDE_END = 20, XML_DOCB_DOCUMENT_NODE = 21 +} xmlElementType; + +typedef struct _xmlNotation xmlNotation; +typedef xmlNotation *xmlNotationPtr; + +struct _xmlNotation +{ + const xmlChar *name; + const xmlChar *PublicID; + const xmlChar *SystemID; +}; + +typedef enum +{ + XML_ATTRIBUTE_CDATA = 1, + XML_ATTRIBUTE_ID, + XML_ATTRIBUTE_IDREF, + XML_ATTRIBUTE_IDREFS, + XML_ATTRIBUTE_ENTITY, + XML_ATTRIBUTE_ENTITIES, + XML_ATTRIBUTE_NMTOKEN, + XML_ATTRIBUTE_NMTOKENS, + XML_ATTRIBUTE_ENUMERATION, + XML_ATTRIBUTE_NOTATION +} xmlAttributeType; + +typedef enum +{ + XML_ATTRIBUTE_NONE = 1, + XML_ATTRIBUTE_REQUIRED, + XML_ATTRIBUTE_IMPLIED, + XML_ATTRIBUTE_FIXED +} xmlAttributeDefault; + +typedef struct _xmlEnumeration xmlEnumeration; +typedef xmlEnumeration *xmlEnumerationPtr; + +struct _xmlEnumeration +{ + struct _xmlEnumeration *next; + const xmlChar *name; +}; + +typedef struct _xmlAttribute xmlAttribute; +typedef xmlAttribute *xmlAttributePtr; +struct _xmlAttribute +{ + void *_private; + xmlElementType type; + const xmlChar *name; + struct _xmlNode *children; + struct _xmlNode *last; + struct _xmlDtd *parent; + struct _xmlNode *next; + struct _xmlNode *prev; + struct _xmlDoc *doc; + + struct _xmlAttribute *nexth; + xmlAttributeType atype; + xmlAttributeDefault def; + const xmlChar *defaultValue; + xmlEnumerationPtr tree; + const xmlChar *prefix; + const xmlChar *elem; +}; + +typedef enum +{ + XML_ELEMENT_CONTENT_PCDATA = 1, + XML_ELEMENT_CONTENT_ELEMENT, + XML_ELEMENT_CONTENT_SEQ, + XML_ELEMENT_CONTENT_OR +} xmlElementContentType; + +typedef enum +{ + XML_ELEMENT_CONTENT_ONCE = 1, + XML_ELEMENT_CONTENT_OPT, + XML_ELEMENT_CONTENT_MULT, + XML_ELEMENT_CONTENT_PLUS +} xmlElementContentOccur; + +typedef struct _xmlElementContent xmlElementContent; +typedef xmlElementContent *xmlElementContentPtr; + +struct _xmlElementContent +{ + xmlElementContentType type; + xmlElementContentOccur ocur; + const xmlChar *name; + struct _xmlElementContent *c1; + struct _xmlElementContent *c2; + struct _xmlElementContent *parent; + const xmlChar *prefix; +}; + +typedef enum +{ + XML_ELEMENT_TYPE_UNDEFINED = 0, + XML_ELEMENT_TYPE_EMPTY = 1, + XML_ELEMENT_TYPE_ANY, + XML_ELEMENT_TYPE_MIXED, + XML_ELEMENT_TYPE_ELEMENT +} xmlElementTypeVal; + +typedef struct _xmlRegexp xmlRegexp; +typedef xmlRegexp *xmlRegexpPtr; +typedef struct _xmlRegExecCtxt xmlRegExecCtxt; +typedef xmlRegExecCtxt *xmlRegExecCtxtPtr; +typedef struct _xmlDict xmlDict; +typedef xmlDict *xmlDictPtr; + +int xmlInitializeDict (void); +xmlDictPtr xmlDictCreate (void); +size_t xmlDictSetLimit (xmlDictPtr dict, size_t limit); +size_t xmlDictGetUsage (xmlDictPtr dict); +xmlDictPtr xmlDictCreateSub (xmlDictPtr sub); +int xmlDictReference (xmlDictPtr dict); +void xmlDictFree (xmlDictPtr dict); +const xmlChar *xmlDictLookup (xmlDictPtr dict, const xmlChar * name, int len); +const xmlChar *xmlDictExists (xmlDictPtr dict, const xmlChar * name, int len); +const xmlChar *xmlDictQLookup (xmlDictPtr dict, + const xmlChar * prefix, const xmlChar * name); +int xmlDictOwns (xmlDictPtr dict, const xmlChar * str); +int xmlDictSize (xmlDictPtr dict); +void xmlDictCleanup (void); +xmlRegexpPtr xmlRegexpCompile (const xmlChar * regexp); +void xmlRegFreeRegexp (xmlRegexpPtr regexp); +int xmlRegexpExec (xmlRegexpPtr comp, const xmlChar * value); +void xmlRegexpPrint (FILE * output, xmlRegexpPtr regexp); +int xmlRegexpIsDeterminist (xmlRegexpPtr comp); +typedef void (*xmlRegExecCallbacks) (xmlRegExecCtxtPtr exec, + const xmlChar * token, + void *transdata, void *inputdata); +xmlRegExecCtxtPtr +xmlRegNewExecCtxt (xmlRegexpPtr comp, + xmlRegExecCallbacks callback, void *data); +void xmlRegFreeExecCtxt (xmlRegExecCtxtPtr exec); +int xmlRegExecPushString (xmlRegExecCtxtPtr exec, + const xmlChar * value, void *data); +int xmlRegExecPushString2 (xmlRegExecCtxtPtr exec, + const xmlChar * value, + const xmlChar * value2, void *data); + +int xmlRegExecNextValues (xmlRegExecCtxtPtr exec, + int *nbval, + int *nbneg, xmlChar ** values, int *terminal); +int xmlRegExecErrInfo (xmlRegExecCtxtPtr exec, + const xmlChar ** string, + int *nbval, int *nbneg, xmlChar ** values, int *terminal); + +typedef struct _xmlExpCtxt xmlExpCtxt; +typedef xmlExpCtxt *xmlExpCtxtPtr; +void xmlExpFreeCtxt (xmlExpCtxtPtr ctxt); +xmlExpCtxtPtr xmlExpNewCtxt (int maxNodes, xmlDictPtr dict); +int xmlExpCtxtNbNodes (xmlExpCtxtPtr ctxt); +int xmlExpCtxtNbCons (xmlExpCtxtPtr ctxt); +typedef struct _xmlExpNode xmlExpNode; +typedef xmlExpNode *xmlExpNodePtr; + +typedef enum +{ + XML_EXP_EMPTY = 0, + XML_EXP_FORBID = 1, + XML_EXP_ATOM = 2, + XML_EXP_SEQ = 3, + XML_EXP_OR = 4, + XML_EXP_COUNT = 5 +} xmlExpNodeType; + +extern xmlExpNodePtr forbiddenExp; +extern xmlExpNodePtr emptyExp; + +void xmlExpFree (xmlExpCtxtPtr ctxt, xmlExpNodePtr expr); +void xmlExpRef (xmlExpNodePtr expr); + +xmlExpNodePtr xmlExpParse (xmlExpCtxtPtr ctxt, const char *expr); +xmlExpNodePtr xmlExpNewAtom (xmlExpCtxtPtr ctxt, const xmlChar * name, int len); +xmlExpNodePtr xmlExpNewOr (xmlExpCtxtPtr ctxt, xmlExpNodePtr left, xmlExpNodePtr right); +xmlExpNodePtr xmlExpNewSeq (xmlExpCtxtPtr ctxt, xmlExpNodePtr left, xmlExpNodePtr right); +xmlExpNodePtr xmlExpNewRange (xmlExpCtxtPtr ctxt, xmlExpNodePtr subset, int min, int max); + +int xmlExpIsNillable (xmlExpNodePtr expr); +int xmlExpMaxToken (xmlExpNodePtr expr); +int xmlExpGetLanguage (xmlExpCtxtPtr ctxt, + xmlExpNodePtr expr, const xmlChar ** langList, int len); +int xmlExpGetStart (xmlExpCtxtPtr ctxt, + xmlExpNodePtr expr, const xmlChar ** tokList, int len); +xmlExpNodePtr xmlExpStringDerive (xmlExpCtxtPtr ctxt, + xmlExpNodePtr expr, const xmlChar * str, int len); +xmlExpNodePtr xmlExpExpDerive (xmlExpCtxtPtr ctxt, xmlExpNodePtr expr, xmlExpNodePtr sub); +int xmlExpSubsume (xmlExpCtxtPtr ctxt, xmlExpNodePtr expr, xmlExpNodePtr sub); +void xmlExpDump (xmlBufferPtr buf, xmlExpNodePtr expr); +typedef struct _xmlElement xmlElement; +typedef xmlElement *xmlElementPtr; + +struct _xmlElement +{ + void *_private; + xmlElementType type; + const xmlChar *name; + struct _xmlNode *children; + struct _xmlNode *last; + struct _xmlDtd *parent; + struct _xmlNode *next; + struct _xmlNode *prev; + struct _xmlDoc *doc; + xmlElementTypeVal etype; + xmlElementContentPtr content; + xmlAttributePtr attributes; + const xmlChar *prefix; + xmlRegexpPtr contModel; +}; + +typedef xmlElementType xmlNsType; +typedef struct _xmlNs xmlNs; +typedef xmlNs *xmlNsPtr; + +struct _xmlNs +{ + struct _xmlNs *next; + xmlNsType type; + const xmlChar *href; + const xmlChar *prefix; + void *_private; + struct _xmlDoc *context; +}; + +typedef struct _xmlDtd xmlDtd; +typedef xmlDtd *xmlDtdPtr; +struct _xmlDtd +{ + void *_private; + xmlElementType type; + const xmlChar *name; + struct _xmlNode *children; + struct _xmlNode *last; + struct _xmlDoc *parent; + struct _xmlNode *next; + struct _xmlNode *prev; + struct _xmlDoc *doc; + void *notations; + void *elements; + void *attributes; + void *entities; + const xmlChar *ExternalID; + const xmlChar *SystemID; + void *pentities; +}; + +typedef struct _xmlAttr xmlAttr; +typedef xmlAttr *xmlAttrPtr; +struct _xmlAttr +{ + void *_private; + xmlElementType type; + const xmlChar *name; + struct _xmlNode *children; + struct _xmlNode *last; + struct _xmlNode *parent; + struct _xmlAttr *next; + struct _xmlAttr *prev; + struct _xmlDoc *doc; + xmlNs *ns; + xmlAttributeType atype; + void *psvi; +}; + +typedef struct _xmlID xmlID; +typedef xmlID *xmlIDPtr; +struct _xmlID +{ + struct _xmlID *next; + const xmlChar *value; + xmlAttrPtr attr; + const xmlChar *name; + int lineno; + struct _xmlDoc *doc; +}; + +typedef struct _xmlRef xmlRef; +typedef xmlRef *xmlRefPtr; +struct _xmlRef +{ + struct _xmlRef *next; + const xmlChar *value; + xmlAttrPtr attr; + const xmlChar *name; + int lineno; +}; + +typedef struct _xmlNode xmlNode; +typedef xmlNode *xmlNodePtr; +struct _xmlNode +{ + void *_private; + xmlElementType type; + const xmlChar *name; + struct _xmlNode *children; + struct _xmlNode *last; + struct _xmlNode *parent; + struct _xmlNode *next; + struct _xmlNode *prev; + struct _xmlDoc *doc; + xmlNs *ns; + xmlChar *content; + struct _xmlAttr *properties; + xmlNs *nsDef; + void *psvi; + unsigned short line; + unsigned short extra; +}; + +typedef enum +{ + XML_DOC_WELLFORMED = 1 << 0, + XML_DOC_NSVALID = 1 << 1, + XML_DOC_OLD10 = 1 << 2, + XML_DOC_DTDVALID = 1 << 3, + XML_DOC_XINCLUDE = 1 << 4, + XML_DOC_USERBUILT = 1 << 5, + XML_DOC_INTERNAL = 1 << 6, + XML_DOC_HTML = 1 << 7 +} xmlDocProperties; + +typedef struct _xmlDoc xmlDoc; +typedef xmlDoc *xmlDocPtr; + +struct _xmlDoc +{ + void *_private; + xmlElementType type; + char *name; + struct _xmlNode *children; + struct _xmlNode *last; + struct _xmlNode *parent; + struct _xmlNode *next; + struct _xmlNode *prev; + struct _xmlDoc *doc; + int compression; + int standalone; + struct _xmlDtd *intSubset; + struct _xmlDtd *extSubset; + struct _xmlNs *oldNs; + const xmlChar *version; + const xmlChar *encoding; + void *ids; + void *refs; + const xmlChar *URL; + int charset; + struct _xmlDict *dict; + void *psvi; + int parseFlags; + int properties; +}; + +typedef struct _xmlDOMWrapCtxt xmlDOMWrapCtxt; +typedef xmlDOMWrapCtxt *xmlDOMWrapCtxtPtr; +typedef xmlNsPtr (*xmlDOMWrapAcquireNsFunction) (xmlDOMWrapCtxtPtr ctxt, + xmlNodePtr node, + const xmlChar * nsName, + const xmlChar * nsPrefix); + +struct _xmlDOMWrapCtxt +{ + void *_private; + int type; + void *namespaceMap; + xmlDOMWrapAcquireNsFunction getNsForNodeFunc; +}; + +int xmlValidateNCName (const xmlChar * value, int space); +int xmlValidateQName (const xmlChar * value, int space); +int xmlValidateName (const xmlChar * value, int space); +int xmlValidateNMToken (const xmlChar * value, int space); +xmlChar *xmlBuildQName (const xmlChar * ncname, + const xmlChar * prefix, xmlChar * memory, int len); +xmlChar *xmlSplitQName2 (const xmlChar * name, xmlChar ** prefix); +const xmlChar *xmlSplitQName3 (const xmlChar * name, int *len); +void xmlSetBufferAllocationScheme (xmlBufferAllocationScheme scheme); +xmlBufferAllocationScheme xmlGetBufferAllocationScheme (void); +xmlBufferPtr xmlBufferCreate (void); +xmlBufferPtr xmlBufferCreateSize (size_t size); +xmlBufferPtr xmlBufferCreateStatic (void *mem, size_t size); +int xmlBufferResize (xmlBufferPtr buf, unsigned int size); +void xmlBufferFree (xmlBufferPtr buf); +int xmlBufferDump (FILE * file, xmlBufferPtr buf); +int xmlBufferAdd (xmlBufferPtr buf, const xmlChar * str, int len); +int xmlBufferAddHead (xmlBufferPtr buf, const xmlChar * str, int len); +int xmlBufferCat (xmlBufferPtr buf, const xmlChar * str); +int xmlBufferCCat (xmlBufferPtr buf, const char *str); +int xmlBufferShrink (xmlBufferPtr buf, unsigned int len); +int xmlBufferGrow (xmlBufferPtr buf, unsigned int len); +void xmlBufferEmpty (xmlBufferPtr buf); +const xmlChar *xmlBufferContent (const xmlBuffer * buf); +xmlChar *xmlBufferDetach (xmlBufferPtr buf); +void xmlBufferSetAllocationScheme (xmlBufferPtr buf, + xmlBufferAllocationScheme scheme); +int xmlBufferLength (const xmlBuffer * buf); + +xmlDtdPtr xmlCreateIntSubset (xmlDocPtr doc, + const xmlChar * name, + const xmlChar * ExternalID, const xmlChar * SystemID); +xmlDtdPtr xmlNewDtd (xmlDocPtr doc, + const xmlChar * name, + const xmlChar * ExternalID, const xmlChar * SystemID); +xmlDtdPtr xmlGetIntSubset (const xmlDoc * doc); +void xmlFreeDtd (xmlDtdPtr cur); + +xmlNsPtr xmlNewGlobalNs (xmlDocPtr doc, const xmlChar * href, const xmlChar * prefix); + +xmlNsPtr xmlNewNs (xmlNodePtr node, const xmlChar * href, const xmlChar * prefix); +void xmlFreeNs (xmlNsPtr cur); +void xmlFreeNsList (xmlNsPtr cur); +xmlDocPtr xmlNewDoc (const xmlChar * version); +void xmlFreeDoc (xmlDocPtr cur); +xmlAttrPtr xmlNewDocProp (xmlDocPtr doc, const xmlChar * name, const xmlChar * value); + + +xmlAttrPtr xmlNewProp (xmlNodePtr node, const xmlChar * name, const xmlChar * value); + +xmlAttrPtr xmlNewNsProp (xmlNodePtr node, + xmlNsPtr ns, const xmlChar * name, const xmlChar * value); +xmlAttrPtr xmlNewNsPropEatName (xmlNodePtr node, + xmlNsPtr ns, xmlChar * name, const xmlChar * value); +void xmlFreePropList (xmlAttrPtr cur); +void xmlFreeProp (xmlAttrPtr cur); +xmlAttrPtr xmlCopyProp (xmlNodePtr target, xmlAttrPtr cur); +xmlAttrPtr xmlCopyPropList (xmlNodePtr target, xmlAttrPtr cur); +xmlDtdPtr xmlCopyDtd (xmlDtdPtr dtd); +xmlDocPtr xmlCopyDoc (xmlDocPtr doc, int recursive); +xmlNodePtr xmlNewDocNode (xmlDocPtr doc, + xmlNsPtr ns, const xmlChar * name, const xmlChar * content); +xmlNodePtr xmlNewDocNodeEatName (xmlDocPtr doc, + xmlNsPtr ns, xmlChar * name, const xmlChar * content); +xmlNodePtr xmlNewNode (xmlNsPtr ns, const xmlChar * name); +xmlNodePtr xmlNewNodeEatName (xmlNsPtr ns, xmlChar * name); + +xmlNodePtr xmlNewChild (xmlNodePtr parent, + xmlNsPtr ns, const xmlChar * name, const xmlChar * content); +xmlNodePtr xmlNewDocText (const xmlDoc * doc, const xmlChar * content); +xmlNodePtr xmlNewText (const xmlChar * content); +xmlNodePtr xmlNewDocPI (xmlDocPtr doc, const xmlChar * name, const xmlChar * content); +xmlNodePtr xmlNewPI (const xmlChar * name, const xmlChar * content); +xmlNodePtr xmlNewDocTextLen (xmlDocPtr doc, const xmlChar * content, int len); +xmlNodePtr xmlNewTextLen (const xmlChar * content, int len); +xmlNodePtr xmlNewDocComment (xmlDocPtr doc, const xmlChar * content); +xmlNodePtr xmlNewComment (const xmlChar * content); +xmlNodePtr xmlNewCDataBlock (xmlDocPtr doc, const xmlChar * content, int len); +xmlNodePtr xmlNewCharRef (xmlDocPtr doc, const xmlChar * name); +xmlNodePtr xmlNewReference (const xmlDoc * doc, const xmlChar * name); +xmlNodePtr xmlCopyNode (xmlNodePtr node, int recursive); +xmlNodePtr xmlDocCopyNode (xmlNodePtr node, xmlDocPtr doc, int recursive); +xmlNodePtr xmlDocCopyNodeList (xmlDocPtr doc, xmlNodePtr node); +xmlNodePtr xmlCopyNodeList (xmlNodePtr node); + +xmlNodePtr xmlNewTextChild (xmlNodePtr parent, + xmlNsPtr ns, const xmlChar * name, const xmlChar * content); +xmlNodePtr xmlNewDocRawNode (xmlDocPtr doc, + xmlNsPtr ns, const xmlChar * name, const xmlChar * content); +xmlNodePtr xmlNewDocFragment (xmlDocPtr doc); +long xmlGetLineNo (const xmlNode * node); +xmlChar *xmlGetNodePath (const xmlNode * node); +xmlNodePtr xmlDocGetRootElement (const xmlDoc * doc); +xmlNodePtr xmlGetLastChild (const xmlNode * parent); +int xmlNodeIsText (const xmlNode * node); +int xmlIsBlankNode (const xmlNode * node); +xmlNodePtr xmlDocSetRootElement (xmlDocPtr doc, xmlNodePtr root); +void xmlNodeSetName (xmlNodePtr cur, const xmlChar * name); +xmlNodePtr xmlAddChild (xmlNodePtr parent, xmlNodePtr cur); +xmlNodePtr xmlAddChildList (xmlNodePtr parent, xmlNodePtr cur); +xmlNodePtr xmlReplaceNode (xmlNodePtr old, xmlNodePtr cur); +xmlNodePtr xmlAddPrevSibling (xmlNodePtr cur, xmlNodePtr elem); +xmlNodePtr xmlAddSibling (xmlNodePtr cur, xmlNodePtr elem); +xmlNodePtr xmlAddNextSibling (xmlNodePtr cur, xmlNodePtr elem); +void xmlUnlinkNode (xmlNodePtr cur); +xmlNodePtr xmlTextMerge (xmlNodePtr first, xmlNodePtr second); +int xmlTextConcat (xmlNodePtr node, const xmlChar * content, int len); +void xmlFreeNodeList (xmlNodePtr cur); +void xmlFreeNode (xmlNodePtr cur); +void xmlSetTreeDoc (xmlNodePtr tree, xmlDocPtr doc); +void xmlSetListDoc (xmlNodePtr list, xmlDocPtr doc); + +xmlNsPtr xmlSearchNs (xmlDocPtr doc, xmlNodePtr node, const xmlChar * nameSpace); +xmlNsPtr xmlSearchNsByHref (xmlDocPtr doc, xmlNodePtr node, const xmlChar * href); +xmlNsPtr *xmlGetNsList (const xmlDoc * doc, const xmlNode * node); +void xmlSetNs (xmlNodePtr node, xmlNsPtr ns); +xmlNsPtr xmlCopyNamespace (xmlNsPtr cur); +xmlNsPtr xmlCopyNamespaceList (xmlNsPtr cur); +xmlAttrPtr xmlSetProp (xmlNodePtr node, const xmlChar * name, const xmlChar * value); +xmlAttrPtr xmlSetNsProp (xmlNodePtr node, + xmlNsPtr ns, const xmlChar * name, const xmlChar * value); + +xmlChar *xmlGetNoNsProp (const xmlNode * node, const xmlChar * name); +xmlChar *xmlGetProp (const xmlNode * node, const xmlChar * name); +xmlAttrPtr xmlHasProp (const xmlNode * node, const xmlChar * name); +xmlAttrPtr xmlHasNsProp (const xmlNode * node, + const xmlChar * name, const xmlChar * nameSpace); +xmlChar *xmlGetNsProp (const xmlNode * node, + const xmlChar * name, const xmlChar * nameSpace); +xmlNodePtr xmlStringGetNodeList (const xmlDoc * doc, const xmlChar * value); +xmlNodePtr xmlStringLenGetNodeList (const xmlDoc * doc, const xmlChar * value, int len); +xmlChar *xmlNodeListGetString (xmlDocPtr doc, + const xmlNode * list, int inLine); + +xmlChar *xmlNodeListGetRawString (const xmlDoc * doc, + const xmlNode * list, int inLine); + +void xmlNodeSetContent (xmlNodePtr cur, const xmlChar * content); +void xmlNodeSetContentLen (xmlNodePtr cur, const xmlChar * content, int len); +void xmlNodeAddContent (xmlNodePtr cur, const xmlChar * content); +void xmlNodeAddContentLen (xmlNodePtr cur, const xmlChar * content, int len); +xmlChar *xmlNodeGetContent (const xmlNode * cur); +int xmlNodeBufGetContent (xmlBufferPtr buffer, const xmlNode * cur); +int xmlBufGetNodeContent (xmlBufPtr buf, const xmlNode * cur); +xmlChar *xmlNodeGetLang (const xmlNode * cur); +int xmlNodeGetSpacePreserve (const xmlNode * cur); +void xmlNodeSetLang (xmlNodePtr cur, const xmlChar * lang); +void xmlNodeSetSpacePreserve (xmlNodePtr cur, int val); +xmlChar *xmlNodeGetBase (const xmlDoc * doc, const xmlNode * cur); +void xmlNodeSetBase (xmlNodePtr cur, const xmlChar * uri); +int xmlRemoveProp (xmlAttrPtr cur); +int xmlUnsetNsProp (xmlNodePtr node, xmlNsPtr ns, const xmlChar * name); +int xmlUnsetProp (xmlNodePtr node, const xmlChar * name); +void xmlBufferWriteCHAR (xmlBufferPtr buf, const xmlChar * string); +void xmlBufferWriteChar (xmlBufferPtr buf, const char *string); +void xmlBufferWriteQuotedString (xmlBufferPtr buf, const xmlChar * string); +void xmlAttrSerializeTxtContent (xmlBufferPtr buf, + xmlDocPtr doc, + xmlAttrPtr attr, const xmlChar * string); +int xmlReconciliateNs (xmlDocPtr doc, xmlNodePtr tree); +void xmlDocDumpFormatMemory (xmlDocPtr cur, xmlChar ** mem, int *size, int format); +void xmlDocDumpMemory (xmlDocPtr cur, xmlChar ** mem, int *size); +void xmlDocDumpMemoryEnc (xmlDocPtr out_doc, + xmlChar ** doc_txt_ptr, + int *doc_txt_len, const char *txt_encoding); +void xmlDocDumpFormatMemoryEnc (xmlDocPtr out_doc, + xmlChar ** doc_txt_ptr, + int *doc_txt_len, + const char *txt_encoding, int format); +int xmlDocFormatDump (FILE * f, xmlDocPtr cur, int format); +int xmlDocDump (FILE * f, xmlDocPtr cur); +void xmlElemDump (FILE * f, xmlDocPtr doc, xmlNodePtr cur); +int xmlSaveFile (const char *filename, xmlDocPtr cur); +int xmlSaveFormatFile (const char *filename, xmlDocPtr cur, int format); +size_t xmlBufNodeDump (xmlBufPtr buf, + xmlDocPtr doc, xmlNodePtr cur, int level, int format); +int xmlNodeDump (xmlBufferPtr buf, + xmlDocPtr doc, xmlNodePtr cur, int level, int format); + +int xmlSaveFileTo (xmlOutputBufferPtr buf, xmlDocPtr cur, const char *encoding); +int xmlSaveFormatFileTo (xmlOutputBufferPtr buf, + xmlDocPtr cur, const char *encoding, int format); +void xmlNodeDumpOutput (xmlOutputBufferPtr buf, + xmlDocPtr doc, + xmlNodePtr cur, + int level, int format, const char *encoding); + +int xmlSaveFormatFileEnc (const char *filename, + xmlDocPtr cur, const char *encoding, int format); + +int xmlSaveFileEnc (const char *filename, xmlDocPtr cur, const char *encoding); +int xmlIsXHTML (const xmlChar * systemID, const xmlChar * publicID); +int xmlGetDocCompressMode (const xmlDoc * doc); +void xmlSetDocCompressMode (xmlDocPtr doc, int mode); +int xmlGetCompressMode (void); +void xmlSetCompressMode (int mode); +xmlDOMWrapCtxtPtr xmlDOMWrapNewCtxt (void); +void xmlDOMWrapFreeCtxt (xmlDOMWrapCtxtPtr ctxt); +int xmlDOMWrapReconcileNamespaces (xmlDOMWrapCtxtPtr ctxt, + xmlNodePtr elem, int options); +int xmlDOMWrapAdoptNode (xmlDOMWrapCtxtPtr ctxt, + xmlDocPtr sourceDoc, + xmlNodePtr node, + xmlDocPtr destDoc, xmlNodePtr destParent, int options); +int xmlDOMWrapRemoveNode (xmlDOMWrapCtxtPtr ctxt, + xmlDocPtr doc, xmlNodePtr node, int options); +int xmlDOMWrapCloneNode (xmlDOMWrapCtxtPtr ctxt, + xmlDocPtr sourceDoc, + xmlNodePtr node, + xmlNodePtr * clonedNode, + xmlDocPtr destDoc, + xmlNodePtr destParent, int deep, int options); + +unsigned long xmlChildElementCount (xmlNodePtr parent); +xmlNodePtr xmlNextElementSibling (xmlNodePtr node); +xmlNodePtr xmlFirstElementChild (xmlNodePtr parent); +xmlNodePtr xmlLastElementChild (xmlNodePtr parent); +xmlNodePtr xmlPreviousElementSibling (xmlNodePtr node); +typedef struct _xmlHashTable xmlHashTable; +typedef xmlHashTable *xmlHashTablePtr; +typedef void (*xmlHashDeallocator) (void *payload, xmlChar * name); +typedef void *(*xmlHashCopier) (void *payload, xmlChar * name); +typedef void (*xmlHashScanner) (void *payload, void *data, xmlChar * name); +typedef void (*xmlHashScannerFull) (void *payload, void *data, + const xmlChar * name, + const xmlChar * name2, + const xmlChar * name3); + + + + +xmlHashTablePtr xmlHashCreate (int size); +xmlHashTablePtr xmlHashCreateDict (int size, xmlDictPtr dict); +void xmlHashFree (xmlHashTablePtr table, xmlHashDeallocator f); + +int xmlHashAddEntry (xmlHashTablePtr table, const xmlChar * name, void *userdata); +int xmlHashUpdateEntry (xmlHashTablePtr table, + const xmlChar * name, + void *userdata, xmlHashDeallocator f); +int xmlHashAddEntry2 (xmlHashTablePtr table, + const xmlChar * name, + const xmlChar * name2, void *userdata); +int xmlHashUpdateEntry2 (xmlHashTablePtr table, + const xmlChar * name, + const xmlChar * name2, + void *userdata, xmlHashDeallocator f); +int xmlHashAddEntry3 (xmlHashTablePtr table, + const xmlChar * name, + const xmlChar * name2, + const xmlChar * name3, void *userdata); +int xmlHashUpdateEntry3 (xmlHashTablePtr table, + const xmlChar * name, + const xmlChar * name2, + const xmlChar * name3, + void *userdata, xmlHashDeallocator f); + +int xmlHashRemoveEntry (xmlHashTablePtr table, const xmlChar * name, + xmlHashDeallocator f); +int xmlHashRemoveEntry2 (xmlHashTablePtr table, const xmlChar * name, + const xmlChar * name2, xmlHashDeallocator f); +int xmlHashRemoveEntry3 (xmlHashTablePtr table, const xmlChar * name, + const xmlChar * name2, const xmlChar * name3, + xmlHashDeallocator f); + +void *xmlHashLookup (xmlHashTablePtr table, const xmlChar * name); +void *xmlHashLookup2 (xmlHashTablePtr table, + const xmlChar * name, const xmlChar * name2); +void *xmlHashLookup3 (xmlHashTablePtr table, + const xmlChar * name, + const xmlChar * name2, const xmlChar * name3); +void *xmlHashQLookup (xmlHashTablePtr table, + const xmlChar * name, const xmlChar * prefix); +void *xmlHashQLookup2 (xmlHashTablePtr table, + const xmlChar * name, + const xmlChar * prefix, + const xmlChar * name2, const xmlChar * prefix2); +void *xmlHashQLookup3 (xmlHashTablePtr table, + const xmlChar * name, + const xmlChar * prefix, + const xmlChar * name2, + const xmlChar * prefix2, + const xmlChar * name3, const xmlChar * prefix3); + +xmlHashTablePtr xmlHashCopy (xmlHashTablePtr table, xmlHashCopier f); +int xmlHashSize (xmlHashTablePtr table); +void xmlHashScan (xmlHashTablePtr table, xmlHashScanner f, void *data); +void xmlHashScan3 (xmlHashTablePtr table, + const xmlChar * name, + const xmlChar * name2, + const xmlChar * name3, xmlHashScanner f, void *data); +void xmlHashScanFull (xmlHashTablePtr table, xmlHashScannerFull f, void *data); +void xmlHashScanFull3 (xmlHashTablePtr table, + const xmlChar * name, + const xmlChar * name2, + const xmlChar * name3, xmlHashScannerFull f, void *data); +typedef enum +{ + XML_ERR_NONE = 0, + XML_ERR_WARNING = 1, + XML_ERR_ERROR = 2, + XML_ERR_FATAL = 3 +} xmlErrorLevel; + +typedef enum +{ + XML_FROM_NONE = 0, + XML_FROM_PARSER, + XML_FROM_TREE, + XML_FROM_NAMESPACE, + XML_FROM_DTD, + XML_FROM_HTML, + XML_FROM_MEMORY, + XML_FROM_OUTPUT, + XML_FROM_IO, + XML_FROM_FTP, + XML_FROM_HTTP, + XML_FROM_XINCLUDE, + XML_FROM_XPATH, + XML_FROM_XPOINTER, + XML_FROM_REGEXP, + XML_FROM_DATATYPE, + XML_FROM_SCHEMASP, + XML_FROM_SCHEMASV, + XML_FROM_RELAXNGP, + XML_FROM_RELAXNGV, + XML_FROM_CATALOG, + XML_FROM_C14N, + XML_FROM_XSLT, + XML_FROM_VALID, + XML_FROM_CHECK, + XML_FROM_WRITER, + XML_FROM_MODULE, + XML_FROM_I18N, + XML_FROM_SCHEMATRONV, + XML_FROM_BUFFER, + XML_FROM_URI +} xmlErrorDomain; + +typedef struct _xmlError xmlError; +typedef xmlError *xmlErrorPtr; +struct _xmlError +{ + int domain; + int code; + char *message; + xmlErrorLevel level; + char *file; + int line; + char *str1; + char *str2; + char *str3; + int int1; + int int2; + void *ctxt; + void *node; +}; + +typedef enum +{ + XML_ERR_OK = 0, + XML_ERR_INTERNAL_ERROR, + XML_ERR_NO_MEMORY, + XML_ERR_DOCUMENT_START, + XML_ERR_DOCUMENT_EMPTY, + XML_ERR_DOCUMENT_END, + XML_ERR_INVALID_HEX_CHARREF, + XML_ERR_INVALID_DEC_CHARREF, + XML_ERR_INVALID_CHARREF, + XML_ERR_INVALID_CHAR, + XML_ERR_CHARREF_AT_EOF, + XML_ERR_CHARREF_IN_PROLOG, + XML_ERR_CHARREF_IN_EPILOG, + XML_ERR_CHARREF_IN_DTD, + XML_ERR_ENTITYREF_AT_EOF, + XML_ERR_ENTITYREF_IN_PROLOG, + XML_ERR_ENTITYREF_IN_EPILOG, + XML_ERR_ENTITYREF_IN_DTD, + XML_ERR_PEREF_AT_EOF, + XML_ERR_PEREF_IN_PROLOG, + XML_ERR_PEREF_IN_EPILOG, + XML_ERR_PEREF_IN_INT_SUBSET, + XML_ERR_ENTITYREF_NO_NAME, + XML_ERR_ENTITYREF_SEMICOL_MISSING, + XML_ERR_PEREF_NO_NAME, + XML_ERR_PEREF_SEMICOL_MISSING, + XML_ERR_UNDECLARED_ENTITY, + XML_WAR_UNDECLARED_ENTITY, + XML_ERR_UNPARSED_ENTITY, + XML_ERR_ENTITY_IS_EXTERNAL, + XML_ERR_ENTITY_IS_PARAMETER, + XML_ERR_UNKNOWN_ENCODING, + XML_ERR_UNSUPPORTED_ENCODING, + XML_ERR_STRING_NOT_STARTED, + XML_ERR_STRING_NOT_CLOSED, + XML_ERR_NS_DECL_ERROR, + XML_ERR_ENTITY_NOT_STARTED, + XML_ERR_ENTITY_NOT_FINISHED, + XML_ERR_LT_IN_ATTRIBUTE, + XML_ERR_ATTRIBUTE_NOT_STARTED, + XML_ERR_ATTRIBUTE_NOT_FINISHED, + XML_ERR_ATTRIBUTE_WITHOUT_VALUE, + XML_ERR_ATTRIBUTE_REDEFINED, + XML_ERR_LITERAL_NOT_STARTED, + XML_ERR_LITERAL_NOT_FINISHED, + XML_ERR_COMMENT_NOT_FINISHED, + XML_ERR_PI_NOT_STARTED, + XML_ERR_PI_NOT_FINISHED, + XML_ERR_NOTATION_NOT_STARTED, + XML_ERR_NOTATION_NOT_FINISHED, + XML_ERR_ATTLIST_NOT_STARTED, + XML_ERR_ATTLIST_NOT_FINISHED, + XML_ERR_MIXED_NOT_STARTED, + XML_ERR_MIXED_NOT_FINISHED, + XML_ERR_ELEMCONTENT_NOT_STARTED, + XML_ERR_ELEMCONTENT_NOT_FINISHED, + XML_ERR_XMLDECL_NOT_STARTED, + XML_ERR_XMLDECL_NOT_FINISHED, + XML_ERR_CONDSEC_NOT_STARTED, + XML_ERR_CONDSEC_NOT_FINISHED, + XML_ERR_EXT_SUBSET_NOT_FINISHED, + XML_ERR_DOCTYPE_NOT_FINISHED, + XML_ERR_MISPLACED_CDATA_END, + XML_ERR_CDATA_NOT_FINISHED, + XML_ERR_RESERVED_XML_NAME, + XML_ERR_SPACE_REQUIRED, + XML_ERR_SEPARATOR_REQUIRED, + XML_ERR_NMTOKEN_REQUIRED, + XML_ERR_NAME_REQUIRED, + XML_ERR_PCDATA_REQUIRED, + XML_ERR_URI_REQUIRED, + XML_ERR_PUBID_REQUIRED, + XML_ERR_LT_REQUIRED, + XML_ERR_GT_REQUIRED, + XML_ERR_LTSLASH_REQUIRED, + XML_ERR_EQUAL_REQUIRED, + XML_ERR_TAG_NAME_MISMATCH, + XML_ERR_TAG_NOT_FINISHED, + XML_ERR_STANDALONE_VALUE, + XML_ERR_ENCODING_NAME, + XML_ERR_HYPHEN_IN_COMMENT, + XML_ERR_INVALID_ENCODING, + XML_ERR_EXT_ENTITY_STANDALONE, + XML_ERR_CONDSEC_INVALID, + XML_ERR_VALUE_REQUIRED, + XML_ERR_NOT_WELL_BALANCED, + XML_ERR_EXTRA_CONTENT, + XML_ERR_ENTITY_CHAR_ERROR, + XML_ERR_ENTITY_PE_INTERNAL, + XML_ERR_ENTITY_LOOP, + XML_ERR_ENTITY_BOUNDARY, + XML_ERR_INVALID_URI, + XML_ERR_URI_FRAGMENT, + XML_WAR_CATALOG_PI, + XML_ERR_NO_DTD, + XML_ERR_CONDSEC_INVALID_KEYWORD, + XML_ERR_VERSION_MISSING, + XML_WAR_UNKNOWN_VERSION, + XML_WAR_LANG_VALUE, + XML_WAR_NS_URI, + XML_WAR_NS_URI_RELATIVE, + XML_ERR_MISSING_ENCODING, + XML_WAR_SPACE_VALUE, + XML_ERR_NOT_STANDALONE, + XML_ERR_ENTITY_PROCESSING, + XML_ERR_NOTATION_PROCESSING, + XML_WAR_NS_COLUMN, + XML_WAR_ENTITY_REDEFINED, + XML_ERR_UNKNOWN_VERSION, + XML_ERR_VERSION_MISMATCH, + XML_ERR_NAME_TOO_LONG, + XML_ERR_USER_STOP, + XML_NS_ERR_XML_NAMESPACE = 200, + XML_NS_ERR_UNDEFINED_NAMESPACE, + XML_NS_ERR_QNAME, + XML_NS_ERR_ATTRIBUTE_REDEFINED, + XML_NS_ERR_EMPTY, + XML_NS_ERR_COLON, + XML_DTD_ATTRIBUTE_DEFAULT = 500, + XML_DTD_ATTRIBUTE_REDEFINED, + XML_DTD_ATTRIBUTE_VALUE, + XML_DTD_CONTENT_ERROR, + XML_DTD_CONTENT_MODEL, + XML_DTD_CONTENT_NOT_DETERMINIST, + XML_DTD_DIFFERENT_PREFIX, + XML_DTD_ELEM_DEFAULT_NAMESPACE, + XML_DTD_ELEM_NAMESPACE, + XML_DTD_ELEM_REDEFINED, + XML_DTD_EMPTY_NOTATION, + XML_DTD_ENTITY_TYPE, + XML_DTD_ID_FIXED, + XML_DTD_ID_REDEFINED, + XML_DTD_ID_SUBSET, + XML_DTD_INVALID_CHILD, + XML_DTD_INVALID_DEFAULT, + XML_DTD_LOAD_ERROR, + XML_DTD_MISSING_ATTRIBUTE, + XML_DTD_MIXED_CORRUPT, + XML_DTD_MULTIPLE_ID, + XML_DTD_NO_DOC, + XML_DTD_NO_DTD, + XML_DTD_NO_ELEM_NAME, + XML_DTD_NO_PREFIX, + XML_DTD_NO_ROOT, + XML_DTD_NOTATION_REDEFINED, + XML_DTD_NOTATION_VALUE, + XML_DTD_NOT_EMPTY, + XML_DTD_NOT_PCDATA, + XML_DTD_NOT_STANDALONE, + XML_DTD_ROOT_NAME, + XML_DTD_STANDALONE_WHITE_SPACE, + XML_DTD_UNKNOWN_ATTRIBUTE, + XML_DTD_UNKNOWN_ELEM, + XML_DTD_UNKNOWN_ENTITY, + XML_DTD_UNKNOWN_ID, + XML_DTD_UNKNOWN_NOTATION, + XML_DTD_STANDALONE_DEFAULTED, + XML_DTD_XMLID_VALUE, + XML_DTD_XMLID_TYPE, + XML_DTD_DUP_TOKEN, + XML_HTML_STRUCURE_ERROR = 800, + XML_HTML_UNKNOWN_TAG, + XML_RNGP_ANYNAME_ATTR_ANCESTOR = 1000, + XML_RNGP_ATTR_CONFLICT, + XML_RNGP_ATTRIBUTE_CHILDREN, + XML_RNGP_ATTRIBUTE_CONTENT, + XML_RNGP_ATTRIBUTE_EMPTY, + XML_RNGP_ATTRIBUTE_NOOP, + XML_RNGP_CHOICE_CONTENT, + XML_RNGP_CHOICE_EMPTY, + XML_RNGP_CREATE_FAILURE, + XML_RNGP_DATA_CONTENT, + XML_RNGP_DEF_CHOICE_AND_INTERLEAVE, + XML_RNGP_DEFINE_CREATE_FAILED, + XML_RNGP_DEFINE_EMPTY, + XML_RNGP_DEFINE_MISSING, + XML_RNGP_DEFINE_NAME_MISSING, + XML_RNGP_ELEM_CONTENT_EMPTY, + XML_RNGP_ELEM_CONTENT_ERROR, + XML_RNGP_ELEMENT_EMPTY, + XML_RNGP_ELEMENT_CONTENT, + XML_RNGP_ELEMENT_NAME, + XML_RNGP_ELEMENT_NO_CONTENT, + XML_RNGP_ELEM_TEXT_CONFLICT, + XML_RNGP_EMPTY, + XML_RNGP_EMPTY_CONSTRUCT, + XML_RNGP_EMPTY_CONTENT, + XML_RNGP_EMPTY_NOT_EMPTY, + XML_RNGP_ERROR_TYPE_LIB, + XML_RNGP_EXCEPT_EMPTY, + XML_RNGP_EXCEPT_MISSING, + XML_RNGP_EXCEPT_MULTIPLE, + XML_RNGP_EXCEPT_NO_CONTENT, + XML_RNGP_EXTERNALREF_EMTPY, + XML_RNGP_EXTERNAL_REF_FAILURE, + XML_RNGP_EXTERNALREF_RECURSE, + XML_RNGP_FORBIDDEN_ATTRIBUTE, + XML_RNGP_FOREIGN_ELEMENT, + XML_RNGP_GRAMMAR_CONTENT, + XML_RNGP_GRAMMAR_EMPTY, + XML_RNGP_GRAMMAR_MISSING, + XML_RNGP_GRAMMAR_NO_START, + XML_RNGP_GROUP_ATTR_CONFLICT, + XML_RNGP_HREF_ERROR, + XML_RNGP_INCLUDE_EMPTY, + XML_RNGP_INCLUDE_FAILURE, + XML_RNGP_INCLUDE_RECURSE, + XML_RNGP_INTERLEAVE_ADD, + XML_RNGP_INTERLEAVE_CREATE_FAILED, + XML_RNGP_INTERLEAVE_EMPTY, + XML_RNGP_INTERLEAVE_NO_CONTENT, + XML_RNGP_INVALID_DEFINE_NAME, + XML_RNGP_INVALID_URI, + XML_RNGP_INVALID_VALUE, + XML_RNGP_MISSING_HREF, + XML_RNGP_NAME_MISSING, + XML_RNGP_NEED_COMBINE, + XML_RNGP_NOTALLOWED_NOT_EMPTY, + XML_RNGP_NSNAME_ATTR_ANCESTOR, + XML_RNGP_NSNAME_NO_NS, + XML_RNGP_PARAM_FORBIDDEN, + XML_RNGP_PARAM_NAME_MISSING, + XML_RNGP_PARENTREF_CREATE_FAILED, + XML_RNGP_PARENTREF_NAME_INVALID, + XML_RNGP_PARENTREF_NO_NAME, + XML_RNGP_PARENTREF_NO_PARENT, + XML_RNGP_PARENTREF_NOT_EMPTY, + XML_RNGP_PARSE_ERROR, + XML_RNGP_PAT_ANYNAME_EXCEPT_ANYNAME, + XML_RNGP_PAT_ATTR_ATTR, + XML_RNGP_PAT_ATTR_ELEM, + XML_RNGP_PAT_DATA_EXCEPT_ATTR, + XML_RNGP_PAT_DATA_EXCEPT_ELEM, + XML_RNGP_PAT_DATA_EXCEPT_EMPTY, + XML_RNGP_PAT_DATA_EXCEPT_GROUP, + XML_RNGP_PAT_DATA_EXCEPT_INTERLEAVE, + XML_RNGP_PAT_DATA_EXCEPT_LIST, + XML_RNGP_PAT_DATA_EXCEPT_ONEMORE, + XML_RNGP_PAT_DATA_EXCEPT_REF, + XML_RNGP_PAT_DATA_EXCEPT_TEXT, + XML_RNGP_PAT_LIST_ATTR, + XML_RNGP_PAT_LIST_ELEM, + XML_RNGP_PAT_LIST_INTERLEAVE, + XML_RNGP_PAT_LIST_LIST, + XML_RNGP_PAT_LIST_REF, + XML_RNGP_PAT_LIST_TEXT, + XML_RNGP_PAT_NSNAME_EXCEPT_ANYNAME, + XML_RNGP_PAT_NSNAME_EXCEPT_NSNAME, + XML_RNGP_PAT_ONEMORE_GROUP_ATTR, + XML_RNGP_PAT_ONEMORE_INTERLEAVE_ATTR, + XML_RNGP_PAT_START_ATTR, + XML_RNGP_PAT_START_DATA, + XML_RNGP_PAT_START_EMPTY, + XML_RNGP_PAT_START_GROUP, + XML_RNGP_PAT_START_INTERLEAVE, + XML_RNGP_PAT_START_LIST, + XML_RNGP_PAT_START_ONEMORE, + XML_RNGP_PAT_START_TEXT, + XML_RNGP_PAT_START_VALUE, + XML_RNGP_PREFIX_UNDEFINED, + XML_RNGP_REF_CREATE_FAILED, + XML_RNGP_REF_CYCLE, + XML_RNGP_REF_NAME_INVALID, + XML_RNGP_REF_NO_DEF, + XML_RNGP_REF_NO_NAME, + XML_RNGP_REF_NOT_EMPTY, + XML_RNGP_START_CHOICE_AND_INTERLEAVE, + XML_RNGP_START_CONTENT, + XML_RNGP_START_EMPTY, + XML_RNGP_START_MISSING, + XML_RNGP_TEXT_EXPECTED, + XML_RNGP_TEXT_HAS_CHILD, + XML_RNGP_TYPE_MISSING, + XML_RNGP_TYPE_NOT_FOUND, + XML_RNGP_TYPE_VALUE, + XML_RNGP_UNKNOWN_ATTRIBUTE, + XML_RNGP_UNKNOWN_COMBINE, + XML_RNGP_UNKNOWN_CONSTRUCT, + XML_RNGP_UNKNOWN_TYPE_LIB, + XML_RNGP_URI_FRAGMENT, + XML_RNGP_URI_NOT_ABSOLUTE, + XML_RNGP_VALUE_EMPTY, + XML_RNGP_VALUE_NO_CONTENT, + XML_RNGP_XMLNS_NAME, + XML_RNGP_XML_NS, + XML_XPATH_EXPRESSION_OK = 1200, + XML_XPATH_NUMBER_ERROR, + XML_XPATH_UNFINISHED_LITERAL_ERROR, + XML_XPATH_START_LITERAL_ERROR, + XML_XPATH_VARIABLE_REF_ERROR, + XML_XPATH_UNDEF_VARIABLE_ERROR, + XML_XPATH_INVALID_PREDICATE_ERROR, + XML_XPATH_EXPR_ERROR, + XML_XPATH_UNCLOSED_ERROR, + XML_XPATH_UNKNOWN_FUNC_ERROR, + XML_XPATH_INVALID_OPERAND, + XML_XPATH_INVALID_TYPE, + XML_XPATH_INVALID_ARITY, + XML_XPATH_INVALID_CTXT_SIZE, + XML_XPATH_INVALID_CTXT_POSITION, + XML_XPATH_MEMORY_ERROR, + XML_XPTR_SYNTAX_ERROR, + XML_XPTR_RESOURCE_ERROR, + XML_XPTR_SUB_RESOURCE_ERROR, + XML_XPATH_UNDEF_PREFIX_ERROR, + XML_XPATH_ENCODING_ERROR, + XML_XPATH_INVALID_CHAR_ERROR, + XML_TREE_INVALID_HEX = 1300, + XML_TREE_INVALID_DEC, + XML_TREE_UNTERMINATED_ENTITY, + XML_TREE_NOT_UTF8, + XML_SAVE_NOT_UTF8 = 1400, + XML_SAVE_CHAR_INVALID, + XML_SAVE_NO_DOCTYPE, + XML_SAVE_UNKNOWN_ENCODING, + XML_REGEXP_COMPILE_ERROR = 1450, + XML_IO_UNKNOWN = 1500, + XML_IO_EACCES, + XML_IO_EAGAIN, + XML_IO_EBADF, + XML_IO_EBADMSG, + XML_IO_EBUSY, + XML_IO_ECANCELED, + XML_IO_ECHILD, + XML_IO_EDEADLK, + XML_IO_EDOM, + XML_IO_EEXIST, + XML_IO_EFAULT, + XML_IO_EFBIG, + XML_IO_EINPROGRESS, + XML_IO_EINTR, + XML_IO_EINVAL, + XML_IO_EIO, + XML_IO_EISDIR, + XML_IO_EMFILE, + XML_IO_EMLINK, + XML_IO_EMSGSIZE, + XML_IO_ENAMETOOLONG, + XML_IO_ENFILE, + XML_IO_ENODEV, + XML_IO_ENOENT, + XML_IO_ENOEXEC, + XML_IO_ENOLCK, + XML_IO_ENOMEM, + XML_IO_ENOSPC, + XML_IO_ENOSYS, + XML_IO_ENOTDIR, + XML_IO_ENOTEMPTY, + XML_IO_ENOTSUP, + XML_IO_ENOTTY, + XML_IO_ENXIO, + XML_IO_EPERM, + XML_IO_EPIPE, + XML_IO_ERANGE, + XML_IO_EROFS, + XML_IO_ESPIPE, + XML_IO_ESRCH, + XML_IO_ETIMEDOUT, + XML_IO_EXDEV, + XML_IO_NETWORK_ATTEMPT, + XML_IO_ENCODER, + XML_IO_FLUSH, + XML_IO_WRITE, + XML_IO_NO_INPUT, + XML_IO_BUFFER_FULL, + XML_IO_LOAD_ERROR, + XML_IO_ENOTSOCK, + XML_IO_EISCONN, + XML_IO_ECONNREFUSED, + XML_IO_ENETUNREACH, + XML_IO_EADDRINUSE, + XML_IO_EALREADY, + XML_IO_EAFNOSUPPORT, + XML_XINCLUDE_RECURSION = 1600, + XML_XINCLUDE_PARSE_VALUE, + XML_XINCLUDE_ENTITY_DEF_MISMATCH, + XML_XINCLUDE_NO_HREF, + XML_XINCLUDE_NO_FALLBACK, + XML_XINCLUDE_HREF_URI, + XML_XINCLUDE_TEXT_FRAGMENT, + XML_XINCLUDE_TEXT_DOCUMENT, + XML_XINCLUDE_INVALID_CHAR, + XML_XINCLUDE_BUILD_FAILED, + XML_XINCLUDE_UNKNOWN_ENCODING, + XML_XINCLUDE_MULTIPLE_ROOT, + XML_XINCLUDE_XPTR_FAILED, + XML_XINCLUDE_XPTR_RESULT, + XML_XINCLUDE_INCLUDE_IN_INCLUDE, + XML_XINCLUDE_FALLBACKS_IN_INCLUDE, + XML_XINCLUDE_FALLBACK_NOT_IN_INCLUDE, + XML_XINCLUDE_DEPRECATED_NS, + XML_XINCLUDE_FRAGMENT_ID, + XML_CATALOG_MISSING_ATTR = 1650, + XML_CATALOG_ENTRY_BROKEN, + XML_CATALOG_PREFER_VALUE, + XML_CATALOG_NOT_CATALOG, + XML_CATALOG_RECURSION, + XML_SCHEMAP_PREFIX_UNDEFINED = 1700, + XML_SCHEMAP_ATTRFORMDEFAULT_VALUE, + XML_SCHEMAP_ATTRGRP_NONAME_NOREF, + XML_SCHEMAP_ATTR_NONAME_NOREF, + XML_SCHEMAP_COMPLEXTYPE_NONAME_NOREF, + XML_SCHEMAP_ELEMFORMDEFAULT_VALUE, + XML_SCHEMAP_ELEM_NONAME_NOREF, + XML_SCHEMAP_EXTENSION_NO_BASE, + XML_SCHEMAP_FACET_NO_VALUE, + XML_SCHEMAP_FAILED_BUILD_IMPORT, + XML_SCHEMAP_GROUP_NONAME_NOREF, + XML_SCHEMAP_IMPORT_NAMESPACE_NOT_URI, + XML_SCHEMAP_IMPORT_REDEFINE_NSNAME, + XML_SCHEMAP_IMPORT_SCHEMA_NOT_URI, + XML_SCHEMAP_INVALID_BOOLEAN, + XML_SCHEMAP_INVALID_ENUM, + XML_SCHEMAP_INVALID_FACET, + XML_SCHEMAP_INVALID_FACET_VALUE, + XML_SCHEMAP_INVALID_MAXOCCURS, + XML_SCHEMAP_INVALID_MINOCCURS, + XML_SCHEMAP_INVALID_REF_AND_SUBTYPE, + XML_SCHEMAP_INVALID_WHITE_SPACE, + XML_SCHEMAP_NOATTR_NOREF, + XML_SCHEMAP_NOTATION_NO_NAME, + XML_SCHEMAP_NOTYPE_NOREF, + XML_SCHEMAP_REF_AND_SUBTYPE, + XML_SCHEMAP_RESTRICTION_NONAME_NOREF, + XML_SCHEMAP_SIMPLETYPE_NONAME, + XML_SCHEMAP_TYPE_AND_SUBTYPE, + XML_SCHEMAP_UNKNOWN_ALL_CHILD, + XML_SCHEMAP_UNKNOWN_ANYATTRIBUTE_CHILD, + XML_SCHEMAP_UNKNOWN_ATTR_CHILD, + XML_SCHEMAP_UNKNOWN_ATTRGRP_CHILD, + XML_SCHEMAP_UNKNOWN_ATTRIBUTE_GROUP, + XML_SCHEMAP_UNKNOWN_BASE_TYPE, + XML_SCHEMAP_UNKNOWN_CHOICE_CHILD, + XML_SCHEMAP_UNKNOWN_COMPLEXCONTENT_CHILD, + XML_SCHEMAP_UNKNOWN_COMPLEXTYPE_CHILD, + XML_SCHEMAP_UNKNOWN_ELEM_CHILD, + XML_SCHEMAP_UNKNOWN_EXTENSION_CHILD, + XML_SCHEMAP_UNKNOWN_FACET_CHILD, + XML_SCHEMAP_UNKNOWN_FACET_TYPE, + XML_SCHEMAP_UNKNOWN_GROUP_CHILD, + XML_SCHEMAP_UNKNOWN_IMPORT_CHILD, + XML_SCHEMAP_UNKNOWN_LIST_CHILD, + XML_SCHEMAP_UNKNOWN_NOTATION_CHILD, + XML_SCHEMAP_UNKNOWN_PROCESSCONTENT_CHILD, + XML_SCHEMAP_UNKNOWN_REF, + XML_SCHEMAP_UNKNOWN_RESTRICTION_CHILD, + XML_SCHEMAP_UNKNOWN_SCHEMAS_CHILD, + XML_SCHEMAP_UNKNOWN_SEQUENCE_CHILD, + XML_SCHEMAP_UNKNOWN_SIMPLECONTENT_CHILD, + XML_SCHEMAP_UNKNOWN_SIMPLETYPE_CHILD, + XML_SCHEMAP_UNKNOWN_TYPE, + XML_SCHEMAP_UNKNOWN_UNION_CHILD, + XML_SCHEMAP_ELEM_DEFAULT_FIXED, + XML_SCHEMAP_REGEXP_INVALID, + XML_SCHEMAP_FAILED_LOAD, + XML_SCHEMAP_NOTHING_TO_PARSE, + XML_SCHEMAP_NOROOT, + XML_SCHEMAP_REDEFINED_GROUP, + XML_SCHEMAP_REDEFINED_TYPE, + XML_SCHEMAP_REDEFINED_ELEMENT, + XML_SCHEMAP_REDEFINED_ATTRGROUP, + XML_SCHEMAP_REDEFINED_ATTR, + XML_SCHEMAP_REDEFINED_NOTATION, + XML_SCHEMAP_FAILED_PARSE, + XML_SCHEMAP_UNKNOWN_PREFIX, + XML_SCHEMAP_DEF_AND_PREFIX, + XML_SCHEMAP_UNKNOWN_INCLUDE_CHILD, + XML_SCHEMAP_INCLUDE_SCHEMA_NOT_URI, + XML_SCHEMAP_INCLUDE_SCHEMA_NO_URI, + XML_SCHEMAP_NOT_SCHEMA, + XML_SCHEMAP_UNKNOWN_MEMBER_TYPE, + XML_SCHEMAP_INVALID_ATTR_USE, + XML_SCHEMAP_RECURSIVE, + XML_SCHEMAP_SUPERNUMEROUS_LIST_ITEM_TYPE, + XML_SCHEMAP_INVALID_ATTR_COMBINATION, + XML_SCHEMAP_INVALID_ATTR_INLINE_COMBINATION, + XML_SCHEMAP_MISSING_SIMPLETYPE_CHILD, + XML_SCHEMAP_INVALID_ATTR_NAME, + XML_SCHEMAP_REF_AND_CONTENT, + XML_SCHEMAP_CT_PROPS_CORRECT_1, + XML_SCHEMAP_CT_PROPS_CORRECT_2, + XML_SCHEMAP_CT_PROPS_CORRECT_3, + XML_SCHEMAP_CT_PROPS_CORRECT_4, + XML_SCHEMAP_CT_PROPS_CORRECT_5, + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1, + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_1, + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_2, + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_2, + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_3, + XML_SCHEMAP_WILDCARD_INVALID_NS_MEMBER, + XML_SCHEMAP_INTERSECTION_NOT_EXPRESSIBLE, + XML_SCHEMAP_UNION_NOT_EXPRESSIBLE, + XML_SCHEMAP_SRC_IMPORT_3_1, + XML_SCHEMAP_SRC_IMPORT_3_2, + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_1, + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_2, + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_3, + XML_SCHEMAP_COS_CT_EXTENDS_1_3, + XML_SCHEMAV_NOROOT = 1801, + XML_SCHEMAV_UNDECLAREDELEM, + XML_SCHEMAV_NOTTOPLEVEL, + XML_SCHEMAV_MISSING, + XML_SCHEMAV_WRONGELEM, + XML_SCHEMAV_NOTYPE, + XML_SCHEMAV_NOROLLBACK, + XML_SCHEMAV_ISABSTRACT, + XML_SCHEMAV_NOTEMPTY, + XML_SCHEMAV_ELEMCONT, + XML_SCHEMAV_HAVEDEFAULT, + XML_SCHEMAV_NOTNILLABLE, + XML_SCHEMAV_EXTRACONTENT, + XML_SCHEMAV_INVALIDATTR, + XML_SCHEMAV_INVALIDELEM, + XML_SCHEMAV_NOTDETERMINIST, + XML_SCHEMAV_CONSTRUCT, + XML_SCHEMAV_INTERNAL, + XML_SCHEMAV_NOTSIMPLE, + XML_SCHEMAV_ATTRUNKNOWN, + XML_SCHEMAV_ATTRINVALID, + XML_SCHEMAV_VALUE, + XML_SCHEMAV_FACET, + XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1, + XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2, + XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_3, + XML_SCHEMAV_CVC_TYPE_3_1_1, + XML_SCHEMAV_CVC_TYPE_3_1_2, + XML_SCHEMAV_CVC_FACET_VALID, + XML_SCHEMAV_CVC_LENGTH_VALID, + XML_SCHEMAV_CVC_MINLENGTH_VALID, + XML_SCHEMAV_CVC_MAXLENGTH_VALID, + XML_SCHEMAV_CVC_MININCLUSIVE_VALID, + XML_SCHEMAV_CVC_MAXINCLUSIVE_VALID, + XML_SCHEMAV_CVC_MINEXCLUSIVE_VALID, + XML_SCHEMAV_CVC_MAXEXCLUSIVE_VALID, + XML_SCHEMAV_CVC_TOTALDIGITS_VALID, + XML_SCHEMAV_CVC_FRACTIONDIGITS_VALID, + XML_SCHEMAV_CVC_PATTERN_VALID, + XML_SCHEMAV_CVC_ENUMERATION_VALID, + XML_SCHEMAV_CVC_COMPLEX_TYPE_2_1, + XML_SCHEMAV_CVC_COMPLEX_TYPE_2_2, + XML_SCHEMAV_CVC_COMPLEX_TYPE_2_3, + XML_SCHEMAV_CVC_COMPLEX_TYPE_2_4, + XML_SCHEMAV_CVC_ELT_1, + XML_SCHEMAV_CVC_ELT_2, + XML_SCHEMAV_CVC_ELT_3_1, + XML_SCHEMAV_CVC_ELT_3_2_1, + XML_SCHEMAV_CVC_ELT_3_2_2, + XML_SCHEMAV_CVC_ELT_4_1, + XML_SCHEMAV_CVC_ELT_4_2, + XML_SCHEMAV_CVC_ELT_4_3, + XML_SCHEMAV_CVC_ELT_5_1_1, + XML_SCHEMAV_CVC_ELT_5_1_2, + XML_SCHEMAV_CVC_ELT_5_2_1, + XML_SCHEMAV_CVC_ELT_5_2_2_1, + XML_SCHEMAV_CVC_ELT_5_2_2_2_1, + XML_SCHEMAV_CVC_ELT_5_2_2_2_2, + XML_SCHEMAV_CVC_ELT_6, + XML_SCHEMAV_CVC_ELT_7, + XML_SCHEMAV_CVC_ATTRIBUTE_1, + XML_SCHEMAV_CVC_ATTRIBUTE_2, + XML_SCHEMAV_CVC_ATTRIBUTE_3, + XML_SCHEMAV_CVC_ATTRIBUTE_4, + XML_SCHEMAV_CVC_COMPLEX_TYPE_3_1, + XML_SCHEMAV_CVC_COMPLEX_TYPE_3_2_1, + XML_SCHEMAV_CVC_COMPLEX_TYPE_3_2_2, + XML_SCHEMAV_CVC_COMPLEX_TYPE_4, + XML_SCHEMAV_CVC_COMPLEX_TYPE_5_1, + XML_SCHEMAV_CVC_COMPLEX_TYPE_5_2, + XML_SCHEMAV_ELEMENT_CONTENT, + XML_SCHEMAV_DOCUMENT_ELEMENT_MISSING, + XML_SCHEMAV_CVC_COMPLEX_TYPE_1, + XML_SCHEMAV_CVC_AU, + XML_SCHEMAV_CVC_TYPE_1, + XML_SCHEMAV_CVC_TYPE_2, + XML_SCHEMAV_CVC_IDC, + XML_SCHEMAV_CVC_WILDCARD, + XML_SCHEMAV_MISC, + XML_XPTR_UNKNOWN_SCHEME = 1900, + XML_XPTR_CHILDSEQ_START, + XML_XPTR_EVAL_FAILED, + XML_XPTR_EXTRA_OBJECTS, + XML_C14N_CREATE_CTXT = 1950, + XML_C14N_REQUIRES_UTF8, + XML_C14N_CREATE_STACK, + XML_C14N_INVALID_NODE, + XML_C14N_UNKNOW_NODE, + XML_C14N_RELATIVE_NAMESPACE, + XML_FTP_PASV_ANSWER = 2000, + XML_FTP_EPSV_ANSWER, + XML_FTP_ACCNT, + XML_FTP_URL_SYNTAX, + XML_HTTP_URL_SYNTAX = 2020, + XML_HTTP_USE_IP, + XML_HTTP_UNKNOWN_HOST, + XML_SCHEMAP_SRC_SIMPLE_TYPE_1 = 3000, + XML_SCHEMAP_SRC_SIMPLE_TYPE_2, + XML_SCHEMAP_SRC_SIMPLE_TYPE_3, + XML_SCHEMAP_SRC_SIMPLE_TYPE_4, + XML_SCHEMAP_SRC_RESOLVE, + XML_SCHEMAP_SRC_RESTRICTION_BASE_OR_SIMPLETYPE, + XML_SCHEMAP_SRC_LIST_ITEMTYPE_OR_SIMPLETYPE, + XML_SCHEMAP_SRC_UNION_MEMBERTYPES_OR_SIMPLETYPES, + XML_SCHEMAP_ST_PROPS_CORRECT_1, + XML_SCHEMAP_ST_PROPS_CORRECT_2, + XML_SCHEMAP_ST_PROPS_CORRECT_3, + XML_SCHEMAP_COS_ST_RESTRICTS_1_1, + XML_SCHEMAP_COS_ST_RESTRICTS_1_2, + XML_SCHEMAP_COS_ST_RESTRICTS_1_3_1, + XML_SCHEMAP_COS_ST_RESTRICTS_1_3_2, + XML_SCHEMAP_COS_ST_RESTRICTS_2_1, + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_1_1, + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_1_2, + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_1, + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_2, + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_3, + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_4, + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_5, + XML_SCHEMAP_COS_ST_RESTRICTS_3_1, + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_1, + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_1_2, + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_2, + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_1, + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_3, + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_4, + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_5, + XML_SCHEMAP_COS_ST_DERIVED_OK_2_1, + XML_SCHEMAP_COS_ST_DERIVED_OK_2_2, + XML_SCHEMAP_S4S_ELEM_NOT_ALLOWED, + XML_SCHEMAP_S4S_ELEM_MISSING, + XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, + XML_SCHEMAP_S4S_ATTR_MISSING, + XML_SCHEMAP_S4S_ATTR_INVALID_VALUE, + XML_SCHEMAP_SRC_ELEMENT_1, + XML_SCHEMAP_SRC_ELEMENT_2_1, + XML_SCHEMAP_SRC_ELEMENT_2_2, + XML_SCHEMAP_SRC_ELEMENT_3, + XML_SCHEMAP_P_PROPS_CORRECT_1, + XML_SCHEMAP_P_PROPS_CORRECT_2_1, + XML_SCHEMAP_P_PROPS_CORRECT_2_2, + XML_SCHEMAP_E_PROPS_CORRECT_2, + XML_SCHEMAP_E_PROPS_CORRECT_3, + XML_SCHEMAP_E_PROPS_CORRECT_4, + XML_SCHEMAP_E_PROPS_CORRECT_5, + XML_SCHEMAP_E_PROPS_CORRECT_6, + XML_SCHEMAP_SRC_INCLUDE, + XML_SCHEMAP_SRC_ATTRIBUTE_1, + XML_SCHEMAP_SRC_ATTRIBUTE_2, + XML_SCHEMAP_SRC_ATTRIBUTE_3_1, + XML_SCHEMAP_SRC_ATTRIBUTE_3_2, + XML_SCHEMAP_SRC_ATTRIBUTE_4, + XML_SCHEMAP_NO_XMLNS, + XML_SCHEMAP_NO_XSI, + XML_SCHEMAP_COS_VALID_DEFAULT_1, + XML_SCHEMAP_COS_VALID_DEFAULT_2_1, + XML_SCHEMAP_COS_VALID_DEFAULT_2_2_1, + XML_SCHEMAP_COS_VALID_DEFAULT_2_2_2, + XML_SCHEMAP_CVC_SIMPLE_TYPE, + XML_SCHEMAP_COS_CT_EXTENDS_1_1, + XML_SCHEMAP_SRC_IMPORT_1_1, + XML_SCHEMAP_SRC_IMPORT_1_2, + XML_SCHEMAP_SRC_IMPORT_2, + XML_SCHEMAP_SRC_IMPORT_2_1, + XML_SCHEMAP_SRC_IMPORT_2_2, + XML_SCHEMAP_INTERNAL, + XML_SCHEMAP_NOT_DETERMINISTIC, + XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_1, + XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_2, + XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_3, + XML_SCHEMAP_MG_PROPS_CORRECT_1, + XML_SCHEMAP_MG_PROPS_CORRECT_2, + XML_SCHEMAP_SRC_CT_1, + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_3, + XML_SCHEMAP_AU_PROPS_CORRECT_2, + XML_SCHEMAP_A_PROPS_CORRECT_2, + XML_SCHEMAP_C_PROPS_CORRECT, + XML_SCHEMAP_SRC_REDEFINE, + XML_SCHEMAP_SRC_IMPORT, + XML_SCHEMAP_WARN_SKIP_SCHEMA, + XML_SCHEMAP_WARN_UNLOCATED_SCHEMA, + XML_SCHEMAP_WARN_ATTR_REDECL_PROH, + XML_SCHEMAP_WARN_ATTR_POINTLESS_PROH, + XML_SCHEMAP_AG_PROPS_CORRECT, + XML_SCHEMAP_COS_CT_EXTENDS_1_2, + XML_SCHEMAP_AU_PROPS_CORRECT, + XML_SCHEMAP_A_PROPS_CORRECT_3, + XML_SCHEMAP_COS_ALL_LIMITED, + XML_SCHEMATRONV_ASSERT = 4000, + XML_SCHEMATRONV_REPORT, + XML_MODULE_OPEN = 4900, + XML_MODULE_CLOSE, + XML_CHECK_FOUND_ELEMENT = 5000, + XML_CHECK_FOUND_ATTRIBUTE, + XML_CHECK_FOUND_TEXT, + XML_CHECK_FOUND_CDATA, + XML_CHECK_FOUND_ENTITYREF, + XML_CHECK_FOUND_ENTITY, + XML_CHECK_FOUND_PI, + XML_CHECK_FOUND_COMMENT, + XML_CHECK_FOUND_DOCTYPE, + XML_CHECK_FOUND_FRAGMENT, + XML_CHECK_FOUND_NOTATION, + XML_CHECK_UNKNOWN_NODE, + XML_CHECK_ENTITY_TYPE, + XML_CHECK_NO_PARENT, + XML_CHECK_NO_DOC, + XML_CHECK_NO_NAME, + XML_CHECK_NO_ELEM, + XML_CHECK_WRONG_DOC, + XML_CHECK_NO_PREV, + XML_CHECK_WRONG_PREV, + XML_CHECK_NO_NEXT, + XML_CHECK_WRONG_NEXT, + XML_CHECK_NOT_DTD, + XML_CHECK_NOT_ATTR, + XML_CHECK_NOT_ATTR_DECL, + XML_CHECK_NOT_ELEM_DECL, + XML_CHECK_NOT_ENTITY_DECL, + XML_CHECK_NOT_NS_DECL, + XML_CHECK_NO_HREF, + XML_CHECK_WRONG_PARENT, + XML_CHECK_NS_SCOPE, + XML_CHECK_NS_ANCESTOR, + XML_CHECK_NOT_UTF8, + XML_CHECK_NO_DICT, + XML_CHECK_NOT_NCNAME, + XML_CHECK_OUTSIDE_DICT, + XML_CHECK_WRONG_NAME, + XML_CHECK_NAME_NOT_NULL, + XML_I18N_NO_NAME = 6000, + XML_I18N_NO_HANDLER, + XML_I18N_EXCESS_HANDLER, + XML_I18N_CONV_FAILED, + XML_I18N_NO_OUTPUT, + XML_BUF_OVERFLOW = 7000 +} xmlParserErrors; + +typedef void (*xmlGenericErrorFunc) (void *ctx, const char *msg, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); +typedef void (*xmlStructuredErrorFunc) (void *userData, xmlErrorPtr error); + +void xmlSetGenericErrorFunc (void *ctx, xmlGenericErrorFunc handler); +void initGenericErrorDefaultFunc (xmlGenericErrorFunc * handler); +void xmlSetStructuredErrorFunc (void *ctx, xmlStructuredErrorFunc handler); + +void xmlParserError (void *ctx, const char *msg, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); +void xmlParserWarning (void *ctx, const char *msg, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); +void xmlParserValidityError (void *ctx, const char *msg, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); +void xmlParserValidityWarning (void *ctx, const char *msg, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); +void xmlParserPrintFileInfo (xmlParserInputPtr input); +void xmlParserPrintFileContext (xmlParserInputPtr input); +xmlErrorPtr xmlGetLastError (void); +void xmlResetLastError (void); +xmlErrorPtr xmlCtxtGetLastError (void *ctx); +void xmlCtxtResetLastError (void *ctx); +void xmlResetError (xmlErrorPtr err); +int xmlCopyError (xmlErrorPtr from, xmlErrorPtr to); +typedef struct _xmlLink xmlLink; +typedef xmlLink *xmlLinkPtr; +typedef struct _xmlList xmlList; +typedef xmlList *xmlListPtr; +typedef void (*xmlListDeallocator) (xmlLinkPtr lk); +typedef int (*xmlListDataCompare) (const void *data0, const void *data1); +typedef int (*xmlListWalker) (const void *data, const void *user); + +xmlListPtr xmlListCreate (xmlListDeallocator deallocator, xmlListDataCompare compare); +void xmlListDelete (xmlListPtr l); +void *xmlListSearch (xmlListPtr l, void *data); +void *xmlListReverseSearch (xmlListPtr l, void *data); +int xmlListInsert (xmlListPtr l, void *data); +int xmlListAppend (xmlListPtr l, void *data); +int xmlListRemoveFirst (xmlListPtr l, void *data); +int xmlListRemoveLast (xmlListPtr l, void *data); +int xmlListRemoveAll (xmlListPtr l, void *data); +void xmlListClear (xmlListPtr l); +int xmlListEmpty (xmlListPtr l); +xmlLinkPtr xmlListFront (xmlListPtr l); +xmlLinkPtr xmlListEnd (xmlListPtr l); +int xmlListSize (xmlListPtr l); +void xmlListPopFront (xmlListPtr l); +void xmlListPopBack (xmlListPtr l); +int xmlListPushFront (xmlListPtr l, void *data); +int xmlListPushBack (xmlListPtr l, void *data); +void xmlListReverse (xmlListPtr l); +void xmlListSort (xmlListPtr l); +void xmlListWalk (xmlListPtr l, xmlListWalker walker, const void *user); +void xmlListReverseWalk (xmlListPtr l, xmlListWalker walker, const void *user); +void xmlListMerge (xmlListPtr l1, xmlListPtr l2); +xmlListPtr xmlListDup (const xmlListPtr old); +int xmlListCopy (xmlListPtr cur, const xmlListPtr old); +void *xmlLinkGetData (xmlLinkPtr lk); +typedef struct _xmlAutomata xmlAutomata; +typedef xmlAutomata *xmlAutomataPtr; + +typedef struct _xmlAutomataState xmlAutomataState; +typedef xmlAutomataState *xmlAutomataStatePtr; + +xmlAutomataPtr xmlNewAutomata (void); +void xmlFreeAutomata (xmlAutomataPtr am); + +xmlAutomataStatePtr xmlAutomataGetInitState (xmlAutomataPtr am); +int xmlAutomataSetFinalState (xmlAutomataPtr am, xmlAutomataStatePtr state); +xmlAutomataStatePtr xmlAutomataNewState (xmlAutomataPtr am); +xmlAutomataStatePtr +xmlAutomataNewTransition (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar * token, void *data); +xmlAutomataStatePtr +xmlAutomataNewTransition2 (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar * token, + const xmlChar * token2, void *data); +xmlAutomataStatePtr +xmlAutomataNewNegTrans (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar * token, + const xmlChar * token2, void *data); + +xmlAutomataStatePtr +xmlAutomataNewCountTrans (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar * token, + int min, int max, void *data); +xmlAutomataStatePtr +xmlAutomataNewCountTrans2 (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar * token, + const xmlChar * token2, + int min, int max, void *data); +xmlAutomataStatePtr +xmlAutomataNewOnceTrans (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar * token, int min, int max, void *data); +xmlAutomataStatePtr +xmlAutomataNewOnceTrans2 (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar * token, + const xmlChar * token2, + int min, int max, void *data); +xmlAutomataStatePtr +xmlAutomataNewAllTrans (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, int lax); +xmlAutomataStatePtr +xmlAutomataNewEpsilon (xmlAutomataPtr am, + xmlAutomataStatePtr from, xmlAutomataStatePtr to); +xmlAutomataStatePtr +xmlAutomataNewCountedTrans (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, int counter); +xmlAutomataStatePtr +xmlAutomataNewCounterTrans (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, int counter); +int xmlAutomataNewCounter (xmlAutomataPtr am, int min, int max); + +xmlRegexpPtr xmlAutomataCompile (xmlAutomataPtr am); +int xmlAutomataIsDeterminist (xmlAutomataPtr am); +typedef struct _xmlValidState xmlValidState; +typedef xmlValidState *xmlValidStatePtr; +typedef void (*xmlValidityErrorFunc) (void *ctx, const char *msg, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); +typedef void (*xmlValidityWarningFunc) (void *ctx, const char *msg, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); +typedef struct _xmlValidCtxt xmlValidCtxt; +typedef xmlValidCtxt *xmlValidCtxtPtr; + +struct _xmlValidCtxt +{ + void *userData; + xmlValidityErrorFunc error; + xmlValidityWarningFunc warning; + xmlNodePtr node; + int nodeNr; + int nodeMax; + xmlNodePtr *nodeTab; + unsigned int finishDtd; + xmlDocPtr doc; + int valid; + xmlValidState *vstate; + int vstateNr; + int vstateMax; + xmlValidState *vstateTab; + xmlAutomataPtr am; + xmlAutomataStatePtr state; +}; + +typedef struct _xmlHashTable xmlNotationTable; +typedef xmlNotationTable *xmlNotationTablePtr; +typedef struct _xmlHashTable xmlElementTable; +typedef xmlElementTable *xmlElementTablePtr; +typedef struct _xmlHashTable xmlAttributeTable; +typedef xmlAttributeTable *xmlAttributeTablePtr; +typedef struct _xmlHashTable xmlIDTable; +typedef xmlIDTable *xmlIDTablePtr; +typedef struct _xmlHashTable xmlRefTable; +typedef xmlRefTable *xmlRefTablePtr; + +xmlNotationPtr xmlAddNotationDecl (xmlValidCtxtPtr ctxt, + xmlDtdPtr dtd, + const xmlChar * name, + const xmlChar * PublicID, const xmlChar * SystemID); + +xmlNotationTablePtr xmlCopyNotationTable (xmlNotationTablePtr table); + +void xmlFreeNotationTable (xmlNotationTablePtr table); + +void xmlDumpNotationDecl (xmlBufferPtr buf, xmlNotationPtr nota); +void xmlDumpNotationTable (xmlBufferPtr buf, xmlNotationTablePtr table); + +xmlElementContentPtr xmlNewElementContent (const xmlChar * name, xmlElementContentType type); +xmlElementContentPtr xmlCopyElementContent (xmlElementContentPtr content); +void xmlFreeElementContent (xmlElementContentPtr cur); + +xmlElementContentPtr xmlNewDocElementContent (xmlDocPtr doc, + const xmlChar * name, xmlElementContentType type); +xmlElementContentPtr xmlCopyDocElementContent (xmlDocPtr doc, xmlElementContentPtr content); +void xmlFreeDocElementContent (xmlDocPtr doc, xmlElementContentPtr cur); +void xmlSnprintfElementContent (char *buf, + int size, + xmlElementContentPtr content, int englob); + +void xmlSprintfElementContent (char *buf, + xmlElementContentPtr content, int englob); + +xmlElementPtr xmlAddElementDecl (xmlValidCtxtPtr ctxt, + xmlDtdPtr dtd, + const xmlChar * name, + xmlElementTypeVal type, xmlElementContentPtr content); + +xmlElementTablePtr xmlCopyElementTable (xmlElementTablePtr table); + +void xmlFreeElementTable (xmlElementTablePtr table); +void xmlDumpElementTable (xmlBufferPtr buf, xmlElementTablePtr table); +void xmlDumpElementDecl (xmlBufferPtr buf, xmlElementPtr elem); +xmlEnumerationPtr xmlCreateEnumeration (const xmlChar * name); +void xmlFreeEnumeration (xmlEnumerationPtr cur); +xmlEnumerationPtr xmlCopyEnumeration (xmlEnumerationPtr cur); + +xmlAttributePtr xmlAddAttributeDecl (xmlValidCtxtPtr ctxt, + xmlDtdPtr dtd, + const xmlChar * elem, + const xmlChar * name, + const xmlChar * ns, + xmlAttributeType type, + xmlAttributeDefault def, + const xmlChar * defaultValue, xmlEnumerationPtr tree); + +xmlAttributeTablePtr xmlCopyAttributeTable (xmlAttributeTablePtr table); +void xmlFreeAttributeTable (xmlAttributeTablePtr table); +void xmlDumpAttributeTable (xmlBufferPtr buf, xmlAttributeTablePtr table); +void xmlDumpAttributeDecl (xmlBufferPtr buf, xmlAttributePtr attr); + +xmlIDPtr xmlAddID (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, const xmlChar * value, xmlAttrPtr attr); +void xmlFreeIDTable (xmlIDTablePtr table); +xmlAttrPtr xmlGetID (xmlDocPtr doc, const xmlChar * ID); +int xmlIsID (xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr); +int xmlRemoveID (xmlDocPtr doc, xmlAttrPtr attr); + +xmlRefPtr xmlAddRef (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, const xmlChar * value, xmlAttrPtr attr); +void xmlFreeRefTable (xmlRefTablePtr table); +int xmlIsRef (xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr); +int xmlRemoveRef (xmlDocPtr doc, xmlAttrPtr attr); +xmlListPtr xmlGetRefs (xmlDocPtr doc, const xmlChar * ID); + +xmlValidCtxtPtr xmlNewValidCtxt (void); +void xmlFreeValidCtxt (xmlValidCtxtPtr); +int xmlValidateRoot (xmlValidCtxtPtr ctxt, xmlDocPtr doc); +int xmlValidateElementDecl (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, xmlElementPtr elem); +xmlChar *xmlValidNormalizeAttributeValue (xmlDocPtr doc, + xmlNodePtr elem, + const xmlChar * name, + const xmlChar * value); +xmlChar *xmlValidCtxtNormalizeAttributeValue (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem, + const xmlChar * name, + const xmlChar * value); +int xmlValidateAttributeDecl (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, xmlAttributePtr attr); +int xmlValidateAttributeValue (xmlAttributeType type, const xmlChar * value); +int xmlValidateNotationDecl (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, xmlNotationPtr nota); +int xmlValidateDtd (xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlDtdPtr dtd); +int xmlValidateDtdFinal (xmlValidCtxtPtr ctxt, xmlDocPtr doc); +int xmlValidateDocument (xmlValidCtxtPtr ctxt, xmlDocPtr doc); +int xmlValidateElement (xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem); +int xmlValidateOneElement (xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem); +int xmlValidateOneAttribute (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem, + xmlAttrPtr attr, const xmlChar * value); +int xmlValidateOneNamespace (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem, + const xmlChar * prefix, + xmlNsPtr ns, const xmlChar * value); +int xmlValidateDocumentFinal (xmlValidCtxtPtr ctxt, xmlDocPtr doc); + + + +int +xmlValidateNotationUse (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, const xmlChar * notationName); + + +int xmlIsMixedElement (xmlDocPtr doc, const xmlChar * name); +xmlAttributePtr xmlGetDtdAttrDesc (xmlDtdPtr dtd, const xmlChar * elem, const xmlChar * name); +xmlAttributePtr xmlGetDtdQAttrDesc (xmlDtdPtr dtd, + const xmlChar * elem, + const xmlChar * name, const xmlChar * prefix); +xmlNotationPtr xmlGetDtdNotationDesc (xmlDtdPtr dtd, const xmlChar * name); +xmlElementPtr xmlGetDtdQElementDesc (xmlDtdPtr dtd, + const xmlChar * name, const xmlChar * prefix); +xmlElementPtr xmlGetDtdElementDesc (xmlDtdPtr dtd, const xmlChar * name); + +int xmlValidGetPotentialChildren (xmlElementContent * ctree, + const xmlChar ** names, int *len, int max); + +int xmlValidGetValidElements (xmlNode * prev, + xmlNode * next, const xmlChar ** names, int max); +int xmlValidateNameValue (const xmlChar * value); +int xmlValidateNamesValue (const xmlChar * value); +int xmlValidateNmtokenValue (const xmlChar * value); +int xmlValidateNmtokensValue (const xmlChar * value); + +int xmlValidBuildContentModel (xmlValidCtxtPtr ctxt, xmlElementPtr elem); + +int +xmlValidatePushElement (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem, const xmlChar * qname); +int +xmlValidatePushCData (xmlValidCtxtPtr ctxt, const xmlChar * data, int len); +int +xmlValidatePopElement (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, xmlNodePtr elem, const xmlChar * qname); +typedef enum + { + XML_INTERNAL_GENERAL_ENTITY = 1, + XML_EXTERNAL_GENERAL_PARSED_ENTITY = 2, + XML_EXTERNAL_GENERAL_UNPARSED_ENTITY = 3, + XML_INTERNAL_PARAMETER_ENTITY = 4, + XML_EXTERNAL_PARAMETER_ENTITY = 5, + XML_INTERNAL_PREDEFINED_ENTITY = 6 + } xmlEntityType; + +struct _xmlEntity +{ + void *_private; + xmlElementType type; + const xmlChar *name; + struct _xmlNode *children; + struct _xmlNode *last; + struct _xmlDtd *parent; + struct _xmlNode *next; + struct _xmlNode *prev; + struct _xmlDoc *doc; + + xmlChar *orig; + xmlChar *content; + int length; + xmlEntityType etype; + const xmlChar *ExternalID; + const xmlChar *SystemID; + + struct _xmlEntity *nexte; + const xmlChar *URI; + int owner; + int checked; +}; + +typedef struct _xmlHashTable xmlEntitiesTable; +typedef xmlEntitiesTable *xmlEntitiesTablePtr; +void xmlInitializePredefinedEntities (void); + +xmlEntityPtr +xmlNewEntity (xmlDocPtr doc, + const xmlChar * name, + int type, + const xmlChar * ExternalID, + const xmlChar * SystemID, const xmlChar * content); +xmlEntityPtr +xmlAddDocEntity (xmlDocPtr doc, + const xmlChar * name, + int type, + const xmlChar * ExternalID, + const xmlChar * SystemID, const xmlChar * content); +xmlEntityPtr +xmlAddDtdEntity (xmlDocPtr doc, + const xmlChar * name, + int type, + const xmlChar * ExternalID, + const xmlChar * SystemID, const xmlChar * content); +xmlEntityPtr xmlGetPredefinedEntity (const xmlChar * name); +xmlEntityPtr xmlGetDocEntity (const xmlDoc * doc, const xmlChar * name); +xmlEntityPtr xmlGetDtdEntity (xmlDocPtr doc, const xmlChar * name); +xmlEntityPtr xmlGetParameterEntity (xmlDocPtr doc, const xmlChar * name); +const xmlChar *xmlEncodeEntities (xmlDocPtr doc, const xmlChar * input); +xmlChar *xmlEncodeEntitiesReentrant (xmlDocPtr doc, const xmlChar * input); +xmlChar *xmlEncodeSpecialChars (const xmlDoc * doc, const xmlChar * input); +xmlEntitiesTablePtr xmlCreateEntitiesTable (void); + +xmlEntitiesTablePtr xmlCopyEntitiesTable (xmlEntitiesTablePtr table); +void xmlFreeEntitiesTable (xmlEntitiesTablePtr table); +void xmlDumpEntitiesTable (xmlBufferPtr buf, xmlEntitiesTablePtr table); +void xmlDumpEntityDecl (xmlBufferPtr buf, xmlEntityPtr ent); +void xmlCleanupPredefinedEntities (void); +typedef void (*xmlParserInputDeallocate) (xmlChar * str); + +struct _xmlParserInput +{ + xmlParserInputBufferPtr buf; + const char *filename; + const char *directory; + const xmlChar *base; + const xmlChar *cur; + const xmlChar *end; + int length; + int line; + int col; + unsigned long consumed; + xmlParserInputDeallocate free; + const xmlChar *encoding; + const xmlChar *version; + int standalone; + int id; +}; + +typedef struct _xmlParserNodeInfo xmlParserNodeInfo; +typedef xmlParserNodeInfo *xmlParserNodeInfoPtr; + +struct _xmlParserNodeInfo +{ + const struct _xmlNode *node; + unsigned long begin_pos; + unsigned long begin_line; + unsigned long end_pos; + unsigned long end_line; +}; + +typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq; +typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr; +struct _xmlParserNodeInfoSeq +{ + unsigned long maximum; + unsigned long length; + xmlParserNodeInfo *buffer; +}; + +typedef enum + { + XML_PARSER_EOF = -1, + XML_PARSER_START = 0, + XML_PARSER_MISC, + XML_PARSER_PI, + XML_PARSER_DTD, + XML_PARSER_PROLOG, + XML_PARSER_COMMENT, + XML_PARSER_START_TAG, + XML_PARSER_CONTENT, + XML_PARSER_CDATA_SECTION, + XML_PARSER_END_TAG, + XML_PARSER_ENTITY_DECL, + XML_PARSER_ENTITY_VALUE, + XML_PARSER_ATTRIBUTE_VALUE, + XML_PARSER_SYSTEM_LITERAL, + XML_PARSER_EPILOG, + XML_PARSER_IGNORE, + XML_PARSER_PUBLIC_LITERAL + } xmlParserInputState; + +typedef enum + { + XML_PARSE_UNKNOWN = 0, + XML_PARSE_DOM = 1, + XML_PARSE_SAX = 2, + XML_PARSE_PUSH_DOM = 3, + XML_PARSE_PUSH_SAX = 4, + XML_PARSE_READER = 5 + } xmlParserMode; + +struct _xmlParserCtxt +{ + struct _xmlSAXHandler *sax; + void *userData; + xmlDocPtr myDoc; + int wellFormed; + int replaceEntities; + const xmlChar *version; + const xmlChar *encoding; + int standalone; + int html; + xmlParserInputPtr input; + int inputNr; + int inputMax; + xmlParserInputPtr *inputTab; + xmlNodePtr node; + int nodeNr; + int nodeMax; + xmlNodePtr *nodeTab; + int record_info; + xmlParserNodeInfoSeq node_seq; + int errNo; + int hasExternalSubset; + int hasPErefs; + int external; + int valid; + int validate; + xmlValidCtxt vctxt; + xmlParserInputState instate; + int token; + char *directory; + const xmlChar *name; + int nameNr; + int nameMax; + const xmlChar **nameTab; + long nbChars; + long checkIndex; + int keepBlanks; + int disableSAX; + int inSubset; + const xmlChar *intSubName; + xmlChar *extSubURI; + xmlChar *extSubSystem; + int *space; + int spaceNr; + int spaceMax; + int *spaceTab; + int depth; + xmlParserInputPtr entity; + int charset; + int nodelen; + int nodemem; + int pedantic; + void *_private; + int loadsubset; + int linenumbers; + void *catalogs; + int recovery; + int progressive; + xmlDictPtr dict; + const xmlChar **atts; + int maxatts; + int docdict; + const xmlChar *str_xml; + const xmlChar *str_xmlns; + const xmlChar *str_xml_ns; + int sax2; + int nsNr; + int nsMax; + const xmlChar **nsTab; + int *attallocs; + void **pushTab; + xmlHashTablePtr attsDefault; + xmlHashTablePtr attsSpecial; + int nsWellFormed; + int options; + int dictNames; + int freeElemsNr; + xmlNodePtr freeElems; + int freeAttrsNr; + xmlAttrPtr freeAttrs; + xmlError lastError; + xmlParserMode parseMode; + unsigned long nbentities; + unsigned long sizeentities; + xmlParserNodeInfo *nodeInfo; + int nodeInfoNr; + int nodeInfoMax; + xmlParserNodeInfo *nodeInfoTab; + int input_id; + unsigned long sizeentcopy; +}; + +struct _xmlSAXLocator +{ + const xmlChar *(*getPublicId) (void *ctx); + const xmlChar *(*getSystemId) (void *ctx); + int (*getLineNumber) (void *ctx); + int (*getColumnNumber) (void *ctx); +}; + +typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx, + const xmlChar * publicId, + const xmlChar * systemId); +typedef void (*internalSubsetSAXFunc) (void *ctx, + const xmlChar * name, + const xmlChar * ExternalID, + const xmlChar * SystemID); +typedef void (*externalSubsetSAXFunc) (void *ctx, + const xmlChar * name, + const xmlChar * ExternalID, + const xmlChar * SystemID); +typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx, const xmlChar * name); +typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx, + const xmlChar * name); +typedef void (*entityDeclSAXFunc) (void *ctx, + const xmlChar * name, + int type, + const xmlChar * publicId, + const xmlChar * systemId, + xmlChar * content); +typedef void (*notationDeclSAXFunc) (void *ctx, + const xmlChar * name, + const xmlChar * publicId, + const xmlChar * systemId); +typedef void (*attributeDeclSAXFunc) (void *ctx, + const xmlChar * elem, + const xmlChar * fullname, + int type, + int def, + const xmlChar * defaultValue, + xmlEnumerationPtr tree); +typedef void (*elementDeclSAXFunc) (void *ctx, + const xmlChar * name, + int type, xmlElementContentPtr content); +typedef void (*unparsedEntityDeclSAXFunc) (void *ctx, + const xmlChar * name, + const xmlChar * publicId, + const xmlChar * systemId, + const xmlChar * notationName); +typedef void (*setDocumentLocatorSAXFunc) (void *ctx, xmlSAXLocatorPtr loc); +typedef void (*startDocumentSAXFunc) (void *ctx); +typedef void (*endDocumentSAXFunc) (void *ctx); +typedef void (*startElementSAXFunc) (void *ctx, + const xmlChar * name, + const xmlChar ** atts); +typedef void (*endElementSAXFunc) (void *ctx, const xmlChar * name); +typedef void (*attributeSAXFunc) (void *ctx, + const xmlChar * name, + const xmlChar * value); +typedef void (*referenceSAXFunc) (void *ctx, const xmlChar * name); +typedef void (*charactersSAXFunc) (void *ctx, const xmlChar * ch, int len); +typedef void (*ignorableWhitespaceSAXFunc) (void *ctx, + const xmlChar * ch, int len); +typedef void (*processingInstructionSAXFunc) (void *ctx, + const xmlChar * target, + const xmlChar * data); + +typedef void (*commentSAXFunc) (void *ctx, const xmlChar * value); +typedef void (*cdataBlockSAXFunc) (void *ctx, const xmlChar * value, int len); +typedef void (*warningSAXFunc) (void *ctx, + const char *msg, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); +typedef void (*errorSAXFunc) (void *ctx, const char *msg, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); +typedef void (*fatalErrorSAXFunc) (void *ctx, const char *msg, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); +typedef int (*isStandaloneSAXFunc) (void *ctx); +typedef int (*hasInternalSubsetSAXFunc) (void *ctx); +typedef int (*hasExternalSubsetSAXFunc) (void *ctx); +typedef void (*startElementNsSAX2Func) (void *ctx, + const xmlChar * localname, + const xmlChar * prefix, + const xmlChar * URI, + int nb_namespaces, + const xmlChar ** namespaces, + int nb_attributes, + int nb_defaulted, + const xmlChar ** attributes); +typedef void (*endElementNsSAX2Func) (void *ctx, + const xmlChar * localname, + const xmlChar * prefix, + const xmlChar * URI); + + +struct _xmlSAXHandler +{ + internalSubsetSAXFunc internalSubset; + isStandaloneSAXFunc isStandalone; + hasInternalSubsetSAXFunc hasInternalSubset; + hasExternalSubsetSAXFunc hasExternalSubset; + resolveEntitySAXFunc resolveEntity; + getEntitySAXFunc getEntity; + entityDeclSAXFunc entityDecl; + notationDeclSAXFunc notationDecl; + attributeDeclSAXFunc attributeDecl; + elementDeclSAXFunc elementDecl; + unparsedEntityDeclSAXFunc unparsedEntityDecl; + setDocumentLocatorSAXFunc setDocumentLocator; + startDocumentSAXFunc startDocument; + endDocumentSAXFunc endDocument; + startElementSAXFunc startElement; + endElementSAXFunc endElement; + referenceSAXFunc reference; + charactersSAXFunc characters; + ignorableWhitespaceSAXFunc ignorableWhitespace; + processingInstructionSAXFunc processingInstruction; + commentSAXFunc comment; + warningSAXFunc warning; + errorSAXFunc error; + fatalErrorSAXFunc fatalError; + getParameterEntitySAXFunc getParameterEntity; + cdataBlockSAXFunc cdataBlock; + externalSubsetSAXFunc externalSubset; + unsigned int initialized; + + void *_private; + startElementNsSAX2Func startElementNs; + endElementNsSAX2Func endElementNs; + xmlStructuredErrorFunc serror; +}; + +typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1; +typedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr; +struct _xmlSAXHandlerV1 +{ + internalSubsetSAXFunc internalSubset; + isStandaloneSAXFunc isStandalone; + hasInternalSubsetSAXFunc hasInternalSubset; + hasExternalSubsetSAXFunc hasExternalSubset; + resolveEntitySAXFunc resolveEntity; + getEntitySAXFunc getEntity; + entityDeclSAXFunc entityDecl; + notationDeclSAXFunc notationDecl; + attributeDeclSAXFunc attributeDecl; + elementDeclSAXFunc elementDecl; + unparsedEntityDeclSAXFunc unparsedEntityDecl; + setDocumentLocatorSAXFunc setDocumentLocator; + startDocumentSAXFunc startDocument; + endDocumentSAXFunc endDocument; + startElementSAXFunc startElement; + endElementSAXFunc endElement; + referenceSAXFunc reference; + charactersSAXFunc characters; + ignorableWhitespaceSAXFunc ignorableWhitespace; + processingInstructionSAXFunc processingInstruction; + commentSAXFunc comment; + warningSAXFunc warning; + errorSAXFunc error; + fatalErrorSAXFunc fatalError; + getParameterEntitySAXFunc getParameterEntity; + cdataBlockSAXFunc cdataBlock; + externalSubsetSAXFunc externalSubset; + unsigned int initialized; +}; +typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL, + const char *ID, + xmlParserCtxtPtr + context); + +typedef void *iconv_t; +extern iconv_t iconv_open (const char *__tocode, const char *__fromcode); +extern size_t iconv (iconv_t __cd, char **__restrict __inbuf, + size_t * __restrict __inbytesleft, + char **__restrict __outbuf, + size_t * __restrict __outbytesleft); + +extern int iconv_close (iconv_t __cd); +typedef int8_t UBool; +typedef short unsigned int UChar; +typedef int32_t UChar32; +typedef uint8_t UVersionInfo[4]; + +extern __attribute__ ((visibility ("default"))) +void u_versionFromString_52 (UVersionInfo versionArray, + const char *versionString); +extern __attribute__ ((visibility ("default"))) +void u_versionFromUString_52 (UVersionInfo versionArray, + const UChar * versionString); +extern __attribute__ ((visibility ("default"))) +void u_versionToString_52 (const UVersionInfo versionArray, + char *versionString); +extern __attribute__ ((visibility ("default"))) +void u_getVersion_52 (UVersionInfo versionArray); + +extern const uint8_t utf8_countTrailBytes_52[256]; +extern __attribute__ ((visibility ("default"))) +UChar32 utf8_nextCharSafeBody_52 (const uint8_t * s, int32_t * pi, int32_t length, + UChar32 c, UBool strict); +extern __attribute__ ((visibility ("default"))) +int32_t utf8_appendCharSafeBody_52 (uint8_t * s, int32_t i, int32_t length, + UChar32 c, UBool * pIsError); +extern __attribute__ ((visibility ("default"))) +UChar32 utf8_prevCharSafeBody_52 (const uint8_t * s, int32_t start, int32_t * pi, + UChar32 c, UBool strict); +extern __attribute__ ((visibility ("default"))) int32_t +utf8_back1SafeBody_52 (const uint8_t * s, int32_t start, int32_t i); + +typedef double UDate; + +typedef enum UErrorCode { + U_USING_FALLBACK_WARNING = -128, + U_ERROR_WARNING_START = -128, + U_USING_DEFAULT_WARNING = -127, + U_SAFECLONE_ALLOCATED_WARNING = -126, + U_STATE_OLD_WARNING = -125, + U_STRING_NOT_TERMINATED_WARNING = -124, + U_SORT_KEY_TOO_SHORT_WARNING = -123, + U_AMBIGUOUS_ALIAS_WARNING = -122, + U_DIFFERENT_UCA_VERSION = -121, + U_PLUGIN_CHANGED_LEVEL_WARNING = -120, + U_ERROR_WARNING_LIMIT, + U_ZERO_ERROR = 0, + U_ILLEGAL_ARGUMENT_ERROR = 1, + U_MISSING_RESOURCE_ERROR = 2, + U_INVALID_FORMAT_ERROR = 3, + U_FILE_ACCESS_ERROR = 4, + U_INTERNAL_PROGRAM_ERROR = 5, + U_MESSAGE_PARSE_ERROR = 6, + U_MEMORY_ALLOCATION_ERROR = 7, + U_INDEX_OUTOFBOUNDS_ERROR = 8, + U_PARSE_ERROR = 9, + U_INVALID_CHAR_FOUND = 10, + U_TRUNCATED_CHAR_FOUND = 11, + U_ILLEGAL_CHAR_FOUND = 12, + U_INVALID_TABLE_FORMAT = 13, + U_INVALID_TABLE_FILE = 14, + U_BUFFER_OVERFLOW_ERROR = 15, + U_UNSUPPORTED_ERROR = 16, + U_RESOURCE_TYPE_MISMATCH = 17, + U_ILLEGAL_ESCAPE_SEQUENCE = 18, + U_UNSUPPORTED_ESCAPE_SEQUENCE = 19, + U_NO_SPACE_AVAILABLE = 20, + U_CE_NOT_FOUND_ERROR = 21, + U_PRIMARY_TOO_LONG_ERROR = 22, + U_STATE_TOO_OLD_ERROR = 23, + U_TOO_MANY_ALIASES_ERROR = 24, + U_ENUM_OUT_OF_SYNC_ERROR = 25, + U_INVARIANT_CONVERSION_ERROR = 26, + U_INVALID_STATE_ERROR = 27, + U_COLLATOR_VERSION_MISMATCH = 28, + U_USELESS_COLLATOR_ERROR = 29, + U_NO_WRITE_PERMISSION = 30, + U_STANDARD_ERROR_LIMIT, + U_BAD_VARIABLE_DEFINITION = 0x10000, + U_PARSE_ERROR_START = 0x10000, + U_MALFORMED_RULE, + U_MALFORMED_SET, + U_MALFORMED_SYMBOL_REFERENCE, + U_MALFORMED_UNICODE_ESCAPE, + U_MALFORMED_VARIABLE_DEFINITION, + U_MALFORMED_VARIABLE_REFERENCE, + U_MISMATCHED_SEGMENT_DELIMITERS, + U_MISPLACED_ANCHOR_START, + U_MISPLACED_CURSOR_OFFSET, + U_MISPLACED_QUANTIFIER, + U_MISSING_OPERATOR, + U_MISSING_SEGMENT_CLOSE, + U_MULTIPLE_ANTE_CONTEXTS, + U_MULTIPLE_CURSORS, + U_MULTIPLE_POST_CONTEXTS, + U_TRAILING_BACKSLASH, + U_UNDEFINED_SEGMENT_REFERENCE, + U_UNDEFINED_VARIABLE, + U_UNQUOTED_SPECIAL, + U_UNTERMINATED_QUOTE, + U_RULE_MASK_ERROR, + U_MISPLACED_COMPOUND_FILTER, + U_MULTIPLE_COMPOUND_FILTERS, + U_INVALID_RBT_SYNTAX, + U_INVALID_PROPERTY_PATTERN, + U_MALFORMED_PRAGMA, + U_UNCLOSED_SEGMENT, + U_ILLEGAL_CHAR_IN_SEGMENT, + U_VARIABLE_RANGE_EXHAUSTED, + U_VARIABLE_RANGE_OVERLAP, + U_ILLEGAL_CHARACTER, + U_INTERNAL_TRANSLITERATOR_ERROR, + U_INVALID_ID, + U_INVALID_FUNCTION, + U_PARSE_ERROR_LIMIT, + U_UNEXPECTED_TOKEN = 0x10100, + U_FMT_PARSE_ERROR_START = 0x10100, + U_MULTIPLE_DECIMAL_SEPARATORS, + U_MULTIPLE_DECIMAL_SEPERATORS = U_MULTIPLE_DECIMAL_SEPARATORS, + U_MULTIPLE_EXPONENTIAL_SYMBOLS, + U_MALFORMED_EXPONENTIAL_PATTERN, + U_MULTIPLE_PERCENT_SYMBOLS, + U_MULTIPLE_PERMILL_SYMBOLS, + U_MULTIPLE_PAD_SPECIFIERS, + U_PATTERN_SYNTAX_ERROR, + U_ILLEGAL_PAD_POSITION, + U_UNMATCHED_BRACES, + U_UNSUPPORTED_PROPERTY, + U_UNSUPPORTED_ATTRIBUTE, + U_ARGUMENT_TYPE_MISMATCH, + U_DUPLICATE_KEYWORD, + U_UNDEFINED_KEYWORD, + U_DEFAULT_KEYWORD_MISSING, + U_DECIMAL_NUMBER_SYNTAX_ERROR, + U_FORMAT_INEXACT_ERROR, + U_FMT_PARSE_ERROR_LIMIT, + U_BRK_INTERNAL_ERROR = 0x10200, + U_BRK_ERROR_START = 0x10200, + U_BRK_HEX_DIGITS_EXPECTED, + U_BRK_SEMICOLON_EXPECTED, + U_BRK_RULE_SYNTAX, + U_BRK_UNCLOSED_SET, + U_BRK_ASSIGN_ERROR, + U_BRK_VARIABLE_REDFINITION, + U_BRK_MISMATCHED_PAREN, + U_BRK_NEW_LINE_IN_QUOTED_STRING, + U_BRK_UNDEFINED_VARIABLE, + U_BRK_INIT_ERROR, + U_BRK_RULE_EMPTY_SET, + U_BRK_UNRECOGNIZED_OPTION, + U_BRK_MALFORMED_RULE_TAG, + U_BRK_ERROR_LIMIT, + U_REGEX_INTERNAL_ERROR = 0x10300, + U_REGEX_ERROR_START = 0x10300, + U_REGEX_RULE_SYNTAX, + U_REGEX_INVALID_STATE, + U_REGEX_BAD_ESCAPE_SEQUENCE, + U_REGEX_PROPERTY_SYNTAX, + U_REGEX_UNIMPLEMENTED, + U_REGEX_MISMATCHED_PAREN, + U_REGEX_NUMBER_TOO_BIG, + U_REGEX_BAD_INTERVAL, + U_REGEX_MAX_LT_MIN, + U_REGEX_INVALID_BACK_REF, + U_REGEX_INVALID_FLAG, + U_REGEX_LOOK_BEHIND_LIMIT, + U_REGEX_SET_CONTAINS_STRING, + U_REGEX_OCTAL_TOO_BIG, + U_REGEX_MISSING_CLOSE_BRACKET, + U_REGEX_INVALID_RANGE, + U_REGEX_STACK_OVERFLOW, + U_REGEX_TIME_OUT, + U_REGEX_STOPPED_BY_CALLER, + U_REGEX_PATTERN_TOO_BIG, + U_REGEX_ERROR_LIMIT, + U_IDNA_PROHIBITED_ERROR = 0x10400, + U_IDNA_ERROR_START = 0x10400, + U_IDNA_UNASSIGNED_ERROR, + U_IDNA_CHECK_BIDI_ERROR, + U_IDNA_STD3_ASCII_RULES_ERROR, + U_IDNA_ACE_PREFIX_ERROR, + U_IDNA_VERIFICATION_ERROR, + U_IDNA_LABEL_TOO_LONG_ERROR, + U_IDNA_ZERO_LENGTH_LABEL_ERROR, + U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR, + U_IDNA_ERROR_LIMIT, + U_STRINGPREP_PROHIBITED_ERROR = U_IDNA_PROHIBITED_ERROR, + U_STRINGPREP_UNASSIGNED_ERROR = U_IDNA_UNASSIGNED_ERROR, + U_STRINGPREP_CHECK_BIDI_ERROR = U_IDNA_CHECK_BIDI_ERROR, + U_PLUGIN_ERROR_START = 0x10500, + U_PLUGIN_TOO_HIGH = 0x10500, + U_PLUGIN_DIDNT_SET_LEVEL, + U_PLUGIN_ERROR_LIMIT, + U_ERROR_LIMIT = U_PLUGIN_ERROR_LIMIT +} UErrorCode; + +extern __attribute__ ((visibility ("default"))) +const char * u_errorName_52 (UErrorCode code); + +struct UConverter; + +typedef struct UConverter UConverter; +typedef enum { + UCNV_UNASSIGNED = 0, + UCNV_ILLEGAL = 1, + UCNV_IRREGULAR = 2, + UCNV_RESET = 3, + UCNV_CLOSE = 4, + UCNV_CLONE = 5 +} UConverterCallbackReason; + +typedef struct +{ + uint16_t size; + UBool flush; + UConverter *converter; + const UChar *source; + const UChar *sourceLimit; + char *target; + const char *targetLimit; + int32_t * offsets; +} UConverterFromUnicodeArgs; + +typedef struct +{ + uint16_t size; + UBool flush; + UConverter *converter; + const char *source; + const char *sourceLimit; + UChar *target; + const UChar *targetLimit; + int32_t *offsets; +} UConverterToUnicodeArgs; + +extern __attribute__ ((visibility ("default"))) +void UCNV_FROM_U_CALLBACK_STOP_52 (const void *context, + UConverterFromUnicodeArgs * fromUArgs, + const UChar * codeUnits, + int32_t length, + UChar32 codePoint, + UConverterCallbackReason reason, + UErrorCode * err); + +extern __attribute__ ((visibility ("default"))) +void UCNV_TO_U_CALLBACK_STOP_52 (const void *context, + UConverterToUnicodeArgs * toUArgs, + const char *codeUnits, + int32_t length, + UConverterCallbackReason reason, + UErrorCode * err); + +extern __attribute__ ((visibility ("default"))) +void UCNV_FROM_U_CALLBACK_SKIP_52 (const void *context, + UConverterFromUnicodeArgs * fromUArgs, + const UChar * codeUnits, + int32_t length, + UChar32 codePoint, + UConverterCallbackReason reason, + UErrorCode * err); + +extern __attribute__ ((visibility ("default"))) +void UCNV_FROM_U_CALLBACK_SUBSTITUTE_52 (const void *context, + UConverterFromUnicodeArgs * + fromUArgs, const UChar * codeUnits, + int32_t length, UChar32 codePoint, + UConverterCallbackReason reason, + UErrorCode * err); + +extern __attribute__ ((visibility ("default"))) +void UCNV_FROM_U_CALLBACK_ESCAPE_52 (const void *context, + UConverterFromUnicodeArgs * fromUArgs, + const UChar * codeUnits, + int32_t length, + UChar32 codePoint, + UConverterCallbackReason reason, + UErrorCode * err); + +extern __attribute__ ((visibility ("default"))) +void UCNV_TO_U_CALLBACK_SKIP_52 (const void *context, + UConverterToUnicodeArgs * toUArgs, + const char *codeUnits, + int32_t length, + UConverterCallbackReason reason, + UErrorCode * err); + +extern __attribute__ ((visibility ("default"))) +void UCNV_TO_U_CALLBACK_SUBSTITUTE_52 (const void *context, + UConverterToUnicodeArgs * toUArgs, + const char *codeUnits, + int32_t length, + UConverterCallbackReason reason, + UErrorCode * err); + +extern __attribute__ ((visibility ("default"))) +void UCNV_TO_U_CALLBACK_ESCAPE_52 (const void *context, + UConverterToUnicodeArgs * toUArgs, + const char *codeUnits, + int32_t length, + UConverterCallbackReason reason, + UErrorCode * err); +struct UEnumeration; + +typedef struct UEnumeration UEnumeration; + +extern __attribute__ ((visibility ("default"))) +void uenum_close_52 (UEnumeration * en); + +extern __attribute__ ((visibility ("default"))) +int32_t uenum_count_52 (UEnumeration * en, UErrorCode * status); + +extern __attribute__ ((visibility ("default"))) +const UChar *uenum_unext_52 (UEnumeration * en, + int32_t * resultLength, UErrorCode * status); + +extern __attribute__ ((visibility ("default"))) +const char *uenum_next_52 (UEnumeration * en, + int32_t * resultLength, UErrorCode * status); + +extern __attribute__ ((visibility ("default"))) +void uenum_reset_52 (UEnumeration * en, UErrorCode * status); + +extern __attribute__ ((visibility ("default"))) +UEnumeration *uenum_openUCharStringsEnumeration_52 (const UChar * const strings[], + int32_t count, UErrorCode * ec); + +extern __attribute__ ((visibility ("default"))) +UEnumeration *uenum_openCharStringsEnumeration_52 (const char *const strings[], + int32_t count, UErrorCode * ec); + +struct USet; +typedef struct USet USet; + +typedef enum { + UCNV_UNSUPPORTED_CONVERTER = -1, + UCNV_SBCS = 0, + UCNV_DBCS = 1, + UCNV_MBCS = 2, + UCNV_LATIN_1 = 3, + UCNV_UTF8 = 4, + UCNV_UTF16_BigEndian = 5, + UCNV_UTF16_LittleEndian = 6, + UCNV_UTF32_BigEndian = 7, + UCNV_UTF32_LittleEndian = 8, + UCNV_EBCDIC_STATEFUL = 9, + UCNV_ISO_2022 = 10, + UCNV_LMBCS_1 = 11, + UCNV_LMBCS_2, + UCNV_LMBCS_3, + UCNV_LMBCS_4, + UCNV_LMBCS_5, + UCNV_LMBCS_6, + UCNV_LMBCS_8, + UCNV_LMBCS_11, + UCNV_LMBCS_16, + UCNV_LMBCS_17, + UCNV_LMBCS_18, + UCNV_LMBCS_19, + UCNV_LMBCS_LAST = UCNV_LMBCS_19, + UCNV_HZ, + UCNV_SCSU, + UCNV_ISCII, + UCNV_US_ASCII, + UCNV_UTF7, + UCNV_BOCU1, + UCNV_UTF16, + UCNV_UTF32, + UCNV_CESU8, + UCNV_IMAP_MAILBOX, + UCNV_COMPOUND_TEXT, + UCNV_NUMBER_OF_SUPPORTED_CONVERTER_TYPES +} UConverterType; + +typedef enum { + UCNV_UNKNOWN = -1, + UCNV_IBM = 0 +} UConverterPlatform; + +typedef void (*UConverterToUCallback) (const void *context, + UConverterToUnicodeArgs * args, + const char *codeUnits, + int32_t length, + UConverterCallbackReason reason, + UErrorCode * pErrorCode); + +typedef void (*UConverterFromUCallback) (const void *context, + UConverterFromUnicodeArgs * + args, const UChar * codeUnits, + int32_t length, + UChar32 codePoint, + UConverterCallbackReason reason, + UErrorCode * pErrorCode); + +extern __attribute__ ((visibility ("default"))) +int ucnv_compareNames_52 (const char *name1, const char *name2); + +extern __attribute__ ((visibility ("default"))) +UConverter *ucnv_open_52 (const char *converterName, UErrorCode * err); + +extern __attribute__ ((visibility ("default"))) +UConverter *ucnv_openU_52 (const UChar * name, UErrorCode * err); + +extern __attribute__ ((visibility ("default"))) +UConverter *ucnv_openCCSID_52 (int32_t codepage, + UConverterPlatform platform, UErrorCode * err); + +extern __attribute__ ((visibility ("default"))) +UConverter *ucnv_openPackage_52 (const char *packageName, const char *converterName, + UErrorCode * err); +extern __attribute__ ((visibility ("default"))) +UConverter * +ucnv_safeClone_52 (const UConverter * cnv, + void *stackBuffer, + int32_t * pBufferSize, UErrorCode * status); +extern __attribute__ ((visibility ("default"))) +void +ucnv_close_52 (UConverter * converter); +extern __attribute__ ((visibility ("default"))) +void +ucnv_getSubstChars_52 (const UConverter * converter, + char *subChars, int8_t * len, UErrorCode * err); +extern __attribute__ ((visibility ("default"))) +void +ucnv_setSubstChars_52 (UConverter * converter, + const char *subChars, + int8_t len, UErrorCode * err); +extern __attribute__ ((visibility ("default"))) +void +ucnv_setSubstString_52 (UConverter * cnv, + const UChar * s, + int32_t length, UErrorCode * err); +extern __attribute__ ((visibility ("default"))) +void +ucnv_getInvalidChars_52 (const UConverter * converter, + char *errBytes, int8_t * len, UErrorCode * err); +extern __attribute__ ((visibility ("default"))) +void +ucnv_getInvalidUChars_52 (const UConverter * converter, + UChar * errUChars, + int8_t * len, UErrorCode * err); +extern __attribute__ ((visibility ("default"))) +void +ucnv_reset_52 (UConverter * converter); +extern __attribute__ ((visibility ("default"))) +void +ucnv_resetToUnicode_52 (UConverter * converter); +extern __attribute__ ((visibility ("default"))) +void +ucnv_resetFromUnicode_52 (UConverter * converter); +extern __attribute__ ((visibility ("default"))) int8_t +ucnv_getMaxCharSize_52 (const UConverter * converter); +extern __attribute__ ((visibility ("default"))) int8_t +ucnv_getMinCharSize_52 (const UConverter * converter); +extern __attribute__ ((visibility ("default"))) int32_t +ucnv_getDisplayName_52 (const UConverter * converter, + const char *displayLocale, + UChar * displayName, + int32_t displayNameCapacity, UErrorCode * err); +extern __attribute__ ((visibility ("default"))) +const char * +ucnv_getName_52 (const UConverter * converter, UErrorCode * err); +extern __attribute__ ((visibility ("default"))) int32_t +ucnv_getCCSID_52 (const UConverter * converter, UErrorCode * err); +extern __attribute__ ((visibility ("default"))) UConverterPlatform +ucnv_getPlatform_52 (const UConverter * converter, UErrorCode * err); +extern __attribute__ ((visibility ("default"))) UConverterType +ucnv_getType_52 (const UConverter * converter); +extern __attribute__ ((visibility ("default"))) +void +ucnv_getStarters_52 (const UConverter * converter, + UBool starters[256], UErrorCode * err); + +typedef enum UConverterUnicodeSet { + + UCNV_ROUNDTRIP_SET, + + UCNV_ROUNDTRIP_AND_FALLBACK_SET, + + UCNV_SET_COUNT +} UConverterUnicodeSet; +extern __attribute__ ((visibility ("default"))) +void +ucnv_getUnicodeSet_52 (const UConverter * cnv, + USet * setFillIn, + UConverterUnicodeSet whichSet, + UErrorCode * pErrorCode); +extern __attribute__ ((visibility ("default"))) +void +ucnv_getToUCallBack_52 (const UConverter * converter, + UConverterToUCallback * action, + const void **context); +extern __attribute__ ((visibility ("default"))) +void +ucnv_getFromUCallBack_52 (const UConverter * converter, + UConverterFromUCallback * action, + const void **context); +extern __attribute__ ((visibility ("default"))) +void +ucnv_setToUCallBack_52 (UConverter * converter, + UConverterToUCallback newAction, + const void *newContext, + UConverterToUCallback * oldAction, + const void **oldContext, UErrorCode * err); +extern __attribute__ ((visibility ("default"))) +void +ucnv_setFromUCallBack_52 (UConverter * converter, + UConverterFromUCallback newAction, + const void *newContext, + UConverterFromUCallback * oldAction, + const void **oldContext, UErrorCode * err); +extern __attribute__ ((visibility ("default"))) +void +ucnv_fromUnicode_52 (UConverter * converter, + char **target, + const char *targetLimit, + const UChar ** source, + const UChar * sourceLimit, + int32_t * offsets, UBool flush, UErrorCode * err); +extern __attribute__ ((visibility ("default"))) +void +ucnv_toUnicode_52 (UConverter * converter, + UChar ** target, + const UChar * targetLimit, + const char **source, + const char *sourceLimit, + int32_t * offsets, UBool flush, UErrorCode * err); +extern __attribute__ ((visibility ("default"))) int32_t +ucnv_fromUChars_52 (UConverter * cnv, + char *dest, int32_t destCapacity, + const UChar * src, int32_t srcLength, + UErrorCode * pErrorCode); +extern __attribute__ ((visibility ("default"))) int32_t +ucnv_toUChars_52 (UConverter * cnv, + UChar * dest, int32_t destCapacity, + const char *src, int32_t srcLength, + UErrorCode * pErrorCode); +extern __attribute__ ((visibility ("default"))) UChar32 +ucnv_getNextUChar_52 (UConverter * converter, + const char **source, + const char *sourceLimit, UErrorCode * err); +extern __attribute__ ((visibility ("default"))) +void +ucnv_convertEx_52 (UConverter * targetCnv, UConverter * sourceCnv, + char **target, const char *targetLimit, + const char **source, const char *sourceLimit, + UChar * pivotStart, UChar ** pivotSource, + UChar ** pivotTarget, const UChar * pivotLimit, + UBool reset, UBool flush, UErrorCode * pErrorCode); +extern __attribute__ ((visibility ("default"))) int32_t +ucnv_convert_52 (const char *toConverterName, + const char *fromConverterName, + char *target, + int32_t targetCapacity, + const char *source, + int32_t sourceLength, UErrorCode * pErrorCode); +extern __attribute__ ((visibility ("default"))) int32_t +ucnv_toAlgorithmic_52 (UConverterType algorithmicType, + UConverter * cnv, + char *target, int32_t targetCapacity, + const char *source, int32_t sourceLength, + UErrorCode * pErrorCode); +extern __attribute__ ((visibility ("default"))) int32_t +ucnv_fromAlgorithmic_52 (UConverter * cnv, + UConverterType algorithmicType, + char *target, int32_t targetCapacity, + const char *source, int32_t sourceLength, + UErrorCode * pErrorCode); +extern __attribute__ ((visibility ("default"))) int32_t +ucnv_flushCache_52 (void); +extern __attribute__ ((visibility ("default"))) int32_t +ucnv_countAvailable_52 (void); +extern __attribute__ ((visibility ("default"))) +const char * +ucnv_getAvailableName_52 (int32_t n); +extern __attribute__ ((visibility ("default"))) +UEnumeration * +ucnv_openAllNames_52 (UErrorCode * pErrorCode); +extern __attribute__ ((visibility ("default"))) uint16_t +ucnv_countAliases_52 (const char *alias, UErrorCode * pErrorCode); +extern __attribute__ ((visibility ("default"))) +const char * +ucnv_getAlias_52 (const char *alias, uint16_t n, + UErrorCode * pErrorCode); +extern __attribute__ ((visibility ("default"))) +void +ucnv_getAliases_52 (const char *alias, const char **aliases, + UErrorCode * pErrorCode); +extern __attribute__ ((visibility ("default"))) +UEnumeration * +ucnv_openStandardNames_52 (const char *convName, + const char *standard, + UErrorCode * pErrorCode); + + + + + + +extern __attribute__ ((visibility ("default"))) uint16_t +ucnv_countStandards_52 (void); +extern __attribute__ ((visibility ("default"))) +const char * +ucnv_getStandard_52 (uint16_t n, UErrorCode * pErrorCode); +extern __attribute__ ((visibility ("default"))) +const char * +ucnv_getStandardName_52 (const char *name, const char *standard, + UErrorCode * pErrorCode); +extern __attribute__ ((visibility ("default"))) +const char * +ucnv_getCanonicalName_52 (const char *alias, const char *standard, + UErrorCode * pErrorCode); +extern __attribute__ ((visibility ("default"))) +const char * +ucnv_getDefaultName_52 (void); +extern __attribute__ ((visibility ("default"))) +void +ucnv_setDefaultName_52 (const char *name); +extern __attribute__ ((visibility ("default"))) +void +ucnv_fixFileSeparator_52 (const UConverter * cnv, UChar * source, + int32_t sourceLen); +extern +__attribute__ ((visibility ("default"))) UBool +ucnv_isAmbiguous_52 (const UConverter * cnv); +extern __attribute__ ((visibility ("default"))) +void +ucnv_setFallback_52 (UConverter * cnv, UBool usesFallback); +extern __attribute__ ((visibility ("default"))) UBool +ucnv_usesFallback_52 (const UConverter * cnv); +extern __attribute__ ((visibility ("default"))) +const char * +ucnv_detectUnicodeSignature_52 (const char *source, + int32_t sourceLength, + int32_t * signatureLength, + UErrorCode * pErrorCode); +extern __attribute__ ((visibility ("default"))) int32_t +ucnv_fromUCountPending_52 (const UConverter * cnv, UErrorCode * status); +extern __attribute__ ((visibility ("default"))) int32_t +ucnv_toUCountPending_52 (const UConverter * cnv, UErrorCode * status); +extern __attribute__ ((visibility ("default"))) UBool +ucnv_isFixedWidth_52 (UConverter * cnv, UErrorCode * status); + +typedef enum + { + XML_CHAR_ENCODING_ERROR = -1, + XML_CHAR_ENCODING_NONE = 0, + XML_CHAR_ENCODING_UTF8 = 1, + XML_CHAR_ENCODING_UTF16LE = 2, + XML_CHAR_ENCODING_UTF16BE = 3, + XML_CHAR_ENCODING_UCS4LE = 4, + XML_CHAR_ENCODING_UCS4BE = 5, + XML_CHAR_ENCODING_EBCDIC = 6, + XML_CHAR_ENCODING_UCS4_2143 = 7, + XML_CHAR_ENCODING_UCS4_3412 = 8, + XML_CHAR_ENCODING_UCS2 = 9, + XML_CHAR_ENCODING_8859_1 = 10, + XML_CHAR_ENCODING_8859_2 = 11, + XML_CHAR_ENCODING_8859_3 = 12, + XML_CHAR_ENCODING_8859_4 = 13, + XML_CHAR_ENCODING_8859_5 = 14, + XML_CHAR_ENCODING_8859_6 = 15, + XML_CHAR_ENCODING_8859_7 = 16, + XML_CHAR_ENCODING_8859_8 = 17, + XML_CHAR_ENCODING_8859_9 = 18, + XML_CHAR_ENCODING_2022_JP = 19, + XML_CHAR_ENCODING_SHIFT_JIS = 20, + XML_CHAR_ENCODING_EUC_JP = 21, + XML_CHAR_ENCODING_ASCII = 22 + } xmlCharEncoding; +typedef int (*xmlCharEncodingInputFunc) (unsigned char *out, int *outlen, + const unsigned char *in, + int *inlen); +typedef int (*xmlCharEncodingOutputFunc) (unsigned char *out, + int *outlen, + const unsigned char *in, + int *inlen); + + + + + + + +struct _uconv_t +{ + UConverter * + uconv; + UConverter * + utf8; +}; +typedef struct _uconv_t +uconv_t; + + +typedef struct _xmlCharEncodingHandler +xmlCharEncodingHandler; +typedef xmlCharEncodingHandler * +xmlCharEncodingHandlerPtr; +struct _xmlCharEncodingHandler +{ + char * + name; + xmlCharEncodingInputFunc + input; + xmlCharEncodingOutputFunc + output; + + iconv_t + iconv_in; + iconv_t + iconv_out; + + + uconv_t * + uconv_in; + uconv_t * + uconv_out; + +}; +void +xmlInitCharEncodingHandlers (void); +void +xmlCleanupCharEncodingHandlers (void); +void +xmlRegisterCharEncodingHandler (xmlCharEncodingHandlerPtr handler); +xmlCharEncodingHandlerPtr +xmlGetCharEncodingHandler (xmlCharEncoding enc); +xmlCharEncodingHandlerPtr +xmlFindCharEncodingHandler (const char *name); +xmlCharEncodingHandlerPtr +xmlNewCharEncodingHandler (const char *name, + xmlCharEncodingInputFunc input, + xmlCharEncodingOutputFunc output); + + + + +int xmlAddEncodingAlias (const char *name, const char *alias); +int xmlDelEncodingAlias (const char *alias); +const char *xmlGetEncodingAlias (const char *alias); +void xmlCleanupEncodingAliases (void); +xmlCharEncoding +xmlParseCharEncoding (const char *name); +const char *xmlGetCharEncodingName (xmlCharEncoding enc); + + + + +xmlCharEncoding +xmlDetectCharEncoding (const unsigned char *in, int len); + +int +xmlCharEncOutFunc (xmlCharEncodingHandler * handler, + xmlBufferPtr out, xmlBufferPtr in); + +int +xmlCharEncInFunc (xmlCharEncodingHandler * handler, + xmlBufferPtr out, xmlBufferPtr in); +int +xmlCharEncFirstLine (xmlCharEncodingHandler * handler, + xmlBufferPtr out, xmlBufferPtr in); +int xmlCharEncCloseFunc (xmlCharEncodingHandler * handler); + + + + + +int +UTF8Toisolat1 (unsigned char *out, + int *outlen, const unsigned char *in, int *inlen); + +int +isolat1ToUTF8 (unsigned char *out, + int *outlen, const unsigned char *in, int *inlen); +typedef int (*xmlInputMatchCallback) (char const *filename); +typedef void *(*xmlInputOpenCallback) (char const *filename); +typedef int (*xmlInputReadCallback) (void *context, char *buffer, + int len); +typedef int (*xmlInputCloseCallback) (void *context); +typedef int (*xmlOutputMatchCallback) (char const *filename); +typedef void *(*xmlOutputOpenCallback) (char const *filename); +typedef int (*xmlOutputWriteCallback) (void *context, const char *buffer, + int len); +typedef int (*xmlOutputCloseCallback) (void *context); + + + + + + + +typedef xmlChar *xlinkHRef; +typedef xmlChar *xlinkRole; +typedef xmlChar *xlinkTitle; + +typedef enum + { + XLINK_TYPE_NONE = 0, + XLINK_TYPE_SIMPLE, + XLINK_TYPE_EXTENDED, + XLINK_TYPE_EXTENDED_SET + } xlinkType; + +typedef enum + { + XLINK_SHOW_NONE = 0, + XLINK_SHOW_NEW, + XLINK_SHOW_EMBED, + XLINK_SHOW_REPLACE + } xlinkShow; + +typedef enum + { + XLINK_ACTUATE_NONE = 0, + XLINK_ACTUATE_AUTO, + XLINK_ACTUATE_ONREQUEST + } xlinkActuate; +typedef void (*xlinkNodeDetectFunc) (void *ctx, xmlNodePtr node); +typedef void +(*xlinkSimpleLinkFunk) (void *ctx, + xmlNodePtr node, + const xlinkHRef href, + const xlinkRole role, const xlinkTitle title); +typedef void +(*xlinkExtendedLinkFunk) (void *ctx, + xmlNodePtr node, + int nbLocators, + const xlinkHRef * hrefs, + const xlinkRole * roles, + int nbArcs, + const xlinkRole * from, + const xlinkRole * to, + xlinkShow * show, + xlinkActuate * actuate, + int nbTitles, + const xlinkTitle * titles, + const xmlChar ** langs); +typedef void +(*xlinkExtendedLinkSetFunk) (void *ctx, + xmlNodePtr node, + int nbLocators, + const xlinkHRef * hrefs, + const xlinkRole * roles, + int nbTitles, + const xlinkTitle * titles, + const xmlChar ** langs); + + + + + + + +typedef struct _xlinkHandler xlinkHandler; +typedef xlinkHandler *xlinkHandlerPtr; +struct _xlinkHandler +{ + xlinkSimpleLinkFunk simple; + xlinkExtendedLinkFunk extended; + xlinkExtendedLinkSetFunk set; +}; + + + + + + +xlinkNodeDetectFunc +xlinkGetDefaultDetect (void); +void xlinkSetDefaultDetect (xlinkNodeDetectFunc func); + + + + +xlinkHandlerPtr +xlinkGetDefaultHandler (void); +void xlinkSetDefaultHandler (xlinkHandlerPtr handler); + + + + +xlinkType +xlinkIsLink (xmlDocPtr doc, xmlNodePtr node); + + + + + + +const xmlChar *getPublicId (void *ctx); +const xmlChar *getSystemId (void *ctx); +void setDocumentLocator (void *ctx, xmlSAXLocatorPtr loc); + +int getLineNumber (void *ctx); +int getColumnNumber (void *ctx); + +int isStandalone (void *ctx); +int hasInternalSubset (void *ctx); +int hasExternalSubset (void *ctx); + +void +internalSubset (void *ctx, + const xmlChar * name, + const xmlChar * ExternalID, const xmlChar * SystemID); +void +externalSubset (void *ctx, + const xmlChar * name, + const xmlChar * ExternalID, const xmlChar * SystemID); +xmlEntityPtr +getEntity (void *ctx, const xmlChar * name); +xmlEntityPtr +getParameterEntity (void *ctx, const xmlChar * name); +xmlParserInputPtr +resolveEntity (void *ctx, const xmlChar * publicId, const xmlChar * systemId); + +void +entityDecl (void *ctx, + const xmlChar * name, + int type, + const xmlChar * publicId, + const xmlChar * systemId, xmlChar * content); +void +attributeDecl (void *ctx, + const xmlChar * elem, + const xmlChar * fullname, + int type, + int def, + const xmlChar * defaultValue, xmlEnumerationPtr tree); +void +elementDecl (void *ctx, + const xmlChar * name, + int type, xmlElementContentPtr content); +void +notationDecl (void *ctx, + const xmlChar * name, + const xmlChar * publicId, const xmlChar * systemId); +void +unparsedEntityDecl (void *ctx, + const xmlChar * name, + const xmlChar * publicId, + const xmlChar * systemId, + const xmlChar * notationName); + +void startDocument (void *ctx); +void endDocument (void *ctx); +void +attribute (void *ctx, const xmlChar * fullname, const xmlChar * value); +void +startElement (void *ctx, + const xmlChar * fullname, const xmlChar ** atts); +void endElement (void *ctx, const xmlChar * name); +void reference (void *ctx, const xmlChar * name); +void characters (void *ctx, const xmlChar * ch, int len); +void ignorableWhitespace (void *ctx, const xmlChar * ch, int len); +void +processingInstruction (void *ctx, + const xmlChar * target, const xmlChar * data); +void +globalNamespace (void *ctx, + const xmlChar * href, const xmlChar * prefix); +void setNamespace (void *ctx, const xmlChar * name); +xmlNsPtr +getNamespace (void *ctx); +int checkNamespace (void *ctx, xmlChar * nameSpace); +void +namespaceDecl (void *ctx, + const xmlChar * href, const xmlChar * prefix); +void comment (void *ctx, const xmlChar * value); +void cdataBlock (void *ctx, const xmlChar * value, int len); + + +void initxmlDefaultSAXHandler (xmlSAXHandlerV1 * hdlr, int warning); + +void inithtmlDefaultSAXHandler (xmlSAXHandlerV1 * hdlr); + + +void initdocbDefaultSAXHandler (xmlSAXHandlerV1 * hdlr); +const xmlChar *xmlSAX2GetPublicId (void *ctx); +const xmlChar *xmlSAX2GetSystemId (void *ctx); +void xmlSAX2SetDocumentLocator (void *ctx, xmlSAXLocatorPtr loc); + +int xmlSAX2GetLineNumber (void *ctx); +int xmlSAX2GetColumnNumber (void *ctx); + +int xmlSAX2IsStandalone (void *ctx); +int xmlSAX2HasInternalSubset (void *ctx); +int xmlSAX2HasExternalSubset (void *ctx); + +void +xmlSAX2InternalSubset (void *ctx, + const xmlChar * name, + const xmlChar * ExternalID, + const xmlChar * SystemID); +void +xmlSAX2ExternalSubset (void *ctx, + const xmlChar * name, + const xmlChar * ExternalID, + const xmlChar * SystemID); +xmlEntityPtr +xmlSAX2GetEntity (void *ctx, const xmlChar * name); +xmlEntityPtr +xmlSAX2GetParameterEntity (void *ctx, const xmlChar * name); +xmlParserInputPtr +xmlSAX2ResolveEntity (void *ctx, + const xmlChar * publicId, const xmlChar * systemId); + +void +xmlSAX2EntityDecl (void *ctx, + const xmlChar * name, + int type, + const xmlChar * publicId, + const xmlChar * systemId, xmlChar * content); +void +xmlSAX2AttributeDecl (void *ctx, + const xmlChar * elem, + const xmlChar * fullname, + int type, + int def, + const xmlChar * defaultValue, + xmlEnumerationPtr tree); +void +xmlSAX2ElementDecl (void *ctx, + const xmlChar * name, + int type, xmlElementContentPtr content); +void +xmlSAX2NotationDecl (void *ctx, + const xmlChar * name, + const xmlChar * publicId, + const xmlChar * systemId); +void +xmlSAX2UnparsedEntityDecl (void *ctx, + const xmlChar * name, + const xmlChar * publicId, + const xmlChar * systemId, + const xmlChar * notationName); + +void xmlSAX2StartDocument (void *ctx); +void xmlSAX2EndDocument (void *ctx); + + + +void +xmlSAX2StartElement (void *ctx, + const xmlChar * fullname, const xmlChar ** atts); +void xmlSAX2EndElement (void *ctx, const xmlChar * name); + +void +xmlSAX2StartElementNs (void *ctx, + const xmlChar * localname, + const xmlChar * prefix, + const xmlChar * URI, + int nb_namespaces, + const xmlChar ** namespaces, + int nb_attributes, + int nb_defaulted, const xmlChar ** attributes); +void +xmlSAX2EndElementNs (void *ctx, + const xmlChar * localname, + const xmlChar * prefix, const xmlChar * URI); +void xmlSAX2Reference (void *ctx, const xmlChar * name); +void xmlSAX2Characters (void *ctx, const xmlChar * ch, int len); +void xmlSAX2IgnorableWhitespace (void *ctx, const xmlChar * ch, int len); +void +xmlSAX2ProcessingInstruction (void *ctx, + const xmlChar * target, + const xmlChar * data); +void xmlSAX2Comment (void *ctx, const xmlChar * value); +void xmlSAX2CDataBlock (void *ctx, const xmlChar * value, int len); + + +int xmlSAXDefaultVersion (int version); + + +int xmlSAXVersion (xmlSAXHandler * hdlr, int version); +void xmlSAX2InitDefaultSAXHandler (xmlSAXHandler * hdlr, int warning); + +void xmlSAX2InitHtmlDefaultSAXHandler (xmlSAXHandler * hdlr); +void htmlDefaultSAXHandlerInit (void); + + +void xmlSAX2InitDocbDefaultSAXHandler (xmlSAXHandler * hdlr); +void docbDefaultSAXHandlerInit (void); + +void xmlDefaultSAXHandlerInit (void); +typedef void (*xmlFreeFunc) (void *mem); +typedef void *( __attribute__ ((alloc_size (1))) * + xmlMallocFunc) (size_t size); +typedef void *(*xmlReallocFunc) (void *mem, size_t size); +typedef char *(*xmlStrdupFunc) (const char *str); +int +xmlMemSetup (xmlFreeFunc freeFunc, + xmlMallocFunc mallocFunc, + xmlReallocFunc reallocFunc, xmlStrdupFunc strdupFunc); +int +xmlMemGet (xmlFreeFunc * freeFunc, + xmlMallocFunc * mallocFunc, + xmlReallocFunc * reallocFunc, xmlStrdupFunc * strdupFunc); +int +xmlGcMemSetup (xmlFreeFunc freeFunc, + xmlMallocFunc mallocFunc, + xmlMallocFunc mallocAtomicFunc, + xmlReallocFunc reallocFunc, xmlStrdupFunc strdupFunc); +int +xmlGcMemGet (xmlFreeFunc * freeFunc, + xmlMallocFunc * mallocFunc, + xmlMallocFunc * mallocAtomicFunc, + xmlReallocFunc * reallocFunc, xmlStrdupFunc * strdupFunc); + + + + +int xmlInitMemory (void); + + + + +void xmlCleanupMemory (void); + + + +int xmlMemUsed (void); +int xmlMemBlocks (void); +void xmlMemDisplay (FILE * fp); +void xmlMemDisplayLast (FILE * fp, long nbBytes); +void xmlMemShow (FILE * fp, int nr); +void xmlMemoryDump (void); +void *xmlMemMalloc (size_t size) __attribute__ ((alloc_size (1))); +void *xmlMemRealloc (void *ptr, size_t size); +void xmlMemFree (void *ptr); +char *xmlMemoryStrdup (const char *str); +void *xmlMallocLoc (size_t size, const char *file, int line) + __attribute__ ((alloc_size (1))); +void *xmlReallocLoc (void *ptr, size_t size, const char *file, int line); +void *xmlMallocAtomicLoc (size_t size, const char *file, int line) + __attribute__ ((alloc_size (1))); +char *xmlMemStrdupLoc (const char *str, const char *file, int line); + + + + + +void xmlInitGlobals (void); +void xmlCleanupGlobals (void); +typedef +xmlParserInputBufferPtr (*xmlParserInputBufferCreateFilenameFunc) +(const char *URI, xmlCharEncoding enc); +typedef xmlOutputBufferPtr (*xmlOutputBufferCreateFilenameFunc) (const + char + *URI, + xmlCharEncodingHandlerPtr + encoder, + int + compression); + +xmlParserInputBufferCreateFilenameFunc +xmlParserInputBufferCreateFilenameDefault +(xmlParserInputBufferCreateFilenameFunc func); +xmlOutputBufferCreateFilenameFunc +xmlOutputBufferCreateFilenameDefault (xmlOutputBufferCreateFilenameFunc func); +typedef void (*xmlRegisterNodeFunc) (xmlNodePtr node); + + + + + + +typedef void (*xmlDeregisterNodeFunc) (xmlNodePtr node); + +typedef struct _xmlGlobalState xmlGlobalState; +typedef xmlGlobalState *xmlGlobalStatePtr; +struct _xmlGlobalState +{ + const char *xmlParserVersion; + + xmlSAXLocator xmlDefaultSAXLocator; + xmlSAXHandlerV1 xmlDefaultSAXHandler; + xmlSAXHandlerV1 docbDefaultSAXHandler; + xmlSAXHandlerV1 htmlDefaultSAXHandler; + + xmlFreeFunc xmlFree; + xmlMallocFunc xmlMalloc; + xmlStrdupFunc xmlMemStrdup; + xmlReallocFunc xmlRealloc; + + xmlGenericErrorFunc xmlGenericError; + xmlStructuredErrorFunc xmlStructuredError; + void *xmlGenericErrorContext; + + int oldXMLWDcompatibility; + + xmlBufferAllocationScheme xmlBufferAllocScheme; + int xmlDefaultBufferSize; + + int xmlSubstituteEntitiesDefaultValue; + int xmlDoValidityCheckingDefaultValue; + int xmlGetWarningsDefaultValue; + int xmlKeepBlanksDefaultValue; + int xmlLineNumbersDefaultValue; + int xmlLoadExtDtdDefaultValue; + int xmlParserDebugEntities; + int xmlPedanticParserDefaultValue; + + int xmlSaveNoEmptyTags; + int xmlIndentTreeOutput; + const char *xmlTreeIndentString; + + xmlRegisterNodeFunc xmlRegisterNodeDefaultValue; + xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue; + + xmlMallocFunc xmlMallocAtomic; + xmlError xmlLastError; + + xmlParserInputBufferCreateFilenameFunc + xmlParserInputBufferCreateFilenameValue; + xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue; + + void *xmlStructuredErrorContext; +}; + + + + +typedef struct _xmlMutex xmlMutex; +typedef xmlMutex *xmlMutexPtr; + + + + +typedef struct _xmlRMutex xmlRMutex; +typedef xmlRMutex *xmlRMutexPtr; + + + + + + + +xmlMutexPtr +xmlNewMutex (void); +void xmlMutexLock (xmlMutexPtr tok); +void xmlMutexUnlock (xmlMutexPtr tok); +void xmlFreeMutex (xmlMutexPtr tok); + +xmlRMutexPtr +xmlNewRMutex (void); +void xmlRMutexLock (xmlRMutexPtr tok); +void xmlRMutexUnlock (xmlRMutexPtr tok); +void xmlFreeRMutex (xmlRMutexPtr tok); + + + + +void xmlInitThreads (void); +void xmlLockLibrary (void); +void xmlUnlockLibrary (void); +int xmlGetThreadId (void); +int xmlIsMainThread (void); +void xmlCleanupThreads (void); +xmlGlobalStatePtr +xmlGetGlobalState (void); + + + + +void xmlInitializeGlobalState (xmlGlobalStatePtr gs); + +void xmlThrDefSetGenericErrorFunc (void *ctx, + xmlGenericErrorFunc handler); + +void xmlThrDefSetStructuredErrorFunc (void *ctx, + xmlStructuredErrorFunc handler); + +xmlRegisterNodeFunc xmlRegisterNodeDefault (xmlRegisterNodeFunc func); +xmlRegisterNodeFunc xmlThrDefRegisterNodeDefault (xmlRegisterNodeFunc + func); +xmlDeregisterNodeFunc xmlDeregisterNodeDefault (xmlDeregisterNodeFunc + func); +xmlDeregisterNodeFunc +xmlThrDefDeregisterNodeDefault (xmlDeregisterNodeFunc func); + +xmlOutputBufferCreateFilenameFunc +xmlThrDefOutputBufferCreateFilenameDefault (xmlOutputBufferCreateFilenameFunc + func); +xmlParserInputBufferCreateFilenameFunc +xmlThrDefParserInputBufferCreateFilenameDefault +(xmlParserInputBufferCreateFilenameFunc func); +extern xmlMallocFunc xmlMalloc; +extern xmlMallocFunc xmlMallocAtomic; +extern xmlReallocFunc xmlRealloc; +extern xmlFreeFunc xmlFree; +extern xmlStrdupFunc xmlMemStrdup; + + + +xmlSAXHandlerV1 *__docbDefaultSAXHandler (void); +xmlSAXHandlerV1 *__htmlDefaultSAXHandler (void); +xmlError *__xmlLastError (void); +int *__oldXMLWDcompatibility (void); + + + + + + + +xmlBufferAllocationScheme *__xmlBufferAllocScheme (void); + + + + + + +xmlBufferAllocationScheme +xmlThrDefBufferAllocScheme (xmlBufferAllocationScheme v); + +int *__xmlDefaultBufferSize (void); + + + + + + +int xmlThrDefDefaultBufferSize (int v); + +xmlSAXHandlerV1 *__xmlDefaultSAXHandler (void); + + + + + + + +xmlSAXLocator *__xmlDefaultSAXLocator (void); + + + + + + + +int *__xmlDoValidityCheckingDefaultValue (void); + + + + + + +int xmlThrDefDoValidityCheckingDefaultValue (int v); + +xmlGenericErrorFunc *__xmlGenericError (void); + + + + + + + +xmlStructuredErrorFunc *__xmlStructuredError (void); + + + + + + + +void **__xmlGenericErrorContext (void); + + + + + + + +void **__xmlStructuredErrorContext (void); + + + + + + + +int *__xmlGetWarningsDefaultValue (void); + + + + + + +int xmlThrDefGetWarningsDefaultValue (int v); + +int *__xmlIndentTreeOutput (void); + + + + + + +int xmlThrDefIndentTreeOutput (int v); + +const char **__xmlTreeIndentString (void); + + + + + + +const char *xmlThrDefTreeIndentString (const char *v); + +int *__xmlKeepBlanksDefaultValue (void); + + + + + + +int xmlThrDefKeepBlanksDefaultValue (int v); + +int *__xmlLineNumbersDefaultValue (void); + + + + + + +int xmlThrDefLineNumbersDefaultValue (int v); + +int *__xmlLoadExtDtdDefaultValue (void); + + + + + + +int xmlThrDefLoadExtDtdDefaultValue (int v); + +int *__xmlParserDebugEntities (void); + + + + + + +int xmlThrDefParserDebugEntities (int v); + +const char **__xmlParserVersion (void); + + + + + + + +int *__xmlPedanticParserDefaultValue (void); + + + + + + +int xmlThrDefPedanticParserDefaultValue (int v); + +int *__xmlSaveNoEmptyTags (void); + + + + + + +int xmlThrDefSaveNoEmptyTags (int v); + +int *__xmlSubstituteEntitiesDefaultValue (void); + + + + + + +int xmlThrDefSubstituteEntitiesDefaultValue (int v); + +xmlRegisterNodeFunc *__xmlRegisterNodeDefaultValue (void); + + + + + + + +xmlDeregisterNodeFunc *__xmlDeregisterNodeDefaultValue (void); + + + + + + + +xmlParserInputBufferCreateFilenameFunc +*__xmlParserInputBufferCreateFilenameValue (void); + + + + + + + +xmlOutputBufferCreateFilenameFunc +*__xmlOutputBufferCreateFilenameValue (void); + + + + + + + +struct _xmlParserInputBuffer +{ + void *context; + xmlInputReadCallback readcallback; + xmlInputCloseCallback closecallback; + + xmlCharEncodingHandlerPtr encoder; + + xmlBufPtr buffer; + xmlBufPtr raw; + int compressed; + int error; + unsigned long rawconsumed; +}; + + + +struct _xmlOutputBuffer +{ + void *context; + xmlOutputWriteCallback writecallback; + xmlOutputCloseCallback closecallback; + + xmlCharEncodingHandlerPtr encoder; + + xmlBufPtr buffer; + xmlBufPtr conv; + int written; + int error; +}; + + + + + +void xmlCleanupInputCallbacks (void); + +int xmlPopInputCallbacks (void); + +void xmlRegisterDefaultInputCallbacks (void); +xmlParserInputBufferPtr +xmlAllocParserInputBuffer (xmlCharEncoding enc); + +xmlParserInputBufferPtr +xmlParserInputBufferCreateFilename (const char *URI, xmlCharEncoding enc); +xmlParserInputBufferPtr +xmlParserInputBufferCreateFile (FILE * file, xmlCharEncoding enc); +xmlParserInputBufferPtr +xmlParserInputBufferCreateFd (int fd, xmlCharEncoding enc); +xmlParserInputBufferPtr +xmlParserInputBufferCreateMem (const char *mem, int size, + xmlCharEncoding enc); +xmlParserInputBufferPtr +xmlParserInputBufferCreateStatic (const char *mem, int size, + xmlCharEncoding enc); +xmlParserInputBufferPtr +xmlParserInputBufferCreateIO (xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, xmlCharEncoding enc); +int xmlParserInputBufferRead (xmlParserInputBufferPtr in, int len); +int xmlParserInputBufferGrow (xmlParserInputBufferPtr in, int len); +int +xmlParserInputBufferPush (xmlParserInputBufferPtr in, + int len, const char *buf); +void xmlFreeParserInputBuffer (xmlParserInputBufferPtr in); +char *xmlParserGetDirectory (const char *filename); + +int +xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc, + xmlInputOpenCallback openFunc, + xmlInputReadCallback readFunc, + xmlInputCloseCallback closeFunc); + +xmlParserInputBufferPtr +__xmlParserInputBufferCreateFilename (const char *URI, xmlCharEncoding enc); + + + + + +void xmlCleanupOutputCallbacks (void); +void xmlRegisterDefaultOutputCallbacks (void); +xmlOutputBufferPtr +xmlAllocOutputBuffer (xmlCharEncodingHandlerPtr encoder); + +xmlOutputBufferPtr +xmlOutputBufferCreateFilename (const char *URI, + xmlCharEncodingHandlerPtr encoder, + int compression); + +xmlOutputBufferPtr +xmlOutputBufferCreateFile (FILE * file, xmlCharEncodingHandlerPtr encoder); + +xmlOutputBufferPtr +xmlOutputBufferCreateBuffer (xmlBufferPtr buffer, + xmlCharEncodingHandlerPtr encoder); + +xmlOutputBufferPtr +xmlOutputBufferCreateFd (int fd, xmlCharEncodingHandlerPtr encoder); + +xmlOutputBufferPtr +xmlOutputBufferCreateIO (xmlOutputWriteCallback iowrite, + xmlOutputCloseCallback ioclose, + void *ioctx, xmlCharEncodingHandlerPtr encoder); + + +const xmlChar *xmlOutputBufferGetContent (xmlOutputBufferPtr out); +size_t +xmlOutputBufferGetSize (xmlOutputBufferPtr out); + +int +xmlOutputBufferWrite (xmlOutputBufferPtr out, + int len, const char *buf); +int xmlOutputBufferWriteString (xmlOutputBufferPtr out, const char *str); +int +xmlOutputBufferWriteEscape (xmlOutputBufferPtr out, + const xmlChar * str, + xmlCharEncodingOutputFunc escaping); + +int xmlOutputBufferFlush (xmlOutputBufferPtr out); +int xmlOutputBufferClose (xmlOutputBufferPtr out); + +int +xmlRegisterOutputCallbacks (xmlOutputMatchCallback matchFunc, + xmlOutputOpenCallback openFunc, + xmlOutputWriteCallback writeFunc, + xmlOutputCloseCallback closeFunc); + +xmlOutputBufferPtr +__xmlOutputBufferCreateFilename (const char *URI, + xmlCharEncodingHandlerPtr encoder, + int compression); + + + +void xmlRegisterHTTPPostCallbacks (void); + + + + +xmlParserInputPtr +xmlCheckHTTPInput (xmlParserCtxtPtr ctxt, xmlParserInputPtr ret); + + + + +xmlParserInputPtr +xmlNoNetExternalEntityLoader (const char *URL, + const char *ID, xmlParserCtxtPtr ctxt); + + + + + +xmlChar *xmlNormalizeWindowsPath (const xmlChar * path); + +int xmlCheckFilename (const char *path); + + + +int xmlFileMatch (const char *filename); +void *xmlFileOpen (const char *filename); +int xmlFileRead (void *context, char *buffer, int len); +int xmlFileClose (void *context); + + + + + +int xmlIOHTTPMatch (const char *filename); +void *xmlIOHTTPOpen (const char *filename); + +void *xmlIOHTTPOpenW (const char *post_uri, int compression); + +int xmlIOHTTPRead (void *context, char *buffer, int len); +int xmlIOHTTPClose (void *context); + + + + + + +int xmlIOFTPMatch (const char *filename); +void *xmlIOFTPOpen (const char *filename); +int xmlIOFTPRead (void *context, char *buffer, int len); +int xmlIOFTPClose (void *context); +void xmlInitParser (void); +void xmlCleanupParser (void); + + + + +int xmlParserInputRead (xmlParserInputPtr in, int len); +int xmlParserInputGrow (xmlParserInputPtr in, int len); + + + + + +xmlDocPtr +xmlParseDoc (const xmlChar * cur); +xmlDocPtr +xmlParseFile (const char *filename); +xmlDocPtr +xmlParseMemory (const char *buffer, int size); + +int xmlSubstituteEntitiesDefault (int val); +int xmlKeepBlanksDefault (int val); +void xmlStopParser (xmlParserCtxtPtr ctxt); +int xmlPedanticParserDefault (int val); +int xmlLineNumbersDefault (int val); + + + + + +xmlDocPtr +xmlRecoverDoc (const xmlChar * cur); +xmlDocPtr +xmlRecoverMemory (const char *buffer, int size); +xmlDocPtr +xmlRecoverFile (const char *filename); + + + + + +int xmlParseDocument (xmlParserCtxtPtr ctxt); +int xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt); + +int +xmlSAXUserParseFile (xmlSAXHandlerPtr sax, + void *user_data, const char *filename); +int +xmlSAXUserParseMemory (xmlSAXHandlerPtr sax, + void *user_data, const char *buffer, int size); +xmlDocPtr +xmlSAXParseDoc (xmlSAXHandlerPtr sax, const xmlChar * cur, int recovery); +xmlDocPtr +xmlSAXParseMemory (xmlSAXHandlerPtr sax, + const char *buffer, int size, int recovery); +xmlDocPtr +xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax, + const char *buffer, + int size, int recovery, void *data); +xmlDocPtr +xmlSAXParseFile (xmlSAXHandlerPtr sax, const char *filename, int recovery); +xmlDocPtr +xmlSAXParseFileWithData (xmlSAXHandlerPtr sax, + const char *filename, int recovery, void *data); +xmlDocPtr +xmlSAXParseEntity (xmlSAXHandlerPtr sax, const char *filename); +xmlDocPtr +xmlParseEntity (const char *filename); + + + +xmlDtdPtr +xmlSAXParseDTD (xmlSAXHandlerPtr sax, + const xmlChar * ExternalID, const xmlChar * SystemID); +xmlDtdPtr +xmlParseDTD (const xmlChar * ExternalID, const xmlChar * SystemID); +xmlDtdPtr +xmlIOParseDTD (xmlSAXHandlerPtr sax, + xmlParserInputBufferPtr input, xmlCharEncoding enc); + + +int +xmlParseBalancedChunkMemory (xmlDocPtr doc, + xmlSAXHandlerPtr sax, + void *user_data, + int depth, + const xmlChar * string, xmlNodePtr * lst); + +xmlParserErrors +xmlParseInNodeContext (xmlNodePtr node, + const char *data, + int datalen, int options, xmlNodePtr * lst); + +int +xmlParseBalancedChunkMemoryRecover (xmlDocPtr doc, + xmlSAXHandlerPtr sax, + void *user_data, + int depth, + const xmlChar * string, + xmlNodePtr * lst, int recover); +int +xmlParseExternalEntity (xmlDocPtr doc, + xmlSAXHandlerPtr sax, + void *user_data, + int depth, + const xmlChar * URL, + const xmlChar * ID, xmlNodePtr * lst); + +int +xmlParseCtxtExternalEntity (xmlParserCtxtPtr ctx, + const xmlChar * URL, + const xmlChar * ID, xmlNodePtr * lst); + + + + +xmlParserCtxtPtr +xmlNewParserCtxt (void); +int xmlInitParserCtxt (xmlParserCtxtPtr ctxt); +void xmlClearParserCtxt (xmlParserCtxtPtr ctxt); +void xmlFreeParserCtxt (xmlParserCtxtPtr ctxt); + +void +xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt, + const xmlChar * buffer, const char *filename); + +xmlParserCtxtPtr +xmlCreateDocParserCtxt (const xmlChar * cur); + + + + + +int xmlGetFeaturesList (int *len, const char **result); +int +xmlGetFeature (xmlParserCtxtPtr ctxt, const char *name, void *result); +int xmlSetFeature (xmlParserCtxtPtr ctxt, const char *name, void *value); + + + + + + +xmlParserCtxtPtr +xmlCreatePushParserCtxt (xmlSAXHandlerPtr sax, + void *user_data, + const char *chunk, int size, const char *filename); +int +xmlParseChunk (xmlParserCtxtPtr ctxt, + const char *chunk, int size, int terminate); + + + + + + +xmlParserCtxtPtr +xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax, + void *user_data, + xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, xmlCharEncoding enc); + +xmlParserInputPtr +xmlNewIOInputStream (xmlParserCtxtPtr ctxt, + xmlParserInputBufferPtr input, xmlCharEncoding enc); + + + + +const xmlParserNodeInfo *xmlParserFindNodeInfo (const xmlParserCtxtPtr + ctxt, + const xmlNodePtr node); +void xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq); +void xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq); +unsigned long +xmlParserFindNodeInfoIndex (const xmlParserNodeInfoSeqPtr seq, + const xmlNodePtr node); +void +xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt, + const xmlParserNodeInfoPtr info); + + + + + +void xmlSetExternalEntityLoader (xmlExternalEntityLoader f); +xmlExternalEntityLoader +xmlGetExternalEntityLoader (void); +xmlParserInputPtr +xmlLoadExternalEntity (const char *URL, + const char *ID, xmlParserCtxtPtr ctxt); + + + + +long xmlByteConsumed (xmlParserCtxtPtr ctxt); +typedef enum + { + XML_PARSE_RECOVER = 1 << 0, + XML_PARSE_NOENT = 1 << 1, + XML_PARSE_DTDLOAD = 1 << 2, + XML_PARSE_DTDATTR = 1 << 3, + XML_PARSE_DTDVALID = 1 << 4, + XML_PARSE_NOERROR = 1 << 5, + XML_PARSE_NOWARNING = 1 << 6, + XML_PARSE_PEDANTIC = 1 << 7, + XML_PARSE_NOBLANKS = 1 << 8, + XML_PARSE_SAX1 = 1 << 9, + XML_PARSE_XINCLUDE = 1 << 10, + XML_PARSE_NONET = 1 << 11, + XML_PARSE_NODICT = 1 << 12, + XML_PARSE_NSCLEAN = 1 << 13, + XML_PARSE_NOCDATA = 1 << 14, + XML_PARSE_NOXINCNODE = 1 << 15, + XML_PARSE_COMPACT = 1 << 16, + + + XML_PARSE_OLD10 = 1 << 17, + XML_PARSE_NOBASEFIX = 1 << 18, + XML_PARSE_HUGE = 1 << 19, + XML_PARSE_OLDSAX = 1 << 20, + XML_PARSE_IGNORE_ENC = 1 << 21, + XML_PARSE_BIG_LINES = 1 << 22 + } xmlParserOption; + +void xmlCtxtReset (xmlParserCtxtPtr ctxt); +int +xmlCtxtResetPush (xmlParserCtxtPtr ctxt, + const char *chunk, + int size, + const char *filename, const char *encoding); +int xmlCtxtUseOptions (xmlParserCtxtPtr ctxt, int options); +xmlDocPtr +xmlReadDoc (const xmlChar * cur, + const char *URL, const char *encoding, int options); +xmlDocPtr +xmlReadFile (const char *URL, const char *encoding, int options); +xmlDocPtr +xmlReadMemory (const char *buffer, + int size, const char *URL, const char *encoding, int options); +xmlDocPtr +xmlReadFd (int fd, const char *URL, const char *encoding, int options); +xmlDocPtr +xmlReadIO (xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, const char *URL, const char *encoding, int options); +xmlDocPtr +xmlCtxtReadDoc (xmlParserCtxtPtr ctxt, + const xmlChar * cur, + const char *URL, const char *encoding, int options); +xmlDocPtr +xmlCtxtReadFile (xmlParserCtxtPtr ctxt, + const char *filename, const char *encoding, int options); +xmlDocPtr +xmlCtxtReadMemory (xmlParserCtxtPtr ctxt, + const char *buffer, + int size, + const char *URL, const char *encoding, int options); +xmlDocPtr +xmlCtxtReadFd (xmlParserCtxtPtr ctxt, + int fd, const char *URL, const char *encoding, int options); +xmlDocPtr +xmlCtxtReadIO (xmlParserCtxtPtr ctxt, + xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + const char *URL, const char *encoding, int options); +typedef enum + { + XML_WITH_THREAD = 1, + XML_WITH_TREE = 2, + XML_WITH_OUTPUT = 3, + XML_WITH_PUSH = 4, + XML_WITH_READER = 5, + XML_WITH_PATTERN = 6, + XML_WITH_WRITER = 7, + XML_WITH_SAX1 = 8, + XML_WITH_FTP = 9, + XML_WITH_HTTP = 10, + XML_WITH_VALID = 11, + XML_WITH_HTML = 12, + XML_WITH_LEGACY = 13, + XML_WITH_C14N = 14, + XML_WITH_CATALOG = 15, + XML_WITH_XPATH = 16, + XML_WITH_XPTR = 17, + XML_WITH_XINCLUDE = 18, + XML_WITH_ICONV = 19, + XML_WITH_ISO8859X = 20, + XML_WITH_UNICODE = 21, + XML_WITH_REGEXP = 22, + XML_WITH_AUTOMATA = 23, + XML_WITH_EXPR = 24, + XML_WITH_SCHEMAS = 25, + XML_WITH_SCHEMATRON = 26, + XML_WITH_MODULES = 27, + XML_WITH_DEBUG = 28, + XML_WITH_DEBUG_MEM = 29, + XML_WITH_DEBUG_RUN = 30, + XML_WITH_ZLIB = 31, + XML_WITH_ICU = 32, + XML_WITH_LZMA = 33, + XML_WITH_NONE = 99999 + } xmlFeature; + +int xmlHasFeature (xmlFeature feature); +typedef unsigned long int ub4; + + + +typedef signed long int sb4; + + + +typedef unsigned short int ub2; + + + +typedef signed short int sb2; + + + +typedef unsigned char ub1; + + + +typedef signed char sb1; + + + +typedef int word; +struct randctx +{ + ub4 randcnt; + ub4 randrsl[(1 << (4))]; + ub4 randmem[(1 << (4))]; + ub4 randa; + ub4 randb; + ub4 randc; +}; +typedef struct randctx randctx; + + + + + + +void irandinit (randctx * r, word flag); + +void isaac (randctx * r); +char *flam3_version (); +typedef struct +{ + double index; + double color[4]; +} flam3_palette_entry; + +typedef flam3_palette_entry flam3_palette[256]; + +int flam3_get_palette (int palette_index, flam3_palette p, + double hue_rotation); + + + + +extern char *flam3_variation_names[]; +typedef struct +{ + + double badvals; + long int num_iters; + int render_seconds; + +} stat_struct; + +typedef struct +{ + + unsigned int width, height; + int version; + int id; + + + double intensity_weight[256]; + unsigned int bin_size[256]; + unsigned int bin_offset[256]; + + + + + + unsigned short *rowcols; + +} flam3_image_store; + + +typedef struct xform +{ + double var[98]; + double c[3][2]; + double post[3][2]; + double density; + double color; + double color_speed; + double animate; + double opacity; + double vis_adjusted; + + int padding; + double wind[2]; + + int precalc_angles_flag; + int precalc_atan_xy_flag; + int precalc_atan_yx_flag; + double has_preblur; + int has_post; + + + + double blob_low; + double blob_high; + double blob_waves; + + + double pdj_a; + double pdj_b; + double pdj_c; + double pdj_d; + + + double fan2_x; + double fan2_y; + + + double rings2_val; + + + double perspective_angle; + double perspective_dist; + + + double julian_power; + double julian_dist; + + + double juliascope_power; + double juliascope_dist; + + + double radial_blur_angle; + + + double pie_slices; + double pie_rotation; + double pie_thickness; + + + double ngon_sides; + double ngon_power; + double ngon_circle; + double ngon_corners; + + + double curl_c1; + double curl_c2; + + + double rectangles_x; + double rectangles_y; + + + double amw_amp; + + + double disc2_rot; + double disc2_twist; + + + double super_shape_rnd; + double super_shape_m; + double super_shape_n1; + double super_shape_n2; + double super_shape_n3; + double super_shape_holes; + + + double flower_petals; + double flower_holes; + + + double conic_eccentricity; + double conic_holes; + + + double parabola_height; + double parabola_width; + + + double bent2_x; + double bent2_y; + + + double bipolar_shift; + + + double cell_size; + + + double cpow_r; + double cpow_i; + double cpow_power; + + + double curve_xamp, curve_yamp; + double curve_xlength, curve_ylength; + + + double escher_beta; + + + double lazysusan_spin; + double lazysusan_space; + double lazysusan_twist; + double lazysusan_x, lazysusan_y; + + + double modulus_x, modulus_y; + + + double oscope_separation; + double oscope_frequency; + double oscope_amplitude; + double oscope_damping; + + + double popcorn2_x, popcorn2_y, popcorn2_c; + + + double separation_x, separation_xinside; + double separation_y, separation_yinside; + + + double split_xsize; + double split_ysize; + + + double splits_x, splits_y; + + + double stripes_space; + double stripes_warp; + + + double wedge_angle, wedge_hole; + double wedge_count, wedge_swirl; + + + double wedge_julia_angle; + double wedge_julia_count; + double wedge_julia_power; + double wedge_julia_dist; + + + double wedge_sph_angle, wedge_sph_count; + double wedge_sph_hole, wedge_sph_swirl; + + + double whorl_inside, whorl_outside; + + + double waves2_freqx, waves2_scalex; + double waves2_freqy, waves2_scaley; + + + double auger_sym, auger_weight; + double auger_freq, auger_scale; + + + double flux_spread; + + + + double persp_vsin; + double persp_vfcos; + + + double julian_rN; + double julian_cn; + + + double juliascope_rN; + double juliascope_cn; + + + double wedgeJulia_rN; + double wedgeJulia_cn; + double wedgeJulia_cf; + + + double radialBlur_spinvar; + double radialBlur_zoomvar; + + + double waves_dx2; + double waves_dy2; + + + double disc2_sinadd; + double disc2_cosadd; + double disc2_timespi; + + + double super_shape_pm_4; + double super_shape_pneg1_n1; + + int num_active_vars; + double active_var_weights[98]; + int varFunc[98]; + + int motion_freq; + int motion_func; + + struct xform *motion; + int num_motion; + + +} flam3_xform; + +typedef struct +{ + char flame_name[64 + 1]; + double time; + int interpolation; + int interpolation_type; + int palette_interpolation; + int num_xforms; + int final_xform_index; + int final_xform_enable; + flam3_xform *xform; + + + double **chaos; + int chaos_enable; + + int genome_index; + char parent_fname[30]; + int symmetry; + flam3_palette palette; + char *input_image; + int palette_index; + double brightness; + double contrast; + double gamma; + double highlight_power; + int width, height; + int spatial_oversample; + double center[2]; + double rot_center[2]; + double rotate; + double vibrancy; + double hue_rotation; + double background[3]; + double zoom; + double pixels_per_unit; + double spatial_filter_radius; + int spatial_filter_select; + + + double sample_density; + + + + + + + int nbatches; + int ntemporal_samples; + + + double estimator; + double estimator_curve; + double estimator_minimum; + + + + xmlDocPtr edits; + + + double gam_lin_thresh; + + + int palette_index0; + double hue_rotation0; + int palette_index1; + double hue_rotation1; + double palette_blend; + + int temporal_filter_type; + double temporal_filter_width, temporal_filter_exp; + + int palette_mode; + + +} flam3_genome; + +typedef struct +{ + int from; + int to; + double scalar; +} flam3_chaos_entry; + + + +void flam3_add_motion_element (flam3_xform * xf); +void flam3_add_xforms (flam3_genome * cp, int num_to_add, + int interp_padding, int final_flag); +void flam3_delete_xform (flam3_genome * thiscp, int idx_to_delete); +void flam3_copy_xform (flam3_xform * dest, flam3_xform * src); +void flam3_copy (flam3_genome * dest, flam3_genome * src); +void flam3_copyx (flam3_genome * dest, flam3_genome * src, int num_std, + int num_final); +void flam3_copy_params (flam3_xform * dest, flam3_xform * src, int varn); +void flam3_delete_motion_elements (flam3_xform * xf); + +int flam3_xform_preview (flam3_genome * cp, int xi, double range, + int numvals, int depth, double *result, + randctx * rc); +unsigned short *flam3_create_xform_distrib (flam3_genome * cp); +int flam3_create_chaos_distrib (flam3_genome * cp, int xi, + unsigned short *xform_distrib); +int flam3_check_unity_chaos (flam3_genome * cp); +void clear_cp (flam3_genome * cp, int def_flag); + + + + + + +int flam3_iterate (flam3_genome * g, int nsamples, int fuse, + double *samples, unsigned short *xform_distrib, + randctx * rc); + +void apply_motion_parameters (flam3_xform * xf, flam3_xform * addto, + double blend); + + + +void flam3_interpolate (flam3_genome * genomes, int ngenomes, + double time, double stagger, + flam3_genome * result); + + +void flam3_print (FILE * f, flam3_genome * g, char *extra_attributes, + int print_edits); +void flam3_print_xform (FILE * f, flam3_xform * x, int final_flag, + int numstd, double *chaos_row, int motion_flag); +char *flam3_print_to_string (flam3_genome * cp); + + + + + +void flam3_random (flam3_genome * g, int *ivars, int ivars_n, int sym, + int spec_xforms); + +void add_to_action (char *action, char *addtoaction); + +void flam3_mutate (flam3_genome * cp, int mutate_mode, int *ivars, + int ivars_n, int sym, double speed, randctx * rc, + char *action); +void flam3_cross (flam3_genome * cp0, flam3_genome * cp1, + flam3_genome * out, int cross_mode, randctx * rc, + char *action); + + +flam3_genome *flam3_parse_xml2 (char *s, char *fn, int default_flag, + int *ncps); +flam3_genome *flam3_parse_from_file (FILE * f, char *fn, + int default_flag, int *ncps); + +void flam3_add_symmetry (flam3_genome * g, int sym); + +void flam3_improve_colors (flam3_genome * g, int ntries, + int change_palette, int color_resolution); +int flam3_colorhist (flam3_genome * cp, int num_batches, randctx * rc, + double *hist); +int flam3_estimate_bounding_box (flam3_genome * g, double eps, + int nsamples, double *bmin, + double *bmax, randctx * rc); +void flam3_rotate (flam3_genome * g, double angle, int interp_type); + +double flam3_dimension (flam3_genome * g, int ntries, + int clip_to_camera); +double flam3_lyapunov (flam3_genome * g, int ntries); + +void flam3_apply_template (flam3_genome * cp, flam3_genome * templ); + +int flam3_count_nthreads (void); + +typedef struct +{ + + double pixel_aspect_ratio; + flam3_genome *genomes; + int ngenomes; + int verbose; + int bits; + int bytes_per_channel; + int earlyclip; + double time; + int (*progress) (void *, double, int, double); + void *progress_parameter; + randctx rc; + int nthreads; + int sub_batch_size; +} flam3_frame; +int flam3_render (flam3_frame * f, void *out, int field, int nchan, + int transp, stat_struct * stats); + +double flam3_render_memory_required (flam3_frame * f); +int flam3_make_strip (flam3_genome * cp, int nstrips, int stripnum); +void rotate_by (double *p, double *center, double by); + + +double flam3_random01 (); +double flam3_random11 (); +int flam3_random_bit (); + + +double flam3_random_isaac_01 (randctx *); +double flam3_random_isaac_11 (randctx *); +int flam3_random_isaac_bit (randctx *); + +void flam3_init_frame (flam3_frame * f); + + +void *flam3_malloc (size_t size); +void flam3_free (void *ptr); + +void flam3_srandom (); + +flam3_genome *sheep_loop (flam3_genome * cp, double blend); +flam3_genome *sheep_edge (flam3_genome * cp, double blend, int seqflag, + double stagger); + + + + + +extern char *dirname (char *__path) + __attribute__ ((__nothrow__, __leaf__)); + + + + + + + +extern char *__xpg_basename (char *__path) + __attribute__ ((__nothrow__, __leaf__)); + + + + + + +void docstring (); + + +typedef struct +{ + unsigned short *xform_distrib; + flam3_frame *spec; + double bounds[4]; + double rot[2][2]; + double size[2]; + int width, height; + double ws0, wb0s0, hs1, hb1s1; + flam3_palette_entry *dmap; + double color_scalar; + void *buckets; + double badvals; + double batch_size; + int temporal_sample_num, ntemporal_samples; + int batch_num, nbatches, aborted; + time_t *progress_timer; + time_t *progress_timer_history; + double *progress_history; + int *progress_history_mark; + + + pthread_mutex_t bucket_mutex; + + +} flam3_iter_constants; + +typedef struct +{ + + double tx, ty; + + double precalc_atan, precalc_sina; + double precalc_cosa, precalc_sqrt; + double precalc_sumsq, precalc_atanyx; + + flam3_xform *xform; + + + + double p0, p1; + + + randctx *rc; + +} flam3_iter_helper; + +typedef struct +{ + double *iter_storage; + randctx rc; + flam3_genome cp; + int first_thread; + int timer_initialize; + flam3_iter_constants *fic; +} flam3_thread_helper; + +double flam3_sinc (double x); + + +double flam3_gaussian_filter (double x); +double flam3_hermite_filter (double t); +double flam3_box_filter (double t); +double flam3_triangle_filter (double t); +double flam3_bell_filter (double t); +double flam3_b_spline_filter (double t); +double flam3_lanczos3_filter (double t); +double flam3_lanczos2_filter (double t); +double flam3_mitchell_filter (double t); +double flam3_blackman_filter (double x); +double flam3_catrom_filter (double x); +double flam3_hamming_filter (double x); +double flam3_hanning_filter (double x); +double flam3_quadratic_filter (double x); + +double flam3_spatial_filter (int knum, double x); +typedef struct +{ + int max_filtered_counts; + int max_filter_index; + int kernel_size; + double *filter_widths; + double *filter_coefs; +} flam3_de_helper; + +extern double flam3_spatial_support[14]; + +double flam3_spatial_filter (int knum, double x); +int flam3_create_spatial_filter (flam3_frame * spec, int field, + double **filter); +flam3_de_helper flam3_create_de_filters (double max_rad, double min_rad, + double curve, int ss); +double flam3_create_temporal_filter (int numsteps, int filter_type, + double filter_exp, + double filter_width, + double **temporal_filter, + double **temporal_deltas); + +double flam3_spatial_support[14] = { + 1.5, + 1.0, + 0.5, + 1.0, + 1.5, + 2.0, + 2.0, + 1.0, + 2.0, + 1.0, + 1.0, + 3.0, + 2.0, + 1.5 +}; + +double +flam3_hermite_filter (double t) +{ + + if (t < 0.0) + t = -t; + if (t < 1.0) + return ((2.0 * t - 3.0) * t * t + 1.0); + return (0.0); +} + +double +flam3_box_filter (double t) +{ + if ((t > -0.5) && (t <= 0.5)) + return (1.0); + return (0.0); +} + +double +flam3_triangle_filter (double t) +{ + if (t < 0.0) + t = -t; + if (t < 1.0) + return (1.0 - t); + return (0.0); +} + +double +flam3_bell_filter (double t) +{ + + if (t < 0) + t = -t; + if (t < .5) + return (.75 - (t * t)); + if (t < 1.5) + { + t = (t - 1.5); + return (.5 * (t * t)); + } + return (0.0); +} + +double +flam3_b_spline_filter (double t) +{ + + + double tt; + + if (t < 0) + t = -t; + if (t < 1) + { + tt = t * t; + return ((.5 * tt * t) - tt + (2.0 / 3.0)); + } + else if (t < 2) + { + t = 2 - t; + return ((1.0 / 6.0) * (t * t * t)); + } + return (0.0); +} + +double +flam3_sinc (double x) +{ + x *= 3.14159265358979323846; + if (x != 0) + return (sin (x) / x); + return (1.0); +} + +double +flam3_blackman_filter (double x) +{ + return (0.42 + 0.5 * cos (3.14159265358979323846 * x) + 0.08 * cos (2 * 3.14159265358979323846 * x)); +} + +double +flam3_catrom_filter (double x) +{ + if (x < -2.0) + return (0.0); + if (x < -1.0) + return (0.5 * (4.0 + x * (8.0 + x * (5.0 + x)))); + if (x < 0.0) + return (0.5 * (2.0 + x * x * (-5.0 - 3.0 * x))); + if (x < 1.0) + return (0.5 * (2.0 + x * x * (-5.0 + 3.0 * x))); + if (x < 2.0) + return (0.5 * (4.0 + x * (-8.0 + x * (5.0 - x)))); + return (0.0); +} + +double +flam3_mitchell_filter (double t) +{ + double tt; + + tt = t * t; + if (t < 0) + t = -t; + if (t < 1.0) + { + t = (((12.0 - 9.0 * (1.0 / 3.0) - 6.0 * (1.0 / 3.0)) * (t * tt)) + + ((-18.0 + 12.0 * (1.0 / 3.0) + 6.0 * (1.0 / 3.0)) * tt) + + (6.0 - 2 * (1.0 / 3.0))); + return (t / 6.0); + } + else if (t < 2.0) + { + t = (((-1.0 * (1.0 / 3.0) - 6.0 * (1.0 / 3.0)) * (t * tt)) + + ((6.0 * (1.0 / 3.0) + 30.0 * (1.0 / 3.0)) * tt) + + ((-12.0 * (1.0 / 3.0) - 48.0 * (1.0 / 3.0)) * t) + + (8.0 * (1.0 / 3.0) + 24 * (1.0 / 3.0))); + return (t / 6.0); + } + return (0.0); +} + +double +flam3_hanning_filter (double x) +{ + return (0.5 + 0.5 * cos (3.14159265358979323846 * x)); +} + +double +flam3_hamming_filter (double x) +{ + return (0.54 + 0.46 * cos (3.14159265358979323846 * x)); +} + +double +flam3_lanczos3_filter (double t) +{ + if (t < 0) + t = -t; + if (t < 3.0) + return (flam3_sinc (t) * flam3_sinc (t / 3.0)); + return (0.0); +} + +double +flam3_lanczos2_filter (double t) +{ + if (t < 0) + t = -t; + if (t < 2.0) + return (flam3_sinc (t) * flam3_sinc (t / 2.0)); + return (0.0); +} + +double +flam3_gaussian_filter (double x) +{ + return (exp ((-2.0 * x * x)) * sqrt (2.0 / 3.14159265358979323846)); +} + +double +flam3_quadratic_filter (double x) +{ + if (x < -1.5) + return (0.0); + if (x < -0.5) + return (0.5 * (x + 1.5) * (x + 1.5)); + if (x < 0.5) + return (0.75 - x * x); + if (x < 1.5) + return (0.5 * (x - 1.5) * (x - 1.5)); + return (0.0); +} + +double +flam3_spatial_filter (int knum, double x) +{ + + if (knum == 0) + return flam3_gaussian_filter (x); + else if (knum == 1) + return flam3_hermite_filter (x); + else if (knum == 2) + return flam3_box_filter (x); + else if (knum == 3) + return flam3_triangle_filter (x); + else if (knum == 4) + return flam3_bell_filter (x); + else if (knum == 5) + return flam3_b_spline_filter (x); + else if (knum == 6) + return flam3_mitchell_filter (x); + else if (knum == 7) + return flam3_sinc (x) * flam3_blackman_filter (x); + else if (knum == 8) + return flam3_catrom_filter (x); + else if (knum == 9) + return flam3_sinc (x) * flam3_hanning_filter (x); + else if (knum == 10) + return flam3_sinc (x) * flam3_hamming_filter (x); + else if (knum == 11) + return flam3_lanczos3_filter (x) * flam3_sinc (x / 3.0); + else if (knum == 12) + return flam3_lanczos2_filter (x) * flam3_sinc (x / 2.0); + else if (knum == 13) + return flam3_quadratic_filter (x); +} + +int +normalize_vector (double *v, int n) +{ + double t = 0.0; + int i; + for (i = 0; i < n; i++) + t += v[i]; + if (0.0 == t) + return 1; + t = 1.0 / t; + for (i = 0; i < n; i++) + v[i] *= t; + return 0; +} + + +int +flam3_create_spatial_filter (flam3_frame * spec, int field, double **filter) +{ + + int sf_kernel = spec->genomes[0].spatial_filter_select; + int supersample = spec->genomes[0].spatial_oversample; + double sf_radius = spec->genomes[0].spatial_filter_radius; + double aspect_ratio = spec->pixel_aspect_ratio; + double sf_supp = flam3_spatial_support[sf_kernel]; + + double fw = 2.0 * sf_supp * supersample * sf_radius / aspect_ratio; + double adjust, ii, jj; + + int fwidth = ((int) fw) + 1; + int i, j; + + + + if ((fwidth ^ supersample) & 1) + fwidth++; + + + if (fw > 0.0) + adjust = sf_supp * fwidth / fw; + else + adjust = 1.0; + + + (*filter) = (double *) calloc (fwidth * fwidth, sizeof (double)); + + + for (i = 0; i < fwidth; i++) + for (j = 0; j < fwidth; j++) + { + + + ii = ((2.0 * i + 1.0) / (double) fwidth - 1.0) * adjust; + jj = ((2.0 * j + 1.0) / (double) fwidth - 1.0) * adjust; + + + if (field) + jj *= 2.0; + + + jj /= aspect_ratio; + + (*filter)[i + j * fwidth] = + flam3_spatial_filter (sf_kernel, + ii) * flam3_spatial_filter (sf_kernel, jj); + } + + + if (normalize_vector ((*filter), fwidth * fwidth)) + { + fprintf (stderr, + "Spatial filter value is too small: %g. Terminating.\n", + sf_radius); + return (-1); + } + + return (fwidth); +} + +flam3_de_helper +flam3_create_de_filters (double max_rad, double min_rad, double curve, int ss) +{ + + flam3_de_helper de; + double comp_max_radius, comp_min_radius; + double num_de_filters_d; + int num_de_filters, de_max_ind; + int de_row_size, de_half_size; + int filtloop; + int keep_thresh = 100; + + de.kernel_size = -1; + + if (curve <= 0.0) + { + fprintf (stderr, "estimator curve must be > 0\n"); + return (de); + } + + if (max_rad < min_rad) + { + fprintf (stderr, "estimator must be larger than estimator_minimum.\n"); + fprintf (stderr, "(%f > %f) ? \n", max_rad, min_rad); + return (de); + } + + + + comp_max_radius = max_rad * ss + 1; + comp_min_radius = min_rad * ss + 1; + + + + + + num_de_filters_d = pow (comp_max_radius / comp_min_radius, 1.0 / curve); + if (num_de_filters_d > 1e7) + { + fprintf (stderr, + "too many filters required in this configuration (%g)\n", + num_de_filters_d); + return (de); + } + num_de_filters = (int) ceil (num_de_filters_d); + + + if (num_de_filters > keep_thresh) + { + de_max_ind = (int) ceil (100 + pow (num_de_filters - 100, curve)) + 1; + de.max_filtered_counts = + (int) pow ((double) (de_max_ind - 100), 1.0 / curve) + 100; + } + else + { + de_max_ind = num_de_filters; + de.max_filtered_counts = de_max_ind; + } + + + + de_row_size = (int) (2 * ceil (comp_max_radius) - 1); + de_half_size = (de_row_size - 1) / 2; + de.kernel_size = (de_half_size + 1) * (2 + de_half_size) / 2; + + de.filter_coefs = + (double *) calloc (de_max_ind * de.kernel_size, sizeof (double)); + de.filter_widths = (double *) calloc (de_max_ind, sizeof (double)); + + + de.max_filter_index = 0; + for (filtloop = 0; filtloop < de_max_ind; filtloop++) + { + + double de_filt_sum = 0.0, de_filt_d; + double de_filt_h; + int dej, dek; + double adjloop; + int filter_coef_idx; + + + if (filtloop < keep_thresh) + de_filt_h = (comp_max_radius / pow (filtloop + 1, curve)); + else + { + adjloop = pow (filtloop - keep_thresh, (1.0 / curve)) + keep_thresh; + de_filt_h = (comp_max_radius / pow (adjloop + 1, curve)); + } + + + if (de_filt_h <= comp_min_radius) + { + de_filt_h = comp_min_radius; + de.max_filter_index = filtloop; + } + + de.filter_widths[filtloop] = de_filt_h; + + + for (dej = -de_half_size; dej <= de_half_size; dej++) + { + for (dek = -de_half_size; dek <= de_half_size; dek++) + { + + de_filt_d = sqrt ((double) (dej * dej + dek * dek)) / de_filt_h; + + + if (de_filt_d <= 1.0) + { + de_filt_sum += flam3_spatial_filter (0, flam3_spatial_support [0] * de_filt_d); + } + } + } + + filter_coef_idx = filtloop * de.kernel_size; + + + for (dej = 0; dej <= de_half_size; dej++) + { + for (dek = 0; dek <= dej; dek++) + { + de_filt_d = sqrt ((double) (dej * dej + dek * dek)) / de_filt_h; + + + if (de_filt_d > 1.0) + de.filter_coefs[filter_coef_idx] = 0.0; + else + { + de.filter_coefs[filter_coef_idx] = flam3_spatial_filter (0, flam3_spatial_support[0] * de_filt_d) / de_filt_sum; + } + + filter_coef_idx++; + } + } + + if (de.max_filter_index > 0) + break; + } + + if (de.max_filter_index == 0) + de.max_filter_index = de_max_ind - 1; + + + return (de); +} + +double +flam3_create_temporal_filter (int numsteps, int filter_type, + double filter_exp, double filter_width, + double **temporal_filter, + double **temporal_deltas) +{ + + double maxfilt = 0.0; + double sumfilt = 0.0; + double slpx, halfsteps; + double *deltas, *filter; + + int i; + + + deltas = (double *) malloc (numsteps * sizeof (double)); + filter = (double *) malloc (numsteps * sizeof (double)); + + + if (numsteps == 1) + { + deltas[0] = 0; + filter[0] = 1.0; + *temporal_deltas = deltas; + *temporal_filter = filter; + return (1.0); + } + + + for (i = 0; i < numsteps; i++) + deltas[i] = ((double) i / (double) (numsteps - 1) - 0.5) * filter_width; + + + if (2 == filter_type) + { + + for (i = 0; i < numsteps; i++) + { + + if (filter_exp >= 0) + slpx = ((double) i + 1.0) / numsteps; + else + slpx = (double) (numsteps - i) / numsteps; + + + filter[i] = pow (slpx, fabs (filter_exp)); + + + if (filter[i] > maxfilt) + maxfilt = filter[i]; + } + + } + else if (1 == filter_type) + { + + halfsteps = numsteps / 2.0; + for (i = 0; i < numsteps; i++) + { + + + filter[i] = flam3_spatial_filter (0, flam3_spatial_support[0] * fabs (i - halfsteps) / halfsteps); + if (filter[i] > maxfilt) + maxfilt = filter[i]; + } + + } + else + { + + for (i = 0; i < numsteps; i++) + filter[i] = 1.0; + + maxfilt = 1.0; + + } + + + + for (i = 0; i < numsteps; i++) + { + filter[i] /= maxfilt; + sumfilt += filter[i]; + } + + sumfilt /= numsteps; + + *temporal_deltas = deltas; + *temporal_filter = filter; + + return (sumfilt); +} diff --git a/gcc/testsuite/g++.dg/pr65242.C b/gcc/testsuite/g++.dg/pr65242.C new file mode 100644 index 0000000000..c123056586 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr65242.C @@ -0,0 +1,97 @@ +/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */ +/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */ +/* { dg-require-effective-target powerpc_p8vector_ok } */ +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */ +/* { dg-options "-mcpu=power8 -O3" } */ + +class A { +public: + int m_fn1(); +}; +class B { +public: + enum IOMode { reading }; +}; +class tn_file_buf_stream : B { +public: + tn_file_buf_stream(IOMode); + ~tn_file_buf_stream(); +}; +class C { +public: + int &operator[](int); +}; +class D { +public: + bool m_fn2(); +}; +class F { +public: + int m_fn3(D &); +}; +class G { +public: + D bdt; +}; +class ObjectType { +public: + int id; + D weather; + struct H { + F terrainaccess; + }; + H m_fn4(); + struct { + A images; + } weatherPicture[]; + ObjectType *m_fn5(); + int m_fn6(); +} a; +#pragma pack(1) +class I {}; +class J { + J(I *); + I translationTableTMISSPart; + void m_fn8(); + tn_file_buf_stream *MissFile; + void m_fn9(); + virtual G *m_fn7(int, int); +}; +int b, c, d, g; +int e[5]; +short f; +void J::m_fn9() { + int h; + C k; + for (; b;) { + int l = c, n = c & 1; + for (int m; d;) { + int o = 0; + for (int p = 0; p < 2 && !o; p++) + if (g) + for (int i; i < a.m_fn6(); i++) { + ObjectType *q = a.m_fn5(); + for (int r = 0; r < 6; r++) + if (q->weather.m_fn2()) + for (int j; j < q->weatherPicture[r].images.m_fn1(); j++) + if (e[m]) { + G *s = m_fn7(l, n); + if (q->m_fn4().terrainaccess.m_fn3(s->bdt)) + g = o = 1; + } + } + k[h++] = f; + } + } +} + +void J::m_fn8() try { + tn_file_buf_stream t(B::reading); + MissFile = &t; + m_fn9(); + J u(0); + u.m_fn8(); +} + +catch (int) { +} diff --git a/gcc/testsuite/g++.dg/pr65295.C b/gcc/testsuite/g++.dg/pr65295.C new file mode 100644 index 0000000000..c189ee1369 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr65295.C @@ -0,0 +1,20 @@ +// { dg-do compile } +// { dg-options "-std=c++1y" } + +struct arr { + constexpr arr() : elem() { } + char elem[17]; +}; + +constexpr +arr f() +{ + arr result; + return result; +} + +constexpr arr a { f() }; + +int main() +{ +} diff --git a/gcc/testsuite/g++.dg/rtti/dyncast6.C b/gcc/testsuite/g++.dg/rtti/dyncast6.C index a6329e9441..bfbf5117dd 100644 --- a/gcc/testsuite/g++.dg/rtti/dyncast6.C +++ b/gcc/testsuite/g++.dg/rtti/dyncast6.C @@ -38,19 +38,19 @@ void r() B b; A& a1 = dynamic_cast<A&>(b); - A& a2 = dynamic_cast<const A&>(b); // { dg-error "invalid" } - A& a3 = dynamic_cast<volatile A&>(b); // { dg-error "invalid" } - A& a4 = dynamic_cast<const volatile A&>(b); // { dg-error "invalid" } + A& a2 = dynamic_cast<const A&>(b); // { dg-error "" } + A& a3 = dynamic_cast<volatile A&>(b); // { dg-error "" } + A& a4 = dynamic_cast<const volatile A&>(b); // { dg-error "" } const A& ca1 = dynamic_cast<A&>(b); const A& ca2 = dynamic_cast<const A&>(b); - const A& ca3 = dynamic_cast<volatile A&>(b); // { dg-error "invalid" } - const A& ca4 = dynamic_cast<const volatile A&>(b); // { dg-error "invalid" } + const A& ca3 = dynamic_cast<volatile A&>(b); // { dg-error "" } + const A& ca4 = dynamic_cast<const volatile A&>(b); // { dg-error "" } volatile A& va1 = dynamic_cast<A&>(b); - volatile A& va2 = dynamic_cast<const A&>(b); // { dg-error "invalid" } + volatile A& va2 = dynamic_cast<const A&>(b); // { dg-error "" } volatile A& va3 = dynamic_cast<volatile A&>(b); - volatile A& va4 = dynamic_cast<const volatile A&>(b);// { dg-error "invalid" } + volatile A& va4 = dynamic_cast<const volatile A&>(b);// { dg-error "" } const volatile A& cva1 = dynamic_cast<A&>(b); const volatile A& cva2 = dynamic_cast<const A&>(b); diff --git a/gcc/testsuite/g++.dg/rtti/dyncast7.C b/gcc/testsuite/g++.dg/rtti/dyncast7.C new file mode 100644 index 0000000000..deb4397663 --- /dev/null +++ b/gcc/testsuite/g++.dg/rtti/dyncast7.C @@ -0,0 +1,28 @@ +// I think this dynamic_cast has undefined behavior when destroying E::o +// because we're the F period of destruction has started and ap doesn't +// point to the object currently being destroyed--but the reasonable +// options are success or failure, not SEGV. + +// { dg-do run } + +extern "C" void abort(); + +struct A { virtual ~A(); }; +struct B { virtual ~B() { } }; +struct C : B, A { }; +struct E : virtual B { A o; }; +struct F : virtual C, virtual E { }; + +A* ap; +C* cp; + +A::~A() { + C* cp2 = dynamic_cast<C*>(ap); + if (cp2 != cp && cp2 != 0) + abort(); +} + +int main() { + F f; + ap = cp = &f; +} diff --git a/gcc/testsuite/g++.dg/simulate-thread/bitfields-2.C b/gcc/testsuite/g++.dg/simulate-thread/bitfields-2.C index 077514a3ff..be5d1eae5c 100644 --- a/gcc/testsuite/g++.dg/simulate-thread/bitfields-2.C +++ b/gcc/testsuite/g++.dg/simulate-thread/bitfields-2.C @@ -1,5 +1,5 @@ /* { dg-do link } */ -/* { dg-options "--param allow-load-data-races=0 --param allow-store-data-races=0" } */ +/* { dg-options "--param allow-store-data-races=0" } */ /* { dg-final { simulate-thread } } */ /* Test that setting <var.a> does not touch either <var.b> or <var.c>. diff --git a/gcc/testsuite/g++.dg/simulate-thread/bitfields.C b/gcc/testsuite/g++.dg/simulate-thread/bitfields.C index 3acf21f876..b829587276 100644 --- a/gcc/testsuite/g++.dg/simulate-thread/bitfields.C +++ b/gcc/testsuite/g++.dg/simulate-thread/bitfields.C @@ -1,5 +1,5 @@ /* { dg-do link } */ -/* { dg-options "--param allow-load-data-races=0 --param allow-store-data-races=0" } */ +/* { dg-options "--param allow-store-data-races=0" } */ /* { dg-final { simulate-thread } } */ /* Test that setting <var.a> does not touch either <var.b> or <var.c>. diff --git a/gcc/testsuite/g++.dg/simulate-thread/simulate-thread.exp b/gcc/testsuite/g++.dg/simulate-thread/simulate-thread.exp index b07fbb08c6..61aab9eff1 100644 --- a/gcc/testsuite/g++.dg/simulate-thread/simulate-thread.exp +++ b/gcc/testsuite/g++.dg/simulate-thread/simulate-thread.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2014 Free Software Foundation, Inc. +# Copyright (C) 2011-2015 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -31,8 +31,8 @@ set-torture-options [list \ { -Os -g } ] if [gdb-exists] { - gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] "" - gcc-dg-runtest [lsort [glob $srcdir/c-c++-common/simulate-thread/*.c]] "" + gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] "" "" + gcc-dg-runtest [lsort [glob $srcdir/c-c++-common/simulate-thread/*.c]] "" "" } torture-finish diff --git a/gcc/testsuite/g++.dg/special/ecos.exp b/gcc/testsuite/g++.dg/special/ecos.exp index 6b0f5d5aee..a8c0157418 100644 --- a/gcc/testsuite/g++.dg/special/ecos.exp +++ b/gcc/testsuite/g++.dg/special/ecos.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1999-2014 Free Software Foundation, Inc. +# Copyright (C) 1999-2015 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/gcc/testsuite/g++.dg/stackprotectexplicit2.C b/gcc/testsuite/g++.dg/stackprotectexplicit2.C new file mode 100644 index 0000000000..9cf9ab909c --- /dev/null +++ b/gcc/testsuite/g++.dg/stackprotectexplicit2.C @@ -0,0 +1,27 @@ +/* Test that stack protection is done on chosen functions. */ + +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -fstack-protector-explicit" } */ + +int A() +{ + int A[23]; + char b[22]; +} + +int __attribute__((stack_protect)) B() +{ + int a; + int b; + return a+b; +} + +int __attribute__((stack_protect)) c() +{ + int a; + char b[34]; + return 0; +} + + +/* { dg-final { scan-assembler-times "stack_chk_fail" 2 } } */
\ No newline at end of file diff --git a/gcc/testsuite/g++.dg/system-binary-constants-1.C b/gcc/testsuite/g++.dg/system-binary-constants-1.C index fbf8bb2c96..614f9265d4 100644 --- a/gcc/testsuite/g++.dg/system-binary-constants-1.C +++ b/gcc/testsuite/g++.dg/system-binary-constants-1.C @@ -14,5 +14,5 @@ foo (void) warning. */ return 23; #endif - return 0b1101; /* { dg-warning "binary constants are a C..1y feature or GCC extension" } */ + return 0b1101; /* { dg-warning "binary constants are a C..14 feature or GCC extension" } */ } diff --git a/gcc/testsuite/g++.dg/tc1/dr152.C b/gcc/testsuite/g++.dg/tc1/dr152.C index bf742ee9b8..e787f8bcbf 100644 --- a/gcc/testsuite/g++.dg/tc1/dr152.C +++ b/gcc/testsuite/g++.dg/tc1/dr152.C @@ -7,12 +7,11 @@ namespace N1 { X(); // { dg-message "note" } explicit X(const X&); }; - void f(X); // { dg-error "initializing" } + void f(X); // { dg-message "initializing" } int foo() { X x; f(x); // { dg-error "matching" "matching" } - // { dg-message "candidate" "candidate note" { target *-*-* } 14 } } } @@ -24,14 +23,13 @@ namespace N2 { }; template <class T> - void f(T ) {} // { dg-error "initializing" } + void f(T) {} // { dg-message "initializing" } template <class T> int foo() { X<T> x; N2::f(x); // { dg-error "matching" "matching" } - // { dg-message "candidate" "candidate note" { target *-*-* } 33 } } template int foo<float>(); // { dg-message "required from here" } diff --git a/gcc/testsuite/g++.dg/tc1/dr217-2.C b/gcc/testsuite/g++.dg/tc1/dr217-2.C new file mode 100644 index 0000000000..75c40f8b20 --- /dev/null +++ b/gcc/testsuite/g++.dg/tc1/dr217-2.C @@ -0,0 +1,13 @@ +// { dg-do compile } +// DR217: Default arguments for non-template member functions of class +// templates + +template <class T> +struct S +{ + static void foo (int); +}; + +template <class T> +void S<T>::foo (int = 0) // { dg-error "" "default arguments for parameters of member functions of class templates can be specified in the initial declaration only" } +{ } diff --git a/gcc/testsuite/g++.dg/template/anonunion1.C b/gcc/testsuite/g++.dg/template/anonunion1.C index 89a8c5bec9..ea17e5d5f9 100644 --- a/gcc/testsuite/g++.dg/template/anonunion1.C +++ b/gcc/testsuite/g++.dg/template/anonunion1.C @@ -1,6 +1,6 @@ // PR c++/47303 // { dg-do compile } -// { dg-options "-fabi-version=1" } + struct Z { diff --git a/gcc/testsuite/g++.dg/template/array1-1.C b/gcc/testsuite/g++.dg/template/array1-1.C deleted file mode 100644 index 97fe7cde25..0000000000 --- a/gcc/testsuite/g++.dg/template/array1-1.C +++ /dev/null @@ -1,32 +0,0 @@ -// { dg-do compile } -// { dg-options "-fabi-version=1" } - -// Contributed by Nathan Sidwell 22 Dec 2003 <nathan@codesourcery.com> -// Origin: Roger Sayle <roger@eyesopen.com> - -// PR c++/12774 Array domains compared unequal - -void Foo(double r[3][3]) -{ -} - -void Baz() -{ - double m[3][3]; - Foo(m); -} - -template <class T> -void Bar() -{ - double m[3][3]; - Foo(m); -} - -int main() -{ - Baz(); - Bar<int>(); - return 0; -} - diff --git a/gcc/testsuite/g++.dg/template/array2-1.C b/gcc/testsuite/g++.dg/template/array2-1.C deleted file mode 100644 index 2980a1fd18..0000000000 --- a/gcc/testsuite/g++.dg/template/array2-1.C +++ /dev/null @@ -1,14 +0,0 @@ -// { dg-do compile } -// { dg-options "-fabi-version=1" } - -// Copyright (C) 2003 Free Software Foundation, Inc. -// Contributed by Nathan Sidwell 29 Dec 2003 <nathan@codesourcery.com> - -// PR c++/13494. ICE - -template<typename T> -int foo(int d[][4]) -{ - return d[0][0]; -} - diff --git a/gcc/testsuite/g++.dg/template/array28.C b/gcc/testsuite/g++.dg/template/array28.C new file mode 100644 index 0000000000..18b629d447 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/array28.C @@ -0,0 +1,7 @@ +typedef int (A)[]; + +template<class T> void f(T (*)[1]); // { dg-error "array" } + +int main() { + f<int[]>(0); // { dg-error "no match" } +} diff --git a/gcc/testsuite/g++.dg/template/array29.C b/gcc/testsuite/g++.dg/template/array29.C new file mode 100644 index 0000000000..e43cb9d965 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/array29.C @@ -0,0 +1,56 @@ +// PR c++/63485 + +template <typename C> struct A +{ + typedef C type; +}; +template <class> class B +{ +}; +template <class Range> void as_literal (Range &); +template <typename> struct C +{ + typedef wchar_t char_type; + const char_type on_full_year_placeholder[3]; + void + on_extended_iso_date () + { + B<A<wchar_t const[3]>::type> a; + as_literal (on_full_year_placeholder); + } +}; +template <typename> struct date_time_format_parser_callback : C<wchar_t> +{ +}; +template <typename BaseT> struct D +{ + typedef typename BaseT::char_type char_type; + char_type + parse (const char_type *, const char_type *, + typename BaseT::callback_type p3) + { + p3.on_extended_iso_date (); + } +}; +struct F +{ + typedef date_time_format_parser_callback<wchar_t> callback_type; + typedef wchar_t char_type; +}; +template <typename CharT, typename ParserT, typename CallbackT> +void +parse_format (CharT *p1, ParserT p2, CallbackT p3) +{ + CharT p = p2.parse (&p, p1, p3); +} +template <typename CharT> +void +parse_date_time_format (const CharT *, const CharT *p2, + date_time_format_parser_callback<CharT> &p3) +{ + D<F> b; + parse_format (p2, b, p3); +} +template void +parse_date_time_format (const wchar_t *, const wchar_t *, + date_time_format_parser_callback<wchar_t> &); diff --git a/gcc/testsuite/g++.dg/template/arrow1.C b/gcc/testsuite/g++.dg/template/arrow1.C index c96141063a..690df4c5fc 100644 --- a/gcc/testsuite/g++.dg/template/arrow1.C +++ b/gcc/testsuite/g++.dg/template/arrow1.C @@ -9,9 +9,7 @@ struct a { }; int main() { - a<0>()->x; // { dg-error "instantiation depth exceeds maximum" } + a<0>()->x; // { dg-error "depth" } } -// { dg-prune-output "incomplete type" } -// { dg-prune-output "declaration of" } -// { dg-prune-output "used but never defined" } +// { dg-prune-output "compilation terminated" } diff --git a/gcc/testsuite/g++.dg/template/conv8.C b/gcc/testsuite/g++.dg/template/conv8.C deleted file mode 100644 index 01d415b3ed..0000000000 --- a/gcc/testsuite/g++.dg/template/conv8.C +++ /dev/null @@ -1,12 +0,0 @@ -// { dg-options "-fabi-version=1 -Wno-abi" } - -template <typename T> struct S { - struct I{}; - operator I* (); -}; - -template <typename T> struct S2 : S<T> { - operator typename S<T>::I* (); -}; - -template struct S2<int>; diff --git a/gcc/testsuite/g++.dg/template/copy1.C b/gcc/testsuite/g++.dg/template/copy1.C index c6b3ff8066..bf5a37ce0a 100644 --- a/gcc/testsuite/g++.dg/template/copy1.C +++ b/gcc/testsuite/g++.dg/template/copy1.C @@ -6,10 +6,9 @@ struct A { - A(A&); // { dg-message "note" } - template <class T> A(T); // { dg-message "note" } + A(A&); // { dg-message "A::A" } + template <class T> A(T); // { dg-message "A::A" } }; -A a = 0; // { dg-error "no matching function" } -// { dg-message "candidate" "candidate note" { target *-*-* } 13 } +A a = 0; // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/template/crash106.C b/gcc/testsuite/g++.dg/template/crash106.C index ebd47bcffd..5bef101e59 100644 --- a/gcc/testsuite/g++.dg/template/crash106.C +++ b/gcc/testsuite/g++.dg/template/crash106.C @@ -9,6 +9,6 @@ struct A template<T N = 0, void (A::*)() = &A::foo<N> > struct B {}; // { dg-error "type|declared" } -B<> b; // { dg-error "type|declaration" } +B<> b; // { dg-message "non-type" } // { dg-prune-output "could not convert" } diff --git a/gcc/testsuite/g++.dg/template/crash107.C b/gcc/testsuite/g++.dg/template/crash107.C index bb405ac7ee..d92ee3394e 100644 --- a/gcc/testsuite/g++.dg/template/crash107.C +++ b/gcc/testsuite/g++.dg/template/crash107.C @@ -14,7 +14,5 @@ template<typename FP_> struct Vec { // { dg-message "note" } } }; Vec<double> v(3,4,12); // { dg-error "no matching" } -// { dg-message "note" "note" { target *-*-* } 16 } Vec<double> V(12,4,3); // { dg-error "no matching" } -// { dg-message "note" "note" { target *-*-* } 18 } Vec<double> c = v^V; // { dg-message "required" } diff --git a/gcc/testsuite/g++.dg/template/crash120.C b/gcc/testsuite/g++.dg/template/crash120.C new file mode 100644 index 0000000000..9d15c2e660 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/crash120.C @@ -0,0 +1,18 @@ +// PR c++/60493 + +template <class T, class U> +struct foo +{ +}; +template <class T> +struct baz +{ + class bar; +}; + +template <class T, class D> +struct baz<T>::bar : foo<int, D> // { dg-error "parameters|required" } +{ +}; + +baz<int>::bar it; // { dg-error "incomplete" } diff --git a/gcc/testsuite/g++.dg/template/crash35.C b/gcc/testsuite/g++.dg/template/crash35.C index 348d91d0ca..c457798dd0 100644 --- a/gcc/testsuite/g++.dg/template/crash35.C +++ b/gcc/testsuite/g++.dg/template/crash35.C @@ -1,7 +1,7 @@ // PR c++/20463 // { dg-do compile } -template <typename T> struct C; // { dg-error "declaration" } +template <typename T> struct C; // { dg-message "declaration" } template <typename T> void C<T>::f() // { dg-error "invalid|template" } { diff --git a/gcc/testsuite/g++.dg/template/crash55.C b/gcc/testsuite/g++.dg/template/crash55.C index 7cf9f1eae8..9b80fd125d 100644 --- a/gcc/testsuite/g++.dg/template/crash55.C +++ b/gcc/testsuite/g++.dg/template/crash55.C @@ -3,4 +3,4 @@ template<typename class T, T = T()> // { dg-error "nested-name-specifier|two or more|valid type" } struct A {}; -template<int> void foo(A<int>); // { dg-error "mismatch|constant|template argument" } +template<int> void foo(A<int>); // { dg-error "cast|argument" "" { target c++98_only } } diff --git a/gcc/testsuite/g++.dg/template/crash57.C b/gcc/testsuite/g++.dg/template/crash57.C index cf1c3c2961..ad05e6aceb 100644 --- a/gcc/testsuite/g++.dg/template/crash57.C +++ b/gcc/testsuite/g++.dg/template/crash57.C @@ -7,4 +7,4 @@ template<typename> struct B template<int(> struct C; // { dg-error "token" } }; -A<char> a; // { dg-error "type/value mismatch|constant|declaration" } +A<char> a; diff --git a/gcc/testsuite/g++.dg/template/crash59.C b/gcc/testsuite/g++.dg/template/crash59.C index 61d2188fc9..ebc0e281c5 100644 --- a/gcc/testsuite/g++.dg/template/crash59.C +++ b/gcc/testsuite/g++.dg/template/crash59.C @@ -1,6 +1,6 @@ //PR c++/27329 -template<int> struct A // { dg-error "forward declaration" } +template<int> struct A // { dg-message "forward declaration" } ! // { dg-error "expected unqualified-id" } ; diff --git a/gcc/testsuite/g++.dg/template/crash71.C b/gcc/testsuite/g++.dg/template/crash71.C index 86aa1521d4..3ac862ed81 100644 --- a/gcc/testsuite/g++.dg/template/crash71.C +++ b/gcc/testsuite/g++.dg/template/crash71.C @@ -1,3 +1,3 @@ // PR c++/30659 -extern "C" template A<char> foo(); // { dg-error "forbids|static data|expected" } +extern "C" template A<char> foo(); // { dg-error "forbids|static data|expected|template" } diff --git a/gcc/testsuite/g++.dg/template/crash77.C b/gcc/testsuite/g++.dg/template/crash77.C index b4d6e8f4a6..21747792c2 100644 --- a/gcc/testsuite/g++.dg/template/crash77.C +++ b/gcc/testsuite/g++.dg/template/crash77.C @@ -1,5 +1,5 @@ // PR c++/34603 -template<typename> struct A; // { dg-error "declaration" } +template<typename> struct A; // { dg-message "declaration" } template<typename T> A<T>::A( struct A; // { dg-error "definition|expected|incomplete" } diff --git a/gcc/testsuite/g++.dg/template/crash89.C b/gcc/testsuite/g++.dg/template/crash89.C index f4cdaf9d9b..d5c3a92832 100644 --- a/gcc/testsuite/g++.dg/template/crash89.C +++ b/gcc/testsuite/g++.dg/template/crash89.C @@ -5,6 +5,4 @@ template<typename T, int = T()[0]> struct A // { dg-error "subscripted" } typedef A<T> B; }; -A<int> a; // { dg-error "declaration" } - -// { dg-prune-output "template argument 2 is invalid" } +A<int> a; // { dg-error "template argument 2 is invalid" } diff --git a/gcc/testsuite/g++.dg/template/defarg18.C b/gcc/testsuite/g++.dg/template/defarg18.C new file mode 100644 index 0000000000..ac08966061 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/defarg18.C @@ -0,0 +1,15 @@ +// PR c++/60067 + +template <class> struct A; +template <class> struct B { enum { v = 1 }; }; + +template <class T = void (A<int>)> +struct C { + void f () { + void g (int [B<T>::v]); + } +}; + +void foo (void) { + C<int>().f (); +} diff --git a/gcc/testsuite/g++.dg/template/dependent-expr5.C b/gcc/testsuite/g++.dg/template/dependent-expr5.C index af0dfb912a..8d14553352 100644 --- a/gcc/testsuite/g++.dg/template/dependent-expr5.C +++ b/gcc/testsuite/g++.dg/template/dependent-expr5.C @@ -18,7 +18,7 @@ template<class F, class T> void bindb(F (T::*f)(void)) {} // { dg-message "note" struct foo { static int baist; - int bait; // { dg-error "non-static data member" } + int bait; // { dg-message "" } void barf (); static void barf (int); @@ -31,7 +31,7 @@ struct foo { bar() { bind (&baist); bind (&foo::baist); - bind (&bait); // { dg-error "from this location" } + bind (&bait); // { dg-error "non-static data member" } bind (&foo::bait); bind (&baikst); @@ -53,7 +53,7 @@ struct foo { bindb (&barf); bindb (&foo::barf); // { dg-error "ambiguous" } - // { dg-message "(candidate|deduce template parameter)" "candidate note" { target *-*-* } 55 } + bind (&bark); // { dg-error "no matching function" } // { dg-message "(candidate|deduce template parameter)" "candidate note" { target *-*-* } 58 } @@ -69,7 +69,7 @@ struct foo { bindb (&bark); bindb (&bar::bark); // { dg-error "ambiguous" } - // { dg-message "(candidate|deduce template parameter)" "candidate note" { target *-*-* } 71 } + } }; @@ -83,7 +83,7 @@ struct foo { barT() { bind (&baist); bind (&foo::baist); - bind (&bait); // { dg-error "from this location" } + bind (&bait); // { dg-error "non-static data member" } bind (&foo::bait); bind (&baikst); @@ -105,7 +105,7 @@ struct foo { bindb (&barf); bindb (&foo::barf); // { dg-error "ambiguous" } - // { dg-message "(candidate|deduce template parameter)" "candidate note" { target *-*-* } 107 } + bind (&bark); // { dg-error "no matching function" } // { dg-message "(candidate|deduce template parameter)" "candidate note" { target *-*-* } 110 } @@ -121,7 +121,7 @@ struct foo { bindb (&bark); bindb (&barT::bark); // { dg-error "ambiguous" } - // { dg-message "(candidate|deduce template parameter)" "candidate note" { target *-*-* } 123 } + } }; diff --git a/gcc/testsuite/g++.dg/template/dtor3.C b/gcc/testsuite/g++.dg/template/dtor3.C index 98c2ef6c18..38ddaf6d4e 100644 --- a/gcc/testsuite/g++.dg/template/dtor3.C +++ b/gcc/testsuite/g++.dg/template/dtor3.C @@ -1,4 +1,4 @@ // PR c++/19762 -template<int> struct A { ~A(){} }; // { dg-error "" } +template<int> struct A { ~A(){} }; // { dg-message "provided for" } template A<>::~A(); // { dg-error "template|declaration" } diff --git a/gcc/testsuite/g++.dg/template/error15.C b/gcc/testsuite/g++.dg/template/error15.C index b7c7bc8ca4..86936581cf 100644 --- a/gcc/testsuite/g++.dg/template/error15.C +++ b/gcc/testsuite/g++.dg/template/error15.C @@ -9,9 +9,9 @@ template <class T> class B { protected: - A<T> a; // { dg-error "" } + A<T> a; // { dg-message "" } - void f(const A<T> * a1 = &a); // { dg-error "this location" } + void f(const A<T> * a1 = &a); // { dg-error "non-static" } void g(void); }; diff --git a/gcc/testsuite/g++.dg/template/error2.C b/gcc/testsuite/g++.dg/template/error2.C index be5ab1d450..a7f199e51e 100644 --- a/gcc/testsuite/g++.dg/template/error2.C +++ b/gcc/testsuite/g++.dg/template/error2.C @@ -7,8 +7,7 @@ template<class T> struct X { - T m; // { dg-error "void" "void" } - // { dg-error "incomplete type" "incomplete" { target *-*-* } 10 } + T m; // { dg-error "incomplete type|invalid use" } }; template<class T > diff --git a/gcc/testsuite/g++.dg/template/error38.C b/gcc/testsuite/g++.dg/template/error38.C index 14a2132998..6c25b9f9c0 100644 --- a/gcc/testsuite/g++.dg/template/error38.C +++ b/gcc/testsuite/g++.dg/template/error38.C @@ -32,12 +32,8 @@ int main() { A<B> a; a.f(); // { dg-error "" } - // { dg-message "candidate" "candidate note" { target *-*-* } 34 } a.g(); // { dg-error "" } - // { dg-message "candidate" "candidate note" { target *-*-* } 36 } f(i); // { dg-error "" } - // { dg-message "candidate" "candidate note" { target *-*-* } 39 } f(p); // { dg-error "" } - // { dg-message "candidate" "candidate note" { target *-*-* } 41 } } diff --git a/gcc/testsuite/g++.dg/template/error40.C b/gcc/testsuite/g++.dg/template/error40.C index 7746ed2cee..c5df56fc1b 100644 --- a/gcc/testsuite/g++.dg/template/error40.C +++ b/gcc/testsuite/g++.dg/template/error40.C @@ -26,7 +26,5 @@ struct B int main() { f(1); // { dg-error "" } - // { dg-message "candidate" "candidate note" { target *-*-* } 28 } B<A<int> >().f(); // { dg-error "" } - // { dg-message "candidate" "candidate note" { target *-*-* } 30 } } diff --git a/gcc/testsuite/g++.dg/template/error42.C b/gcc/testsuite/g++.dg/template/error42.C index 0d651e3162..3c66ed0289 100644 --- a/gcc/testsuite/g++.dg/template/error42.C +++ b/gcc/testsuite/g++.dg/template/error42.C @@ -3,18 +3,18 @@ template <int> struct A { - int i; // { dg-error "invalid use of non-static data member" } + int i; // { dg-message "" } friend void foo () { - int x[i]; // { dg-error "from this location" } + int x[i]; // { dg-error "non-static data member" } } }; struct B { - int j; // { dg-error "invalid use of non-static data member" } + int j; // { dg-message "" } friend int bar () { - return j; // { dg-error "from this location" } + return j; // { dg-error "non-static data member" } } }; diff --git a/gcc/testsuite/g++.dg/template/error46.C b/gcc/testsuite/g++.dg/template/error46.C index 6cb085a182..be0b813324 100644 --- a/gcc/testsuite/g++.dg/template/error46.C +++ b/gcc/testsuite/g++.dg/template/error46.C @@ -8,4 +8,4 @@ void bar() { foo(A<0>(), A<1>()); // { dg-error "no matching" } } -// { dg-message "candidate|parameter 'N' ('0' and '1')" "" { target *-*-* } 9 } +// { dg-message "deduced conflicting values" "" { target *-*-* } 9 } diff --git a/gcc/testsuite/g++.dg/template/error47.C b/gcc/testsuite/g++.dg/template/error47.C index 74a5989229..e598d141c2 100644 --- a/gcc/testsuite/g++.dg/template/error47.C +++ b/gcc/testsuite/g++.dg/template/error47.C @@ -6,4 +6,4 @@ void bar(void* p) { foo(0, p); // { dg-error "no matching" } } -// { dg-message "candidate|parameter 'T' ('int' and 'void*')" "" { target *-*-* } 7 } +// { dg-message "parameter 'T' .'int' and 'void.'" "" { target *-*-* } 7 } diff --git a/gcc/testsuite/g++.dg/template/error51.C b/gcc/testsuite/g++.dg/template/error51.C index b3a6cfb3d2..304a13a70f 100644 --- a/gcc/testsuite/g++.dg/template/error51.C +++ b/gcc/testsuite/g++.dg/template/error51.C @@ -2,7 +2,7 @@ template<int> void foo() { - struct A; // { dg-error "declaration" } + struct A; // { dg-message "declaration" } struct B : A {}; // { dg-error "invalid use of incomplete" } } diff --git a/gcc/testsuite/g++.dg/template/friend57.C b/gcc/testsuite/g++.dg/template/friend57.C new file mode 100644 index 0000000000..7077d5e53c --- /dev/null +++ b/gcc/testsuite/g++.dg/template/friend57.C @@ -0,0 +1,21 @@ +// PR c++/59366 +// { dg-do compile } +template<typename T> void f(T); + +struct S +{ + template<typename T> friend void f(T) {} + template<typename T> friend void g(T) {} + template<typename T> friend void h(T) {} +}; + +template<typename T> void h(T); + +int +main () +{ + f(1); + g(1); // { dg-error "'g' was not declared in this scope" } + g(S()); + h(1); +} diff --git a/gcc/testsuite/g++.dg/template/friend58.C b/gcc/testsuite/g++.dg/template/friend58.C new file mode 100644 index 0000000000..cadfb3e1f4 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/friend58.C @@ -0,0 +1,19 @@ +// PR c++/42328 + +template<typename T, typename U> +class freeList +{ +public: + void foo() {}; +}; + +class bar {}; + +class baz : protected freeList<bar, baz> +{ + template<typename T> + friend + void freeList<T, baz>::foo(); // { dg-error "friend" } +}; + +baz b; diff --git a/gcc/testsuite/g++.dg/template/friend59.C b/gcc/testsuite/g++.dg/template/friend59.C new file mode 100644 index 0000000000..e7c6d58ab1 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/friend59.C @@ -0,0 +1,22 @@ +// PR c++/42328 + +template<typename T, typename U> +class freeList +{ +public: + void foo() {}; +}; + +class bar {}; + +class baz; +template<typename T> class freeList<T, baz> { void foo(); }; + +class baz : protected freeList<bar, baz> +{ + template<typename T> + friend + void freeList<T, baz>::foo(); +}; + +baz b; diff --git a/gcc/testsuite/g++.dg/template/incomplete1.C b/gcc/testsuite/g++.dg/template/incomplete1.C index e4997ef014..53bd8170e6 100644 --- a/gcc/testsuite/g++.dg/template/incomplete1.C +++ b/gcc/testsuite/g++.dg/template/incomplete1.C @@ -2,7 +2,7 @@ // Origin: Ivan Godard <igodard at pacbell dot net> // PR c++/17447: Detect parameters of dependent types even in templates -struct B; // { dg-error "forward declaration" } +struct B; // { dg-message "forward declaration" } template<typename T> struct A { friend A& operator <<(A& a, B b) { return a; } // { dg-error "incomplete" } diff --git a/gcc/testsuite/g++.dg/template/incomplete2.C b/gcc/testsuite/g++.dg/template/incomplete2.C index b855569088..bad16020ba 100644 --- a/gcc/testsuite/g++.dg/template/incomplete2.C +++ b/gcc/testsuite/g++.dg/template/incomplete2.C @@ -10,5 +10,4 @@ A a; // { dg-error "incomplete type" } void bar() { foo<a>(); // { dg-error "(no matching function|could not convert)" } - // { dg-message "candidate" "candidate note" { target *-*-* } 12 } } diff --git a/gcc/testsuite/g++.dg/template/incomplete3.C b/gcc/testsuite/g++.dg/template/incomplete3.C index 8a20bba74d..9b2efb77b7 100644 --- a/gcc/testsuite/g++.dg/template/incomplete3.C +++ b/gcc/testsuite/g++.dg/template/incomplete3.C @@ -1,5 +1,5 @@ // PR c++/27315 // { dg-do compile } -struct A; // { dg-error "forward declaration" } +struct A; // { dg-message "forward declaration" } template void A::foo<0>(); // { dg-error "before|incomplete" } diff --git a/gcc/testsuite/g++.dg/template/incomplete4.C b/gcc/testsuite/g++.dg/template/incomplete4.C index f2832a73c4..7cff66bdc0 100644 --- a/gcc/testsuite/g++.dg/template/incomplete4.C +++ b/gcc/testsuite/g++.dg/template/incomplete4.C @@ -1,11 +1,11 @@ // PR c++/33501 // { dg-do compile } -class A; // { dg-error "forward declaration" } +class A; // { dg-message "forward declaration" } template <typename T> struct X { - static int f (T); // { dg-error "initializing" } + static int f (T); // { dg-message "initializing" } static const T &make (); }; diff --git a/gcc/testsuite/g++.dg/template/incomplete5.C b/gcc/testsuite/g++.dg/template/incomplete5.C index f7802825fd..1bd21b95e8 100644 --- a/gcc/testsuite/g++.dg/template/incomplete5.C +++ b/gcc/testsuite/g++.dg/template/incomplete5.C @@ -1,11 +1,11 @@ // PR c++/33501 // { dg-do compile } -class A; // { dg-error "forward declaration" } +class A; // { dg-message "forward declaration" } template <typename T> struct X { - static int f (T); // { dg-error "initializing" } + static int f (T); // { dg-message "initializing" } static const T &make (); static const bool value = sizeof (f (make ())) == sizeof (int); // { dg-error "invalid use of incomplete type" } }; diff --git a/gcc/testsuite/g++.dg/template/inherit8.C b/gcc/testsuite/g++.dg/template/inherit8.C index 3176dc06d0..62a0f1da1a 100644 --- a/gcc/testsuite/g++.dg/template/inherit8.C +++ b/gcc/testsuite/g++.dg/template/inherit8.C @@ -4,7 +4,7 @@ template <typename T> struct A { template <typename U> - struct B : public A <B<U> > // { dg-error "declaration" } + struct B : public A <B<U> > // { dg-message "not complete" } { struct C : public B<U> // { dg-error "incomplete" } { diff --git a/gcc/testsuite/g++.dg/template/instantiate1.C b/gcc/testsuite/g++.dg/template/instantiate1.C index dd501684e6..a9c8cf8696 100644 --- a/gcc/testsuite/g++.dg/template/instantiate1.C +++ b/gcc/testsuite/g++.dg/template/instantiate1.C @@ -12,7 +12,7 @@ template <class T> struct Y { X<T> x; // { dg-message "required" } }; -template <class T> struct Z { // { dg-error "declaration" } +template <class T> struct Z { // { dg-message "declaration" } Y<Z<T> > y; // { dg-message "required" } }; diff --git a/gcc/testsuite/g++.dg/template/instantiate3.C b/gcc/testsuite/g++.dg/template/instantiate3.C index c0754da922..e99ec84c2a 100644 --- a/gcc/testsuite/g++.dg/template/instantiate3.C +++ b/gcc/testsuite/g++.dg/template/instantiate3.C @@ -4,7 +4,7 @@ // PR c++/7639 // ICE when accessing member with incomplete type. -class ACE_Null_Mutex; // { dg-error "forward declaration" } +class ACE_Null_Mutex; // { dg-message "forward declaration" } template <class TYPE> struct ACE_Cleanup_Adapter diff --git a/gcc/testsuite/g++.dg/template/instantiate5.C b/gcc/testsuite/g++.dg/template/instantiate5.C index 2198087abf..896313d14d 100644 --- a/gcc/testsuite/g++.dg/template/instantiate5.C +++ b/gcc/testsuite/g++.dg/template/instantiate5.C @@ -19,7 +19,6 @@ struct B template <typename T> struct C { virtual void bar() const { T::foo(); } // { dg-error "no matching function" } - // { dg-message "candidate" "candidate note" { target *-*-* } 21 } }; C<B> c; // { dg-message "required" } diff --git a/gcc/testsuite/g++.dg/template/linkage1.C b/gcc/testsuite/g++.dg/template/linkage1.C index 02aa967296..ac4d30b131 100644 --- a/gcc/testsuite/g++.dg/template/linkage1.C +++ b/gcc/testsuite/g++.dg/template/linkage1.C @@ -1,7 +1,7 @@ // PR c++/50372 // Test that a template instantiation has the same linkage as its argument. // { dg-final { scan-assembler "(weak|glob)\[^\n\]*_Z3fooIXadL_Z13external_funcvEEEvv" } } -// { dg-final { scan-assembler-not "(weak|glob)\[^\n\]*_Z3fooIXadL_ZL11static_funcvEEEvv" } } +// { dg-final { scan-assembler-not "(weak|glob)\[^\n\]*_Z3fooIXadL_ZL11static_funcvEEEvv" { xfail powerpc-*-aix* } } } template<void (*fptr)(void)> void foo() { } diff --git a/gcc/testsuite/g++.dg/template/local4.C b/gcc/testsuite/g++.dg/template/local4.C index d842076bd8..95d2990ec8 100644 --- a/gcc/testsuite/g++.dg/template/local4.C +++ b/gcc/testsuite/g++.dg/template/local4.C @@ -6,5 +6,4 @@ template <typename T> void foo() {} // { dg-message "note" } int main () { struct S {}; foo<S> (); // { dg-error "(match|template argument for|trying to instantiate)" } - // { dg-message "candidate" "candidate note" { target *-*-* } 8 } } diff --git a/gcc/testsuite/g++.dg/template/local8.C b/gcc/testsuite/g++.dg/template/local8.C new file mode 100644 index 0000000000..006bd8c40e --- /dev/null +++ b/gcc/testsuite/g++.dg/template/local8.C @@ -0,0 +1,18 @@ +// PR c++/56947 + +struct A +{ + A (int); +}; + +template < typename > +void Fn () +{ + const int kCapacity = 0; + struct Q:A + { + Q ():A (kCapacity) { } + }; + Q q; +} +template void Fn < int >(); diff --git a/gcc/testsuite/g++.dg/template/local9.C b/gcc/testsuite/g++.dg/template/local9.C new file mode 100644 index 0000000000..90f14bb796 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/local9.C @@ -0,0 +1,15 @@ +// PR c++/61445 + +template <typename T> void f (T) +{ + struct A + { + struct B { B(); }; + void g () { B b; } + }; +} + +int main() +{ + f(0); +} diff --git a/gcc/testsuite/g++.dg/template/nested6.C b/gcc/testsuite/g++.dg/template/nested6.C new file mode 100644 index 0000000000..f5b8054a59 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/nested6.C @@ -0,0 +1,19 @@ +// PR c++/63309 + +template <class T> +class A +{ +public: + class B; +}; + +template <class T, class I> +class A<T>::B // { dg-error "template parameters|required" } +{ +}; + +int main() +{ + A<int>::B myB; // { dg-prune-output "incomplete type" } + return 0; +} diff --git a/gcc/testsuite/g++.dg/template/new3.C b/gcc/testsuite/g++.dg/template/new3.C index 230330ec66..461b47b5e9 100644 --- a/gcc/testsuite/g++.dg/template/new3.C +++ b/gcc/testsuite/g++.dg/template/new3.C @@ -6,7 +6,6 @@ struct C void f() { int* node; new (&node) int(0); // { dg-error "new" } - // { dg-message "candidate" "candidate note" { target *-*-* } 8 } } }; diff --git a/gcc/testsuite/g++.dg/template/non-dependent14.C b/gcc/testsuite/g++.dg/template/non-dependent14.C new file mode 100644 index 0000000000..b257d9baf1 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/non-dependent14.C @@ -0,0 +1,7 @@ +// PR c++/64251 + +class DictionaryValue {}; +template <typename T> void CreateValue(T) { + DictionaryValue(0); + CreateValue(0); +} diff --git a/gcc/testsuite/g++.dg/template/nontype7.C b/gcc/testsuite/g++.dg/template/nontype7.C index 5eac558e45..ba33b19db3 100644 --- a/gcc/testsuite/g++.dg/template/nontype7.C +++ b/gcc/testsuite/g++.dg/template/nontype7.C @@ -10,6 +10,3 @@ char p[] = "Vivisectionist"; X<int,"Studebaker"> x1; // { dg-error "string literal" } X<int, p> x2; - -// { dg-bogus "" "additional errors" { xfail *-*-* } 11 } - diff --git a/gcc/testsuite/g++.dg/template/offsetof2.C b/gcc/testsuite/g++.dg/template/offsetof2.C index da888f7a59..3f08f9b0b8 100644 --- a/gcc/testsuite/g++.dg/template/offsetof2.C +++ b/gcc/testsuite/g++.dg/template/offsetof2.C @@ -1,7 +1,7 @@ // PR c++/49085 template <class T> -struct A // { dg-error "declaration" } +struct A // { dg-message "not complete" } { int i, j; int ar[__builtin_offsetof(A,j)]; // { dg-error "incomplete type" } diff --git a/gcc/testsuite/g++.dg/template/offsetof3.C b/gcc/testsuite/g++.dg/template/offsetof3.C new file mode 100644 index 0000000000..b17374645b --- /dev/null +++ b/gcc/testsuite/g++.dg/template/offsetof3.C @@ -0,0 +1,18 @@ +// PR c++/64487 + +struct foo { + int member; +}; + +template < int N> +struct bar {}; + +template <int N> +struct qux { + static bar<N+__builtin_offsetof(foo,member)> static_member; +}; + +template <int N> +bar<N+__builtin_offsetof(foo,member)> qux<N>::static_member; + +int main() { } diff --git a/gcc/testsuite/g++.dg/template/operator13.C b/gcc/testsuite/g++.dg/template/operator13.C new file mode 100644 index 0000000000..1967c910e6 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/operator13.C @@ -0,0 +1,12 @@ +// PR c++/50961 + +template < class > void foo (); + +bool b1 = !foo<void>; +bool b2 = foo<void> ? true : false; + +void bar() +{ + if (foo<void>) + ; +} diff --git a/gcc/testsuite/g++.dg/template/operator14.C b/gcc/testsuite/g++.dg/template/operator14.C new file mode 100644 index 0000000000..6267dbb140 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/operator14.C @@ -0,0 +1,7 @@ +// DR 2007 +// We shouldn't instantiate A<void> to lookup operator=, since operator= +// must be a non-static member function. + +template<typename T> struct A { typename T::error e; }; +template<typename T> struct B { }; +B<A<void> > b1, &b2 = (b1 = b1); diff --git a/gcc/testsuite/g++.dg/template/operator8.C b/gcc/testsuite/g++.dg/template/operator8.C index 29d17b84b8..52f22188dd 100644 --- a/gcc/testsuite/g++.dg/template/operator8.C +++ b/gcc/testsuite/g++.dg/template/operator8.C @@ -2,5 +2,5 @@ struct A { - template<operator+> void foo() {} // { dg-error "identifier|non-function|template arguments" } + template<operator+> void foo() {} // { dg-error "identifier|parameter|template arguments" } }; diff --git a/gcc/testsuite/g++.dg/template/operator9.C b/gcc/testsuite/g++.dg/template/operator9.C index 46eef0a9ac..d4ebad3aa1 100644 --- a/gcc/testsuite/g++.dg/template/operator9.C +++ b/gcc/testsuite/g++.dg/template/operator9.C @@ -1,10 +1,9 @@ //PR c++/27670 -template<operator+> void foo(); // { dg-error "before|non-function|template" } +template<operator+> void foo(); // { dg-error "before|parameter|template" } void bar() { foo(); // { dg-error "no matching function" } - // { dg-message "(candidate|deduce template parameter)" "candidate note" { target *-*-* } 7 } } diff --git a/gcc/testsuite/g++.dg/template/overload14.C b/gcc/testsuite/g++.dg/template/overload14.C new file mode 100644 index 0000000000..ec2c381510 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/overload14.C @@ -0,0 +1,18 @@ +// PR c++/65051 + +template<typename T> struct wrap { typedef T type; }; +template <class T> class rv: public wrap <T>::type {}; + +template <class value_type> +struct circular_buffer +{ + typedef const value_type& param_value_type; + typedef rv< value_type >& rvalue_type; + + void push_back(param_value_type item) {} + void push_back(rvalue_type item) {} +}; + +union U { int i; char c; }; + +void f(circular_buffer<U> b, const U& u) { b.push_back(u); } diff --git a/gcc/testsuite/g++.dg/template/pr16564.C b/gcc/testsuite/g++.dg/template/pr16564.C new file mode 100644 index 0000000000..7a34313e90 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr16564.C @@ -0,0 +1,10 @@ +// { dg-do compile } +template<typename> struct A +{ + A<A> a; /* { dg-error "depth" } */ + A() {} +}; + +A<int> a; + +// { dg-prune-output "compilation terminated" } diff --git a/gcc/testsuite/g++.dg/template/pr23510.C b/gcc/testsuite/g++.dg/template/pr23510.C index 7163e30ba2..c1ffc176c5 100644 --- a/gcc/testsuite/g++.dg/template/pr23510.C +++ b/gcc/testsuite/g++.dg/template/pr23510.C @@ -3,21 +3,21 @@ template<unsigned int nFactor> struct Factorial { - enum { nValue = nFactor * Factorial<nFactor - 1>::nValue }; // { dg-error "depth exceeds maximum" "exceeds" } - // { dg-message "recursively required" "recurse" { target *-*-* } 6 } - // { dg-error "incomplete type" "incomplete" { target *-*-* } 6 } -} // { dg-error "expected ';' after" } + enum { nValue = nFactor * Factorial<nFactor - 1>::nValue }; // { dg-error "depth" } +}; - template<> - struct Factorial<0> - { - enum { nValue = 1 }; - }; +template<> +struct Factorial<0> +{ + enum { nValue = 1 }; +}; - static const unsigned int FACTOR = 20; +static const unsigned int FACTOR = 20; int main() { - Factorial<FACTOR>::nValue; + Factorial<FACTOR>::nValue; // { dg-message "from here" } return 0; } + +// { dg-prune-output "compilation terminated" } diff --git a/gcc/testsuite/g++.dg/template/pr34938-1.C b/gcc/testsuite/g++.dg/template/pr34938-1.C new file mode 100644 index 0000000000..f23a5a3e20 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr34938-1.C @@ -0,0 +1,7 @@ +// PR c++/34938 + +typedef void (*fptr)() __attribute((noreturn)); +template<int> void foo(); +template<fptr> void bar(); + +fptr f = bar< foo<0> >; // { dg-error "noreturn" } diff --git a/gcc/testsuite/g++.dg/template/pr34938-2.C b/gcc/testsuite/g++.dg/template/pr34938-2.C new file mode 100644 index 0000000000..fe7650fd62 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr34938-2.C @@ -0,0 +1,10 @@ +// PR c++/34938 + +template <class T> struct A { }; +struct B { }; + +A<void()const>* p1 = 42; // { dg-error "void\\(\\) const" } +A<void(B::*)()const>* p2 = 42; // { dg-error "void \\(B::\\*\\)\\(\\) const" } + +A<void()volatile>* p3 = 42; // { dg-error "void\\(\\) volatile" } +A<void(B::*)()volatile>* p4 = 42; // { dg-error "void \\(B::\\*\\)\\(\\) volatile" } diff --git a/gcc/testsuite/g++.dg/template/pr51199.C b/gcc/testsuite/g++.dg/template/pr51199.C new file mode 100644 index 0000000000..e56b2549ef --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr51199.C @@ -0,0 +1,17 @@ +// PR c++/51199 + +typedef void FC() const; + +template<class T> +struct add_ref { + typedef T& type; // { dg-error "forming reference" } +}; + +typedef add_ref<FC>::type ref_type; + +template<class T> +struct add_ptr { + typedef T* type; // { dg-error "forming pointer" } +}; + +typedef add_ptr<FC>::type ptr_type; diff --git a/gcc/testsuite/g++.dg/template/pr51385.C b/gcc/testsuite/g++.dg/template/pr51385.C new file mode 100644 index 0000000000..e76995467c --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr51385.C @@ -0,0 +1,24 @@ +// PR c++/51385 + +template <__SIZE_TYPE__ N> struct NTmpl; +template <typename T, typename U, typename V = NTmpl<sizeof(T *)> > +struct PtrConvs { + enum { bad = 1 }; +}; + +template <typename Target, typename Source> +struct PtrConvs<Target, Source, NTmpl<sizeof (*(Target **)0 = (Source *)0)> >; + +template<typename T> struct test { static const bool value = true; }; +template<> struct test<short> { static const bool value = false; }; + +template <typename T> +struct FussyTemplate +{ + int sa[test<T>::value ? 1 : -1]; +}; + +struct B { }; + +typedef char chk[1]; +typedef char chk[PtrConvs<FussyTemplate<short>, B>::bad]; diff --git a/gcc/testsuite/g++.dg/template/pr52819.C b/gcc/testsuite/g++.dg/template/pr52819.C new file mode 100644 index 0000000000..66175bc21e --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr52819.C @@ -0,0 +1,14 @@ +// PR c++/52819 + +typedef void (*cfi)(void*); + +void function(int *a) {} + +template<cfi Func> +void get() { Func(0); } + +int main() +{ + get<(cfi)function>(); // { dg-error "" } + return 0; +} diff --git a/gcc/testsuite/g++.dg/template/pr54310.C b/gcc/testsuite/g++.dg/template/pr54310.C new file mode 100644 index 0000000000..94e5f2494c --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr54310.C @@ -0,0 +1,19 @@ +// PR c++/54310 + +template <typename T> +struct meta +{ + typedef typename T::type type; +}; + +struct S{}; + +template <typename T> +typename meta<T>::type foo(T, S); + +int foo(int, int); + +int main() +{ + foo(0, 0); +} diff --git a/gcc/testsuite/g++.dg/template/pr54377.C b/gcc/testsuite/g++.dg/template/pr54377.C new file mode 100644 index 0000000000..b85181749c --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr54377.C @@ -0,0 +1,6 @@ +// PR c++/54377 + +template <typename, typename, typename = void, typename = void> +struct foo {}; // { dg-message "provided for" } + +foo<int> f; // { dg-error "at least 2" } diff --git a/gcc/testsuite/g++.dg/template/pr54987.C b/gcc/testsuite/g++.dg/template/pr54987.C new file mode 100644 index 0000000000..773f023e0a --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr54987.C @@ -0,0 +1,51 @@ +// PR c++/54987 + +struct Argument1 +{ +}; + +struct Argument2 +{ +}; + +template<typename T> +struct Template1 +{ + Template1() {} + + template<typename Y> + Template1( const Template1<Y>& ) {} +}; + +template<typename T> +struct Template2 +{ + Template2() {} + + template<typename Y> + Template2( const Template1<Y>& ) {} +}; + +template <typename T> +struct make_type +{ + typedef Argument1 type; +}; + +template<typename T> +void foo( T, Template1<typename make_type<T>::type> ) +{ +} + +template<typename T> +void foo( T, Template2<typename make_type<T>::type> ) +{ +} + +int main() +{ + Template1<Argument2> t; + Argument1 a; + foo( a, t ); // { dg-error "ambiguous" } + return 0; +} diff --git a/gcc/testsuite/g++.dg/template/pr57573.C b/gcc/testsuite/g++.dg/template/pr57573.C new file mode 100644 index 0000000000..1344511a69 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr57573.C @@ -0,0 +1,13 @@ +// PR c++/57573 + +struct A { }; +struct B { A a; }; + +void f(A*) { } + +template<class T> +void g() +{ + B b; + f(&(b.a)); +} diff --git a/gcc/testsuite/g++.dg/template/pr61670.C b/gcc/testsuite/g++.dg/template/pr61670.C new file mode 100644 index 0000000000..d244efae71 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr61670.C @@ -0,0 +1,9 @@ +// PR c++/61670 +// { dg-do compile } + +template <class> +class A { + A: 0 // { dg-error "" } +}; + +A<int> a; diff --git a/gcc/testsuite/g++.dg/template/pr61745.C b/gcc/testsuite/g++.dg/template/pr61745.C new file mode 100644 index 0000000000..0f7c280e52 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr61745.C @@ -0,0 +1,22 @@ +// PR c++/61745 + +template <typename INT,INT P> class Zp; + +template <typename INT,INT P> +Zp<INT,P> operator-(const Zp<INT,P>& a, const Zp<INT,P>& b); + +template <typename INT,INT P> +class Zp { +public: + static const INT p = P; +private: + INT val; +public: + Zp() : val(0) {} + Zp( INT x ) : val(x%p) { if (x < 0 ) x+= p; } + + // this compiles only if the following definition is moved + // AFTER the friend declaration + Zp operator-() const { return Zp(p-val); } + friend Zp<INT,P> operator- <>(const Zp<INT,P>& a, const Zp<INT,P>& b); // { dg-error "declaration|expected" } +}; diff --git a/gcc/testsuite/g++.dg/template/pr64100.C b/gcc/testsuite/g++.dg/template/pr64100.C new file mode 100644 index 0000000000..493849f24c --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr64100.C @@ -0,0 +1,9 @@ +// { dg-do compile { target c++11 } } + +template<typename> struct foo // { dg-message "note" } +{ // { dg-error "incomplete type" } + static_assert(noexcept(((foo *)1)->~foo()), ""); +}; + +template class foo<int>; + diff --git a/gcc/testsuite/g++.dg/template/pr65390.C b/gcc/testsuite/g++.dg/template/pr65390.C new file mode 100644 index 0000000000..299d22a7ee --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr65390.C @@ -0,0 +1,12 @@ +// PR c++/65390 +// { dg-do compile } +// { dg-options "" } + +template<typename T> struct shared_ptr { }; + +template<typename T, typename Arg> +shared_ptr<T> make_shared(Arg) { return shared_ptr<T>(); } // { dg-error "variably modified type|trying to instantiate" } + +void f(int n){ + make_shared<int[n]>(1); // { dg-error "no matching function" } +} diff --git a/gcc/testsuite/g++.dg/template/ptrmem2.C b/gcc/testsuite/g++.dg/template/ptrmem2.C index 5f03580c1b..6aa251243a 100644 --- a/gcc/testsuite/g++.dg/template/ptrmem2.C +++ b/gcc/testsuite/g++.dg/template/ptrmem2.C @@ -12,5 +12,4 @@ template <typename T> T A::* Foo (); // { dg-error "reference" } void Baz () { Foo <int &> (); // { dg-error "no matching function" "" } - // { dg-message "candidate" "candidate note" { target *-*-* } 14 } } diff --git a/gcc/testsuite/g++.dg/template/ptrmem20.C b/gcc/testsuite/g++.dg/template/ptrmem20.C index dee3c629a7..2d2453d73d 100644 --- a/gcc/testsuite/g++.dg/template/ptrmem20.C +++ b/gcc/testsuite/g++.dg/template/ptrmem20.C @@ -13,5 +13,4 @@ template<void (A::*)()> void bar(); // { dg-message "note" } void baz() { bar<&B::foo>(); // { dg-error "not a valid template argument|no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 15 } } diff --git a/gcc/testsuite/g++.dg/template/qualttp17.C b/gcc/testsuite/g++.dg/template/qualttp17.C index f492ced8c8..fea8b3df95 100644 --- a/gcc/testsuite/g++.dg/template/qualttp17.C +++ b/gcc/testsuite/g++.dg/template/qualttp17.C @@ -1,7 +1,7 @@ // Copyright (C) 2001 Free Software Foundation // Contributed by Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> // { dg-do compile } -// { dg-options "-fno-inline -fabi-version=1 -Wno-abi" } +// { dg-options "-fno-inline" } struct A { @@ -22,4 +22,4 @@ int main() f<A>(x); } -// { dg-final { scan-assembler "\n_?_Z1fI1AEv1XIN1T1BEE\[: \t\n\]" } } +// { dg-final { scan-assembler "\n_?_Z1fI1AEv1XINT_1BEE\[: \t\n\]" } } diff --git a/gcc/testsuite/g++.dg/template/qualttp4.C b/gcc/testsuite/g++.dg/template/qualttp4.C index 0f45c8c832..102fc35754 100644 --- a/gcc/testsuite/g++.dg/template/qualttp4.C +++ b/gcc/testsuite/g++.dg/template/qualttp4.C @@ -7,7 +7,7 @@ struct A template <class T> struct B {}; }; -template <template <class, class> class TT> // { dg-error "provided" } +template <template <class, class> class TT> // { dg-message "provided for" } struct X { TT<int> y; // { dg-error "number" } diff --git a/gcc/testsuite/g++.dg/template/qualttp5.C b/gcc/testsuite/g++.dg/template/qualttp5.C index 8ac1952f9a..7e74f6092e 100644 --- a/gcc/testsuite/g++.dg/template/qualttp5.C +++ b/gcc/testsuite/g++.dg/template/qualttp5.C @@ -11,7 +11,6 @@ template <template <class> class TT> void f() { TT<int> y; y = 0; // { dg-error "no match" } - // { dg-message "candidate" "candidate note" { target *-*-* } 13 } } template <class T> struct C diff --git a/gcc/testsuite/g++.dg/template/recurse.C b/gcc/testsuite/g++.dg/template/recurse.C index 94b56f67e9..fbd7def061 100644 --- a/gcc/testsuite/g++.dg/template/recurse.C +++ b/gcc/testsuite/g++.dg/template/recurse.C @@ -5,10 +5,8 @@ template <int I> struct F { int operator()() { - F<I+1> f; // { dg-error "incomplete type" "incomplete" } - // { dg-bogus "exceeds maximum.*exceeds maximum" "exceeds" { xfail *-*-* } 8 } - // { dg-error "exceeds maximum" "exceeds" { xfail *-*-* } 8 } - return f()*I; // { dg-message "recursively" "recurse" } + F<I+1> f; // { dg-error "depth" } + return f()*I; } }; @@ -20,8 +18,7 @@ template <> struct F<52> int main () { F<1> f; - return f(); // { dg-message "from here" "excessive recursion" } + return f(); // { dg-message "from here" } } -// Ignore excess messages from recursion. -// { dg-prune-output "from 'int" } +// { dg-prune-output "compilation terminated" } diff --git a/gcc/testsuite/g++.dg/template/recurse2.C b/gcc/testsuite/g++.dg/template/recurse2.C index eae411b5ea..0df8e5244f 100644 --- a/gcc/testsuite/g++.dg/template/recurse2.C +++ b/gcc/testsuite/g++.dg/template/recurse2.C @@ -2,7 +2,8 @@ // We should not see an error about non-constant initialization. template <int N> struct X { - static const int value = X<N-1>::value; // { dg-error "instantiation|incomplete" } - // { dg-message "recursively required" "" { target *-*-* } 5 } + static const int value = X<N-1>::value; // { dg-error "depth" } }; template struct X<1000>; + +// { dg-prune-output "compilation terminated" } diff --git a/gcc/testsuite/g++.dg/template/recurse4.C b/gcc/testsuite/g++.dg/template/recurse4.C new file mode 100644 index 0000000000..ee8d1b70df --- /dev/null +++ b/gcc/testsuite/g++.dg/template/recurse4.C @@ -0,0 +1,18 @@ +// PR c++/62255 + +// It's not clear whether this is well-formed; instantiating the +// initializer of 'value' causes the instantiation of Derived, which in +// turn requires the value of 'value', but the recursion ends there, so it +// seems reasonable to allow it. + +template <typename T> struct Test { + template<typename X> static int check(typename X::Type*); + template<typename> static char check(...); + static const bool value = (sizeof(check<T>(0)) == sizeof(int)); +}; +template <int> struct Sink { }; +template <typename T> struct Derived : Sink<Test<Derived<T> >::value> { + typedef int Type; +}; + +Sink<Test<Derived<int> >::value> s; diff --git a/gcc/testsuite/g++.dg/template/ref9.C b/gcc/testsuite/g++.dg/template/ref9.C new file mode 100644 index 0000000000..983f627887 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/ref9.C @@ -0,0 +1,15 @@ +// PR c++/63658 + +struct Descriptor {}; + +template <Descriptor & D> +struct foo +{ + void size (); +}; + +Descriptor g_descriptor = {}; + +template<> void foo<g_descriptor>::size() +{ +} diff --git a/gcc/testsuite/g++.dg/template/repo11.C b/gcc/testsuite/g++.dg/template/repo11.C new file mode 100644 index 0000000000..5cabfd452e --- /dev/null +++ b/gcc/testsuite/g++.dg/template/repo11.C @@ -0,0 +1,31 @@ +// PR c++/64521 +// { dg-options "-frepo -std=c++11" } +// { dg-require-host-local "" } +// { dg-skip-if "dkms are not final links" { vxworks_kernel } } +// { dg-final cleanup-repo-files } + +template <typename H> struct J { J(H) {} }; +template <unsigned long, typename...> struct K; +template <unsigned long I> struct K<I> {}; +template <unsigned long I, typename H, typename... T> +struct K<I, H, T...> : K<I + 1, T...>, J<H> { + K(const H &p1, const T &... p2) : K<I + 1, T...>(p2...), J<H>(p1) {} +}; +template <typename... E> struct C : K<0, E...> { + C(const E &... p1) : K<0, E...>(p1...) {} +}; +template <typename> struct A { + A() = default; +}; +struct M; +template <typename> struct L { + struct B { + template <typename> static M *__test(...); + typedef A<int> _Del; + typedef decltype(__test<_Del>()) type; + }; + C<typename B::type, A<M>> _M_t; + L(typename B::type) : _M_t(0, A<M>()) {} +}; +struct M {}; +int main() { L<int>(new M); } diff --git a/gcc/testsuite/g++.dg/template/sfinae2.C b/gcc/testsuite/g++.dg/template/sfinae2.C index c9e103114d..38eb325c61 100644 --- a/gcc/testsuite/g++.dg/template/sfinae2.C +++ b/gcc/testsuite/g++.dg/template/sfinae2.C @@ -13,6 +13,5 @@ template<int I> void fn (char (*) [cl<I>::value] = 0 ); // { dg-error "zero-size void foo (void) { fn<0> (); // { dg-error "no matching function" } - // { dg-message "candidate" "candidate note" { target *-*-* } 15 } } diff --git a/gcc/testsuite/g++.dg/template/spec22.C b/gcc/testsuite/g++.dg/template/spec22.C index f916ea4689..7e627f1676 100644 --- a/gcc/testsuite/g++.dg/template/spec22.C +++ b/gcc/testsuite/g++.dg/template/spec22.C @@ -16,6 +16,6 @@ template <typename T> struct srp }; ptr<int> parent_get() { - srp<int> parent; // { dg-message "candidate" } + srp<int> parent; return parent; // { dg-error "is ambiguous" } } diff --git a/gcc/testsuite/g++.dg/template/spec23.C b/gcc/testsuite/g++.dg/template/spec23.C index 3d401f00ef..1c027fa438 100644 --- a/gcc/testsuite/g++.dg/template/spec23.C +++ b/gcc/testsuite/g++.dg/template/spec23.C @@ -20,7 +20,6 @@ struct Bar Foo Quux (Bar const &b) { return b; // { dg-error "ambiguous" } - // { dg-message "candidate" "candidate note" { target *-*-* } 22 } } diff --git a/gcc/testsuite/g++.dg/template/spec28.C b/gcc/testsuite/g++.dg/template/spec28.C index f0bb22caeb..ef4b883bcb 100644 --- a/gcc/testsuite/g++.dg/template/spec28.C +++ b/gcc/testsuite/g++.dg/template/spec28.C @@ -2,5 +2,5 @@ // Bad diagnostic // { dg-do compile } -template<typename> struct A {}; // { dg-error "provided" } +template<typename> struct A {}; // { dg-message "provided for" } template<> struct A<> {}; // { dg-error "wrong number" } diff --git a/gcc/testsuite/g++.dg/template/static36.C b/gcc/testsuite/g++.dg/template/static36.C new file mode 100644 index 0000000000..36c48b021b --- /dev/null +++ b/gcc/testsuite/g++.dg/template/static36.C @@ -0,0 +1,4 @@ +// PR c++/65646 + +template <typename = int> class A {}; +template <> A<> &A<>::a; // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/template/typedef4.C b/gcc/testsuite/g++.dg/template/typedef4.C index 60fad06885..2676d8fec1 100644 --- a/gcc/testsuite/g++.dg/template/typedef4.C +++ b/gcc/testsuite/g++.dg/template/typedef4.C @@ -6,5 +6,4 @@ template<typedef> void foo(); // { dg-error "no type|typedef declaration|templa void bar() { foo<int>(); // { dg-error "matching" } - // { dg-message "candidate" "candidate note" { target *-*-* } 8 } } diff --git a/gcc/testsuite/g++.dg/template/void3.C b/gcc/testsuite/g++.dg/template/void3.C index bb59934ffe..1124e44103 100644 --- a/gcc/testsuite/g++.dg/template/void3.C +++ b/gcc/testsuite/g++.dg/template/void3.C @@ -1,5 +1,5 @@ //PR c++/28637 template<void> struct A {}; // { dg-error "not a valid type" } -A<0> a; // { dg-error "type" } +A<0> a; // { dg-message "non-type" } diff --git a/gcc/testsuite/g++.dg/template/void7.C b/gcc/testsuite/g++.dg/template/void7.C index 95d87a2073..5edff9e856 100644 --- a/gcc/testsuite/g++.dg/template/void7.C +++ b/gcc/testsuite/g++.dg/template/void7.C @@ -5,4 +5,4 @@ template<void> struct A // { dg-error "not a valid type" } static int i; }; -A<0> a; // { dg-error "invalid type|not a valid type" } +A<0> a; // { dg-message "non-type" } diff --git a/gcc/testsuite/g++.dg/template/vtable2.C b/gcc/testsuite/g++.dg/template/vtable2.C index 3bcc1ac3f8..53b72f6f4e 100644 --- a/gcc/testsuite/g++.dg/template/vtable2.C +++ b/gcc/testsuite/g++.dg/template/vtable2.C @@ -11,8 +11,10 @@ template <class T> struct inner {}; template <class T> struct parent { - virtual void f() // { dg-error "instantiation depth" } + virtual void f() // { dg-error "depth" } { parent<inner<T> > p; }; }; template struct parent<int>; + +// { dg-prune-output "compilation terminated" } diff --git a/gcc/testsuite/g++.dg/tls/thread_local-ice3.C b/gcc/testsuite/g++.dg/tls/thread_local-ice3.C new file mode 100644 index 0000000000..d061a239f6 --- /dev/null +++ b/gcc/testsuite/g++.dg/tls/thread_local-ice3.C @@ -0,0 +1,5 @@ +// PR c++/58671 +// { dg-do compile { target c++11 } } +// { dg-require-effective-target tls } + +thread_local int i = i; diff --git a/gcc/testsuite/g++.dg/tls/thread_local-ice4.C b/gcc/testsuite/g++.dg/tls/thread_local-ice4.C new file mode 100644 index 0000000000..c49477bd7a --- /dev/null +++ b/gcc/testsuite/g++.dg/tls/thread_local-ice4.C @@ -0,0 +1,19 @@ +// PR c++/60056 +// { dg-do compile { target c++11 } } +// { dg-require-effective-target tls } + +template<typename T> +class Foo { +public: + Foo() { + ++c; + } +private: + thread_local static int c; +}; + +template<typename T> thread_local int Foo<T>::c(0); + +int main(){ + Foo<int> o; +} diff --git a/gcc/testsuite/g++.dg/tls/thread_local1.C b/gcc/testsuite/g++.dg/tls/thread_local1.C index 67bde5549d..e05187912f 100644 --- a/gcc/testsuite/g++.dg/tls/thread_local1.C +++ b/gcc/testsuite/g++.dg/tls/thread_local1.C @@ -7,7 +7,7 @@ // simultaneous execution. // { dg-final { scan-assembler-not "cxa_guard" } } // The guard should be TLS, not local common. -// { dg-final { scan-assembler-not "\.comm" } } +// { dg-final { scan-assembler-not "\.comm" { xfail powerpc-*-aix* } } } struct A { diff --git a/gcc/testsuite/g++.dg/tls/thread_local5.C b/gcc/testsuite/g++.dg/tls/thread_local5.C index 8d17584edd..c4d5ff01bf 100644 --- a/gcc/testsuite/g++.dg/tls/thread_local5.C +++ b/gcc/testsuite/g++.dg/tls/thread_local5.C @@ -2,6 +2,7 @@ // { dg-do run } // { dg-require-effective-target c++11 } +// { dg-require-effective-target unwrapped } // { dg-require-effective-target tls_runtime } // { dg-require-effective-target pthread } // { dg-options -pthread } diff --git a/gcc/testsuite/g++.dg/tls/thread_local5g.C b/gcc/testsuite/g++.dg/tls/thread_local5g.C index f87b0382d9..5ced551fb5 100644 --- a/gcc/testsuite/g++.dg/tls/thread_local5g.C +++ b/gcc/testsuite/g++.dg/tls/thread_local5g.C @@ -2,6 +2,7 @@ // { dg-do run } // { dg-require-effective-target c++11 } +// { dg-require-effective-target unwrapped } // { dg-require-effective-target tls_runtime } // { dg-require-effective-target pthread } // { dg-require-cxa-atexit "" } diff --git a/gcc/testsuite/g++.dg/tls/thread_local6.C b/gcc/testsuite/g++.dg/tls/thread_local6.C index 378cf3d58c..2810efaea9 100644 --- a/gcc/testsuite/g++.dg/tls/thread_local6.C +++ b/gcc/testsuite/g++.dg/tls/thread_local6.C @@ -1,6 +1,7 @@ // Test for cleanups in the main thread without -pthread. -// { dg-do run { target c++11 } } +/* wrapping doesn't reflect _exit value */ +// { dg-do run { target { c++11 && unwrapped } } } // { dg-add-options tls } // { dg-require-effective-target tls_runtime } diff --git a/gcc/testsuite/g++.dg/tls/thread_local6g.C b/gcc/testsuite/g++.dg/tls/thread_local6g.C index f261d5419c..b8f9cdf1de 100644 --- a/gcc/testsuite/g++.dg/tls/thread_local6g.C +++ b/gcc/testsuite/g++.dg/tls/thread_local6g.C @@ -2,6 +2,7 @@ // { dg-do run { target c++11 } } // { dg-add-options tls } +// { dg-require-effective-target unwrapped } // { dg-require-effective-target tls_runtime } // { dg-require-cxa-atexit "" } diff --git a/gcc/testsuite/g++.dg/tls/thread_local7.C b/gcc/testsuite/g++.dg/tls/thread_local7.C index 3cb02dd51f..aaac6c16a5 100644 --- a/gcc/testsuite/g++.dg/tls/thread_local7.C +++ b/gcc/testsuite/g++.dg/tls/thread_local7.C @@ -2,7 +2,7 @@ // { dg-require-effective-target tls } // The reference temp should be TLS, not normal data. -// { dg-final { scan-assembler-not "\\.data" { target tls_native } } } +// { dg-final { scan-assembler-not "\\.data" { target tls_native xfail powerpc-*-aix* } } } void f() { diff --git a/gcc/testsuite/g++.dg/tls/thread_local7g.C b/gcc/testsuite/g++.dg/tls/thread_local7g.C index fb847ce4a0..05c0878e86 100644 --- a/gcc/testsuite/g++.dg/tls/thread_local7g.C +++ b/gcc/testsuite/g++.dg/tls/thread_local7g.C @@ -2,7 +2,7 @@ // { dg-require-effective-target tls } // The reference temp should be TLS, not normal data. -// { dg-final { scan-assembler-not "\\.data" { target tls_native } } } +// { dg-final { scan-assembler-not "\\.data" { target tls_native xfail powerpc-*-aix* } } } thread_local int&& ir = 42; diff --git a/gcc/testsuite/g++.dg/tls/tls.exp b/gcc/testsuite/g++.dg/tls/tls.exp index 279fdfdcb7..dcce401287 100644 --- a/gcc/testsuite/g++.dg/tls/tls.exp +++ b/gcc/testsuite/g++.dg/tls/tls.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2014 Free Software Foundation, Inc. +# Copyright (C) 2002-2015 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -29,7 +29,7 @@ if ![info exists DEFAULT_CXXFLAGS] then { dg-init # Main loop. -g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] $DEFAULT_CXXFLAGS +g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] "" $DEFAULT_CXXFLAGS # All done. dg-finish diff --git a/gcc/testsuite/g++.dg/tm/pr47573.C b/gcc/testsuite/g++.dg/tm/pr47573.C index 239d9222e8..1fd26896c5 100644 --- a/gcc/testsuite/g++.dg/tm/pr47573.C +++ b/gcc/testsuite/g++.dg/tm/pr47573.C @@ -1,4 +1,7 @@ -// { dg-do compile } +// Without comdat support, we don't see the body of the +// extern template class constructor, so limit this to +// known comdat targets. +// { dg-do compile { target comdat_group } } // { dg-options "-fgnu-tm" } template<typename _Tp> class allocator diff --git a/gcc/testsuite/g++.dg/tm/pr47746.C b/gcc/testsuite/g++.dg/tm/pr47746.C index 7cd9e1006d..61082976e6 100644 --- a/gcc/testsuite/g++.dg/tm/pr47746.C +++ b/gcc/testsuite/g++.dg/tm/pr47746.C @@ -1,5 +1,6 @@ // { dg-do compile } // { dg-options "-fgnu-tm" } +/* { dg-add-options bind_pic_locally } */ class InputStream { diff --git a/gcc/testsuite/g++.dg/tm/pr51411-2.C b/gcc/testsuite/g++.dg/tm/pr51411-2.C index 4105d66ec9..3147d2f1d8 100644 --- a/gcc/testsuite/g++.dg/tm/pr51411-2.C +++ b/gcc/testsuite/g++.dg/tm/pr51411-2.C @@ -26,6 +26,7 @@ public: bool compare(const basic_string& __str) const { return 0; } + void key (); }; typedef basic_string<char> string; @@ -35,7 +36,7 @@ inline bool operator<(const basic_string<_CharT, _Traits>& __lhs, const basic_st return __lhs.compare(__rhs); } -extern template class basic_string<char>; +template class basic_string<char>; } diff --git a/gcc/testsuite/g++.dg/tm/pr51928.C b/gcc/testsuite/g++.dg/tm/pr51928.C index 22dbadd4bf..5ea0b0457a 100644 --- a/gcc/testsuite/g++.dg/tm/pr51928.C +++ b/gcc/testsuite/g++.dg/tm/pr51928.C @@ -1,7 +1,7 @@ /* { dg-do compile } */ /* { dg-options "-fgnu-tm" } */ -struct A; // { dg-error "forward declaration of 'struct A'" } +struct A; // { dg-message "forward declaration of 'struct A'" } struct B { diff --git a/gcc/testsuite/g++.dg/tm/tm.exp b/gcc/testsuite/g++.dg/tm/tm.exp index 1d1dc3c799..5b38a11df0 100644 --- a/gcc/testsuite/g++.dg/tm/tm.exp +++ b/gcc/testsuite/g++.dg/tm/tm.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2009-2014 Free Software Foundation, Inc. +# Copyright (C) 2009-2015 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -34,10 +34,10 @@ dg-init # Run the tests that are shared with C. g++-dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/tm/*.c]] \ - $DEFAULT_CXXFLAGS + "" $DEFAULT_CXXFLAGS # Run the C++ only tests. g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] \ - $DEFAULT_CXXFLAGS + "" $DEFAULT_CXXFLAGS # All done. dg-finish diff --git a/gcc/testsuite/g++.dg/torture/20141013.C b/gcc/testsuite/g++.dg/torture/20141013.C new file mode 100644 index 0000000000..82aacd6317 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/20141013.C @@ -0,0 +1,268 @@ +/* { dg-options "-fno-short-enums" } */ +enum +{ + _sch_isdigit = 0x0004, + _sch_ispunct = 0x0020, + _sch_isxdigit = 0x0100, + _sch_isidst = 0x0200, + _sch_isvsp = 0x0400, + _sch_isnvsp = 0x0800, + _sch_isalnum = _sch_isidst | _sch_isdigit, + _sch_iscppsp = _sch_isvsp | _sch_isnvsp, +}; +extern const unsigned short _sch_istable[256]; +typedef union tree_node *tree; +typedef const union tree_node *const_tree; +enum opt_code +{ + OPT_Warray_bounds = 240, + OPT_Wformat_ = 245, + OPT_Wintf_annotation = 368, + OPT_std_gnu__14 = 1311, +}; +enum tree_code +{ + TREE_LIST, + CONST_DECL, + ADDR_EXPR, + MAX_TREE_CODES +}; +enum tree_code_class +{ + tcc_type, +}; +enum tree_node_structure_enum +{ + TS_TYPED, + TS_COMMON, +}; +enum integer_type_kind +{ + itk_char, + itk_none +}; +struct tree_base +{ + enum tree_code code:16; +}; +struct tree_typed +{ + tree type; +}; +struct tree_common +{ + tree chain; +}; +struct tree_list +{ + tree purpose; +}; +struct tree_type_common +{ + tree main_variant; +}; +union tree_node +{ + struct tree_base base; + struct tree_typed typed; + struct tree_common common; + struct tree_type_common type_common; + struct tree_list list; +}; +extern unsigned char tree_contains_struct[MAX_TREE_CODES][64]; +extern tree integer_types[itk_none]; +extern void tree_contains_struct_check_failed (const_tree, + tree_node_structure_enum, + const char *, int, + const char *) + __attribute__ ((__noreturn__)); +inline tree +tree_check (tree __t, const char *__f, int __l, const char *__g, + tree_code __c) +{ +} + +inline const_tree +contains_struct_check (const_tree __t, + const enum tree_node_structure_enum __s, + const char *__f, int __l, const char *__g) +{ + if (tree_contains_struct[((enum tree_code) (__t)->base.code)][__s] != 1) + tree_contains_struct_check_failed (__t, __s, __f, __l, __g); +} + +inline const_tree +tree_class_check (const_tree __t, const enum tree_code_class __class, + const char *__f, int __l, const char *__g) +{ +} + +static inline bool +is_attribute_p (const char *attr_name, const_tree ident) +{ +} + +extern int integer_zerop (const_tree); +extern bool warning (int, const char *, ...) + __attribute__ ((__nonnull__ (2))); +extern void +check_function_arguments_recurse (void (*)(void *, tree, unsigned long long), + void *, tree, unsigned long long); +extern bool objc_string_ref_type_p (tree); +enum +{ + FMT_FLAG_SCANF_A_KLUDGE = 2, + FMT_FLAG_PARSE_ARG_CONVERT_EXTERNAL = 256 +}; +typedef struct +{ +} +format_flag_spec; +typedef struct +{ + int flags; + tree *width_type; +} +format_kind_info; +typedef struct alloc_pool_list_def +{ +} + *alloc_pool; +struct gcc_targetcm +{ + bool (*string_object_ref_type_p) (const_tree stringref); +} + ; +extern struct gcc_targetcm targetcm; +enum format_type +{ + gcc_objc_string_format_type, +}; +typedef struct function_format_info +{ + int format_type; +} +function_format_info; +static const format_kind_info format_types_orig[] = { }; +struct format_check_context { }; + +static const format_kind_info *format_types = format_types_orig; +static void check_format_info (function_format_info *, tree); +void check_format_arg (void *, tree, unsigned long long); + +void +check_function_format (tree attrs, int nargs, tree * argarray) +{ + tree a; + for (a = attrs; + a; + ((contains_struct_check + ((a), (TS_COMMON), "../../git-master/gcc/c-family/c-format.c", 1002, + __FUNCTION__))->common.chain)) + { + if (is_attribute_p + ("format", + ((tree_check + ((a), "../../git-master/gcc/c-family/c-format.c", 1004, + __FUNCTION__, (TREE_LIST)))->list.purpose))) + { + function_format_info info; + { + tree params = (tree) __null; + check_format_info (&info, params); + } + } + } +} + +static bool +avoid_dollar_number (const char *format) +{ + while ((_sch_istable[(*format) & 0xff] & (unsigned short) (_sch_isdigit))) + format++; + if (*format == '$') + { + warning (OPT_Wformat_, + "$ operand number used after format without operand number"); + } +} + +static void +check_format_info (function_format_info * info, tree params) +{ + format_check_context format_ctx; + unsigned long long arg_num; + tree format_tree; + check_function_arguments_recurse (check_format_arg, &format_ctx, + format_tree, arg_num); + const char *format_chars; + if (integer_zerop (format_tree)) + { + { + ((contains_struct_check + ((params), (TS_COMMON), + "../../git-master/gcc/c-family/c-format.c", 1444, + __FUNCTION__))->common.chain); + } + return; + } + if (((enum tree_code) (format_tree)->base.code) != ADDR_EXPR) + { + return; + } + if (format_types[info->format_type].flags & (int) + FMT_FLAG_PARSE_ARG_CONVERT_EXTERNAL) + { + bool objc_str = (info->format_type == gcc_objc_string_format_type); + if (((enum tree_code) (format_tree)->base.code) != CONST_DECL + || + !((objc_str + && + objc_string_ref_type_p (((contains_struct_check + ((format_tree), (TS_TYPED), + "../../git-master/gcc/c-family/c-format.c", + 1498, __FUNCTION__))->typed.type))) + || + (*targetcm.string_object_ref_type_p) ((const_tree) + ((contains_struct_check + ((format_tree), + (TS_TYPED), + "../../git-master/gcc/c-family/c-format.c", + 1500, + __FUNCTION__))->typed. + type)))) + { + } + } + { + } + if (((tree_class_check + ((((contains_struct_check + ((((contains_struct_check + ((format_tree), (TS_TYPED), + "../../git-master/gcc/c-family/c-format.c", 1549, + __FUNCTION__))->typed.type)), (TS_TYPED), + "../../git-master/gcc/c-family/c-format.c", 1549, + __FUNCTION__))->typed.type)), (tcc_type), + "../../git-master/gcc/c-family/c-format.c", 1549, + __FUNCTION__))->type_common.main_variant) != integer_types[itk_char]) + { + return; + } + { + } + const format_kind_info *fki = &format_types[info->format_type]; + while (*format_chars != 0) + { + { + if (fki->width_type != __null && *format_chars == '*') + { + { + if (avoid_dollar_number (format_chars)) + if (avoid_dollar_number (format_chars)) + return; + } + } + } + } +} diff --git a/gcc/testsuite/g++.dg/torture/Wsizeof-pointer-memaccess1.C b/gcc/testsuite/g++.dg/torture/Wsizeof-pointer-memaccess1.C index 6cb39809d6..8b5c33e24b 100644 --- a/gcc/testsuite/g++.dg/torture/Wsizeof-pointer-memaccess1.C +++ b/gcc/testsuite/g++.dg/torture/Wsizeof-pointer-memaccess1.C @@ -1,6 +1,6 @@ // Test -Wsizeof-pointer-memaccess warnings. // { dg-do compile } -// { dg-options "-Wall" } +// { dg-options "-Wall -Wno-sizeof-array-argument" } // Test just twice, once with -O0 non-fortified, once with -O2 fortified. // { dg-skip-if "" { *-*-* } { "*" } { "-O0" "-O2" } } // { dg-skip-if "" { *-*-* } { "-flto" } { "" } } diff --git a/gcc/testsuite/g++.dg/torture/Wsizeof-pointer-memaccess2.C b/gcc/testsuite/g++.dg/torture/Wsizeof-pointer-memaccess2.C index 9e2805d2b7..0e99568d3f 100644 --- a/gcc/testsuite/g++.dg/torture/Wsizeof-pointer-memaccess2.C +++ b/gcc/testsuite/g++.dg/torture/Wsizeof-pointer-memaccess2.C @@ -1,6 +1,6 @@ // Test -Wsizeof-pointer-memaccess warnings. // { dg-do compile } -// { dg-options "-Wall" } +// { dg-options "-Wall -Wno-sizeof-array-argument" } // Test just twice, once with -O0 non-fortified, once with -O2 fortified. // { dg-skip-if "" { *-*-* } { "*" } { "-O0" "-O2" } } // { dg-skip-if "" { *-*-* } { "-flto" } { "" } } diff --git a/gcc/testsuite/g++.dg/torture/dg-torture.exp b/gcc/testsuite/g++.dg/torture/dg-torture.exp index 7525e0408a..f42a6d21a3 100644 --- a/gcc/testsuite/g++.dg/torture/dg-torture.exp +++ b/gcc/testsuite/g++.dg/torture/dg-torture.exp @@ -3,5 +3,5 @@ load_lib g++-dg.exp dg-init -gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.C $srcdir/c-c++-common/torture/*.c]] "" +gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.C $srcdir/c-c++-common/torture/*.c]] "" "" dg-finish diff --git a/gcc/testsuite/g++.dg/torture/pr51344.C b/gcc/testsuite/g++.dg/torture/pr51344.C index 07be919c3c..e60b3adbe1 100644 --- a/gcc/testsuite/g++.dg/torture/pr51344.C +++ b/gcc/testsuite/g++.dg/torture/pr51344.C @@ -1,4 +1,4 @@ -/* { dg-do compile { target { i?86-*-* && ilp32 } } } */ +/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ class A; template <class T> diff --git a/gcc/testsuite/g++.dg/torture/pr59240.C b/gcc/testsuite/g++.dg/torture/pr59240.C new file mode 100644 index 0000000000..90d68c0f93 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr59240.C @@ -0,0 +1 @@ +static int foo __attribute__ ((__weakref__("foo"))); diff --git a/gcc/testsuite/g++.dg/torture/pr60871.C b/gcc/testsuite/g++.dg/torture/pr60871.C new file mode 100644 index 0000000000..902b9ee69d --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr60871.C @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +struct A +{ + virtual void m_fn1 (); + int m_local; +}; +class C : virtual public A +{ +}; +struct B +{ + A *m_g; + + B (A *p1) : m_g (p1) { m_g->m_fn1 (); } +}; +struct C7 +{ + virtual ~C7 (); +}; +class D : public C, C7 +{ +}; +struct F : D +{ + F (int); + + static void m_fn2 () + { + F a (0); + B b (&a); + } +}; +void fn1 () { F::m_fn2 (); } diff --git a/gcc/testsuite/g++.dg/torture/pr61482.C b/gcc/testsuite/g++.dg/torture/pr61482.C new file mode 100644 index 0000000000..1e186cc5ed --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr61482.C @@ -0,0 +1,29 @@ +// { dg-do compile } + +class A +{ +public: + int m_fn1 (); +}; +class B +{ + void m_fn2 (const int &p1); + A mThebesLayerDataStack; +}; +int b, c; +void B::m_fn2 (const int &p1) +{ + if (c && b) + { + int i; + i = mThebesLayerDataStack.m_fn1 (); + for (; i >= 0;) + { + ++i; + break; + } + --i; + for (; i >= 0; --i) + mThebesLayerDataStack.m_fn1 (); + } +} diff --git a/gcc/testsuite/g++.dg/torture/pr61554.C b/gcc/testsuite/g++.dg/torture/pr61554.C new file mode 100644 index 0000000000..6f609c8be0 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr61554.C @@ -0,0 +1,46 @@ +// { dg-do compile } + +struct A +{ + A (); +}; +const unsigned long &min (const unsigned long &, const unsigned long &) {} + +template <typename _InputIterator1, typename _InputIterator2, + typename _OutputIterator, typename _BinaryOperation> +void transform (_InputIterator1 p1, _InputIterator2, _OutputIterator, + _BinaryOperation p4) +{ + for (; p1;) + p4 (0, 0); +} + +class multi_array +{ +public: + multi_array (int &, int &); + int &resize_ranges; + int resize___trans_tmp_1; + void m_fn1 () + { + multi_array a (resize_ranges, this->m_fn2 ()); + const unsigned long &(*b)(const unsigned long &, const unsigned long &) + = min; + transform (&resize___trans_tmp_1, 0, 0, b); + A c; + } + ~multi_array () + { + for (int i; &base_;) + ; + } + int base_; + int &m_fn2 (); +}; + +class B +{ + void m_fn3 (const int &, const int &); + multi_array _bookingSnapshotBlock; +}; +void B::m_fn3 (const int &, const int &) { _bookingSnapshotBlock.m_fn1 (); } diff --git a/gcc/testsuite/g++.dg/torture/pr61558.C b/gcc/testsuite/g++.dg/torture/pr61558.C new file mode 100644 index 0000000000..1e398e9155 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr61558.C @@ -0,0 +1,6 @@ +// { dg-do compile } +static __typeof 0 a __attribute__ ((__weakref__ (""))); +template <typename> class A +{ + static __thread int b; +}; diff --git a/gcc/testsuite/g++.dg/torture/pr61848.C b/gcc/testsuite/g++.dg/torture/pr61848.C new file mode 100644 index 0000000000..beb490c754 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr61848.C @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target named_sections } */ +/* { dg-final { scan-assembler "mysection" } } */ +extern char foo; +char foo __attribute__ ((__section__(".mysection"))); diff --git a/gcc/testsuite/g++.dg/torture/pr62127.C b/gcc/testsuite/g++.dg/torture/pr62127.C new file mode 100644 index 0000000000..7b83a26441 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr62127.C @@ -0,0 +1,11 @@ +// { dg-do compile } +struct A +{ + A(int); +}; + +A::A(int i) +{ + int x[1][i]; + x[0][0] = 0; +} diff --git a/gcc/testsuite/g++.dg/torture/pr63237.C b/gcc/testsuite/g++.dg/torture/pr63237.C new file mode 100644 index 0000000000..d1eaadab04 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr63237.C @@ -0,0 +1,21 @@ +// { dg-do compile } + +class A { + int Length; +public: + A(const char *p1) { Length = __builtin_strlen(p1); } +}; +class B { +public: + void m_fn1(int, A); +}; +class C { +public: + B &m_fn2(); +}; +int a; +void RewriteMacrosInInput() { + C b; + B &c = b.m_fn2(); + c.m_fn1(0, &""[a]); +} diff --git a/gcc/testsuite/g++.dg/torture/pr63366.C b/gcc/testsuite/g++.dg/torture/pr63366.C new file mode 100644 index 0000000000..f08912324e --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr63366.C @@ -0,0 +1,10 @@ +// { dg-do run } +// { dg-options "-pedantic" } + +#include <typeinfo> + +int +main (void) +{ + return typeid (__complex) != typeid (__complex double); /* { dg-warning "ISO C\\+\\+ does not support plain 'complex' meaning 'double complex'" } */ +} diff --git a/gcc/testsuite/g++.dg/torture/pr63419.C b/gcc/testsuite/g++.dg/torture/pr63419.C new file mode 100644 index 0000000000..6d4c0745d4 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr63419.C @@ -0,0 +1,228 @@ +// { dg-do compile } +// { dg-additional-options "-Wno-psabi" } +// Ignore warning on some powerpc-linux configurations. +// { dg-prune-output "non-standard ABI extension" } + +typedef float __m128 __attribute__ ((__vector_size__ (16))); +const int a = 0; +enum +{ + ReadOnlyAccessors +}; +template <typename> struct traits; +struct A +{ + enum + { + value = 1 + }; +}; +template <typename> struct EigenBase; +template <typename> class J; +template <typename, int = A::value> class DenseCoeffsBase; +template <typename, int, int, int = 0, int = 0, int = 0> class K; +template <typename> class N; +template <typename, typename> class CwiseUnaryOp; +template <typename> class L; +template <typename> class P; +template <typename> struct B; +template <typename> struct C; +template <typename Derived> struct dense_xpr_base +{ + typedef N<Derived> type; +}; +template <typename Packet> void padd (Packet); +template <> struct C<float> +{ + typedef __m128 type; +}; +struct D +{ + void + packetOp (C<float>::type) + { + __m128 b = { m_other }; + padd (b); + } + float m_other; +}; +template <typename Derived> +class DenseCoeffsBase<Derived, ReadOnlyAccessors> : public EigenBase<Derived> +{ +public: + typedef typename C<typename traits<Derived>::Scalar>::type PacketScalar; +}; +template <typename Derived> +class DenseCoeffsBase<Derived> + : public DenseCoeffsBase<Derived, ReadOnlyAccessors> +{ +public: + template <typename OtherDerived, int, int LoadMode> + void + copyPacket (typename traits<Derived>::Index, J<OtherDerived> p2) + { + p2.derived ().template packet<LoadMode> (0); + } +}; +template <typename Derived> class J : public DenseCoeffsBase<Derived> +{ +public: + using DenseCoeffsBase<Derived>::derived; + template <typename OtherDerived> + Derived &lazyAssign (const J<OtherDerived> &); +}; +template <typename Derived> class N : public J<Derived> +{ +public: + template <typename OtherDerived> + typename B<OtherDerived>::Type operator*(N<OtherDerived>); + L<Derived> array (); +}; +template <typename Derived> struct EigenBase +{ + Derived + derived () const + { + return *static_cast<const Derived *> (this); + } +}; +template <typename Derived1, typename Derived2> struct F +{ + static void + run (Derived1 p1, Derived2 p2) + { + enum + { + srcAlignment + }; + for (;;) + p1.template copyPacket<Derived2, 0, srcAlignment> (0, p2); + } +}; +template <typename Derived> +template <typename OtherDerived> +Derived & +J<Derived>::lazyAssign (const J<OtherDerived> &p1) +{ + F<Derived, OtherDerived>::run (derived (), p1.derived ()); +} +template <typename Derived, typename OtherDerived> struct G +{ + static Derived + run (Derived p1, OtherDerived p2) + { + p1.lazyAssign (p2); + } +}; +class H +{ +public: + H (int, int, int); +}; +template <typename Derived> class M : public dense_xpr_base<Derived>::type +{ +public: + typedef typename traits<Derived>::Index Index; + H m_storage; + M (Index, Index, Index) : m_storage (0, 0, 0) {} + template <typename OtherDerived> + void + _set_noalias (J<OtherDerived> p1) + { + G<Derived, OtherDerived>::run (this->derived (), p1.derived ()); + } +}; +template <typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, + int _MaxCols> +struct traits<K<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > +{ + typedef _Scalar Scalar; + typedef int StorageKind; + typedef int Index; +}; +template <typename, int _Rows, int _Cols, int, int, int> +class K : public M<K<float, _Rows, _Cols> > +{ +public: + typedef M<K> Base; + typedef K Nested; + template <typename T0, typename T1> K (T0, T1); + template <typename OtherDerived> K (N<OtherDerived> p1) : Base (0, 0, 0) + { + Base::_set_noalias (p1); + } +}; +template <typename UnaryOp, typename XprType> +struct traits<CwiseUnaryOp<UnaryOp, XprType> > : traits<XprType> +{ +}; +template <typename, typename, typename> class I; +template <typename, typename XprType> +class CwiseUnaryOp + : public I<D, XprType, typename traits<XprType>::StorageKind> +{ +public: + D + functor () + { + return m_functor; + } + typename XprType::Nested nestedExpression (); + D m_functor; +}; +template <typename UnaryOp, typename XprType> +class I<UnaryOp, XprType, int> + : public dense_xpr_base<CwiseUnaryOp<UnaryOp, XprType> >::type +{ +public: + typedef CwiseUnaryOp<UnaryOp, XprType> Derived; + typedef typename dense_xpr_base<CwiseUnaryOp<UnaryOp, XprType> >::type Base; + typedef Derived Nested; + using Base::derived; + template <int LoadMode> void packet (typename traits<Derived>::Index) + { + derived ().functor ().packetOp ( + derived ().nestedExpression ().template packet<LoadMode> (0)); + } +}; +template <typename> struct B +{ + typedef P<CwiseUnaryOp<D, L<K<float, 0, 1> > > > Type; +}; +template <typename Derived> class O : public J<Derived> +{ +public: + P<Derived> matrix (); +}; +template <typename ExpressionType> +struct traits<L<ExpressionType> > : traits<typename ExpressionType::Nested> +{ +}; +template <typename ExpressionType> class L : public O<L<ExpressionType> > +{ +public: + typedef L Nested; + template <int> + typename O<L>::PacketScalar packet (typename traits<L>::Index); +}; +template <typename ExpressionType> +struct traits<P<ExpressionType> > : traits<typename ExpressionType::Nested> +{ +}; +template <typename ExpressionType> class P : public N<P<ExpressionType> > +{ +public: + N<P> Base; + template <int LoadMode> void packet (typename traits<P>::Index) + { + m_expression.template packet<LoadMode> (0); + } + ExpressionType m_expression; +}; +int +main () +{ + K<float, 0, a> m (0, 0); + K<float, 0, 1> c (0, 0); + c = m.array ().matrix () * m; +} diff --git a/gcc/testsuite/g++.dg/torture/pr63476.C b/gcc/testsuite/g++.dg/torture/pr63476.C new file mode 100644 index 0000000000..75ecc37406 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr63476.C @@ -0,0 +1,39 @@ +// { dg-do compile } +// { dg-additional-options "-std=gnu++11" } + +enum class nsresult; +class A; +class B +{ +public: + B (int); + A *operator->(); +}; +class C +{ +}; +class A +{ +public: + virtual nsresult AddObserver (const char *, C *, bool) = 0; +}; +class D : A +{ + nsresult + AddObserver (const char *p1, C *p2, bool p3) + { + AddObserver (p1, p2, p3); + } +}; +char *prefList[]{}; +class F : C +{ + nsresult Install (); +}; +nsresult +F::Install () +{ + B branch = 0; + for (int i;;) + branch->AddObserver (prefList[i], this, false); +} diff --git a/gcc/testsuite/g++.dg/torture/pr63512.C b/gcc/testsuite/g++.dg/torture/pr63512.C new file mode 100644 index 0000000000..954901443f --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr63512.C @@ -0,0 +1,46 @@ +// { dg-do compile } + +extern "C" { +void __assert_fail (); +unsigned long strlen (const char *); +} +class A +{ + int Data; + int Length; + +public: + A (const char *p1) : Data () + { + p1 ? void() : __assert_fail (); + Length = strlen (p1); + } +}; +enum TokenKind +{ + semi +}; +class B +{ +public: + void m_fn1 (); +}; +class C +{ + void m_fn2 (TokenKind, int, A); + struct D + { + D (int); + B Range; + }; + int *m_fn3 (const int &, int &, int **); +}; +int a, b; +int * +C::m_fn3 (const int &, int &, int **) +{ + D c (0); + if (a) + c.Range.m_fn1 (); + m_fn2 (semi, 0, b ? "" : a ? "alias declaration" : "using declaration"); +} diff --git a/gcc/testsuite/g++.dg/torture/pr64139.C b/gcc/testsuite/g++.dg/torture/pr64139.C new file mode 100644 index 0000000000..932a676d6a --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr64139.C @@ -0,0 +1,34 @@ +// { dg-do compile } +class IObject { +public: + virtual ~IObject(); +}; +class A { + virtual int m_fn1(); +}; +class B { +public: + virtual int m_fn2(B) const; +}; +class D : IObject, public virtual B {}; +class G : public D, A { +public: + G(A); +}; +class F : B { + friend class C; +}; +class C { + void m_fn3(const IObject &, int &); + void m_fn4(const B &, int &); +}; +A a; +void C::m_fn3(const IObject &, int &p2) { + G r(a); + m_fn4(r, p2); +} +void C::m_fn4(const B &p1, int &) { + F b; + p1.m_fn2(b); +} + diff --git a/gcc/testsuite/g++.dg/torture/pr64280.C b/gcc/testsuite/g++.dg/torture/pr64280.C new file mode 100644 index 0000000000..6ea31481bd --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr64280.C @@ -0,0 +1,42 @@ +// { dg-do compile } + +class A +{ +public: + A (); +}; +class B +{ +public: + B (int); + operator void *() { return m_fn1 () ? 0 : this; } + int m_fn1 (); +}; +typedef int jmp_buf[]; +struct C +{ + jmp_buf cond_; +}; +class F +{ + C what_; + bool m_fn2 (); +}; +int _setjmp (int[]); +void longjmp (); +class D +{ +public: + D () { longjmp (); } +}; +bool +F::m_fn2 () +{ + B a (0); + if (a) + if (_setjmp (what_.cond_)) + return 0; + else + D (); + A b; +} diff --git a/gcc/testsuite/g++.dg/torture/pr64282.C b/gcc/testsuite/g++.dg/torture/pr64282.C new file mode 100644 index 0000000000..48429884e9 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr64282.C @@ -0,0 +1,101 @@ +// { dg-do compile } +template <class _T1> struct A +{ + _T1 first; +}; +struct B +{ + int operator!=(B); +}; +template <typename _Tp> struct C +{ + C (B); + _Tp operator*(); + int operator!=(C); +}; +template <typename _Tp> class D +{ +public: + typedef C<_Tp> const_iterator; + const_iterator m_fn1 () const; + B m_fn2 (); + void m_fn3 (); +}; +class F +{ + struct G + { + static G & + m_fn5 () + { + void fn1 (); + return *reinterpret_cast<G *> (fn1); + } + int * + m_fn6 () + { + return reinterpret_cast<int *> (this); + } + }; + struct _Alloc_hider + { + _Alloc_hider (int *p1, int) : _M_p (p1) {} + int *_M_p; + } _M_dataplus; + G & + m_fn4 () + { + return G::m_fn5 (); + } +public: + F () : _M_dataplus (m_fn4 ().m_fn6 (), 0) {} +}; +class H +{ + void m_fn7 (const F &, bool &); + bool m_fn8 (const D<F> &, const F &, F &); +}; +typedef A<int> CandPair; +class I +{ +public: + virtual void m_fn9 (const F &, bool, D<CandPair> &); +}; +class J : I +{ +public: + void m_fn9 (const F &, bool, D<CandPair> &); +}; +D<I *> c; +void +J::m_fn9 (const F &, bool, D<CandPair> &) +{ + D<int> a; + for (B b; b != a.m_fn2 ();) + ; +} +inline void +fn2 (F p1, int, int, J *p4, D<CandPair>) +{ + D<CandPair> d; + d.m_fn3 (); + p4->m_fn9 (p1, 0, d); + for (D<I *>::const_iterator e = c.m_fn1 (); e != c.m_fn2 ();) + (*e)->m_fn9 (p1, 0, d); +} +void +H::m_fn7 (const F &, bool &) +{ + A<F> f; + D<F> g; + F h; + m_fn8 (g, f.first, h); +} +bool +H::m_fn8 (const D<F> &p1, const F &, F &) +{ + F i; + p1.m_fn1 (); + D<CandPair> j; + fn2 (i, 0, 0, 0, j); +} diff --git a/gcc/testsuite/g++.dg/torture/pr64312.C b/gcc/testsuite/g++.dg/torture/pr64312.C new file mode 100644 index 0000000000..dc3e95dbb9 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr64312.C @@ -0,0 +1,123 @@ +// { dg-do compile } + +template <typename C> struct A +{ + typedef typename C::iterator type; +}; +template <typename T2> struct B +{ + typedef T2 type; +}; +template <typename F2> struct L +{ + typedef typename B<F2>::type::type type; +}; +template <typename C> struct M +{ + typedef typename L<A<C> >::type type; +}; +class C +{ +public: + typedef int iterator; +}; +template <class IteratorT> class D +{ +public: + typedef IteratorT iterator; + template <class Iterator> D (Iterator p1, Iterator) : m_Begin (p1), m_End (0) + { + } + IteratorT m_Begin; + IteratorT m_End; +}; +template <class IteratorT> class I : public D<IteratorT> +{ +protected: + template <class Iterator> + I (Iterator p1, Iterator p2) + : D<IteratorT> (p1, p2) + { + } +}; +class F +{ +public: + int elems[]; + int * + m_fn1 () + { + return elems; + } +}; +class G +{ +public: + void * + m_fn2 (int) + { + return m_buffer.m_fn1 (); + } + F m_buffer; +}; +struct any_incrementable_iterator_interface +{ + virtual ~any_incrementable_iterator_interface () {} +}; +class J : public any_incrementable_iterator_interface +{ +public: + J (int) : m_it () {} + int m_it; +}; +void *operator new(__SIZE_TYPE__, void *p2) { return p2; } +template <class T> typename M<T>::type begin (T) { return 0; } +template <class T> typename M<T>::type end (T) {} +template <class> class any_iterator +{ +public: + template <class WrappedIterator> any_iterator (WrappedIterator) + { + void *ptr = m_buffer.m_fn2 (0); + m_impl = new (ptr) J (0); + } + ~any_iterator () + { + if (m_impl) + m_impl->~any_incrementable_iterator_interface (); + } + G m_buffer; + any_incrementable_iterator_interface *m_impl; +}; +template <class Reference> class K : public I<any_iterator<Reference> > +{ +public: + template <class WrappedRange> + K (WrappedRange p1) + : I<any_iterator<Reference> > (begin (p1), end (p1)) + { + } +}; +template <class Reference> struct H +{ + typedef K<Reference> type; +}; +template <class, class, class, class, class, class TargetReference> +void +mix_values_impl () +{ + C test_data; + H<int>::type source_data (test_data); + typename H<TargetReference>::type t2 = source_data; +} +template <class> +void +mix_values_driver () +{ + mix_values_impl<int, int, int, int, int, int &> (); +} +void +mix_values () +{ + mix_values_driver<int> (); +} diff --git a/gcc/testsuite/g++.dg/torture/pr64378.C b/gcc/testsuite/g++.dg/torture/pr64378.C new file mode 100644 index 0000000000..6770601eaf --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr64378.C @@ -0,0 +1,24 @@ +// { dg-do compile } +// { dg-options "-fno-ipa-cp" } +struct data { + data(int) {} +}; + +struct top { + virtual int topf() {} +}; + +struct child1: top { + void childf() + { + data d(topf()); + } +}; + +void test(top *t) +{ + child1 *c = static_cast<child1 *>(t); + c->childf(); + child1 d; + test(&d); +} diff --git a/gcc/testsuite/g++.dg/torture/pr64565.C b/gcc/testsuite/g++.dg/torture/pr64565.C new file mode 100644 index 0000000000..42b0239c52 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr64565.C @@ -0,0 +1,89 @@ +/* { dg-do compile } */ +typedef enum +{ + NS_OK +} nsresult; +struct A +{ + static int kIID; +}; +class B +{ +}; +class C +{ +public: + C (B p1) { m_fn1 (p1, A::kIID); } + void m_fn1 (B, int); +}; +class D; +class F +{ +public: + F (int); +}; +class G +{ +public: + D *operator[](int); +}; +class H +{ + virtual nsresult m_fn2 (); + +public: + void m_fn3 (); +}; +class J : H +{ + G mQueries; + int mLiveUpdate; + nsresult m_fn2 (); +}; +class D +{ +public: + nsresult m_fn4 (int); + void m_fn5 (int); +}; +class I +{ +public: + static I * + m_fn6 () + { + B __trans_tmp_3; + if (!gHistoryService) + C serv = __trans_tmp_3; + } + void m_fn7 (); + static I *gHistoryService; +}; +D *Refresh___trans_tmp_2; +D Refresh___trans_tmp_6, Refresh___trans_tmp_5; +int Refresh_hasDomain; +nsresult +J::m_fn2 () +{ + m_fn3 (); + I history = *I::m_fn6 (); + switch (mLiveUpdate) + { + case 1: + { + mQueries[0]; + F query = 0; + if (Refresh_hasDomain) + return NS_OK; + } + case 0: + { + Refresh___trans_tmp_2 = mQueries[0]; + F query = Refresh___trans_tmp_5.m_fn4 (0); + history.m_fn7 (); + Refresh___trans_tmp_6.m_fn5 (0); + } + case 3: + m_fn2 (); + } +} diff --git a/gcc/testsuite/g++.dg/torture/pr64568-2.C b/gcc/testsuite/g++.dg/torture/pr64568-2.C new file mode 100644 index 0000000000..0578217900 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr64568-2.C @@ -0,0 +1,146 @@ +// { dg-do compile } + +namespace std +{ + typedef __SIZE_TYPE__ size_t; +} +class H; +namespace std +{ + template <typename> struct complex; + template <typename _Tp> + complex<_Tp> operator+(complex<_Tp> &__x, complex<_Tp> __y) + { + complex<_Tp> a = __x; + a += __y; + return a; + } + template <> struct complex<double> + { + int + imag () + { + return __imag__ _M_value; + } + void operator+=(complex __z) { _M_value += _M_value; _M_value += __z.imag (); } + _Complex double _M_value; + }; +} +struct A +{ + typedef std::complex<double> &const_reference; +}; +class B +{ +public: + B (int); + std::complex<double> &operator[](int i) { return data_[i]; } + std::complex<double> *data_; +}; +struct C +{ + static std::complex<double> + apply (A::const_reference t1, std::complex<double> t2) + { + return t1 + t2; + } + typedef std::complex<double> result_type; +}; +template <class T1, class> struct D +{ + static void + apply (T1 t1, std::complex<double> t2) + { + t1 = t2; + } +}; +class ublas_expression +{ +public: + ~ublas_expression (); +}; +template <class> class F +{ +}; +template <class E> class matrix_expression : ublas_expression +{ +public: + E &operator()() {} +}; +class I : public F<int> +{ +public: + typedef int value_type; + I (int); +}; +template <class E1, class E2> matrix_expression<int> outer_prod (F<E1>, F<E2>); +template <class E1, class F> class J : public matrix_expression<J<E1, F> > +{ +public: + typedef typename F::result_type value_type; + value_type operator()(int i, int) + { + return F::apply (e1_ (i, 0), e2_ (0, 0)); + } + E1 e1_; + E1 e2_; +}; +template <class E1, class E2> +J<H, C> operator+(matrix_expression<E1>, matrix_expression<E2>); +template <template <class, class> class F, class M, class E> +void +indexing_matrix_assign (M m, matrix_expression<E> e, int) +{ + for (int i; i; ++i) + F<typename M::reference, typename E::value_type>::apply (m (0, 0), + e ()(i, 0)); +} +template <template <class, class> class F, class, class M, class E, class C> +void +matrix_assign (M m, matrix_expression<E> e, int, C) +{ + indexing_matrix_assign<F> (m, e, 0); +} +template <template <class, class> class F, class M, class E> +void +matrix_assign (M m, matrix_expression<E> e) +{ + matrix_assign<F, int> (m, e, 0, typename M::orientation_category ()); +} +class H : matrix_expression<int> +{ +public: + typedef std::complex<double> &reference; + typedef int orientation_category; + H (int, int) : data_ (0) {} + template <class AE> H (matrix_expression<AE> ae) : data_ (0) + { + matrix_assign<D> (*this, ae); + } + B & + data () + { + } + std::complex<double> &operator()(int i, int) { return data ()[i]; } + void operator+=(matrix_expression ae) { H (*this + ae); } + B data_; +}; +template <class M, class T, class V1, class V2> +void +sr2 (M m, T, V1 v1, V2 v2) +{ + m += outer_prod (v2, v1); +} +template <class, class, std::size_t> struct G +{ + void test (); +}; +template struct G<I, H, 3>; +template <class V, class M, std::size_t N> +void +G<V, M, N>::test () +{ + V b (0), c (0); + M m (0, 0); + sr2 (m, typename V::value_type (), b, c); +} diff --git a/gcc/testsuite/g++.dg/torture/pr64568.C b/gcc/testsuite/g++.dg/torture/pr64568.C new file mode 100644 index 0000000000..15a89df449 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr64568.C @@ -0,0 +1,111 @@ +// { dg-do compile } +// { dg-additional-options "-std=c++11" } + +namespace std +{ +typedef long unsigned size_t; +template <typename> class complex; +template <typename _Tp> complex<_Tp> operator+(complex<_Tp>, complex<_Tp>) +{ + complex<_Tp> a = 0; + a += 0; + return a; +} +template <> struct complex<double> +{ + complex (int __i) : _M_value{ __i } {} + int imag (); + void operator+=(complex __z) { _M_value = __z.imag (); } + _Complex double _M_value; +}; +} +class A +{ +public: + A (int); + std::complex<double> &operator[](int i) { return data_[i]; } + std::complex<double> *data_; +}; +struct B +{ + static std::complex<double> + apply (std::complex<double> t1, std::complex<double> t2) + { + return t1 + t2; + } +}; +template <class T1, class> struct C +{ + static void + apply (T1 t1, std::complex<double> t2) + { + t1 = t2; + } +}; +template <class E> class D +{ +public: + E operator()(); +}; +class G : public D<G> +{ +public: + typedef std::complex<double> value_type; + value_type operator()(int) { return B::apply (0, 0); } +}; +template <class E1, class E2> G operator+(D<E1>, D<E2>); +template <template <class, class> class F, class V, class E> +void +indexing_vector_assign (V v, D<E> e) +{ + for (int i;; ++i) + F<typename V::reference, typename E::value_type>::apply (v (i), e ()(0)); +} +template <template <class, class> class F, class V, class E> +void +vector_assign (V v, D<E> e, int) +{ + indexing_vector_assign<F> (v, e); +} +template <template <class, class> class F, class V, class E> +void +vector_assign (V v, D<E> e) +{ + vector_assign<F> (v, e, typename V::storage_category ()); +} +class H : public D<int> +{ +public: + typedef std::complex<double> &reference; + typedef int storage_category; + H (int); + template <class AE> H (D<AE> ae) : data_ (0) + { + vector_assign<C> (*this, ae); + } + A + data () + { + return data_; + } + reference operator()(int i) { return data ()[i]; } + A data_; +}; +template <class T1, class V1, class T2, class V2> +void +rot (T1, V1 v1, T2, V2 v2) +{ + H (v1 + v2); +} +template <class, unsigned long> struct F +{ + void test (); +}; +template struct F<H, 3>; +template <class V, std::size_t N> +void +F<V, N>::test () +{ + V b (0), c (0); + rot (0, b, 0, c); +} diff --git a/gcc/testsuite/g++.dg/torture/pr64669.C b/gcc/testsuite/g++.dg/torture/pr64669.C new file mode 100644 index 0000000000..b207739e6d --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr64669.C @@ -0,0 +1,63 @@ +typedef unsigned int source_location; +typedef source_location location_t; +extern void error_at (location_t, const char *, ...) + __attribute__ ((__format__ (__gcc_tdiag__, 2, 3))) + __attribute__ ((__nonnull__ (2))); + +class Lex +{ + static int fetch_char (const char *str, unsigned int *value); + location_t location () const; + const char *advance_one_utf8_char (const char *, unsigned int *, bool *); + const char *advance_one_char (const char *, bool, unsigned int *, bool *); + int lineoff_; + int lineno_; +}; + +int +Lex::fetch_char (const char *p, unsigned int *value) +{ + unsigned char c = *p; + if (c <= 0x7f) + { + return 1; + } + else if ((c & 0xe0) == 0xc0 && (p[1] & 0xc0) == 0x80) + { + *value = (((c & 0x1f) << 6) + (p[1] & 0x3f)); + } + { + *value = (((c & 0xf) << 12) + (p[2] & 0x3f)); + } +} + +const char * +Lex::advance_one_utf8_char (const char *p, unsigned int *value, + bool * issued_error) +{ + *issued_error = false; + if (*p == '\0') + { + *issued_error = true; + return p + 1; + } + int adv = Lex::fetch_char (p, value); + if (*value == 0xfeff && (this->lineno_ != 1 || this->lineoff_ != 0)) + { + *issued_error = true; + } + return p + adv; +} + +const char * +Lex::advance_one_char (const char *p, bool is_single_quote, + unsigned int *value, bool * is_character) +{ + { + bool issued_error; + const char *ret = this->advance_one_utf8_char (p, value, &issued_error); + if (is_single_quote + && (*value == '\'' || *value == '\n') && !issued_error) + error_at (this->location (), "invalid character literal"); + } +} diff --git a/gcc/testsuite/g++.dg/torture/pr64686.C b/gcc/testsuite/g++.dg/torture/pr64686.C new file mode 100644 index 0000000000..714aa4100c --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr64686.C @@ -0,0 +1,19 @@ +// { dg-do compile } +class A +{ +protected: + A *m_fn2 (int) const; +public: + virtual A *m_fn1 (int *) const = 0; +}; +class B : A +{ + B (A *, int, A *); + A *m_fn1 (int *) const; +}; +A * +B::m_fn1 (int *) const +{ + new B (m_fn2 (0)->m_fn1 (0), 0, m_fn2 (0)->m_fn1 (0)); +} + diff --git a/gcc/testsuite/g++.dg/torture/pr64978.C b/gcc/testsuite/g++.dg/torture/pr64978.C new file mode 100644 index 0000000000..a9ac49f8e1 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr64978.C @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +class A { +public: + A(int, int); +}; +class B { +public: + void m_fn1(bool, const int *, int &); + unsigned m_fn2(); +}; +namespace { +class C { + B &VTables; + void m_fn3(A, unsigned, const int *, int &); + +public: + int VFTableBuilder_VisitedBases; + B VFTableBuilder_VTables; + C() : VTables(VFTableBuilder_VTables) { + m_fn3(A(0, 0), 0, 0, VFTableBuilder_VisitedBases); + } +}; +} +int a; +void C::m_fn3(A, unsigned, const int *, int &) { + for (;;) + 1 ? VTables.m_fn2() : 0; +} +void B::m_fn1(bool, const int *, int &) { C(); } +unsigned B::m_fn2() { m_fn1(0, 0, a); } diff --git a/gcc/testsuite/g++.dg/torture/pr64988.C b/gcc/testsuite/g++.dg/torture/pr64988.C new file mode 100644 index 0000000000..b9cf0e004f --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr64988.C @@ -0,0 +1,12 @@ +// { dg-do compile } +// { dg-options "-O -fdeclone-ctor-dtor" } +struct A { + virtual ~ A (); +}; + +struct B : virtual A {}; +struct C : virtual A {}; + +struct D : B, C {}; + +D d; diff --git a/gcc/testsuite/g++.dg/torture/pr64995.C b/gcc/testsuite/g++.dg/torture/pr64995.C new file mode 100644 index 0000000000..f5b97cf371 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr64995.C @@ -0,0 +1,28 @@ +// { dg-do compile } + +extern "C" double acos(double); +class A { +public: + double mY, mZ; + A(double, double); + double m_fn1(A *); + int *m_fn2(); +}; +double a; +A *b; +A::A(double, double) : mY(), mZ() {} + +double A::m_fn1(A *) { return mY * mZ; } + +inline int *A::m_fn2() { + mZ = 0; + double c = m_fn1(this); + a = acos(c); + double d = m_fn1(b); + acos(d); +} + +void passTime() { + A e(0, 1); + e.m_fn2(); +} diff --git a/gcc/testsuite/g++.dg/torture/pr65249.C b/gcc/testsuite/g++.dg/torture/pr65249.C new file mode 100644 index 0000000000..980d506bee --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr65249.C @@ -0,0 +1,54 @@ +// { dg-do compile } +// { dg-additional-options "-fPIC -fstack-protector-strong" { target fpic } } +// { dg-require-effective-target fstack_protector } + +struct struct0 +{ + struct0 (void(*)()); +}; + +int func5 (int* ptr); +void func3 (int*, struct0*); + +inline void +func4 (int* a, void (*b)()) +{ + if (func5 (a) != 2) + { + struct0 f (b); + func3(a, &f); + } +} + +struct struct1 +{ + const void* val0; + const void* val1; +}; + +void* func3 (const void*); + +static const void* gvar1 = 0; +static const void* gvar2 = 0; +static int gvar0 = 0; + +void +func0 (void) +{ + gvar2 = func3 (gvar1); +} + +inline void +func1 (void) +{ + func4 (&gvar0, &func0); +} + +struct1 func2 (void) +{ + func1 (); + struct1 s; + s.val0 = gvar1; + s.val1 = gvar2; + return s; +} diff --git a/gcc/testsuite/g++.dg/torture/pr65555.C b/gcc/testsuite/g++.dg/torture/pr65555.C new file mode 100644 index 0000000000..9027c69567 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr65555.C @@ -0,0 +1,11 @@ +// { dg-do compile } + +class basic_ostream { +public: + basic_ostream &operator<<(basic_ostream &p1(basic_ostream &)) { + return p1(*this); + } +} a; +void fn1() __attribute__((__noreturn__)); +basic_ostream &fn2(basic_ostream &) { fn1(); } +void fn3() { a << fn2; } diff --git a/gcc/testsuite/g++.dg/torture/pr65600.C b/gcc/testsuite/g++.dg/torture/pr65600.C new file mode 100644 index 0000000000..2ee5a4bf55 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr65600.C @@ -0,0 +1,28 @@ +// { dg-do compile } +// { dg-options "-std=c++11" } +class A { +public: + virtual void m_fn1() {} + int weak_release___trans_tmp_1; + void m_fn2() { + __asm__("\n\n\n\n"); + if (weak_release___trans_tmp_1) + m_fn1(); + } +}; +class weak_count { + A *pi_; + +public: + weak_count() : pi_() {} + ~weak_count() { + if (pi_) + pi_->m_fn2(); + } +}; +class B { + weak_count pn; +}; +int +main() { B a; } + diff --git a/gcc/testsuite/g++.dg/torture/pr65626.C b/gcc/testsuite/g++.dg/torture/pr65626.C new file mode 100644 index 0000000000..ed85ba9383 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr65626.C @@ -0,0 +1,19 @@ +// { dg-do compile } + +class A { + virtual unsigned long m_fn1() const; + virtual int &m_fn2(unsigned long) const; +}; +class C : A { +public: + int &m_fn2(unsigned long) const; + unsigned long m_fn1() const; +}; +class B { + void m_fn3(const A &, const int &, const C &, int &) const; +}; +void B::m_fn3(const A &, const int &, const C &, int &) const { + C &a(a); + for (long b = 0; a.m_fn1(); b++) + a.m_fn2(0); +} diff --git a/gcc/testsuite/g++.dg/torture/pr65655.C b/gcc/testsuite/g++.dg/torture/pr65655.C new file mode 100644 index 0000000000..7db385d384 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr65655.C @@ -0,0 +1,51 @@ +/* { dg-do compile } */ +// { dg-additional-options "-std=c++11 -fsanitize=undefined -O2" } +class ECoordinate { }; +class EPoint { +public: + inline ECoordinate & y (); +}; +ECoordinate & EPoint::y () { } +template < class KEY, class CONTENT > class AVLTree; +template < class KEY, class CONTENT > class AVLTreeNode { + friend class + AVLTree < KEY, CONTENT >; + KEY key; + void set_rthread (unsigned char b); + void set_lthread (unsigned char b); +}; +template < class KEY, class CONTENT > class AVLTree { +public: + AVLTree (); + void insert (const KEY & key, const CONTENT & c); +AVLTreeNode < KEY, CONTENT > *root; + const KEY * _target_key; + virtual int compare (const KEY & k1, const KEY & k2) const; + void _add (AVLTreeNode < KEY, CONTENT > *&t); + virtual void _status (unsigned int) { } +}; +template < class KEY, class CONTENT > void AVLTree < KEY, CONTENT >::_add (AVLTreeNode < KEY, CONTENT > *&t) { + int cmp = compare (*_target_key, t->key); + if (cmp == 0) + { _status (1); } +} +template < class KEY, class CONTENT > void AVLTree < KEY, CONTENT >::insert (const KEY & key, const CONTENT & c) { + if (root == 0) { + root->set_rthread (1); + root->set_lthread (1); + } +else { _target_key = &key; _add (root); } +} +template < class KEY, class CONTENT > AVLTree < KEY, CONTENT >::AVLTree () +: root (0) { } +class ContactRepository { + void insertContact (EPoint & pt, int val); +}; +void ContactRepository::insertContact (EPoint & pt, int val) { + AVLTreeNode < ECoordinate, AVLTree < ECoordinate, int >*>*cont_x_node; + if (cont_x_node == __null) + { + AVLTree < ECoordinate, int >*insert_tree = new AVLTree < ECoordinate, int >; + insert_tree->insert (pt.y (), val); + } +} diff --git a/gcc/testsuite/g++.dg/torture/pr65694.C b/gcc/testsuite/g++.dg/torture/pr65694.C new file mode 100644 index 0000000000..55e009a316 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr65694.C @@ -0,0 +1,144 @@ +/* { dg-do compile } */ +/* { dg-options "-Wno-sign-compare -Wno-return-type -Wno-overflow" } */ +/* { dg-additional-options "-mthumb" { target arm_thumb2_ok } } */ + +struct A { + enum { __value }; +}; +template <class _T1> struct B { _T1 first; }; +template <typename _Iterator, bool> struct C { + typedef typename _Iterator::iterator_type iterator_type; + static iterator_type _S_base(_Iterator p1) { return p1.base(); } +}; +template <typename _RandomAccessIterator> +typename _RandomAccessIterator::difference_type +__distance(_RandomAccessIterator p1, _RandomAccessIterator p2, int) { + return p2 - p1; +} + +template <typename _InputIterator> +typename _InputIterator::difference_type distance(_InputIterator p1, + _InputIterator p2) { + return __distance(p1, p2, 0); +} + +template <typename _Iterator, typename> class D { + _Iterator _M_current; + +public: + typedef _Iterator iterator_type; + typedef int difference_type; + _Iterator base() { return _M_current; } +}; + +template <typename _Iterator, typename _Container> +typename D<_Iterator, _Container>::difference_type +operator-(D<_Iterator, _Container> p1, D<_Iterator, _Container> p2) { + return p1.base() - p2.base(); +} + +struct F { + static unsigned short *__copy_m(unsigned short *p1, unsigned short *p2, + unsigned short *p3) { + int a = p2 - p1; + if (a) + __builtin_memmove(p3, p1, a); + return p3 + a; + } +}; +class G { +public: + void allocate(int p1) { + if (p1 > max_size()) + operator new(sizeof(short)); + } + unsigned max_size() { return -1 / sizeof(short); } +}; + +template <typename> class L : public G {}; + +struct H { + static unsigned short *allocate(int p1) { + L<short> d; + d.allocate(p1); + } +}; +struct I { + template <typename _InputIterator, typename _ForwardIterator> + static _ForwardIterator __uninit_copy(_InputIterator p1, _InputIterator p2, + _ForwardIterator p3) { + return copy(p1, p2, p3); + } +}; +struct J { + typedef unsigned short *pointer; + struct K { + unsigned short *_M_start; + unsigned short *_M_finish; + }; + J(); + J(int p1, int) { _M_create_storage(p1); } + K _M_impl; + pointer _M_allocate(unsigned p1) { p1 ? H::allocate(p1) : pointer(); } + void _M_create_storage(int p1) { _M_allocate(p1); } +}; + +C<D<unsigned short *, int>, 1>::iterator_type +__miter_base(D<unsigned short *, int> p1) { + return C<D<unsigned short *, int>, 1>::_S_base(p1); +} + +template <bool, typename _II, typename _OI> +_OI __copy_move_a(_II p1, _II p2, _OI p3) { + return F::__copy_m(p1, p2, p3); +} + +template <bool _IsMove, typename _II, typename _OI> +_OI __copy_move_a2(_II p1, _II p2, _OI p3) { + return __copy_move_a<_IsMove>(p1, p2, p3); +} + +template <typename _II, typename _OI> _OI copy(_II p1, _II p2, _OI p3) { + C<D<unsigned short *, int>, 1>::iterator_type b, c = __miter_base(p1); + b = __miter_base(p2); + return __copy_move_a2<A::__value>(c, b, p3); +} + +template <typename _InputIterator, typename _ForwardIterator> +_ForwardIterator uninitialized_copy(_InputIterator p1, _InputIterator p2, + _ForwardIterator p3) { + return I::__uninit_copy(p1, p2, p3); +} + +template <typename _InputIterator, typename _ForwardIterator, typename _Tp> +_ForwardIterator __uninitialized_copy_a(_InputIterator p1, _InputIterator p2, + _ForwardIterator p3, L<_Tp>) { + return uninitialized_copy(p1, p2, p3); +} + +class M : J { + J _Base; + +public: + M(); + M(int p1, int p2 = int()) : _Base(p1, p2) {} + M(D<unsigned short *, int> p1, D<unsigned short *, int> p2) { + _M_initialize_dispatch(p1, p2, int()); + } + D<pointer, int> begin(); + D<pointer, int> end(); + int size() { return _M_impl._M_finish - _M_impl._M_start; } + void _M_initialize_dispatch(D<unsigned short *, int> p1, + D<unsigned short *, int> p2, int) { + L<short> e; + int f = distance(p1, p2); + _M_impl._M_start = _M_allocate(f); + _M_impl._M_finish = __uninitialized_copy_a(p1, p2, _M_impl._M_start, e); + } +}; + +B<M> g, h; +void twoMeans() { + M i(g.first.begin(), h.first.end()); + M(i.size()); +} diff --git a/gcc/testsuite/g++.dg/torture/pr65747.C b/gcc/testsuite/g++.dg/torture/pr65747.C new file mode 100644 index 0000000000..a556db5aff --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr65747.C @@ -0,0 +1,48 @@ +// PR tree-optimization/65747 +// { dg-do compile } + +struct A {}; +struct E { + virtual A m2(); +} *a; +struct B { + char b[sizeof (E)]; + void m1(); +}; +struct C { + B c; + void m3() { c.m1(); } + friend class D; +}; +struct D { + int m4(C); + void m5(); + void m6(int, C); + void m7(int, C); + void m8(); + bool m9(); + void m10(int); + void m11(int); +}; +void B::m1() { a = (E *)b; a->m2(); } +void D::m10(int) { m8(); } +void D::m11(int) { m8(); } +int D::m4(C p1) { p1.m3(); return 0; } +void D::m6(int, C p2) { + int b = 0; + if (m9()) { + m4(p2); + m10(b); + } else + m5(); + m10(int()); +} +void D::m7(int, C p2) { + int c = 0; + if (m9()) { + m4(p2); + m11(c); + } else + m5(); + m11(int()); +} diff --git a/gcc/testsuite/g++.dg/torture/stackalign/stackalign.exp b/gcc/testsuite/g++.dg/torture/stackalign/stackalign.exp index ad08fc08a3..e1d9eb027a 100644 --- a/gcc/testsuite/g++.dg/torture/stackalign/stackalign.exp +++ b/gcc/testsuite/g++.dg/torture/stackalign/stackalign.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2008-2014 Free Software Foundation, Inc. +# Copyright (C) 2008-2015 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -51,7 +51,7 @@ if { [check_effective_target_fpic] } then { # Combine stackalign options with the usual torture optimization flags. set-torture-options [concat $DG_TORTURE_OPTIONS $LTO_TORTURE_OPTIONS] $stackalign_options -gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.C]] "$default_flags" +gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.C]] "" "$default_flags" torture-finish dg-finish diff --git a/gcc/testsuite/g++.dg/tree-prof/morefunc.C b/gcc/testsuite/g++.dg/tree-prof/morefunc.C new file mode 100644 index 0000000000..722b4b00f1 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-prof/morefunc.C @@ -0,0 +1,55 @@ +/* { dg-options "-O2 -fno-devirtualize --param=profile-func-internal-id=0 -fdump-ipa-profile -Wno-attributes -Wno-coverage-mismatch" } */ +#include "reorder_class1.h" +#include "reorder_class2.h" + +int g; + +#ifdef _PROFILE_USE +/* Another function not existing + * in profile-gen */ + +__attribute__((noinline)) void +new_func (int i) +{ + g += i; +} +#endif + +static __attribute__((always_inline)) +void test1 (A *tc) +{ + int i; + for (i = 0; i < 1000; i++) + g += tc->foo(); + if (g<100) g++; +} + +static __attribute__((always_inline)) +void test2 (B *tc) +{ + int i; + for (i = 0; i < 1000; i++) + g += tc->foo(); +} + + +__attribute__((noinline)) void test_a(A *ap) { test1 (ap); } +__attribute__((noinline)) void test_b(B *bp) { test2 (bp); } + + +int main() +{ + A* ap = new A(); + B* bp = new B(); + + test_a(ap); + test_b(bp); + +#ifdef _PROFILE_USE + new_func(10); +#endif + +} + +/* { dg-final-use { scan-ipa-dump-times "Indirect call -> direct call" 2 "profile" } } */ +/* { dg-final-use { cleanup-ipa-dump "profile" } } */ diff --git a/gcc/testsuite/g++.dg/tree-prof/pr35545.C b/gcc/testsuite/g++.dg/tree-prof/pr35545.C new file mode 100644 index 0000000000..4e84413c56 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-prof/pr35545.C @@ -0,0 +1,52 @@ +// devirt.cc +/* { dg-options "-O2 -fdump-ipa-profile_estimate -fdump-tree-optimized" } */ + +class A { +public: + virtual int foo() { + return 1; + } + +int i; +}; + +class B : public A +{ +public: + virtual int foo() { + return 2; + } + + int b; +} ; + + +int main() +{ + int i; + + A* ap = 0; + + for (i = 0; i < 10000; i++) + { + + if (i%7==0) + { + ap = new A(); + } + else + ap = new B(); + + ap->foo(); + + delete ap; + + } + + return 0; + +} +/* { dg-final-use { scan-ipa-dump "Indirect call -> direct call" "profile_estimate" } } */ +/* { dg-final-use { cleanup-ipa-dump "profile_estimate" } } */ +/* { dg-final-use { scan-tree-dump-not "OBJ_TYPE_REF" "optimized" } } */ +/* { dg-final-use { cleanup-tree-dump "optimized" } } */ diff --git a/gcc/testsuite/g++.dg/tree-prof/pr63581.C b/gcc/testsuite/g++.dg/tree-prof/pr63581.C new file mode 100644 index 0000000000..c8caf07658 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-prof/pr63581.C @@ -0,0 +1,91 @@ +// { dg-require-effective-target freorder } +/* { dg-options "-O2 -g -fno-peel-loops" } */ + +struct page { + int i; +} global; + +__attribute__((noinline)) static struct page* find_page1 (int i) +{ + if ( i< 150) + return 0; + global.i = i; + return &global; +} + +__attribute__((noinline)) static struct page* find_page2 (int i) +{ + global.i = i; + return &global; +} + +volatile int ii; +__attribute__((noinline)) static int zero (void) +{ + return ii; +} + +static inline int uptodate (struct page* p) +{ + return (p->i < 709); +} + +static struct page* bar(int i) +{ + struct page *page; + +repeat: + page = find_page1 (i); + if (!page) { + page = find_page2 (i); + if (!page) + return 0; + if (zero () ) { + zero (); + goto repeat; + } + } + return page; +} + +__attribute__((noinline)) int foo (int n) +{ + struct page *page; + +retry: + page = bar (n); + if (page == 0) + return 0; + if (uptodate (page)) + goto out; + + zero (); + if (page->i < 0) { + zero (); + goto retry; + } +out: + return 1; +} + +__attribute__((noinline)) int hot (void) +{ + int i; + int sum = 0; + + for (i = 0; i < 433038; i++) + sum+=i; + + return sum; +} + +int main(void) +{ + int i; + + global.i = hot (); + for (i = 0; i < 858; i++) + foo (i); + + return 0; +} diff --git a/gcc/testsuite/g++.dg/tree-prof/reorder.C b/gcc/testsuite/g++.dg/tree-prof/reorder.C new file mode 100644 index 0000000000..41d6a15944 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-prof/reorder.C @@ -0,0 +1,48 @@ +/* { dg-options "-O2 -fno-devirtualize --param=profile-func-internal-id=0 -fdump-ipa-profile -Wno-coverage-mismatch -Wno-attributes" } */ + +#ifdef _PROFILE_USE +#include "reorder_class1.h" +#include "reorder_class2.h" +#else +#include "reorder_class2.h" +#include "reorder_class1.h" +#endif + +int g; +static __attribute__((always_inline)) +void test1 (A *tc) +{ + int i; + for (i = 0; i < 1000; i++) + g += tc->foo(); + if (g<100) g++; +} + +static __attribute__((always_inline)) +void test2 (B *tc) +{ + int i; + for (i = 0; i < 1000; i++) + g += tc->foo(); +} + + +#ifdef _PROFILE_USE +__attribute__((noinline)) void test_a(A *ap) { test1 (ap); } +__attribute__((noinline)) void test_b(B *bp) { test2 (bp); } +#else +__attribute__((noinline)) void test_b(B *bp) { test2 (bp); } +__attribute__((noinline)) void test_a(A *ap) { test1 (ap); } +#endif + +int main() +{ + A* ap = new A(); + B* bp = new B(); + + test_a(ap); + test_b(bp); +} + +/* { dg-final-use { scan-ipa-dump-times "Indirect call -> direct call" 2 "profile" } } */ +/* { dg-final-use { cleanup-ipa-dump "profile" } } */ diff --git a/gcc/testsuite/g++.dg/tree-prof/reorder_class1.h b/gcc/testsuite/g++.dg/tree-prof/reorder_class1.h new file mode 100644 index 0000000000..62a1e923c7 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-prof/reorder_class1.h @@ -0,0 +1,11 @@ +struct A { + virtual int foo(); +}; + +int A::foo() +{ + return 1; +} + + + diff --git a/gcc/testsuite/g++.dg/tree-prof/reorder_class2.h b/gcc/testsuite/g++.dg/tree-prof/reorder_class2.h new file mode 100644 index 0000000000..ee3ed109b9 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-prof/reorder_class2.h @@ -0,0 +1,12 @@ + +struct B { + virtual int foo(); +}; + +int B::foo() +{ + return 2; +} + + + diff --git a/gcc/testsuite/g++.dg/tree-prof/tree-prof.exp b/gcc/testsuite/g++.dg/tree-prof/tree-prof.exp index 2c96ee38c1..ce853c2965 100644 --- a/gcc/testsuite/g++.dg/tree-prof/tree-prof.exp +++ b/gcc/testsuite/g++.dg/tree-prof/tree-prof.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2014 Free Software Foundation, Inc. +# Copyright (C) 2001-2015 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -42,8 +42,8 @@ set PROFOPT_OPTIONS [list {}] # These are globals used by profopt-execute. The first is options # needed to generate profile data, the second is options to use the # profile data. -set profile_option "-fprofile-generate" -set feedback_option "-fprofile-use" +set profile_option "-fprofile-generate -D_PROFILE_GENERATE" +set feedback_option "-fprofile-use -D_PROFILE_USE" foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.C]] { # If we're only testing specific files and this isn't one of them, skip it. diff --git a/gcc/testsuite/g++.dg/tree-ssa/calloc.C b/gcc/testsuite/g++.dg/tree-ssa/calloc.C new file mode 100644 index 0000000000..818ca41375 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/calloc.C @@ -0,0 +1,50 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-tree-optimized" } */ + +typedef __SIZE_TYPE__ size_t; +inline void* operator new(size_t, void* p) throw() { return p; } + +typedef void (*handler_t)(void); +extern handler_t get_handle(); + +inline void* operator new(size_t sz) +{ + void *p; + + if (sz == 0) + sz = 1; + + while ((p = __builtin_malloc (sz)) == 0) + { + handler_t handler = get_handle (); + if (! handler) + throw 42; + handler (); + } + return p; +} + +struct vect { + int *start, *end; + vect(size_t n) { + start = end = 0; + if (n > (size_t)-1 / sizeof(int)) + throw 33; + if (n != 0) + start = static_cast<int*> (operator new (n * sizeof(int))); + end = start + n; + int *p = start; + for (size_t l = n; l > 0; --l, ++p) + *p = 0; + } +}; + +void f (void *p, int n) +{ + new (p) vect(n); +} + +/* { dg-final { scan-tree-dump-times "calloc" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-not "malloc" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "memset" "optimized" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc/testsuite/g++.dg/tree-ssa/deleted-label1.C b/gcc/testsuite/g++.dg/tree-ssa/deleted-label1.C new file mode 100644 index 0000000000..11c06be52c --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/deleted-label1.C @@ -0,0 +1,19 @@ +// PR debug/58315 +// { dg-options "-O -g -fdump-tree-einline" } +// { dg-final { scan-tree-dump-not "DEBUG <L0>" "einline" } } +// { dg-final { cleanup-tree-dump "einline" } } + +// We used to emit useless NOTE_INSN_DELETED_DEBUG_LABELs for the +// artificial cdtor_label. + +struct A +{ + ~A() {} +}; + +struct B: A {}; + +int main() +{ + A a; +} diff --git a/gcc/testsuite/g++.dg/tree-ssa/forwprop-switch.C b/gcc/testsuite/g++.dg/tree-ssa/forwprop-switch.C new file mode 100644 index 0000000000..c3f12ac45a --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/forwprop-switch.C @@ -0,0 +1,24 @@ +// { dg-do compile } +// { dg-options "-O -fdump-tree-cddce1" } + +enum Scale { E1, E2, E3, E4, E5, E6, E7, E8 }; + +int Test(Scale s) +{ + switch(s) + { + case E1: return 12; + case E2: return 17; + case E3: return 22; + case E4: return 42; + default: break; + } + return 0; +} + +// tree forwprop should have eliminated the (int) s cast for the +// switch value and directly switch on the 's' parameter + +// { dg-final { scan-tree-dump-not "\\\(int\\\)" "cddce1" } } +// { dg-final { scan-tree-dump "switch \\\(s_.\\\(D\\\)\\\)" "cddce1" } } +// { dg-final { cleanup-tree-dump "cddce1" } } diff --git a/gcc/testsuite/g++.dg/tree-ssa/ivopts-3.C b/gcc/testsuite/g++.dg/tree-ssa/ivopts-3.C new file mode 100644 index 0000000000..d0178b3298 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/ivopts-3.C @@ -0,0 +1,76 @@ +// { dg-do compile } +// { dg-options "-O2 -fdump-tree-ivopts-details" } + +class MinimalVec3 +{ +protected: + double coords[3]; + +public: + + MinimalVec3( ) { + for ( int i = 0; i < 3; ++i ) + coords[i] = 0.; + } + + inline const double& operator[] ( int I ) const { + return coords[I]; + } +}; + +class MinimalVector +{ +protected: + double *_pData; + double stuff; + +public: + explicit MinimalVector ( int length ) { + _pData = new double[length]; + for (int i = 0; i < length; ++i) _pData[i] = 0.; + } + + inline double& operator[] ( int I ) { + return _pData[I]; + } + + inline const double& operator[] ( int I ) const { + return _pData[I]; + } +}; + + +int main ( int , char** ) { + int w = ( 1 << 7 )+1; + int wsqr = w*w; + int wcub = w*w*w; + + MinimalVec3 * rows[9]; + for ( int i = 0; i < 9; ++i ) { + rows[i] = new MinimalVec3[wcub]; + } + + MinimalVector img ( wcub ), res ( wcub ); + + for ( int c = 0; c < 1000; ++c ) { + + for ( int i = 1; i < w-1; ++i ) + for ( int j = 0; j < 3; ++j ) { + + for ( int k = 1; k < w - 1; ++k ) + for ( int l = 0; l < 3; ++l ) { + + for ( int m = 1; m < w - 1; ++m ) + for ( int n = 0; n < 3; ++n ) + res[i*wsqr + k*w + m] += img[( i + j - 1 ) *wsqr + ( k + l - 1 ) *w + m + n - 1] * rows[j*3 + l][i*wsqr + k*w + m][n]; + + } + } + } + return 0; +} + +// Verify that on x86_64 and i?86 we use a single IV for the innermost loop + +// { dg-final { scan-tree-dump "Selected IV set for loop \[0-9\]* at \[^ \]*:64, 1 IVs" "ivopts" { target x86_64-*-* i?86-*-* } } } +// { dg-final { cleanup-tree-dump "ivopts" } } diff --git a/gcc/testsuite/g++.dg/tree-ssa/nonzero-1.C b/gcc/testsuite/g++.dg/tree-ssa/nonzero-1.C new file mode 100644 index 0000000000..60da49dca3 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/nonzero-1.C @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ccp1" } */ +inline void t() +{ +} +int m() +{ + void *q = (void *)&t; + return q != 0; +} +/* { dg-final { scan-tree-dump "return 1" "ccp1"} } */ +/* { dg-final { cleanup-tree-dump "ccp1" } } */ diff --git a/gcc/testsuite/g++.dg/tree-ssa/nonzero-2.C b/gcc/testsuite/g++.dg/tree-ssa/nonzero-2.C new file mode 100644 index 0000000000..fdf4114188 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/nonzero-2.C @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ccp1 -fdelete-null-pointer-checks" } */ +struct t +{ + static inline void tt() + { + } + virtual void q(); +}; +int m() +{ + void *q = (void *)&t::tt; + return q != 0; +} +/* { dg-final { scan-tree-dump "return 1" "ccp1"} } */ +/* { dg-final { cleanup-tree-dump "ccp1" } } */ diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr19637.C b/gcc/testsuite/g++.dg/tree-ssa/pr19637.C index 2d1dcceba4..92f673f9ea 100644 --- a/gcc/testsuite/g++.dg/tree-ssa/pr19637.C +++ b/gcc/testsuite/g++.dg/tree-ssa/pr19637.C @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-dom1" } */ +/* { dg-options "-O2 -fno-ipa-icf -fdump-tree-dom1" } */ #include <new> diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr19807.C b/gcc/testsuite/g++.dg/tree-ssa/pr19807.C index 0eeeb18abd..8d7807050d 100644 --- a/gcc/testsuite/g++.dg/tree-ssa/pr19807.C +++ b/gcc/testsuite/g++.dg/tree-ssa/pr19807.C @@ -11,6 +11,9 @@ void foo(void) z = 1 + &a[1]; } +/* { dg-final { scan-tree-dump-times "&MEM\\\[\\\(void .\\\)&a \\\+ 8B\\\]" 3 "optimized" } } */ + + void bar(int i) { x = &a[i] - 1; @@ -18,13 +21,7 @@ void bar(int i) z = 1 + &a[i]; } -/* { dg-final { scan-tree-dump-times "&a\\\[2\\\]" 3 "optimized" } } */ - -/* We want &a[D.bla + 1] and &a[D.foo - 1] in the final code, but - tuples mean that the offset is calculated in a separate instruction. - Simply test for the existence of +1 and -1 once, which also ensures - the above. If the addition/subtraction would be applied to the - pointer we would instead see +-4 (or 8, depending on sizeof(int)). */ -/* { dg-final { scan-tree-dump "\\\+ (0x0f*|18446744073709551615|4294967295|-1);" "optimized" } } */ -/* { dg-final { scan-tree-dump-times "\\\+ 1;" 1 "optimized" } } */ +/* We can't get &a[i +- 1] in the final code and it is not clear we + want this. Instead we get to see &a[i] and pointer offsetting + by 4 and -4U. */ /* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr29902.C b/gcc/testsuite/g++.dg/tree-ssa/pr29902.C index 838a41169a..996a3b9b53 100644 --- a/gcc/testsuite/g++.dg/tree-ssa/pr29902.C +++ b/gcc/testsuite/g++.dg/tree-ssa/pr29902.C @@ -1,6 +1,5 @@ -/* { dg-do compile { target i?86-*-* } } */ +/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ /* { dg-options "-O1 -fprefetch-loop-arrays -march=athlon" } */ -/* { dg-require-effective-target ilp32 } */ int length1(); int g(int); diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr57380.C b/gcc/testsuite/g++.dg/tree-ssa/pr57380.C index 0a2b2ad5f5..b370292f11 100644 --- a/gcc/testsuite/g++.dg/tree-ssa/pr57380.C +++ b/gcc/testsuite/g++.dg/tree-ssa/pr57380.C @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O2 -fdump-tree-phiopt1" } */ +/* { dg-add-options bind_pic_locally } */ struct my_array { int data[4]; diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr61034.C b/gcc/testsuite/g++.dg/tree-ssa/pr61034.C new file mode 100644 index 0000000000..9ec3995afd --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/pr61034.C @@ -0,0 +1,47 @@ +// { dg-do compile } +// { dg-options "-O3 -fdump-tree-fre2" } + +#define assume(x) if(!(x))__builtin_unreachable() + +inline void* operator new(__SIZE_TYPE__ n){ return __builtin_malloc(n); } +inline void operator delete(void *p) { __builtin_free(p); } +// C++14 sized deallocation function +inline void operator delete(void *p, __SIZE_TYPE__) { __builtin_free(p); } +struct O { + double num; + int count; +}; +struct I { + O *o; + I(double d = 0) : o (new O) { o->num = d; o->count = 1; } + I(I const&i) { assume(i.o->count >= 1); o = i.o; ++o->count; } + I& operator=(I const&i) { I(i).swap(*this); return *this; } + ~I() { if (--o->count == 0) delete o; } + void swap(I& i) { O *tmp = o; o = i.o; i.o = tmp; } + I& operator*= (I const&i) { + if (o->count > 1) *this = I(o->num); + o->num *= i.o->num; + return *this; + } + I& operator-= (I const&i) { + if (o->count > 1) *this = I(o->num); + o->num -= i.o->num; + return *this; + } +}; +inline I operator* (I a, I const&b) { return a *= b; } +inline I operator- (I a, I const&b) { return a -= b; } +inline bool operator< (I const&a, I const&b) { return a.o->num < b.o->num; } + +bool f(I a, I b, I c, I d) { + return (a * d - b * c) * (a * b - c * d) < 42; +} + +// We should be able to CSE most references to count and thus remove +// a bunch of conditional free()s and unreachable()s. +// This works only if everything is inlined into 'f'. + +// { dg-final { scan-tree-dump-times ";; Function" 1 "fre2" } } +// { dg-final { scan-tree-dump-times "free" 19 "fre2" } } +// { dg-final { scan-tree-dump-times "unreachable" 11 "fre2" } } +// { dg-final { cleanup-tree-dump "fre2" } } diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr63841.C b/gcc/testsuite/g++.dg/tree-ssa/pr63841.C new file mode 100644 index 0000000000..2a2c78f9fb --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/pr63841.C @@ -0,0 +1,35 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#include <string> + +std::string __attribute__ ((noinline)) comp_test_write() { + std::string data; + + for (int i = 0; i < 2; ++i) { + char b = 1 >> (i * 8); + data.append(&b, 1); + } + + return data; +} + +std::string __attribute__ ((noinline)) comp_test_write_good() { + std::string data; + + char b; + for (int i = 0; i < 2; ++i) { + b = 1 >> (i * 8); + data.append(&b, 1); + } + + return data; +} + +int main() { + std::string good = comp_test_write_good(); + std::string bad = comp_test_write(); + + if (good != bad) + __builtin_abort (); +} diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr8781.C b/gcc/testsuite/g++.dg/tree-ssa/pr8781.C index cc518a0d25..19549c4f73 100644 --- a/gcc/testsuite/g++.dg/tree-ssa/pr8781.C +++ b/gcc/testsuite/g++.dg/tree-ssa/pr8781.C @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O -fno-tree-sra -fdump-tree-fre1-details" } */ +/* { dg-options "-O -fno-tree-sra -fdump-tree-fre1" } */ int f(); @@ -24,5 +24,5 @@ int x() /* We should optimize this to a direct call. */ -/* { dg-final { scan-tree-dump "Replacing call target with f" "fre1" } } */ +/* { dg-final { scan-tree-dump-times "= f \\(\\);" 1 "fre1" } } */ /* { dg-final { cleanup-tree-dump "fre1" } } */ diff --git a/gcc/testsuite/g++.dg/tree-ssa/tmmti-2.C b/gcc/testsuite/g++.dg/tree-ssa/tmmti-2.C deleted file mode 100644 index 808b5ab275..0000000000 --- a/gcc/testsuite/g++.dg/tree-ssa/tmmti-2.C +++ /dev/null @@ -1,22 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options { -O -fdump-tree-optimized } } */ - -int a[4][8]; - -int foo(long i) -{ - return *(&a[0][0] + i*8); // a[i][0] -} - -struct Foo { double x, y; }; - -Foo b[4]; - -double bar(long i) -{ - return *(&b[0].x + i*2); // b[i].x -} - -/* { dg-final { scan-tree-dump "a\\\[.*i.*\\\]\\\[0\\\]" "optimized" { xfail *-*-* } } } */ -/* { dg-final { scan-tree-dump "b\\\[.*i.*\\\].x" "optimized" } } */ -/* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc/testsuite/g++.dg/tsan/aligned_vs_unaligned_race.C b/gcc/testsuite/g++.dg/tsan/aligned_vs_unaligned_race.C index 390be86d71..1facadc87d 100644 --- a/gcc/testsuite/g++.dg/tsan/aligned_vs_unaligned_race.C +++ b/gcc/testsuite/g++.dg/tsan/aligned_vs_unaligned_race.C @@ -1,29 +1,38 @@ +/* { dg-shouldfail "tsan" } */ +/* { dg-additional-options "-ldl" } */ + #include <pthread.h> #include <stdio.h> #include <stdint.h> +#include "tsan_barrier.h" +static pthread_barrier_t barrier; uint64_t Global[2]; void *Thread1(void *x) { + barrier_wait(&barrier); Global[1]++; return NULL; } void *Thread2(void *x) { char *p1 = reinterpret_cast<char *>(&Global[0]); - uint64_t *p4 = reinterpret_cast<uint64_t *>(p1 + 1); - (*p4)++; + struct __attribute__((packed, aligned(1))) u_uint64_t { uint64_t val; }; + u_uint64_t *p4 = reinterpret_cast<u_uint64_t *>(p1 + 1); + (*p4).val++; + barrier_wait(&barrier); return NULL; } int main() { + barrier_init(&barrier, 2); pthread_t t[2]; pthread_create(&t[0], NULL, Thread1, NULL); pthread_create(&t[1], NULL, Thread2, NULL); pthread_join(t[0], NULL); pthread_join(t[1], NULL); printf("Pass\n"); - /* { dg-prune-output "ThreadSanitizer: data race.*(\n|\r\n|\r)" } */ + /* { dg-output "WARNING: ThreadSanitizer: data race.*(\n|\r\n|\r)" } */ /* { dg-output "Pass.*" } */ return 0; } diff --git a/gcc/testsuite/g++.dg/tsan/atomic_free.C b/gcc/testsuite/g++.dg/tsan/atomic_free.C index 26d01ae3fd..20429f159b 100644 --- a/gcc/testsuite/g++.dg/tsan/atomic_free.C +++ b/gcc/testsuite/g++.dg/tsan/atomic_free.C @@ -1,18 +1,23 @@ /* { dg-shouldfail "tsan" } */ +/* { dg-additional-options "-ldl" } */ #include <pthread.h> -#include <unistd.h> +#include "tsan_barrier.h" + +static pthread_barrier_t barrier; void *Thread(void *a) { __atomic_fetch_add((int*)a, 1, __ATOMIC_SEQ_CST); + barrier_wait(&barrier); return 0; } int main() { + barrier_init(&barrier, 2); int *a = new int(0); pthread_t t; pthread_create(&t, 0, Thread, a); - sleep(1); + barrier_wait(&barrier); delete a; pthread_join(t, 0); } diff --git a/gcc/testsuite/g++.dg/tsan/atomic_free2.C b/gcc/testsuite/g++.dg/tsan/atomic_free2.C index 1fe512cde9..3b6a8e3af9 100644 --- a/gcc/testsuite/g++.dg/tsan/atomic_free2.C +++ b/gcc/testsuite/g++.dg/tsan/atomic_free2.C @@ -1,19 +1,24 @@ /* { dg-shouldfail "tsan" } */ +/* { dg-additional-options "-ldl" } */ #include <pthread.h> -#include <unistd.h> +#include "tsan_barrier.h" + +static pthread_barrier_t barrier; void *Thread(void *a) { - sleep(1); + barrier_wait(&barrier); __atomic_fetch_add((int*)a, 1, __ATOMIC_SEQ_CST); return 0; } int main() { + barrier_init(&barrier, 2); int *a = new int(0); pthread_t t; pthread_create(&t, 0, Thread, a); delete a; + barrier_wait(&barrier); pthread_join(t, 0); } diff --git a/gcc/testsuite/g++.dg/tsan/cond_race.C b/gcc/testsuite/g++.dg/tsan/cond_race.C index a937614776..d72d0fb54f 100644 --- a/gcc/testsuite/g++.dg/tsan/cond_race.C +++ b/gcc/testsuite/g++.dg/tsan/cond_race.C @@ -1,10 +1,12 @@ /* { dg-shouldfail "tsan" } */ +/* { dg-additional-options "-ldl" } */ /* { dg-output "ThreadSanitizer: data race.*" } */ /* { dg-output "pthread_cond_signal.*" } */ -#include <stdio.h> -#include <stdlib.h> #include <pthread.h> +#include "tsan_barrier.h" + +static pthread_barrier_t barrier; struct Ctx { pthread_mutex_t m; @@ -18,10 +20,12 @@ void *thr(void *p) { c->done = true; pthread_mutex_unlock(&c->m); pthread_cond_signal(&c->c); + barrier_wait(&barrier); return 0; } int main() { + barrier_init(&barrier, 2); Ctx *c = new Ctx(); pthread_mutex_init(&c->m, 0); pthread_cond_init(&c->c, 0); @@ -31,6 +35,7 @@ int main() { while (!c->done) pthread_cond_wait(&c->c, &c->m); pthread_mutex_unlock(&c->m); + barrier_wait(&barrier); delete c; pthread_join(th, 0); } diff --git a/gcc/testsuite/g++.dg/tsan/pr64265.C b/gcc/testsuite/g++.dg/tsan/pr64265.C new file mode 100644 index 0000000000..fde32e7d0c --- /dev/null +++ b/gcc/testsuite/g++.dg/tsan/pr64265.C @@ -0,0 +1,54 @@ +// PR sanitizer/64265 +// { dg-shouldfail "tsan" } +// { dg-additional-options "-fno-omit-frame-pointer -ldl" } + +#include <pthread.h> +#include "tsan_barrier.h" + +static pthread_barrier_t barrier; +int v; + +__attribute__((noinline, noclone)) int +foo (int x) +{ + if (x < 99) + throw x; + barrier_wait (&barrier); + v++; + return x; +} + +__attribute__((noinline, noclone)) void +bar (void) +{ + for (int i = 0; i < 100; i++) + try + { + foo (i); + } + catch (int) + { + } +} + +__attribute__((noinline, noclone)) void * +tf (void *) +{ + bar (); + return NULL; +} + +int +main () +{ + pthread_t th; + barrier_init (&barrier, 2); + if (pthread_create (&th, NULL, tf, NULL)) + return 0; + v++; + barrier_wait (&barrier); + pthread_join (th, NULL); + return 0; +} + +// { dg-output "WARNING: ThreadSanitizer: data race.*#2 _?(tf|_Z2tfPv)" } diff --git a/gcc/testsuite/g++.dg/tsan/tsan.exp b/gcc/testsuite/g++.dg/tsan/tsan.exp index 14ff02e557..4cfe9a5fb2 100644 --- a/gcc/testsuite/g++.dg/tsan/tsan.exp +++ b/gcc/testsuite/g++.dg/tsan/tsan.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2014 Free Software Foundation, Inc. +# Copyright (C) 2013-2015 Free Software Foundation, Inc. # # This file is part of GCC. # @@ -23,10 +23,6 @@ load_lib g++-dg.exp load_lib tsan-dg.exp load_lib torture-options.exp -if ![check_effective_target_fthread_sanitizer] { - return -} - # Initialize `dg'. dg-init torture-init @@ -34,11 +30,11 @@ set-torture-options [list \ { -O0 } \ { -O2 } ] -if [tsan_init] { +tsan_init # Main loop. -gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C $srcdir/c-c++-common/tsan/*.c]] "" - +if [check_effective_target_fsanitize_thread] { + gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C $srcdir/c-c++-common/tsan/*.c]] "" "" } # All done. diff --git a/gcc/testsuite/g++.dg/tsan/tsan_barrier.h b/gcc/testsuite/g++.dg/tsan/tsan_barrier.h new file mode 100644 index 0000000000..5d37a64758 --- /dev/null +++ b/gcc/testsuite/g++.dg/tsan/tsan_barrier.h @@ -0,0 +1,14 @@ +/* TSAN-invisible barriers. Link with -ldl. */ +#include <pthread.h> +#include <dlfcn.h> + +static __typeof(pthread_barrier_wait) *barrier_wait; + +static +void barrier_init (pthread_barrier_t *barrier, unsigned count) +{ + void *h = dlopen ("libpthread.so.0", RTLD_LAZY); + barrier_wait = (__typeof (pthread_barrier_wait) *) + dlsym (h, "pthread_barrier_wait"); + pthread_barrier_init (barrier, NULL, count); +} diff --git a/gcc/testsuite/g++.dg/tsan/vptr_benign_race.C b/gcc/testsuite/g++.dg/tsan/vptr_benign_race.C new file mode 100644 index 0000000000..283684bcfa --- /dev/null +++ b/gcc/testsuite/g++.dg/tsan/vptr_benign_race.C @@ -0,0 +1,49 @@ +#include <pthread.h> +#include <semaphore.h> +#include <stdio.h> + +struct A { + A() { + sem_init(&sem_, 0, 0); + } + virtual void F() { + } + void Done() { + sem_post(&sem_); + } + virtual ~A() { + } + sem_t sem_; +}; + +struct B : A { + virtual void F() { + } + virtual ~B() { + sem_wait(&sem_); + sem_destroy(&sem_); + } +}; + +static A *obj = new B; + +void *Thread1(void *x) { + obj->F(); + obj->Done(); + return NULL; +} + +void *Thread2(void *x) { + delete obj; + return NULL; +} + +int main() { + pthread_t t[2]; + pthread_create(&t[0], NULL, Thread1, NULL); + pthread_create(&t[1], NULL, Thread2, NULL); + pthread_join(t[0], NULL); + pthread_join(t[1], NULL); + fprintf(stderr, "PASS\n"); +} +/* { dg-output "PASS.*" } */ diff --git a/gcc/testsuite/g++.dg/tsan/vptr_harmful_race.C b/gcc/testsuite/g++.dg/tsan/vptr_harmful_race.C new file mode 100644 index 0000000000..1473f93ed2 --- /dev/null +++ b/gcc/testsuite/g++.dg/tsan/vptr_harmful_race.C @@ -0,0 +1,58 @@ +/* { dg-shouldfail "tsan" } */ +/* { dg-additional-options "-ldl" } */ + +#include <pthread.h> +#include <semaphore.h> +#include <stdio.h> +#include <unistd.h> +#include "tsan_barrier.h" + +static pthread_barrier_t barrier; + +struct A { + A() { + sem_init(&sem_, 0, 0); + } + virtual void F() { + } + void Done() { + sem_post(&sem_); + } + virtual ~A() { + sem_wait(&sem_); + sem_destroy(&sem_); + } + sem_t sem_; +}; + +struct B : A { + virtual void F() { + } + virtual ~B() { } +}; + +static A *obj = new B; + +void *Thread1(void *x) { + obj->F(); + obj->Done(); + barrier_wait(&barrier); + return NULL; +} + +void *Thread2(void *x) { + barrier_wait(&barrier); + delete obj; + return NULL; +} + +int main() { + barrier_init(&barrier, 2); + pthread_t t[2]; + pthread_create(&t[0], NULL, Thread1, NULL); + pthread_create(&t[1], NULL, Thread2, NULL); + pthread_join(t[0], NULL); + pthread_join(t[1], NULL); +} + +/* { dg-output "WARNING: ThreadSanitizer: data race on vptr.*(\n|\r\n|\r)" } */ diff --git a/gcc/testsuite/g++.dg/ubsan/align-1.C b/gcc/testsuite/g++.dg/ubsan/align-1.C new file mode 100644 index 0000000000..65b1222a5c --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/align-1.C @@ -0,0 +1,27 @@ +// { dg-do run } +// { dg-options "-fsanitize=alignment -Wall -Wno-unused-variable -std=c++11" } + +typedef const long int L; +int a = 1; +L b = 2; + +int +main (void) +{ + int *p = &a; + L *l = &b; + + int &r = *p; + auto &r2 = *p; + L &lr = *l; + + // Try an rvalue reference. + auto &&r3 = *p; + + // Don't evaluate the reference initializer twice. + int i = 1; + int *q = &i; + int &qr = ++*q; + if (i != 2) + __builtin_abort (); +} diff --git a/gcc/testsuite/g++.dg/ubsan/align-2.C b/gcc/testsuite/g++.dg/ubsan/align-2.C new file mode 100644 index 0000000000..3e4f5485d0 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/align-2.C @@ -0,0 +1,45 @@ +// Limit this to known non-strict alignment targets. +// { dg-do run { target { i?86-*-linux* x86_64-*-linux* } } } +// { dg-options "-fsanitize=alignment -Wall -Wno-unused-variable -std=c++11" } + +typedef const long int L; +struct S { long int l; char buf[1 + sizeof (int) + sizeof (L)]; } s; +struct T { char a; int b; long int c; } __attribute__((packed)); +struct U { long int a; struct T b; } u; + +int +main (void) +{ + int *p = (int *) &s.buf[1]; + L *l = (L *) &s.buf[1 + sizeof(int)]; + + int &r = *p; + auto &r2 = *p; + L &lr = *l; + + // Try an rvalue reference. + auto &&r3 = *p; + + // Don't evaluate the reference initializer twice. + int i = 1; + int *q = &i; + int &qr = ++*q; + if (i != 2) + __builtin_abort (); + + int *s = &u.b.b; + L *t = &u.b.c; + int &r4 = *s; + auto &r5 = *s; + L &lr2 = *t; + auto &&r6 = *s; +} + +// { dg-output "\.C:16:\[0-9]*:\[\^\n\r]*reference binding to misaligned address 0x\[0-9a-fA-F]* for type 'int', which requires 4 byte alignment.*" } +// { dg-output "\.C:17:\[0-9]*:\[\^\n\r]*reference binding to misaligned address 0x\[0-9a-fA-F]* for type 'int', which requires 4 byte alignment.*" } +// { dg-output "\.C:18:\[0-9]*:\[\^\n\r]*reference binding to misaligned address 0x\[0-9a-fA-F]* for type 'const L', which requires \[48] byte alignment.*" } +// { dg-output "\.C:21:\[0-9]*:\[\^\n\r]*reference binding to misaligned address 0x\[0-9a-fA-F]* for type 'int', which requires 4 byte alignment.*" } +// { dg-output "\.C:32:\[0-9]*:\[\^\n\r]*reference binding to misaligned address 0x\[0-9a-fA-F]* for type 'int', which requires 4 byte alignment.*" } +// { dg-output "\.C:33:\[0-9]*:\[\^\n\r]*reference binding to misaligned address 0x\[0-9a-fA-F]* for type 'int', which requires 4 byte alignment.*" } +// { dg-output "\.C:34:\[0-9]*:\[\^\n\r]*reference binding to misaligned address 0x\[0-9a-fA-F]* for type 'const L', which requires \[48] byte alignment.*" } +// { dg-output "\.C:35:\[0-9]*:\[\^\n\r]*reference binding to misaligned address 0x\[0-9a-fA-F]* for type 'int', which requires 4 byte alignment" } diff --git a/gcc/testsuite/g++.dg/ubsan/align-3.C b/gcc/testsuite/g++.dg/ubsan/align-3.C new file mode 100644 index 0000000000..1cc40fc4c9 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/align-3.C @@ -0,0 +1,45 @@ +// Limit this to known non-strict alignment targets. +// { dg-do run { target { i?86-*-linux* x86_64-*-linux* } } } +// { dg-options "-fsanitize=alignment -Wall -Wno-unused-variable -std=c++11" } + +#include <new> + +struct U +{ + int a; + void foo () {} +}; +struct V +{ + V () : a (0) {}; + ~V () { a = 0; }; + int a; + void foo () {} + static void bar () {} +}; +struct S { long int l; char buf[1 + sizeof (U) + 2 * sizeof (V)]; } s; + +int +main (void) +{ + U *p = (U *) &s.buf[1]; + p->foo (); + char *q = &s.buf[1 + sizeof (U)]; + V *u = new (q) V; + u->a = 1; + u->~V (); + V *v = new (&s.buf[1 + sizeof (U) + sizeof (V)]) V; + v->foo (); + v->bar (); // We don't instrument this right now. + v->~V (); +} + +// { dg-output "\.C:26:\[0-9]*:\[\^\n\r]*member call on misaligned address 0x\[0-9a-fA-F]* for type 'struct U', which requires 4 byte alignment.*" } +// { dg-output "\.C:28:\[0-9]*:\[\^\n\r]*constructor call on misaligned address 0x\[0-9a-fA-F]* for type 'struct V', which requires 4 byte alignment.*" } +// { dg-output "\.C:14:\[0-9]*:\[\^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct V', which requires 4 byte alignment.*" } +// { dg-output "\.C:29:\[0-9]*:\[\^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct V', which requires 4 byte alignment.*" } +// { dg-output "\.C:30:\[0-9]*:\[\^\n\r]*member call on misaligned address 0x\[0-9a-fA-F]* for type 'struct V', which requires 4 byte alignment.*" } +// { dg-output "\.C:15:\[0-9]*:\[\^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct V', which requires 4 byte alignment.*" } +// { dg-output "\.C:31:\[0-9]*:\[\^\n\r]*constructor call on misaligned address 0x\[0-9a-fA-F]* for type 'struct V', which requires 4 byte alignment.*" } +// { dg-output "\.C:32:\[0-9]*:\[\^\n\r]*member call on misaligned address 0x\[0-9a-fA-F]* for type 'struct V', which requires 4 byte alignment.*" } +// { dg-output "\.C:34:\[0-9]*:\[\^\n\r]*member call on misaligned address 0x\[0-9a-fA-F]* for type 'struct V', which requires 4 byte alignment" } diff --git a/gcc/testsuite/g++.dg/ubsan/attrib-1.C b/gcc/testsuite/g++.dg/ubsan/attrib-1.C new file mode 100644 index 0000000000..f701d02dad --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/attrib-1.C @@ -0,0 +1,27 @@ +// { dg-do compile } +// { dg-options "-fsanitize=undefined -Wall -Wno-unused-variable -std=c++11" } + +typedef const long int L; + +__attribute__((no_sanitize_undefined)) void +foo (int *p, L *l) +{ + int &r = *p; + auto &r2 = *p; + L &lr = *l; + auto &&r3 = *p; +} + +struct U +{ + int a; + void foo () {} +}; + +__attribute__((no_sanitize_undefined)) void +bar (U *p) +{ + p->foo (); +} + +// { dg-final { scan-assembler-not "__ubsan_handle" } } diff --git a/gcc/testsuite/g++.dg/ubsan/cxx11-shift-1.C b/gcc/testsuite/g++.dg/ubsan/cxx11-shift-1.C index f2b2cbd1c2..431eab12d3 100644 --- a/gcc/testsuite/g++.dg/ubsan/cxx11-shift-1.C +++ b/gcc/testsuite/g++.dg/ubsan/cxx11-shift-1.C @@ -1,18 +1,10 @@ -/* { dg-do run { target c++11 } } */ -/* { dg-options "-fsanitize=shift -w" } */ - -#include <stdio.h> +/* { dg-do run } */ +/* { dg-options "-fsanitize=shift -w -fno-sanitize-recover=shift -std=c++11" } */ int main (void) { - fputs ("UBSAN TEST START\n", stderr); - int a = 1; a <<= 31; - - fputs ("UBSAN TEST END\n", stderr); return 0; } - -/* { dg-output "UBSAN TEST START(\n|\r\n|\r)UBSAN TEST END" } */ diff --git a/gcc/testsuite/g++.dg/ubsan/cxx11-shift-2.C b/gcc/testsuite/g++.dg/ubsan/cxx11-shift-2.C index 867908aef7..fbc16dfd3d 100644 --- a/gcc/testsuite/g++.dg/ubsan/cxx11-shift-2.C +++ b/gcc/testsuite/g++.dg/ubsan/cxx11-shift-2.C @@ -1,5 +1,5 @@ -/* { dg-do run { target c++11 } } */ -/* { dg-options "-fsanitize=shift -w" } */ +/* { dg-do run } */ +/* { dg-options "-fsanitize=shift -w -std=c++11" } */ int main (void) diff --git a/gcc/testsuite/g++.dg/ubsan/cxx1y-vla.C b/gcc/testsuite/g++.dg/ubsan/cxx1y-vla.C deleted file mode 100644 index ca1e922d69..0000000000 --- a/gcc/testsuite/g++.dg/ubsan/cxx1y-vla.C +++ /dev/null @@ -1,13 +0,0 @@ -/* { dg-do run { target c++1y } } */ -/* { dg-options "-fsanitize=vla-bound -Wall -Wno-unused-variable" } */ -/* { dg-shouldfail "ubsan" } */ - -int -main (void) -{ - int y = -18; - int a[y]; - return 0; -} - -/* { dg-output "terminate called after throwing an instance" } */ diff --git a/gcc/testsuite/g++.dg/ubsan/div-by-zero-1.C b/gcc/testsuite/g++.dg/ubsan/div-by-zero-1.C index 88acfa1517..946f2e615f 100644 --- a/gcc/testsuite/g++.dg/ubsan/div-by-zero-1.C +++ b/gcc/testsuite/g++.dg/ubsan/div-by-zero-1.C @@ -1,10 +1,14 @@ /* { dg-do compile } */ -/* { dg-options "-fsanitize=integer-divide-by-zero -w" } */ +/* { dg-options "-fsanitize=integer-divide-by-zero" } */ + +/* TODO: We expect an error on the invalid case here, because that + must be a constant-expression. This will be fixed when we have + proper delayed folding. */ void foo (int i) { switch (i) - case 0 * (1 / 0): /* { dg-error "is not a constant expression" } */ - ; + case 0 * (1 / 0): /* { dg-warning "division by zero" } */ + ; /* { dg-error "division by zero" "" { xfail *-*-* } 10 } */ } diff --git a/gcc/testsuite/g++.dg/ubsan/float-cast-overflow-bf.C b/gcc/testsuite/g++.dg/ubsan/float-cast-overflow-bf.C new file mode 100644 index 0000000000..f01c576c3d --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/float-cast-overflow-bf.C @@ -0,0 +1,62 @@ +// { dg-do run { target { int32 } } } +// { dg-options "-fsanitize=float-cast-overflow" } + +#define INT_MAX __INT_MAX__ +#define INT_MIN (-__INT_MAX__ - 1) +#define UINT_MAX 2 * (unsigned) __INT_MAX__ + 1 + +struct S +{ + int i:1; +} s; + +struct T +{ + unsigned int i:1; +} t; + +int +main (void) +{ + volatile double d; + +#define CHECK_BOUNDARY(VAR, VAL) \ + (VAR) = (VAL) - 1.5; \ + (VAR) = (VAL) - 1.0; \ + (VAR) = (VAL) - 0.75; \ + (VAR) = (VAL) - 0.5; \ + (VAR) = (VAL) - 0.0000001; \ + (VAR) = (VAL) - 0.0; \ + (VAR) = (VAL); \ + (VAR) = (VAL) + 0.0; \ + (VAR) = (VAL) + 0.0000001; \ + (VAR) = (VAL) + 0.5; \ + (VAR) = (VAL) + 0.75; \ + (VAR) = (VAL) + 1.0; \ + (VAR) = (VAL) + 1.5; + + /* Signed bit-field. (INT_MIN, INT_MAX) is valid. */ + d = INT_MIN; + CHECK_BOUNDARY (s.i, d); + d = 0.0; + CHECK_BOUNDARY (s.i, d); + d = INT_MAX; + CHECK_BOUNDARY (s.i, d); + + /* Unsigned bit-field. (0, UINT_MAX) is valid. */ + d = UINT_MAX; + CHECK_BOUNDARY (t.i, d); + d = 0.0; + CHECK_BOUNDARY (t.i, d); + + return 0; +} + +/* { dg-output "value -2.14748e\\\+09 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*value -2.14748e\\\+09 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*value 2.14748e\\\+09 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*value 2.14748e\\\+09 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*value 4.29497e\\\+09 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*value 4.29497e\\\+09 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*value -1.5 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*value -1 is outside the range of representable values of type" } */ diff --git a/gcc/testsuite/g++.dg/ubsan/null-1.C b/gcc/testsuite/g++.dg/ubsan/null-1.C new file mode 100644 index 0000000000..e1524b1f92 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/null-1.C @@ -0,0 +1,30 @@ +// { dg-do run } +// { dg-options "-fsanitize=null -Wall -Wno-unused-variable -std=c++11" } + +typedef const long int L; + +int +main (void) +{ + int *p = 0; + L *l = 0; + + int &r = *p; + auto &r2 = *p; + L &lr = *l; + + // Try an rvalue reference. + auto &&r3 = *p; + + // Don't evaluate the reference initializer twice. + int i = 1; + int *q = &i; + int &qr = ++*q; + if (i != 2) + __builtin_abort (); +} + +// { dg-output "reference binding to null pointer of type 'int'(\n|\r\n|\r)" } +// { dg-output "\[^\n\r]*reference binding to null pointer of type 'int'(\n|\r\n|\r)" } +// { dg-output "\[^\n\r]*reference binding to null pointer of type 'const L'(\n|\r\n|\r)" } +// { dg-output "\[^\n\r]*reference binding to null pointer of type 'int'(\n|\r\n|\r)" } diff --git a/gcc/testsuite/g++.dg/ubsan/null-2.C b/gcc/testsuite/g++.dg/ubsan/null-2.C new file mode 100644 index 0000000000..88f387e17c --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/null-2.C @@ -0,0 +1,39 @@ +// Limit this to known non-strict alignment targets. +// { dg-do run { target { i?86-*-linux* x86_64-*-linux* } } } +// { dg-options "-fsanitize=null -Wall -Wno-unused-variable -std=c++11" } + +#include <new> + +struct U +{ + int a; + void foo () {} +}; +struct V +{ + V () {}; + ~V () {}; + int a; + void foo () {} + static void bar () {} +}; +struct S { long int l; char buf[1 + sizeof (U) + 2 * sizeof (V)]; } s; + +int +main (void) +{ + U *p = 0; + p->foo (); + char *q = 0; + V *u = new (q) V; + u->~V (); + V *v = new (q) V; + v->foo (); + v->bar (); // We don't instrument this right now. + v->~V (); +} + +// { dg-output "\.C:26:\[0-9]*:\[\^\n\r]*member call on null pointer of type 'struct U'.*" } +// { dg-output "\.C:29:\[0-9]*:\[\^\n\r]*member call on null pointer of type 'struct V'.*" } +// { dg-output "\.C:31:\[0-9]*:\[\^\n\r]*member call on null pointer of type 'struct V'.*" } +// { dg-output "\.C:33:\[0-9]*:\[\^\n\r]*member call on null pointer of type 'struct V'" } diff --git a/gcc/testsuite/g++.dg/ubsan/null-3.C b/gcc/testsuite/g++.dg/ubsan/null-3.C new file mode 100644 index 0000000000..cd3716b3eb --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/null-3.C @@ -0,0 +1,20 @@ +// { dg-do run } +// { dg-options "-fsanitize=null" } + +int +main (void) +{ + int *p = 0; + + int &r1 = *p; + int &r2 = *p; + int &r3 = *p; + int &r4 = *p; + int &r5 = *p; +} + +// { dg-output "reference binding to null pointer of type 'int'(\n|\r\n|\r)" } +// { dg-output "\[^\n\r]*reference binding to null pointer of type 'int'(\n|\r\n|\r)" } +// { dg-output "\[^\n\r]*reference binding to null pointer of type 'int'(\n|\r\n|\r)" } +// { dg-output "\[^\n\r]*reference binding to null pointer of type 'int'(\n|\r\n|\r)" } +// { dg-output "\[^\n\r]*reference binding to null pointer of type 'int'(\n|\r\n|\r)" } diff --git a/gcc/testsuite/g++.dg/ubsan/null-4.C b/gcc/testsuite/g++.dg/ubsan/null-4.C new file mode 100644 index 0000000000..55944a4712 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/null-4.C @@ -0,0 +1,20 @@ +// { dg-do run } +// { dg-options "-O -fsanitize=null -fno-sanitize-recover=null -fdump-tree-sanopt-details" } +// { dg-skip-if "" { *-*-* } { "-flto -fno-fat-lto-objects" } } +// { dg-shouldfail "ubsan" } + +int +main (void) +{ + int *p = 0; + + int &r1 = *p; + int &r2 = *p; + int &r3 = *p; + int &r4 = *p; + int &r5 = *p; +} + +// { dg-output "reference binding to null pointer of type 'int'(\n|\r\n|\r)" } +// { dg-final { scan-tree-dump-times "Optimizing" 4 "sanopt"} } +// { dg-final { cleanup-tree-dump "sanopt" } } diff --git a/gcc/testsuite/g++.dg/ubsan/null-5.C b/gcc/testsuite/g++.dg/ubsan/null-5.C new file mode 100644 index 0000000000..fbda96ff47 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/null-5.C @@ -0,0 +1,19 @@ +// { dg-do run } +// { dg-options "-O -fsanitize=null -fsanitize-undefined-trap-on-error -fdump-tree-sanopt-details" } +// { dg-skip-if "" { *-*-* } { "-flto -fno-fat-lto-objects" } } +// { dg-shouldfail "ubsan" } + +int +main (void) +{ + int *p = 0; + + int &r1 = *p; + int &r2 = *p; + int &r3 = *p; + int &r4 = *p; + int &r5 = *p; +} + +// { dg-final { scan-tree-dump-times "Optimizing" 4 "sanopt"} } +// { dg-final { cleanup-tree-dump "sanopt" } } diff --git a/gcc/testsuite/g++.dg/ubsan/object-size-1.C b/gcc/testsuite/g++.dg/ubsan/object-size-1.C new file mode 100644 index 0000000000..e2aad4670b --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/object-size-1.C @@ -0,0 +1,18 @@ +// { dg-do compile } +// { dg-options "-fsanitize=undefined -fpermissive" } + +struct T { int c; char d[]; }; + +struct T t = { 1, "a" }; // { dg-warning "initializer-string for array of chars is too long" } + +int +baz (int i) +{ + return t.d[i]; +} + +int +main (void) +{ + baz (3); +} diff --git a/gcc/testsuite/g++.dg/ubsan/pr63813.C b/gcc/testsuite/g++.dg/ubsan/pr63813.C new file mode 100644 index 0000000000..6ca5b2d18c --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/pr63813.C @@ -0,0 +1,12 @@ +// PR sanitizer/63813 +// { dg-do compile } +// { dg-options "-fsanitize=undefined -O1" } + +struct A {}; +struct B { long foo () const; A &bar () const; }; + +A & +B::bar () const +{ + return *reinterpret_cast <A *> (foo ()); +} diff --git a/gcc/testsuite/g++.dg/ubsan/pr63913.C b/gcc/testsuite/g++.dg/ubsan/pr63913.C new file mode 100644 index 0000000000..34dceb4d84 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/pr63913.C @@ -0,0 +1,12 @@ +// PR sanitizer/63913 +// { dg-do compile } +// { dg-options "-fsanitize=bool -fnon-call-exceptions" } + +struct B { B (); ~B (); }; + +double +foo (bool *x) +{ + B b; + return *x; +} diff --git a/gcc/testsuite/g++.dg/ubsan/pr63956.C b/gcc/testsuite/g++.dg/ubsan/pr63956.C new file mode 100644 index 0000000000..185a719c8c --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/pr63956.C @@ -0,0 +1,172 @@ +// PR sanitizer/63956 +// { dg-do compile } +// { dg-options "-std=c++14 -fsanitize=undefined,float-divide-by-zero,float-cast-overflow" } + +#define SA(X) static_assert((X),#X) +#define INT_MIN (-__INT_MAX__ - 1) + +constexpr int +fn1 (int a, int b) +{ + if (b != 2) + a <<= b; + return a; +} + +constexpr int i1 = fn1 (5, 3); +constexpr int i2 = fn1 (5, -2); // { dg-error "is negative" } +constexpr int i3 = fn1 (5, sizeof (int) * __CHAR_BIT__); // { dg-error "is >= than the precision of the left operand" } +constexpr int i4 = fn1 (5, 256); // { dg-error "is >= than the precision of the left operand" } +constexpr int i5 = fn1 (5, 2); +constexpr int i6 = fn1 (-2, 4); // { dg-error "is negative" } +constexpr int i7 = fn1 (0, 2); + +SA (i1 == 40); +SA (i5 == 5); +SA (i7 == 0); + +constexpr int +fn2 (int a, int b) +{ + if (b != 2) + a >>= b; + return a; +} + +constexpr int j1 = fn2 (4, 1); +constexpr int j2 = fn2 (4, -1); // { dg-error "is negative" } +constexpr int j3 = fn2 (10, sizeof (int) * __CHAR_BIT__); // { dg-error "is >= than the precision of the left operand" } +constexpr int j4 = fn2 (1, 256); // { dg-error "is >= than the precision of the left operand" } +constexpr int j5 = fn2 (5, 2); +constexpr int j6 = fn2 (-2, 4); +constexpr int j7 = fn2 (0, 4); + +SA (j1 == 2); +SA (j5 == 5); +SA (j7 == 0); + +constexpr int +fn3 (int a, int b) +{ + if (b != 2) + a = a / b; + return a; +} + +constexpr int k1 = fn3 (8, 4); +constexpr int k2 = fn3 (7, 0); // { dg-error "is not a constant expression" } +constexpr int k3 = fn3 (INT_MIN, -1); // { dg-error "overflow in constant expression" } + +SA (k1 == 2); + +constexpr float +fn4 (float a, float b) +{ + if (b != 2.0) + a = a / b; + return a; +} + +constexpr float l1 = fn4 (5.0, 3.0); +constexpr float l2 = fn4 (7.0, 0.0); // { dg-error "is not a constant expression" } + +constexpr int +fn5 (const int *a, int b) +{ + if (b != 2) + b = a[b]; + return b; +} + +constexpr int m1[4] = { 1, 2, 3, 4 }; +constexpr int m2 = fn5 (m1, 3); +constexpr int m3 = fn5 (m1, 4); // { dg-error "array subscript out of bound" } + +constexpr int +fn6 (const int &a, int b) +{ + if (b != 2) + b = a; + return b; +} + +constexpr int +fn7 (const int *a, int b) +{ + if (b != 3) + return fn6 (*a, b); + return 7; +} + +constexpr int n1 = 7; +constexpr int n2 = fn7 (&n1, 5); +constexpr int n3 = fn7 ((const int *) 0, 8); // { dg-error "is not a constant expression" } + +constexpr int +fn8 (int i) +{ + constexpr int g[10] = { }; + return g[i]; +} + +constexpr int o1 = fn8 (9); +constexpr int o2 = fn8 (10); // { dg-error "array subscript out of bound" } + +constexpr int +fn9 (int a, int b) +{ + if (b != 0) + return a + b; + return a; +} + +constexpr int p1 = fn9 (42, 7); +constexpr int p2 = fn9 (__INT_MAX__, 1); // { dg-error "overflow in constant expression" } +constexpr int p3 = fn9 (__INT_MAX__, -1); +constexpr int p4 = fn9 (INT_MIN, 1); +constexpr int p5 = fn9 (INT_MIN, -1); // { dg-error "overflow in constant expression" } + +SA (p1 == 49); +SA (p3 == __INT_MAX__ - 1); +SA (p4 == INT_MIN + 1); + +constexpr int +fn10 (int a, int b) +{ + if (b != 0) + return a * b; + return a; +} + +constexpr int q1 = fn10 (10, 10); +constexpr int q2 = fn10 (__INT_MAX__, 2); // { dg-error "overflow in constant expression" } +constexpr int q3 = fn10 (INT_MIN, 2); // { dg-error "overflow in constant expression" } +constexpr int q4 = fn10 (-1, -1); + +SA (q1 == 100); +SA (q4 == 1); + +constexpr int +fn11 (double d) +{ + int i = d; + if (i != 0) + return i; + return i * 2; +} + +constexpr int r1 = fn11 (3.4); +constexpr int r2 = fn11 (__builtin_inf ()); // { dg-error "overflow in constant expression" } + +constexpr int +fn12 (int i) +{ + if (i == 42) + __builtin_unreachable (); // { dg-error "is not a constant expression" } + return i + 10; +} + +constexpr int s1 = fn12 (1); +constexpr int s2 = fn12 (42); + +SA (s1 == 11); diff --git a/gcc/testsuite/g++.dg/ubsan/pr64632.C b/gcc/testsuite/g++.dg/ubsan/pr64632.C new file mode 100644 index 0000000000..0d2a7aa9ae --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/pr64632.C @@ -0,0 +1,23 @@ +// PR sanitizer/64632 +// { dg-do run } +// { dg-options "-fsanitize=vptr -fno-sanitize-recover=vptr" } + +struct S +{ + S () : a(0) {} + int a; + int f () { return a; } + virtual int v () { return 0; } +}; + +struct X : virtual S +{ + int v () { return 2; } +}; + +int +main () +{ + X x; + return x.f (); +} diff --git a/gcc/testsuite/g++.dg/ubsan/pr64717-1.C b/gcc/testsuite/g++.dg/ubsan/pr64717-1.C new file mode 100644 index 0000000000..45ed8c6f03 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/pr64717-1.C @@ -0,0 +1,15 @@ +// PR c++/64717 +// { dg-do compile } +// { dg-options "-O2 -Wuninitialized -fsanitize=vptr" } + +class Foo {}; +Foo make_foo (); + +struct Handle { virtual ~Handle (); }; +Handle open (Foo); + +void +bar () +{ + Handle file (open (make_foo ())); // { dg-bogus "is used uninitialized" } +} diff --git a/gcc/testsuite/g++.dg/ubsan/pr64717-2.C b/gcc/testsuite/g++.dg/ubsan/pr64717-2.C new file mode 100644 index 0000000000..3f10440735 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/pr64717-2.C @@ -0,0 +1,20 @@ +// PR c++/64717 +// { dg-do compile } +// { dg-options "-O2 -Wuninitialized -fsanitize=vptr" } + +class ios {}; + +struct stringstream : virtual ios { + stringstream (char *); + ~stringstream (); +}; + +struct string { char *c_str (); }; + +string make_str (); + +void +bar () +{ + stringstream param (make_str ().c_str ()); // { dg-bogus "is used uninitialized" } +} diff --git a/gcc/testsuite/g++.dg/ubsan/pr64984.C b/gcc/testsuite/g++.dg/ubsan/pr64984.C new file mode 100644 index 0000000000..34f8926cc5 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/pr64984.C @@ -0,0 +1,76 @@ +// PR sanitizer/64984 +// { dg-do compile } +// { dg-options "-fsanitize=vptr -std=gnu++11" } + +template <typename X, X> struct K +{ + static constexpr X v = 0; + typedef K t; +}; +template <typename...> struct A; +template <typename X, typename Y> +struct A<X, Y> : Y +{ +}; +template <typename X> X M (); +template <typename...> struct B; +template <typename X, typename Y> +struct B<X, Y> : K<int, noexcept (static_cast<X>(M<Y>()))> +{ +}; +template <typename X, typename... Y> +struct G : A<int, B<X, Y...>>::t +{ +}; +template <typename X> struct J : G<X, X&&> +{ +}; +template <typename X> X&& foo (X&); +template <typename X> X&& bar (X&&); +template <typename X> struct P +{ + P (X& x) : q (x) {} + X q; +}; +template <typename...> struct Q; +template <typename X> +struct Q<X> : P<X> +{ + typedef P<X> r; + X& s (Q&); + Q (X& x) : r (x) {} + Q (Q&& x) noexcept (J<X>::v) : r (foo<X>(s (x))) + { + } +}; +template <typename... X> struct I : Q<X...> +{ + I (); + I (X&... x) : Q<X...>(x...) + { + } +}; +template <typename... X> +I<X&&...> baz (X&&... x) +{ + return I <X&&...> (foo<X>(x)...); +} +template <typename X> struct F +{ + int p; + void operator[] (X&& x) + { + baz (bar (x)); + } +}; +struct U +{ + virtual ~U (); +}; + +int +main () +{ + F<U> m; + m[U ()]; +} diff --git a/gcc/testsuite/g++.dg/ubsan/pr65000.C b/gcc/testsuite/g++.dg/ubsan/pr65000.C new file mode 100644 index 0000000000..298547e0dc --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/pr65000.C @@ -0,0 +1,14 @@ +// PR sanitizer/65000 +// { dg-do compile } +// { dg-options "-O1 -fsanitize=undefined -fno-sanitize-recover" } + +struct B { virtual ~B () {} void foo (); }; +struct C { virtual ~C (); }; +struct A : public virtual C {}; +struct D : A { ~D () { d.foo (); } B d; }; + +void +bar () +{ + D a; +} diff --git a/gcc/testsuite/g++.dg/ubsan/pr65019.C b/gcc/testsuite/g++.dg/ubsan/pr65019.C new file mode 100644 index 0000000000..a7f21a7d24 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/pr65019.C @@ -0,0 +1,24 @@ +// PR sanitizer/65019 +// { dg-do compile } +// { dg-options "-fsanitize=alignment,object-size,vptr -std=c++11 -O2 -fcompare-debug" } + +struct A { }; +struct B { }; +struct C final { + C (const A &, int); + static B *foo (const A &, int = 1); + virtual ~C (); + void *c; +}; + +B * +C::foo (const A &x, int y) +{ + C *d = new C (x, y); + if (d->c == nullptr) + delete d; +} + +C::~C () +{ +} diff --git a/gcc/testsuite/g++.dg/ubsan/pr65583.C b/gcc/testsuite/g++.dg/ubsan/pr65583.C new file mode 100644 index 0000000000..4e1149e9cb --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/pr65583.C @@ -0,0 +1,140 @@ +// PR sanitizer/65583 +// { dg-do compile } +// { dg-options "-std=c++11 -fsanitize=undefined" } + +namespace std +{ + inline namespace __cxx11 + { + } + template < typename > class allocator; + template < class _CharT > struct char_traits; + namespace __cxx11 + { + template < typename _CharT, typename _Traits = + char_traits < _CharT >, typename _Alloc = + allocator < _CharT > >class basic_string; + typedef basic_string < char >string; + } +} +namespace std +{ + template < typename _Tp, _Tp __v > struct integral_constant + { + static constexpr _Tp value = __v; + }; + typedef integral_constant < bool, true > true_type; +} +namespace __gnu_cxx +{ + template < typename _Tp > class new_allocator + { + public: + typedef long unsigned size_type; + typedef _Tp value_type; + template < typename _Tp1 > struct rebind + { + typedef new_allocator < _Tp1 > other; + }; + }; +} +namespace std +{ + template < typename _Tp > using __allocator_base = + __gnu_cxx::new_allocator < _Tp >; + template < typename _Tp > class allocator:public __allocator_base < _Tp > + { + }; + template < typename _Alloc, typename _Tp > class __alloctr_rebind_helper + { + template < typename _Alloc2, typename _Tp2 > + static constexpr true_type _S_chk (typename _Alloc2::template rebind < + _Tp2 >::other *); + public: + using __type = decltype (_S_chk < _Alloc, _Tp > (nullptr)); + }; + template < typename _Alloc, typename _Tp, bool = + __alloctr_rebind_helper < _Alloc, + _Tp >::__type::value > struct __alloctr_rebind; + template < typename _Alloc, typename _Tp > struct __alloctr_rebind <_Alloc, + _Tp, true > + { + typedef typename _Alloc::template rebind < _Tp >::other __type; + }; + template < typename _Alloc > struct allocator_traits + { + typedef typename _Alloc::value_type value_type; + static value_type *_S_pointer_helper (...); + typedef decltype (_S_pointer_helper ((_Alloc *) 0)) __pointer; + typedef __pointer pointer; + template < typename _Tp > + static typename _Tp::size_type _S_size_type_helper (_Tp *); + typedef decltype (_S_size_type_helper ((_Alloc *) 0)) __size_type; + typedef __size_type size_type; + template < typename _Tp > using rebind_alloc = + typename __alloctr_rebind < _Alloc, _Tp >::__type; + }; +} +namespace __gnu_cxx +{ + template < typename _Alloc > struct __alloc_traits:std::allocator_traits < + _Alloc > + { + typedef std::allocator_traits < _Alloc > _Base_type; + template < typename _Tp > struct rebind + { + typedef typename _Base_type::template rebind_alloc < _Tp > other; + }; + }; +} +namespace std +{ + namespace __cxx11 + { + template < typename _CharT, typename _Traits, + typename _Alloc > class basic_string + { + typedef typename __gnu_cxx::__alloc_traits < _Alloc >::template rebind < + _CharT >::other _Char_alloc_type; + typedef __gnu_cxx::__alloc_traits < _Char_alloc_type > _Alloc_traits; + typedef _Char_alloc_type allocator_type; + typedef typename _Alloc_traits::size_type size_type; + typedef typename _Alloc_traits::pointer pointer; + struct _Alloc_hider:allocator_type + { + _Alloc_hider (pointer __dat, const _Alloc & __a) + { + } + }; + _Alloc_hider _M_dataplus; + union + { + size_type _M_allocated_capacity; + }; + pointer _M_local_data () + { + } + void _M_dispose () + { + _M_destroy (_M_allocated_capacity); + } + void _M_destroy (size_type __size) throw () + { + } + public: + basic_string (const _CharT * __s, const _Alloc & __a = _Alloc ()):_M_dataplus (_M_local_data (), + __a) + { + _M_dispose (); + } + }; + } + class FileHandle + { + std::string fname; + FileHandle (const char *fname); + }; + FileHandle::FileHandle (const char *fname):fname (fname) + { + } +} diff --git a/gcc/testsuite/g++.dg/ubsan/pr65610.C b/gcc/testsuite/g++.dg/ubsan/pr65610.C new file mode 100644 index 0000000000..ced59a8743 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/pr65610.C @@ -0,0 +1,57 @@ +// PR ipa/65610 +// { dg-do compile } +// { dg-options "-std=c++11 -fsanitize=undefined -fno-sanitize=vptr -fcompare-debug" } + +class A; +class B {}; +enum C { D }; +class E; +class F; +class G; +class H +{ + F m1 (const A &t) const; + G m2 () const; +}; +class G {}; +template <class S, class T> +class I; +template <class S, class T> +class J +{ + friend class I <S,T>; + J <S,T> *j; +}; +template <class S, class T> +struct I +{ + virtual ~I (); + virtual void m3 (void *p) {} + J <S,T> *i; + void m4 (J <S,T>*& t); +}; +template <class S, class T> +void I <S,T>::m4 (J <S,T> * &t) +{ + m4 (t->j); + m3 (t); +} +template <class S, class T> +I <S,T>::~I () +{ + m4 (i); +} +struct F +{ + explicit inline F (C v); + inline ~F (); + I <B, E> f; +}; +inline F::F (C v) {} +inline F::~F () {} +F H::m1 (const A &t) const +{ + F q (D); + G r = m2 (); + return q; +} diff --git a/gcc/testsuite/g++.dg/ubsan/return-2.C b/gcc/testsuite/g++.dg/ubsan/return-2.C index 546f178105..90c48b5b1d 100644 --- a/gcc/testsuite/g++.dg/ubsan/return-2.C +++ b/gcc/testsuite/g++.dg/ubsan/return-2.C @@ -1,7 +1,5 @@ // { dg-do run } -// { dg-options "-fsanitize=return" } - -#include <stdio.h> +// { dg-options "-fsanitize=return -fno-sanitize-recover=return" } struct S { S (); ~S (); }; @@ -22,12 +20,6 @@ foo (int x) int main () { - fputs ("UBSAN TEST START\n", stderr); - foo (1); foo (14); - - fputs ("UBSAN TEST END\n", stderr); } - -/* { dg-output "UBSAN TEST START(\n|\r\n|\r)UBSAN TEST END" } */ diff --git a/gcc/testsuite/g++.dg/ubsan/return-3.C b/gcc/testsuite/g++.dg/ubsan/return-3.C new file mode 100644 index 0000000000..95f345deb3 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/return-3.C @@ -0,0 +1,27 @@ +// { dg-do compile } +// { dg-options "-fsanitize=return" } + +struct S { S (); ~S (); }; + +S::S () {} +S::~S () {} + +__attribute__((no_sanitize_undefined)) +int +foo (int x) +{ + S a; + { + S b; + if (x) + return 1; + } +} + +int +main () +{ + foo (0); +} + +// { dg-final { scan-assembler-not "__ubsan_handle" } } diff --git a/gcc/testsuite/g++.dg/ubsan/shift-1.C b/gcc/testsuite/g++.dg/ubsan/shift-1.C new file mode 100644 index 0000000000..05e049e82e --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/shift-1.C @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-fsanitize=shift -w" } */ +/* { dg-shouldfail "ubsan" } */ + +int +foo (int x) +{ + /* None of the following should pass. */ + switch (x) + { + case 1 >> -1: /* { dg-error "is not a constant expression" "" { xfail { *-*-* } } } */ + case -1 >> -1: /* { dg-error "is not a constant expression" "" { xfail { *-*-* } } } */ + case 1 << -1: /* { dg-error "is not a constant expression" "" { xfail { *-*-* } } } */ + case -1 << -1: /* { dg-error "is not a constant expression" "" { xfail { *-*-* } } } */ + return 1; + } + return 0; +} + +int +bar (int x) +{ + /* None of the following should pass. */ + switch (x) + { + case -1 >> 200: /* { dg-error "is not a constant expression" "" { xfail { *-*-* } } } */ + case 1 << 200: /* { dg-error "is not a constant expression" "" { xfail { *-*-* } } } */ + return 1; + } + return 0; +} diff --git a/gcc/testsuite/g++.dg/ubsan/ubsan.exp b/gcc/testsuite/g++.dg/ubsan/ubsan.exp index 7d5e9ba72e..5d5e10b286 100644 --- a/gcc/testsuite/g++.dg/ubsan/ubsan.exp +++ b/gcc/testsuite/g++.dg/ubsan/ubsan.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2014 Free Software Foundation, Inc. +# Copyright (C) 2013-2015 Free Software Foundation, Inc. # # This file is part of GCC. # @@ -22,11 +22,11 @@ load_lib ubsan-dg.exp # Initialize `dg'. dg-init -if [ubsan_init] { +ubsan_init # Main loop. -gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C $srcdir/c-c++-common/ubsan/*.c]] "" - +if [check_effective_target_fsanitize_undefined] { + gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C $srcdir/c-c++-common/ubsan/*.c]] "" "" } # All done. diff --git a/gcc/testsuite/g++.dg/ubsan/vla-1.C b/gcc/testsuite/g++.dg/ubsan/vla-1.C new file mode 100644 index 0000000000..e7f24945f7 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/vla-1.C @@ -0,0 +1,13 @@ +// { dg-do run } +// { dg-options "-Wno-vla -fsanitize=undefined" } +// { dg-shouldfail "ubsan" } +// { dg-output "index 1 out of bounds" } + +void f(int i) { + int ar[i] = { 42, 24 }; +} + +int main() +{ + f(1); +} diff --git a/gcc/testsuite/g++.dg/ubsan/vptr-1.C b/gcc/testsuite/g++.dg/ubsan/vptr-1.C new file mode 100644 index 0000000000..f4260c1ba4 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/vptr-1.C @@ -0,0 +1,184 @@ +// { dg-do run { target { ilp32 || lp64 } } } +// { dg-options "-fsanitize=vptr" } + +struct S +{ + S() : a(0) {} + ~S() {} + int a; + int f() { return 0; } + virtual int v() { return 0; } +}; + +struct T : S +{ + T() : b(0) {} + int b; + int g() { return 0; } + virtual int v() { return 1; } +}; + +struct U : S, T { virtual int v() { return 2; } }; // { dg-warning "direct base .S. inaccessible in .U. due to ambiguity" } +struct V : S {}; + +void +foo () +{ + T t; + (void)t.a; + (void)t.b; + (void)t.f(); + (void)t.g(); + (void)t.v(); + (void)t.S::v(); + + U u; + (void)u.T::a; + (void)u.b; + (void)u.T::f(); + (void)u.g(); + (void)u.v(); + (void)u.T::v(); + (void)((T&)u).S::v(); +} + +T *x; + +__attribute__((noinline, noclone)) int +bar (T *p, int q) +{ + switch (q) + { + // These shouldn't fail: + case 0x10: + case 0x20: + case 0x30: + case 0x40: + { + T &r = *p; + break; + } + case 0x21: + case 0x31: + return p->b; + case 0x22: + case 0x32: + return p->g (); + case 0x23: + case 0x33: + x = static_cast<T*>(reinterpret_cast<S*>(p)); + break; + case 0x44: + return reinterpret_cast<U*>(p)->v() - 2; + // These should: + case 0x11: + return p->b; + // { dg-output "\[^\n\r]*vptr-1.C:75:\[0-9]*: runtime error: member access within address 0x\[0-9a-fA-F]* which does not point to an object of type 'T'(\n|\r\n|\r)" } + // { dg-output "0x\[0-9a-fA-F]*: note: object is of type 'S'(\n|\r\n|\r)" } + // { dg-output " .. .. .. .. .. .. .. .. .. .. .. .. \[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " \\^~~~~~~~~~~\[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " vptr for 'S'\[^\n\r]*(\n|\r\n|\r)" } + case 0x12: + return p->g (); + // { dg-output "\[^\n\r]*vptr-1.C:82:\[0-9]*: runtime error: member call on address 0x\[0-9a-fA-F]* which does not point to an object of type 'T'(\n|\r\n|\r)" } + // { dg-output "0x\[0-9a-fA-F]*: note: object is of type 'S'(\n|\r\n|\r)" } + // { dg-output " .. .. .. .. .. .. .. .. .. .. .. .. \[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " \\^~~~~~~~~~~\[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " vptr for 'S'\[^\n\r]*(\n|\r\n|\r)" } + case 0x13: + x = static_cast<T*>(reinterpret_cast<S*>(p)); + break; + // { dg-output "\[^\n\r]*vptr-1.C:89:\[0-9]*: runtime error: downcast of address 0x\[0-9a-fA-F]* which does not point to an object of type 'T'(\n|\r\n|\r)" } + // { dg-output "0x\[0-9a-fA-F]*: note: object is of type 'S'(\n|\r\n|\r)" } + // { dg-output " .. .. .. .. .. .. .. .. .. .. .. .. \[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " \\^~~~~~~~~~~\[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " vptr for 'S'\[^\n\r]*(\n|\r\n|\r)" } + case 0x34: + return reinterpret_cast<U*>(p)->v() - 2; + // { dg-output "\[^\n\r]*vptr-1.C:97:\[0-9]*: runtime error: member call on address 0x\[0-9a-fA-F]* which does not point to an object of type 'U'(\n|\r\n|\r)" } + // { dg-output "0x\[0-9a-fA-F]*: note: object is base class subobject at offset 16 within object of type 'U'(\n|\r\n|\r)" { target lp64 } } + // { dg-output "0x\[0-9a-fA-F]*: note: object is base class subobject at offset 8 within object of type 'U'(\n|\r\n|\r)" { target ilp32 } } + // { dg-output " .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. \[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " \\^ ~~~~~~~~~~~~~~~~~~~~~~~(\n|\r\n|\r)" { target lp64 } } + // { dg-output " vptr for 'T' base class of 'U'\[^\n\r]*(\n|\r\n|\r)" { target lp64 } } + // { dg-output " \\^ ~~~~~~~~~~~(\n|\r\n|\r)" { target ilp32 } } + // { dg-output " vptr for 'T' base class of 'U'\[^\n\r]*(\n|\r\n|\r)" { target ilp32 } } + case 0x41: + return p->b; + // { dg-output "\[^\n\r]*vptr-1.C:107:\[0-9]*: runtime error: member access within address 0x\[0-9a-fA-F]* which does not point to an object of type 'T'(\n|\r\n|\r)" } + // { dg-output "0x\[0-9a-fA-F]*: note: object is of type 'U'(\n|\r\n|\r)" } + // { dg-output " .. .. .. .. .. .. .. .. .. .. .. .. \[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " \\^~~~~~~~~~~\[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " vptr for 'U'\[^\n\r]*(\n|\r\n|\r)" } + case 0x42: + return p->g (); + // { dg-output "\[^\n\r]*vptr-1.C:114:\[0-9]*: runtime error: member call on address 0x\[0-9a-fA-F]* which does not point to an object of type 'T'(\n|\r\n|\r)" } + // { dg-output "0x\[0-9a-fA-F]*: note: object is of type 'U'(\n|\r\n|\r)" } + // { dg-output " .. .. .. .. .. .. .. .. .. .. .. .. \[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " \\^~~~~~~~~~~\[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " vptr for 'U'\[^\n\r]*(\n|\r\n|\r)" } + case 0x43: + x = static_cast<T*>(reinterpret_cast<S*>(p)); + break; + // { dg-output "\[^\n\r]*vptr-1.C:121:\[0-9]*: runtime error: downcast of address 0x\[0-9a-fA-F]* which does not point to an object of type 'T'(\n|\r\n|\r)" } + // { dg-output "0x\[0-9a-fA-F]*: note: object is of type 'U'(\n|\r\n|\r)" } + // { dg-output " .. .. .. .. .. .. .. .. .. .. .. .. \[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " \\^~~~~~~~~~~\[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " vptr for 'U'\[^\n\r]*(\n|\r\n|\r)" } + case 0x51: + return p->b; + // { dg-output "\[^\n\r]*vptr-1.C:129:\[0-9]*: runtime error: member access within address 0x\[0-9a-fA-F]* which does not point to an object of type 'T'(\n|\r\n|\r)" } + // { dg-output "0x\[0-9a-fA-F]*: note: object has invalid vptr(\n|\r\n|\r)" } + // { dg-output " .. .. .. .. 00 00 00 00 00 00 00 00 \[^\n\r]*(\n|\r\n|\r)" { target lp64 } } + // { dg-output " \\^~~~~~~~~~~~~~~~~~~~~~~\[^\n\r]*(\n|\r\n|\r)" { target lp64 } } + // { dg-output " ?.. .. .. .. ?00 00 00 00 ?.. .. .. .. ?\[^\n\r]*(\n|\r\n|\r)" { target ilp32 } } + // { dg-output " \\^~~~~~~~~~~\[^\n\r]*(\n|\r\n|\r)" { target ilp32 } } + // { dg-output " invalid vptr" } + } + return 0; +} + +char b[sizeof (U)] __attribute__((aligned (__alignof__ (U)))) = {}; + +__attribute__((noinline, noclone)) void +baz (int q) +{ + T *p = 0; + S *s = 0; + U *u = 0; + switch (q) + { + case 0x10: case 0x11: case 0x12: case 0x13: + s = new S; + bar (reinterpret_cast<T *>(s), q); + delete s; + break; + case 0x20: case 0x21: case 0x22: case 0x23: + p = new T; + bar (p, q); + delete p; + break; + case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: + u = new U; + bar (u, q); + delete u; + break; + case 0x40: case 0x41: case 0x42: case 0x43: case 0x44: + u = new U; + bar (reinterpret_cast<T *>(u), q); + delete u; + break; + case 0x51: + p = reinterpret_cast<T*>(b); + bar (p, q); + break; + } +} + +int +main () +{ + foo (); + for (int q = 0; q < 0x52; q++) + baz (q); +} diff --git a/gcc/testsuite/g++.dg/ubsan/vptr-2.C b/gcc/testsuite/g++.dg/ubsan/vptr-2.C new file mode 100644 index 0000000000..2aa70469a6 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/vptr-2.C @@ -0,0 +1,184 @@ +// { dg-do run { target { ilp32 || lp64 } } } +// { dg-options "-fsanitize=vptr" } + +struct S +{ + S() : a(0) {} + ~S() {} + int a; + int f() { return 0; } + virtual int v() { return 0; } +}; + +struct T : S +{ + T() : b(0) {} + int b; + int g() { return 0; } + virtual int v() { return 1; } +}; + +struct U : S, T { virtual int v() { return 2; } }; // { dg-warning "direct base .S. inaccessible in .U. due to ambiguity" } +struct V : S {}; + +void +foo () +{ + T t; + (void)t.a; + (void)t.b; + (void)t.f(); + (void)t.g(); + (void)t.v(); + (void)t.S::v(); + + U u; + (void)u.T::a; + (void)u.b; + (void)u.T::f(); + (void)u.g(); + (void)u.v(); + (void)u.T::v(); + (void)((T&)u).S::v(); +} + +T *x; +template <typename S, typename T, typename U> +__attribute__((noinline, noclone)) int +bar (T *p, int q) +{ + switch (q) + { + // These shouldn't fail: + case 0x10: + case 0x20: + case 0x30: + case 0x40: + { + T &r = *p; + break; + } + case 0x21: + case 0x31: + return p->b; + case 0x22: + case 0x32: + return p->g (); + case 0x23: + case 0x33: + x = static_cast<T*>(reinterpret_cast<S*>(p)); + break; + case 0x44: + return reinterpret_cast<U*>(p)->v() - 2; + // These should: + case 0x11: + return p->b; + // { dg-output "\[^\n\r]*vptr-2.C:75:\[0-9]*: runtime error: member access within address 0x\[0-9a-fA-F]* which does not point to an object of type 'T'(\n|\r\n|\r)" } + // { dg-output "0x\[0-9a-fA-F]*: note: object is of type 'S'(\n|\r\n|\r)" } + // { dg-output " .. .. .. .. .. .. .. .. .. .. .. .. \[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " \\^~~~~~~~~~~\[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " vptr for 'S'\[^\n\r]*(\n|\r\n|\r)" } + case 0x12: + return p->g (); + // { dg-output "\[^\n\r]*vptr-2.C:82:\[0-9]*: runtime error: member call on address 0x\[0-9a-fA-F]* which does not point to an object of type 'T'(\n|\r\n|\r)" } + // { dg-output "0x\[0-9a-fA-F]*: note: object is of type 'S'(\n|\r\n|\r)" } + // { dg-output " .. .. .. .. .. .. .. .. .. .. .. .. \[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " \\^~~~~~~~~~~\[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " vptr for 'S'\[^\n\r]*(\n|\r\n|\r)" } + case 0x13: + x = static_cast<T*>(reinterpret_cast<S*>(p)); + break; + // { dg-output "\[^\n\r]*vptr-2.C:89:\[0-9]*: runtime error: downcast of address 0x\[0-9a-fA-F]* which does not point to an object of type 'T'(\n|\r\n|\r)" } + // { dg-output "0x\[0-9a-fA-F]*: note: object is of type 'S'(\n|\r\n|\r)" } + // { dg-output " .. .. .. .. .. .. .. .. .. .. .. .. \[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " \\^~~~~~~~~~~\[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " vptr for 'S'\[^\n\r]*(\n|\r\n|\r)" } + case 0x34: + return reinterpret_cast<U*>(p)->v() - 2; + // { dg-output "\[^\n\r]*vptr-2.C:97:\[0-9]*: runtime error: member call on address 0x\[0-9a-fA-F]* which does not point to an object of type 'U'(\n|\r\n|\r)" } + // { dg-output "0x\[0-9a-fA-F]*: note: object is base class subobject at offset 16 within object of type 'U'(\n|\r\n|\r)" { target lp64 } } + // { dg-output "0x\[0-9a-fA-F]*: note: object is base class subobject at offset 8 within object of type 'U'(\n|\r\n|\r)" { target ilp32 } } + // { dg-output " .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. \[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " \\^ ~~~~~~~~~~~~~~~~~~~~~~~(\n|\r\n|\r)" { target lp64 } } + // { dg-output " vptr for 'T' base class of 'U'\[^\n\r]*(\n|\r\n|\r)" { target lp64 } } + // { dg-output " \\^ ~~~~~~~~~~~(\n|\r\n|\r)" { target ilp32 } } + // { dg-output " vptr for 'T' base class of 'U'\[^\n\r]*(\n|\r\n|\r)" { target ilp32 } } + case 0x41: + return p->b; + // { dg-output "\[^\n\r]*vptr-2.C:107:\[0-9]*: runtime error: member access within address 0x\[0-9a-fA-F]* which does not point to an object of type 'T'(\n|\r\n|\r)" } + // { dg-output "0x\[0-9a-fA-F]*: note: object is of type 'U'(\n|\r\n|\r)" } + // { dg-output " .. .. .. .. .. .. .. .. .. .. .. .. \[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " \\^~~~~~~~~~~\[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " vptr for 'U'\[^\n\r]*(\n|\r\n|\r)" } + case 0x42: + return p->g (); + // { dg-output "\[^\n\r]*vptr-2.C:114:\[0-9]*: runtime error: member call on address 0x\[0-9a-fA-F]* which does not point to an object of type 'T'(\n|\r\n|\r)" } + // { dg-output "0x\[0-9a-fA-F]*: note: object is of type 'U'(\n|\r\n|\r)" } + // { dg-output " .. .. .. .. .. .. .. .. .. .. .. .. \[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " \\^~~~~~~~~~~\[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " vptr for 'U'\[^\n\r]*(\n|\r\n|\r)" } + case 0x43: + x = static_cast<T*>(reinterpret_cast<S*>(p)); + break; + // { dg-output "\[^\n\r]*vptr-2.C:121:\[0-9]*: runtime error: downcast of address 0x\[0-9a-fA-F]* which does not point to an object of type 'T'(\n|\r\n|\r)" } + // { dg-output "0x\[0-9a-fA-F]*: note: object is of type 'U'(\n|\r\n|\r)" } + // { dg-output " .. .. .. .. .. .. .. .. .. .. .. .. \[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " \\^~~~~~~~~~~\[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " vptr for 'U'\[^\n\r]*(\n|\r\n|\r)" } + case 0x51: + return p->b; + // { dg-output "\[^\n\r]*vptr-2.C:129:\[0-9]*: runtime error: member access within address 0x\[0-9a-fA-F]* which does not point to an object of type 'T'(\n|\r\n|\r)" } + // { dg-output "0x\[0-9a-fA-F]*: note: object has invalid vptr(\n|\r\n|\r)" } + // { dg-output " .. .. .. .. 00 00 00 00 00 00 00 00 \[^\n\r]*(\n|\r\n|\r)" { target lp64 } } + // { dg-output " \\^~~~~~~~~~~~~~~~~~~~~~~\[^\n\r]*(\n|\r\n|\r)" { target lp64 } } + // { dg-output " ?.. .. .. .. ?00 00 00 00 ?.. .. .. .. ?\[^\n\r]*(\n|\r\n|\r)" { target ilp32 } } + // { dg-output " \\^~~~~~~~~~~\[^\n\r]*(\n|\r\n|\r)" { target ilp32 } } + // { dg-output " invalid vptr" } + } + return 0; +} + +char b[sizeof (U)] __attribute__((aligned (__alignof__ (U)))) = {}; + +__attribute__((noinline, noclone)) void +baz (int q) +{ + T *p = 0; + S *s = 0; + U *u = 0; + switch (q) + { + case 0x10: case 0x11: case 0x12: case 0x13: + s = new S; + bar<S, T, U> (reinterpret_cast<T *>(s), q); + delete s; + break; + case 0x20: case 0x21: case 0x22: case 0x23: + p = new T; + bar<S, T, U> (p, q); + delete p; + break; + case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: + u = new U; + bar<S, T, U> (u, q); + delete u; + break; + case 0x40: case 0x41: case 0x42: case 0x43: case 0x44: + u = new U; + bar<S, T, U> (reinterpret_cast<T *>(u), q); + delete u; + break; + case 0x51: + p = reinterpret_cast<T*>(b); + bar<S, T, U> (p, q); + break; + } +} + +int +main () +{ + foo (); + for (int q = 0; q < 0x52; q++) + baz (q); +} diff --git a/gcc/testsuite/g++.dg/ubsan/vptr-3.C b/gcc/testsuite/g++.dg/ubsan/vptr-3.C new file mode 100644 index 0000000000..916d8ef8e2 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/vptr-3.C @@ -0,0 +1,184 @@ +// { dg-do run { target { ilp32 || lp64 } } } +// { dg-options "-fsanitize=vptr" } + +struct S +{ + S() : a(0) {} + ~S() {} + int a; + int f() { return 0; } + virtual int v() { return 0; } +}; + +struct T : S +{ + T() : b(0) {} + int b; + int g() { return 0; } + virtual int v() { return 1; } +}; + +struct U : S, T { virtual int v() { return 2; } }; // { dg-warning "direct base .S. inaccessible in .U. due to ambiguity" } +struct V : S {}; + +void +foo () +{ + T t; + (void)t.a; + (void)t.b; + (void)t.f(); + (void)t.g(); + (void)t.v(); + (void)t.S::v(); + + U u; + (void)u.T::a; + (void)u.b; + (void)u.T::f(); + (void)u.g(); + (void)u.v(); + (void)u.T::v(); + (void)((T&)u).S::v(); +} + +T *x; +template <int N> +__attribute__((noinline, noclone)) int +bar (T *p, int q) +{ + switch (q) + { + // These shouldn't fail: + case 0x10: + case 0x20: + case 0x30: + case 0x40: + { + T &r = *p; + break; + } + case 0x21: + case 0x31: + return p->b; + case 0x22: + case 0x32: + return p->g (); + case 0x23: + case 0x33: + x = static_cast<T*>(reinterpret_cast<S*>(p)); + break; + case 0x44: + return reinterpret_cast<U*>(p)->v() - 2; + // These should: + case 0x11: + return p->b; + // { dg-output "\[^\n\r]*vptr-3.C:75:\[0-9]*: runtime error: member access within address 0x\[0-9a-fA-F]* which does not point to an object of type 'T'(\n|\r\n|\r)" } + // { dg-output "0x\[0-9a-fA-F]*: note: object is of type 'S'(\n|\r\n|\r)" } + // { dg-output " .. .. .. .. .. .. .. .. .. .. .. .. \[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " \\^~~~~~~~~~~\[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " vptr for 'S'\[^\n\r]*(\n|\r\n|\r)" } + case 0x12: + return p->g (); + // { dg-output "\[^\n\r]*vptr-3.C:82:\[0-9]*: runtime error: member call on address 0x\[0-9a-fA-F]* which does not point to an object of type 'T'(\n|\r\n|\r)" } + // { dg-output "0x\[0-9a-fA-F]*: note: object is of type 'S'(\n|\r\n|\r)" } + // { dg-output " .. .. .. .. .. .. .. .. .. .. .. .. \[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " \\^~~~~~~~~~~\[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " vptr for 'S'\[^\n\r]*(\n|\r\n|\r)" } + case 0x13: + x = static_cast<T*>(reinterpret_cast<S*>(p)); + break; + // { dg-output "\[^\n\r]*vptr-3.C:89:\[0-9]*: runtime error: downcast of address 0x\[0-9a-fA-F]* which does not point to an object of type 'T'(\n|\r\n|\r)" } + // { dg-output "0x\[0-9a-fA-F]*: note: object is of type 'S'(\n|\r\n|\r)" } + // { dg-output " .. .. .. .. .. .. .. .. .. .. .. .. \[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " \\^~~~~~~~~~~\[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " vptr for 'S'\[^\n\r]*(\n|\r\n|\r)" } + case 0x34: + return reinterpret_cast<U*>(p)->v() - 2; + // { dg-output "\[^\n\r]*vptr-3.C:97:\[0-9]*: runtime error: member call on address 0x\[0-9a-fA-F]* which does not point to an object of type 'U'(\n|\r\n|\r)" } + // { dg-output "0x\[0-9a-fA-F]*: note: object is base class subobject at offset 16 within object of type 'U'(\n|\r\n|\r)" { target lp64 } } + // { dg-output "0x\[0-9a-fA-F]*: note: object is base class subobject at offset 8 within object of type 'U'(\n|\r\n|\r)" { target ilp32 } } + // { dg-output " .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. \[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " \\^ ~~~~~~~~~~~~~~~~~~~~~~~(\n|\r\n|\r)" { target lp64 } } + // { dg-output " vptr for 'T' base class of 'U'\[^\n\r]*(\n|\r\n|\r)" { target lp64 } } + // { dg-output " \\^ ~~~~~~~~~~~(\n|\r\n|\r)" { target ilp32 } } + // { dg-output " vptr for 'T' base class of 'U'\[^\n\r]*(\n|\r\n|\r)" { target ilp32 } } + case 0x41: + return p->b; + // { dg-output "\[^\n\r]*vptr-3.C:107:\[0-9]*: runtime error: member access within address 0x\[0-9a-fA-F]* which does not point to an object of type 'T'(\n|\r\n|\r)" } + // { dg-output "0x\[0-9a-fA-F]*: note: object is of type 'U'(\n|\r\n|\r)" } + // { dg-output " .. .. .. .. .. .. .. .. .. .. .. .. \[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " \\^~~~~~~~~~~\[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " vptr for 'U'\[^\n\r]*(\n|\r\n|\r)" } + case 0x42: + return p->g (); + // { dg-output "\[^\n\r]*vptr-3.C:114:\[0-9]*: runtime error: member call on address 0x\[0-9a-fA-F]* which does not point to an object of type 'T'(\n|\r\n|\r)" } + // { dg-output "0x\[0-9a-fA-F]*: note: object is of type 'U'(\n|\r\n|\r)" } + // { dg-output " .. .. .. .. .. .. .. .. .. .. .. .. \[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " \\^~~~~~~~~~~\[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " vptr for 'U'\[^\n\r]*(\n|\r\n|\r)" } + case 0x43: + x = static_cast<T*>(reinterpret_cast<S*>(p)); + break; + // { dg-output "\[^\n\r]*vptr-3.C:121:\[0-9]*: runtime error: downcast of address 0x\[0-9a-fA-F]* which does not point to an object of type 'T'(\n|\r\n|\r)" } + // { dg-output "0x\[0-9a-fA-F]*: note: object is of type 'U'(\n|\r\n|\r)" } + // { dg-output " .. .. .. .. .. .. .. .. .. .. .. .. \[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " \\^~~~~~~~~~~\[^\n\r]*(\n|\r\n|\r)" } + // { dg-output " vptr for 'U'\[^\n\r]*(\n|\r\n|\r)" } + case 0x51: + return p->b; + // { dg-output "\[^\n\r]*vptr-3.C:129:\[0-9]*: runtime error: member access within address 0x\[0-9a-fA-F]* which does not point to an object of type 'T'(\n|\r\n|\r)" } + // { dg-output "0x\[0-9a-fA-F]*: note: object has invalid vptr(\n|\r\n|\r)" } + // { dg-output " .. .. .. .. 00 00 00 00 00 00 00 00 \[^\n\r]*(\n|\r\n|\r)" { target lp64 } } + // { dg-output " \\^~~~~~~~~~~~~~~~~~~~~~~\[^\n\r]*(\n|\r\n|\r)" { target lp64 } } + // { dg-output " ?.. .. .. .. ?00 00 00 00 ?.. .. .. .. ?\[^\n\r]*(\n|\r\n|\r)" { target ilp32 } } + // { dg-output " \\^~~~~~~~~~~\[^\n\r]*(\n|\r\n|\r)" { target ilp32 } } + // { dg-output " invalid vptr" } + } + return 0; +} + +char b[sizeof (U)] __attribute__((aligned (__alignof__ (U)))) = {}; + +__attribute__((noinline, noclone)) void +baz (int q) +{ + T *p = 0; + S *s = 0; + U *u = 0; + switch (q) + { + case 0x10: case 0x11: case 0x12: case 0x13: + s = new S; + bar<0> (reinterpret_cast<T *>(s), q); + delete s; + break; + case 0x20: case 0x21: case 0x22: case 0x23: + p = new T; + bar<0> (p, q); + delete p; + break; + case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: + u = new U; + bar<0> (u, q); + delete u; + break; + case 0x40: case 0x41: case 0x42: case 0x43: case 0x44: + u = new U; + bar<0> (reinterpret_cast<T *>(u), q); + delete u; + break; + case 0x51: + p = reinterpret_cast<T*>(b); + bar<0> (p, q); + break; + } +} + +int +main () +{ + foo (); + for (int q = 0; q < 0x52; q++) + baz (q); +} diff --git a/gcc/testsuite/g++.dg/ubsan/vptr-4.C b/gcc/testsuite/g++.dg/ubsan/vptr-4.C new file mode 100644 index 0000000000..1c037d047d --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/vptr-4.C @@ -0,0 +1,54 @@ +// Verify that -fsanitize=vptr downcast instrumentation works properly +// inside of constexpr. +// { dg-do compile } +// { dg-options "-std=c++11 -fsanitize=vptr" } + +struct S { + constexpr S() : a(0) {} + int a; + int f() { return 0; } + virtual int v() { return 0; } +}; + +struct T : S { + constexpr T() : b(0) {} + int b; + int g() { return 0; } + virtual int v() { return 1; } + constexpr const T *foo() { return (const T *) reinterpret_cast<const S *> (this); } +}; + +constexpr T t; +constexpr const T *p = t.foo (); + +template <typename U> +struct V { + constexpr V() : a(0) {} + int a; + int f() { return 0; } + virtual int v() { return 0; } +}; + +template <typename U> +struct W : V<U> { + constexpr W() : b(0) {} + int b; + int g() { return 0; } + virtual int v() { return 1; } + constexpr const W<U> *foo() { return (const W<U> *) reinterpret_cast<const V<U> *> (this); } +}; + +constexpr W<int> w; +constexpr const W<int> *s = w.foo (); + +template <typename U> +int foo (void) +{ + static constexpr T t; + static constexpr const T *p = t.foo (); + static constexpr W<U> w; + static constexpr const W<U> *s = w.foo (); + return t.b + w.b; +} + +int x = foo <char> (); diff --git a/gcc/testsuite/g++.dg/ubsan/vptr-5.C b/gcc/testsuite/g++.dg/ubsan/vptr-5.C new file mode 100644 index 0000000000..fb9d15cc99 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/vptr-5.C @@ -0,0 +1,32 @@ +// { dg-do run } +// { dg-options "-fsanitize=vptr" } + +struct S +{ + S() : a(0) {} + ~S() {} + int a; + int f() { return 0; } + virtual int v() { return 0; } +}; + +struct T : S +{ + T() : b(0) {} + int b; + int g() { return 0; } + virtual int v() { return 1; } +}; + +T * +foo (S *p) +{ + return (T *) p; +} + +int +main () +{ + if (foo (__null) != __null) + __builtin_abort (); +} diff --git a/gcc/testsuite/g++.dg/ubsan/vptr-6.C b/gcc/testsuite/g++.dg/ubsan/vptr-6.C new file mode 100644 index 0000000000..1e595c50c9 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/vptr-6.C @@ -0,0 +1,32 @@ +// { dg-do compile } +// { dg-skip-if "" { *-*-* } { "-flto" } { "" } } +// { dg-options "-fsanitize=vptr -O2 -fdump-tree-optimized" } + +struct S { virtual ~S (); int i; _Complex int j[5]; }; + +int +f1 (S *p) +{ + return p->i; +} + +int +f2 (S *p) +{ + return *&p->i; +} + +_Complex int * +f3 (S *p, S *q) +{ + return &p->j[q->i]; +} + +int +f4 (S &p, S &q) +{ + return __imag__ p.j[q.i]; +} + +// { dg-final { scan-tree-dump-times "__ubsan_handle_dynamic_type_cache_miss" 5 "optimized" } } +// { dg-final { cleanup-tree-dump "optimized" } } diff --git a/gcc/testsuite/g++.dg/ubsan/vptr-7.C b/gcc/testsuite/g++.dg/ubsan/vptr-7.C new file mode 100644 index 0000000000..d3ff1a36d5 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/vptr-7.C @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-skip-if "" { *-*-* } { "-flto" } { "" } } +// { dg-options "-fsanitize=vptr -O2 -fdump-tree-optimized" } + +struct S { virtual ~S (); int i; }; + +int * +f1 (S *p) +{ + return &p->i; +} + +int * +f2 (S *p) +{ + return &*&p->i; +} + +int & +f3 (S *p) +{ + return p->i; +} + +// { dg-final { scan-tree-dump-times "__ubsan_handle_dynamic_type_cache_miss" 0 "optimized" } } +// { dg-final { cleanup-tree-dump "optimized" } } diff --git a/gcc/testsuite/g++.dg/ubsan/vptr-8.C b/gcc/testsuite/g++.dg/ubsan/vptr-8.C new file mode 100644 index 0000000000..1533f20f1f --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/vptr-8.C @@ -0,0 +1,32 @@ +// { dg-do run } +// { dg-shouldfail "ubsan" } +// { dg-options "-fsanitize=vptr -fno-sanitize-recover=vptr" } + +extern "C" void abort (); + +struct S { virtual void f () {} }; +struct T : S { ~T (); }; +struct U : S { }; +struct V : T, virtual U {}; + +U *up; +V *vp; + +int +main () +{ + V v; + up = vp = &v; +} + +T::~T () +{ + if (vp != up) + abort (); +} + +// { dg-output "\[^\n\r]*vptr-8.C:24:\[0-9]*: runtime error: cast to virtual base of address 0x\[0-9a-fA-F]* which does not point to an object of type 'V'(\n|\r\n|\r)" } +// { dg-output "0x\[0-9a-fA-F]*: note: object is of type 'T'(\n|\r\n|\r)" } +// { dg-output " ?.. .. .. .. ?.. .. .. .. ?.. .. .. .. \[^\n\r]*(\n|\r\n|\r)" } +// { dg-output " ?\\^~~~~~~~~~~\[^\n\r]*(\n|\r\n|\r)" } +// { dg-output " ?vptr for 'T'\[^\n\r]*(\n|\r\n|\r)" } diff --git a/gcc/testsuite/g++.dg/ubsan/vptr-9.C b/gcc/testsuite/g++.dg/ubsan/vptr-9.C new file mode 100644 index 0000000000..482e3e6030 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/vptr-9.C @@ -0,0 +1,22 @@ +// { dg-do run } +// { dg-shouldfail "ubsan" } +// { dg-options "-fsanitize=vptr -fno-sanitize-recover=undefined" } + +struct S { virtual int f () { return 0; } }; +struct T : virtual S {}; +struct U { virtual int f () { return 0; } }; + +int +main () +{ + U u; + T *t = (T *) &u; + S *s = t; + return s->f (); +} + +// { dg-output "\[^\n\r]*vptr-9.C:14:\[0-9]*: runtime error: cast to virtual base of address 0x\[0-9a-fA-F]* which does not point to an object of type 'T'(\n|\r\n|\r)" } +// { dg-output "0x\[0-9a-fA-F]*: note: object is of type 'U'(\n|\r\n|\r)" } +// { dg-output " ?.. .. .. .. ?.. .. .. .. ?.. .. .. .. \[^\n\r]*(\n|\r\n|\r)" } +// { dg-output " ?\\^~~~~~~~~~~\[^\n\r]*(\n|\r\n|\r)" } +// { dg-output " ?vptr for 'U'\[^\n\r]*(\n|\r\n|\r)" } diff --git a/gcc/testsuite/g++.dg/vect/pr60896.cc b/gcc/testsuite/g++.dg/vect/pr60896.cc new file mode 100644 index 0000000000..c6ce68b82a --- /dev/null +++ b/gcc/testsuite/g++.dg/vect/pr60896.cc @@ -0,0 +1,44 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +struct A +{ + int m_fn1 (); + short *m_fn2 (); +}; + +struct B +{ + void *fC; +}; + +int a, b; +unsigned char i; +void fn1 (unsigned char *p1, A &p2) +{ + int c = p2.m_fn1 (); + for (int d = 0; c; d++) + { + short *e = p2.m_fn2 (); + unsigned char *f = &p1[0]; + for (int g = 0; g < a; g++) + { + int h = e[0]; + b += h * f[g]; + } + } +} + +void fn2 (A &p1, A &p2, B &p3) +{ + int j = p2.m_fn1 (); + for (int k = 0; j; k++) + if (0) + ; + else + fn1 (&i, p1); + if (p3.fC) + ; + else + ; +} diff --git a/gcc/testsuite/g++.dg/vect/pr64410.cc b/gcc/testsuite/g++.dg/vect/pr64410.cc new file mode 100644 index 0000000000..13d5576f37 --- /dev/null +++ b/gcc/testsuite/g++.dg/vect/pr64410.cc @@ -0,0 +1,53 @@ +// { dg-do compile } +// { dg-require-effective-target vect_double } + +#include <vector> +#include <complex> +#include <iostream> +#include <cstdlib> + +using namespace std; + +int +main(int argc, char** argv) +{ + if (argc < 3) + { + cout << "usage: size N" << endl; + return -1; + } + + const unsigned int size = atoi(argv[1]); + const unsigned int N = atoi(argv[2]); + + cout << "size = " << size << endl; + cout << "N = " << N << endl; + + typedef complex<double> cx_double; + + vector< cx_double > A(size); + vector< cx_double > B(size); + vector< cx_double > C(size); + + cx_double* A_ptr = &A[0]; + cx_double* B_ptr = &B[0]; + cx_double* C_ptr = &C[0]; + + for (unsigned int i=0; i<size; ++i) + { + A_ptr[i] = cx_double( (double(rand())/RAND_MAX), (double(rand())/RAND_MAX) ); + B_ptr[i] = cx_double( (double(rand())/RAND_MAX), (double(rand())/RAND_MAX) ); + C_ptr[i] = cx_double( double(0), double(0) ); + } + + for (unsigned int j=0; j<N; ++j) + for (unsigned int i=0; i<size; ++i) + C_ptr[i] = A_ptr[i] + B_ptr[i]; + + cout << C_ptr[0] << endl; + + return 0; +} + +// { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } +// { dg-final { cleanup-tree-dump "vect" } } diff --git a/gcc/testsuite/g++.dg/vect/slp-pr50413.cc b/gcc/testsuite/g++.dg/vect/slp-pr50413.cc index 6e69f11b38..4ba606c8bd 100644 --- a/gcc/testsuite/g++.dg/vect/slp-pr50413.cc +++ b/gcc/testsuite/g++.dg/vect/slp-pr50413.cc @@ -160,6 +160,6 @@ void shift(unsigned char t) V.bitmap.b96 = t; } -/* { dg-final { scan-tree-dump-times "basic block vectorized" 0 "slp" } } */ -/* { dg-final { cleanup-tree-dump "slp" } } */ +/* { dg-final { scan-tree-dump-times "basic block vectorized" 0 "slp2" } } */ +/* { dg-final { cleanup-tree-dump "slp2" } } */ diff --git a/gcc/testsuite/g++.dg/vect/slp-pr50819.cc b/gcc/testsuite/g++.dg/vect/slp-pr50819.cc index 515d774a22..60fd1561b3 100644 --- a/gcc/testsuite/g++.dg/vect/slp-pr50819.cc +++ b/gcc/testsuite/g++.dg/vect/slp-pr50819.cc @@ -49,5 +49,5 @@ const & v2) { res = res + s*(v1+v2); } -/* { dg-final { scan-tree-dump-times "basic block vectorized" 2 "slp" } } */ -/* { dg-final { cleanup-tree-dump "slp" } } */ +/* { dg-final { scan-tree-dump-times "basic block vectorized" 2 "slp2" } } */ +/* { dg-final { cleanup-tree-dump "slp2" } } */ diff --git a/gcc/testsuite/g++.dg/vect/slp-pr56812.cc b/gcc/testsuite/g++.dg/vect/slp-pr56812.cc index 9c0b2b8b78..a0155a921d 100644 --- a/gcc/testsuite/g++.dg/vect/slp-pr56812.cc +++ b/gcc/testsuite/g++.dg/vect/slp-pr56812.cc @@ -17,5 +17,5 @@ void mydata::Set (float x) data[i] = x;
}
-/* { dg-final { scan-tree-dump-times "basic block vectorized" 1 "slp" } } */
-/* { dg-final { cleanup-tree-dump "slp" } } */
+/* { dg-final { scan-tree-dump-times "basic block vectorized" 1 "slp1" } } */
+/* { dg-final { cleanup-tree-dump "slp1" } } */
diff --git a/gcc/testsuite/g++.dg/vect/vect.exp b/gcc/testsuite/g++.dg/vect/vect.exp index 2bac8105d8..aba1866a3a 100644 --- a/gcc/testsuite/g++.dg/vect/vect.exp +++ b/gcc/testsuite/g++.dg/vect/vect.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2004-2014 Free Software Foundation, Inc. +# Copyright (C) 2004-2015 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -59,9 +59,9 @@ dg-init # Main loop. g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/pr*.{c,cc,S} ]] \ - $DEFAULT_VECTCFLAGS + "" $DEFAULT_VECTCFLAGS g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/slp-pr*.{c,cc,S} ]] \ - $VECT_SLP_CFLAGS + "" $VECT_SLP_CFLAGS #### Tests with special options global SAVED_DEFAULT_VECTCFLAGS @@ -71,7 +71,7 @@ set SAVED_DEFAULT_VECTCFLAGS $DEFAULT_VECTCFLAGS set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS lappend DEFAULT_VECTCFLAGS "--param max-aliased-vops=0" g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/param-max-aliased*.\[cS\]]] \ - $DEFAULT_VECTCFLAGS + "" $DEFAULT_VECTCFLAGS # Clean up. set dg-do-what-default ${save-dg-do-what-default} diff --git a/gcc/testsuite/g++.dg/warn/Waddress-1.C b/gcc/testsuite/g++.dg/warn/Waddress-1.C new file mode 100644 index 0000000000..8723ac936e --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Waddress-1.C @@ -0,0 +1,50 @@ +// PR c++/43906 +// { dg-options "-Waddress -pedantic" } + +extern void z(); +typedef void (*ptrf) (); +typedef int (*ptrfn) (int); +int n; +const int m = 1; +struct S { }; +struct T : S { }; +struct U; +S s; +T t; +double d; + +void f() { if (z) z(); } // { dg-warning "address" } + +void gl() { if (z != 0) z(); } // { dg-warning "address" } +void hl() { if (z != (ptrf)0) z(); } // { dg-warning "address" } +void il() { if (z != (void*)0) z(); } // { dg-warning "address|comparison" } +void jl() { if (&n != (int*)0) z(); } // { dg-warning "address" } +void kl() { if (&m != (int*)0) z(); } // { dg-warning "address" } +void ll() { if (&s != (T*)0) z(); } // { dg-warning "address" } +void ml() { if (&t != (S*)0) z(); } // { dg-warning "address" } + +void nl() { if (z != (S*)0) z(); } // { dg-error "comparison" } +// { dg-warning "address" "" { target *-*-* } 26 } +void pl() { if (z != (ptrfn)0) z(); } // { dg-error "comparison" } +// { dg-warning "address" "" { target *-*-* } 28 } +void ql() { if (&d != (int*)0) z(); } // { dg-error "comparison" } +// { dg-warning "address" "" { target *-*-* } 30 } +void rl() { if (&s != (U*)0) z(); } // { dg-error "comparison" } +// { dg-warning "address" "" { target *-*-* } 32 } + +void gr() { if (0 != z) z(); } // { dg-warning "address" } +void hr() { if ((ptrf)0 != z) z(); } // { dg-warning "address" } +void ir() { if ((void*)0 != z) z(); } // { dg-warning "address|comparison" } +void jr() { if ((int*)0 != &n) z(); } // { dg-warning "address" } +void kr() { if ((int*)0 != &m) z(); } // { dg-warning "address" } +void lr() { if ((T*)0 != &s) z(); } // { dg-warning "address" } +void mr() { if ((S*)0 != &t) z(); } // { dg-warning "address" } + +void nr() { if ((S*)0 != z) z(); } // { dg-error "comparison" } +// { dg-warning "address" "" { target *-*-* } 43 } +void pr() { if ((ptrfn)0 != z) z(); } // { dg-error "comparison" } +// { dg-warning "address" "" { target *-*-* } 45 } +void qr() { if ((int*)0 != &d) z(); } // { dg-error "comparison" } +// { dg-warning "address" "" { target *-*-* } 47 } +void rr() { if ((U*)0 != &s) z(); } // { dg-error "comparison" } +// { dg-warning "address" "" { target *-*-* } 49 } diff --git a/gcc/testsuite/g++.dg/warn/Waddress-2.C b/gcc/testsuite/g++.dg/warn/Waddress-2.C new file mode 100644 index 0000000000..58594f9629 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Waddress-2.C @@ -0,0 +1,24 @@ +// PR c++/64877 +// { dg-options "-Waddress" } + +template<class Derived> +struct S +{ + void m() { + } + + S() + { + if (&S<Derived>::Unwrap != &Derived::Unwrap) + m(); + } + + void Unwrap() { + } +}; + +struct T : public S<T> +{ +}; + +T t; diff --git a/gcc/testsuite/g++.dg/warn/Warray-bounds-6.C b/gcc/testsuite/g++.dg/warn/Warray-bounds-6.C new file mode 100644 index 0000000000..f2e5f2f597 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Warray-bounds-6.C @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-O3 -Warray-bounds" } + +struct type { + bool a, b; + bool get_b() { return b; } +}; + +type stuff[9u]; + +void bar(); + +void foo() +{ + for(unsigned i = 0u; i < 9u; i++) + { + if(!stuff[i].a) + continue; + + bar(); + + for(unsigned j = i + 1u; j < 9u; j++) + if(stuff[j].a && stuff[j].get_b()) // { dg-bogus "above array bounds" } + return; + } +} diff --git a/gcc/testsuite/g++.dg/warn/Warray-bounds-7.C b/gcc/testsuite/g++.dg/warn/Warray-bounds-7.C new file mode 100644 index 0000000000..7f18a61a47 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Warray-bounds-7.C @@ -0,0 +1,21 @@ +// PR c++/61971 +// { dg-options "-O2 -Warray-bounds" } + +class B { +public: + virtual ~B(){}; +}; + +class A { +public: + B m1[1]; + B m2[1]; + B m3[1]; + + A(){}; +}; + +int main() { + A v; + return 0; +} diff --git a/gcc/testsuite/g++.dg/warn/Wdelete-incomplete-1.C b/gcc/testsuite/g++.dg/warn/Wdelete-incomplete-1.C index 69689ba348..729ea21017 100644 --- a/gcc/testsuite/g++.dg/warn/Wdelete-incomplete-1.C +++ b/gcc/testsuite/g++.dg/warn/Wdelete-incomplete-1.C @@ -1,6 +1,6 @@ // PR c++/43452 -class Foo; // { dg-warning "forward" } +class Foo; // { dg-message "forward" } int main() { Foo* p; // { dg-warning "incomplete" } delete [] p; // { dg-warning "problem" } diff --git a/gcc/testsuite/g++.dg/warn/Wdelete-incomplete-3.C b/gcc/testsuite/g++.dg/warn/Wdelete-incomplete-3.C new file mode 100644 index 0000000000..2202d60a6f --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wdelete-incomplete-3.C @@ -0,0 +1,6 @@ +// PR c++/63619 + +int main() { + void* p; + delete p; // { dg-warning "undefined" } +} diff --git a/gcc/testsuite/g++.dg/warn/Wdelete-incomplete-4.C b/gcc/testsuite/g++.dg/warn/Wdelete-incomplete-4.C new file mode 100644 index 0000000000..f2eb5ba079 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wdelete-incomplete-4.C @@ -0,0 +1,7 @@ +// PR c++/63619 +// { dg-options -Wno-delete-incomplete } + +int main() { + void* p; + delete p; +} diff --git a/gcc/testsuite/g++.dg/warn/Wformat-1.C b/gcc/testsuite/g++.dg/warn/Wformat-1.C new file mode 100644 index 0000000000..6094a9ca36 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wformat-1.C @@ -0,0 +1,10 @@ +// PR c++/64629 +// { dg-options "-Wformat -Wformat-security" } + +extern void bar (int, const char *, ...) __attribute__((format (printf, 2, 3))); +void +foo (void) +{ + const char *const msg = "abc"; + bar (1, msg); +} diff --git a/gcc/testsuite/g++.dg/warn/Winit-self-2.C b/gcc/testsuite/g++.dg/warn/Winit-self-2.C new file mode 100644 index 0000000000..a619d5a0b4 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Winit-self-2.C @@ -0,0 +1,12 @@ +// PR c++/63203 +// { dg-options "-Winit-self" } + +struct string { }; + +int main() +{ + for (int ii = 0; ii < 1; ++ii) + { + const string& str = str; // { dg-warning "is initialized with itself" } + } +} diff --git a/gcc/testsuite/g++.dg/warn/Wmemset-transposed-args-1.C b/gcc/testsuite/g++.dg/warn/Wmemset-transposed-args-1.C new file mode 100644 index 0000000000..89d3edf966 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wmemset-transposed-args-1.C @@ -0,0 +1,74 @@ +// { dg-do compile } +// { dg-options "-Wall" } + +typedef __SIZE_TYPE__ size_t; +extern "C" void *memset (void *, int, size_t); +char buf[1024]; +namespace std +{ + extern "C" void *memset (void *, int, size_t); +} + +template <int N> +void +foo () +{ + memset (buf, sizeof buf, 0); /* { dg-warning ".memset. used with constant zero length parameter; this could be due to transposed parameters" } */ + memset (buf, sizeof buf, '\0'); /* { dg-warning ".memset. used with constant zero length parameter; this could be due to transposed parameters" } */ + memset (buf, sizeof buf, L'\0'); /* { dg-warning ".memset. used with constant zero length parameter; this could be due to transposed parameters" } */ + memset (buf, sizeof buf, N); + memset (buf, 1, 1 - 1); + memset (buf, 1, 0 - 0); + memset (buf, 1, N - N); + memset (buf, 0, 0); + memset (buf, 1 - 1, 0); /* { dg-warning ".memset. used with constant zero length parameter; this could be due to transposed parameters" } */ + memset (buf, 0 - 0, 0); /* { dg-warning ".memset. used with constant zero length parameter; this could be due to transposed parameters" } */ + memset (buf, sizeof buf, 0L); /* { dg-warning ".memset. used with constant zero length parameter; this could be due to transposed parameters" } */ + memset (buf, sizeof buf, 0UL); /* { dg-warning ".memset. used with constant zero length parameter; this could be due to transposed parameters" } */ + memset (buf, sizeof buf, 0LL); /* { dg-warning ".memset. used with constant zero length parameter; this could be due to transposed parameters" } */ + memset (buf, sizeof buf, 0ULL); /* { dg-warning ".memset. used with constant zero length parameter; this could be due to transposed parameters" } */ + memset (buf, sizeof buf, (int) 0); + memset (buf, sizeof buf, -0); +} + +template <int N> +void +baz () +{ + std::memset (buf, sizeof buf, 0); /* { dg-warning ".memset. used with constant zero length parameter; this could be due to transposed parameters" } */ + std::memset (buf, sizeof buf, '\0'); /* { dg-warning ".memset. used with constant zero length parameter; this could be due to transposed parameters" } */ + std::memset (buf, sizeof buf, L'\0'); /* { dg-warning ".memset. used with constant zero length parameter; this could be due to transposed parameters" } */ + std::memset (buf, sizeof buf, N); + std::memset (buf, 1, 1 - 1); + std::memset (buf, 1, 0 - 0); + std::memset (buf, 1, N - N); + std::memset (buf, 0, 0); + std::memset (buf, 1 - 1, 0); /* { dg-warning ".memset. used with constant zero length parameter; this could be due to transposed parameters" } */ + std::memset (buf, 0 - 0, 0); /* { dg-warning ".memset. used with constant zero length parameter; this could be due to transposed parameters" } */ + std::memset (buf, sizeof buf, 0L); /* { dg-warning ".memset. used with constant zero length parameter; this could be due to transposed parameters" } */ + std::memset (buf, sizeof buf, 0UL); /* { dg-warning ".memset. used with constant zero length parameter; this could be due to transposed parameters" } */ + std::memset (buf, sizeof buf, 0LL); /* { dg-warning ".memset. used with constant zero length parameter; this could be due to transposed parameters" } */ + std::memset (buf, sizeof buf, 0ULL); /* { dg-warning ".memset. used with constant zero length parameter; this could be due to transposed parameters" } */ + std::memset (buf, sizeof buf, (int) 0); + std::memset (buf, sizeof buf, -0); +} + +void +bar () +{ + foo<0> (); + std::memset (buf, sizeof buf, 0); /* { dg-warning ".memset. used with constant zero length parameter; this could be due to transposed parameters" } */ + std::memset (buf, sizeof buf, '\0'); /* { dg-warning ".memset. used with constant zero length parameter; this could be due to transposed parameters" } */ + std::memset (buf, sizeof buf, L'\0'); /* { dg-warning ".memset. used with constant zero length parameter; this could be due to transposed parameters" } */ + std::memset (buf, 1, 1 - 1); + std::memset (buf, 1, 0 - 0); + std::memset (buf, 0, 0); + std::memset (buf, 1 - 1, 0); /* { dg-warning ".memset. used with constant zero length parameter; this could be due to transposed parameters" } */ + std::memset (buf, 0 - 0, 0); /* { dg-warning ".memset. used with constant zero length parameter; this could be due to transposed parameters" } */ + std::memset (buf, sizeof buf, 0L); /* { dg-warning ".memset. used with constant zero length parameter; this could be due to transposed parameters" } */ + std::memset (buf, sizeof buf, 0UL); /* { dg-warning ".memset. used with constant zero length parameter; this could be due to transposed parameters" } */ + std::memset (buf, sizeof buf, 0LL); /* { dg-warning ".memset. used with constant zero length parameter; this could be due to transposed parameters" } */ + std::memset (buf, sizeof buf, 0ULL); /* { dg-warning ".memset. used with constant zero length parameter; this could be due to transposed parameters" } */ + std::memset (buf, sizeof buf, (int) 0); + std::memset (buf, sizeof buf, -0); +} diff --git a/gcc/testsuite/g++.dg/warn/Wmissing-field-initializers-1.C b/gcc/testsuite/g++.dg/warn/Wmissing-field-initializers-1.C new file mode 100644 index 0000000000..47308d9d20 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wmissing-field-initializers-1.C @@ -0,0 +1,31 @@ +// PR c++/61489 +// { dg-options "-Wmissing-field-initializers" } + +struct mystruct1 { + int a, b; +}; + +struct aux2 { + aux2(); +}; + +struct mystruct2 { + aux2 a, b; +}; + +struct aux3 { + int x; +}; + +struct mystruct3 { + aux3 a, b; +}; + +mystruct1 obj11 = {}; +mystruct1 obj12 = {0}; // { dg-warning "missing initializer" } + +mystruct2 obj21 = {}; +mystruct2 obj22 = {aux2()}; // { dg-warning "missing initializer" } + +mystruct3 obj31 = {}; +mystruct3 obj32 = {0}; // { dg-warning "missing initializer" } diff --git a/gcc/testsuite/g++.dg/warn/Wparentheses-25.C b/gcc/testsuite/g++.dg/warn/Wparentheses-25.C index ab00c25f02..d9951a4f46 100644 --- a/gcc/testsuite/g++.dg/warn/Wparentheses-25.C +++ b/gcc/testsuite/g++.dg/warn/Wparentheses-25.C @@ -8,7 +8,7 @@ int foo (int); int bar (int a, int b, int c) { - foo (!a & b); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ + foo (!a & b); /* { dg-warning "parentheses" "correct warning" } */ foo (!a & (b < c)); foo (!a & (b > c)); foo (!a & (b == c)); @@ -20,7 +20,7 @@ bar (int a, int b, int c) foo (!a & !b); foo (!(a & b)); foo ((!a) & b); - foo (!a & 2); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ + foo (!a & 2); /* { dg-warning "parentheses" "correct warning" } */ foo (!a & (2 < c)); foo (!a & (2 > c)); foo (!a & (2 == c)); @@ -32,7 +32,7 @@ bar (int a, int b, int c) foo (!a & !2); foo (!(a & 2)); foo ((!a) & 2); - foo (!1 & 2); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ + foo (!1 & 2); /* { dg-warning "parentheses" "correct warning" } */ foo (!1 & (2 < c)); foo (!1 & (2 > c)); foo (!1 & (2 == c)); @@ -44,7 +44,7 @@ bar (int a, int b, int c) foo (!1 & !2); foo (!(1 & 2)); - foo (!a | b); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ + foo (!a | b); /* { dg-warning "parentheses" "correct warning" } */ foo (!a | (b < c)); foo (!a | (b > c)); foo (!a | (b == c)); @@ -56,7 +56,7 @@ bar (int a, int b, int c) foo (!a | !b); foo (!(a | b)); foo ((!a) | b); - foo (!a | 2); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ + foo (!a | 2); /* { dg-warning "parentheses" "correct warning" } */ foo (!a | (2 < c)); foo (!a | (2 > c)); foo (!a | (2 == c)); @@ -68,7 +68,7 @@ bar (int a, int b, int c) foo (!a | !2); foo (!(a | 2)); foo ((!a) | 2); - foo (!1 | 2); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ + foo (!1 | 2); /* { dg-warning "parentheses" "correct warning" } */ foo (!1 | (2 < c)); foo (!1 | (2 > c)); foo (!1 | (2 == c)); @@ -159,55 +159,55 @@ bar (int a, int b, int c) 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 (!a & (b << c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (b >> c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (b + c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (b - c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (b = c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & ~b); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (b & c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (b | c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & 2); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (2 << c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (2 >> c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (2 + c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (2 - c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (c = 2)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & ~2); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (2 & c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (2 | c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 & (2 << c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!1 & (2 >> c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!1 & (2 + c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 & (2 - c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 & (c = 2)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 & ~2); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 & (2 & c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 & (2 | c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (b << c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (b >> c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (b + c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (b - c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (b = c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | ~b); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (b & c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (b | c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (2 << c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (2 >> c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (2 + c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (2 - c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (c = 2)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | ~2); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (2 & c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (2 | c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 | (2 << c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!1 | (2 >> c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!1 | (2 + c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 | (2 - c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 | (c = 2)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 | ~2); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 | (2 & c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 | (2 | c)); /* { dg-warning "parentheses" "correct warning" } */ foo ((b << c) & !a); foo ((b >> c) & !a); foo ((b + c) & !a); diff --git a/gcc/testsuite/g++.dg/warn/Wshadow-10.C b/gcc/testsuite/g++.dg/warn/Wshadow-10.C new file mode 100644 index 0000000000..21d5002005 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wshadow-10.C @@ -0,0 +1,15 @@ +// PR c++/56100 +// { dg-options "-Wshadow" } + +struct bar +{ + template <typename T> + void baz () { int foo; } +}; + +int foo; + +int main () +{ + bar ().baz <int> (); +} diff --git a/gcc/testsuite/g++.dg/warn/Wshadow-11.C b/gcc/testsuite/g++.dg/warn/Wshadow-11.C new file mode 100644 index 0000000000..d3b70c39ac --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wshadow-11.C @@ -0,0 +1,15 @@ +// PR c++/56100 +// { dg-options "-Wshadow" } + +int foo; // { dg-message "shadowed declaration" } + +struct bar +{ + template <typename T> + void baz () { int foo; } // { dg-warning "shadows a global" } +}; + +int main () +{ + bar ().baz <int> (); +} diff --git a/gcc/testsuite/g++.dg/warn/Wshadow-8.C b/gcc/testsuite/g++.dg/warn/Wshadow-8.C new file mode 100644 index 0000000000..4f1ed02f31 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wshadow-8.C @@ -0,0 +1,15 @@ +// PR c++/56100 +// { dg-options "-Wshadow" } + +template <typename T> +struct bar +{ + void baz () { int foo; } +}; + +int foo; + +int main () +{ + bar <int> ().baz (); +} diff --git a/gcc/testsuite/g++.dg/warn/Wshadow-9.C b/gcc/testsuite/g++.dg/warn/Wshadow-9.C new file mode 100644 index 0000000000..836bce62cf --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wshadow-9.C @@ -0,0 +1,15 @@ +// PR c++/56100 +// { dg-options "-Wshadow" } + +int foo; // { dg-message "shadowed declaration" } + +template <typename T> +struct bar +{ + void baz () { int foo; } // { dg-warning "shadows a global" } +}; + +int main () +{ + bar <int> ().baz (); +} diff --git a/gcc/testsuite/g++.dg/warn/Wsizeof-pointer-memaccess-1.C b/gcc/testsuite/g++.dg/warn/Wsizeof-pointer-memaccess-1.C index e2ba8769b9..798cb6de04 100644 --- a/gcc/testsuite/g++.dg/warn/Wsizeof-pointer-memaccess-1.C +++ b/gcc/testsuite/g++.dg/warn/Wsizeof-pointer-memaccess-1.C @@ -1,6 +1,6 @@ // Test -Wsizeof-pointer-memaccess warnings. // { dg-do compile } -// { dg-options "-Wall" } +// { dg-options "-Wall -Wno-sizeof-array-argument" } typedef __SIZE_TYPE__ size_t; extern "C" void *memset (void *, int, size_t); diff --git a/gcc/testsuite/g++.dg/warn/Wsuggest-final-2.C b/gcc/testsuite/g++.dg/warn/Wsuggest-final-2.C new file mode 100644 index 0000000000..51e466d594 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wsuggest-final-2.C @@ -0,0 +1,4 @@ +// PR ipa/61998 +// { dg-do compile } +// { dg-options "-O2 -Wsuggest-final-types" } +int main () {} diff --git a/gcc/testsuite/g++.dg/warn/Wsuggest-final.C b/gcc/testsuite/g++.dg/warn/Wsuggest-final.C new file mode 100644 index 0000000000..f1d419e144 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wsuggest-final.C @@ -0,0 +1,15 @@ +// { dg-do compile } +// { dg-options "-O2 -Wsuggest-final-types -Wsuggest-final-methods" } +int c; +struct A { // { dg-warning "final would enable devirtualization of 4 calls" } +virtual void a() {} // { dg-warning "final would enable devirtualization of 2 calls" } + virtual void b() {c++;} // { dg-warning "final would enable devirtualization of 2 calls" } +}; +void +t(struct A *a) +{ + a->a(); + a->a(); + a->b(); + a->b(); +} diff --git a/gcc/testsuite/g++.dg/warn/Wsuggest-override.C b/gcc/testsuite/g++.dg/warn/Wsuggest-override.C new file mode 100644 index 0000000000..f820f4b82c --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wsuggest-override.C @@ -0,0 +1,23 @@ +// { dg-do compile } +// { dg-options "-std=c++11 -Wsuggest-override" } +struct A +{ + A(); + virtual ~A(); + virtual void f(); + virtual int bar(); + int c(); + operator int(); + virtual operator float(); +}; + +struct B : A +{ + B(); + virtual ~B(); + virtual void f(); // { dg-warning "can be marked override" } +virtual int bar() override; +int c(); +operator int(); +virtual operator float(); // { dg-warning "can be marked override" } +}; diff --git a/gcc/testsuite/g++.dg/warn/Wunused-var-22.C b/gcc/testsuite/g++.dg/warn/Wunused-var-22.C new file mode 100644 index 0000000000..8ae46c17f8 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wunused-var-22.C @@ -0,0 +1,12 @@ +// PR c++/63657 +// { dg-options "-Wunused-variable" } + +class Bar +{ + virtual ~Bar() {} +}; +Bar& getbar(); +void bar() +{ + Bar& b = getbar(); // { dg-warning "unused" } +} diff --git a/gcc/testsuite/g++.dg/warn/Wunused-var-23.C b/gcc/testsuite/g++.dg/warn/Wunused-var-23.C new file mode 100644 index 0000000000..baa1d03d46 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wunused-var-23.C @@ -0,0 +1,17 @@ +// PR c++/64383 +// { dg-options "-Wunused-variable" } + +struct Y +{ + ~Y(); +}; + +struct X +{ + static Y& get(); +}; + +int main() +{ + Y& y = X::get(); // { dg-warning "unused" } +} diff --git a/gcc/testsuite/g++.dg/warn/Wvla-2.C b/gcc/testsuite/g++.dg/warn/Wvla-2.C index df479d0b0b..eacd212375 100644 --- a/gcc/testsuite/g++.dg/warn/Wvla-2.C +++ b/gcc/testsuite/g++.dg/warn/Wvla-2.C @@ -1,4 +1,4 @@ -/* { dg-do compile { target { ! c++1y } } } */ +/* { dg-do compile { target { ! c++14 } } } */ /* { dg-options "-pedantic-errors -Wvla" } */ void func (int i) diff --git a/gcc/testsuite/g++.dg/warn/deprecated-3.C b/gcc/testsuite/g++.dg/warn/deprecated-3.C index 8b4378c410..b65beb15bc 100644 --- a/gcc/testsuite/g++.dg/warn/deprecated-3.C +++ b/gcc/testsuite/g++.dg/warn/deprecated-3.C @@ -10,5 +10,5 @@ struct Foo void g(void) { Foo f; - (int)f; // { dg-warning "'Foo::operator int\\(\\)' is deprecated \\(declared at" } + (int)f; // { dg-warning "'Foo::operator int\\(\\)' is deprecated" } } diff --git a/gcc/testsuite/g++.dg/warn/deprecated-6.C b/gcc/testsuite/g++.dg/warn/deprecated-6.C index 8ce6ac02d5..4afb2841a7 100644 --- a/gcc/testsuite/g++.dg/warn/deprecated-6.C +++ b/gcc/testsuite/g++.dg/warn/deprecated-6.C @@ -5,16 +5,16 @@ typedef int INT1 __attribute__((deprecated("Please avoid INT1"))); typedef INT1 INT2 __attribute__ ((__deprecated__("Please avoid INT2"))); -typedef INT1 INT1a; /* { dg-warning "'INT1' is deprecated .declared at \[^\n\]*: Please avoid INT1" "" } */ +typedef INT1 INT1a; /* { dg-warning "'INT1' is deprecated: Please avoid INT1" "" } */ -INT1 should_be_unavailable; /* { dg-warning "'INT1' is deprecated .declared at \[^\n\]*: Please avoid INT1" "" } */ +INT1 should_be_unavailable; /* { dg-warning "'INT1' is deprecated: Please avoid INT1" "" } */ INT1a should_not_be_deprecated; INT1 f1(void) __attribute__ ((deprecated("Please avoid f1"))); -INT1 f2(void) { return 0; } /* { dg-warning "'INT1' is deprecated .declared at \[^\n\]*: Please avoid INT1" "" } */ +INT1 f2(void) { return 0; } /* { dg-warning "'INT1' is deprecated: Please avoid INT1" "" } */ INT2 f3(void) __attribute__ ((__deprecated__("Please avoid f3"))); -INT2 f4(void) { return 0; } /* { dg-warning "'INT2' is deprecated .declared at \[^\n\]*: Please avoid INT2" "" } */ +INT2 f4(void) { return 0; } /* { dg-warning "'INT2' is deprecated: Please avoid INT2" "" } */ int f5(INT2 x); /* { dg-warning "'INT2' is deprecated" "" } */ int f6(INT2 x) __attribute__ ((__deprecated__("Please avoid f6"))); @@ -23,7 +23,7 @@ typedef enum Color {red, green, blue} Color __attribute__((deprecated("Please av int g1; int g2 __attribute__ ((deprecated("Please avoid g2"))); int g3 __attribute__ ((__deprecated__("Please avoid g3"))); -Color k; /* { dg-warning "'Color' is deprecated .declared at \[^\n\]*: Please avoid Color" "" } */ +Color k; /* { dg-warning "'Color' is deprecated: Please avoid Color" "" } */ typedef struct { int field1; @@ -44,17 +44,17 @@ typedef struct { int func1() { - INT1 w; /* { dg-warning "'INT1' is deprecated .declared at \[^\n\]*: Please avoid INT1" "" } */ + INT1 w; /* { dg-warning "'INT1' is deprecated: Please avoid INT1" "" } */ int x __attribute__ ((deprecated("Please avoid x"))); int y __attribute__ ((__deprecated__("Please avoid y"))); int z; - int (*pf)() = f1; /* { dg-warning "'INT1 f1\\(\\)' is deprecated .declared at \[^\n\]*: Please avoid f1" "" } */ + int (*pf)() = f1; /* { dg-warning "'INT1 f1\\(\\)' is deprecated: Please avoid f1" "" } */ - z = w + x + y + g1 + g2 + g3; /* { dg-warning "'x' is deprecated .declared at \[^\n\]*: Please avoid x" "" } */ - /* { dg-warning "'y' is deprecated .declared at \[^\n\]*: Please avoid y" "y" { target *-*-* } 53 } */ - /* { dg-warning "'g2' is deprecated .declared at \[^\n\]*: Please avoid g2" "g2" { target *-*-* } 53 } */ - /* { dg-warning "'g3' is deprecated .declared at \[^\n\]*: Please avoid g3" "g3" { target *-*-* } 53 } */ - return f1(); /* { dg-warning "'INT1 f1\\(\\)' is deprecated .declared at \[^\n\]*: Please avoid f1" "f1" } */ + z = w + x + y + g1 + g2 + g3; /* { dg-warning "'x' is deprecated: Please avoid x" "" } */ + /* { dg-warning "'y' is deprecated: Please avoid y" "y" { target *-*-* } 53 } */ + /* { dg-warning "'g2' is deprecated: Please avoid g2" "g2" { target *-*-* } 53 } */ + /* { dg-warning "'g3' is deprecated: Please avoid g3" "g3" { target *-*-* } 53 } */ + return f1(); /* { dg-warning "'INT1 f1\\(\\)' is deprecated: Please avoid f1" "f1" } */ } int func2(S1 *p) @@ -62,29 +62,29 @@ int func2(S1 *p) S1 lp; if (p->field1) - return p->field2; /* { dg-warning "'S1::field2' is deprecated .declared at \[^\n\]*: Please avoid field2" "" } */ - else if (lp.field4) /* { dg-warning "'S1::field4' is deprecated .declared at \[^\n\]*: Please avoid field4" "" } */ + return p->field2; /* { dg-warning "'S1::field2' is deprecated: Please avoid field2" "" } */ + else if (lp.field4) /* { dg-warning "'S1::field4' is deprecated: Please avoid field4" "" } */ return p->field3; p->u1.field5 = g1 + p->field7; - p->u2.field9; /* { dg-warning "'S1::u2' is deprecated .declared at \[^\n\]*: Please avoid u2" "" } */ - return p->u1.field6 + p->field8; /* { dg-warning "'S1::<anonymous union>::field6' is deprecated .declared at \[^\n\]*: Please avoid field6" "" } */ - /* { dg-warning "'S1::field8' is deprecated .declared at \[^\n\]*: Please avoid field8" "field8" { target *-*-* } 71 } */ + p->u2.field9; /* { dg-warning "'S1::u2' is deprecated: Please avoid u2" "" } */ + return p->u1.field6 + p->field8; /* { dg-warning "'S1::<anonymous union>::field6' is deprecated: Please avoid field6" "" } */ + /* { dg-warning "'S1::field8' is deprecated: Please avoid field8" "field8" { target *-*-* } 71 } */ } struct SS1 { int x; - INT1 y; /* { dg-warning "'INT1' is deprecated .declared at \[^\n\]*: Please avoid INT1" "" } */ + INT1 y; /* { dg-warning "'INT1' is deprecated: Please avoid INT1" "" } */ } __attribute__ ((deprecated("Please avoid SS1"))); -struct SS1 *p1; /* { dg-warning "'SS1' is deprecated .declared at \[^\n\]*: Please avoid SS1" "" } */ +struct SS1 *p1; /* { dg-warning "'SS1' is deprecated: Please avoid SS1" "" } */ struct __attribute__ ((__deprecated__("Please avoid SS2"))) SS2 { int x; - INT1 y; /* { dg-warning "'INT1' is deprecated .declared at \[^\n\]*: Please avoid INT1" "" } */ + INT1 y; /* { dg-warning "'INT1' is deprecated: Please avoid INT1" "" } */ }; -struct SS2 *p2; /* { dg-warning "'SS2' is deprecated .declared at \[^\n\]*: Please avoid SS2" "" } */ +struct SS2 *p2; /* { dg-warning "'SS2' is deprecated: Please avoid SS2" "" } */ class T { public: @@ -94,17 +94,17 @@ class T { int x; } __attribute__ ((deprecated("Please avoid T"))); -T *p3; // { dg-warning "'T' is deprecated .declared at \[^\n\]*: Please avoid T" } +T *p3; // { dg-warning "'T' is deprecated: Please avoid T" } inline void T::member1(int) {} -int T::member3(T *p) // { dg-warning "'T' is deprecated .declared at \[^\n\]*: Please avoid T" } +int T::member3(T *p) // { dg-warning "'T' is deprecated: Please avoid T" } { - p->member1(1); /* { dg-warning "'void T::member1\\(int\\)' is deprecated .declared at \[^\n\]*: Please avoid member1" "" } */ - (*p).member1(2); /* { dg-warning "'void T::member1\\(int\\)' is deprecated .declared at \[^\n\]*: Please avoid member1" "" } */ - p->member2(1); /* { dg-warning "'void T::member2\\(INT1\\)' is deprecated .declared at \[^\n\]*: Please avoid member2" "" } */ - (*p).member2(2); /* { dg-warning "'void T::member2\\(INT1\\)' is deprecated .declared at \[^\n\]*: Please avoid member2" "" } */ + p->member1(1); /* { dg-warning "'void T::member1\\(int\\)' is deprecated: Please avoid member1" "" } */ + (*p).member1(2); /* { dg-warning "'void T::member1\\(int\\)' is deprecated: Please avoid member1" "" } */ + p->member2(1); /* { dg-warning "'void T::member2\\(INT1\\)' is deprecated: Please avoid member2" "" } */ + (*p).member2(2); /* { dg-warning "'void T::member2\\(INT1\\)' is deprecated: Please avoid member2" "" } */ p->member3(p); (*p).member3(p); - return f1(); /* { dg-warning "'INT1 f1\\(\\)' is deprecated .declared at \[^\n\]*: Please avoid f1" "" } */ + return f1(); /* { dg-warning "'INT1 f1\\(\\)' is deprecated: Please avoid f1" "" } */ } diff --git a/gcc/testsuite/g++.dg/warn/incomplete1.C b/gcc/testsuite/g++.dg/warn/incomplete1.C index 9dc645d82f..1fa27123e6 100644 --- a/gcc/testsuite/g++.dg/warn/incomplete1.C +++ b/gcc/testsuite/g++.dg/warn/incomplete1.C @@ -9,7 +9,7 @@ // (But the deletion does not constitute an ill-formed program. So the // program should nevertheless compile, but it should give a warning.) -class A; // { dg-warning "forward declaration of 'class A'" "" } +class A; // { dg-message "forward declaration of 'class A'" "" } A *a; // { dg-warning "'a' has incomplete type" "" } diff --git a/gcc/testsuite/g++.dg/warn/incomplete2.C b/gcc/testsuite/g++.dg/warn/incomplete2.C index 30be26749c..bfaf6be310 100644 --- a/gcc/testsuite/g++.dg/warn/incomplete2.C +++ b/gcc/testsuite/g++.dg/warn/incomplete2.C @@ -1,9 +1,9 @@ // PR c++/33501 // { dg-do compile } -class A; // { dg-error "forward declaration" } +class A; // { dg-message "forward declaration" } -int f (A); // { dg-error "initializing" } +int f (A); // { dg-message "initializing" } const A &make (); int diff --git a/gcc/testsuite/g++.dg/warn/nonnull2.C b/gcc/testsuite/g++.dg/warn/nonnull2.C new file mode 100644 index 0000000000..10515a4740 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/nonnull2.C @@ -0,0 +1,10 @@ +// PR c++/60764 +// { dg-options "-Wall" } + +struct foo +{ + foo () __attribute__ ((nonnull (1))); +}; + +const foo &x = foo (); // { dg-bogus "null argument" } +foo y = foo (); // { dg-bogus "null argument" } diff --git a/gcc/testsuite/g++.dg/warn/pedantic1.C b/gcc/testsuite/g++.dg/warn/pedantic1.C index 2a4d05536c..08de9ba26f 100644 --- a/gcc/testsuite/g++.dg/warn/pedantic1.C +++ b/gcc/testsuite/g++.dg/warn/pedantic1.C @@ -2,9 +2,9 @@ // { dg-options "-pedantic" } int main() { - goto label; // { dg-error "" } + goto label; // { dg-message "" } - int temp = 1; // { dg-error "" } + int temp = 1; // { dg-message "" } label: // { dg-error "" } return 1; diff --git a/gcc/testsuite/g++.dg/warn/pr61945.C b/gcc/testsuite/g++.dg/warn/pr61945.C new file mode 100644 index 0000000000..5584d84169 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/pr61945.C @@ -0,0 +1,11 @@ +// PR c++/61945 +// { dg-do compile } +// { dg-options "-Woverloaded-virtual" } + +class A { + virtual int foo (); // { dg-warning "was hidden" } +}; +class B : A { + template <typename> + void foo (); // { dg-warning "by .B::foo\\(\\)." } +}; diff --git a/gcc/testsuite/g++.dg/warn/register-parm-1.C b/gcc/testsuite/g++.dg/warn/register-parm-1.C new file mode 100644 index 0000000000..44232d3cf4 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/register-parm-1.C @@ -0,0 +1,9 @@ +// PR c++/60955 +// { dg-options "-Wextra" } + +unsigned int erroneous_warning(register int a) { + if ((a) & 0xff) return 1; else return 0; +} +unsigned int no_erroneous_warning(register int a) { + if (a & 0xff) return 1; else return 0; +} diff --git a/gcc/testsuite/g++.dg/warn/return-reference.C b/gcc/testsuite/g++.dg/warn/return-reference.C index 83021900db..710e87c8cb 100644 --- a/gcc/testsuite/g++.dg/warn/return-reference.C +++ b/gcc/testsuite/g++.dg/warn/return-reference.C @@ -7,7 +7,7 @@ foo1() { static int empty; const int* x = bar(); - return (x ? *x : empty); // { dg-bogus ".*" "" { xfail *-*-* } } + return (x ? *x : empty); // { dg-bogus ".*" } } const int& diff --git a/gcc/testsuite/g++.dg/warn/var-args1.C b/gcc/testsuite/g++.dg/warn/var-args1.C index 9bd84a7dd5..35deb096a6 100644 --- a/gcc/testsuite/g++.dg/warn/var-args1.C +++ b/gcc/testsuite/g++.dg/warn/var-args1.C @@ -6,6 +6,6 @@ void foo(int, ...) { va_list va; int i; - i = va_arg(va, int&); /* { dg-error "cannot receive objects" } */ + i = va_arg(va, int&); /* { dg-error "cannot receive" } */ } diff --git a/gcc/testsuite/g++.dg/warn/warn_format_signedness.C b/gcc/testsuite/g++.dg/warn/warn_format_signedness.C new file mode 100644 index 0000000000..473d522c8a --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/warn_format_signedness.C @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-Wformat -Wformat-signedness" } */ + +/* PR c/60194 */ + +void foo(unsigned u, int i, unsigned char uc, signed char sc) { + __builtin_printf("%d\n", u); /* { dg-warning "expects argument of type 'int', but argument 2 has type 'unsigned int'" } */ + __builtin_printf("%u\n", i); /* { dg-warning "expects argument of type 'unsigned int', but argument 2 has type 'int'" } */ + __builtin_printf("%c\n", sc); + __builtin_printf("%c\n", uc); +} diff --git a/gcc/testsuite/g++.dg/warn/wdate-time.C b/gcc/testsuite/g++.dg/warn/wdate-time.C deleted file mode 100644 index 0ff27b4cd6..0000000000 --- a/gcc/testsuite/g++.dg/warn/wdate-time.C +++ /dev/null @@ -1,6 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-Wdate-time" } */ - -const char time[] = __TIME__; /* { dg-warning "might prevent reproducible builds" } */ -const char date[] = __DATE__; /* { dg-warning "might prevent reproducible builds" } */ -const char timestamp[] = __TIMESTAMP__; /* { dg-warning "might prevent reproducible builds" } */ diff --git a/gcc/testsuite/g++.dg/warn/write-strings-default.C b/gcc/testsuite/g++.dg/warn/write-strings-default.C index ee6b217185..063b303f66 100644 --- a/gcc/testsuite/g++.dg/warn/write-strings-default.C +++ b/gcc/testsuite/g++.dg/warn/write-strings-default.C @@ -3,5 +3,5 @@ int main() { - char* p = "Asgaard"; // { dg-warning "deprecated" } + char* p = "Asgaard"; // { dg-warning "deprecated|forbids converting a string constant" } } diff --git a/gcc/testsuite/g++.dg/warn/write-strings.C b/gcc/testsuite/g++.dg/warn/write-strings.C index 73c8149098..1293e85915 100644 --- a/gcc/testsuite/g++.dg/warn/write-strings.C +++ b/gcc/testsuite/g++.dg/warn/write-strings.C @@ -3,5 +3,5 @@ int main() { - char* p = "Asgaard"; // { dg-warning "deprecated" } + char* p = "Asgaard"; // { dg-warning "deprecated|forbids converting a string constant" } } |