diff options
author | rmanfredi <rmanfredi@2592e710-e01b-42a5-8df0-11608a6cc53d> | 2012-02-09 19:15:13 +0000 |
---|---|---|
committer | rmanfredi <rmanfredi@2592e710-e01b-42a5-8df0-11608a6cc53d> | 2012-02-09 19:15:13 +0000 |
commit | 8160f5523cbbb37197732ea645d02f884e180f3c (patch) | |
tree | 614060e525e21db3fe968eb823fa7ae941bff7d8 | |
parent | c1893f4bddbe65d8a7bca7e34890fd85d58bd509 (diff) |
Make Assert.U explicitly claim it creates a local "static_assert.h" file.
Taught metalint to look for #include files in here-documents to catch
missing dependencies on Assert, or other special units that would create
such locally-defined includes.
git-svn-id: svn://svn.code.sf.net/p/dist/code/trunk/dist@132 2592e710-e01b-42a5-8df0-11608a6cc53d
-rw-r--r-- | mcon/U/Assert.U | 9 | ||||
-rw-r--r-- | mcon/pl/lint.pl | 16 |
2 files changed, 23 insertions, 2 deletions
diff --git a/mcon/U/Assert.U b/mcon/U/Assert.U index dfb33a1..59b4e39 100644 --- a/mcon/U/Assert.U +++ b/mcon/U/Assert.U @@ -9,7 +9,16 @@ ?RCS: ?MAKE:Assert: cat ?MAKE: -pick add $@ %< +?F:./static_assert.h : static assertion checking include file +?X: +?X: C programs can include this file to perform STATIC_ASSERT() checks +?X: which are done at compile-time and cause the compilation to fail when +?X: the expression is false. +?X: +?X: It is sufficient to compile with: $cc -c $ccflags try.c +?X: There is no need to link the file to spot the assertion failure. +?X: $cat >static_assert.h <<'EOC' #define STATIC_ASSERT(expr) \ do { switch (0) { case ((expr) ? 1 : 0): case 0: break; } } while(0) diff --git a/mcon/pl/lint.pl b/mcon/pl/lint.pl index 1e4cad3..64bb466 100644 --- a/mcon/pl/lint.pl +++ b/mcon/pl/lint.pl @@ -793,14 +793,26 @@ sub p_body { $shused{$unit} .= "\$$var " unless $shused{$unit} =~ /\$$var\b/; } - return if $heredoc ne '' && !$began_here; # Still in here-document + local($file); + + if ($heredoc ne '' && !$began_here) { + # Still in here-document + # Just look for included files from C programs expected to be local + # in case they missed the special unit that produces these files. + if (s!#(\s*)include(\s+)"([\w.]+)"!!) { + $file = $3; + $fileused{$unit} .= "$file " unless + $filetmp{$file} || $fileused{$unit} =~ /\b$file\b/; + } + return; + } # Now look at private files used by the unit (./file or ..../UU/file) # We look at things like '. ./myread' and `./loc ...` as well as "< file" - local($file); $_ = $line; s/<\S+?>//g; # <header.h> would set-off our <file detection while ( + s!#(\s*)include(\s+)"([\w.]+)"!! || s!(\.\s+|`\s*)(\S*UU|\.)/([^\$/`\s;]+)\s*!! || s!(`\s*\$?)cat\s+(\./)?([^\$/`\s;]+)\s*`!! || s!(\s+)(\./)([^\$/`\s;]+)\s*!! || |