Skip to content

Add -Wdeprecated to show deprecated warnings#1072

Open
quic-shaksuma wants to merge 1 commit intoqualcomm:mainfrom
quic-shaksuma:add-diag
Open

Add -Wdeprecated to show deprecated warnings#1072
quic-shaksuma wants to merge 1 commit intoqualcomm:mainfrom
quic-shaksuma:add-diag

Conversation

@quic-shaksuma
Copy link
Copy Markdown
Contributor

@quic-shaksuma quic-shaksuma commented Apr 17, 2026

Add diagnostics for assignment expression having improper white-spaces around the assignment operator.
Add -Wdeprecated to show the warnings of these kind.
Update the documentation to include the exception for MEMORY command.

Fixes #336

@quic-shaksuma quic-shaksuma marked this pull request as draft April 17, 2026 20:59
@quic-shaksuma quic-shaksuma changed the title Add linker script assignment expression diagnostics. Add -Wdeprecated for linker script assignment expression diagnostics. May 5, 2026
@quic-shaksuma quic-shaksuma changed the title Add -Wdeprecated for linker script assignment expression diagnostics. Add -Wdeprecated to show deprecated warnings May 5, 2026
@quic-shaksuma quic-shaksuma marked this pull request as ready for review May 5, 2026 15:49
Add -Wdeprecated to show diagnostics for deprecated linker features
and linker-script syntax.

Assignment expressions having improper white-spaces around them should
show a deprecated warning when -Wdeprecated is enabled.
Update the documentation to include the assignment operator exception
for MEMORY command.

Fixes  qualcomm#336

Signed-off-by: Shakti Suman <shaksuma@qti.qualcomm.com>
Copy link
Copy Markdown
Contributor

@parth-07 parth-07 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this patch. There are a few cases that does not work quite right with this change.

#!/usr/bin/env bash

cat >script.t <<\EOF
u =v;
PROVIDE(v =11);
EOF

ld.eld -m armelf -o a.out /dev/null -T script.t -Wdeprecated
ld.bfd -o a.bfd.out /dev/null -T script.t

We only want to warn/error when = does not have a space with the LHS symbol.

#!/usr/bin/env bash

cat >script.t <<\EOF
a = 0;
b = 11;
a += b; // +=
EOF

ld.eld -m armelf -o a.out /dev/null -T script.t -Wdeprecated
ld.bfd -o a.bfd.out /dev/null -T script.t

This incorrectly reports the warning:

Warning: script.t:3: missing whitespace around assignment operator '+=' in assignment expression is deprecated
>>> a += b; // +=
>>> 
#!/usr/bin/env bash

cat >script.t <<\EOF
SECTIONS {
  u=v : {
    *(.text)
  }
}
EOF

ld.eld -m armelf -o a.out /dev/null -T script.t -Wdeprecated
ld.bfd -o a.bfd.out /dev/null -T script.t

This linker script works fine with GNU ld and the current eld but fails with this patch.

If we are okay with not allowing = in symbol names and section names, then can you please take a look at this patch: #295. It parses the section and symbol names in LexState::Expr if they contain =. We can report the warning easily as well by checking if the op token is immediately after the LHS symbol token. This PR avoids many of the complication such as getOpWithoutSpace and splitting the token based on operators.

return false;
}

bool ScriptParser::isValidAssignment(llvm::StringRef Op) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please rename the function to something like reportInvalidAssignment? The name isValidAssignment does not indicate that this function has a side affect and it also does not return false for invalid assignments as the name suggests it should.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve error messages from assignment expressions

2 participants