Skip to content

Commit

Permalink
[flang] Assert the Options fit into the storage bits (llvm#126169)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmayer authored and sivan-shani committed Feb 21, 2025
1 parent 797ebf0 commit 7e392bb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion flang/include/flang/Support/LangOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ class LangOptions : public LangOptionsBase {
#define LANGOPT(Name, Bits, Default)
#define ENUM_LANGOPT(Name, Type, Bits, Default) \
Type get##Name() const { return static_cast<Type>(Name); } \
void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
void set##Name(Type Value) { \
assert(static_cast<unsigned>(Value) < (1u << Bits)); \
Name = static_cast<unsigned>(Value); \
}
#include "LangOptions.def"

/// Name of the IR file that contains the result of the OpenMP target
Expand Down

0 comments on commit 7e392bb

Please sign in to comment.