October 09, 2020 [Issue 21300] New: C++ header generation produce nonsense code on enum with enum as parent | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=21300 Issue ID: 21300 Summary: C++ header generation produce nonsense code on enum with enum as parent Product: D Version: D2 Hardware: All OS: All Status: NEW Keywords: C++ Severity: blocker Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: pro.mathias.lang@gmail.com Code, extracted from DMD: ``` extern(C++): enum Color : int { Blue, Red, Green, } enum Classification { Deprecation = Color.Blue, Error = Color.Red, Tip = Color.Green, } ``` Using master: * de9057ea6 - (upstream/master, origin/master, origin/HEAD, master) Merge pull request #11805 from MoonlightSentinel/build-from-run (14 hours ago) <The Dlang Bot> ``` // Automatically generated by Digital Mars D Compiler #pragma once #include <stddef.h> #include <stdint.h> enum class Color { Blue = 0, Red = 1, Green = 2, }; namespace Classification { static Color const Deprecation = (Classification)(Color)0; static Color const Error = (Classification)(Color)1; static Color const Tip = (Classification)(Color)2; }; ``` Compiling this code: ``` In file included from foo.cpp:1: ./foobar.h:18:39: error: unexpected namespace name 'Classification': expected expression static Color const Deprecation = (Classification)(Color)0; ^ ./foobar.h:18:55: error: 'Color' does not refer to a value static Color const Deprecation = (Classification)(Color)0; ^ ./foobar.h:9:12: note: declared here enum class Color ^ ./foobar.h:19:33: error: unexpected namespace name 'Classification': expected expression static Color const Error = (Classification)(Color)1; ^ ./foobar.h:19:49: error: 'Color' does not refer to a value static Color const Error = (Classification)(Color)1; ^ ./foobar.h:9:12: note: declared here enum class Color ^ ./foobar.h:20:31: error: unexpected namespace name 'Classification': expected expression static Color const Tip = (Classification)(Color)2; ^ ./foobar.h:20:47: error: 'Color' does not refer to a value static Color const Tip = (Classification)(Color)2; ^ ./foobar.h:9:12: note: declared here enum class Color ^ 6 errors generated. ``` Marking as blocker since this is a pattern used in DMD, and dtoh is now required by the CI. -- |
Copyright © 1999-2021 by the D Language Foundation