Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion nix/srcml.nix
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 ]
Expand Down
14 changes: 13 additions & 1 deletion tests/t/tokenizeSrcMl.t
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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 $!;
Expand Down
Loading