[cfe-commits] r108234 - in /cfe/trunk: include/clang/AST/ include/clang/Basic/ lib/AST/ lib/Rewrite/ lib/Sema/ test/CodeGen/ test/Sema/ test/SemaCXX/ test/SemaTemplate/

Douglas Gregor dgregor at apple.com
Tue Jul 13 01:18:22 PDT 2010


Author: dgregor
Date: Tue Jul 13 03:18:22 2010
New Revision: 108234

URL: http://llvm.org/viewvc/llvm-project?rev=108234&view=rev
Log:
When forming a function call or message send expression, be sure to
strip cv-qualifiers from the expression's type when the language calls
for it: in C, that's all the time, while C++ only does it for
non-class types. 

Centralized the computation of the call expression type in
QualType::getCallResultType() and some helper functions in other nodes
(FunctionDecl, ObjCMethodDecl, FunctionType), and updated all relevant
callers of getResultType() to getCallResultType().

Fixes PR7598 and PR7463, along with a bunch of getResultType() call
sites that weren't stripping references off the result type (nothing
stripped cv-qualifiers properly before this change).


Modified:
    cfe/trunk/include/clang/AST/Decl.h
    cfe/trunk/include/clang/AST/DeclObjC.h
    cfe/trunk/include/clang/AST/Type.h
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/AST/Expr.cpp
    cfe/trunk/lib/AST/Type.cpp
    cfe/trunk/lib/Rewrite/RewriteObjC.cpp
    cfe/trunk/lib/Sema/SemaChecking.cpp
    cfe/trunk/lib/Sema/SemaCodeComplete.cpp
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/lib/Sema/SemaExprCXX.cpp
    cfe/trunk/lib/Sema/SemaExprObjC.cpp
    cfe/trunk/lib/Sema/SemaInit.cpp
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/lib/Sema/SemaType.cpp
    cfe/trunk/lib/Sema/TreeTransform.h
    cfe/trunk/test/CodeGen/volatile.c
    cfe/trunk/test/Sema/block-call.c
    cfe/trunk/test/Sema/block-return.c
    cfe/trunk/test/Sema/struct-cast.c
    cfe/trunk/test/SemaCXX/ambig-user-defined-conversions.cpp
    cfe/trunk/test/SemaCXX/conditional-expr.cpp
    cfe/trunk/test/SemaCXX/friend.cpp
    cfe/trunk/test/SemaTemplate/deduction.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=108234&r1=108233&r2=108234&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue Jul 13 03:18:22 2010
@@ -1382,6 +1382,12 @@
   QualType getResultType() const {
     return getType()->getAs<FunctionType>()->getResultType();
   }
+  
+  /// \brief Determine the type of an expression that calls this function.
+  QualType getCallResultType() const {
+    return getType()->getAs<FunctionType>()->getCallResultType(getASTContext());
+  }
+                       
   StorageClass getStorageClass() const { return StorageClass(SClass); }
   void setStorageClass(StorageClass SC) { SClass = SC; }
 

Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=108234&r1=108233&r2=108234&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Tue Jul 13 03:18:22 2010
@@ -239,6 +239,12 @@
   QualType getResultType() const { return MethodDeclType; }
   void setResultType(QualType T) { MethodDeclType = T; }
 
+  /// \brief Determine the type of an expression that sends a message to this 
+  /// function.
+  QualType getSendResultType() const {
+    return getResultType().getCallResultType(getASTContext());
+  }
+  
   TypeSourceInfo *getResultTypeSourceInfo() const { return ResultTInfo; }
   void setResultTypeSourceInfo(TypeSourceInfo *TInfo) { ResultTInfo = TInfo; }
 

Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=108234&r1=108233&r2=108234&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Tue Jul 13 03:18:22 2010
@@ -629,6 +629,14 @@
   bool isAtLeastAsQualifiedAs(QualType Other) const;
   QualType getNonReferenceType() const;
 
+  /// \brief Determine the type of an expression that calls a function of
+  /// with the given result type.
+  ///                       
+  /// This routine removes a top-level reference (since there are no 
+  /// expressions of reference type) and deletes top-level cvr-qualifiers
+  /// from non-class types (in C++) or all types (in C).
+  QualType getCallResultType(ASTContext &Context) const;
+  
   /// getDesugaredType - Return the specified type with any "sugar" removed from
   /// the type.  This takes off typedefs, typeof's etc.  If the outer level of
   /// the type is already concrete, it returns it unmodified.  This is similar
