Commit Graph

224 Commits

Author SHA1 Message Date
Martin Whitaker d8cb29f6e0 Fix bug in preprocessor line directive handling. 2021-03-14 10:03:08 +00:00
Martin Whitaker 9a2c43ec34 Recognise and obey `line directives in the preprocessor (issue #488)
To correctly restore the file name and line number after including a
file or expanding a macro, the preprocessor needs to be aware of the
changes introduced by `line directives. The `line directive still
needs to be passed on to the main compiler so it can track the
changes too.

To avoid duplicate error messages, the preprocessor silently ignores
invalid `line directives, relying on the main compiler to report the
errors.
2021-03-13 23:38:30 +00:00
Cary R 2cc41a4639 Allow a macro generated string to work with an include 2021-02-13 16:58:21 -08:00
Cary R 0cfbb8afeb Fail for `else or `elsif after a matching `else 2021-01-26 19:53:45 -08:00
Cary R 9eb77116b9 Missing macro arguments are an error 2021-01-10 19:23:16 -08:00
Cary R 5f281d5f21 Pass fail information from the preprocessor to the compiler 2021-01-10 18:27:31 -08:00
Cary R 85e8cc6c5f Update some preprocessor error messages 2021-01-10 18:27:23 -08:00
Cary R c978d28c09 Update main component Copyright to 2021 2021-01-10 14:32:30 -08:00
Cary R 1d318c4393 Update cppcheck to not run posix and add some -U flags 2021-01-02 13:23:59 -08:00
Martin Whitaker fe79f130b5 Support macro text continuation after single line comment (issue #435) 2020-12-20 12:29:24 +00:00
Martin Whitaker 359b2b65c2 Support escaped identifiers as macro names. 2020-10-09 11:38:16 +01:00
Martin Whitaker 6566072741 Fix GitHub issue #374 - ordering of `` and embedded macro expansion.
The IEEE standard does not clearly state whether the `` directive is applied
before or after embedded macros are expanded. Other simulators vary in their
behaviour. For maximum compatibility, this fix adopts the behaviour found in
Verilator, where `prefix``suffix expands to <prefix>suffix if prefix is a
defined macro, otherwise it expands to <prefixsuffix> (where <...> is the
expanded macro text). Other simulators show this behaviour in at least some
circumstances.
2020-10-09 08:09:04 +01:00
Martin Whitaker d8556e4c86 Fix handling of the SV `` delimiter when combined with macro usage.
Given a macro definition like this:

  `define name  `macro``text

