Skip to content

Commit e866ca1

Browse files
committed
Fix build error.
Add static to getModel() and constexpr to template specializations.
1 parent 421180e commit e866ca1

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

flang/include/flang/Optimizer/CodeGen/DescriptorModel.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,73 +35,73 @@ using TypeBuilderFunc = mlir::Type (*)(mlir::MLIRContext *);
3535

3636
/// Get the LLVM IR dialect model for building a particular C++ type, `T`.
3737
template <typename T>
38-
TypeBuilderFunc getModel();
38+
static TypeBuilderFunc getModel();
3939

4040
template <>
41-
TypeBuilderFunc getModel<void *>() {
41+
constexpr TypeBuilderFunc getModel<void *>() {
4242
return [](mlir::MLIRContext *context) -> mlir::Type {
4343
return mlir::LLVM::LLVMPointerType::get(context);
4444
};
4545
}
4646
template <>
47-
TypeBuilderFunc getModel<unsigned>() {
47+
constexpr TypeBuilderFunc getModel<unsigned>() {
4848
return [](mlir::MLIRContext *context) -> mlir::Type {
4949
return mlir::IntegerType::get(context, sizeof(unsigned) * 8);
5050
};
5151
}
5252
template <>
53-
TypeBuilderFunc getModel<int>() {
53+
constexpr TypeBuilderFunc getModel<int>() {
5454
return [](mlir::MLIRContext *context) -> mlir::Type {
5555
return mlir::IntegerType::get(context, sizeof(int) * 8);
5656
};
5757
}
5858
template <>
59-
TypeBuilderFunc getModel<unsigned long>() {
59+
constexpr TypeBuilderFunc getModel<unsigned long>() {
6060
return [](mlir::MLIRContext *context) -> mlir::Type {
6161
return mlir::IntegerType::get(context, sizeof(unsigned long) * 8);
6262
};
6363
}
6464
template <>
65-
TypeBuilderFunc getModel<unsigned long long>() {
65+
constexpr TypeBuilderFunc getModel<unsigned long long>() {
6666
return [](mlir::MLIRContext *context) -> mlir::Type {
6767
return mlir::IntegerType::get(context, sizeof(unsigned long long) * 8);
6868
};
6969
}
7070
template <>
71-
TypeBuilderFunc getModel<long long>() {
71+
constexpr TypeBuilderFunc getModel<long long>() {
7272
return [](mlir::MLIRContext *context) -> mlir::Type {
7373
return mlir::IntegerType::get(context, sizeof(long long) * 8);
7474
};
7575
}
7676
template <>
77-
TypeBuilderFunc getModel<Fortran::ISO::CFI_rank_t>() {
77+
constexpr TypeBuilderFunc getModel<Fortran::ISO::CFI_rank_t>() {
7878
return [](mlir::MLIRContext *context) -> mlir::Type {
7979
return mlir::IntegerType::get(context,
8080
sizeof(Fortran::ISO::CFI_rank_t) * 8);
8181
};
8282
}
8383
template <>
84-
TypeBuilderFunc getModel<Fortran::ISO::CFI_type_t>() {
84+
constexpr TypeBuilderFunc getModel<Fortran::ISO::CFI_type_t>() {
8585
return [](mlir::MLIRContext *context) -> mlir::Type {
8686
return mlir::IntegerType::get(context,
8787
sizeof(Fortran::ISO::CFI_type_t) * 8);
8888
};
8989
}
9090
template <>
91-
TypeBuilderFunc getModel<long>() {
91+
constexpr TypeBuilderFunc getModel<long>() {
9292
return [](mlir::MLIRContext *context) -> mlir::Type {
9393
return mlir::IntegerType::get(context, sizeof(long) * 8);
9494
};
9595
}
9696
template <>
97-
TypeBuilderFunc getModel<Fortran::ISO::CFI_dim_t>() {
97+
constexpr TypeBuilderFunc getModel<Fortran::ISO::CFI_dim_t>() {
9898
return [](mlir::MLIRContext *context) -> mlir::Type {
9999
auto indexTy = getModel<Fortran::ISO::CFI_index_t>()(context);
100100
return mlir::LLVM::LLVMArrayType::get(indexTy, 3);
101101
};
102102
}
103103
template <>
104-
TypeBuilderFunc
104+
constexpr TypeBuilderFunc
105105
getModel<Fortran::ISO::cfi_internal::FlexibleArray<Fortran::ISO::CFI_dim_t>>() {
106106
return getModel<Fortran::ISO::CFI_dim_t>();
107107
}

0 commit comments

Comments
 (0)