2013-03-16 Jason Merrill <jason@redhat.com>
+ PR c++/54359
+ * parser.c (cp_parser_direct_declarator): Fix late return
+ for out-of-class defn of member function.
+
PR c++/55357
* semantics.c (maybe_add_lambda_conv_op): Clear DECL_NAME of copied
parms to avoid duplicate -Wshadow warnings.
tree exception_specification;
tree late_return;
tree attrs;
+ bool memfn = (member_p || (pushed_scope
+ && CLASS_TYPE_P (pushed_scope)));
is_declarator = true;
attrs = cp_parser_std_attribute_spec_seq (parser);
late_return = (cp_parser_late_return_type_opt
- (parser, member_p ? cv_quals : -1));
+ (parser, memfn ? cv_quals : -1));
/* Parse the virt-specifier-seq. */
virt_specifiers = cp_parser_virt_specifier_seq_opt (parser);
--- /dev/null
+// PR c++/54359
+// { dg-require-effective-target c++11 }
+
+int& ref(int& x) { return x; }
+const int& ref(const int& x) { return x; }
+
+class A {
+ int x;
+ int f() const;
+ auto test1() const -> decltype(this);
+ auto test2() const -> decltype(ref(x));
+ auto test3() const -> decltype(f());
+};
+
+auto A::test1() const -> decltype(this) {
+ return this;
+}
+
+auto A::test2() const -> decltype(ref(x)) {
+ return ref(x);
+}
+
+auto A::test3() const -> decltype(f()) {
+ return f();
+}