Add -Wignored-pragma-intrinsic flag
authorAlbert Gutowski <agutowski@google.com>
Wed, 21 Sep 2016 20:19:21 +0000 (20:19 +0000)
committerAlbert Gutowski <agutowski@google.com>
Wed, 21 Sep 2016 20:19:21 +0000 (20:19 +0000)
Summary: People might want to receive warnings about pragmas but not about intrinsics that are implemented in intrin.h.

Reviewers: thakis, hans

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D24775

llvm-svn: 282108

clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/test/Preprocessor/pragma_microsoft.c

index dc3d1ba..110550e 100644 (file)
@@ -439,8 +439,9 @@ def UninitializedSometimes : DiagGroup<"sometimes-uninitialized">;
 def UninitializedStaticSelfInit : DiagGroup<"static-self-init">;
 def Uninitialized  : DiagGroup<"uninitialized", [UninitializedSometimes,
                                                  UninitializedStaticSelfInit]>;
+def IgnoredPragmaIntrinsic : DiagGroup<"ignored-pragma-intrinsic">;
 def UnknownPragmas : DiagGroup<"unknown-pragmas">;
-def IgnoredPragmas : DiagGroup<"ignored-pragmas">;
+def IgnoredPragmas : DiagGroup<"ignored-pragmas", [IgnoredPragmaIntrinsic]>;
 def Pragmas : DiagGroup<"pragmas", [UnknownPragmas, IgnoredPragmas]>;
 def UnknownWarningOption : DiagGroup<"unknown-warning-option">;
 def NSobjectAttribute : DiagGroup<"NSObject-attribute">;
index ebaaf30..66fd5c1 100644 (file)
@@ -914,7 +914,7 @@ def warn_pragma_pack_malformed : Warning<
 // - #pragma intrinsic
 def warn_pragma_intrinsic_builtin : Warning<
   "%0 is not a recognized builtin%select{|; consider including <intrin.h> to access non-builtin intrinsics}1">,
-  InGroup<IgnoredPragmas>;
+  InGroup<IgnoredPragmaIntrinsic>;
 // - #pragma unused
 def warn_pragma_unused_expected_var : Warning<
   "expected '#pragma unused' argument to be a variable name">,
index 31b907a..b256b2b 100644 (file)
@@ -178,3 +178,15 @@ void g() {}
 #pragma intrinsic(memset) // no-warning
 #undef __INTRIN_H
 #pragma intrinsic(asdf) // expected-warning {{'asdf' is not a recognized builtin; consider including <intrin.h>}}
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wignored-pragma-intrinsic"
+#pragma intrinsic(asdf) // no-warning
+#pragma clang diagnostic pop
+#pragma intrinsic(asdf) // expected-warning {{'asdf' is not a recognized builtin; consider including <intrin.h>}}
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wignored-pragmas"
+#pragma intrinsic(asdf) // no-warning
+#pragma clang diagnostic pop
+#pragma intrinsic(asdf) // expected-warning {{'asdf' is not a recognized builtin; consider including <intrin.h>}}