blob: 98989d12f98559220d7c57ef1292fc7b99f26000 [file] [log] [blame]
Richard Smith32952e12014-10-14 02:00:47 +00001// RUN: rm -rf %t
Richard Smith47972af2015-06-16 00:08:24 +00002// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify %s -DORDER=1
3// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify %s -DORDER=2
Richard Smith32952e12014-10-14 02:00:47 +00004
5#if ORDER == 1
6#include "a.h"
7#include "b.h"
8#else
9#include "b.h"
10#include "a.h"
11#endif
12
13struct Y {
14 int value; // expected-note 0-1{{target of using}}
15 typedef int type; // expected-note 0-1{{target of using}}
16};
17
18template<typename T> int Use() {
19 int k = T().v + T().value; // expected-note 0-2{{instantiation of}}
20 typedef typename T::type I;
21 typedef typename T::t I;
22 typedef int I;
23 return k;
24}
25
26template<typename T> int UseAll() {
27 return Use<C<T> >() + Use<D<T> >() + Use<E<T> >() + Use<F<T> >(); // expected-note 0-2{{instantiation of}}
28}
29
30template int UseAll<YA>();
31template int UseAll<YB>();
32template int UseAll<Y>();
33
Richard Smithd88a7f12015-09-01 20:35:42 +000034// Which of these two sets of diagnostics is chosen is not important. It's OK
35// if this varies with ORDER, but it must be consistent across runs.
Richard Smith7fa450c2015-09-01 01:37:34 +000036#if ORDER == 1
Richard Smith32952e12014-10-14 02:00:47 +000037// Here, we're instantiating the definition from 'A' and merging the definition
38// from 'B' into it.
39
40// expected-error@b.h:* {{'E::value' from module 'B' is not present in definition of 'E<T>' in module 'A'}}
41// expected-error@b.h:* {{'E::v' from module 'B' is not present in definition of 'E<T>' in module 'A'}}
42
43// expected-error@b.h:* {{'F::type' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
44// expected-error@b.h:* {{'F::t' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
45// expected-error@b.h:* {{'F::value' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
46// expected-error@b.h:* {{'F::v' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
47
48// expected-note@a.h:* +{{does not match}}
49#else
50// Here, we're instantiating the definition from 'B' and merging the definition
51// from 'A' into it.
52
53// expected-error@a.h:* {{'D::type' from module 'A' is not present in definition of 'D<T>' in module 'B'}}
54// expected-error@a.h:* {{'D::value' from module 'A' is not present in definition of 'D<T>' in module 'B'}}
55// expected-error@b.h:* 2{{'typename' keyword used on a non-type}}
56// expected-error@b.h:* 2{{dependent using declaration resolved to type without 'typename'}}
57
58// expected-error@a.h:* {{'E::type' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
59// expected-error@a.h:* {{'E::t' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
60// expected-error@a.h:* {{'E::value' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
61// expected-error@a.h:* {{'E::v' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
62// expected-note@b.h:* 2{{definition has no member}}
63
64// expected-error@a.h:* {{'F::type' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
65// expected-error@a.h:* {{'F::t' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
66// expected-error@a.h:* {{'F::value' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
67// expected-error@a.h:* {{'F::v' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
68
69// expected-note@b.h:* +{{does not match}}
70// expected-note@b.h:* +{{target of using}}
71#endif