[cfe-commits] r72041 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/SemaTemplate/instantiate-try-catch.cpp
Douglas Gregor
dgregor at apple.com
Mon May 18 14:08:16 PDT 2009
Author: dgregor
Date: Mon May 18 16:08:14 2009
New Revision: 72041
URL: http://llvm.org/viewvc/llvm-project?rev=72041&view=rev
Log:
Deal with an icky corner case where we were complaining that a catch
statement was using an rvalue reference during the template
definition. However, template instantiations based on an lvalue
reference type are well-formed, so we delay checking of these property
until template instantiation time.
Added:
cfe/trunk/test/SemaTemplate/instantiate-try-catch.cpp
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=72041&r1=72040&r2=72041&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon May 18 16:08:14 2009
@@ -2553,7 +2553,7 @@
// The exception-declaration shall not denote a pointer or reference to an
// incomplete type, other than [cv] void*.
// N2844 forbids rvalue references.
- if(ExDeclType->isRValueReferenceType()) {
+ if(!ExDeclType->isDependentType() && ExDeclType->isRValueReferenceType()) {
Diag(Loc, diag::err_catch_rvalue_ref) << Range;
Invalid = true;
}
Added: cfe/trunk/test/SemaTemplate/instantiate-try-catch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-try-catch.cpp?rev=72041&view=auto
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-try-catch.cpp (added)
+++ cfe/trunk/test/SemaTemplate/instantiate-try-catch.cpp Mon May 18 16:08:14 2009
@@ -0,0 +1,14 @@
+// RUN: clang-cc -fsyntax-only -std=c++0x -verify %s
+
+template<typename T> struct TryCatch0 {
+ void f() {
+ try {
+ } catch (T&&) { // expected-error 2{{cannot catch exceptions by rvalue reference}}
+ }
+ }
+};
+
+template struct TryCatch0<int&>; // okay
+template struct TryCatch0<int&&>; // expected-note{{instantiation}}
+template struct TryCatch0<int>; // expected-note{{instantiation}}
+
More information about the cfe-commits
mailing list