Issue 170429
Summary [Modules] Deprecation warning suppressed for deprecated type used in system module template instantiation
Labels new issue
Assignees
Reporter atetubou
    **Summary**
When using Clang modules, deprecation warnings are incorrectly suppressed when a template defined in a module marked with `[system]` is instantiated with a deprecated user-defined type.

Normally, Clang suppresses warnings originating from system headers, but it should still report warnings when a system header template (like `std::make_unique`) uses a deprecated type from user code. This works correctly without modules, but fails when the system header is part of a `[system]` module.

**Reproduction**
The following shell script demonstrates the issue. It defines a module `A` marked as `[system]` containing a template `make_unique`. When `make_unique<C>()` is called with a deprecated class `C`, no warning is reported if modules are enabled.

```bash
dir=$(mktemp -d)
cd $dir

echo '
// [system] suppresses deprecated warning.
module A [system] {
 header "A.h"
}
' > module.modulemap

echo '
template<typename T>
void make_unique() {
 T();
}
' > A.h

echo '
#include "A.h"

class C {
 public:
 C() __attribute__((deprecated("","")));
};

void bar() {
 make_unique<C>();
}
' > use.cc

clang -cc1 -x c++ -emit-module -o A.pcm -fmodules module.modulemap -fmodule-name=A

echo "compile with module (Warning SUPPRESSED - Incorrect)"
clang -cc1 -x c++ -emit-obj -I. use.cc -fmodules -fmodule-map-file=module.modulemap -fmodule-file=A=A.pcm

echo "compile without module (Warning REPORTED - Correct)"
clang -cc1 -x c++ -emit-obj -I. use.cc
```

**Expected Behavior**
The deprecation warning for `C::C()` should be reported in both cases, as `C` is not a system type.

**Actual Behavior**
The warning is suppressed when compiling with the `[system]` module.

**Context**
Found in Chromium where `std::make_unique` (from a system module) was used with a deprecated type, causing build failures when modules were disabled (due to `-Werror` and the warning appearing) but passing silently when modules were enabled.

 ([source](https://crbug.com/462591003))




_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to