[cfe-commits] r173184 - in /cfe/trunk: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td test/Sema/incompatible-pointer-types-error.c

Ted Kremenek kremenek at apple.com
Tue Jan 22 11:32:27 PST 2013


Author: kremenek
Date: Tue Jan 22 13:32:27 2013
New Revision: 173184

URL: http://llvm.org/viewvc/llvm-project?rev=173184&view=rev
Log:
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>.

Added:
    cfe/trunk/test/Sema/incompatible-pointer-types-error.c
Modified:
    cfe/trunk/include/clang/Basic/DiagnosticGroups.td
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=173184&r1=173183&r2=173184&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Jan 22 13:32:27 2013
@@ -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">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=173184&r1=173183&r2=173184&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Jan 22 13:32:27 2013
@@ -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"

Added: cfe/trunk/test/Sema/incompatible-pointer-types-error.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/incompatible-pointer-types-error.c?rev=173184&view=auto
==============================================================================
--- cfe/trunk/test/Sema/incompatible-pointer-types-error.c (added)
+++ cfe/trunk/test/Sema/incompatible-pointer-types-error.c Tue Jan 22 13:32:27 2013
@@ -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 *'}}
+}





More information about the cfe-commits mailing list