Commit Graph

242 Commits

Author SHA1 Message Date
Cary R 08c8ee081a More cppcheck updates 2025-10-20 23:54:15 -07:00
Cary R 94dcd658c8 Update exe and manual pages to report @(C) 2025 2025-10-12 19:13:30 -07:00
Cary R 1b729831b7 Cast ispace()/isdigit() args to int to remove warning 2025-02-13 00:03:18 -08:00
Martin Whitaker 2799799358 Make compiler return non-zero exit code when include file not found.
Most pre-processor errors are flagged to the main compiler by a comment
at the end of the pre-processed output. But certain errors, such as
failing to find or open an include file, cause the pre-processor to
exit immediately, which bypassed the generation of that comment. So
we need to also generate that comment for all early-exit cases.

This fixes issue #1104.
2024-02-24 13:30:27 +00:00
Martin Whitaker 855dd3a7e6 Fix new GCC warning when building ivlpp.
Using the old buffer pointer value after a realloc to adjust the pointers
into that buffer is technically undefined behaviour.
2024-02-09 11:52:38 +00:00
Cary R 2948e9a89f Update cppcheck to use c++11 2024-02-05 02:21:24 -08:00
Cary R dc047799d6 Update displayed Copyright 2024-01-20 17:52:04 -08:00
Cary R 807058e3a4 Add check for pragma name in ivlpp 2023-09-04 14:00:41 -07:00
Cary R 76a65d5958 Add error message for bad line directives to ivlpp 2023-09-04 14:00:41 -07:00
Cary R b12977d61a A macro can only have `" and add `\`" for pragma comments
We want to support `" and `\`" when a pragma comment is part of a macro
definition, but this cannot be part of a normal pragma comment.
2023-09-03 21:34:31 -07:00
Wilfried Chauveau 873c2fecd4
add double quote escapes from pragma comments. 2023-08-29 22:37:14 +01:00
Cary R 9e4c4d5460 `line directive line number must be > 0 and can have arbitrary space 2023-07-19 01:51:36 -07:00
Cary R ee14cb0eb0 Update displayed Copyright dates 2023-06-10 20:33:08 -07:00
mole99 b0c1eab51e Move textfiles to documentation 2023-06-09 13:30:44 +02:00
Lars-Peter Clausen c4daf11fac ivlpp: Handle multi-line comments in macros
Make sure that comments spanning multiple lines are supported in multi-line
macros. Since the lexer parses line by line we need a flag to track whether
a multi-line comment is currently active.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-26 16:12:01 -08:00
Lars-Peter Clausen d12a74beec ivlpp: Handle '*' or '/' following C-style comment in macro
A '*' or '/' directly following a C-style comment in a macro currently
triggers the detection of the start of another comment. Fix this by first
looking for a '/' that should start the comment.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-26 16:08:28 -08:00
Sean Anderson b18d90a2d9 ivlpp: Fix segfault in macro_start_args
macro_start_args truncates def_buf, but does not check to ensure that
someone has allocated def_buf first. This will cause a null pointer
dereference if the first access to def_buf while parsing a file is a
macro invocation. Fix this by avoiding truncating def_buf if it is NULL,
as it is effectively already truncated.

Fixes: 680196953 ("Add support for text macros with arguments.")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
2022-10-30 18:02:40 -04:00
Martin Whitaker 01a11cce56 Handle C-style comments following a `include directive (issue #782) 2022-10-16 22:03:37 +01:00
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