return StmtError();
RetValExp = Result.take();
- if (!CurContext->isDependentContext())
+ if (!CurContext->isDependentContext()) {
FnRetType = RetValExp->getType();
- else
+ // In C++11, we take the type of the expression after decay and
+ // lvalue-to-rvalue conversion, so a class type can be cv-qualified.
+ // In C++1y, we perform template argument deduction as if the return
+ // type were 'auto', so an implicit return type is never cv-qualified.
+ if (getLangOpts().CPlusPlus1y && FnRetType.hasQualifiers())
+ FnRetType = FnRetType.getUnqualifiedType();
+ } else
FnRetType = CurCap->ReturnType = Context.DependentTy;
} else {
if (RetValExp) {
if (y > 0)
return X();
else
- return x; // expected-error{{return type 'const X' must match previous return type 'X' when lambda expression has unspecified explicit return type}}
+ return x;
+#if __cplusplus <= 201103L
+ // expected-error@-2 {{return type 'const X' must match previous return type 'X' when lambda expression has unspecified explicit return type}}
+#endif
}(5);
}
-// RUN: %clang_cc1 -std=c++0x -Wno-unused-value -fsyntax-only -verify -fblocks %s
+// RUN: %clang_cc1 -std=c++11 -Wno-unused-value -fsyntax-only -verify -fblocks %s
+// RUN: %clang_cc1 -std=c++1y -Wno-unused-value -fsyntax-only -verify -fblocks %s
namespace std { class type_info; };
return 0;
};
}
+
+namespace TypeDeduction {
+ struct S {};
+ void f() {
+ const S s {};
+ S &&t = [&] { return s; } ();
+#if __cplusplus <= 201103L
+ // expected-error@-2 {{drops qualifiers}}
+#else
+ S &&u = [&] () -> auto { return s; } ();
+#endif
+ }
+}