[llvm-branch-commits] [cfe-branch] r119418 - in /cfe/branches/Apple/whitney: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaOverload.cpp test/SemaCXX/copy-initialization.cpp
Daniel Dunbar
daniel at zuster.org
Tue Nov 16 16:23:37 PST 2010
Author: ddunbar
Date: Tue Nov 16 18:23:37 2010
New Revision: 119418
URL: http://llvm.org/viewvc/llvm-project?rev=119418&view=rev
Log:
Merge r119336:
--
Author: Argyrios Kyrtzidis <akyrtzi at gmail.com>
Date: Tue Nov 16 08:04:45 2010 +0000
Improve diagnostic for calling non-const method on const object. Fixes rdar://7743000
Modified:
cfe/branches/Apple/whitney/include/clang/Basic/DiagnosticSemaKinds.td
cfe/branches/Apple/whitney/lib/Sema/SemaOverload.cpp
cfe/branches/Apple/whitney/test/SemaCXX/copy-initialization.cpp
Modified: cfe/branches/Apple/whitney/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/include/clang/Basic/DiagnosticSemaKinds.td?rev=119418&r1=119417&r2=119418&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/branches/Apple/whitney/include/clang/Basic/DiagnosticSemaKinds.td Tue Nov 16 18:23:37 2010
@@ -765,6 +765,10 @@
def err_init_list_bad_dest_type : Error<
"%select{|non-aggregate }0type %1 cannot be initialized with an initializer "
"list">;
+def err_member_function_call_bad_cvr : Error<"member function %0 not viable: "
+ "'this' argument has type %1, but function is not marked "
+ "%select{const|restrict|const or restrict|volatile|const or volatile|"
+ "volatile or restrict|const, volatile, or restrict}2">;
def err_reference_init_drops_quals : Error<
"initialization of reference to type %0 with a %select{value|temporary}1 of type %2 drops "
Modified: cfe/branches/Apple/whitney/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/Sema/SemaOverload.cpp?rev=119418&r1=119417&r2=119418&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/Sema/SemaOverload.cpp (original)
+++ cfe/branches/Apple/whitney/lib/Sema/SemaOverload.cpp Tue Nov 16 18:23:37 2010
@@ -3178,10 +3178,26 @@
ImplicitConversionSequence ICS
= TryObjectArgumentInitialization(*this, From->getType(), Method,
Method->getParent());
- if (ICS.isBad())
+ if (ICS.isBad()) {
+ if (ICS.Bad.Kind == BadConversionSequence::bad_qualifiers) {
+ Qualifiers FromQs = FromRecordType.getQualifiers();
+ Qualifiers ToQs = DestType.getQualifiers();
+ unsigned CVR = FromQs.getCVRQualifiers() & ~ToQs.getCVRQualifiers();
+ if (CVR) {
+ Diag(From->getSourceRange().getBegin(),
+ diag::err_member_function_call_bad_cvr)
+ << Method->getDeclName() << FromRecordType << (CVR - 1)
+ << From->getSourceRange();
+ Diag(Method->getLocation(), diag::note_previous_decl)
+ << Method->getDeclName();
+ return true;
+ }
+ }
+
return Diag(From->getSourceRange().getBegin(),
diag::err_implicit_object_parameter_init)
<< ImplicitParamRecordType << FromRecordType << From->getSourceRange();
+ }
if (ICS.Standard.Second == ICK_Derived_To_Base)
return PerformObjectMemberConversion(From, Qualifier, FoundDecl, Method);
Modified: cfe/branches/Apple/whitney/test/SemaCXX/copy-initialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/SemaCXX/copy-initialization.cpp?rev=119418&r1=119417&r2=119418&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/test/SemaCXX/copy-initialization.cpp (original)
+++ cfe/branches/Apple/whitney/test/SemaCXX/copy-initialization.cpp Tue Nov 16 18:23:37 2010
@@ -19,11 +19,11 @@
}
struct foo {
- void bar();
+ void bar(); // expected-note{{declared here}}
};
// PR3600
-void test(const foo *P) { P->bar(); } // expected-error{{cannot initialize object parameter of type 'foo' with an expression of type 'const foo'}}
+void test(const foo *P) { P->bar(); } // expected-error{{'bar' not viable: 'this' argument has type 'const foo', but function is not marked const}}
namespace PR6757 {
struct Foo {
More information about the llvm-branch-commits
mailing list