public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/60994] New: gcc does not recognize hidden/shadowed enumeration as valid nested-name-specifier
@ 2014-04-29  7:00 momchil.velikov at gmail dot com
  2014-04-29  7:07 ` [Bug c++/60994] " trippels at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: momchil.velikov at gmail dot com @ 2014-04-29  7:00 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60994

            Bug ID: 60994
           Summary: gcc does not recognize hidden/shadowed enumeration as
                    valid nested-name-specifier
           Product: gcc
           Version: 4.10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: momchil.velikov at gmail dot com

gcc version 4.10.0 20140428 (experimental) (GCC)

Compiling (with c++ -c -std=c++11 b.cc) the following program

enum struct A
{
  n = 3
};

int
foo()
{
  int A;
  return A::n;
}

results in the error:

b.cc: In function 'int foo()':
b.cc:10:10: error: 'A' is not a class, namespace, or enumeration
   return A::n;
          ^
According to the C++11 Standard, [basic.lookup.qual] #1

"If a :: scope resolution operator in a nested-name-specifier is not preceded
by a decltype-specifier, lookup of the name preceding that :: considers only
namespaces, types, and templates whose specializations are types."

GCC ought not to resolve "A" to the local variable, but to the enumeration
type. This is very similar to the example in the standard 

struct A
{
  static int n;
};

int
foo()
{
  int A;
  return A::n;
}


which is compiled correctly by GCC, though.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/60994] gcc does not recognize hidden/shadowed enumeration as valid nested-name-specifier
  2014-04-29  7:00 [Bug c++/60994] New: gcc does not recognize hidden/shadowed enumeration as valid nested-name-specifier momchil.velikov at gmail dot com
@ 2014-04-29  7:07 ` trippels at gcc dot gnu.org
  2014-04-29  7:56 ` redi at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: trippels at gcc dot gnu.org @ 2014-04-29  7:07 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60994

Markus Trippelsdorf <trippels at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |trippels at gcc dot gnu.org
         Resolution|---                         |INVALID

--- Comment #1 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
Implicit enum to int conversion is not provided for a scoped enumeration.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/60994] gcc does not recognize hidden/shadowed enumeration as valid nested-name-specifier
  2014-04-29  7:00 [Bug c++/60994] New: gcc does not recognize hidden/shadowed enumeration as valid nested-name-specifier momchil.velikov at gmail dot com
  2014-04-29  7:07 ` [Bug c++/60994] " trippels at gcc dot gnu.org
@ 2014-04-29  7:56 ` redi at gcc dot gnu.org
  2014-04-29  9:59 ` momchil.velikov at gmail dot com
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2014-04-29  7:56 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60994

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
             Status|RESOLVED                    |NEW
   Last reconfirmed|                            |2014-04-29
         Resolution|INVALID                     |---
     Ever confirmed|0                           |1

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Momchil Velikov from comment #0)

> According to the C++11 Standard, [basic.lookup.qual] #1
> 
> "If a :: scope resolution operator in a nested-name-specifier is not
> preceded by a decltype-specifier, lookup of the name preceding that ::
> considers only namespaces, types, and templates whose specializations are
> types."

Confirmed. C++03 said "During the lookup for a name preceding the :: scope
resolution operator, object, function, and enumerator names are ignored."


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/60994] gcc does not recognize hidden/shadowed enumeration as valid nested-name-specifier
  2014-04-29  7:00 [Bug c++/60994] New: gcc does not recognize hidden/shadowed enumeration as valid nested-name-specifier momchil.velikov at gmail dot com
  2014-04-29  7:07 ` [Bug c++/60994] " trippels at gcc dot gnu.org
  2014-04-29  7:56 ` redi at gcc dot gnu.org
@ 2014-04-29  9:59 ` momchil.velikov at gmail dot com
  2014-08-28 19:02 ` aaw at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: momchil.velikov at gmail dot com @ 2014-04-29  9:59 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60994

--- Comment #5 from Momchil Velikov <momchil.velikov at gmail dot com> ---
Proposed fix: http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01938.html


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/60994] gcc does not recognize hidden/shadowed enumeration as valid nested-name-specifier
  2014-04-29  7:00 [Bug c++/60994] New: gcc does not recognize hidden/shadowed enumeration as valid nested-name-specifier momchil.velikov at gmail dot com
                   ` (2 preceding siblings ...)
  2014-04-29  9:59 ` momchil.velikov at gmail dot com
