Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Interpreter / disambiguate-decl-stmt.cpp
bloba49d7013c540ac22cc205c6a6ef05d963d0b8ca5
1 // RUN: %clang_cc1 -fsyntax-only -verify -fincremental-extensions -std=c++20 %s
2 // RUN: %clang_cc1 -fsyntax-only -DMS -fms-extensions -verify -fincremental-extensions -std=c++20 %s
4 extern "C" int printf(const char*,...);
6 // Decls which are hard to disambiguate
8 // Templates
9 namespace ns1 { template<typename T> void tmplt(T &) {}}
10 int arg_tmplt = 12; ns1::tmplt(arg_tmplt);
12 namespace ns2 { template <typename T> struct S {}; }
13 namespace ns3 { struct A { public: using S = int; }; }
14 namespace ns3 { A::S f(A::S a); }
16 // ParseStatementOrDeclaration returns multiple statements.
17 #ifdef MS
18 int g_bFlag = 1;
19 __if_exists(::g_bFlag) {
20 printf("Entering __if_exists\n");
21 printf("g_bFlag = %d\n", g_bFlag);
23 #endif // MS
25 // Operators.
26 struct S1 { operator int(); };
27 S1::operator int() { return 0; }
29 // Dtors
30 using I = int;
31 I x = 10;
32 x.I::~I();
33 x = 20;
35 struct Dtor1 {~Dtor1();};
36 Dtor1::~Dtor1() { printf("Dtor1\n"); }
37 Dtor1 d1;
39 struct Dtor2 { ~Dtor2(); };
40 ::Dtor2::~Dtor2() { printf("Dtor2\n"); }
41 Dtor2 d2;
43 struct ANestedDtor { struct A1 { struct A2 { ~A2(); }; }; };
44 ANestedDtor::A1::A2::~A2() { printf("Dtor A::A1::A2::~A2\n"); }
46 // Ctors
48 // Private typedefs / using declarations
49 class PrivateUsingMember { using T = int; T f(); };
50 PrivateUsingMember::T PrivateUsingMember::f() { return 0; }
52 class PrivateUsingVar { using T = int; static T i; };
53 PrivateUsingVar::T PrivateUsingVar::i = 42;
55 // The same with namespaces
56 namespace PrivateUsingNamespace { class Member { using T = int; T f(); }; }
57 PrivateUsingNamespace::Member::T PrivateUsingNamespace::Member::f() { return 0; }
59 namespace PrivateUsingNamespace { class Var { using T = int; static T i; }; }
60 PrivateUsingNamespace::Var::T PrivateUsingNamespace::Var::i = 42;
62 // The same with friend declarations
63 class PrivateUsingFriendMember;
64 class PrivateUsingFriendVar;
65 class PrivateUsingFriend { friend class PrivateUsingFriendMember; friend class PrivateUsingFriendVar; using T = int; };
66 class PrivateUsingFriendMember { PrivateUsingFriend::T f(); };
67 PrivateUsingFriend::T PrivateUsingFriendMember::f() { return 0; }
69 class PrivateUsingFriendVar { static PrivateUsingFriend::T i; };
70 PrivateUsingFriend::T PrivateUsingFriendVar::i = 42;
72 // The following should still diagnose (inspired by PR13642)
73 // FIXME: Should not be diagnosed twice!
74 class PR13642 { class Inner { public: static int i; }; };
75 // expected-note@-1 2 {{implicitly declared private here}}
76 PR13642::Inner::i = 5;
77 // expected-error@-1 2 {{'Inner' is a private member of 'PR13642'}}
79 // Deduction guide
80 template<typename T> struct A { A(); A(T); };
81 A() -> A<int>;
83 struct S2 { S2(); };
84 S2::S2() = default;
86 namespace N { struct S { S(); }; }
87 N::S::S() { printf("N::S::S()\n"); }
88 N::S s;
90 namespace Ns {namespace Ns { void Ns(); void Fs();}}
91 void Ns::Ns::Ns() { printf("void Ns::Ns::Ns()\n"); }
92 void Ns::Ns::Fs() {}
94 Ns::Ns::Fs();
95 Ns::Ns::Ns();
97 struct Attrs1 { Attrs1(); };
98 Attrs1::Attrs1() __attribute((pure)) = default;
100 struct Attrs2 { Attrs2(); };
101 __attribute((pure)) Attrs2::Attrs2() = default;
103 // Extra semicolon
104 namespace N {};