Clang Project

clang_source_code/test/SemaCXX/conversion-incomplete-type.cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s
2
3struct string {};
4
5class StringPiece;  // expected-note {{forward declaration of 'StringPiece'}} \
6                    // expected-note {{forward declaration of 'StringPiece'}}
7
8struct Test {
9  void expectStringPiece(const StringPiece& blah) {};  // expected-note {{passing argument to parameter 'blah' here}}
10  
11  void test(const string& s) { 
12    expectStringPiece(s);  // expected-error {{no viable conversion from 'const string' to incomplete type 'const StringPiece'}}
13  }
14};
15
16struct TestStatic {
17  static void expectStringPiece(const StringPiece& blah) {};  // expected-note {{passing argument to parameter 'blah' here}}
18  
19  static void test(const string& s) { 
20    expectStringPiece(s);  // expected-error {{no viable conversion from 'const string' to incomplete type 'const StringPiece'}}
21  }
22};
23
24