Skip to content

Commit 6a19012

Browse files
committed
Clean up UNUSED() macro
1. Use [[maybe_unused]] C++17 attribute instead of GCC/Clang __attribute__((unused)) The attribute should appear immediately AFTER the name of the parameter, before any array dimensions (this should fix ARM build issue where old-style __attribute__((unused)) worked after an array dimension but [[maybe_unused]] did not work). The UNUSED() macro is almost always called with only the name of the function parameter, without any type information, so the [[maybe_unused]] attribute cannot be placed BEFORE the macro argument, where it would be ignored as not applying to the immediately preceding type. For it to appear BEFORE the parameter name, it would need to appear before the type as well, and then all of the calls to UNUSED() would need to be modified to look something like: UNUSED(const std::string& name) instead of: const std::string& UNUSED(name) Although cppreference.com is scant on details, my research has found that attributes applying to specific identifiers must appear immediately AFTER the name. The old __attribute__((unused)) GCC/Clang attribute appeared after the name, and so does [[maybe_unused]] with this change. 2. Remove UNUSED() macro used in function declarations which are not definitions, since the compiler does not check whether function parameters are actually used in declarations, only in definitions. 3. Remove UNUSED() macro that is used where the parameter is not unused anymore.
1 parent 8cce3d5 commit 6a19012

File tree

7 files changed

+9
-9
lines changed

7 files changed

+9
-9
lines changed

src/sst/core/eli/categoryInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ProvidesCategory
4242
}
4343
}
4444

45-
void toString(std::ostream& UNUSED(os)) const { os << " Category: " << categoryName(cat_) << "\n"; }
45+
void toString(std::ostream& os) const { os << " Category: " << categoryName(cat_) << "\n"; }
4646

4747
template <class XMLNode>
4848
void outputXML(XMLNode* UNUSED(node))

src/sst/core/impl/interactive/simpleDebug.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ class SimpleDebugger : public SST::InteractiveConsole
6363
6464
std::vector<std::string> tokenize(std::vector<std::string>& tokens, const std::string& input);
6565
66-
void cmd_pwd(std::vector<std::string>& UNUSED(tokens));
67-
void cmd_ls(std::vector<std::string>& UNUSED(tokens));
66+
void cmd_pwd(std::vector<std::string>& tokens);
67+
void cmd_ls(std::vector<std::string>& tokens);
6868
void cmd_cd(std::vector<std::string>& tokens);
6969
void cmd_print(std::vector<std::string>& tokens);
7070
void cmd_set(std::vector<std::string>& tokens);

src/sst/core/interfaces/stdMem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ class StandardMem : public SubComponent
931931
virtual std::string getString() = 0; /* String representation for debug/output/etc. */
932932

933933
/* This needs to be serializable so that we can use it in events in parallel simulations */
934-
virtual void serialize_order(SST::Core::Serialization::serializer& UNUSED(ser)) override = 0;
934+
virtual void serialize_order(SST::Core::Serialization::serializer& ser) override = 0;
935935
// ImplementSerializable(SST::Interfaces::StandardMem::CustomData);
936936
ImplementVirtualSerializable(CustomData);
937937
};

src/sst/core/profile/eventHandlerProfileTool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class EventHandlerProfileToolCount : public EventHandlerProfileTool
9595
uintptr_t registerLinkAttachTool(const AttachPointMetaData& mdata) override;
9696

9797
void beforeHandler(uintptr_t key, const SST::Event* event) override;
98-
void eventSent(uintptr_t UNUSED(key), Event*& UNUSED(ev)) override;
98+
void eventSent(uintptr_t key, Event*& ev) override;
9999

100100
void outputData(FILE* fp) override;
101101

src/sst/core/shared/sharedObject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class SharedObjectChangeSet : public SST::Core::Serialization::serializable
5454
@param manager The SharedObjectDataManager for the rank. This
5555
is used to get the named shared data.
5656
*/
57-
virtual void applyChanges(SharedObjectDataManager* UNUSED(manager)) = 0;
57+
virtual void applyChanges(SharedObjectDataManager* manager) = 0;
5858

5959
/**
6060
Clears the data. Used after transfering data to other ranks to

src/sst/core/sstinfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@ class SSTInfoConfig : public ConfigShared
124124
return 0;
125125
}
126126

127-
int setXMLOutput(const std::string& UNUSED(arg))
127+
int setXMLOutput(const std::string& arg)
128128
{
129129
m_XMLFilePath = arg;
130130
return 0;
131131
}
132132

133-
int setLibs(const std::string& UNUSED(arg))
133+
int setLibs(const std::string& arg)
134134
{
135135
addFilter(arg);
136136
return 0;

src/sst/core/warnmacros.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#ifndef SST_CORE_WARNMACROS_H
1515
#define SST_CORE_WARNMACROS_H
1616

17-
#define UNUSED(x) x __attribute__((unused))
17+
#define UNUSED(x) x [[maybe_unused]]
1818

1919
#define DIAG_STR(s) #s
2020
#define DIAG_JOINSTR(x, y) DIAG_STR(x##y)

0 commit comments

Comments
 (0)