Split "discards qualifiers" warnings of -Wincompatible-pointer-types into subgroup.
This allows users to promote -Wincompatible-pointer-type warnings to
errors but keep those for "discard qualifiers" as warnings (if they
so desire).
Addresses <rdar://problem/13062738>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173184 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Basic/DiagnosticGroups.td b/include/clang/Basic/DiagnosticGroups.td
index 8a2d596..7709be1 100644
--- a/include/clang/Basic/DiagnosticGroups.td
+++ b/include/clang/Basic/DiagnosticGroups.td
@@ -124,7 +124,11 @@
def DistributedObjectModifiers : DiagGroup<"distributed-object-modifiers">;
def IgnoredQualifiers : DiagGroup<"ignored-qualifiers">;
def : DiagGroup<"import">;
-def IncompatiblePointerTypes : DiagGroup<"incompatible-pointer-types">;
+def IncompatiblePointerTypesDiscardsQualifiers
+ : DiagGroup<"incompatible-pointer-types-discards-qualifiers">;
+def IncompatiblePointerTypes
+ : DiagGroup<"incompatible-pointer-types",
+ [IncompatiblePointerTypesDiscardsQualifiers]>;
def IncompleteUmbrella : DiagGroup<"incomplete-umbrella">;
def InvalidNoreturn : DiagGroup<"invalid-noreturn">;
def InvalidSourceEncoding : DiagGroup<"invalid-source-encoding">;
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index 3b37658..053f392 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -4902,7 +4902,7 @@
"sending to parameter of different type}0,1"
"|%diff{casting $ to type $|casting between types}0,1}2"
" discards qualifiers">,
- InGroup<IncompatiblePointerTypes>;
+ InGroup<IncompatiblePointerTypesDiscardsQualifiers>;
def ext_nested_pointer_qualifier_mismatch : ExtWarn<
"%select{%diff{assigning to $ from $|assigning to different types}0,1"
"|%diff{passing $ to parameter of type $|"
@@ -4916,7 +4916,7 @@
"sending to parameter of different type}0,1"
"|%diff{casting $ to type $|casting between types}0,1}2"
" discards qualifiers in nested pointer types">,
- InGroup<IncompatiblePointerTypes>;
+ InGroup<IncompatiblePointerTypesDiscardsQualifiers>;
def warn_incompatible_vectors : Warning<
"incompatible vector types "
"%select{%diff{assigning to $ from $|assigning to different types}0,1"
diff --git a/test/Sema/incompatible-pointer-types-error.c b/test/Sema/incompatible-pointer-types-error.c
new file mode 100644
index 0000000..fda45cf
--- /dev/null
+++ b/test/Sema/incompatible-pointer-types-error.c
@@ -0,0 +1,16 @@
+// RUN: %clang -fsyntax-only %s -Xclang -verify -Werror=incompatible-pointer-types -Wno-error=incompatible-pointer-types-discards-qualifiers
+
+// This test ensures that the subgroup of -Wincompatible-pointer-types warnings that
+// concern discarding qualifers can be promoted (or not promoted) to an error *separately* from
+// the other -Wincompatible-pointer-type warnings.
+//
+// <rdar://problem/13062738>
+//
+
+void foo(char *s); // expected-note {{passing argument to parameter 's' here}}
+void baz(int *s); // expected-note {{passing argument to parameter 's' here}}
+
+void bar(const char *s) {
+ foo(s); // expected-warning {{passing 'const char *' to parameter of type 'char *' discards qualifiers}}
+ baz(s); // expected-error {{incompatible pointer types passing 'const char *' to parameter of type 'int *'}}
+}