* decl.c (grokdeclarator): Clear type_quals for a member function
declared using a typedef. Don't complain about adding cv-quals
to a function typedef in C++0x mode.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156084
138bc75d-0d04-0410-961f-
82ee72b054a4
+2010-01-20 Jason Merrill <jason@redhat.com>
+
+ PR c++/40750
+ * decl.c (grokdeclarator): Clear type_quals for a member function
+ declared using a typedef. Don't complain about adding cv-quals
+ to a function typedef in C++0x mode.
+
2010-01-20 Jakub Jelinek <jakub@redhat.com>
* decl.c (create_array_type_for_decl): Remove set but not used
/* This was an error in C++98 (cv-qualifiers cannot be added to
a function type), but DR 295 makes the code well-formed by
dropping the extra qualifiers. */
- if (pedantic)
+ if (pedantic && cxx_dialect == cxx98)
{
tree bad_type = build_qualified_type (type, type_quals);
pedwarn (input_location, OPT_pedantic,
/* The qualifiers on the function type become the qualifiers on
the non-static member function. */
memfn_quals |= cp_type_quals (type);
+ type_quals = TYPE_UNQUALIFIED;
}
}
+2010-01-20 Jason Merrill <jason@redhat.com>
+
+ PR c++/40750
+ * g++.dg/parse/fn-typedef1.C: New.
+ * g++.dg/other/cv_quals.C: Adjust.
+
2010-01-20 Anthony Green <green@moxielogic.com>
* gcc.dg/cpp/_Pragma6.c: Skip this test for moxie-*-* (no
typedef int FI(int);
FIC f; // { dg-error "qualified" }
-// { dg-error "ignoring" "ignoring" { target *-*-* } 6 }
struct S {
FIC f; // OK
};
FIC S::*pm = &S::f;
const FI S::*pm2 = &S::f; // { dg-error "qualifier" }
-// { dg-error "cannot convert" "cannot convert" { target *-*-* } 17 }
+// { dg-error "cannot convert" "cannot convert" { target *-*-* } 16 }
const FIC S::*pm3 = &S::f; // { dg-error "qualifier" }
int S::f(int) const
--- /dev/null
+// PR c++/40750
+
+extern "C" void abort ();
+
+typedef void Fn() const;
+
+struct Foo {
+ Fn fn;
+};
+
+bool called = false;
+void Foo::fn() const { called = true; }
+
+int main() {
+ Foo f; f.fn();
+ if (!called)
+ abort();
+}