Commit Graph

41 Commits

Author SHA1 Message Date
Anna Gringauze
6418b5f4de
Clang cl (#762)
* Added c++17 test configurations for clang5.0 and clang6.0

* Fix #739 correct cppcorecheck warnings for clang-cl

* Add clang-cl  configurations

* Corrections Appveyor;
Temporarily disable msvc compilation for faster testing (#741)

* Add path to clang-cl.exe (#741)

* Escape backslash in path (#741)

* Update vcpkg (#741)

* Check vcpkg version; try without building vcpkg; use latest clang-cl from path (#741)

* Fix blocks in ps script (#741)

* Try accessing APPVEYOR_BUILD_FOLDER variable (#471)

* Update span size() bug confirmation test for GCC 6.5 (#741)

* MSVC flags to Clang-cl; disable c++98-compat and undefined macro warnings (#741)

* Suppress clang warning on tests (missing-prototypes) (#741)

* Fix clang warning -Wnewline-eof (#741)

* Fix clang warning -Wdouble-promotion (#741)

* Set linker explicitly

* Clean condition statement

* For Clang, fallback to the AppVeyor installed version of CMake

* Fix clang warning -Wmissing-variable-declarations

* Fallback to the MSVC linker until vcpkg has been updated

* Revert "Fallback to the MSVC linker until vcpkg has been updated"

This reverts commit 7263f3289e.

* Fix clang warning -Wunused-member-function

* Fix clang warning -Wmissing-noreturn

* Fix clang warning -Winvalid-noreturn on Windows

* Add macro block end comment on large #if blocks

* Workaround: fallback to mscv link.exe

* Workaround: get msvc paths into PowerShell through intermediate file

* Workaround: fix, remove "PATH=" from text

* Workaround: try with full-path; and return user PATH

* Workaround: fix, escape backslashes

* Revert all since "Workaround: fallback to mscv link.exe" did not work on AppVeyor

This reverts the commits:
bda3d6a428
97062933ac
0f4fb04bac
1b0c19afd1
a5739ea5f0

* Suppress output of git pull; remove vcpkg from cache

* Re-enable AppVeyor builds for all platforms

* Correct typo

Co-Authored-By: Farwaykorse <Farwaykorse@users.noreply.github.com>

* Add Clang-cl 7.0.0 to the supported platforms

* Revert "Fix clang warning -Wunused-member-function"

This reverts commit 6fe1a42035.

* Fix or locally suppress clang warning -Wunused-member-function

* format touched code and correct comment

* git pull --quiet

* fix logic error in workaround

* fix missing bracket

* Suppress output of mkdir

* Replace MSBuild with Ninja

* Suppress output of 7z

* Add architecture flags for Clang

* Drop workaround for lld-link

* 7-zip Overwrite and Alternative output suppression without suppressing errors

Replaces 3c1c0794dd

* AppVeyor setup and CMake before build

* reorder compiler configuration

* remove unnecessary

* remove -fno-strict-aliasing

* remove -Wsign-conversion, since before v4.0 part of -Wconversion

* -Wctor-dtor-privacy is GCC only

* remove -Woverloaded-virtual part of -Wmost, part of -Wall

* add -Wmissing-noreturn

* remove the pragmas for -Wunused-member-function

* Re-add MSBuild generator on AppVeyor

* Print CMake commands

* Add MSBuild toolset selection

* Separate Architecture setting

* clang-cl: add -Weverything

* clang-cl -Wno-c++98-compat

* clang-cl -Wno-c++98-compat-pedantic

* clang-cl -Wno-missing-prototypes

* clang-cl C++14 -Wno-unused-member-function

* clang-cl -Wundef __GNUC__

* clang++: add -Weverything

* clang++ -Wno-c++98-compat

* clang++ -Wno-c++98-compat-pedantic

* clang++ -Wno-missing-prototypes

* clang++ -Wno-weak-vtables

* clang++ C++14 -Wno-unused-member-function

* clang++ fix -Wundef _MSC_VER

* clang++ -Wno-padded

* clang++ solve -Wdeprecated

* Add AppleClang compiler target
Since CMake v3.0 use of Clang for both is deprecated

* clang++ v5.0 C++17 -Wno-undefined-func-template

* Add VS2015 + LLVM/clang-cl to AppVeyor

* Do not disable constexpr when compiling with clang-cl on Windows

* Clean-up clang-only warnings (now under -Weverything)

* Revert "Fix clang warning -Winvalid-noreturn on Windows"

This reverts commit 2238c4760e.

* Suppress -Winvalid-noreturn for the MS STL noexception workaround

* CMake: put preprocessor definition in target_compile_definitions

* Solve compiler warning C4668: __GNUC__ not defined
2019-01-15 10:27:34 -08:00
Anna Gringauze
9ff6e19ea9
Dev/annagrin/remove explicit not null constructor (#743)
* Added c++17 test configurations for clang5.0 and clang6.0

* Removed explicit not_null constructor, sloppy_not_null, added strict_not_null

We added explicit not_null constructor in version 2.0.0.
It proved very difficult to switch to the new version for
large code bases that adopted previous versions of gsl,
due to not_null used extensively in the code. Still, using
explicit constructor is very benefitial for new code, since
it encorages better API design and make null checks intentional.

To resolve the issue, this change:
- removes explicit keyword from not_null constructor
- removes unneded sloppy_not_null type
- adds strict_not_null type to behave the same way as v2 not_null
- updates tests

* Removed explicit not_null constructor, sloppy_not_null, added strict_not_null

We added explicit not_null constructor in version 2.0.0.
It proved very difficult to switch to the new version for
large code bases that adopted previous versions of gsl,
due to not_null used extensively in the code. Still, using
explicit constructor is very benefitial for new code, since
it encorages better API design and make null checks intentional.

To resolve the issue, this change:
- removes explicit keyword from not_null constructor
- removes unneded sloppy_not_null type
- adds strict_not_null type to behave the same way as v2 not_null
- updates tests

* fixed build break for gcc7

* added more tests

* added more non-compiling tests

* Addressed PR comments and suppressed a code analysis warning

* Fixed test failure in not_null tests
2019-01-14 16:45:47 -08:00
Anna Gringauze
6241b3faa6
Dev/annagrin/sloppy not null (#712)
* Added c++17 test configurations for clang5.0 and clang6.0

* added transition helper sloppy_not_null

* Moved gsl_transition to a samples folder

* Fixed build break and static analysis warnings
2018-08-13 09:55:48 -07:00
Anna Gringauze
cea0d0ac2b fix cppcorecheck warnings (#703)
* Added c++17 test configurations for clang5.0 and clang6.0

* Fixed CppCoreCheck warnings in GSL and tests

- Added CMakeSettings.json for VS Open Folder configuration
	- So we can easily run CppCoreCheck in VS
- Fixed CppCorecheck warnings where it made sense
- Suppressed the rest
	- Some suppression does not work due to compiler/tool bugs,
          so replaced by #pragma disable
	- CppCoreCheck has noise, suppressed those with comments
	- Catch produces many warnings, blanket-supressed them all
- Had to fix clang formatting to keep attributes in place
	- clang-format does not support attributes, so I am using
        - "CommentPragmas: '^ NO-FORMAT:'" to skip formatiting on them
- Removed GSL_NOEXCEPT macro, removed incorred noexcepts

* Ignore unknown attributes

* ignore unknown attributes in noexception mode tests

* fixed C26472 in at()

* created GSL_SUPPRESS macro to allow all compilers to parse suppression attributes

* try to fix gcc compilation problems with attributes

* ignore gsl::suppress for gcc

* move suppression to function level on return statements

clang5.0 and up does not allow attributes on return statemets in constexpr functions

* move suppression to function level on return statements

* use GSL_SUPPRESS in algorithm_tests

* Addressed PR comments
2018-08-12 21:44:17 -07:00
Anna Gringauze
21cb6bb8b0
Added testing for c++17 to latest compilers with test with (#692)
* Added testing with std=c++17 for latest compilers

Added running latest compilers with -std=c++17 option to CI the test matrix,
Updated cmake configuration to allow passing c++ standard on the command line.

* attempt to fix appveyor break

* added clang6.0, removed c++17 tests for clang 5.0

* commented out tests for clang with c++17 die to issue #695

* Addresed comments
2018-06-15 10:13:11 -07:00
Anna Gringauze
d846fe50a3
Enable usage of gsl::narrow with exceptions disabled (#640)
* Enable usage of gsl::narrow with exceptions disabled

This solution uses the approach of boost::asio to enabling usage of the
library in environments where exception usage is either prohibited
or not feasible (due to code size constraints). A function template
gsl::throw_exception has been added, which in a normal environment just
throws the exception. However, when GSL_TERMINATE_ON_CONTRACT_VIOLATION
is defined the function is only declared by gsl and the definition of
this function template must be supplied by the library's user.

Closes: #468

Signed-off-by: Damian Jarek <damian.jarek93@gmail.com>

Addition:
- understand STL no exception macro
- use function static variable to set termination handler in kernel mode
- add compile-only tests for no-exception mode

* added termination tests and fixed bugs

* disabled warning C4577 for msvc 2015
2018-03-15 16:00:08 -07:00
Tiago
1c95f9436e Updates catch to version 2.0 (#580)
Catch 1 would capture exceptions by value and depending on your clang
config could lead to errors/warnings.
2017-11-14 08:44:56 -08:00
Nicholas Guriev
e249f861e3 Allow to use system version of the catch test framework (#549) 2017-08-16 19:00:30 -07:00
Tiago
25f913e200 Fix catch installation issue (#540)
Catch was being installed to the root of the cmake project. This
violated the source code tree itself and would not work at all if GSL
was being consumed with add_subdirectory.

CMake will now install catch to the build tree under /dependencies.
2017-08-16 18:38:47 -07:00
Neil MacIntosh
b2ee484334 Move from unittest-cpp to catch for unit testing. (#533)
Many thanks to @rianquinn. This should fix #495, #494 and #529.
2017-07-13 13:53:56 -07:00
Tiago
8b320e3f5d Update CMake usage (#493)
* Refactor cmake file to have GSL as an interface

CMake supports header only libraries as INTERFACE libraries. Using
interfaces libraries make is easier for users to use the library because
one just need to "link" agaisnt the library and necessary include paths,
definitions, flags... will be taken care of.

This commit creates a new interface library called GSL. It then add the
following things to the GSL library:
- compiler flags ex: (-std=c++14)
- definitions ex: _SCL_SECURE_NO_WARNINGS
- include paths ex: include/gsl
- natvis file

Another project can now have the GSL project as a git submodule and one
only need to add the two following lines to their project to use the
GSL.
add_subdirectory(GSL)
target_link_libraries(<some target> GSL)

After cmake 3.8.0 a lot of the logic can be simplified. Right now the
cmake file has an if for version checking, but when the minimun required
version is 3.8.0 one can just delete the branching and keep the simpler
version.

* Cut support for c++11

Compiling on GCC6.2 with only the c++11 flag will generate compilation
errors. For example some of the errors are related to the use of
enable_if_t which is a c++14 feature.

To avoid compilation errors this comiit removes c++11 support on linux.

* Refactor code that pulls unittest-cpp

Two minor changes:
- uses cmake to find a proper installation of git (in case user does not
have it on the path)
- checks for the CMakeLists file instead. This is needed for the build
itself and seems like a better way to do the checking

* Refactor tests so they show together on VS

This commit will make a VS geenrated project to group all tests under
GSL_tests

* Refactor tests configuration

This creates a test configuration interface and add all the previous
compiler options to that interface. compiler options are now sorted so
it is easier to find them, and also one per line, so that modifications
are easier to track from git.
2017-04-25 17:08:36 -07:00
Casey Carter
c5851a8161 Turn warnings into errors (#488) 2017-04-17 12:26:38 -07:00
Casey Carter
4e8f95b418 Cleanup include structure, constexpr and noexcept compiler workarounds.
* Nest "gsl" directory inside a new "include" directory.

* Cleanup the _MSC_VER conditionals a bit; use constexpr on VS2017+.

* Don't #define noexcept on non-Microsoft implementations.

* Workaround VS2017 bug in multi_span. (Also implement == and != for static_bounds_dynamic_range_t because I'm an EoP semantic soundness snob.)

Fixes #441.
2017-02-07 15:59:37 -08:00
MikeGitb
d2dafe2ddf Add a copy() function for span. 2016-11-17 10:45:06 -08:00
Neil MacIntosh
0d31109d41 Fixed compile flags for tests when using MSVC. 2016-11-04 14:48:22 -07:00
Rian Quinn
d641796b21 Cleanup additional GCC warnings
When turning on the following flags, several additional warnings
were generated, which have been cleaned up in this patch. The
flags included:

-Wextra
-Wpedantic
-Wconversion
-Wsign-conversion
-Wctor-dtor-privacy
-Wshadow
-Wnon-virtual-dtor
-Wold-style-cast
-Wcast-align
-Woverloaded-virtual
2016-11-03 18:38:32 -07:00
Marc Mutz
1e95421889 [#392] Don't install tests
'make install' should install the GSL library (ie. the headers),
not the tests.

It still installs the UnitTest++ headers, but that will be more
complex to fix, as GSL just imports UnitTest++ as a git submodule,
and the install command propagates down to UnitTest++'s
CMakeLists.txt.
2016-10-17 12:42:58 -07:00
MikeGitb
1287e624cd Address #313: try to guard against strict-aliasing bugs with gsl::byte
* Add test to demonstrate byte aliasing problem on g++ and clang++

* Add note about no-strict-aliasing flag in README

* Activate aliasing unit test and use -fno-strict-aliasing flag
2016-10-17 12:36:11 -07:00
Galik
222c2d85fd Removed .h extension from header files. 2016-08-10 17:24:00 +01:00
galik
f6cc5798a1 Renamed include/ folder to gsl/ to make including the library consistent
whether using it from the development folder, from the installation
folder or from being copied into a project. 

    #include <gsl/gsl.h>

Updated headers/tests/instructions/cmake build accordingly

This PR should address https://github.com/Microsoft/GSL/issues/277 (less
the renaming of gsl itself)
2016-08-09 15:04:58 +01:00
Neil MacIntosh
eed99d8599 Merge branch 'master' into dev/neilmac/spec 2016-07-20 09:30:05 -07:00
Neil MacIntosh
b72d7abfb0 Added definition of gsl::byte to match proposed std::byte. 2016-06-24 04:54:09 -07:00
Sergiy Oryekhov
79030c5586 Moving submodule init before subdirectory. 2016-03-23 16:53:00 -07:00
Sergiy Oryekhov
32d00796ad Adding unittest-cpp as a submodule. 2016-03-23 16:42:35 -07:00
Neil MacIntosh
cec26a23b9 Added new span-related files. 2016-02-24 11:26:28 -08:00
Neil MacIntosh
d2f12a8fa3 File renames to reflect new multi_span name. 2016-02-24 11:03:33 -08:00
Neil MacIntosh
0cf947db77 Reworked span to match GSL design. 2015-11-29 19:19:37 -08:00
Neil MacIntosh
38eaf9fc95 Refactored headers so span can use narrow_cast etc. 2015-11-23 16:22:31 -08:00
Neil MacIntosh
d13f6daa75 Refactored to use Expects/Ensures everywhere. 2015-11-20 17:06:23 -08:00
Neil MacIntosh
b9565e50ce Update CMakeLists.txt 2015-11-12 19:36:34 -08:00
Neil MacIntosh
fa056f67e8 Enabled -Wall for gcc and clang. 2015-11-13 03:27:53 +00:00
Neil MacIntosh
a998a9b33b Turned on Level 3 warnings for MSVC. 2015-11-12 18:57:23 -08:00
Neil MacIntosh
b63ec949e9 Renaming array_view and string_view, as per WG21 discussions. 2015-11-04 12:42:27 -08:00
Treb Connell
fda8e12310 Fix #124 remove maybe_null 2015-10-05 13:34:50 -07:00
Neil MacIntosh
ef626fd33a Renamed namespace to 'gsl'. Renamed macro to configure testing. 2015-09-29 16:41:37 -07:00
Tamas Kenez
9b454b7a9b add travis testing (gcc5, clang36)
- also relaxed CMake version to 2.8.7, the version default in travis
2015-09-23 17:43:36 +02:00
David Capello
5d9aae7430 Add add_gsl_test() function in tests/CMakeLists.txt
With this function we can avoid duplicated code to add a new test.
2015-09-21 16:04:06 -03:00
Neil MacIntosh
05e6b6dd4b Added missing owner<T>, corrected array_view::sub(). 2015-09-20 19:18:12 -07:00
Neil MacIntosh
75f31dabe9 Removed Debug build warnings from MSVC STL. 2015-08-27 22:15:44 -07:00
Anna Gringauze
5e945461c9 Fixed unittest directory check to look in the source directory 2015-08-25 11:50:58 -07:00
Neil MacIntosh
a9dcbe04ff Initial commit of library files. 2015-08-20 18:09:14 -07:00