8195691: AIX build broken after 8194312
authormdoerr
Mon, 22 Jan 2018 12:04:12 +0100 (2018-01-22)
changeset 48806 51fc22e5fb00
parent 48805 decc1bb41107
child 48807 fd8ccb37fce9
8195691: AIX build broken after 8194312 Reviewed-by: kbarrett, goetz
src/hotspot/share/gc/shared/oopStorage.hpp
test/hotspot/gtest/gc/shared/test_oopStorage.cpp
--- a/src/hotspot/share/gc/shared/oopStorage.hpp	Tue Jan 23 08:18:36 2018 -0800
+++ b/src/hotspot/share/gc/shared/oopStorage.hpp	Mon Jan 22 12:04:12 2018 +0100
@@ -171,9 +171,15 @@
   void print_on(outputStream* st) const PRODUCT_RETURN;
 
   // Provides access to storage internals, for unit testing.
+  // Declare, but not define, the public class OopStorage::TestAccess.
+  // That class is defined as part of the unit-test. It "exports" the needed
+  // private types by providing public typedefs for them.
   class TestAccess;
 
-private:
+  // xlC on AIX can't compile test_oopStorage.cpp with following private
+  // classes. C++03 introduced access for nested classes with DR45, but xlC
+  // version 12 rejects it.
+NOT_AIX( private: )
   class Block;
   class BlockList;
 
@@ -279,6 +285,7 @@
     template<typename F> bool iterate(F f) const;
   }; // class Block
 
+private:
   const char* _name;
   BlockList _active_list;
   BlockList _allocate_list;
--- a/test/hotspot/gtest/gc/shared/test_oopStorage.cpp	Tue Jan 23 08:18:36 2018 -0800
+++ b/test/hotspot/gtest/gc/shared/test_oopStorage.cpp	Mon Jan 22 12:04:12 2018 +0100
@@ -101,6 +101,9 @@
 // --- FIXME: Similarly, this typedef collides with opto BlockList.
 // typedef TestAccess::BlockList BlockList;
 
+// Using EXPECT_EQ can't use NULL directly. Otherwise AIX build breaks.
+const OopBlock* const NULL_BLOCK = NULL;
+
 static size_t list_length(const TestAccess::BlockList& list) {
   size_t result = 0;
   for (const OopBlock* block = list.chead();
@@ -1196,9 +1199,9 @@
   TestAccess::BlockList list(&OopBlock::get_active_entry);
 
   EXPECT_TRUE(is_list_empty(list));
-  EXPECT_EQ(NULL, list.head());
-  EXPECT_EQ(NULL, list.chead());
-  EXPECT_EQ(NULL, list.ctail());
+  EXPECT_EQ(NULL_BLOCK, list.head());
+  EXPECT_EQ(NULL_BLOCK, list.chead());
+  EXPECT_EQ(NULL_BLOCK, list.ctail());
 }
 
 TEST_F(OopStorageBlockListTest, push_back) {
@@ -1219,14 +1222,14 @@
     EXPECT_EQ(block, values[i]);
     block = list.next(*block);
   }
-  EXPECT_EQ(NULL, block);
+  EXPECT_EQ(NULL_BLOCK, block);
 
   block = list.ctail();
   for (size_t i = 0; i < nvalues; ++i) {
     EXPECT_EQ(block, values[nvalues - i - 1]);
     block = list.prev(*block);
   }
-  EXPECT_EQ(NULL, block);
+  EXPECT_EQ(NULL_BLOCK, block);
 
   clear_list(list);
 }
@@ -1249,14 +1252,14 @@
     EXPECT_EQ(block, values[nvalues - i - 1]);
     block = list.next(*block);
   }
-  EXPECT_EQ(NULL, block);
+  EXPECT_EQ(NULL_BLOCK, block);
 
   block = list.ctail();
   for (size_t i = 0; i < nvalues; ++i) {
     EXPECT_EQ(block, values[i]);
     block = list.prev(*block);
   }
-  EXPECT_EQ(NULL, block);
+  EXPECT_EQ(NULL_BLOCK, block);
 
   clear_list(list);
 }
@@ -1281,8 +1284,8 @@
   EXPECT_EQ(list.ctail(), values[nvalues - 1]);
 
   list.unlink(*values[0]);
