Commit Graph

1037 Commits

Author SHA1 Message Date
wechman
2e8d50eca2 User-defined operators: Documentation 2023-02-22 00:39:25 +01:00
wechman
5b03c13f90 User-defined operators: Analysis 2023-02-22 00:39:25 +01:00
wechman
9a36438441 User-defined operators: AST 2023-02-22 00:06:17 +01:00
Peter Lemenkov
603f9f7208 Type recognition workaround for some GCC compilers
Looks like somewhat old GCC compilers, namely 12.2.1, cannot recognize a
string literal sometimes. Let's help it to avoid error logs like this
one:

```
[ 75%] Building CXX object libsolidity/CMakeFiles/solidity.dir/codegen/ir/IRGeneratorForStatements.cpp.o
cd /builddir/build/BUILD/solidity-0.8.18/redhat-linux-build/libsolidity && /usr/bin/g++ -DBOOST_ATOMIC_DYN_LINK -DBOOST_ATOMIC_NO_LIB -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_FILESYSTEM_NO_LIB -DBOOST_SYSTEM_DYN_LINK -DBOOST_SYSTEM_NO_LIB -DFMT_HEADER_ONLY=1 -DHAVE_CVC4 -DHAVE_Z3 -I/builddir/build/BUILD/solidity-0.8.18/redhat-linux-build/include -I/builddir/build/BUILD/solidity-0.8.18 -isystem /usr/include/z3 -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64  -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fuse-ld=gold -O3 -DNDEBUG -fstack-protector-strong -Wimplicit-fallthrough -fmacro-prefix-map=/builddir/build/BUILD/solidity-0.8.18=/solidity -Wpessimizing-move -Wredundant-move -Wall -Wextra -Werror -pedantic -Wmissing-declarations -Wno-unknown-pragmas -Wsign-conversion -Wconversion -Wextra-semi -Wduplicated-cond -Wlogical-op -fdiagnostics-color -std=c++17 -MD -MT libsolidity/CMakeFiles/solidity.dir/codegen/ir/IRGeneratorForStatements.cpp.o -MF CMakeFiles/solidity.dir/codegen/ir/IRGeneratorForStatements.cpp.o.d -o CMakeFiles/solidity.dir/codegen/ir/IRGeneratorForStatements.cpp.o -c /builddir/build/BUILD/solidity-0.8.18/libsolidity/codegen/ir/IRGeneratorForStatements.cpp
In file included from /usr/include/c++/12/string:40,
                 from /builddir/build/BUILD/solidity-0.8.18/libsolidity/ast/ASTForward.h:27,
                 from /builddir/build/BUILD/solidity-0.8.18/libsolidity/ast/AST.h:26,
                 from /builddir/build/BUILD/solidity-0.8.18/libsolidity/ast/ASTVisitor.h:26,
                 from /builddir/build/BUILD/solidity-0.8.18/libsolidity/codegen/ir/IRGeneratorForStatements.h:24,
                 from /builddir/build/BUILD/solidity-0.8.18/libsolidity/codegen/ir/IRGeneratorForStatements.cpp:22:
In function 'std::char_traits<char>::copy(char*, char const*, unsigned long)',
    inlined from 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy(char*, char const*, unsigned long)' at /usr/include/c++/12/bits/basic_string.h:423:21,
    inlined from 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace(unsigned long, unsigned long, char const*, unsigned long)' at /usr/include/c++/12/bits/basic_string.tcc:532:22,
    inlined from 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::assign(char const*)' at /usr/include/c++/12/bits/basic_string.h:1647:19,
    inlined from 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator=(char const*)' at /usr/include/c++/12/bits/basic_string.h:815:28,
    inlined from '(anonymous namespace)::CopyTranslate::translateReference(solidity::yul::Identifier const&)' at /builddir/build/BUILD/solidity-0.8.18/libsolidity/codegen/ir/IRGeneratorForStatements.cpp:182:13:
/usr/include/c++/12/bits/char_traits.h:431:56: error: 'memcpy' accessing 9223372036854775810 or more bytes at offsets -4611686018427387902 and [-4611686018427387903, 4611686018427387904] may overlap up to 9223372036854775813 bytes at offset -3 [-Werror=restrict]
  431 |         return static_cast<char_type*>(__builtin_memcpy(__s1, __s2, __n));
      |                                        ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
gmake[2]: *** [libsolidity/CMakeFiles/solidity.dir/build.make:695: libsolidity/CMakeFiles/solidity.dir/codegen/ir/IRGeneratorForStatements.cpp.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....
gmake[2]: Leaving directory '/builddir/build/BUILD/solidity-0.8.18/redhat-linux-build'
gmake[1]: *** [CMakeFiles/Makefile2:414: libsolidity/CMakeFiles/solidity.dir/all] Error 2
gmake[1]: Leaving directory '/builddir/build/BUILD/solidity-0.8.18/redhat-linux-build'
gmake: *** [Makefile:139: all] Error 2
```

Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
2023-02-08 17:51:56 +01:00
Peter Lemenkov
b3f35f703a libsolidity: Redundant std::move
This patch suppresses warnings like this one:

