From: Steve Naroff Date: Sat, 21 Feb 2009 19:50:43 +0000 (+0000) Subject: Warn about bogus protocol qualifiers. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8dfb0c57ddb700b163afa89e3ab160f1de26753d;p=clang 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 cce97aa48f..7ebb5a706c 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.def +++ b/include/clang/Basic/DiagnosticSemaKinds.def @@ -1402,4 +1402,6 @@ DIAG(warn_objc_array_of_interfaces, WARNING, "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 252cd2d533..acdeec6ba9 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -151,6 +151,9 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS) { // id 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 bfae348f08..2cba1fad05 100644 --- a/test/SemaObjC/protocol-archane.m +++ b/test/SemaObjC/protocol-archane.m @@ -21,4 +21,9 @@ void foo(id x) { // FIXME: provide a better diagnostic (no typedef). - (void)m2:(id 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 *obj; // expected-warning {{ignoring protocol qualifiers on non-ObjC type}}