aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2006-05-14 20:37:56 +0000
committerAlexandre Oliva <aoliva@gcc.gnu.org>2006-05-14 20:37:56 +0000
commitc497db75bae31d76a5402644ef247c2dc48ad801 (patch)
treed2c3f8b2f287aaa758f45c7def17dd6b5475546e
parentfaf32f4aa5df7a44d5566884150fcf910cc647a5 (diff)
downloadgcc-c497db75bae31d76a5402644ef247c2dc48ad801.zip
gcc-c497db75bae31d76a5402644ef247c2dc48ad801.tar.gz
gcc-c497db75bae31d76a5402644ef247c2dc48ad801.tar.bz2
pt.c (build_non_dependent_expr): Leave ADDR_EXPR of COMPONENT_REF alone.
gcc/cp/ChangeLog: * pt.c (build_non_dependent_expr): Leave ADDR_EXPR of COMPONENT_REF alone. gcc/testsuite/ChangeLog: * g++.dg/template/dependent-expr5.C: New test. From-SVN: r113765
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/pt.c9
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/template/dependent-expr5.C114
4 files changed, 128 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 898c13f..0af68ec 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2006-05-14 Alexandre Oliva <aoliva@redhat.com>
+
+ * pt.c (build_non_dependent_expr): Leave ADDR_EXPR of
+ COMPONENT_REF alone.
+
2006-05-11 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/27547
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 4d34da4..c1530fb 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -12903,10 +12903,11 @@ build_non_dependent_expr (tree expr)
return expr;
/* Preserve OVERLOADs; the functions must be available to resolve
types. */
- inner_expr = (TREE_CODE (expr) == ADDR_EXPR ?
- TREE_OPERAND (expr, 0) :
- TREE_CODE (expr) == COMPONENT_REF ?
- TREE_OPERAND (expr, 1) : expr);
+ inner_expr = expr;
+ if (TREE_CODE (inner_expr) == ADDR_EXPR)
+ inner_expr = TREE_OPERAND (inner_expr, 0);
+ if (TREE_CODE (inner_expr) == COMPONENT_REF)
+ inner_expr = TREE_OPERAND (inner_expr, 1);
if (is_overloaded_fn (inner_expr)
|| TREE_CODE (inner_expr) == OFFSET_REF)
return expr;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 030c182..a2a2ae5e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2006-05-14 Alexandre Oliva <aoliva@redhat.com>
+
+ * g++.dg/template/dependent-expr5.C: New test.
+
2006-05-14 Roger Sayle <roger@eyesopen.com>
PR middle-end/26729
diff --git a/gcc/testsuite/g++.dg/template/dependent-expr5.C b/gcc/testsuite/g++.dg/template/dependent-expr5.C
new file mode 100644
index 0000000..023f433
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/dependent-expr5.C
@@ -0,0 +1,114 @@
+// { dg-do compile }
+
+// Copyright 2005 Free Software Foundation
+// contributed by Alexandre Oliva <aoliva@redhat.com>
+// inspired in the failure reported in Red Hat bugzilla #168260.
+
+template<class F> void bind(F f) {}
+
+template<class F> void bindm(F f) {}
+template<class F, class T> void bindm(F (T::*f)(void)) {} // { dg-error "note" }
+
+template<class F> void bindn(F f) {}
+template<class F, class T> void bindn(F (*f)(T)) {}
+
+template<class F> void bindb(F f) {}
+template<class F, class T> void bindb(F (*f)(T)) {} // { dg-error "note" }
+template<class F, class T> void bindb(F (T::*f)(void)) {} // { dg-error "note" }
+
+struct foo {
+ static int baist;
+ int bait;
+ void barf ();
+ static void barf (int);
+
+ struct bar {
+ static int baikst;
+ int baikt;
+ void bark ();
+ static void bark (int);
+
+ bar() {
+ bind (&baist);
+ bind (&foo::baist);
+ bind (&bait); // { dg-error "nonstatic data member" }
+ bind (&foo::bait);
+
+ bind (&baikst);
+ bind (&bar::baikst);
+ bind (&baikt); // ok, this->baikt
+ bind (&bar::baikt);
+
+ bind (&barf); // { dg-error "no matching function" }
+ bind (&foo::barf); // { dg-error "no matching function" }
+
+ bindm (&barf); // { dg-error "no matching function" }
+ bindm (&foo::barf);
+
+ bindn (&barf);
+ bindn (&foo::barf);
+
+ bindb (&barf);
+ bindb (&foo::barf); // { dg-error "ambiguous" }
+
+ bind (&bark); // { dg-error "no matching function" }
+ bind (&bar::bark); // { dg-error "no matching function" }
+
+ bindm (&bark); // { dg-error "no matching function" }
+ bindm (&bar::bark);
+
+ bindn (&bark);
+ bindn (&bar::bark);
+
+ bindb (&bark);
+ bindb (&bar::bark); // { dg-error "ambiguous" }
+ }
+ };
+
+ template <typename T>
+ struct barT {
+ static int baikst;
+ int baikt;
+ void bark ();
+ static void bark (int);
+
+ barT() {
+ bind (&baist);
+ bind (&foo::baist);
+ bind (&bait); // { dg-error "nonstatic data member" }
+ bind (&foo::bait);
+
+ bind (&baikst);
+ bind (&barT::baikst);
+ bind (&baikt); // ok, this->baikt
+ bind (&barT::baikt);
+
+ bind (&barf); // { dg-error "no matching function" }
+ bind (&foo::barf); // { dg-error "no matching function" }
+
+ bindm (&barf); // { dg-error "no matching function" }
+ bindm (&foo::barf);
+
+ bindn (&barf);
+ bindn (&foo::barf);
+
+ bindb (&barf);
+ bindb (&foo::barf); // { dg-error "ambiguous" }
+
+ bind (&bark); // { dg-error "no matching function" }
+ bind (&barT::bark); // { dg-error "no matching function" }
+
+ bindm (&bark); // { dg-error "no matching function" }
+ bindm (&barT::bark);
+
+ bindn (&bark);
+ bindn (&barT::bark);
+
+ bindb (&bark);
+ bindb (&barT::bark); // { dg-error "ambiguous" }
+ }
+ };
+
+ bar bard;
+ barT<void> bart;
+} bad;