diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/g++.dg/cpp0x/auto9.C | |
download | cbb-gcc-4.6.4-upstream.tar.bz2 cbb-gcc-4.6.4-upstream.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/g++.dg/cpp0x/auto9.C')
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/auto9.C | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp0x/auto9.C b/gcc/testsuite/g++.dg/cpp0x/auto9.C new file mode 100644 index 000000000..190bfa6e8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto9.C @@ -0,0 +1,124 @@ +// PR c++/37962 +// Negative test for auto +// { dg-do compile } +// { dg-options "-std=c++0x" } + +#include <typeinfo> +#include <stdarg.h> +#include <stddef.h> + +int i = *(auto *) 0; // { dg-error "auto" } +struct A *p = (auto *) 0; // { dg-error "auto" } +int *q = static_cast <auto *>(0); // { dg-error "auto" } +const int *r = const_cast <auto *>(q); // { dg-error "auto" } +const std::type_info &t1 = typeid (auto); // { dg-error "auto" } +const std::type_info &t2 = typeid (auto *); // { dg-error "auto" } + +struct A +{ + operator auto (); // { dg-error "auto" } + operator auto *(); // { dg-error "auto" } +}; + +struct A2 +{ + operator auto () -> int; // { dg-error "invalid use of" } + operator auto *() -> int; // { dg-error "auto" } +}; + +template <typename> struct B +{ + enum { e }; +}; + +template <typename T> struct C +{ + C () : i () {} + int i; +}; + +bool d = (auto (A::*)()) 0; // { dg-error "auto" } + +void +foo () +{ + (auto) { 0 }; // { dg-error "auto" } + C<int> c; + dynamic_cast<auto> (c); // { dg-error "auto" } + reinterpret_cast<auto> (c); // { dg-error "auto" } + int i = auto (0); // { dg-error "auto" } + auto p1 = new (auto); // { dg-error "auto" } + auto p2 = new (auto) (42); // { dg-error "invalid use of|deduce" } + offsetof (auto, fld); // { dg-error "auto" } + offsetof (auto *, fld); // { dg-error "auto" } + sizeof (auto); // { dg-error "auto" } + sizeof (auto *); // { dg-error "auto" } +} + +void +foo2 (void) +{ + __alignof__ (auto); // { dg-error "auto" } + __alignof__ (auto *); // { dg-error "auto" } + __typeof__ (auto) v1; // { dg-error "auto" } + __typeof__ (auto *) v2; // { dg-error "auto" } + __is_class (auto); // { dg-error "auto|expected" } + __is_pod (auto *); // { dg-error "auto|expected" } + __is_base_of (int, auto); // { dg-error "auto|expected" } + __is_base_of (auto, int); // { dg-error "auto|expected" } + __is_base_of (auto, auto *); // { dg-error "auto|expected" } +} + +B<auto> b; // { dg-error "auto|invalid" } +C<auto> c; // { dg-error "auto|invalid" } +C<auto *> c2; // { dg-error "auto|invalid" } + +enum : auto { EE = 0 }; // { dg-error "must be an integral type" } +enum struct D : auto * { FF = 0 }; // { dg-error "must be an integral type|declar|expected" } + +void +bar () +{ + try { } catch (auto i) { } // { dg-error "parameter declared" } + try { } catch (auto) { } // { dg-error "parameter declared" } + try { } catch (auto *i) { } // { dg-error "parameter declared" } + try { } catch (auto *) { } // { dg-error "parameter declared" } +} + +void +baz (int i, ...) +{ + va_list ap; + va_start (ap, i); + va_arg (ap, auto); // { dg-error "invalid use of" } + va_arg (ap, auto *); // { dg-error "invalid use of|expected" } + va_arg (ap, auto &); // { dg-error "invalid use of|expected" } + va_end (ap); +} + +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" } +auto fnlate2 () -> auto *; // { dg-error "invalid use of|expected" } + +void +badthrow () throw (auto) // { dg-error "invalid use of" } +{ +} + +void +badthrow2 () throw (auto &) // { dg-error "invalid use of|expected" } +{ +} + +template <auto V = 4> struct G {}; // { dg-error "auto" } + +template <typename T> struct H { H (); ~H (); }; +H<auto> h; // { dg-error "invalid" } + +void qq (auto); // { dg-error "auto" } +void qr (auto*); // { dg-error "auto" } + +// PR c++/46145 +typedef auto autot; // { dg-error "auto" } |