Skip to content
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

[BUG] Namespace-scope variable alias not rejected #378

Closed
JohelEGP opened this issue Apr 16, 2023 · 1 comment
Closed

[BUG] Namespace-scope variable alias not rejected #378

JohelEGP opened this issue Apr 16, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@JohelEGP
Copy link
Contributor

A variable alias has a deduced type. Such is prohibited for a namespace-scope variable (see #315 (comment)).
Phase 1 emits the definition, so perhaps they were never intended to be used at namespace scope.

Minimal reproducer (https://godbolt.org/z/sjoK8saP4):

v1g: == v0g;
v0g: i8 = 0;

Commands:

cppfront x.cpp2
clang++17 -std=c++2b -stdlib=libc++ -I $CPPFRONT_INCLUDE_DIR x.cpp

Expected result: A similar diagnostic to that of a global variable of deduced type.

Actual result and error:

Generated C++1.
//=== Cpp2 type declarations ====================================================


#include "cpp2util.h"


//=== Cpp2 type definitions and function declarations ===========================

#line 1 "/app/main.cpp2"
auto const& v1g = v0g;
extern cpp2::i8 v0g;
//=== Cpp2 function definitions =================================================


#line 2 "/app/main.cpp2"
cpp2::i8 v0g {0}; 
main.cpp2:1:19: error: use of undeclared identifier 'v0g'
auto const& v1g = v0g;
                  ^
1 error generated.
@JohelEGP JohelEGP added the bug Something isn't working label Apr 16, 2023
@JohelEGP
Copy link
Contributor Author

These now lower to constexpr globals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant