This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH]: Fix 11525
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Mark Mitchell <mitchell at codesourcery dot com>
- Date: Fri, 01 Aug 2003 10:10:49 +0100
- Subject: [C++ PATCH]: Fix 11525
- Organization: Codesourcery LLC
Hi,
I've installed the attached obvious patch for 11525. We were saying that
a dependent expression was non-constant far too early. Interestingly
this bug only shows up for function scope static consts, not class
scope static consts -- the linkage on the former is internal, but the
latter external, so the latter is a valid object for a
non-type template arg.
booted & tested on i686-pc-linux-gnu.
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
The voices in my head said this was stupid too
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
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.
Index: cp/parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.93
diff -c -3 -p -r1.93 parser.c
*** cp/parser.c 29 Jul 2003 23:36:52 -0000 1.93
--- cp/parser.c 31 Jul 2003 17:39:19 -0000
*************** cp_parser_primary_expression (cp_parser
*** 2394,2404 ****
{
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
--- 2394,2399 ----
// { 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" "" }
}