Author: lantictac Date: Thu Oct 25 04:45:32 2018 New Revision: 345258 URL: http://llvm.org/viewvc/llvm-project?rev=345258&view=rev Log: [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 Modified: cfe/trunk/lib/Parse/ParseExpr.cpp cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp Modified: cfe/trunk/lib/Parse/ParseExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=345258&r1=345257&r2=345258&view=diff ============================================================================== --- cfe/trunk/lib/Parse/ParseExpr.cpp (original) +++ cfe/trunk/lib/Parse/ParseExpr.cpp Thu Oct 25 04:45:32 2018 @@ -1809,7 +1809,8 @@ Parser::ParsePostfixExpressionSuffix(Exp /*EnteringContext=*/false, /*AllowDestructorName=*/true, /*AllowConstructorName=*/ - getLangOpts().MicrosoftExt, + getLangOpts().MicrosoftExt && + SS.isNotEmpty(), /*AllowDeductionGuide=*/false, ObjectType, &TemplateKWLoc, Name)) { (void)Actions.CorrectDelayedTyposInExpr(LHS); Modified: cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp?rev=345258&r1=345257&r2=345258&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp (original) +++ cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp Thu Oct 25 04:45:32 2018 @@ -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; } +} + _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits