{"action":"created","comment":{"url":"https://api.github.com/repos/p4lang/p4c/pulls/comments/111442321","pull_request_review_id":32690353,"id":111442321,"diff_hunk":"@@ -0,0 +1,348 @@\n+/*\n+Copyright 2013-present Barefoot Networks, Inc.\n+\n+Licensed under the Apache License, Version 2.0 (the \"License\");\n+you may not use this file except in compliance with the License.\n+You may obtain a copy of the License at\n+\n+    http://www.apache.org/licenses/LICENSE-2.0\n+\n+Unless required by applicable law or agreed to in writing, software\n+distributed under the License is distributed on an \"AS IS\" BASIS,\n+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+See the License for the specific language governing permissions and\n+limitations under the License.\n+*/\n+\n+#include \"gtest/gtest.h\"\n+#include \"ir/ir.h\"\n+#include \"helpers.h\"\n+#include \"lib/log.h\"\n+\n+#include \"frontends/p4/typeMap.h\"\n+#include \"frontends/common/resolveReferences/referenceMap.h\"\n+#include \"frontends/common/resolveReferences/resolveReferences.h\"\n+\n+#include \"p4/createBuiltins.h\"\n+#include \"p4/typeChecking/typeChecker.h\"\n+\n+using namespace P4;\n+\n+TEST(arch, packet_out) {\n+    std::string program = R\"(\n+        // simplified core.p4\n+        extern packet_out {\n+            void emit<T> (in T hdr);\n+        }\n+        // simplified v1model.p4\n+        control Deparser<H> (packet_out b, in H hdr);\n+        package PSA<H> (Deparser<H> p);\n+        // user program\n+        struct ParsedHeaders {\n+            bit<32> hdr;\n+        }\n+        control MyDeparser(packet_out b, in ParsedHeaders h){\n+            apply {\n+                b.emit(h.hdr);\n+            }\n+        }\n+        PSA(MyDeparser()) main;\n+    )\";\n+    const IR::P4Program* pgm = parse_string(program);\n+\n+    ReferenceMap refMap;\n+    TypeMap      typeMap;\n+    PassManager  passes({\n+        new TypeChecking(&refMap, &typeMap)\n+    });\n+\n+    pgm = pgm->apply(passes);\n+    ASSERT_NE(nullptr, pgm);\n+}\n+\n+// Potential bug\n+TEST(arch, duplicatedDeclarationBug) {\n+    std::string program = R\"(\n+        // simplified core.p4\n+        extern packet_out {\n+            void emit<T> (in T hdr);\n+        }\n+        // simplified v1model.p4\n+        control Deparser<H> (packet_out b, in H hdr);\n+        package PSA<H> (Deparser<H> p);\n+        // user program\n+        struct ParsedHeaders {\n+            bit<32> hdr;\n+        }\n+        // BUG: duplicated name with 'Deparser'\n+        control Deparser(packet_out b, in ParsedHeaders h){","path":"test/gtest/arch_test.cpp","position":78,"original_position":78,"commit_id":"f39535a49c54fd92fafab92aceada9b62b2e0d7c","original_commit_id":"f39535a49c54fd92fafab92aceada9b62b2e0d7c","user":{"login":"ChrisDodd","id":4070641,"avatar_url":"https://avatars3.githubusercontent.com/u/4070641?v=3","gravatar_id":"","url":"https://api.github.com/users/ChrisDodd","html_url":"https://github.com/ChrisDodd","followers_url":"https://api.github.com/users/ChrisDodd/followers","following_url":"https://api.github.com/users/ChrisDodd/following{/other_user}","gists_url":"https://api.github.com/users/ChrisDodd/gists{/gist_id}","starred_url":"https://api.github.com/users/ChrisDodd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChrisDodd/subscriptions","organizations_url":"https://api.github.com/users/ChrisDodd/orgs","repos_url":"https://api.github.com/users/ChrisDodd/repos","events_url":"https://api.github.com/users/ChrisDodd/events{/privacy}","received_events_url":"https://api.github.com/users/ChrisDodd/received_events","type":"User","site_admin":false},"body":"The point is to test the simplified core/psa stuff.  The goal is ultimately to get a p4c-bmv2 that can generate code for either simple_switch or psa (depending on which header is included) and have it \"just work\"","created_at":"2017-04-13T17:24:28Z","updated_at":"2017-04-13T17:25:11Z","html_url":"https://github.com/p4lang/p4c/pull/459#discussion_r111442321","pull_request_url":"https://api.github.com/repos/p4lang/p4c/pulls/459","_links":{"self":{"href":"https://api.github.com/repos/p4lang/p4c/pulls/comments/111442321"},"html":{"href":"https://github.com/p4lang/p4c/pull/459#discussion_r111442321"},"pull_request":{"href":"https://api.github.com/repos/p4lang/p4c/pulls/459"}}},"pull_request":{"url":"https://api.github.com/repos/p4lang/p4c/pulls/459","id":114925058,"html_url":"https://github.com/p4lang/p4c/pull/459","diff_url":"https://github.com/p4lang/p4c/pull/459.diff","patch_url":"https://github.com/p4lang/p4c/pull/459.patch","issue_url":"https://api.github.com/repos/p4lang/p4c/issues/459","number":459,"state":"closed","locked":false,"title":"A few gtest cases for PSA","user":{"login":"hanw","id":125978,"avatar_url":"https://avatars2.githubusercontent.com/u/125978?v=3","gravatar_id":"","url":"https://api.github.com/users/hanw","html_url":"https://github.com/hanw","followers_url":"https://api.github.com/users/hanw/followers","following_url":"https://api.github.com/users/hanw/following{/other_user}","gists_url":"https://api.github.com/users/hanw/gists{/gist_id}","starred_url":"https://api.github.com/users/hanw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hanw/subscriptions","organizations_url":"https://api.github.com/users/hanw/orgs","repos_url":"https://api.github.com/users/hanw/repos","events_url":"https://api.github.com/users/hanw/events{/privacy}","received_events_url":"https://api.github.com/users/hanw/received_events","type":"User","site_admin":false},"body":"A few examples for creating clone as extern in PSA.","created_at":"2017-04-08T01:18:30Z","updated_at":"2017-04-13T17:25:11Z","closed_at":"2017-04-09T05:57:13Z","merged_at":"2017-04-09T05:57:13Z","merge_commit_sha":"1297646b93d773be26a92c2c8a08c2cf05ae6b44","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/p4lang/p4c/pulls/459/commits","review_comments_url":"https://api.github.com/repos/p4lang/p4c/pulls/459/comments","review_comment_url":"https://api.github.com/repos/p4lang/p4c/pulls/comments{/number}","comments_url":"https://api.github.com/repos/p4lang/p4c/issues/459/comments","statuses_url":"https://api.github.com/repos/p4lang/p4c/statuses/f39535a49c54fd92fafab92aceada9b62b2e0d7c","head":{"label":"hanw:psa","ref":"psa","sha":"f39535a49c54fd92fafab92aceada9b62b2e0d7c","user":{"login":"hanw","id":125978,"avatar_url":"https://avatars2.githubusercontent.com/u/125978?v=3","gravatar_id":"","url":"https://api.github.com/users/hanw","html_url":"https://github.com/hanw","followers_url":"https://api.github.com/users/hanw/followers","following_url":"https://api.github.com/users/hanw/following{/other_user}","gists_url":"https://api.github.com/users/hanw/gists{/gist_id}","starred_url":"https://api.github.com/users/hanw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hanw/subscriptions","organizations_url":"https://api.github.com/users/hanw/orgs","repos_url":"https://api.github.com/users/hanw/repos","events_url":"https://api.github.com/users/hanw/events{/privacy}","received_events_url":"https://api.github.com/users/hanw/received_events","type":"User","site_admin":false},"repo":{"id":67609693,"name":"p4c","full_name":"hanw/p4c","owner":{"login":"hanw","id":125978,"avatar_url":"https://avatars2.githubusercontent.com/u/125978?v=3","gravatar_id":"","url":"https://api.github.com/users/hanw","html_url":"https://github.com/hanw","followers_url":"https://api.github.com/users/hanw/followers","following_url":"https://api.github.com/users/hanw/following{/other_user}","gists_url":"https://api.github.com/users/hanw/gists{/gist_id}","starred_url":"https://api.github.com/users/hanw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hanw/subscriptions","organizations_url":"https://api.github.com/users/hanw/orgs","repos_url":"https://api.github.com/users/hanw/repos","events_url":"https://api.github.com/users/hanw/events{/privacy}","received_events_url":"https://api.github.com/users/hanw/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hanw/p4c","description":"P4-16 prototype compiler","fork":true,"url":"https://api.github.com/repos/hanw/p4c","forks_url":"https://api.github.com/repos/hanw/p4c/forks","keys_url":"https://api.github.com/repos/hanw/p4c/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hanw/p4c/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hanw/p4c/teams","hooks_url":"https://api.github.com/repos/hanw/p4c/hooks","issue_events_url":"https://api.github.com/repos/hanw/p4c/issues/events{/number}","events_url":"https://api.github.com/repos/hanw/p4c/events","assignees_url":"https://api.github.com/repos/hanw/p4c/assignees{/user}","branches_url":"https://api.github.com/repos/hanw/p4c/branches{/branch}","tags_url":"https://api.github.com/repos/hanw/p4c/tags","blobs_url":"https://api.github.com/repos/hanw/p4c/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hanw/p4c/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hanw/p4c/git/refs{/sha}","trees_url":"https://api.github.com/repos/hanw/p4c/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hanw/p4c/statuses/{sha}","languages_url":"https://api.github.com/repos/hanw/p4c/languages","stargazers_url":"https://api.github.com/repos/hanw/p4c/stargazers","contributors_url":"https://api.github.com/repos/hanw/p4c/contributors","subscribers_url":"https://api.github.com/repos/hanw/p4c/subscribers","subscription_url":"https://api.github.com/repos/hanw/p4c/subscription","commits_url":"https://api.github.com/repos/hanw/p4c/commits{/sha}","git_commits_url":"https://api.github.com/repos/hanw/p4c/git/commits{/sha}","comments_url":"https://api.github.com/repos/hanw/p4c/comments{/number}","issue_comment_url":"https://api.github.com/repos/hanw/p4c/issues/comments{/number}","contents_url":"https://api.github.com/repos/hanw/p4c/contents/{+path}","compare_url":"https://api.github.com/repos/hanw/p4c/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hanw/p4c/merges","archive_url":"https://api.github.com/repos/hanw/p4c/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hanw/p4c/downloads","issues_url":"https://api.github.com/repos/hanw/p4c/issues{/number}","pulls_url":"https://api.github.com/repos/hanw/p4c/pulls{/number}","milestones_url":"https://api.github.com/repos/hanw/p4c/milestones{/number}","notifications_url":"https://api.github.com/repos/hanw/p4c/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hanw/p4c/labels{/name}","releases_url":"https://api.github.com/repos/hanw/p4c/releases{/id}","deployments_url":"https://api.github.com/repos/hanw/p4c/deployments","created_at":"2016-09-07T13:36:25Z","updated_at":"2017-02-23T22:19:47Z","pushed_at":"2017-04-13T10:24:50Z","git_url":"git://github.com/hanw/p4c.git","ssh_url":"git@github.com:hanw/p4c.git","clone_url":"https://github.com/hanw/p4c.git","svn_url":"https://github.com/hanw/p4c","homepage":"","size":20990,"stargazers_count":0,"watchers_count":0,"language":"P4","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"p4lang:master","ref":"master","sha":"bbf177cd8ce583840589f4dd0d8ef7d756c4f112","user":{"login":"p4lang","id":10765181,"avatar_url":"https://avatars2.githubusercontent.com/u/10765181?v=3","gravatar_id":"","url":"https://api.github.com/users/p4lang","html_url":"https://github.com/p4lang","followers_url":"https://api.github.com/users/p4lang/followers","following_url":"https://api.github.com/users/p4lang/following{/other_user}","gists_url":"https://api.github.com/users/p4lang/gists{/gist_id}","starred_url":"https://api.github.com/users/p4lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/p4lang/subscriptions","organizations_url":"https://api.github.com/users/p4lang/orgs","repos_url":"https://api.github.com/users/p4lang/repos","events_url":"https://api.github.com/users/p4lang/events{/privacy}","received_events_url":"https://api.github.com/users/p4lang/received_events","type":"Organization","site_admin":false},"repo":{"id":55433859,"name":"p4c","full_name":"p4lang/p4c","owner":{"login":"p4lang","id":10765181,"avatar_url":"https://avatars2.githubusercontent.com/u/10765181?v=3","gravatar_id":"","url":"https://api.github.com/users/p4lang","html_url":"https://github.com/p4lang","followers_url":"https://api.github.com/users/p4lang/followers","following_url":"https://api.github.com/users/p4lang/following{/other_user}","gists_url":"https://api.github.com/users/p4lang/gists{/gist_id}","starred_url":"https://api.github.com/users/p4lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/p4lang/subscriptions","organizations_url":"https://api.github.com/users/p4lang/orgs","repos_url":"https://api.github.com/users/p4lang/repos","events_url":"https://api.github.com/users/p4lang/events{/privacy}","received_events_url":"https://api.github.com/users/p4lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/p4lang/p4c","description":"P4_16 prototype compiler","fork":false,"url":"https://api.github.com/repos/p4lang/p4c","forks_url":"https://api.github.com/repos/p4lang/p4c/forks","keys_url":"https://api.github.com/repos/p4lang/p4c/keys{/key_id}","collaborators_url":"https://api.github.com/repos/p4lang/p4c/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/p4lang/p4c/teams","hooks_url":"https://api.github.com/repos/p4lang/p4c/hooks","issue_events_url":"https://api.github.com/repos/p4lang/p4c/issues/events{/number}","events_url":"https://api.github.com/repos/p4lang/p4c/events","assignees_url":"https://api.github.com/repos/p4lang/p4c/assignees{/user}","branches_url":"https://api.github.com/repos/p4lang/p4c/branches{/branch}","tags_url":"https://api.github.com/repos/p4lang/p4c/tags","blobs_url":"https://api.github.com/repos/p4lang/p4c/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/p4lang/p4c/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/p4lang/p4c/git/refs{/sha}","trees_url":"https://api.github.com/repos/p4lang/p4c/git/trees{/sha}","statuses_url":"https://api.github.com/repos/p4lang/p4c/statuses/{sha}","languages_url":"https://api.github.com/repos/p4lang/p4c/languages","stargazers_url":"https://api.github.com/repos/p4lang/p4c/stargazers","contributors_url":"https://api.github.com/repos/p4lang/p4c/contributors","subscribers_url":"https://api.github.com/repos/p4lang/p4c/subscribers","subscription_url":"https://api.github.com/repos/p4lang/p4c/subscription","commits_url":"https://api.github.com/repos/p4lang/p4c/commits{/sha}","git_commits_url":"https://api.github.com/repos/p4lang/p4c/git/commits{/sha}","comments_url":"https://api.github.com/repos/p4lang/p4c/comments{/number}","issue_comment_url":"https://api.github.com/repos/p4lang/p4c/issues/comments{/number}","contents_url":"https://api.github.com/repos/p4lang/p4c/contents/{+path}","compare_url":"https://api.github.com/repos/p4lang/p4c/compare/{base}...{head}","merges_url":"https://api.github.com/repos/p4lang/p4c/merges","archive_url":"https://api.github.com/repos/p4lang/p4c/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/p4lang/p4c/downloads","issues_url":"https://api.github.com/repos/p4lang/p4c/issues{/number}","pulls_url":"https://api.github.com/repos/p4lang/p4c/pulls{/number}","milestones_url":"https://api.github.com/repos/p4lang/p4c/milestones{/number}","notifications_url":"https://api.github.com/repos/p4lang/p4c/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/p4lang/p4c/labels{/name}","releases_url":"https://api.github.com/repos/p4lang/p4c/releases{/id}","deployments_url":"https://api.github.com/repos/p4lang/p4c/deployments","created_at":"2016-04-04T18:12:32Z","updated_at":"2017-04-07T12:33:00Z","pushed_at":"2017-04-13T06:32:37Z","git_url":"git://github.com/p4lang/p4c.git","ssh_url":"git@github.com:p4lang/p4c.git","clone_url":"https://github.com/p4lang/p4c.git","svn_url":"https://github.com/p4lang/p4c","homepage":"","size":55338,"stargazers_count":18,"watchers_count":18,"language":"P4","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":21,"mirror_url":null,"open_issues_count":47,"forks":21,"open_issues":47,"watchers":18,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/p4lang/p4c/pulls/459"},"html":{"href":"https://github.com/p4lang/p4c/pull/459"},"issue":{"href":"https://api.github.com/repos/p4lang/p4c/issues/459"},"comments":{"href":"https://api.github.com/repos/p4lang/p4c/issues/459/comments"},"review_comments":{"href":"https://api.github.com/repos/p4lang/p4c/pulls/459/comments"},"review_comment":{"href":"https://api.github.com/repos/p4lang/p4c/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/p4lang/p4c/pulls/459/commits"},"statuses":{"href":"https://api.github.com/repos/p4lang/p4c/statuses/f39535a49c54fd92fafab92aceada9b62b2e0d7c"}}}}
{"actor":{"display_login":"ChrisDodd"}}