[llvm-bugs] [Bug 51187] New: -Wno-error not honored when modules are enabled

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jul 23 10:08:13 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=51187

            Bug ID: 51187
           Summary: -Wno-error not honored when modules are enabled
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Modules
          Assignee: unassignedclangbugs at nondot.org
          Reporter: lxfind at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Created attachment 25059
  --> https://bugs.llvm.org/attachment.cgi?id=25059&action=edit
Reproduce source files

When compiling with -fmodules, Clang seems to ignore the -Wno-error settings.
I attached a repro, if you run make on it, it will error out with:

In module 'module_a' imported from a.cpp:3:
./a.h:26:10: error: 'a<int>' is deprecated: THIS WILL WARN
[-Werror,-Wdeprecated-declarations]
  return a(t);
         ^
a.cpp:6:10: note: in instantiation of function template specialization 'b<int>'
requested here
  return b<int>(0) + c<int>(0);
         ^
./a.h:20:3: note: 'a<int>' has been explicitly marked deprecated here
[[deprecated("THIS WILL WARN")]] enable_if_t<true, T> a(T t) {



For reference, the content of the attachment is listed below as well:
*** a.h ***
template <bool B, class T = void>
struct enable_if {};

template <class T>
struct enable_if<true, T> {
  typedef T type;
};

template <bool B, class T = void>
using enable_if_t = typename enable_if<B, T>::type;

template <typename T>
enable_if_t<false, T> a(T t) {
  return t;
}

template <typename T>
[[deprecated("THIS WILL WARN")]] enable_if_t<true, T> a(T t) {
  return t;
}

template <typename T>
T b(T t) {
  return a(t);
}

template <typename T>
[[deprecated("THIS WON'T WARN")]] T c(T t) {
  return t;
}


*** a.cpp ***
#include "a.h"

int main() {
  return b<int>(0) + c<int>(0);
}

*** module.modulemap ***
module "module_a" {
  explicit module "a.h" {
    header "a.h"
    export *
  }
}

*** Makefile ***
CLANG=clang

fail:
        ${CLANG} -fmodules -Werror -Wdeprecated-declarations -Xclang
-emit-module -fmodule-name=module_a -x c++-header -I. module.modulemap
        ${CLANG} -Wno-error -Wno-error=deprecated-declarations
-Wno-deprecated-declarations -fmodules -fmodule-map-file=module.modulemap
-fmodule-file=module_a=module_a.pcm a.cpp

clean:
        rm -f *.out *.pcm

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210723/517de113/attachment.html>


More information about the llvm-bugs mailing list