@@ -1888,6 +1896,7 @@
 public:
 
   QualType getResultType() const { return ResultType; }
+  
   unsigned getRegParmType() const { return RegParm; }
   bool getNoReturnAttr() const { return NoReturn; }
   CallingConv getCallConv() const { return (CallingConv)CallConv; }
@@ -1895,6 +1904,12 @@
     return ExtInfo(NoReturn, RegParm, (CallingConv)CallConv);
   }
 
+  /// \brief Determine the type of an expression that calls a function of
+  /// this type.
+  QualType getCallResultType(ASTContext &Context) const { 
+    return getResultType().getCallResultType(Context);
+  }
+
   static llvm::StringRef getNameForCallConv(CallingConv CC);
 
   static bool classof(const Type *T) {

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=108234&r1=108233&r2=108234&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Jul 13 03:18:22 2010
@@ -120,6 +120,8 @@
   "use of out-of-scope declaration of %0">;
 def err_inline_non_function : Error<
   "'inline' can only appear on functions">;
+def warn_qual_return_type : Warning< 
+  "type qualifier on return type has no effect">;
 
 def warn_decl_shadow :
   Warning<"declaration shadows a %select{"

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=108234&r1=108233&r2=108234&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Tue Jul 13 03:18:22 2010
@@ -576,7 +576,10 @@
     CalleeType = FnTypePtr->getPointeeType();
   else if (const BlockPointerType *BPT = CalleeType->getAs<BlockPointerType>())
     CalleeType = BPT->getPointeeType();
-
+  else if (const MemberPointerType *MPT
+                                      = CalleeType->getAs<MemberPointerType>())
+    CalleeType = MPT->getPointeeType();
+    
   const FunctionType *FnType = CalleeType->getAs<FunctionType>();
   return FnType->getResultType();
 }

Modified: cfe/trunk/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=108234&r1=108233&r2=108234&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Tue Jul 13 03:18:22 2010
@@ -992,6 +992,22 @@
 
 void FunctionType::ANCHOR() {} // Key function for FunctionType.
 
+QualType QualType::getCallResultType(ASTContext &Context) const {
+  if (const ReferenceType *RefType = getTypePtr()->getAs<ReferenceType>())
+    return RefType->getPointeeType();
+  
+  // C++0x [basic.lval]:
+  //   Class prvalues can have cv-qualified types; non-class prvalues always 
+  //   have cv-unqualified types.
+  //
+  // See also C99 6.3.2.1p2.
+  if (!Context.getLangOptions().CPlusPlus ||
+      !getTypePtr()->isDependentType() && !getTypePtr()->isRecordType())
+    return getUnqualifiedType();
+  
+  return *this;
+}
+
 llvm::StringRef FunctionType::getNameForCallConv(CallingConv CC) {
   switch (CC) {
   case CC_Default: llvm_unreachable("no name for default cc");

Modified: cfe/trunk/lib/Rewrite/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/RewriteObjC.cpp?rev=108234&r1=108233&r2=108234&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/RewriteObjC.cpp (original)
+++ cfe/trunk/lib/Rewrite/RewriteObjC.cpp Tue Jul 13 03:18:22 2010
@@ -2113,8 +2113,8 @@
   const FunctionType *FT = msgSendType->getAs<FunctionType>();
 
   CallExpr *Exp =  
-    new (Context) CallExpr(*Context, ICE, args, nargs, FT->getResultType(),
-                                EndLoc);
+    new (Context) CallExpr(*Context, ICE, args, nargs, 
+                           FT->getCallResultType(*Context), EndLoc);
   return Exp;
 }
 

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=108234&r1=108233&r2=108234&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Jul 13 03:18:22 2010
@@ -561,7 +561,7 @@
   TheCall->setCallee(PromotedCall);
 
   // Change the result type of the call to match the result type of the decl.
-  TheCall->setType(NewBuiltinDecl->getResultType());
+  TheCall->setType(NewBuiltinDecl->getCallResultType());
 
   // If the value type was converted to an integer when processing the
   // arguments (e.g. void* -> int), we need to convert the result back.

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=108234&r1=108233&r2=108234&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Tue Jul 13 03:18:22 2010
@@ -567,11 +567,11 @@
   
   QualType T;
   if (FunctionDecl *Function = dyn_cast<FunctionDecl>(ND))
-    T = Function->getResultType();
+    T = Function->getCallResultType();
   else if (ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(ND))
-    T = Method->getResultType();
+    T = Method->getSendResultType();
   else if (FunctionTemplateDecl *FunTmpl = dyn_cast<FunctionTemplateDecl>(ND))
-    T = FunTmpl->getTemplatedDecl()->getResultType();
+    T = FunTmpl->getTemplatedDecl()->getCallResultType();
   else if (EnumConstantDecl *Enumerator = dyn_cast<EnumConstantDecl>(ND))
     T = C.getTypeDeclType(cast<EnumDecl>(Enumerator->getDeclContext()));
   else if (ObjCPropertyDecl *Property = dyn_cast<ObjCPropertyDecl>(ND))

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=108234&r1=108233&r2=108234&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Jul 13 03:18:22 2010
@@ -3004,7 +3004,7 @@
         QualType PType;
 
         if (Getter)
-          PType = Getter->getResultType();
+          PType = Getter->getSendResultType();
         else
           // Get the expression type from Setter's incoming parameter.
           PType = (*(Setter->param_end() -1))->getType();
@@ -3180,7 +3180,7 @@
           return ExprError();
 
         return Owned(ObjCMessageExpr::Create(Context,
-                                     OMD->getResultType().getNonReferenceType(),
+                                             OMD->getSendResultType(),
                                              OpLoc, BaseExpr, Sel,
                                              OMD, NULL, 0, MemberLoc));
       }
