aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@redhat.com>2012-11-13 16:07:39 +0000
committerDodji Seketeli <dodji@gcc.gnu.org>2012-11-13 17:07:39 +0100
commitbe22520dc2bc13d2cfa59266f55776889f5a2775 (patch)
treeec9c5e766874a50e7788247a78b4d686f70b0720 /gcc
parentd6531d8364a6dc74c61462743c52dc6275d54beb (diff)
downloadgcc-be22520dc2bc13d2cfa59266f55776889f5a2775.zip
gcc-be22520dc2bc13d2cfa59266f55776889f5a2775.tar.gz
gcc-be22520dc2bc13d2cfa59266f55776889f5a2775.tar.bz2
PR c++/54466 - ICE with alias template which type-id is const qualified
Consider this short example: template<typename T> struct X { }; template<typename T> using Y = const X<T>; using Z = Y<int>; G++ crashes in lookup_class_template_1 while trying to build the alias template instantiation Y<int>. I think this is indirectly due to the fact that that lookup_class_template_1 can now yield a const qualified type like 'const X<T>'. As a consequence, the code in lookup_template_class_1 that was trying to access the TYPE_STUB_DECL field of the result of lookup_template_class_1 should now be adjusted to access the TYPE_STUB_DECL of the main variant of the resulting type instead (and that is TYPE_MAIN_DECL); because qualified types (constructed with build_qualified_type) have their TYPE_STUB_DECL set to NULL. Fixed thus and tested on x86_64-unknown-linux-gnu against trunk. gcc/cp PR c++/54466 * pt.c (lookup_template_class_1): TYPE_STUB_DECL should be accessed on the main variant of the type. gcc/testsuite/ * g++.dg/cpp0x/alias-decl-26.C: New test file. In the example of this patch, g++ crashes when trying to build the alias template Y<int From-SVN: r193479
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/pt.c4
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/alias-decl-26.C10
4 files changed, 23 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index cb861cb..0f23cbc 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2012-11-13 Dodji Seketeli <dodji@redhat.com>
+
+ PR c++/54466
+ * pt.c (lookup_template_class_1): TYPE_STUB_DECL should be
+ accessed on the main variant of the type.
+
2012-11-12 Ed Smith-Rowland <3dw4rd@verizon.net>
* parser.c (cp_parser_objc_class_ivars):
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 50d12b0..802c79b 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -7372,9 +7372,9 @@ lookup_template_class_1 (tree d1, tree arglist, tree in_decl, tree context,
if (CLASS_TYPE_P (template_type))
{
TREE_PRIVATE (type_decl)
- = TREE_PRIVATE (TYPE_STUB_DECL (template_type));
+ = TREE_PRIVATE (TYPE_MAIN_DECL (template_type));
TREE_PROTECTED (type_decl)
- = TREE_PROTECTED (TYPE_STUB_DECL (template_type));
+ = TREE_PROTECTED (TYPE_MAIN_DECL (template_type));
if (CLASSTYPE_VISIBILITY_SPECIFIED (template_type))
{
DECL_VISIBILITY_SPECIFIED (type_decl) = 1;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1eba36d..e82a88f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2012-11-13 Dodji Seketeli <dodji@redhat.com>
+
+ PR c++/54466
+ * g++.dg/cpp0x/alias-decl-26.C: New test file.
+
2012-11-13 H.J. Lu <hongjiu.lu@intel.com>
* gcc.target/i386/avx256-unaligned-load-2.c: Requre !ia32
diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-26.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-26.C
new file mode 100644
index 0000000..dd4cc02
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-26.C
@@ -0,0 +1,10 @@
+// Origin: PR c++/54466
+// { dg-do compile { target c++11 } }
+
+template<typename T>
+ struct X { };
+
+template<typename T>
+ using Y = const X<T>;
+
+using Z = Y<int>;