diff options
author | Reid Kleckner <rnk@google.com> | 2016-05-24 21:23:54 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2016-05-24 21:23:54 +0000 |
commit | 27c10ea3c6816d78f62152fb0ddd0516d25afe88 (patch) | |
tree | e264757f1ae11959b247a4e7efcae9f3b0243b2b /test/SemaTemplate/ms-lookup-template-base-classes.cpp | |
parent | b49e6f8c472760ae8c44318ea7e04b99a7a0a75e (diff) | |
download | clang-27c10ea3c6816d78f62152fb0ddd0516d25afe88.tar.gz |
[ms] Allow more unqualified lookup of types in dependent base classes
Summary:
In dependent contexts where we know a type name is required, such as a
new expression, we can recover by forming a DependentNameType.
This generalizes our existing compatibility hack for default arguments
for template type parameters.
Works towards parsing atlctrlw.h, which is PR26748.
Reviewers: avt77, rsmith
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D20500
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@270615 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaTemplate/ms-lookup-template-base-classes.cpp')
-rw-r--r-- | test/SemaTemplate/ms-lookup-template-base-classes.cpp | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/test/SemaTemplate/ms-lookup-template-base-classes.cpp b/test/SemaTemplate/ms-lookup-template-base-classes.cpp index 4f3df277d9..51d19cef38 100644 --- a/test/SemaTemplate/ms-lookup-template-base-classes.cpp +++ b/test/SemaTemplate/ms-lookup-template-base-classes.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++1y -fms-compatibility -fno-spell-checking -fsyntax-only -verify %s +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -std=c++1y -fms-compatibility -fno-spell-checking -fsyntax-only -verify %s template <class T> @@ -573,3 +573,33 @@ void h(); template <typename T> decltype(h(T())) check2(); // expected-note{{candidate template ignored: substitution failure [with T = int]: no matching function for call to 'h'}} decltype(check2<int>()) y; // expected-error{{no matching function for call to 'check2'}} } + +// We also allow unqualified lookup into bases in contexts where the we know the +// undeclared identifier *must* be a type, such as a new expression or catch +// parameter type. +template <typename T> +struct UseUnqualifiedTypeNames : T { + void foo() { + void *P = new TheType; // expected-warning {{unqualified lookup}} expected-error {{no type}} + size_t x = __builtin_offsetof(TheType, f2); // expected-warning {{unqualified lookup}} expected-error {{no type}} + try { + } catch (TheType) { // expected-warning {{unqualified lookup}} expected-error {{no type}} + } + enum E : IntegerType { E0 = 42 }; // expected-warning {{unqualified lookup}} expected-error {{no type}} + _Atomic(TheType) a; // expected-warning {{unqualified lookup}} expected-error {{no type}} + } + void out_of_line(); +}; +template <typename T> +void UseUnqualifiedTypeNames<T>::out_of_line() { + void *p = new TheType; // expected-warning {{unqualified lookup}} expected-error {{no type}} +} +struct Base { + typedef int IntegerType; + struct TheType { + int f1, f2; + }; +}; +template struct UseUnqualifiedTypeNames<Base>; +struct BadBase { }; +template struct UseUnqualifiedTypeNames<BadBase>; // expected-note-re 2 {{in instantiation {{.*}} requested here}} |