Skip to content

Commit 7134db5

Browse files
committed
Don't require a _ between Dv and the variable dimension expression.
The previous code is based on what libiberty does, but gcc doesn't appear to actually emit the dimension expression form (see https://github.com/gcc-mirror/gcc/blob/a27940feffbbff172d8ec84ee825e1997b3d0210/gcc/cp/mangle.c#L2286) and clang emits the expression without this _, so lets follow clang. This intentionally regresses libiberty test 123. Fixes #231
1 parent 2874bd0 commit 7134db5

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ use std::fmt::Write;
132132
s.extend(94..113);
133133
s.extend(115..118);
134134
s.extend(119..120);
135-
s.extend(121..124);
135+
s.extend(121..123);
136136
s.extend(127..131);
137137
s.extend(133..134);
138138
s.extend(137..138);

src/ast.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4732,7 +4732,7 @@ where
47324732
///
47334733
/// ```text
47344734
/// <vector-type> ::= Dv <number> _ <type>
4735-
/// ::= Dv _ <expression> _ <type>
4735+
/// ::= Dv <expression> _ <type>
47364736
/// ```
47374737
#[derive(Clone, Debug, PartialEq, Eq)]
47384738
pub enum VectorType {
@@ -4760,7 +4760,6 @@ impl Parse for VectorType {
47604760
return Ok((VectorType::DimensionNumber(num as _, ty), tail));
47614761
}
47624762

4763-
let tail = consume(b"_", tail)?;
47644763
let (expr, tail) = Expression::parse(ctx, subs, tail)?;
47654764
let tail = consume(b"_", tail)?;
47664765
let (ty, tail) = TypeHandle::parse(ctx, subs, tail)?;
@@ -9090,7 +9089,7 @@ mod tests {
90909089
b"...",
90919090
[]
90929091
}
9093-
b"Dv_tr_S_..." => {
9092+
b"Dvtr_S_..." => {
90949093
VectorType::DimensionExpression(Expression::Rethrow,
90959094
TypeHandle::BackReference(0)),
90969095
b"...",
@@ -9102,7 +9101,8 @@ mod tests {
91029101
b"Dv" => Error::UnexpectedEnd,
91039102
b"Dv42_" => Error::UnexpectedEnd,
91049103
b"Dv42_..." => Error::UnexpectedText,
9105-
b"Dvtr_" => Error::UnexpectedText,
9104+
b"Dvtr_" => Error::UnexpectedEnd,
9105+
b"Dvtr_..." => Error::UnexpectedText,
91069106
b"" => Error::UnexpectedEnd,
91079107
b"..." => Error::UnexpectedText,
91089108
}

tests/tests.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,3 +595,8 @@ demangles_simplify_template_parameters!(
595595
_ZN11SmiTagging2ILs4EE13kSmiShiftSizeE,
596596
"SmiTagging2<4>::kSmiShiftSize"
597597
);
598+
599+
demangles!(
600+
_ZN4glslL7combineIhLi2EEEDvmlT0_Li4E_T_DvT0__S1_S3_S3_S3_,
601+
"unsigned char __vector((2)*(4)) glsl::combine<unsigned char, 2>(unsigned char __vector(2), unsigned char __vector(2), unsigned char __vector(2), unsigned char __vector(2))"
602+
);

0 commit comments

Comments
 (0)