the preprocessor should expand `macro, not `macrotext, when it expands
`name. This also ensures that

  `define name(p,s)     p``_``s
  `define PREFIX        my_prefix
  `define SUFFIX        my_suffix

  `name(`PREFIX, `SUFFIX)

expands to

  my_prefix_my_suffix

as the user would expect.
2020-08-24 20:29:15 +01:00
Martin Whitaker dc2aa6efa0 Fix handling of SV `" and `\`" escape sequences in macros (GitHub issue #366).
`" overrides the normal behaviour of disabling macro expansion within
a string.
2020-08-24 14:48:40 +01:00
Martin Whitaker e69549034d Fix potential buffer overflows (GitHub issue #346). 2020-07-28 13:17:57 +01:00
Cary R fb237fb006 Update the user visible copyright to be 2020 2020-05-31 13:41:38 -07:00
Huang Rui 11001f58d5
Thoroughly fix parallel installation issues
In PR #300, @xdch47 pointed out a stable way to fix parallel
installation problems.

This fix applied the method, thanks!

Signed-off-by: Huang Rui <vowstar@gmail.com>
2020-02-12 22:42:04 +08:00
Huang Rui 593d5b5c83 [16/20]ivlpp/Makefile.in:fix install timestamp check
Fix bug: https://bugs.gentoo.org/705412
Fix bug: https://github.com/gentoo/gentoo/pull/14096
Related: https://github.com/steveicarus/iverilog/pull/294

Signed-off-by: Huang Rui <vowstar@gmail.com>
2020-02-12 22:08:40 +08:00
Martin Whitaker fb29da0bd8 Fix for GitHub issue #309 - allow braced expressions as macro arguments.
As for parentheses, we need to ignore commas within a pair of braces
when parsing a macro argument, e.g. `MACRO({a,b}) has one argument.

This fix is a little crude in that it doesn't distinguish between
parentheses and braces, e.g. it will accept {a,b). But any errors
like that will be caught by the compiler proper.
2020-02-08 20:51:50 +00:00
Cary R ea4e41207c Update cppcheck standards that are checked 2019-09-30 22:14:15 -07:00
Cary R f03033e612 Update flex destroy routines to work for version 2.6 and greater 2017-11-16 19:11:50 -08:00
Martin Whitaker c0845d8bea Fix assertion failure when using -Wmacro-redefinition, -y, and -D.
Predefined macros get stored in the precompiled macro file that gets
read back in when processing library files. This means the predefined
macros get processed twice. We need to skip the check in this case.
2017-11-08 20:07:38 +00:00
Martin Whitaker 02daffc97e Add option to only warn about macro redefinitions that change the text.
A common use case (prior to the introduction of localparam) was to
use macros to define constant values, and to put global constant
values in an include file that gets included by each source file.
This will generate a lot of spurious warnings if we warn about all
redefinitions. Make this new option the default for -Wall.
2017-11-08 19:50:42 +00:00
Martin Whitaker af1ea13c47 Don't check for macro redefinition if the warning is disabled.
And reword the comment to be a bit less dictatorial.
2017-11-06 21:03:03 +00:00
Andrew Andrianov 9e2252bc39 ivlpp: Actually take warn_redef flag into account
Signed-off-by: Andrew Andrianov <andrew@ncrmnt.org>
2017-10-22 13:28:15 +03:00
Andrew Andrianov 0c84413347 ivlpp: Add -Wredef option to enable redefinition warnings
Signed-off-by: Andrew Andrianov <andrew@ncrmnt.org>
2017-10-18 19:18:14 +03:00
Andrew Andrianov 73167563d5 ivlpp: Warn about macro redefinition
Verilog spec has a very nasty system of macros jumping from
file to file, resulting in a global macro scope. We abosolutely
MUST track macro redefinitions and warn user about them.

Signed-off-by: Andrew Andrianov <andrew@ncrmnt.org>
2017-10-08 14:22:40 +03:00
Martin Whitaker 332170d36b Fix for GitHub issue #105 - fully support SV macro escape sequences.
The existing support for ``, `", and `\`" did not work in nested macro
definitions. Note that the new implementation only detects and replaces
these sequences inside the macro text (as required by the IEEE standard),
whereas the old implementation would detect and replace them anywhere in
the source files.
2016-06-06 20:12:04 +01:00
Martin Whitaker 9f4b485c1c Updated copyright dates displayed for main programs and targets. 2015-08-17 22:05:08 +01:00
Martin Whitaker 586e415d96 Allow macro arguments to be omitted when default values are available.
SystemVerilog allows fewer actual arguments than formal arguments when
all remaining formal arguments have default values.
2015-06-27 19:02:02 +01:00
Larry Doolittle b23faff27c Just a few more spelling fixes
Includes some user-visible messages
2015-06-17 08:09:34 -07:00
Larry Doolittle 33c651aa00 Spelling fixes in .txt files 2015-05-25 12:52:03 -07:00
Martin Whitaker d5b41853fd Fix for br979 part 2 - handle blank lines in macro definition continuation. 2015-05-22 18:44:25 +01:00
Martin Whitaker 0fc10e3e70 Fix for br979 part 1 - strip leading/trailing space from macro actual args.
Although the IEEE standard doesn't explicitly state this is required,
the examples added in the SystemVerilog standard show that this is
expected.

Also add a preprocessor lexical rule to recognise `` inside a macro
definition when it is not immediately followed by an identifier.
2015-05-22 18:11:24 +01:00
Martin Whitaker a479bd6b16 Fix for br977 - preprocessor macros substitute text inside token.
When replacing macro formal parameters, the preprocessor should not
replace matching strings that are not complete tokens. The test for
this was incorrect, and failed when a match was found at the start
of the replacement text.
2015-05-17 20:05:45 +01:00
Martin Whitaker cfbc90812b Enable use of MinGW ANSI stdio routines.
Defining __USE_MINGW_ANSI_STDIO=1 provides C99 compatible printf
and scanf routines, which avoids the need for workarounds for the
various failings of the Microsoft C runtime library.
2015-05-10 11:45:42 +01:00
Martin Whitaker 6a3edc63d5 Fix printf format for size_t values when using 64-bit MinGW.
The Microsoft C runtime does not support the %zu and %zd formats.
Previously these were replaced with %u and %d, but for 64-bit we
need to use %llu and %lld.
2015-05-08 20:20:14 +01:00
Cary R 43841af2f3 Fix a cppcheck warning and fix code style a bit 2014-12-11 09:59:15 -08:00
Stephen Williams 3e9c14060f lexor handles arbitrary length defines in the precompiled_defiles file. 2014-10-25 09:48:11 -07:00
Cary R d6b6b76015 Update header files to use a more standard name to prevent rereading
This is from github report #16. There are likely a few more issues
that need to be addressed though this takes care of the major ones.
2014-07-23 13:42:56 -07:00
Cary R 9d99a64bf0 Remove warnings and -Wno-type-limits option since it is not always supported. 2014-07-09 11:04:43 -07:00
Larry Doolittle e221a8ced9 Rearrange compiler warning flags
Before this patch, WARNING_FLAGS applied to both C and C++,
and WARNING_FLAGS_CXX applied to C++ only.
This patch adds a WARNING_FLAGS_CC that applies to C only.
That change should be generally useful; in particular the C
code is almost ready for -Wstrict-prototypes, which does not
apply to C++.

-Wextra (or -W) used to only apply to C++ via WARNING_FLAGS_CXX.
This patch moves it to WARNING_FLAGS, to apply to both C and C++.
Unfortunately, that triggers a ton of warnings.

For now, cover most of the new warnings up by adding
-Wno-unused -Wno-sign-compare -Wno-type-limits
to WARNING_FLAGS_CC.  In the long run, I want to change the C coding
style, and take off these disable-warning flags.  But those changes
can dribble in as separate commits; this patch is big enough already.

Actually fix a couple missing-field-initializers in libveriuser/veriusertfs.c.
2014-07-09 09:04:17 -07:00
Larry Doolittle 6ebb57195b Fuss with C function prototypes
119 formal void parameters added to keep -Wstrict-prototypes happy.
Process found one real missing prototype in vpi/vcd_priv.h:
EXTERN void vcd_names_delete(struct vcd_names_list_s*tab);
8 such warnings left, all in Tony's code
2014-07-08 13:44:11 -07:00
Larry Doolittle 642acb4082 Clean up some more sign-compare issues
The only known problems left are in files imported from gtkwave,
if not for them you could turn on -Wsign-compare.

Assumes c99 for c code, so the scope of for-loop indexes can be made sane.
2014-06-17 12:57:26 -07:00
Stephen Williams aced587461 Macros with formal arguments can have default text for those arguments. 2013-12-07 12:20:28 -08:00
Cary R d5823b3e55 update a copyright and fix the define order. 2013-10-07 16:51:48 -07:00
Jared Casper ec8081f983 Handle `", `\`", and `` in macro definitions.
Implements page 644 of IEEE 1800-2012.

`` is now overloaded with the Icarus-specific "stringify" expansions.
It is now used as indicated in 1800-2012 when appearing inside a macro
definition, and the Icarus way when not.  To do so, it uses the fact
that istack->file is NULL iff we are processing expanded macro text,
which is a bit of hack but works as is.

`" and `\`" on the other hand are treated the same inside and outside
of macro definitions.
2013-10-07 16:16:00 -07:00
Arun Persaud f5aafc32f9 updated FSF-address 2012-08-29 10:12:10 -07:00
Cary R ea420d94ac Fix for pr3539372.
This patch matches what was proposed in pr3539372 to fix ivlpp to correctly
handle an escapped \ at the end of a string.
2012-07-09 11:42:28 -07:00
Cary R fc7e7640ed Remove some MinGW32-w64 compile warnings. 2012-01-05 17:26:08 -08:00