-  EXPECT_EQ(NULL, list.next(*values[0]));
-  EXPECT_EQ(NULL, list.prev(*values[0]));
+  EXPECT_EQ(NULL_BLOCK, list.next(*values[0]));
+  EXPECT_EQ(NULL_BLOCK, list.prev(*values[0]));
   EXPECT_EQ(list.chead(), values[1]);
   EXPECT_EQ(list.ctail(), values[nvalues - 1]);
 
@@ -1291,15 +1294,15 @@
     EXPECT_EQ(block, values[i]);
     block = list.next(*block);
   }
-  EXPECT_EQ(NULL, block);
+  EXPECT_EQ(NULL_BLOCK, block);
 }
 
 TEST_F(OopStorageBlockListTestWithList, unlink_back) {
   EXPECT_EQ(list.chead(), values[0]);
 
   list.unlink(*values[nvalues - 1]);
-  EXPECT_EQ(NULL, list.next(*values[nvalues - 1]));
-  EXPECT_EQ(NULL, list.prev(*values[nvalues - 1]));
+  EXPECT_EQ(NULL_BLOCK, list.next(*values[nvalues - 1]));
+  EXPECT_EQ(NULL_BLOCK, list.prev(*values[nvalues - 1]));
   EXPECT_EQ(list.chead(), values[0]);
   EXPECT_EQ(list.ctail(), values[nvalues - 2]);
 
@@ -1308,7 +1311,7 @@
     EXPECT_EQ(block, values[i]);
     block = list.next(*block);
   }
-  EXPECT_EQ(NULL, block);
+  EXPECT_EQ(NULL_BLOCK, block);
 }
 
 TEST_F(OopStorageBlockListTestWithList, unlink_middle) {
@@ -1317,8 +1320,8 @@
   size_t index = nvalues / 2;
 
   list.unlink(*values[index]);
-  EXPECT_EQ(NULL, list.next(*values[index]));
-  EXPECT_EQ(NULL, list.prev(*values[index]));
+  EXPECT_EQ(NULL_BLOCK, list.next(*values[index]));
+  EXPECT_EQ(NULL_BLOCK, list.prev(*values[index]));
   EXPECT_EQ(list.chead(), values[0]);
   EXPECT_EQ(list.ctail(), values[nvalues - 1]);
 
@@ -1331,23 +1334,23 @@
     EXPECT_EQ(block, values[i]);
     block = list.next(*block);
   }
-  EXPECT_EQ(NULL, block);
+  EXPECT_EQ(NULL_BLOCK, block);
 }
 
 TEST_F(OopStorageBlockListTest, single) {
   TestAccess::BlockList list(&OopBlock::get_active_entry);
 
   list.push_back(*values[0]);
-  EXPECT_EQ(NULL, list.next(*values[0]));
-  EXPECT_EQ(NULL, list.prev(*values[0]));
+  EXPECT_EQ(NULL_BLOCK, list.next(*values[0]));
+  EXPECT_EQ(NULL_BLOCK, list.prev(*values[0]));
   EXPECT_EQ(list.chead(), values[0]);
   EXPECT_EQ(list.ctail(), values[0]);
 
   list.unlink(*values[0]);
-  EXPECT_EQ(NULL, list.next(*values[0]));
-  EXPECT_EQ(NULL, list.prev(*values[0]));
-  EXPECT_EQ(NULL, list.chead());
-  EXPECT_EQ(NULL, list.ctail());
+  EXPECT_EQ(NULL_BLOCK, list.next(*values[0]));
+  EXPECT_EQ(NULL_BLOCK, list.prev(*values[0]));
+  EXPECT_EQ(NULL_BLOCK, list.chead());
+  EXPECT_EQ(NULL_BLOCK, list.ctail());
 }
 
 TEST_F(OopStorageBlockListTestWithList, two_lists) {
@@ -1363,8 +1366,8 @@
     active_block = list.next(*active_block);
     allocate_block = list2.prev(*allocate_block);
   }
-  EXPECT_EQ(NULL, active_block);
-  EXPECT_EQ(NULL, allocate_block);
+  EXPECT_EQ(NULL_BLOCK, active_block);
+  EXPECT_EQ(NULL_BLOCK, allocate_block);
 
   for (size_t i = 0; i < nvalues; ++i) {
     list2.unlink(*values[i]);
@@ -1376,6 +1379,6 @@
     EXPECT_EQ(active_block, values[i]);
     active_block = list.next(*active_block);
   }
-  EXPECT_EQ(NULL, active_block);
+  EXPECT_EQ(NULL_BLOCK, active_block);
 }