diff mbox

C++ PATCH for c++/60046 (ICE with noexcept)

Message ID 5304FFB3.10406@redhat.com
State New
Headers show

Commit Message

Jason Merrill Feb. 19, 2014, 7:02 p.m. UTC
In this testcase, when we see a non-dependent use of a function template 
instance we mark it as used, but we don't want to instantiate the 
noexcept-specification at that point because we aren't doing full 
expression evaluation yet.

Tested x86_64-pc-linux-gnu, applying to trunk, 4.8, 4.7.
diff mbox

Patch

commit 783a814e999b5c1de5f8cd1e4df13eee78cff244
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Feb 19 12:59:50 2014 -0500

    	PR c++/60046
    	* pt.c (maybe_instantiate_noexcept): Don't instantiate exception
    	spec from template context.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 7967db8..0b4a889 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -19280,6 +19280,10 @@  maybe_instantiate_noexcept (tree fn)
 {
   tree fntype, spec, noex, clone;
 
+  /* Don't instantiate a noexcept-specification from template context.  */
+  if (processing_template_decl)
+    return;
+
   if (DECL_CLONED_FUNCTION_P (fn))
     fn = DECL_CLONED_FUNCTION (fn);
   fntype = TREE_TYPE (fn);
diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept22.C b/gcc/testsuite/g++.dg/cpp0x/noexcept22.C
new file mode 100644
index 0000000..7aab0f4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/noexcept22.C
@@ -0,0 +1,21 @@ 
+// PR c++/60046
+// { dg-require-effective-target c++11 }
+
+constexpr bool foo () { return noexcept (true); }
+template <typename T>
+struct V
+{
+  void bar (V &) noexcept (foo ()) {}
+};
+template <typename T>
+struct W : public V <int>
+{
+  void bar (W &x) { V <int>::bar (x); }
+};
+
+int
+main ()
+{
+  W <int> a, b;
+  a.bar (b);
+}