1// Copyright 2013 The Chromium Authors 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5// This is a "No Compile Test" suite. 6// http://dev.chromium.org/developers/testing/no-compile-tests 7 8#include "base/values.h" 9 10#include <stdint.h> 11 12namespace base { 13 14void G(ValueView v) {} 15 16#if defined(NCTEST_VALUE_CTOR_PTR_DOES_NOT_CONVERT_TO_BOOL) // [r"fatal error: call to deleted constructor"] 17 18void F() { 19 int* ptr = nullptr; 20 Value v(ptr); 21} 22 23#elif defined(NCTEST_DICT_SET_PTR_DOES_NOT_CONVERT_TO_BOOL) // [r"fatal error: call to deleted member function"] 24 25void F() { 26 int* ptr = nullptr; 27 Value::Dict dict; 28 dict.Set("moo", ptr); 29} 30 31#elif defined(NCTEST_DICT_SETBYDOTTEDPATH_PTR_DOES_NOT_CONVERT_TO_BOOL) // [r"fatal error: call to deleted member function"] 32 33void F() { 34 int* ptr = nullptr; 35 Value::Dict dict; 36 dict.SetByDottedPath("moo.moo", ptr); 37} 38 39#elif defined(NCTEST_LIST_APPEND_PTR_DOES_NOT_CONVERT_TO_BOOL) // [r"fatal error: call to deleted member function"] 40 41void F() { 42 int* ptr = nullptr; 43 Value::List list; 44 list.Append(ptr); 45} 46 47#elif defined(NCTEST_VALUE_CTOR_INT64_T) // [r"fatal error: ambiguous conversion for functional-style cast from 'int64_t' \(aka '.+?'\) to 'Value'"] 48 49Value F(int64_t value) { 50 return Value(value); 51} 52 53#elif defined(NCTEST_SET_INT64_T) // [r"fatal error: call to member function 'Set' is ambiguous"] 54 55Value::Dict F(int64_t value) { 56 Value::Dict dict; 57 dict.Set("あいうえお", value); 58 return dict; 59} 60 61#elif defined(NCTEST_SETBYDOTTEDPATH_INT64_T) // [r"fatal error: call to member function 'SetByDottedPath' is ambiguous"] 62 63Value::Dict F(int64_t value) { 64 Value::Dict dict; 65 dict.SetByDottedPath("あいうえお", value); 66 return dict; 67} 68 69#elif defined(NCTEST_LIST_APPEND_INT64_T) // [r"fatal error: call to member function 'Append' is ambiguous"] 70 71Value::List F(int64_t value) { 72 Value::List list; 73 list.Append(value); 74 return list; 75} 76 77#elif defined(NCTEST_VALUEVIEW_FROM_CONST_NON_CHAR_POINTER) // [r"fatal error: conversion function from 'const int \*' to 'ValueView' invokes a deleted function"] 78 79void F() { 80 const int* ptr = nullptr; 81 ValueView v = ptr; 82 G(v); 83} 84 85#elif defined(NCTEST_VALUEVIEW_FROM_NON_CHAR_POINTER) // [r"fatal error: conversion function from 'int \*' to 'ValueView' invokes a deleted function"] 86 87void F() { 88 int* ptr = nullptr; 89 ValueView v = ptr; 90 G(v); 91} 92 93#elif defined(NCTEST_VALUEVIEW_FROM_STRING_TEMPORARY) // [r"fatal error: object backing the pointer will be destroyed at the end of the full-expression"] 94 95void F() { 96 ValueView v = std::string(); 97 G(v); 98} 99 100#elif defined(NCTEST_VALUEVIEW_FROM_BLOB_TEMPORARY) // [r"fatal error: object backing the pointer will be destroyed at the end of the full-expression"] 101 102void F() { 103 ValueView v = Value::BlobStorage(); 104 G(v); 105} 106 107#elif defined(NCTEST_VALUEVIEW_FROM_DICT_TEMPORARY) // [r"fatal error: object backing the pointer will be destroyed at the end of the full-expression"] 108 109void F() { 110 ValueView v = Value::Dict(); 111 G(v); 112} 113 114#elif defined(NCTEST_VALUEVIEW_FROM_LIST_TEMPORARY) // [r"fatal error: object backing the pointer will be destroyed at the end of the full-expression"] 115 116void F() { 117 ValueView v = Value::List(); 118 G(v); 119} 120 121#elif defined(NCTEST_VALUEVIEW_FROM_VALUE_TEMPORARY) // [r"fatal error: object backing the pointer will be destroyed at the end of the full-expression"] 122 123void F() { 124 ValueView v = Value(); 125 G(v); 126} 127 128#endif 129 130} // namespace base 131