diff options
author | ed <ed@FreeBSD.org> | 2009-06-23 19:32:16 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2009-06-23 19:32:16 +0000 |
commit | 14660dbe9881f68a6cc2b9f014e1fb7b7228bca4 (patch) | |
tree | 258c14596f927fd77ae8d727dc9c3d4471bf0f46 /test/CXX/basic | |
parent | da468bf93e74598f985f4988936ee5ca2dc9a38c (diff) | |
download | FreeBSD-src-14660dbe9881f68a6cc2b9f014e1fb7b7228bca4.zip FreeBSD-src-14660dbe9881f68a6cc2b9f014e1fb7b7228bca4.tar.gz |
Import Clang r73984.
Diffstat (limited to 'test/CXX/basic')
-rw-r--r-- | test/CXX/basic/basic.def.odr/p2-typeid.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/CXX/basic/basic.def.odr/p2-typeid.cpp b/test/CXX/basic/basic.def.odr/p2-typeid.cpp new file mode 100644 index 0000000..7eb10ef --- /dev/null +++ b/test/CXX/basic/basic.def.odr/p2-typeid.cpp @@ -0,0 +1,36 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +// C++ [basic.def.odr]p2: +// An expression is potentially evaluated unless it [...] is the +// operand of the typeid operator and the expression does not +// designate an lvalue of polymorphic class type. + +// FIXME: This should really include <typeinfo>, but we don't have that yet. +namespace std { + class type_info; +} + +struct Poly { + virtual ~Poly(); +}; + +struct NonPoly { }; + +template<typename T, typename Result = T> +struct X { + Result f(T t) { return t + t; } // expected-error{{invalid operands}} + + void g(T t) { + (void)typeid(f(t)); // expected-note{{here}} + } +}; + +void test(X<Poly> xp, X<Poly, Poly&> xpr, X<NonPoly> xnp, X<NonPoly, NonPoly&> xnpr) { + // These are okay (although GCC and EDG get them wrong). + xp.g(Poly()); + xnp.g(NonPoly()); + xnpr.g(NonPoly()); + + // Triggers an error (as it should); + xpr.g(Poly()); +} |