r178218 - For -Wignored-qualifiers, don't warn on qualifiers which we acquire via a

Richard Smith richard-llvm at metafoo.co.uk
Wed Mar 27 20:27:52 PDT 2013


Author: rsmith
Date: Wed Mar 27 22:27:52 2013
New Revision: 178218

URL: http://llvm.org/viewvc/llvm-project?rev=178218&view=rev
Log:
For -Wignored-qualifiers, don't warn on qualifiers which we acquire via a
typedef. Also don't warn on the _Atomic type specifier, just on the _Atomic
type qualifier.

Modified:
    cfe/trunk/lib/Sema/SemaType.cpp
    cfe/trunk/test/Sema/return.c
    cfe/trunk/test/SemaCXX/return.cpp

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=178218&r1=178217&r2=178218&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Wed Mar 27 22:27:52 2013
@@ -1888,7 +1888,9 @@ static void diagnoseIgnoredQualifiers(
     SourceLocation VolatileQualLoc = SourceLocation(),
     SourceLocation RestrictQualLoc = SourceLocation(),
     SourceLocation AtomicQualLoc = SourceLocation()) {
-  assert(Quals && "no qualifiers to diagnose");
+  if (!Quals)
+    return;
+
   const SourceManager &SM = S.getSourceManager();
 
   struct Qual {
@@ -1933,12 +1935,10 @@ static void diagnoseIgnoredQualifiers(
 static void diagnoseIgnoredFunctionQualifiers(Sema &S, QualType RetTy,
                                               Declarator &D,
                                               unsigned FunctionChunkIndex) {
-  unsigned AtomicQual = RetTy->isAtomicType() ? DeclSpec::TQ_atomic : 0;
-
   if (D.getTypeObject(FunctionChunkIndex).Fun.hasTrailingReturnType()) {
     // FIXME: TypeSourceInfo doesn't preserve location information for
     // qualifiers.
-    diagnoseIgnoredQualifiers(S, RetTy.getCVRQualifiers() | AtomicQual,
+    diagnoseIgnoredQualifiers(S, RetTy.getLocalCVRQualifiers(),
                               D.getIdentifierLoc());
     return;
   }
@@ -1970,6 +1970,7 @@ static void diagnoseIgnoredFunctionQuali
     case DeclaratorChunk::MemberPointer:
       // FIXME: We can't currently provide an accurate source location and a
       // fix-it hint for these.
+      unsigned AtomicQual = RetTy->isAtomicType() ? DeclSpec::TQ_atomic : 0;
       diagnoseIgnoredQualifiers(S, RetTy.getCVRQualifiers() | AtomicQual,
                                 D.getIdentifierLoc());
       return;
@@ -1986,7 +1987,7 @@ static void diagnoseIgnoredFunctionQuali
 
   // Just parens all the way out to the decl specifiers. Diagnose any qualifiers
   // which are present there.
-  diagnoseIgnoredQualifiers(S, D.getDeclSpec().getTypeQualifiers() | AtomicQual,
+  diagnoseIgnoredQualifiers(S, D.getDeclSpec().getTypeQualifiers(),
                             D.getIdentifierLoc(),
                             D.getDeclSpec().getConstSpecLoc(),
                             D.getDeclSpec().getVolatileSpecLoc(),

Modified: cfe/trunk/test/Sema/return.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/return.c?rev=178218&r1=178217&r2=178218&view=diff
==============================================================================
--- cfe/trunk/test/Sema/return.c (original)
+++ cfe/trunk/test/Sema/return.c Wed Mar 27 22:27:52 2013
@@ -244,6 +244,11 @@ const int ignored_c_quals(); // expected
 const volatile int ignored_cv_quals(); // expected-warning{{'const volatile' type qualifiers on return type have no effect}}
 char* const volatile restrict ignored_cvr_quals(); // expected-warning{{'const volatile restrict' type qualifiers on return type have no effect}}
 
+typedef const int CI;
+CI ignored_quals_typedef();
+
+const CI ignored_quals_typedef_2(); // expected-warning{{'const' type qualifier}}
+
 // Test that for switch(enum) that if the switch statement covers all the cases
 // that we don't consider that for -Wreturn-type.
 enum Cases { C1, C2, C3, C4 };

Modified: cfe/trunk/test/SemaCXX/return.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/return.cpp?rev=178218&r1=178217&r2=178218&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/return.cpp (original)
+++ cfe/trunk/test/SemaCXX/return.cpp Wed Mar 27 22:27:52 2013
@@ -55,8 +55,7 @@ mixed_ret(); // expected-warning {{'vola
 const int volatile // expected-warning {{'const volatile' type qualifiers on return type have no effect}}
     (((parens())));
 
-_Atomic(int)
-    atomic(); // expected-warning {{'_Atomic' type qualifier on return type has no effect}}
+_Atomic(int) atomic();
 
 _Atomic // expected-warning {{'_Atomic' type qualifier on return type has no effect}}
     int





More information about the cfe-commits mailing list