[PATCH] D41080: Don't trigger -Wuser-defined-literals for system headers
Dimitry Andric via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 11 13:33:25 PST 2017
dim updated this revision to Diff 126436.
dim added a comment.
Add a test case.
Repository:
rC Clang
https://reviews.llvm.org/D41080
Files:
lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/no-warn-user-defined-literals-in-system-headers.cpp
test/SemaCXX/no-warn-user-defined-literals-in-system-headers.h
Index: test/SemaCXX/no-warn-user-defined-literals-in-system-headers.h
===================================================================
--- /dev/null
+++ test/SemaCXX/no-warn-user-defined-literals-in-system-headers.h
@@ -0,0 +1,2 @@
+// Header for no-warn-user-defined-literals-in-system-headers.cpp
+void operator "" foo (const char *);
Index: test/SemaCXX/no-warn-user-defined-literals-in-system-headers.cpp
===================================================================
--- /dev/null
+++ test/SemaCXX/no-warn-user-defined-literals-in-system-headers.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wsystem-headers -isystem %S %s
+
+#include <no-warn-user-defined-literals-in-system-headers.h>
+
+void operator "" bar(long double); // expected-warning{{user-defined literal suffixes not starting with '_' are reserved}}
Index: lib/Sema/SemaDeclCXX.cpp
===================================================================
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -13076,7 +13076,8 @@
StringRef LiteralName
= FnDecl->getDeclName().getCXXLiteralIdentifier()->getName();
- if (LiteralName[0] != '_') {
+ if (LiteralName[0] != '_' &&
+ !getSourceManager().isInSystemHeader(FnDecl->getLocation())) {
// C++11 [usrlit.suffix]p1:
// Literal suffix identifiers that do not start with an underscore
// are reserved for future standardization.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41080.126436.patch
Type: text/x-patch
Size: 1422 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171211/10454f5d/attachment-0001.bin>
More information about the cfe-commits
mailing list