aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2010-01-20 16:30:20 -0500
committerJason Merrill <jason@gcc.gnu.org>2010-01-20 16:30:20 -0500
commite4672ccdb366be7135f3e931c710df0ffbc46d1d (patch)
treee967e0b66fcbfaa1ab6aac422cfbc8718b8478a1 /gcc
parent35b954c12d0d5473a5d51fe1ff167aa0774c1a9c (diff)
downloadgcc-e4672ccdb366be7135f3e931c710df0ffbc46d1d.zip
gcc-e4672ccdb366be7135f3e931c710df0ffbc46d1d.tar.gz
gcc-e4672ccdb366be7135f3e931c710df0ffbc46d1d.tar.bz2
re PR c++/40750 (Side-effect of member function call not produced in certain circumstances)
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. From-SVN: r156084
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/decl.c3
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/other/cv_func.C3
-rw-r--r--gcc/testsuite/g++.dg/parse/fn-typedef1.C18
5 files changed, 34 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 8059a93..7269838 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+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
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 9624771..920d75b 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -8149,7 +8149,7 @@ grokdeclarator (const cp_declarator *declarator,
/* 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,
@@ -9046,6 +9046,7 @@ grokdeclarator (const cp_declarator *declarator,
/* 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;
}
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 90c8ca7..db9bb35 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+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
diff --git a/gcc/testsuite/g++.dg/other/cv_func.C b/gcc/testsuite/g++.dg/other/cv_func.C
index 4f10382..788c173 100644
--- a/gcc/testsuite/g++.dg/other/cv_func.C
+++ b/gcc/testsuite/g++.dg/other/cv_func.C
@@ -4,7 +4,6 @@ typedef int FIC(int) const;
typedef int FI(int);
FIC f; // { dg-error "qualified" }
-// { dg-error "ignoring" "ignoring" { target *-*-* } 6 }
struct S {
FIC f; // OK
@@ -15,7 +14,7 @@ struct S {
};
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
diff --git a/gcc/testsuite/g++.dg/parse/fn-typedef1.C b/gcc/testsuite/g++.dg/parse/fn-typedef1.C
new file mode 100644
index 0000000..6cc8625
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/fn-typedef1.C
@@ -0,0 +1,18 @@
+// 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();
+}