[Beignet] [PATCH 1/2] fix newer gcc warning "variable set but not used".
Yang, Rong R
rong.r.yang at intel.com
Mon May 18 21:39:34 PDT 2015
Do clang and icc also support __attribute__ ((unused))?
If not support, maybe could use IF_DEBUG macro to define the debug only variables.
> -----Original Message-----
> From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of
> xionghu.luo at intel.com
> Sent: Thursday, May 7, 2015 09:47
> To: beignet at lists.freedesktop.org
> Cc: Luo, Xionghu
> Subject: [Beignet] [PATCH 1/2] fix newer gcc warning "variable set but not
> used".
>
> From: Luo Xionghu <xionghu.luo at intel.com>
>
> this warning appeared in gcc 4.9.1, declear the variables with attribute
> ((unused)).
>
> Signed-off-by: Luo Xionghu <xionghu.luo at intel.com>
> ---
> backend/src/backend/program.cpp | 3 ++-
> backend/src/llvm/ExpandLargeIntegers.cpp | 3 ++-
> backend/src/llvm/llvm_bitcode_link.cpp | 3 ++-
> backend/src/llvm/llvm_printf_parser.cpp | 1 -
> 4 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/backend/src/backend/program.cpp
> b/backend/src/backend/program.cpp index eee7c3c..9e0bc66 100644
> --- a/backend/src/backend/program.cpp
> +++ b/backend/src/backend/program.cpp
> @@ -655,7 +655,8 @@ namespace gbe {
> std::string hdirs = OCL_HEADER_FILE_DIR;
> std::istringstream hidirs(hdirs);
> std::string headerFilePath;
> - bool findOcl = false;
> + bool findOcl __attribute__ ((unused));
> + findOcl = false;
>
> while (getline(hidirs, headerFilePath, ':')) {
> std::string oclDotHName = headerFilePath + "/ocl.h"; diff --git
> a/backend/src/llvm/ExpandLargeIntegers.cpp
> b/backend/src/llvm/ExpandLargeIntegers.cpp
> index f7e59a5..d7440aa 100644
> --- a/backend/src/llvm/ExpandLargeIntegers.cpp
> +++ b/backend/src/llvm/ExpandLargeIntegers.cpp
> @@ -442,7 +442,8 @@ static void convertInstruction(Instruction *Inst,
> ConversionState &State,
> } else if (TruncInst *Trunc = dyn_cast<TruncInst>(Inst)) {
> Value *Operand = Trunc->getOperand(0);
> assert(shouldConvert(Operand) && "TruncInst is expandable but not its
> op");
> - TypePair OpTys = getExpandedIntTypes(Operand->getType());
> + TypePair OpTys __attribute__ ((unused));
> + OpTys = getExpandedIntTypes(Operand->getType());
> ValuePair Ops = State.getConverted(Operand);
> if (!shouldConvert(Inst)) {
> Value *NewInst = IRB.CreateTrunc(Ops.Lo, Trunc->getType(), Name); diff
> --git a/backend/src/llvm/llvm_bitcode_link.cpp
> b/backend/src/llvm/llvm_bitcode_link.cpp
> index ebf4386..c9824e7 100644
> --- a/backend/src/llvm/llvm_bitcode_link.cpp
> +++ b/backend/src/llvm/llvm_bitcode_link.cpp
> @@ -51,7 +51,8 @@ namespace gbe
> std::string bitCodeFiles = OCL_BITCODE_LIB_PATH;
> std::istringstream bitCodeFilePath(bitCodeFiles);
> std::string FilePath;
> - bool findBC = false;
> + bool findBC __attribute__ ((unused));
> + findBC = false;
> Module* oclLib = NULL;
> SMDiagnostic Err;
>
> diff --git a/backend/src/llvm/llvm_printf_parser.cpp
> b/backend/src/llvm/llvm_printf_parser.cpp
> index 2f85443..712c478 100644
> --- a/backend/src/llvm/llvm_printf_parser.cpp
> +++ b/backend/src/llvm/llvm_printf_parser.cpp
> @@ -503,7 +503,6 @@ error:
> info.printf_fmt = printf_fmt;
>
> sizeof_size = 0;
> - int i = 1;
> for (auto &s : (*printf_fmt).first) {
> int sz = 0;
> if (s.type == PRINTF_SLOT_TYPE_STRING)
> --
> 2.1.0
>
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list