diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-07-13 08:18:22 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-07-13 08:18:22 +0000 |
commit | 603d81bf8d055732b3ba24899dd9c443e1ef243b (patch) | |
tree | ddea48df7318af2c406d98e6bbeee74b066139ae /clang/test | |
parent | d8f446f1b2dbe66cfa30335b60d6217fef684811 (diff) | |
download | bcm5719-llvm-603d81bf8d055732b3ba24899dd9c443e1ef243b.tar.gz bcm5719-llvm-603d81bf8d055732b3ba24899dd9c443e1ef243b.zip |
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).
llvm-svn: 108234
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/CodeGen/volatile.c | 6 | ||||
-rw-r--r-- | clang/test/Sema/block-call.c | 6 | ||||
-rw-r--r-- | clang/test/Sema/block-return.c | 7 | ||||
-rw-r--r-- | clang/test/Sema/struct-cast.c | 3 | ||||
-rw-r--r-- | clang/test/SemaCXX/ambig-user-defined-conversions.cpp | 3 | ||||
-rw-r--r-- | clang/test/SemaCXX/conditional-expr.cpp | 17 | ||||
-rw-r--r-- | clang/test/SemaCXX/friend.cpp | 3 | ||||
-rw-r--r-- | clang/test/SemaTemplate/deduction.cpp | 9 |
8 files changed, 43 insertions, 11 deletions
diff --git a/clang/test/CodeGen/volatile.c b/clang/test/CodeGen/volatile.c index db87a375152..1a996defcf0 100644 --- a/clang/test/CodeGen/volatile.c +++ b/clang/test/CodeGen/volatile.c @@ -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 @@ int main() { i=vV[3]; i=VE.yx[1]; i=vVE.zy[1]; - i = aggFct().x; + i = aggFct().x; // Note: not volatile i=vtS; diff --git a/clang/test/Sema/block-call.c b/clang/test/Sema/block-call.c index 318bc6b2a3b..28e6c68a800 100644 --- a/clang/test/Sema/block-call.c +++ b/clang/test/Sema/block-call.c @@ -13,9 +13,11 @@ int main() { 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; diff --git a/clang/test/Sema/block-return.c b/clang/test/Sema/block-return.c index 10b3b8480cc..33fd183be06 100644 --- a/clang/test/Sema/block-return.c +++ b/clang/test/Sema/block-return.c @@ -109,8 +109,11 @@ void foo6() { 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 diff --git a/clang/test/Sema/struct-cast.c b/clang/test/Sema/struct-cast.c index dc7db130dc1..3456665a8c5 100644 --- a/clang/test/Sema/struct-cast.c +++ b/clang/test/Sema/struct-cast.c @@ -5,7 +5,8 @@ struct S { 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; diff --git a/clang/test/SemaCXX/ambig-user-defined-conversions.cpp b/clang/test/SemaCXX/ambig-user-defined-conversions.cpp index 7f676748740..9811859fccc 100644 --- a/clang/test/SemaCXX/ambig-user-defined-conversions.cpp +++ b/clang/test/SemaCXX/ambig-user-defined-conversions.cpp @@ -17,7 +17,8 @@ namespace test0 { 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}} } diff --git a/clang/test/SemaCXX/conditional-expr.cpp b/clang/test/SemaCXX/conditional-expr.cpp index d008b8d6ed7..9cbc3244678 100644 --- a/clang/test/SemaCXX/conditional-expr.cpp +++ b/clang/test/SemaCXX/conditional-expr.cpp @@ -282,3 +282,20 @@ namespace rdar7998817 { : 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; + } + +} diff --git a/clang/test/SemaCXX/friend.cpp b/clang/test/SemaCXX/friend.cpp index 4f86d6a94d6..ba34efe36c2 100644 --- a/clang/test/SemaCXX/friend.cpp +++ b/clang/test/SemaCXX/friend.cpp @@ -44,7 +44,8 @@ namespace test2 { // 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}} + }; } diff --git a/clang/test/SemaTemplate/deduction.cpp b/clang/test/SemaTemplate/deduction.cpp index 8d00bb796e9..25ffb67492a 100644 --- a/clang/test/SemaTemplate/deduction.cpp +++ b/clang/test/SemaTemplate/deduction.cpp @@ -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 @@ namespace PR6257 { 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}} +} |