diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2003-08-01 09:10:29 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2003-08-01 09:10:29 +0000 |
commit | f21e6028bf127c16c109bbfe9135334077522ee5 (patch) | |
tree | d54995de86d2bed6da9b874ebae55c3a69e5f7e8 /gcc | |
parent | 2fdd01a09a1376515255cfb8a568f682dce80fbc (diff) | |
download | gcc-f21e6028bf127c16c109bbfe9135334077522ee5.zip gcc-f21e6028bf127c16c109bbfe9135334077522ee5.tar.gz gcc-f21e6028bf127c16c109bbfe9135334077522ee5.tar.bz2 |
re PR c++/11525 (ICE/segfault on C++ code)
cp:
PR c++/11525
* parser.c (cp_parser_primary_expression): Do not set
non-constant-p merely because it is a dependent scope.
testsuite:
PR c++/11525
* g++.dg/parse/constant4.C: New test.
From-SVN: r70041
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/parser.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/parse/constant4.C | 40 |
4 files changed, 47 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8c2e6a3..1bc4fed 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2003-08-01 Nathan Sidwell <nathan@codesourcery.com> + PR c++/11525 + * parser.c (cp_parser_primary_expression): Do not set + non-constant-p merely because it is a dependent scope. + PR c++/9447 * decl2.c (do_class_using_decl): Set type to NULL_TREE. * semantics.c (finish_expr_stmt): Do not convert to void in a diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 64d260d..c4b40b2 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -2394,11 +2394,6 @@ cp_parser_primary_expression (cp_parser *parser, { if (TYPE_P (TREE_OPERAND (decl, 0))) *qualifying_class = TREE_OPERAND (decl, 0); - /* Since this name was dependent, the expression isn't - constant -- yet. No error is issued because it - might be constant when things are instantiated. */ - if (parser->constant_expression_p) - parser->non_constant_expression_p = true; return decl; } /* Check to see if DECL is a local variable in a context diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 57e9802..f78f24ec 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2003-08-01 Nathan Sidwell <nathan@codesourcery.com> + PR c++/11525 + * g++.dg/parse/constant4.C: New test. + PR c++/9447 * g++.dg/template/using5.C: New test. diff --git a/gcc/testsuite/g++.dg/parse/constant4.C b/gcc/testsuite/g++.dg/parse/constant4.C new file mode 100644 index 0000000..65c84d9 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/constant4.C @@ -0,0 +1,40 @@ +// { dg-do compile } + +// Copyright (C) 2003 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 31 Jul 2003 <nathan@codesourcery.com> + +// PR c++/11525 incorrect error about non-constant initalizer + +template<typename> class X; +template<unsigned> class Y {}; + + +template<typename T> +void Foo () +{ + static const unsigned I = X<T>::I; + + Y<I> i; + + static const unsigned J = X<T>::J; + + Y<J> j; // { dg-error "non-constant" "" } +} + +struct A +{ + operator unsigned () const; +}; + +template <typename> struct X +{ + enum {I}; + static A const J; +}; + +void Baz () +{ + Foo<int> (); // { dg-error "instantiated" "" } +} + + |