Re: [Bug c++/22452] [4.1 regression] ICE expected tree that contains 'decl with visibility' structure, have 'const_decl' in decl_linkage, at cp/tree.c:2132

2005-07-14 Thread Gabriel Dos Reis
dberlin at gcc dot gnu dot org [EMAIL PROTECTED] writes:

| Nathan tells me it's lk_internal for a CONST_DECL.

Where does that come from?

There is a section numbered 3.5 and titled Program and linkage.  It
says in paragraph 4

  A name having namespace scope has external linkage if it is the name of
  -- an object or reference, unless it has internal linkage; or

  -- a function, unless it has internal linkage; or

  -- a named class (clause 9), or an unnamed class defined in a
 typedef declaration in which the class has the typedef name for
 linkage purposes (7.1.3); or 

  -- a named enumeration (7.2), or an unnamed enumeration defined in a
 typedef declaration in which the enumeration has the typedef name
  for linkage purposes (7.1.3); or 

  -- an enumerator belonging to an enumeration with external linkage; or

  -- a template, unless it is a function template that has internal
 linkage (clause 14); or

  -- a namespace (7.3), unless it is declared within an unnamed namespace.

And in paragraph 8, it continues:

  Names not covered by these rules have no linkage. Moreover, except
  as noted, a name declared in a local scope (3.3.2) has no linkage. A
  name with no linkage (notably, the name of a class or enumeration
  declared in a local scope (3.3.2)) shall not be used to declare an
  entity with linkage. If a declaration uses a typedef name, it is the
  linkage of the type name to which the typedef refers that is considered.

those clearly indicates to me that the linkage of a CONST_DECL
depends on the linkage of its enumeration.

| fixing.

Please look at section 3.5 before fixing this.  
(besides an numeration does not have storage).

-- Gaby


Re: [Bug c++/22452] [4.1 regression] ICE expected tree that contains 'decl with visibility' structure, have 'const_decl' in decl_linkage, at cp/tree.c:2132

2005-07-14 Thread Gabriel Dos Reis
dberlin at dberlin dot org [EMAIL PROTECTED] writes:

| --- Additional Comments From dberlin at gcc dot gnu dot org  2005-07-14 
20:40 ---
| Subject: Re:  [4.1 regression] ICE expected tree that
|   contains 'decl with visibility' structure, have 'const_decl'  in
|   decl_linkage, at cp/tree.c:2132
| 
| 
|  | 
|  | I really don't have the skills to play language lawyer here, my
|  
|  I'm not here to play language lawyer neither; but the claim just looks
|  wrong to me.  Unless you define playing language lawyer as giving
|  asnwer you questions you raised.
| Playing language lawyer is sitting here quoting the standard at me
| instead of demonstrating a testcase where the old answer is wrong.

The comment in front of DECL_EXTERNAL_LINKAGE_P says this:

   /* Returns nonzero if DECL has external linkage, as specified by the
  language standard.  (This predicate may hold even when the
  corresponding entity is not actually given external linkage in the
  object file; see decl_linkage for details.)  */
   #define DECL_EXTERNAL_LINKAGE_P(DECL) \
 (decl_linkage (DECL) == lk_external)

So, if you find a testcase where decl_linkage() returns lk_internal
insteand of lk_external, then you have found a bug in the compiler.
The fix is not to copy-and-paste that error.  Language lawyering
notwithstanding. 

-- Gaby