"function returning %qT", valtype);
/* Remember that this function did return. */
current_function_returns_value = 1;
+ /* But suppress NRV .*/
+ current_function_return_value = error_mark_node;
/* And signal caller that TREE_NO_WARNING should be set on the
RETURN_EXPR to avoid control reaches end of non-void function
warnings in tree-cfg.cc. */
/* If the conversion failed, treat this just like `return;'. */
if (retval == error_mark_node)
- return retval;
+ {
+ /* And suppress NRV. */
+ current_function_return_value = error_mark_node;
+ return retval;
+ }
/* We can't initialize a register from a AGGR_INIT_EXPR. */
else if (! cfun->returns_struct
&& TREE_CODE (retval) == TARGET_EXPR
--- /dev/null
+// PR c++/117099
+// With -fpermissive, make sure we don't do NRV in this case, but keep
+// executing fine. Note that the return at line 16 is undefined behaviour.
+// { dg-do "run" }
+// { dg-options "-fpermissive" }
+
+struct X {
+ ~X() {}
+};
+
+X test(bool b) {
+ X x;
+ if (b)
+ return x;
+ else
+ return; // { dg-warning "return-statement with no value" }
+}
+
+int main(int, char*[]) {
+ (void) test (false);
+ return 0;
+}
--- /dev/null
+// PR c++/117129
+// { dg-do "compile" { target c++11 } }
+
+struct Noncopyable {
+ Noncopyable();
+ Noncopyable(const Noncopyable &) = delete; // { dg-note "declared here" }
+ virtual ~Noncopyable();
+};
+Noncopyable nrvo() {
+ {
+ Noncopyable A;
+ return A; // { dg-error "use of deleted function" }
+ // { dg-note "display considered" "" { target *-*-* } .-1 }
+ }
+}