Bug 12924 – deprecated("foo"); and deprecated; should not compile

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-06-15T06:23:00Z
Last change time
2014-06-18T08:25:03Z
Keywords
accepts-invalid, pull
Assigned to
nobody
Creator
issues.dlang

Comments

Comment #0 by issues.dlang — 2014-06-15T06:23:31Z
This code compiles with no errors or deprecation messages: deprecated("Don't use me!"); void foo() { } void main() { foo(); } Of course, what it should be is deprecated("Don't use me!") void foo() { } void main() { foo(); } and that _will_ give a deprecation warning. However, I don't think that the problem is that the first example doesn't give a deprecation warning. Rather, it should be an error, as deprecated isn't a statement. It's an attribute. Whether there is a message or not doesn't seem to affect anything, e.g. deprecated; void foo() { } void main() { foo(); } also compiles with no errors or deprecation warnings.
Comment #1 by k.hara.pg — 2014-06-17T06:57:31Z
This is git-head regression caused by the parser improvement: https://github.com/D-Programming-Language/dmd/pull/2924 Compiler fix: https://github.com/D-Programming-Language/dmd/pull/3676
Comment #2 by github-bugzilla — 2014-06-18T08:25:02Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/4b2578e208f2af9a02159fc2d8d87fb17b09005e fix Issue 12924 - deprecated("foo"); and deprecated; should not compile 'DeclarationBlock' that follows 'Attribute' should be parsed by parseBlock. `PrefixAttribute` is used to check redundant/conflicting attributes over the mutual call between `parseDeclDefs` and `parseBlock`. https://github.com/D-Programming-Language/dmd/commit/77f4e95af6cf1fd2dd80902ec122a23f1358fd1f Merge pull request #3676 from 9rnsr/fix12924 [REG2.066a] Issue 12924 - deprecated("foo"); and deprecated; should not compile