C++ PATCH for c++/83714, ICE checking return from template

Jason Merrill jason@redhat.com
Tue Jan 16 23:05:00 GMT 2018


Like my recent patch for 83186, we were missing a build_non_dependent_expr.

Tested x86_64-pc-linux-gnu, applying to trunk.
-------------- next part --------------
commit 5c63951fe987acd133bf59532896a4b397f49f12
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Jan 16 17:19:22 2018 -0500

            PR c++/83714 - ICE checking return in template.
    
            * typeck.c (check_return_expr): Call build_non_dependent_expr.

diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index f0dc03de111..d0adb798278 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -9333,6 +9333,9 @@ check_return_expr (tree retval, bool *no_warning)
 	 to undo it so we can try to treat it as an rvalue below.  */
       retval = maybe_undo_parenthesized_ref (retval);
 
+      if (processing_template_decl)
+	retval = build_non_dependent_expr (retval);
+
       /* Under C++11 [12.8/32 class.copy], a returned lvalue is sometimes
 	 treated as an rvalue for the purposes of overload resolution to
 	 favor move constructors over copy constructors.
diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-61.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-61.C
new file mode 100644
index 00000000000..670d91a158c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-61.C
@@ -0,0 +1,16 @@
+// PR c++/83714
+// { dg-do compile { target c++11 } }
+
+class a {
+  typedef int b;
+  operator b();
+};
+struct c {
+  using d = a;
+};
+using e = c;
+
+template <class T>
+e f(T) {
+  return e::d {};		// { dg-error "could not convert" }
+}


More information about the Gcc-patches mailing list