public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97531] New: Improve type/non-type declaration diagnostic
@ 2020-10-22 15:27 mpolacek at gcc dot gnu.org
  2020-10-25 22:32 ` [Bug c++/97531] " mpolacek at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-10-22 15:27 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97531
           Summary: Improve type/non-type declaration diagnostic
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mpolacek at gcc dot gnu.org
  Target Milestone: ---

For this:

struct A { };
struct B { B(A); };

void
fn ()
{
  B(A()); // extern struct B A (void);
  A a;
}

we issue:
q.C: In function ‘void fn()’:
q.C:8:4: error: expected ‘;’ before ‘a’
    8 |   A a;
      |    ^~
      |    ;

Eh, what?

clang++:
q.C:8:3: error: must use 'struct' tag to refer to type 'A' in this scope
  A a;
  ^
  struct 
q.C:7:5: note: struct 'A' is hidden by a non-type declaration of 'A' here
  B(A()); // extern struct B A (void);
    ^

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

* [Bug c++/97531] Improve type/non-type declaration diagnostic
  2020-10-22 15:27 [Bug c++/97531] New: Improve type/non-type declaration diagnostic mpolacek at gcc dot gnu.org
@ 2020-10-25 22:32 ` mpolacek at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-10-25 22:32 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2020-10-25
     Ever confirmed|0                           |1

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Extended test:

// PR c++/97531

struct A { };
void A(int);

void
fn0 ()
{
  A a;
  static A *a2;
}

int B;
struct B { };

void
fn1 ()
{
  B b;
  static B *b2;
}

enum E { };
void E();

void
fn2 ()
{
  E e;
  static E *e2;
}

class C { };
void C(int);

void
fn3 ()
{
  C c;
  static C *c2;
}

union U { };
void U(int);

void
fn4 ()
{
  U u;
  static U *u2;
}

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

end of thread, other threads:[~2020-10-25 22:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-22 15:27 [Bug c++/97531] New: Improve type/non-type declaration diagnostic mpolacek at gcc dot gnu.org
2020-10-25 22:32 ` [Bug c++/97531] " mpolacek 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).