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

diagnostic: "module not found" is reported for missing semicolon after import module statement #121066

Closed
zowers opened this issue Dec 24, 2024 · 1 comment
Assignees
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer clang:modules C++20 modules and Clang Header Modules

Comments

@zowers
Copy link

zowers commented Dec 24, 2024

clang++-19.1 gives incorrect diagnostic when import module statement is not followed by semicolon:
e.g.

import mod1
//         ^ note no semicolon

errors with:

/opt/compiler-explorer/clang-19.1.0/bin/clang++ --gcc-toolchain=/opt/compiler-explorer/gcc-14.2.0   -fcolor-diagnostics -fno-crash-diagnostics -g -std=gnu++20 -Wno-private-header -MD -MT CMakeFiles/test_mod.dir/main.cpp.o -MF CMakeFiles/test_mod.dir/main.cpp.o.d @CMakeFiles/test_mod.dir/main.cpp.o.modmap -o CMakeFiles/test_mod.dir/main.cpp.o -c /app/main.cpp
main.cpp:1:8: fatal error: module 'mod1' not found
    1 | import mod1
      | ~~~~~~~^~~~

while gcc correctly reports

main.cpp:1:12: error: expected ';' before end of line
    1 | import mod1
      |            ^
      |            ;

reproduce link: https://godbolt.org/z/6x3KW6Gx9
main.cpp:

import mod1
//         ^ note no semicolon
int main() {
    return f();
}

mod1.cppm

export module mod1;
export int f()
{
    return 1;
}

CMakeCache.txt

cmake_minimum_required(VERSION 3.28)
project(test_mod)
set(CMAKE_CXX_STANDARD 20)
add_executable(test_mod)
target_sources(test_mod
  PUBLIC
    main.cpp
)
target_sources(test_mod
  PUBLIC
    FILE_SET CXX_MODULES
    FILES
        mod1.cppm
)

@EugeneZelenko EugeneZelenko added clang:modules C++20 modules and Clang Header Modules clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer and removed new issue labels Dec 25, 2024
@llvmbot
Copy link
Member

llvmbot commented Dec 25, 2024

@llvm/issue-subscribers-clang-modules

Author: Alexander Petrov (zowers)

clang++-19.1 gives incorrect diagnostic when import module statement is not followed by semicolon: e.g. ``` import mod1 // ^ note no semicolon ``` errors with: ``` /opt/compiler-explorer/clang-19.1.0/bin/clang++ --gcc-toolchain=/opt/compiler-explorer/gcc-14.2.0 -fcolor-diagnostics -fno-crash-diagnostics -g -std=gnu++20 -Wno-private-header -MD -MT CMakeFiles/test_mod.dir/main.cpp.o -MF CMakeFiles/test_mod.dir/main.cpp.o.d @CMakeFiles/test_mod.dir/main.cpp.o.modmap -o CMakeFiles/test_mod.dir/main.cpp.o -c /app/main.cpp main.cpp:1:8: fatal error: module 'mod1' not found 1 | import mod1 | ~~~~~~~^~~~ ``` while gcc correctly reports ``` main.cpp:1:12: error: expected ';' before end of line 1 | import mod1 | ^ | ; ``` reproduce link: https://godbolt.org/z/6x3KW6Gx9 main.cpp: ``` import mod1 // ^ note no semicolon int main() { return f(); } ``` mod1.cppm ``` export module mod1; export int f() { return 1; } ``` CMakeCache.txt ``` cmake_minimum_required(VERSION 3.28) project(test_mod) set(CMAKE_CXX_STANDARD 20) add_executable(test_mod) target_sources(test_mod PUBLIC main.cpp ) target_sources(test_mod PUBLIC FILE_SET CXX_MODULES FILES mod1.cppm )
</details>

@ChuanqiXu9 ChuanqiXu9 added clang:tooling LibTooling and removed clang:tooling LibTooling labels Dec 25, 2024
@ChuanqiXu9 ChuanqiXu9 self-assigned this Dec 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer clang:modules C++20 modules and Clang Header Modules
Projects
None yet
Development

No branches or pull requests

4 participants