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(); }
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK: define {{.*}} @_Z1fIA2_sEvv() [[NUW:#[0-9]+]] {
|
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(); }
|
|
|
|
|
2013-03-01 06:49:57 +08:00
|
|
|
// CHECK: define {{.*}} @_Z1fIDsEvv() [[NONE]] {
|
2012-04-18 06:30:01 +08:00
|
|
|
template void f<char16_t>();
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK: define {{.*}} @_Z1fIA2_DsEvv() [[NUW]] {
|
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() {
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK: define {{.*}} @_Z1fIiEvv() [[NUW]] {
|
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>();
|
2013-03-01 06:49:57 +08:00
|
|
|
// CHECK: define {{.*}} @_Z1fIA2_iEvv() [[NONE]] {
|
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();
|
|
|
|
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK: define {{.*}} @_Z1fIfEvv() [[NUW]] {
|
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>;
|
2013-03-01 06:49:57 +08:00
|
|
|
// CHECK: define {{.*}} @_Z1fIdEvv() [[NONE]] {
|
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;
|
|
|
|
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK: define {{.*}} @_Z1fIA4_cEvv() [[NUW]] {
|
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]>;
|
2013-03-01 06:49:57 +08:00
|
|
|
// CHECK: define {{.*}} @_Z1fIcEvv() [[NONE]] {
|
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{{.*}} }
|