2013-12-14 12:49:06 +08:00
|
|
|
// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -verify -fexceptions -fcxx-exceptions -triple x86_64-linux-gnu | FileCheck %s
|
|
|
|
// expected-no-diagnostics
|
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
2012-04-17 08:58:00 +08:00
|
|
|
|
2012-04-18 06:30:01 +08:00
|
|
|
void h();
|
|
|
|
|
|
|
|
template<typename T> void f() noexcept(sizeof(T) == 4) { h(); }
|
2012-04-19 08:08:28 +08:00
|
|
|
template<typename T> void g() noexcept(sizeof(T) == 4);
|
2012-04-18 06:30:01 +08:00
|
|
|
|
|
|
|
template<typename T> struct S {
|
|
|
|
static void f() noexcept(sizeof(T) == 4) { h(); }
|
2012-04-19 08:08:28 +08:00
|
|
|
static void g() noexcept(sizeof(T) == 4);
|
2012-04-18 06:30:01 +08:00
|
|
|
};
|
|
|
|
|
2013-03-01 06:49:57 +08:00
|
|
|
// CHECK: define {{.*}} @_Z1fIsEvv() [[NONE:#[0-9]+]] {
|
2012-04-18 06:30:01 +08:00
|
|
|
template<> void f<short>() { h(); }
|
2015-06-18 04:53:19 +08:00
|
|
|
// CHECK: define {{.*}} @_Z1fIA2_sEvv() [[NUW:#[0-9]+]] personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
|
2012-04-18 06:30:01 +08:00
|
|
|
template<> void f<short[2]>() noexcept { h(); }
|
|
|
|
|
|
|
|
// CHECK: define {{.*}} @_ZN1SIsE1fEv()
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK-NOT: [[NUW]]
|
2012-04-18 06:30:01 +08:00
|
|
|
template<> void S<short>::f() { h(); }
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK: define {{.*}} @_ZN1SIA2_sE1fEv() [[NUW]]
|
2012-04-18 06:30:01 +08:00
|
|
|
template<> void S<short[2]>::f() noexcept { h(); }
|
|
|
|
|
2015-01-13 06:13:53 +08:00
|
|
|
// CHECK: define {{.*}} @_Z1fIDsEvv() [[NONE]] comdat {
|
2012-04-18 06:30:01 +08:00
|
|
|
template void f<char16_t>();
|
2015-06-18 04:53:19 +08:00
|
|
|
// CHECK: define {{.*}} @_Z1fIA2_DsEvv() [[NUW]] comdat personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
|
2012-04-18 06:30:01 +08:00
|
|
|
template void f<char16_t[2]>();
|
|
|
|
|
|
|
|
// CHECK: define {{.*}} @_ZN1SIDsE1fEv()
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK-NOT: [[NUW]]
|
2012-04-18 06:30:01 +08:00
|
|
|
template void S<char16_t>::f();
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK: define {{.*}} @_ZN1SIA2_DsE1fEv() [[NUW]]
|
2012-04-18 06:30:01 +08:00
|
|
|
template void S<char16_t[2]>::f();
|
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
2012-04-17 08:58:00 +08:00
|
|
|
|
2012-04-19 08:08:28 +08:00
|
|
|
void h() {
|
2015-06-18 04:53:19 +08:00
|
|
|
// CHECK: define {{.*}} @_Z1fIiEvv() [[NUW]] comdat personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
|
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
2012-04-17 08:58:00 +08:00
|
|
|
f<int>();
|
2015-01-13 06:13:53 +08:00
|
|
|
// CHECK: define {{.*}} @_Z1fIA2_iEvv() [[NONE]] comdat {
|
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
2012-04-17 08:58:00 +08:00
|
|
|
f<int[2]>();
|
2012-04-18 06:30:01 +08:00
|
|
|
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK: define {{.*}} @_ZN1SIiE1fEv() [[NUW]]
|
2012-04-18 06:30:01 +08:00
|
|
|
S<int>::f();
|
|
|
|
// CHECK: define {{.*}} @_ZN1SIA2_iE1fEv()
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK-NOT: [[NUW]]
|
2012-04-18 06:30:01 +08:00
|
|
|
S<int[2]>::f();
|
|
|
|
|
2015-06-18 04:53:19 +08:00
|
|
|
// CHECK: define {{.*}} @_Z1fIfEvv() [[NUW]] comdat personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
|
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
2012-04-17 08:58:00 +08:00
|
|
|
void (*f1)() = &f<float>;
|
2015-01-13 06:13:53 +08:00
|
|
|
// CHECK: define {{.*}} @_Z1fIdEvv() [[NONE]] comdat {
|
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
2012-04-17 08:58:00 +08:00
|
|
|
void (*f2)() = &f<double>;
|
2012-04-18 06:30:01 +08:00
|
|
|
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK: define {{.*}} @_ZN1SIfE1fEv() [[NUW]]
|
2012-04-18 06:30:01 +08:00
|
|
|
void (*f3)() = &S<float>::f;
|
|
|
|
// CHECK: define {{.*}} @_ZN1SIdE1fEv()
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK-NOT: [[NUW]]
|
2012-04-18 06:30:01 +08:00
|
|
|
void (*f4)() = &S<double>::f;
|
|
|
|
|
2015-06-18 04:53:19 +08:00
|
|
|
// CHECK: define {{.*}} @_Z1fIA4_cEvv() [[NUW]] comdat personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
|
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
2012-04-17 08:58:00 +08:00
|
|
|
(void)&f<char[4]>;
|
2015-01-13 06:13:53 +08:00
|
|
|
// CHECK: define {{.*}} @_Z1fIcEvv() [[NONE]] comdat {
|
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
2012-04-17 08:58:00 +08:00
|
|
|
(void)&f<char>;
|
2012-04-18 06:30:01 +08:00
|
|
|
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK: define {{.*}} @_ZN1SIA4_cE1fEv() [[NUW]]
|
2012-04-18 06:30:01 +08:00
|
|
|
(void)&S<char[4]>::f;
|
|
|
|
// CHECK: define {{.*}} @_ZN1SIcE1fEv()
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK-NOT: [[NUW]]
|
2012-04-18 06:30:01 +08:00
|
|
|
(void)&S<char>::f;
|
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
2012-04-17 08:58:00 +08:00
|
|
|
}
|
2012-04-19 08:08:28 +08:00
|
|
|
|
|
|
|
// CHECK: define {{.*}} @_Z1iv
|
|
|
|
void i() {
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK: declare {{.*}} @_Z1gIiEvv() [[NUW]]
|
2012-04-19 08:08:28 +08:00
|
|
|
g<int>();
|
|
|
|
// CHECK: declare {{.*}} @_Z1gIA2_iEvv()
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK-NOT: [[NUW]]
|
2012-04-19 08:08:28 +08:00
|
|
|
g<int[2]>();
|
|
|
|
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK: declare {{.*}} @_ZN1SIiE1gEv() [[NUW]]
|
2012-04-19 08:08:28 +08:00
|
|
|
S<int>::g();
|
|
|
|
// CHECK: declare {{.*}} @_ZN1SIA2_iE1gEv()
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK-NOT: [[NUW]]
|
2012-04-19 08:08:28 +08:00
|
|
|
S<int[2]>::g();
|
|
|
|
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK: declare {{.*}} @_Z1gIfEvv() [[NUW]]
|
2012-04-19 08:08:28 +08:00
|
|
|
void (*g1)() = &g<float>;
|
|
|
|
// CHECK: declare {{.*}} @_Z1gIdEvv()
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK-NOT: [[NUW]]
|
2012-04-19 08:08:28 +08:00
|
|
|
void (*g2)() = &g<double>;
|
|
|
|
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK: declare {{.*}} @_ZN1SIfE1gEv() [[NUW]]
|
2012-04-19 08:08:28 +08:00
|
|
|
void (*g3)() = &S<float>::g;
|
|
|
|
// CHECK: declare {{.*}} @_ZN1SIdE1gEv()
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK-NOT: [[NUW]]
|
2012-04-19 08:08:28 +08:00
|
|
|
void (*g4)() = &S<double>::g;
|
|
|
|
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK: declare {{.*}} @_Z1gIA4_cEvv() [[NUW]]
|
2012-04-19 08:08:28 +08:00
|
|
|
(void)&g<char[4]>;
|
|
|
|
// CHECK: declare {{.*}} @_Z1gIcEvv()
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK-NOT: [[NUW]]
|
2012-04-19 08:08:28 +08:00
|
|
|
(void)&g<char>;
|
|
|
|
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK: declare {{.*}} @_ZN1SIA4_cE1gEv() [[NUW]]
|
2012-04-19 08:08:28 +08:00
|
|
|
(void)&S<char[4]>::g;
|
|
|
|
// CHECK: declare {{.*}} @_ZN1SIcE1gEv()
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK-NOT: [[NUW]]
|
2012-04-19 08:08:28 +08:00
|
|
|
(void)&S<char>::g;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T> struct Nested {
|
|
|
|
template<bool b, typename U> void f() noexcept(sizeof(T) == sizeof(U));
|
|
|
|
};
|
|
|
|
|
|
|
|
// CHECK: define {{.*}} @_Z1jv
|
|
|
|
void j() {
|
|
|
|
// CHECK: declare {{.*}} @_ZN6NestedIiE1fILb1EcEEvv(
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK-NOT: [[NUW]]
|
2012-04-19 08:08:28 +08:00
|
|
|
Nested<int>().f<true, char>();
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK: declare {{.*}} @_ZN6NestedIlE1fILb0ElEEvv({{.*}}) [[NUW]]
|
2012-04-19 08:08:28 +08:00
|
|
|
Nested<long>().f<false, long>();
|
|
|
|
}
|
2013-02-20 15:22:19 +08:00
|
|
|
|
2013-03-01 06:49:57 +08:00
|
|
|
// CHECK: attributes [[NONE]] = { {{.*}} }
|
|
|
|
// CHECK: attributes [[NUW]] = { nounwind{{.*}} }
|
2014-08-28 01:04:39 +08:00
|
|
|
|
|
|
|
namespace PR19190 {
|
|
|
|
template <class T> struct DWFIterator { virtual void get() throw(int) = 0; };
|
|
|
|
void foo(DWFIterator<int> *foo) { foo->get(); }
|
|
|
|
}
|