Bug 64267 - [DR 482] Qualified declarators in redeclarations
Summary: [DR 482] Qualified declarators in redeclarations
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2014-12-11 12:37 UTC by Jonathan Wakely
Modified: 2021-08-09 21:04 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-08-09 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wakely 2014-12-11 12:37:18 UTC
namespace S
{
  struct coll;
  struct ::S::coll { };
}

qual.cc:4:20: error: global qualification of class name is invalid before ‘{’ token
   struct ::S::coll { };
                    ^

Clang 3.4 rejected this but 3.5 accepts it (with a -Wextra-qualification warning) and EDG accepts it.

http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#482 makes this valid, in at least C++14 (but it's a DR against C++11 so maybe there too).

The example from DR 482 is:

    void f();
    void ::f();        // error: qualified declarator

    namespace N {
      void f();
      void N::f() { }  // error: qualified declarator
    }

I get the same results for this, Clang 3.4 rejects, 3.5+ accepts, EDG accepts, and G++ rejects in all modes:

dr482.cc:2:14: error: explicit qualification in declaration of ‘void f()’
     void ::f();        // error: qualified declarator
              ^
dr482.cc:6:17: error: explicit qualification in declaration of ‘void N::f()’
       void N::f() { }  // error: qualified declarator
                 ^
Comment 1 Jonathan Wakely 2014-12-11 13:02:41 UTC
It seems Clang 3.1 used to give a warning, but Clang 3.2 promoted it to an error for GCC and EDG compatibility. They must have changed it again for DR482.