@ 2014-08-28 19:02 ` aaw at gcc dot gnu.org
  2015-02-12 13:49 ` redi at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: aaw at gcc dot gnu.org @ 2014-08-28 19:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60994

Ollie Wild <aaw at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |potswa at mac dot com

--- Comment #6 from Ollie Wild <aaw at gcc dot gnu.org> ---
*** Bug 61492 has been marked as a duplicate of this bug. ***


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/60994] gcc does not recognize hidden/shadowed enumeration as valid nested-name-specifier
  2014-04-29  7:00 [Bug c++/60994] New: gcc does not recognize hidden/shadowed enumeration as valid nested-name-specifier momchil.velikov at gmail dot com
                   ` (3 preceding siblings ...)
  2014-08-28 19:02 ` aaw at gcc dot gnu.org
@ 2015-02-12 13:49 ` redi at gcc dot gnu.org
  2015-02-12 13:53 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2015-02-12 13:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60994

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Another example, with a function template:

struct s
{
  static int i;
};

template <typename T>
int s()
{
  return s::i;
}

p.cc: In function ‘int s()’:
p.cc:9:10: error: ‘s’ is not a class, namespace, or enumeration
   return s::i;
          ^

Clang and EDG accept it.
>From gcc-bugs-return-477030-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Feb 12 13:49:35 2015
Return-Path: <gcc-bugs-return-477030-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 7818 invoked by alias); 12 Feb 2015 13:49:34 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 7723 invoked by uid 48); 12 Feb 2015 13:49:31 -0000
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug lto/65012] [5 Regression] systemd fails to build at least on ppc64el, powerpc, arm-inux-gnueabihf and aarch64 with -flto (ICE)
Date: Thu, 12 Feb 2015 13:49:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: lto
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords: ice-on-valid-code
X-Bugzilla-Severity: normal
X-Bugzilla-Who: jakub at gcc dot gnu.org
X-Bugzilla-Status: WAITING
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 5.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on cc everconfirmed
Message-ID: <bug-65012-4-B936rJUGP7@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-65012-4@http.gcc.gnu.org/bugzilla/>
References: <bug-65012-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-02/txt/msg01363.txt.bz2
Content-length: 478

https://gcc.gnu.org/bugzilla/show_bug.cgi?ide012

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2015-02-12
                 CC|                            |jakub at gcc dot gnu.org
     Ever confirmed|0                           |1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/60994] gcc does not recognize hidden/shadowed enumeration as valid nested-name-specifier
  2014-04-29  7:00 [Bug c++/60994] New: gcc does not recognize hidden/shadowed enumeration as valid nested-name-specifier momchil.velikov at gmail dot com
                   ` (4 preceding siblings ...)
  2015-02-12 13:49 ` redi at gcc dot gnu.org
@ 2015-02-12 13:53 ` jakub at gcc dot gnu.org
  2015-02-12 14:28 ` momchil.velikov at gmail dot com
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-02-12 13:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60994

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Have you pinged your patch?  If a patch isn't reviewed within a week or two,
you should ping it on gcc-patches.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/60994] gcc does not recognize hidden/shadowed enumeration as valid nested-name-specifier
  2014-04-29  7:00 [Bug c++/60994] New: gcc does not recognize hidden/shadowed enumeration as valid nested-name-specifier momchil.velikov at gmail dot com
                   ` (5 preceding siblings ...)
  2015-02-12 13:53 ` jakub at gcc dot gnu.org
@ 2015-02-12 14:28 ` momchil.velikov at gmail dot com
  2015-04-14 15:30 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: momchil.velikov at gmail dot com @ 2015-02-12 14:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60994

--- Comment #9 from Momchil Velikov <momchil.velikov at gmail dot com> ---
https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00659.html(In reply to Jakub
Jelinek from comment #8)
> Have you pinged your patch?  If a patch isn't reviewed within a week or two,
> you should ping it on gcc-patches.

Yep, I did and got feedback.

https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00659.html

Unfortunately, I'm kinda busy with other things right now ...


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/60994] gcc does not recognize hidden/shadowed enumeration as valid nested-name-specifier
  2014-04-29  7:00 [Bug c++/60994] New: gcc does not recognize hidden/shadowed enumeration as valid nested-name-specifier momchil.velikov at gmail dot com
                   ` (6 preceding siblings ...)
  2015-02-12 14:28 ` momchil.velikov at gmail dot com
