Issue 121066
Summary diagnostic: "module not found" is reported for missing semicolon after import module statement
Labels
Assignees
Reporter 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
)

```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to