diff --git a/nix/srcml.nix b/nix/srcml.nix index 93f91a24..f8ac9cb0 100644 --- a/nix/srcml.nix +++ b/nix/srcml.nix @@ -1,9 +1,12 @@ # srcML at a pinned source revision. The 1.1.0 release binary segfaults under # `--position` (srcML/srcML#2395, fixed upstream by cebd3ab, still unreleased), -# and the pipeline always passes `--position`. +# and the pipeline always passes `--position`. The pin also segfaults on a GCC +# `__attribute__` after an expression inside parentheses (srcML/srcML#2425), so +# the upstream fix 0910c0eb is applied on top of it until a release carries it. { lib , stdenv , fetchFromGitHub +, fetchpatch , fetchurl , cmake , ninja @@ -59,6 +62,13 @@ stdenv.mkDerivation { hash = "sha256-stn1VP+D9Awd9B+r3UWIjHJUkoNU52SOJndX9hLEnrY="; }; + patches = [ + (fetchpatch { + url = "https://github.com/srcML/srcML/commit/0910c0ebac7d595a3ad47e3bbe681dfa130bf3b0.patch"; + hash = "sha256-GqVYV8Z8OmK1TGsusNiGUjfXDAJlkB03ZPyuYLVABFA="; + }) + ]; + nativeBuildInputs = [ cmake ninja jdk_headless ]; buildInputs = [ libxml2 libxslt libarchive curl ] diff --git a/tests/t/tokenizeSrcMl.t b/tests/t/tokenizeSrcMl.t index b2978141..14aed94c 100644 --- a/tests/t/tokenizeSrcMl.t +++ b/tests/t/tokenizeSrcMl.t @@ -20,7 +20,7 @@ plan skip_all => "ctags not on PATH" plan skip_all => "srcml2token not built (cd tokenize/srcMLtoken && make)" unless -x $srcml2token; -plan tests => 24; +plan tests => 27; my $workdir = tempdir(CLEANUP => 1); @@ -110,6 +110,18 @@ sub run_tokenizer { } } +{ + my $attr = "$workdir/attribute-in-parens.c"; + open(my $fh, '>', $attr) or die $!; + print $fh "void f(int a) { F(a __attribute__((unused))); }\n"; + close $fh; + + my ($status, $out, $err) = run_tokenizer("--position", "'$attr'"); + is($status, 0, "a GCC attribute after an expression inside parentheses tokenizes (srcML/srcML#2425)"); + like($out, qr/^\d+:\d+\|attribute\|__attribute__\(\($/m, "and the attribute is in the tokenization"); + like($out, qr/^\d+:\d+\|name\|unused$/m, "with its argument"); +} + { my $dies = "$workdir/srcml-that-dies"; open(my $fh, '>', $dies) or die $!;