diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2002-01-19 20:55:35 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2002-01-19 20:55:35 +0000 |
commit | 3807621a13b69e6b12fbae5d4667c696c0898da2 (patch) | |
tree | c0caa429a30876deffed186413d273aee78c75d9 | |
parent | e5550355c859516409f4e089ca5bda09f3811ea6 (diff) | |
download | gcc-3807621a13b69e6b12fbae5d4667c696c0898da2.zip gcc-3807621a13b69e6b12fbae5d4667c696c0898da2.tar.gz gcc-3807621a13b69e6b12fbae5d4667c696c0898da2.tar.bz2 |
Fix regression introduced with patch for c++/775
cp:
Fix regression introduced with patch for c++/775
* parse.y (class_head_defn): Check for template specializations
with a different class-key.
testsuite:
* g++.dg/template/access1.C: New test.
From-SVN: r49016
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/parse.y | 10 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/access1.C | 27 |
4 files changed, 47 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index abb6417..b4c9f70 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2002-01-19 Nathan Sidwell <nathan@codesourcery.com> + + Fix regression introduced with patch for c++/775 + * parse.y (class_head_defn): Check for template specializations + with a different class-key. + 2002-01-17 Jason Merrill <jason@redhat.com> * decl.c (begin_constructor_body, begin_destructor_body): New fns. diff --git a/gcc/cp/parse.y b/gcc/cp/parse.y index 31fc850..420e428 100644 --- a/gcc/cp/parse.y +++ b/gcc/cp/parse.y @@ -2434,12 +2434,22 @@ class_head_defn: yyungetc ('{', 1); $$.t = $1; $$.new_type_flag = 0; + if (TREE_CODE (TREE_TYPE ($1)) == RECORD_TYPE) + /* We might be specializing a template with a different + class-key. */ + CLASSTYPE_DECLARED_CLASS (TREE_TYPE ($1)) + = (current_aggr == class_type_node); } | class_head_apparent_template ':' { yyungetc (':', 1); $$.t = $1; $$.new_type_flag = 0; + if (TREE_CODE (TREE_TYPE ($1)) == RECORD_TYPE) + /* We might be specializing a template with a different + class-key. */ + CLASSTYPE_DECLARED_CLASS (TREE_TYPE ($1)) + = (current_aggr == class_type_node); } | aggr identifier_defn '{' { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6d56315..54e1a36 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2002-01-19 Nathan Sidwell <nathan@codesourcery.com> + + * g++.dg/template/access1.C: New test. + 2002-01-18 Aldy Hernandez <aldyh@redhat.com> * gcc.dg/20020118-1.c: New. diff --git a/gcc/testsuite/g++.dg/template/access1.C b/gcc/testsuite/g++.dg/template/access1.C new file mode 100644 index 0000000..1622e08 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/access1.C @@ -0,0 +1,27 @@ +// { dg-do compile } + +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 19 Jan 2002 <nathan@codesourcery.com> + +// It is legal to specialize a template with a different class-key. + +template<typename T> class X; + +template<typename T> struct X<T *> +{ + int i; +}; +template<> struct X<int> +{ + int i; +}; + +void foo () +{ + X<int *> xip; + X<int> xi; + + xip.i; + xi.i; +} + |