teak-llvm/clang/test/SemaTemplate/instantiate-exception-spec.cpp
Richard Smith 2e32155b58 Instantiate exception specifications when instantiating function types (other
than the type of a function declaration). We previously didn't instantiate
these at all! This also covers the pathological case where the only mention of
a parameter pack is within the exception specification; this gives us a second
way (other than alias templates) to reach the horrible state where a type
contains an unexpanded pack, but its canonical type does not.


This is a re-commit of r219977:

r219977 was reverted in r220038 because it hit a wrong-code bug in GCC 4.7.2.
(That's gcc.gnu.org/PR56135, and affects any implicit lambda-capture of
'this' within a template.)


r219977 was a re-commit of r217995, r218011, and r218053:

r217995 was reverted in r218058 because it hit a rejects-valid bug in MSVC.
(Incorrect overload resolution in the presence of using-declarations.)
It was re-committed in r219977 with a workaround for the MSVC rejects-valid.

r218011 was a workaround for an MSVC parser bug. (Incorrect desugaring of
unbraced range-based for loop).

llvm-svn: 221750
2014-11-12 02:00:47 +00:00

29 lines
944 B
C++

// RUN: %clang_cc1 -fexceptions -fcxx-exceptions -verify %s -DERRORS
// RUN: %clang_cc1 -fexceptions -fcxx-exceptions -emit-llvm-only %s
#ifdef ERRORS
template<typename T> void f1(T*) throw(T); // expected-error{{incomplete type 'Incomplete' is not allowed in exception specification}}
struct Incomplete; // expected-note{{forward}}
void test_f1(Incomplete *incomplete_p, int *int_p) {
f1(int_p);
f1(incomplete_p); // expected-note{{instantiation of}}
}
#endif
template<typename T> void f(void (*p)() throw(T)) {
#ifdef ERRORS
void (*q)() throw(char) = p; // expected-error {{target exception spec}}
extern void (*p2)() throw(T);
void (*q2)() throw(char) = p2; // expected-error {{target exception spec}}
extern void (*p3)() throw(char);
void (*q3)() throw(T) = p3; // expected-error {{target exception spec}}
void (*q4)() throw(T) = p2; // ok
#endif
p();
}
void g() { f<int>(0); } // expected-note {{instantiation of}}