1 // RUN: %clang_cc1 -fms-compatibility -std=c++11 %s -verify
3 // MSVC should compile this file without errors.
6 template <typename T
= Baz
> // expected-warning {{using the undeclared type 'Baz' as a default template argument is a Microsoft extension}}
12 namespace test_namespace
{
14 template <typename T
= Baz
> // expected-warning {{using the undeclared type 'Baz' as a default template argument is a Microsoft extension}}
16 static_assert(sizeof(T
) == 4, "should get int, not double");
21 template struct nested::Foo
<>;
24 namespace test_inner_class_template
{
26 template <typename T
= Baz
> // expected-warning {{using the undeclared type 'Baz' as a default template argument is a Microsoft extension}}
28 static_assert(sizeof(T
) == 4, "should get int, not double");
33 template struct Outer::Foo
<>;
36 namespace test_nontype_param
{
37 template <typename T
> struct Bar
{ T x
; };
39 template <Bar
<Qux
> *P
>
43 template struct Foo
<&g
>;
46 // MSVC accepts this, but Clang doesn't.
47 namespace test_template_instantiation_arg
{
48 template <typename T
> struct Bar
{ T x
; };
49 template <typename T
= Bar
<Weber
>> // expected-error {{use of undeclared identifier 'Weber'}}
51 static_assert(sizeof(T
) == 4, "Bar should have gotten int");
56 // MSVC accepts this, but Clang doesn't.
57 namespace test_scope_spec
{
58 template <typename T
= ns::Bar
> // expected-error {{use of undeclared identifier 'ns'}}
60 static_assert(sizeof(T
) == 4, "Bar should have gotten int");
62 namespace ns
{ typedef int Bar
; }
66 // These are negative test cases that MSVC doesn't compile either. Try to use
67 // unique undeclared identifiers so typo correction doesn't find types declared
70 namespace test_undeclared_nontype_parm_type
{
71 template <Zargon N
> // expected-error {{unknown type name 'Zargon'}}
72 struct Foo
{ int x
[N
]; };
74 template struct Foo
<4>;
77 namespace test_undeclared_nontype_parm_type_no_name
{
78 template <typename T
, Asdf
> // expected-error {{unknown type name 'Asdf'}}
80 template struct Foo
<int, 0>;
83 namespace test_undeclared_type_arg
{
86 template struct Foo
<Yodel
>; // expected-error {{use of undeclared identifier 'Yodel'}}
89 namespace test_undeclared_nontype_parm_arg
{
90 // Bury an undeclared type as a template argument to the type of a non-type
91 // template parameter.
92 template <typename T
> struct Bar
{ T x
; };
94 template <Bar
<Xylophone
> *P
> // expected-error {{use of undeclared identifier 'Xylophone'}}
95 // expected-note@-1{{template parameter is declared here}}
98 typedef int Xylophone
;
100 template struct Foo
<&g
>; // expected-error {{value of type}}