@@ -3575,7 +3575,7 @@
           BO->getOpcode() == BinaryOperator::PtrMemI) {
         if (const FunctionProtoType *FPT
                                 = BO->getType()->getAs<FunctionProtoType>()) {
-          QualType ResultTy = FPT->getResultType().getNonReferenceType();
+          QualType ResultTy = FPT->getCallResultType(Context);
 
           ExprOwningPtr<CXXMemberCallExpr>
             TheCall(this, new (Context) CXXMemberCallExpr(Context, BO, Args,
@@ -3665,7 +3665,7 @@
     return ExprError();
 
   // We know the result type of the call, set it.
-  TheCall->setType(FuncT->getResultType().getNonReferenceType());
+  TheCall->setType(FuncT->getCallResultType(Context));
 
   if (const FunctionProtoType *Proto = dyn_cast<FunctionProtoType>(FuncT)) {
     if (ConvertArgumentsForCall(&*TheCall, Fn, FDecl, Proto, Args, NumArgs,

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=108234&r1=108233&r2=108234&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Jul 13 03:18:22 2010
@@ -3032,7 +3032,7 @@
   MemberExpr *ME = 
       new (Context) MemberExpr(Exp, /*IsArrow=*/false, Method, 
                                SourceLocation(), Method->getType());
-  QualType ResultType = Method->getResultType().getNonReferenceType();
+  QualType ResultType = Method->getCallResultType();
   MarkDeclarationReferenced(Exp->getLocStart(), Method);
   CXXMemberCallExpr *CE =
     new (Context) CXXMemberCallExpr(Context, ME, 0, 0, ResultType,

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=108234&r1=108233&r2=108234&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Tue Jul 13 03:18:22 2010
@@ -207,7 +207,7 @@
     return false;
   }
 
-  ReturnType = Method->getResultType().getNonReferenceType();
+  ReturnType = Method->getSendResultType();
 
   unsigned NumNamedArgs = Sel.getNumArgs();
   // Method might have more arguments than selector indicates. This is due
@@ -346,7 +346,7 @@
     Selector Sel = PP.getSelectorTable().getNullarySelector(Member);
     ObjCMethodDecl *Getter = IFace->lookupInstanceMethod(Sel);
     if (DiagnosePropertyAccessorMismatch(PD, Getter, MemberLoc))
-      ResTy = Getter->getResultType();
+      ResTy = Getter->getSendResultType();
     return Owned(new (Context) ObjCPropertyRefExpr(PD, ResTy,
                                                    MemberLoc, BaseExpr));
   }
@@ -402,7 +402,7 @@
 
   if (Getter) {
     QualType PType;
-    PType = Getter->getResultType();
+    PType = Getter->getSendResultType();
     return Owned(new (Context) ObjCImplicitSetterGetterRefExpr(Getter, PType,
                                     Setter, MemberLoc, BaseExpr));
   }
@@ -510,7 +510,7 @@
     QualType PType;
 
     if (Getter)
-      PType = Getter->getResultType();
+      PType = Getter->getSendResultType();
     else {
       for (ObjCMethodDecl::param_iterator PI = Setter->param_begin(),
            E = Setter->param_end(); PI != E; ++PI)

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=108234&r1=108233&r2=108234&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Tue Jul 13 03:18:22 2010
@@ -2942,7 +2942,7 @@
   }
 
   // Add the user-defined conversion step that calls the conversion function.
-  QualType ConvType = Function->getResultType().getNonReferenceType();
+  QualType ConvType = Function->getCallResultType();
   if (ConvType->getAs<RecordType>()) {
     // If we're converting to a class type, there may be an copy if
     // the resulting temporary object (possible to create an object of

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=108234&r1=108233&r2=108234&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Tue Jul 13 03:18:22 2010
@@ -6668,7 +6668,7 @@
       DiagnoseUseOfDecl(Best->FoundDecl, OpLoc);
 
       // Determine the result type
-      QualType ResultTy = FnDecl->getResultType().getNonReferenceType();
+      QualType ResultTy = FnDecl->getCallResultType();
 
       // Build the actual expression node.
       Expr *FnExpr = new (Context) DeclRefExpr(FnDecl, FnDecl->getType(),
@@ -6875,8 +6875,8 @@
 
         // Determine the result type
         QualType ResultTy
-          = FnDecl->getType()->getAs<FunctionType>()->getResultType();
-        ResultTy = ResultTy.getNonReferenceType();
+          = FnDecl->getType()->getAs<FunctionType>()
+                                                ->getCallResultType(Context);
 
         // Build the actual expression node.
         Expr *FnExpr = new (Context) DeclRefExpr(FnDecl, FnDecl->getType(),
@@ -7032,8 +7032,8 @@
 
         // Determine the result type
         QualType ResultTy
-          = FnDecl->getType()->getAs<FunctionType>()->getResultType();
-        ResultTy = ResultTy.getNonReferenceType();
+          = FnDecl->getType()->getAs<FunctionType>()
+                                                  ->getCallResultType(Context);
 
         // Build the actual expression node.
         Expr *FnExpr = new (Context) DeclRefExpr(FnDecl, FnDecl->getType(),
@@ -7221,7 +7221,7 @@
   ExprOwningPtr<CXXMemberCallExpr>
     TheCall(this, new (Context) CXXMemberCallExpr(Context, MemExprE, Args,
                                                   NumArgs,
-                                  Method->getResultType().getNonReferenceType(),
+                                  Method->getCallResultType(),
                                   RParenLoc));
 
   // Check for a valid return type.
@@ -7436,7 +7436,7 @@
 
   // Once we've built TheCall, all of the expressions are properly
   // owned.
-  QualType ResultTy = Method->getResultType().getNonReferenceType();
+  QualType ResultTy = Method->getCallResultType();
   ExprOwningPtr<CXXOperatorCallExpr>
     TheCall(this, new (Context) CXXOperatorCallExpr(Context, OO_Call, NewFn,
                                                     MethodArgs, NumArgs + 1,
@@ -7592,7 +7592,7 @@
                                            SourceLocation());
   UsualUnaryConversions(FnExpr);
   
-  QualType ResultTy = Method->getResultType().getNonReferenceType();
+  QualType ResultTy = Method->getCallResultType();
   ExprOwningPtr<CXXOperatorCallExpr> 
     TheCall(this, new (Context) CXXOperatorCallExpr(Context, OO_Arrow, FnExpr, 
                                                     &Base, 1, ResultTy, OpLoc));

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=108234&r1=108233&r2=108234&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Tue Jul 13 03:18:22 2010
@@ -818,7 +818,7 @@
       << T->isFunctionType() << T;
     return QualType();
   }
-
+       
   bool Invalid = false;
   for (unsigned Idx = 0; Idx < NumParamTypes; ++Idx) {
     QualType ParamType = adjustParameterType(ParamTypes[Idx]);
@@ -1129,6 +1129,31 @@
         D.setInvalidType(true);
       }
 
+      // cv-qualifiers on return types are pointless except when the type is a
+      // class type in C++.
+      if (T.getCVRQualifiers() && D.getDeclSpec().getTypeQualifiers() &&
+          (!getLangOptions().CPlusPlus ||
+           (!T->isDependentType() && !T->isRecordType()))) {
+        unsigned Quals = D.getDeclSpec().getTypeQualifiers();
+        SourceLocation Loc;
+        if (Quals & Qualifiers::Const)
+          Loc = D.getDeclSpec().getConstSpecLoc();
+        else if (Quals & Qualifiers::Volatile)
+          Loc = D.getDeclSpec().getVolatileSpecLoc();
+        else {
+          assert((Quals & Qualifiers::Restrict) && "Unknown type qualifier");
+          Loc = D.getDeclSpec().getRestrictSpecLoc();
+        }
+        
+        SemaDiagnosticBuilder DB = Diag(Loc, diag::warn_qual_return_type);
+        if (Quals & Qualifiers::Const)
+          DB << FixItHint::CreateRemoval(D.getDeclSpec().getConstSpecLoc());
+        if (Quals & Qualifiers::Volatile)
+          DB << FixItHint::CreateRemoval(D.getDeclSpec().getVolatileSpecLoc());
+        if (Quals & Qualifiers::Restrict)
+          DB << FixItHint::CreateRemoval(D.getDeclSpec().getRestrictSpecLoc());
+      }
+      
       if (getLangOptions().CPlusPlus && D.getDeclSpec().isTypeSpecOwned()) {
         // C++ [dcl.fct]p6:
         //   Types shall not be defined in return or parameter types.

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=108234&r1=108233&r2=108234&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Tue Jul 13 03:18:22 2010
@@ -1952,7 +1952,7 @@
     Expr **Subs = (Expr **)SubExprs.release();
     CallExpr *TheCall = new (SemaRef.Context) CallExpr(SemaRef.Context, Callee,
                                                        Subs, NumSubExprs,
-                                                       Builtin->getResultType(),
+                                                   Builtin->getCallResultType(),
                                                        RParenLoc);
     OwningExprResult OwnedCall(SemaRef.Owned(TheCall));
 

Modified: cfe/trunk/test/CodeGen/volatile.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/volatile.c?rev=108234&r1=108233&r2=108234&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/volatile.c (original)
+++ cfe/trunk/test/CodeGen/volatile.c Tue Jul 13 03:18:22 2010
@@ -1,8 +1,8 @@
 // RUN: %clang_cc1 -emit-llvm < %s -o %t
-// RUN: grep volatile %t | count 29
+// RUN: grep volatile %t | count 28
 // RUN: grep memcpy %t | count 7
 
-// The number 29 comes from the current codegen for volatile loads;
+// The number 28 comes from the current codegen for volatile loads;
 // if this number changes, it's not necessarily something wrong, but
 // something has changed to affect volatile load/store codegen
 
@@ -64,7 +64,7 @@
   i=vV[3];
   i=VE.yx[1];
   i=vVE.zy[1];
-  i = aggFct().x;
+  i = aggFct().x; // Note: not volatile
   i=vtS;
 
 

Modified: cfe/trunk/test/Sema/block-call.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-call.c?rev=108234&r1=108233&r2=108234&view=diff
==============================================================================
--- cfe/trunk/test/Sema/block-call.c (original)
+++ cfe/trunk/test/Sema/block-call.c Tue Jul 13 03:18:22 2010
@@ -13,9 +13,11 @@
   int (^IFP) () = PFR; // OK
 
 
-  const int (^CIC) () = IFP; // expected-error {{incompatible block pointer types initializing 'int const (^)()' with an expression of type 'int (^)()'}}
+  const int (^CIC) () = IFP; // expected-error {{incompatible block pointer types initializing 'int const (^)()' with an expression of type 'int (^)()'}} \
+  // expected-warning{{type qualifier on return type has no effect}}
+
+  const int (^CICC) () = CIC;   // expected-warning{{type qualifier on return type has no effect}}
 
-  const int (^CICC) () = CIC;
 
   int * const (^IPCC) () = 0;
 

Modified: cfe/trunk/test/Sema/block-return.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-return.c?rev=108234&r1=108233&r2=108234&view=diff
==============================================================================
--- cfe/trunk/test/Sema/block-return.c (original)
+++ cfe/trunk/test/Sema/block-return.c Tue Jul 13 03:18:22 2010
@@ -109,8 +109,11 @@
 
 void foo7()
 {
- const int (^BB) (void) = ^{ const int i = 1; return i; }; // expected-error{{incompatible block pointer types initializing 'int const (^)(void)' with an expression of type 'int (^)(void)'}}
- const int (^CC) (void)  = ^const int{ const int i = 1; return i; }; // OK
+ const int (^BB) (void) = ^{ const int i = 1; return i; }; // expected-error{{incompatible block pointer types initializing 'int const (^)(void)' with an expression of type 'int (^)(void)'}} \
+ // expected-warning{{type qualifier on return type has no effect}}
+
+ const int (^CC) (void)  = ^const int{ const int i = 1; return i; }; // expected-warning{{type qualifier on return type has no effect}}
+
 
   int i;
   int (^FF) (void)  = ^{ return i; }; // OK

Modified: cfe/trunk/test/Sema/struct-cast.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/struct-cast.c?rev=108234&r1=108233&r2=108234&view=diff
==============================================================================
--- cfe/trunk/test/Sema/struct-cast.c (original)
+++ cfe/trunk/test/Sema/struct-cast.c Tue Jul 13 03:18:22 2010
@@ -5,7 +5,8 @@
  int two;
 };
 
-struct S const foo(void);
+struct S const foo(void);  // expected-warning{{type qualifier on return type has no effect}}
+
 
 struct S tmp;
 

Modified: cfe/trunk/test/SemaCXX/ambig-user-defined-conversions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ambig-user-defined-conversions.cpp?rev=108234&r1=108233&r2=108234&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/ambig-user-defined-conversions.cpp (original)
+++ cfe/trunk/test/SemaCXX/ambig-user-defined-conversions.cpp Tue Jul 13 03:18:22 2010
@@ -17,7 +17,8 @@
   void func(const char ci, const B b); // expected-note {{candidate function}}
   void func(const B b, const int ci); // expected-note {{candidate function}}
 
-  const int Test1() {
+  const int Test1() { // expected-warning{{type qualifier on return type has no effect}}
+
     func(b1, f()); // expected-error {{call to 'func' is ambiguous}}
     return f(); // expected-error {{conversion from 'test0::B' to 'int const' is ambiguous}}
   }

Modified: cfe/trunk/test/SemaCXX/conditional-expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/conditional-expr.cpp?rev=108234&r1=108233&r2=108234&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/conditional-expr.cpp (original)
+++ cfe/trunk/test/SemaCXX/conditional-expr.cpp Tue Jul 13 03:18:22 2010
@@ -282,3 +282,20 @@
            : X());
   }
 }
+
+namespace PR7598 {
+  enum Enum {
+    v = 1,
+  };
+
+  const Enum g() { // expected-warning{{type qualifier on return type has no effect}}
+    return v;
+  }
+
+  void f() {
+    const Enum v2 = v;
+    Enum e = false ? g() : v;
+    Enum e2 = false ? v2 : v;
+  }
+
+}

Modified: cfe/trunk/test/SemaCXX/friend.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/friend.cpp?rev=108234&r1=108233&r2=108234&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/friend.cpp (original)
+++ cfe/trunk/test/SemaCXX/friend.cpp Tue Jul 13 03:18:22 2010
@@ -44,7 +44,8 @@
 // PR5134
 namespace test3 {
   class Foo {
-    friend const int getInt(int inInt = 0);
+    friend const int getInt(int inInt = 0);   // expected-warning{{type qualifier on return type has no effect}}
+
   };
 }
 

Modified: cfe/trunk/test/SemaTemplate/deduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/deduction.cpp?rev=108234&r1=108233&r2=108234&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/deduction.cpp (original)
+++ cfe/trunk/test/SemaTemplate/deduction.cpp Tue Jul 13 03:18:22 2010
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
 
 // Template argument deduction with template template parameters.
 template<typename T, template<T> class A> 
@@ -98,3 +98,10 @@
   void f(const X<A>& a);
   void test(A& a) { (void)f(a); }
 }
+
+// PR7463
+namespace PR7463 {
+  const int f (); // expected-warning{{type qualifier on return type has no effect}}
+  template <typename T_> void g (T_&); // expected-note{{T_ = int}}
+  void h (void) { g(f()); } // expected-error{{no matching function for call}}
+}





More information about the cfe-commits mailing list