```
/builddir/build/BUILD/solidity-0.8.18/libsolidity/ast/AST.h: In constructor 'solidity::frontend::FunctionDefinition::FunctionDefinition(int64_t, const solidity::frontend::ASTNode::SourceLocation&, solidity::frontend::ASTPointer<std::__cxx11::basic_string<char> >&, const solidity::frontend::ASTNode::SourceLocation&, solidity::frontend::Visibility, solidity::frontend::StateMutability, bool, solidity::langutil::Token, bool, solidity::frontend::ASTPointer<solidity::frontend::OverrideSpecifier>&, solidity::frontend::ASTPointer<solidity::frontend::StructuredDocumentation>&, solidity::frontend::ASTPointer<solidity::frontend::ParameterList>&, std::vector<std::shared_ptr<solidity::frontend::ModifierInvocation> >, solidity::frontend::ASTPointer<solidity::frontend::ParameterList>&, solidity::frontend::ASTPointer<solidity::frontend::Block>&)':
/builddir/build/BUILD/solidity-0.8.18/libsolidity/ast/AST.h:926:69: error: redundant move in initialization [-Werror=redundant-move]
  926 |                 CallableDeclaration(_id, _location, _name, std::move(_nameLocation), _visibility, _parameters, _isVirtual, _overrides, _returnParameters),
      |                                                            ~~~~~~~~~^~~~~~~~~~~~~~~
/builddir/build/BUILD/solidity-0.8.18/libsolidity/ast/AST.h:926:69: note: remove 'std::move' call
```

Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
2023-02-05 12:06:19 +01:00
Rodrigo Q. Saramago
ef6ff2f055
Adds support for the EVM version "Paris".
Deprecates `block.difficulty` and disallow `difficulty()` in inline assembly for EVM versions >= paris.
The change is due to the renaming introduced by EIP-4399 (see: https://eips.ethereum.org/EIPS/eip-4399).
Introduces `block.prevrandao` in Solidity and `prevrandao()` in inline assembly for EVM versions >= paris.

Co-authored-by: Alex Beregszaszi <alex@rtfs.hu>
Co-authored-by: Daniel <daniel@ekpyron.org>
Co-authored-by: matheusaaguiar <95899911+matheusaaguiar@users.noreply.github.com>
Co-authored-by: Nikola Matić <nikola.matic@ethereum.org>
2023-01-23 18:50:36 +00:00
Nikola Matic
83c1f62026 Source location for named mapping keys 2023-01-17 12:25:23 +01:00
Daniel
f441e1323a
Merge pull request #13384 from zemse/develop
Allow named parameters in mapping types
2023-01-09 17:59:29 +01:00
Saw-mon-and-Natalie
e295964f50
fixed some comments in Types.h 2022-12-16 14:58:41 +00:00
Soham Zemse
fa78e0f3d4 feat: allow named parameters in mapping types
Co-authored-by: Hari <webmail.hari@gmail.com>

test: add parser and abi test cases

docs: add example on using named parameters for mappings

- Add changelog

feat: update antlr grammar to allow named parameters in mappings

fix: prevent conflicting mapping parameter names

ref: change order of mapping initializers

test: update expectations and fix build

test: add more tests

fix: use common error & code for conflicting params

fix: issue with accessing nested mapping

test: add conflicting params tests for more nested levels

Update libsolidity/analysis/DeclarationTypeChecker.cpp

Co-authored-by: Nikola Matić <nikola.matic@ethereum.org>

fix: error reported with the same code twice

test: add more tests for 3 level nested mapping

Address review comments
2022-12-08 11:56:58 +01:00
wechman
64a4f32bc2 Consistent terminology for attached/bound functions 2022-12-07 19:31:41 +01:00
chriseth
261e819df7 Type: Extract usingForDirectivesForType() helper 2022-11-23 14:22:49 +01:00
wechman
df1f5eef72 UsingForDirective: Rename m_functions to m_functionsOrLibrary 2022-11-07 23:58:19 +01:00
Alex Beregszaszi
725253551e Improve FunctionSelector helpers 2022-09-27 17:58:32 +02:00
Damian Wechman
6b99162457
Merge pull request #13406 from ethereum/slot_on_reference_fix
Fix `.slot` accessing via mapping reference in assembly
2022-09-05 14:00:18 +02:00
Leo
242096695f
Merge pull request #13428 from ethereum/qualify-move
Add std:: qualifier to move() calls
2022-08-30 11:57:54 +02:00
Marenz
f7cc29bec1 Add std:: qualifier to move() calls 2022-08-30 11:12:15 +02:00
tcoyvwac
3d54bfd0c3
ast: condense duplicate code
AST.cpp:
* Added findClause() helper function to anonymous namespace.
2022-08-25 14:45:22 +02:00
wechman
cf3bae0839 Fix "slot" access via mapping reference in assembly 2022-08-17 07:53:52 +02:00
Leonid Pospelov
4682c01920
Update ASTJsonExporter.cpp 2022-08-14 03:07:01 +03:00
Duc Thanh Nguyen
e0ba7ef0d3 Rename _short in toString to _withoutDataLocation 2022-07-06 10:49:58 -04:00
Duc Thanh Nguyen
0a14368315 Display human readable type name in conversion error message 2022-07-06 10:49:51 -04:00
Mathias L. Baumann
d4e2c2cc89
Merge pull request #13185 from ethereum/functionCall_locations
Add location for parameter names in FunctionCall ASTNode
2022-07-04 16:40:45 +02:00
Marenz
3a5218d3d5 Add location for parameter names in FunctionCall ASTNode 2022-06-29 18:37:36 +02:00
Marenz
ee710eadd4 Add location for member in MemberAccess ASTNode 2022-06-29 18:37:09 +02:00
Mathias L. Baumann
2397f09b79
Merge pull request #13182 from ethereum/identifierPath_declarations
Add all path declarations in IdentifierPath annotation
2022-06-27 12:35:50 +02:00
Marenz
5d2e134378 Add all path locations to the IdentifierPath ASTNode 2022-06-21 14:19:45 +02:00
Marenz
18784cff81 Add all path declarations in IdentifierPath annotation 2022-06-20 18:08:57 +02:00
Marenz
c88c74ceb8 Rename ASTJsonConverter to ASTJsonExporter
given that we have an ASTJsonImporter this name makes more sense.
2022-06-16 18:05:51 +02:00
Daniel Kirchner
16245f7b9b Warn about multiple assignments to storage byte pushes and fix warnings about multiple storage to storage copies.
Co-authored-by: Kamil Śliwak <kamil.sliwak@codepoets.it>
2022-06-15 13:53:05 +02:00
Daniel Kirchner
d30b04674e Add resolveUnaryTuples helper. 2022-06-15 13:15:26 +02:00
Kamil Śliwak
acbdcc3711 Revert the change that made events accessible in other contacts via qualified access 2022-06-14 12:04:14 +02:00
Ryan
4b7ed2d47a Display human readable type name in conversion error message 2022-06-08 18:23:51 +05:30
Christian Parpart
4ae43884d0 Apply a better way to annotate unreachability to the C++ compiler. 2022-06-07 16:41:04 +02:00
Kamil Śliwak
539e139555 Add explicit throws after some assertions to work around a spurious warning in GCC 12.1 2022-06-01 20:37:48 +02:00
nishant-sachdeva
d4c06d2b4e Adding event and error selector fields on the lines of the function selector fields 2022-05-23 10:49:16 +02:00
chriseth
dfa0bcf760 More strict override check for data locations. 2022-05-17 13:02:12 +02:00
Aisultan Kali
96376264e8 Set handlers use unified jsonPrint with prettifier if needed 2022-04-04 20:17:11 +02:00
chriseth
9188519f11 Using for with global binding. 2022-03-14 17:39:14 +01:00
chriseth
3f6beaa0ad
Merge pull request #12121 from ethereum/extend-using-statement
Extend using statement
2022-03-14 14:10:16 +01:00
hrkrshnn
672951ccc7 Extend using-for. 2022-03-14 12:33:44 +01:00
Christian Parpart
2b2f8acc12 LSP: Implements goto-definition. 2022-03-14 11:59:41 +01:00
Tyler
1c58b91075 Merge branch 'develop' of github.com:tfire/solidity into fix/remove-namespace-ast-annotations 2022-03-10 17:39:29 -05:00
Tyler
1653b6c5b7 more qualifying 2022-03-10 17:36:46 -05:00
Tyler
047034544e Merge branch 'develop' of github.com:tfire/solidity into fix/remove-namespace-ast-annotations 2022-03-09 18:55:22 -05:00
chriseth
7bd6cba79c Provide generic access to type definition for user-defined types. 2022-03-09 10:41:57 +01:00
Tyler
519e1c9402 Specify namespaces
Fix references into solidity::util
2022-03-08 00:09:17 -05:00
chriseth
77c40cd2af
Merge pull request #12740 from ethereum/remove-locale-dependent-operations
Replace all locale-dependent operations with locale-agnostic counterparts
2022-03-07 17:56:58 +01:00
wechman
52dfccca98 Replace all locale-dependent operations with locale-agnostic counterparts 2022-03-07 17:23:08 +01:00
Tyler
a890c82f9d Remove use of using namespace in header file 2022-03-06 23:16:10 -05:00