Warn about bogus protocol qualifiers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65241 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Basic/DiagnosticSemaKinds.def b/include/clang/Basic/DiagnosticSemaKinds.def
index cce97aa..7ebb5a7 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.def
+++ b/include/clang/Basic/DiagnosticSemaKinds.def
@@ -1402,4 +1402,6 @@
"array of interface %0 should probably be an array of pointers")
DIAG(ext_c99_array_usage, EXTENSION,
"use of C99-specific array features, accepted as an extension")
+DIAG(warn_ignoring_objc_qualifiers, WARNING,
+ "ignoring protocol qualifiers on non-ObjC type")
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 252cd2d..acdeec6 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -151,6 +151,9 @@
// id<protocol-list>
Result = Context.getObjCQualifiedIdType((ObjCProtocolDecl**)PQ,
DS.getNumProtocolQualifiers());
+ else
+ Diag(DS.getSourceRange().getBegin(),
+ diag::warn_ignoring_objc_qualifiers) << DS.getSourceRange();
}
// TypeQuals handled by caller.
break;
diff --git a/test/SemaObjC/protocol-archane.m b/test/SemaObjC/protocol-archane.m
index bfae348..2cba1fa 100644
--- a/test/SemaObjC/protocol-archane.m
+++ b/test/SemaObjC/protocol-archane.m
@@ -21,4 +21,9 @@
// FIXME: provide a better diagnostic (no typedef).
- (void)m2:(id <MyProtocol> short)arg1; // expected-error {{'short type-name' is invalid}}
-@end
\ No newline at end of file
+@end
+
+typedef int NotAnObjCObjectType;
+
+// GCC doesn't diagnose this.
+NotAnObjCObjectType <SomeProtocol> *obj; // expected-warning {{ignoring protocol qualifiers on non-ObjC type}}