moneroexamples / compile-cpp-ethereum-on-arch

Compile cpp-ethereum on Arch Linux
5 stars 2 forks source link

Solidity compilation error #2

Open kusayuzayushko opened 7 years ago

kusayuzayushko commented 7 years ago
/home/kusayu/solidity/libsolidity/codegen/CompilerUtils.cpp: In member function ‘void dev::solidity::CompilerUtils::convertType(const dev::solidity::Type&, const dev::solidity::Type&, bool, bool)’:
/home/kusayu/solidity/libsolidity/codegen/CompilerUtils.cpp:784:3: error: this statement may fall through [-Werror=implicit-fallthrough=]
   }
   ^
/home/kusayu/solidity/libsolidity/codegen/CompilerUtils.cpp:786:2: note: here
  default:
  ^~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [libsolidity/CMakeFiles/solidity.dir/build.make:543: libsolidity/CMakeFiles/solidity.dir/codegen/CompilerUtils.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:275: libsolidity/CMakeFiles/solidity.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

Any ideas how to fix it?

moneroexamples commented 7 years ago

New gcc seem not to allow switch cases to fall through.

A possible fix could be adding __attribute__((fallthrough)); to the switch statements that it happens. This happens in two files:

  1. ~/solidity/libsolidity/codegen/CompilerUtils.cpp

In line 784 add: __attribute__((fallthrough));, so this should look like:

            // stack: <address> <function_id>
            m_context << Instruction::POP;
            break;
        }
        __attribute__((fallthrough)); // <- this is added
    }
    default:
  1. ~/solidity/libsolidity/codegen/ExpressionCompiler.cpp

In line 1046 add: __attribute__((fallthrough));, so this should look like:

                // not found in contract, search in members inherited from address
                alsoSearchInteger = true;
        }
        if (!alsoSearchInteger)
            break;
        __attribute__((fallthrough)); // <- this is added
    }
    case Type::Category::Integer:

I will make issue on solidity shortly.

Hope this helps.