-
Notifications
You must be signed in to change notification settings - Fork 260
[BUG] alias: type == _ generates invalid cpp1 #357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is better left off to the C++1 compiler to diagnose. Otherwise, |
We can diagnose cases like: alias5: type == _; |
In the current implementation of cppfront (f83ca9) the following code: ```cpp alias5: type == _; ``` Generates succesfuly: ```cpp using alias5 = auto; ``` Which is invalid cpp1 code. After this change the alias to wildcard will generate the following error: ``` a 'type ==' alias declaration must be followed by a type name and not a wildcard _ ``` All regression tests pass. Closes hsutter#357
Change that provides diagnostics for a wildcard: #360 |
In the current implementation of cppfront (f83ca9) the following code: ```cpp alias5: type == _; alias6: type == auto; ``` Generates succesfuly: ```cpp using alias5 = auto; using alias6 = auto; ``` Which is invalid cpp1 code. After this change the alias to wildcard will generate the following error: ``` error: a 'type ==' alias declaration must be followed by a type name (not a wildcard _ nor auto) ``` All regression tests pass. Closes hsutter#357
Great. |
In the current implementation of cppfront (f83ca9) the following code: ```cpp alias5: type == _; alias6: type == auto; ``` Generates succesfuly: ```cpp using alias5 = auto; using alias6 = auto; ``` Which is invalid cpp1 code. After this change the alias to wildcard will generate the following error: ``` error: a 'type ==' alias declaration must be followed by a type name (not a wildcard _ nor auto) ``` All regression tests pass. Closes hsutter#357
In the current implementation of cppfront (f83ca9) the following code: ```cpp alias5: type == _; alias6: type == auto; ``` Generates succesfuly: ```cpp using alias5 = auto; using alias6 = auto; ``` Which is invalid cpp1 code. After this change the alias to wildcard will generate the following error: ``` error: a 'type ==' alias declaration must be followed by a type name (not a wildcard _ nor auto) ``` All regression tests pass. Closes #357
…tter#360) In the current implementation of cppfront (f83ca9) the following code: ```cpp alias5: type == _; alias6: type == auto; ``` Generates succesfuly: ```cpp using alias5 = auto; using alias6 = auto; ``` Which is invalid cpp1 code. After this change the alias to wildcard will generate the following error: ``` error: a 'type ==' alias declaration must be followed by a type name (not a wildcard _ nor auto) ``` All regression tests pass. Closes hsutter#357
Minimal reproduce
alias5: type == _;
passes succssfully cpp2, but generates invalid cpp1:
using alias5 = auto;
Command lines including which C++ compiler you are using
cppfront example.cpp2 -p
(build from latest mai. f83ca9b with clang++-15)
Then cpp1 compiled with
clang++-15 -Icppfront/include $1.cpp -std=c++20 -o $1
Actual result/error
Cppfront passes with
example.cpp2... ok (all Cpp2, passes safety checks)
But then clang fails with
error: 'auto' not allowed in type alias using alias5 = auto;
Expected result
Diagnostic at cpp2 side. (I guess that`s strategy, to catch whatever possible cpp2 relateed before relying on cpp1 compiler?)
Additional context
This is extreme case, because clang says
auto
is never allowed.There is other case
alias6: type == foo
whenfoo
is not defined generates correctusing alias6 = foo;
But I guess this can be separate issue, for should cppfront check if alias goes to something undefined.
The text was updated successfully, but these errors were encountered: