diff options
author | Will Wilson <will@indefiant.com> | 2018-10-25 11:45:32 +0000 |
---|---|---|
committer | Will Wilson <will@indefiant.com> | 2018-10-25 11:45:32 +0000 |
commit | b716dcf4d9808f273f8752751ecd53901bc627fc (patch) | |
tree | bcc71496ca0f067bf99e064446f35ef7753560ff /test | |
parent | 7378d7a652df04f180b40d747710f407684c7752 (diff) |
[ms] Prevent explicit constructor name lookup if scope is missing
MicrosoftExt allows explicit constructor calls. Prevent lookup of constructor name unless the name has explicit scope.
This avoids a compile-time crash due to confusing a member access for a constructor name.
Test case included. All tests pass.
Differential Revision: https://reviews.llvm.org/D53441
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@345258 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/SemaCXX/MicrosoftCompatibility.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/SemaCXX/MicrosoftCompatibility.cpp b/test/SemaCXX/MicrosoftCompatibility.cpp index 203a810111..727e67528f 100644 --- a/test/SemaCXX/MicrosoftCompatibility.cpp +++ b/test/SemaCXX/MicrosoftCompatibility.cpp @@ -302,3 +302,23 @@ void function_to_voidptr_conv() { void *a2 = &function_prototype; // expected-warning {{implicit conversion between pointer-to-function and pointer-to-object is a Microsoft extension}} void *a3 = function_ptr; // expected-warning {{implicit conversion between pointer-to-function and pointer-to-object is a Microsoft extension}} } + +namespace member_lookup { + +template<typename T> +struct ConfuseLookup { + T* m_val; + struct m_val { + static size_t ms_test; + }; +}; + +// Microsoft mode allows explicit constructor calls +// This could confuse name lookup in cases such as this +template<typename T> +size_t ConfuseLookup<T>::m_val::ms_test + = size_t(&(char&)(reinterpret_cast<ConfuseLookup<T>*>(0)->m_val)); + +void instantiate() { ConfuseLookup<int>::m_val::ms_test = 1; } +} + |