Skip to content

Commit

Permalink
pgi compiler support: -pedantic -Werror
Browse files Browse the repository at this point in the history
pgroup.com pgcc does not support -pedantic -Werror,
probe for it on non-GNUC compatible compilers.
Add @pedantic@ and @WARN_CFLAGS_TESTS@

Tested ok with nvidia PGI pgcc 17.4 and 19.4 on darwin.
  • Loading branch information
rurban committed Jun 2, 2019
1 parent 2f0427f commit 63a6c0c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
19 changes: 18 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# 2017 Reini Urban <[email protected]>
#
# Copyright (c) 2012, 2013 Cisco Systems
# Copyright (c) 2017, 2018 Reini Urban
# Copyright (c) 2017, 2018, 2019 Reini Urban
# All rights reserved.
#
# Permission is hereby granted, free of charge, to any person
Expand Down Expand Up @@ -534,6 +534,19 @@ esac
if test x$ax_cv_check_cflags__Wrestrict = xyes; then
AC_DEFINE([HAVE_WARNING_RESTRICT], 1, [Have -Wrestrict])
fi
PEDANTIC="-pedantic"
WARN_CFLAGS_TEST="-Wall -Wextra"
if test x$ac_compiler_gnu = xno; then
AX_CHECK_COMPILE_FLAG([-pedantic],
[PEDANTIC="-pedantic"],
[PEDANTIC=""
WARN_CFLAGS_TEST=""],[$ax_ccf_err])
AX_CHECK_COMPILE_FLAG([-Werror],
[],
[WARN_CFLAGS=""
WARN_CFLAGS_TEST=""],[$ax_ccf_err])
fi
AC_SUBST(PEDANTIC, $PEDANTIC)
AX_GCC_BUILTIN(__builtin_object_size)
dnl against -Werror,-Wgcc-compat fortify errors, only on clang
INSERT_OBJECT_SIZE="#undef HAVE___BUILTIN_OBJECT_SIZE"
Expand Down Expand Up @@ -587,6 +600,7 @@ int myfunc(char *ptr) {
)],
[ AC_MSG_RESULT([yes])
have_attribute_diagnose_if=yes
WARN_CFLAGS_TESTS="$WARN_CFLAGS_TESTS -Wno-gcc-compat"
AC_DEFINE([HAVE_ATTRIBUTE_DIAGNOSE_IF], 1,
[Defined to 1 when the compiler supports attribute diagnose_if, since clang-5])
],
Expand All @@ -598,6 +612,7 @@ int myfunc(char *ptr) {
])
CFLAGS="$old_cflags"
AM_CONDITIONAL([HAVE_ATTRIBUTE_DIAGNOSE_IF], [test "x$have_attribute_diagnose_if" = "xyes"])
AC_SUBST(WARN_CFLAGS_TEST, $WARN_CFLAGS_TEST)

AX_ASM_INLINE()

Expand Down Expand Up @@ -964,6 +979,8 @@ if test "x$enable_debug_build" = "xtrue"; then
AC_MSG_RESULT([AM_LDFLAGS = $AM_LDFLAGS])
AC_MSG_RESULT([CFLAGS = $CFLAGS])
AC_MSG_RESULT([WARN_CFLAGS = $WARN_CFLAGS])
AC_MSG_RESULT([WARN_CFLAGS_TESTS = $WARN_CFLAGS_TESTS])
AC_MSG_RESULT([PEDANTIC = $PEDANTIC])
fi

# Output files
Expand Down
4 changes: 3 additions & 1 deletion include/safe_types.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ extern "C" {
#endif

/* C11 appendix K types - specific for bounds checking */
#ifndef _RSIZE_T /* PGI */
typedef size_t rsize_t;
#endif

#ifndef RSIZE_MAX
# define RSIZE_MAX (~(rsize_t)0) /* leave here for completeness */
#define RSIZE_MAX (~(rsize_t)0) /* leave here for completeness */
#endif

#ifdef __KERNEL__
Expand Down
4 changes: 2 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# 2017-2018 Reini Urban
#
# Copyright (c) 2012, 2013 Cisco Systems
# Copyright (c) 2017 Reini Urban
# Copyright (c) 2017, 2019 Reini Urban
# All rights reserved.
#
# Permission is hereby granted, free of charge, to any person
Expand Down Expand Up @@ -235,7 +235,7 @@ ALL_SRC_FILES =
# wcsnorm_CFLAGS = -fbracket-depth=512
AM_CFLAGS += -I$(top_builddir)/include -I$(srcdir)
if !HAVE_MINGW
AM_CFLAGS += -pedantic
AM_CFLAGS += @PEDANTIC@
endif
AM_CFLAGS += $(WARN_CFLAGS)

Expand Down
11 changes: 3 additions & 8 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -209,19 +209,14 @@ SAFEC_TEST_MSVCRT = \
UNIDATA = CaseFolding.txt DerivedGeneralCategory.txt

# WARNING: tests won't build with -Werror right now. A few minor warnings
#AM_CFLAGS += -Werror
#AM_CFLAGS += -Werror
AM_CFLAGS += -I$(top_builddir)/include -I$(srcdir)
# pedantic complains about __FUNCTION__
#if !HAVE_MINGW
#AM_CFLAGS += -pedantic
#endif
AM_CFLAGS += -Wall -Wextra
# works mostly, but too strict with gnu extensions
# AM_CFLAGS += $(WARN_CFLAGS)
# clang:
if HAVE_ATTRIBUTE_DIAGNOSE_IF
AM_CFLAGS += -Wno-gcc-compat
endif
# WARN_CFLAGS works mostly, but too strict with gnu extensions
AM_CFLAGS += $(WARN_CFLAGS_TESTS)

LDADD = $(top_builddir)/src/libsafec-@[email protected]

Expand Down

0 comments on commit 63a6c0c

Please sign in to comment.