{"action":"created","issue":{"url":"https://api.github.com/repos/D-Programming-GDC/GDC/issues/168","repository_url":"https://api.github.com/repos/D-Programming-GDC/GDC","labels_url":"https://api.github.com/repos/D-Programming-GDC/GDC/issues/168/labels{/name}","comments_url":"https://api.github.com/repos/D-Programming-GDC/GDC/issues/168/comments","events_url":"https://api.github.com/repos/D-Programming-GDC/GDC/issues/168/events","html_url":"https://github.com/D-Programming-GDC/GDC/pull/168","id":143354908,"number":168,"title":"Rewrite function duplicate handling","user":{"login":"jpf91","id":583238,"avatar_url":"https://avatars.githubusercontent.com/u/583238?v=3","gravatar_id":"","url":"https://api.github.com/users/jpf91","html_url":"https://github.com/jpf91","followers_url":"https://api.github.com/users/jpf91/followers","following_url":"https://api.github.com/users/jpf91/following{/other_user}","gists_url":"https://api.github.com/users/jpf91/gists{/gist_id}","starred_url":"https://api.github.com/users/jpf91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpf91/subscriptions","organizations_url":"https://api.github.com/users/jpf91/orgs","repos_url":"https://api.github.com/users/jpf91/repos","events_url":"https://api.github.com/users/jpf91/events{/privacy}","received_events_url":"https://api.github.com/users/jpf91/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2016-03-24T20:46:36Z","updated_at":"2016-03-29T17:58:00Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/D-Programming-GDC/GDC/pulls/168","html_url":"https://github.com/D-Programming-GDC/GDC/pull/168","diff_url":"https://github.com/D-Programming-GDC/GDC/pull/168.diff","patch_url":"https://github.com/D-Programming-GDC/GDC/pull/168.patch"},"body":"As already discussed the current fix for duplicate `FuncDeclaration`s generated by the frontend doesn't work for GCC <= 4.9. This approach keeps a hashmap of `Symbol`s in the `FuncDeclaration::toSymbol` function and makes sure we generate only one `Symbol` and therefore one `tree` per mangled name. It's a brute force method but there are some nice aspects as well. For example this is independent of the compiler backend version and we don't have to rely on backend internals. Additionally we still benefit from GCCs type checking: If the frontend provides to identically named functions with different types the GCC type checking will still detect the problem in some cases.\r\n\r\nI'm not sure if the code handling `VarDeclaration`s is actually required. At least the unit tests and the test suite don't seem to produce duplicated `VarDeclaration`s.\r\n\r\nThe `loc` comparison is necessary for the `fail_compilation/fail5634.d` testcase. Right now if a user creates duplicate functions these are only caught by the assembler. This pull request instead generates a nice error message with the location of the conflicting functions. BTW: Is there a better way to abort the compilation in `toSymbol` than checking for `error_mark_node` in the `toObjfile` methods?\r\n\r\nBTW2: I think the biggest backporting issue in the future will be the missing hash table. Pointer map only works for simple cases, but in cases like in this pull request I need a real hash table. So is there any reason I can't simply use the STL in GCC <= 4.9?"},"comment":{"url":"https://api.github.com/repos/D-Programming-GDC/GDC/issues/comments/203027431","html_url":"https://github.com/D-Programming-GDC/GDC/pull/168#issuecomment-203027431","issue_url":"https://api.github.com/repos/D-Programming-GDC/GDC/issues/168","id":203027431,"user":{"login":"ibuclaw","id":397929,"avatar_url":"https://avatars.githubusercontent.com/u/397929?v=3","gravatar_id":"","url":"https://api.github.com/users/ibuclaw","html_url":"https://github.com/ibuclaw","followers_url":"https://api.github.com/users/ibuclaw/followers","following_url":"https://api.github.com/users/ibuclaw/following{/other_user}","gists_url":"https://api.github.com/users/ibuclaw/gists{/gist_id}","starred_url":"https://api.github.com/users/ibuclaw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ibuclaw/subscriptions","organizations_url":"https://api.github.com/users/ibuclaw/orgs","repos_url":"https://api.github.com/users/ibuclaw/repos","events_url":"https://api.github.com/users/ibuclaw/events{/privacy}","received_events_url":"https://api.github.com/users/ibuclaw/received_events","type":"User","site_admin":false},"created_at":"2016-03-29T17:58:00Z","updated_at":"2016-03-29T17:58:00Z","body":":+1:"}}