@ 2015-04-14 15:30 ` jason at gcc dot gnu.org
  2021-08-04 21:03 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2015-04-14 15:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60994

--- Comment #10 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Tue Apr 14 15:29:21 2015
New Revision: 222094

URL: https://gcc.gnu.org/viewcvs?rev=222094&root=gcc&view=rev
Log:
    PR c++/60994
    * parser.c (cp_parser_class_name): Add enum_ok parameter.
    (cp_parser_qualifying_entity): Use it instead of cp_parser_type_name.
    (cp_parser_diagnose_invalid_type_name): Don't assume a template is
    a class template.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/scoped_enum3.C
    trunk/gcc/testsuite/g++.dg/cpp0x/scoped_enum4.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/g++.dg/cpp1y/var-templ23.C


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/60994] gcc does not recognize hidden/shadowed enumeration as valid nested-name-specifier
  2014-04-29  7:00 [Bug c++/60994] New: gcc does not recognize hidden/shadowed enumeration as valid nested-name-specifier momchil.velikov at gmail dot com
                   ` (7 preceding siblings ...)
  2015-04-14 15:30 ` jason at gcc dot gnu.org
@ 2021-08-04 21:03 ` pinskia at gcc dot gnu.org
  2021-08-04 21:04 ` pinskia at gcc dot gnu.org
  2023-12-02 11:16 ` cvs-commit at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-04 21:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60994

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |6.0

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/60994] gcc does not recognize hidden/shadowed enumeration as valid nested-name-specifier
  2014-04-29  7:00 [Bug c++/60994] New: gcc does not recognize hidden/shadowed enumeration as valid nested-name-specifier momchil.velikov at gmail dot com
                   ` (8 preceding siblings ...)
  2021-08-04 21:03 ` pinskia at gcc dot gnu.org
@ 2021-08-04 21:04 ` pinskia at gcc dot gnu.org
  2023-12-02 11:16 ` cvs-commit at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-04 21:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60994

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kariya_mitsuru at hotmail dot com

--- Comment #18 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 59921 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/60994] gcc does not recognize hidden/shadowed enumeration as valid nested-name-specifier
  2014-04-29  7:00 [Bug c++/60994] New: gcc does not recognize hidden/shadowed enumeration as valid nested-name-specifier momchil.velikov at gmail dot com
                   ` (9 preceding siblings ...)
  2021-08-04 21:04 ` pinskia at gcc dot gnu.org
@ 2023-12-02 11:16 ` cvs-commit at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-12-02 11:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60994

--- Comment #19 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Roger Sayle <sayle@gcc.gnu.org>:

https://gcc.gnu.org/g:193ef02a7f4f3e5349ad9cf8d3d4df466a99b677

commit r14-6075-g193ef02a7f4f3e5349ad9cf8d3d4df466a99b677
Author: Roger Sayle <roger@nextmovesoftware.com>
Date:   Sat Dec 2 11:15:14 2023 +0000

    RISC-V: Improve style to work around PR 60994 in host compiler.

    This simple patch allows me to build a cross-compiler to riscv using
    older versions of RedHat's system compiler.  The issue is PR c++/60994
    where g++ doesn't like the same name (demand_flags) to be used by both
    a variable and a (enumeration) type, which is also undesirable from a
    (GNU) coding style perspective.  One solution is to rename the type
    to demand_flags_t, but a less invasive change is to simply use another
    identifier for the problematic local variable, renaming demand_flags
    to dflags.

    2023-12-02  Roger Sayle  <roger@nextmovesoftware.com>

    gcc/ChangeLog
            * config/riscv/riscv-vsetvl.cc (csetvl_info::parse_insn): Rename
            local variable from demand_flags to dflags, to avoid conflicting
            with (enumeration) type of the same name.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-12-02 11:16 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-29  7:00 [Bug c++/60994] New: gcc does not recognize hidden/shadowed enumeration as valid nested-name-specifier momchil.velikov at gmail dot com
2014-04-29  7:07 ` [Bug c++/60994] " trippels at gcc dot gnu.org
2014-04-29  7:56 ` redi at gcc dot gnu.org
2014-04-29  9:59 ` momchil.velikov at gmail dot com
2014-08-28 19:02 ` aaw at gcc dot gnu.org
2015-02-12 13:49 ` redi at gcc dot gnu.org
2015-02-12 13:53 ` jakub at gcc dot gnu.org
2015-02-12 14:28 ` momchil.velikov at gmail dot com
2015-04-14 15:30 ` jason at gcc dot gnu.org
2021-08-04 21:03 ` pinskia at gcc dot gnu.org
2021-08-04 21:04 ` pinskia at gcc dot gnu.org
2023-12-02 11:16 ` cvs-commit at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).