blob: c51cb28408844edd51ebc7298dfc3e706e4fb793 [file] [log] [blame]
Richard Smith87bb5692015-06-09 00:35:49 +00001// RUN: rm -rf %t
Richard Smith4440d6e2015-07-19 23:44:27 +00002// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -fno-modules-error-recovery -I %S/Inputs/template-default-args -std=c++11 %s -DBEGIN= -DEND=
3// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -fno-modules-error-recovery -I %S/Inputs/template-default-args -std=c++11 %s -DBEGIN="namespace N {" -DEND="}"
Richard Smith87bb5692015-06-09 00:35:49 +00004
Richard Smith4440d6e2015-07-19 23:44:27 +00005BEGIN
Richard Smith87bb5692015-06-09 00:35:49 +00006template<typename T> struct A;
7template<typename T> struct B;
8template<typename T> struct C;
9template<typename T = int> struct D;
Richard Smithe7bd6de2015-06-10 20:30:23 +000010template<typename T = int> struct E {};
Richard Smith35c1df52015-06-17 20:16:32 +000011template<typename T> struct H {};
Richard Smithafe800c2015-06-17 22:13:23 +000012template<typename T = int, typename U = int> struct I {};
Richard Smith4440d6e2015-07-19 23:44:27 +000013END
Richard Smith87bb5692015-06-09 00:35:49 +000014
15#include "b.h"
Richard Smith535ff802015-09-11 22:39:35 +000016#include "d.h"
Richard Smith87bb5692015-06-09 00:35:49 +000017
Richard Smith4440d6e2015-07-19 23:44:27 +000018BEGIN
Richard Smith87bb5692015-06-09 00:35:49 +000019template<typename T = int> struct A {};
20template<typename T> struct B {};
21template<typename T = int> struct B;
22template<typename T = int> struct C;
23template<typename T> struct D {};
Richard Smithe7bd6de2015-06-10 20:30:23 +000024template<typename T> struct F {};
Richard Smith35c1df52015-06-17 20:16:32 +000025template<typename T> struct G {};
Richard Smith6dc8ae12015-08-17 20:24:17 +000026template<typename T> struct J {};
27template<typename T = int> struct J;
28struct K : J<> {};
Richard Smith4440d6e2015-07-19 23:44:27 +000029END
Richard Smithe7bd6de2015-06-10 20:30:23 +000030
31#include "c.h"
Richard Smith87bb5692015-06-09 00:35:49 +000032
Richard Smith4440d6e2015-07-19 23:44:27 +000033BEGIN
Richard Smith87bb5692015-06-09 00:35:49 +000034A<> a;
35B<> b;
36extern C<> c;
37D<> d;
Richard Smithe7bd6de2015-06-10 20:30:23 +000038E<> e;
39F<> f;
Richard Smith35c1df52015-06-17 20:16:32 +000040G<> g; // expected-error {{default argument of 'G' must be imported from module 'X.A' before it is required}}
Richard Smith35c1df52015-06-17 20:16:32 +000041// expected-note@a.h:7 {{default argument declared here}}
Richard Smith4440d6e2015-07-19 23:44:27 +000042H<> h; // expected-error {{default argument of 'H' must be imported from module 'X.A' before it is required}}
43// expected-note@a.h:8 {{default argument declared here}}
Richard Smithafe800c2015-06-17 22:13:23 +000044I<> i;
Richard Smith535ff802015-09-11 22:39:35 +000045L<> *l;
Richard Smith4440d6e2015-07-19 23:44:27 +000046END
Richard Smith2195ec92017-04-21 01:15:13 +000047
48namespace DeferredLookup {
49 template<typename T, typename U = T> using X = U;
50 template<typename T> void f() { (void) X<T>(); }
51 template<typename T> int n = X<T>(); // expected-warning {{extension}}
52 template<typename T> struct S { X<T> xt; enum E : int; };
53 template<typename T> enum S<T>::E : int { a = X<T>() };
54
55 void test() {
56 f<int>();
57 n<int> = 1;
58 S<int> s;
59 S<int>::E e = S<int>::E::a;
60
61 Indirect::B<int>::C<int> indirect;
62 }
63}