LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 15243 - clang makes nested-namespace incorrectly
Summary: clang makes nested-namespace incorrectly
Status: RESOLVED DUPLICATE of bug 13403
Alias: None
Product: clang
Classification: Unclassified
Component: C++ (show other bugs)
Version: trunk
Hardware: PC Linux
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
: 15860 19276 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-02-12 03:54 PST by Jaemin Park
Modified: 2015-04-16 18:15 PDT (History)
6 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jaemin Park 2013-02-12 03:54:41 PST
Following code snippet seems incorrect, but clang handles it without error. 

class CFoo
{
public:
  CFoo() {};
  ~CFoo() {};
};

int main()
{
  CFoo::CFoo::CFoo::CFoo::CFoo* pFoo = new CFoo();
}
Comment 1 Richard Smith 2013-02-12 11:05:41 PST
Clang is correct. The inner ::CFoo is the injected class name.
Comment 2 Jaemin Park 2013-02-12 23:26:43 PST
Could you explain about this behavior? GCC handles it as an error.
Comment 3 Richard Smith 2013-02-19 16:35:22 PST
Looks like GCC implements the resolution of core issue 1310, under which this is ill-formed.

For some lookups, this rule applies:

C++ [class]p2: "A class-name is inserted into the scope in which it is declared immediately after the class-name is seen. The class-name is also inserted into the scope of the class itself; this is known as the injected-class-name."

However, under core issue 1310, this only applies in the rarer case of a lookup which ignores function names. So the 'CFoo::CFoo::' finds the injected-class-name, but the final '::CFoo' is a constructor name.
Comment 4 Richard Smith 2013-04-29 08:03:57 PDT
*** Bug 15860 has been marked as a duplicate of this bug. ***
Comment 5 Richard Smith 2014-03-28 13:08:40 PDT
*** Bug 19276 has been marked as a duplicate of this bug. ***
Comment 6 Richard Smith 2015-04-16 18:15:13 PDT

*** This bug has been marked as a duplicate of bug 13403 ***