aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@redhat.com>2009-12-11 12:25:19 +0000
committerDodji Seketeli <dodji@gcc.gnu.org>2009-12-11 13:25:19 +0100
commitc9e900454a397fc14d0ba4bdef23fd3154314fbe (patch)
tree47ca36bdaed6504bec92cf44422a699d05be52d4 /gcc
parent8a8d675f4148d4fbccba88f514da8656bf1f27f2 (diff)
downloadgcc-c9e900454a397fc14d0ba4bdef23fd3154314fbe.zip
gcc-c9e900454a397fc14d0ba4bdef23fd3154314fbe.tar.gz
gcc-c9e900454a397fc14d0ba4bdef23fd3154314fbe.tar.bz2
re PR c++/42251 (failure detecting constant integral expression)
Fix PR c++/42251 gcc/cp/ChangeLog: PR c++/42251 * pt.c (convert_template_argument): Avoid missing folding of SCOPE_REFs. gcc/testsuite/ChangeLog: PR c++/42251 * g++.dg/template/const3.C: New test. From-SVN: r155159
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/pt.c16
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/template/const3.C20
4 files changed, 39 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index c98e68a..19e751d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2009-12-11 Dodji Seketeli <dodji@redhat.com>
+
+ PR c++/42251
+ * pt.c (convert_template_argument): Avoid missing folding of SCOPE_REFs.
+
2009-12-10 Jakub Jelinek <jakub@redhat.com>
PR c++/42317
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 97a2f80..6f76d46 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -5526,13 +5526,6 @@ convert_template_argument (tree parm,
if (TYPE_P (val))
val = strip_typedefs (val);
}
- else if (TREE_CODE (orig_arg) == SCOPE_REF)
- {
- /* Strip typedefs from the SCOPE_REF. */
- tree type = strip_typedefs (TREE_TYPE (orig_arg));
- tree scope = strip_typedefs (TREE_OPERAND (orig_arg, 0));
- val = build2 (SCOPE_REF, type, scope, TREE_OPERAND (orig_arg, 1));
- }
else
{
tree t = tsubst (TREE_TYPE (parm), args, complain, in_decl);
@@ -5571,6 +5564,15 @@ convert_template_argument (tree parm,
val = error_mark_node;
else if (val == error_mark_node && (complain & tf_error))
error ("could not convert template argument %qE to %qT", orig_arg, t);
+
+ if (TREE_CODE (val) == SCOPE_REF)
+ {
+ /* Strip typedefs from the SCOPE_REF. */
+ tree type = strip_typedefs (TREE_TYPE (val));
+ tree scope = strip_typedefs (TREE_OPERAND (val, 0));
+ val = build_qualified_name (type, scope, TREE_OPERAND (val, 1),
+ QUALIFIED_NAME_IS_TEMPLATE (val));
+ }
}
return val;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d6256a3..98744464 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2009-12-11 Dodji Seketeli <dodji@redhat.com>
+
+ PR c++/42251
+ * g++.dg/template/const3.C: New test.
+
2009-12-11 Richard Guenther <rguenther@suse.de>
PR lto/42320
diff --git a/gcc/testsuite/g++.dg/template/const3.C b/gcc/testsuite/g++.dg/template/const3.C
new file mode 100644
index 0000000..5ef2731
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/const3.C
@@ -0,0 +1,20 @@
+// Contributed by Dodji Seketeli <dodji@redhat.com>
+// Origin PR c++/42251
+// { dg-do "compile" }
+
+struct foo
+{
+ static const bool b = false;
+};
+
+template<bool x>
+struct S1
+{
+};
+
+template<bool x>
+struct S2
+ : S1<foo::b>
+{
+};
+