Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Side by Side Diff: base/memory/scoped_ptr_unittest.nc

Issue 678263003: Switch to clang for nocompile tests and rebaseline existing results. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 8
9 namespace { 9 namespace {
10 10
11 class Parent { 11 class Parent {
12 }; 12 };
13 13
14 class Child : public Parent { 14 class Child : public Parent {
15 }; 15 };
16 16
17 class RefCountedClass : public base::RefCountedThreadSafe<RefCountedClass> { 17 class RefCountedClass : public base::RefCountedThreadSafe<RefCountedClass> {
18 }; 18 };
19 19
20 } // namespace 20 } // namespace
21 21
22 #if defined(NCTEST_NO_PASSAS_DOWNCAST) // [r"invalid conversion from"] 22 #if defined(NCTEST_NO_REF_COUNTED_SCOPED_PTR) // [r"fatal error: static_assert failed \"T_is_refcounted_type_and_needs_scoped_refptr\""]
23
24 scoped_ptr<Child> DowncastUsingPassAs(scoped_ptr<Parent> object) {
25 return object.PassAs<Child>();
danakj 2014/11/03 16:05:13 Should we have a case of object.Pass(); where the
dcheng 2014/11/03 18:58:18 Good point. Changed this to DowncastUsingPass.
26 }
27
28 #elif defined(NCTEST_NO_REF_COUNTED_SCOPED_PTR) // [r"size of array is negative "]
29 23
30 // scoped_ptr<> should not work for ref-counted objects. 24 // scoped_ptr<> should not work for ref-counted objects.
31 void WontCompile() { 25 void WontCompile() {
32 scoped_ptr<RefCountedClass> x; 26 scoped_ptr<RefCountedClass> x;
33 } 27 }
34 28
35 #elif defined(NCTEST_NO_ARRAY_WITH_SIZE) // [r"size of array is negative"] 29 #elif defined(NCTEST_NO_ARRAY_WITH_SIZE) // [r"fatal error: static_assert faile d \"do_not_use_array_with_size_as_type\""]
36 30
37 void WontCompile() { 31 void WontCompile() {
38 scoped_ptr<int[10]> x; 32 scoped_ptr<int[10]> x;
39 } 33 }
40 34
41 #elif defined(NCTEST_NO_PASS_FROM_ARRAY) // [r"size of array is negative"] 35 #elif defined(NCTEST_NO_PASS_FROM_ARRAY) // [r"fatal error: static_assert faile d \"U_cannot_be_an_array\""]
42 36
43 void WontCompile() { 37 void WontCompile() {
44 scoped_ptr<int[]> a; 38 scoped_ptr<int[]> a;
45 scoped_ptr<int*> b; 39 scoped_ptr<int*> b;
46 b = a.Pass(); 40 b = a.Pass();
47 } 41 }
48 42
49 #elif defined(NCTEST_NO_PASS_TO_ARRAY) // [r"no match for 'operator='"] 43 #elif defined(NCTEST_NO_PASS_TO_ARRAY) // [r"fatal error: no viable overloaded '='"]
50 44
51 void WontCompile() { 45 void WontCompile() {
52 scoped_ptr<int*> a; 46 scoped_ptr<int*> a;
53 scoped_ptr<int[]> b; 47 scoped_ptr<int[]> b;
54 b = a.Pass(); 48 b = a.Pass();
55 } 49 }
56 50
57 #elif defined(NCTEST_NO_CONSTRUCT_FROM_ARRAY) // [r"is private"] 51 #elif defined(NCTEST_NO_CONSTRUCT_FROM_ARRAY) // [r"fatal error: 'impl_' is a p rivate member of 'scoped_ptr<int \[\], base::DefaultDeleter<int \[\]> >'"]
58 52
59 void WontCompile() { 53 void WontCompile() {
60 scoped_ptr<int[]> a; 54 scoped_ptr<int[]> a;
61 scoped_ptr<int*> b(a.Pass()); 55 scoped_ptr<int*> b(a.Pass());
62 } 56 }
63 57
64 #elif defined(NCTEST_NO_CONSTRUCT_TO_ARRAY) // [r"no matching function for call "] 58 #elif defined(NCTEST_NO_CONSTRUCT_TO_ARRAY) // [r"fatal error: no matching cons tructor for initialization of 'scoped_ptr<int \[\]>'"]
65 59
66 void WontCompile() { 60 void WontCompile() {
67 scoped_ptr<int*> a; 61 scoped_ptr<int*> a;
68 scoped_ptr<int[]> b(a.Pass()); 62 scoped_ptr<int[]> b(a.Pass());
69 } 63 }
70 64
71 #elif defined(NCTEST_NO_CONSTRUCT_SCOPED_PTR_ARRAY_FROM_NULL) // [r"is ambiguou s"] 65 #elif defined(NCTEST_NO_CONSTRUCT_SCOPED_PTR_ARRAY_FROM_NULL) // [r"is ambiguou s"]
72 66
73 void WontCompile() { 67 void WontCompile() {
74 scoped_ptr<int[]> x(NULL); 68 scoped_ptr<int[]> x(NULL);
75 } 69 }
76 70
77 #elif defined(NCTEST_NO_CONSTRUCT_SCOPED_PTR_ARRAY_FROM_DERIVED) // [r"is priva te"] 71 #elif defined(NCTEST_NO_CONSTRUCT_SCOPED_PTR_ARRAY_FROM_DERIVED) // [r"fatal er ror: calling a private constructor of class 'scoped_ptr<\(anonymous namespace\): :Parent \[\], base::DefaultDeleter<\(anonymous namespace\)::Parent \[\]> >'"]
78 72
79 void WontCompile() { 73 void WontCompile() {
80 scoped_ptr<Parent[]> x(new Child[1]); 74 scoped_ptr<Parent[]> x(new Child[1]);
81 } 75 }
82 76
83 #elif defined(NCTEST_NO_RESET_SCOPED_PTR_ARRAY_FROM_NULL) // [r"is ambiguous"] 77 #elif defined(NCTEST_NO_RESET_SCOPED_PTR_ARRAY_FROM_NULL) // [r"is ambiguous"]
84 78
85 void WontCompile() { 79 void WontCompile() {
86 scoped_ptr<int[]> x; 80 scoped_ptr<int[]> x;
87 x.reset(NULL); 81 x.reset(NULL);
88 } 82 }
89 83
90 #elif defined(NCTEST_NO_RESET_SCOPED_PTR_ARRAY_FROM_DERIVED) // [r"is private"] 84 #elif defined(NCTEST_NO_RESET_SCOPED_PTR_ARRAY_FROM_DERIVED) // [r"fatal error: 'reset' is a private member of 'scoped_ptr<\(anonymous namespace\)::Parent \[\] , base::DefaultDeleter<\(anonymous namespace\)::Parent \[\]> >'"]
91 85
92 void WontCompile() { 86 void WontCompile() {
93 scoped_ptr<Parent[]> x; 87 scoped_ptr<Parent[]> x;
94 x.reset(new Child[1]); 88 x.reset(new Child[1]);
95 } 89 }
96 90
97 #elif defined(NCTEST_NO_DELETER_REFERENCE) // [r"fails to be a struct or class type"] 91 #elif defined(NCTEST_NO_DELETER_REFERENCE) // [r"fatal error: base specifier mu st name a class"]
98 92
99 struct Deleter { 93 struct Deleter {
100 void operator()(int*) {} 94 void operator()(int*) {}
101 }; 95 };
102 96
103 // Current implementation doesn't support Deleter Reference types. Enabling 97 // Current implementation doesn't support Deleter Reference types. Enabling
104 // support would require changes to the behavior of the constructors to match 98 // support would require changes to the behavior of the constructors to match
105 // including the use of SFINAE to discard the type-converting constructor 99 // including the use of SFINAE to discard the type-converting constructor
106 // as per C++11 20.7.1.2.1.19. 100 // as per C++11 20.7.1.2.1.19.
107 void WontCompile() { 101 void WontCompile() {
108 Deleter d; 102 Deleter d;
109 int n; 103 int n;
110 scoped_ptr<int*, Deleter&> a(&n, d); 104 scoped_ptr<int*, Deleter&> a(&n, d);
111 } 105 }
112 106
113 #endif 107 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698