summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaTemplate/instantiate-declref.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-04-17 00:58:00 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-04-17 00:58:00 +0000
commitf623c962600b40e38145b9ab4b8e41058a93abea (patch)
treec02f329318f56a4112e4a0e81b8304738fc0f6e2 /clang/test/SemaTemplate/instantiate-declref.cpp
parent0765c8269488be139a77561b456b73cb0cd4bc57 (diff)
downloadbcm5719-llvm-f623c962600b40e38145b9ab4b8e41058a93abea.tar.gz
bcm5719-llvm-f623c962600b40e38145b9ab4b8e41058a93abea.zip
Implement DR1330 in C++11 mode, to support libstdc++4.7 which uses it.
We have a new flavor of exception specification, EST_Uninstantiated. A function type with this exception specification carries a pointer to a FunctionDecl, and the exception specification for that FunctionDecl is instantiated (if needed) and used in the place of the function type's exception specification. When a function template declaration with a non-trivial exception specification is instantiated, the specialization's exception specification is set to this new 'uninstantiated' kind rather than being instantiated immediately. Expr::CanThrow has migrated onto Sema, so it can instantiate exception specs on-demand. Also, any odr-use of a function triggers the instantiation of its exception specification (the exception specification could be needed by IRGen). In passing, fix two places where a DeclRefExpr was created but the corresponding function was not actually marked odr-used. We used to get away with this, but don't any more. Also fix a bug where instantiating an exception specification which refers to function parameters resulted in a crash. We still have the same bug in default arguments, which I'll be looking into next. This, plus a tiny patch to fix libstdc++'s common_type, is enough for clang to parse (and, in very limited testing, support) all of libstdc++4.7's standard headers. llvm-svn: 154886
Diffstat (limited to 'clang/test/SemaTemplate/instantiate-declref.cpp')
-rw-r--r--clang/test/SemaTemplate/instantiate-declref.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/test/SemaTemplate/instantiate-declref.cpp b/clang/test/SemaTemplate/instantiate-declref.cpp
index ced56dfc6ab..7d4a2ff6a3f 100644
--- a/clang/test/SemaTemplate/instantiate-declref.cpp
+++ b/clang/test/SemaTemplate/instantiate-declref.cpp
@@ -105,3 +105,13 @@ namespace test1 {
}
template void f(int const &); // expected-note {{requested here}}
}
+
+namespace test2 {
+ template<typename T> void f() {
+ T::error; // expected-error {{no member}}
+ }
+ void g() {
+ // This counts as an odr-use, so should trigger the instantiation of f<int>.
+ (void)&f<int>; // expected-note {{here}}
+ }
+}
OpenPOWER on IntegriCloud