1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
Upstream-Status: Inappropriate [Backport]
From 4215154488607abf1ee95f1d1f03cb66be4bd4d8 Mon Sep 17 00:00:00 2001
From: jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 8 Apr 2011 15:02:16 +0000
Subject: [PATCH 089/200] PR c++/48468
* except.c (build_noexcept_spec): Propagate error_mark_node.
(finish_noexcept_expr): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@172194 138bc75d-0d04-0410-961f-82ee72b054a4
index a814d67..874f111 100644
--- a/gcc/cp/except.c
+++ b/gcc/cp/except.c
@@ -1125,6 +1125,9 @@ finish_noexcept_expr (tree expr, tsubst_flags_t complain)
{
tree fn;
+ if (expr == error_mark_node)
+ return error_mark_node;
+
if (processing_template_decl)
return build_min (NOEXCEPT_EXPR, boolean_type_node, expr);
@@ -1212,6 +1215,8 @@ build_noexcept_spec (tree expr, int complain)
return noexcept_true_spec;
else if (expr == boolean_false_node)
return noexcept_false_spec;
+ else if (expr == error_mark_node)
+ return error_mark_node;
else
{
gcc_assert (processing_template_decl || expr == error_mark_node);
index be6fa00..60015e7 100644
--- a/gcc/testsuite/g++.dg/cpp0x/noexcept02.C
+++ b/gcc/testsuite/g++.dg/cpp0x/noexcept02.C
@@ -46,7 +46,9 @@ SA(!noexcept(f3(A())));
template <class T1, class T2>
void f (T1, T2) noexcept(noexcept(T1(), T2()));
-SA(noexcept(f3(1,1)));
+struct B { };
+
+SA(noexcept(f3(1,B())));
SA(!noexcept(f3(1,A())));
SA(!noexcept(f3(A(),1)));
SA(!noexcept(f3(A(),A())));
diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae11.C b/gcc/testsuite/g++.dg/cpp0x/sfinae11.C
new file mode 100644
index 0000000..a3ffc34
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/sfinae11.C
@@ -0,0 +1,56 @@
+// PR c++/48468
+// { dg-options -std=c++0x }
+// { dg-prune-output "note" }
+
+template<class T>
+T&& declval() noexcept;
+
+template< class T >
+inline void f1( T& x ) noexcept( noexcept( declval<T&>().foo() ) )
+{
+ x.foo();
+}
+
+template< class T,
+ bool Noexcept = noexcept( declval<T&>().foo() )
+>
+inline void f2( T& x ) noexcept( Noexcept )
+{
+ x.foo();
+}
+
+// a common and trivial mistake
+template< class T >
+inline void f3( T& x ) noexcept( declval<T&>().foo() )
+{
+ x.foo();
+}
+
+struct X
+{
+ void foo();
+};
+
+struct Y
+{
+ void foo() noexcept;
+};
+
+struct Z {};
+
+int main()
+{
+ X x; Y y; Z z;
+
+ static_assert( !noexcept( f1(x) ), "OK." );
+ static_assert( !noexcept( f2(x) ), "OK." );
+ // static_assert( !noexcept( f3(x) ), "shall be ill-formed(OK)." );
+
+ static_assert( noexcept( f1(y) ), "OK." );
+ static_assert( noexcept( f2(y) ), "OK." );
+ // static_assert( noexcept( f3(y) ), "shall be ill-formed(OK)." );
+
+ static_assert( noexcept( f1(z) ), "shall be ill-formed." ); // { dg-error "no match" }
+ static_assert( noexcept( f2(z) ), "shall be ill-formed." ); // { dg-error "no match" }
+ static_assert( !noexcept( f3(z) ), "shall be ill-formed." ); // { dg-error "no match" }
+}
--
1.7.0.4
|