[cfe-commits] r64993 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaCXX/copy-initialization.cpp test/SemaTemplate/class-template-spec.cpp

Douglas Gregor dgregor at apple.com
Wed Feb 18 16:52:42 PST 2009


Author: dgregor
Date: Wed Feb 18 18:52:42 2009
New Revision: 64993

URL: http://llvm.org/viewvc/llvm-project?rev=64993&view=rev
Log:
Provide a proper source location when building an implicit dereference. Fixes PR3600

Modified:
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/test/SemaCXX/copy-initialization.cpp
    cfe/trunk/test/SemaTemplate/class-template-spec.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=64993&r1=64992&r2=64993&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Feb 18 18:52:42 2009
@@ -3705,7 +3705,7 @@
   if (MemExpr->isArrow())
     ObjectArg = new (Context) UnaryOperator(ObjectArg, UnaryOperator::Deref,
                      ObjectArg->getType()->getAsPointerType()->getPointeeType(),
-                     SourceLocation());
+                                            ObjectArg->getLocStart());
   CXXMethodDecl *Method = 0;
   if (OverloadedFunctionDecl *Ovl 
         = dyn_cast<OverloadedFunctionDecl>(MemExpr->getMemberDecl())) {

Modified: cfe/trunk/test/SemaCXX/copy-initialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/copy-initialization.cpp?rev=64993&r1=64992&r2=64993&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/copy-initialization.cpp (original)
+++ cfe/trunk/test/SemaCXX/copy-initialization.cpp Wed Feb 18 18:52:42 2009
@@ -1,5 +1,4 @@
 // RUN: clang -fsyntax-only -verify %s 
-
 class X {
 public:
   explicit X(const X&);
@@ -15,3 +14,10 @@
   X x3 = ip;
   X x4 = fp; // expected-error{{cannot initialize 'x4' with an lvalue of type 'float *'}}
 }
+
+struct foo {
+ void bar();
+};
+
+// PR3600
+void test(const foo *P) { P->bar(); } // expected-error{{cannot initialize object parameter of type 'struct foo' with an expression of type 'struct foo const'}}

Modified: cfe/trunk/test/SemaTemplate/class-template-spec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/class-template-spec.cpp?rev=64993&r1=64992&r2=64993&view=diff

==============================================================================
--- cfe/trunk/test/SemaTemplate/class-template-spec.cpp (original)
+++ cfe/trunk/test/SemaTemplate/class-template-spec.cpp Wed Feb 18 18:52:42 2009
@@ -29,3 +29,14 @@
 template<> class A<FLOAT, float> { }; // expected-error{{redefinition}}
 
 template<> class A<float, int> { }; // expected-error{{redefinition}}
+
+template<typename T, typename U = int> class X;
+
+template <> class X<int, int> { int foo(); }; // #1
+template <> class X<float> { int bar(); };  // #2
+
+typedef int int_type;
+void testme(X<int_type> *x1, X<float, int> *x2) { 
+  x1->foo(); // okay: refers to #1
+  x2->bar(); // okay: refers to #2
+}





More information about the cfe-commits mailing list