summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/MicrosoftCompatibility.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [MS] Warn when shadowing template parameters under -fms-compatibilityReid Kleckner2019-09-121-0/+18
| | | | | | | | | | | | | | | | | | | | Summary: C++ does not allow shadowing template parameters, but previously we allowed it under -fms-extensions. Now this behavior is controlled by -fms-compatibility, and we emit a -Wmicrosoft-template warning when it happens. Fixes PR43265 Reviewers: thakis, hans Subscribers: amccarth, rsmith, STL_MSFT, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67463 llvm-svn: 371753
* Move EH spec mismatches under -fms-compatibilityReid Kleckner2019-08-271-0/+44
| | | | | | | | | | | | | | | | | | | | | -fms-extensions is intended to enable conforming language extensions and -fms-compatibility is intended to language rule relaxations, so a user could plausibly compile with -fno-ms-compatibility on Windows while still using dllexport, for example. This exception specification validation behavior has been handled as a warning since before -fms-compatibility was added in 2011. I think it's just an oversight that it hasn't been moved yet. This will help users find conformance issues in their code such as those found in _com_ptr_t as described in https://llvm.org/PR42842. Reviewers: hans Subscribers: STL_MSFT, cfe-commits Differential Revision: https://reviews.llvm.org/D66770 llvm-svn: 370087
* [ms] Prevent explicit constructor name lookup if scope is missingWill Wilson2018-10-251-0/+20
| | | | | | | | | | | 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 llvm-svn: 345258
* [AST] Fix loss of enum forward decl from decl contextJoel E. Denny2018-05-301-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | For example, given: enum __attribute__((deprecated)) T *p; -ast-print produced: enum T *p; The attribute was lost because the enum forward decl was lost. Another example is the loss of enum forward decls from C++ namespaces (in MS compatibility mode). The trouble was that the EnumDecl node was suppressed, as revealed by -ast-dump. The suppression of the EnumDecl was intentional in r116122, but I don't understand why. The suppression isn't needed for the test suite to behave. Reviewed by: rsmith Differential Revision: https://reviews.llvm.org/D46846 llvm-svn: 333574
* [ms] Give -Wmicrosoft-enum-forward-reference a chance to fire in clang-cl, ↵Nico Weber2017-04-211-0/+24
| | | | | | | | | | | | | | | | | | PR32736 clang-cl sets MicrosoftCompat. In that mode, we always give enums a fixed underlying type, and for enums with fixed underlying type we never enter the block that tries to emit ext_ms_forward_ref_enum. Fix this by requiring an explicit underlying type when we're skipping this diagnostic. We had a test for this warning, but it only ran in C++98 mode. clang-cl always enables -std=c++14, so MicrosoftCompatibiliy-cxx98.cpp is a fairly useless test. Fold it into MicrosoftCompatibility.cpp -- that way, the test checks if -Wmicrosoft-enum-forward-reference can fire in clang-cl builds. https://reviews.llvm.org/D32369 llvm-svn: 301032
* Sema: As of MSVC 2015, a user-declared move operation causes the deletion of ↵Peter Collingbourne2016-11-191-0/+16
| | | | | | | | both copy operations. Differential Revision: https://reviews.llvm.org/D26868 llvm-svn: 287411
* [MS] Move hex long long sign compat hack to -fms-compatibilityReid Kleckner2016-10-041-0/+11
| | | | | | | | | Treating large 0x*LL literals as signed instead of unsigned is not a conforming language extension, so move it out of -fms-extensions. Came up in PR30605 llvm-svn: 283227
* [MS Compat] Allow _Atomic(Type) and 'struct _Atomic' to coexistDavid Majnemer2015-07-221-4/+11
| | | | | | | | | | | | | | | | | | | | | | MSVC 2013 ships, as part of its STL implementation, a class named '_Atomic'. This is unfortunate because this keyword is in conflict with the C11 keyword with the same name. Our solution was to disable this keyword when targeting MSVC 2013 and reenable it for 2015. However, this makes it impossible for clang's headers to make use of _Atomic. This is problematic in the case of libc++ as it makes heavy use of this keyword. Let the keywordness of _Atomic float under certain circumstances: the body of a class named _Atomic, or a class with a base specifier named _Atomic, will not have the keyword variant of _Atomic for the duration of the class body. This is sufficient to allow us to correctly handle _Atomic in the STL while permitting us to use _Atomic as a keyword everywhere else. Differential Revision: http://reviews.llvm.org/D11233 llvm-svn: 242970
* MS ABI: Define _HAS_CHAR16_T_LANGUAGE_SUPPORT when appropriateDavid Majnemer2015-03-181-2/+6
| | | | | | | If we are in MSVC 2015 compatibility mode and C++11 language conformance is enabled, define _HAS_CHAR16_T_LANGUAGE_SUPPORT to 1. llvm-svn: 232615
* MSVC Compat: Permit char16_t, char32_t and _Atomic when targeting > 2013David Majnemer2015-03-181-3/+9
| | | | | | | | We disabled support for _Atomic because the STL had name conflicts, they've been resolved in 2015. Similarly, reenable char16_t and char32_t. llvm-svn: 232611
* Reword switch/goto diagnostics "protected scope" diagnostics. Making up a termRichard Smith2014-09-061-5/+5
| | | | | | | | "protected scope" is very unhelpful here and actively confuses users. Instead, simply state the nature of the problem in the diagnostic: we cannot jump from here to there. The notes explain nicely why not. llvm-svn: 217293
* TokenKinds: _Atomic isn't a keyword in MS modeDavid Majnemer2014-03-041-0/+1
| | | | | | | | | | | | | | | | Summary: This is needed to allow MSVC's <atomic> header to properly parse. It uses _Atomic as a class-id. Reviewers: rnk Reviewed By: rnk CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2948 llvm-svn: 202901
* Move the -fms-compatibility using decl check after real access checkingReid Kleckner2014-02-081-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This avoids false positives from -Wmicrosoft when name lookup would normally succeed in standard C++. This triggered on a common CRTP pattern in clang, where a derived class would have a private using decl to pull in members of a dependent base: class Verifier : InstVisitor<Verifier> { private: using InstVisitor<Verifier>::visit; ... void anything() { visit(); // warned here } }; Real access checks pass here because we're in the context of the Verifier, but the -Wmicrosoft extension was just looking for the private access specifier. Reviewers: rsmith CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2679 llvm-svn: 201019
* Restrict redeclaration of tags introduced by using decls to MSVCCompatAlp Toker2014-01-181-0/+21
| | | | | | | This limits the facility added in r199490 while we seek clarification on the standard. llvm-svn: 199531
* Sema: Predefine size_t in MSVC Compatibility modeDavid Majnemer2014-01-141-0/+1
| | | | | | | | MSVC defines size_t without any explicit declarations. This change allows us to be compatible with TUs that depend on this declaration appearing from nowhere. llvm-svn: 199190
* Fix 'declartion' typosAlp Toker2014-01-051-1/+1
| | | | llvm-svn: 198549
* Pre-declare '::type_info' in MicrosoftMode only, not MicrosoftExtAlp Toker2014-01-051-0/+5
| | | | | | | | It was previously enabled in both but should only have been part of the drop-in quirks mode that is 'MicrosoftMode' given that it's only useful for compatibility with the Microsoft headers/runtime. llvm-svn: 198548
* -fms-compatibility: Use C++98 null pointer constant rulesReid Kleckner2013-11-121-0/+16
| | | | | | Patch by Will Wilson! llvm-svn: 194441
* Allow the parser to recover gracefully if a typename is used to introduce a ↵Francois Pichet2012-07-221-0/+2
| | | | | | | | | | decltype type. In Microsoft mode, we emit a warning instead of an error. This fixes a couple of errors when parsing the MSVC 11 RC headers with clang. llvm-svn: 160613
* char16_t and char32_t are defined via typedef in MSVC 11 RC. So introduce a ↵Francois Pichet2012-07-221-0/+2
| | | | | | way to disable keywords under Microsoft mode. llvm-svn: 160612
* In microsoft mode, downgrade pseudo-destructors on void from error to warning.Nico Weber2012-01-231-0/+11
| | | | | | This matches cl.exe's behavior and fixes PR11791. llvm-svn: 148682
* Convert file from 60% unix 40% dos line endings to 100% unix line endings.Nico Weber2012-01-231-67/+67
| | | | | | No other changes. llvm-svn: 148678
* Eli says this should check MicrosoftMode instead.Nico Weber2012-01-231-0/+21
| | | | | | Also change a || that I accidentally changed to && back to ||. llvm-svn: 148677
* In Microsoft Mode, disable the C++11 strict integral conversion rules for ↵Francois Pichet2012-01-211-1/+6
| | | | | | enumerator that were introduced with r148439. Otherwise MSVC headers won't compile in C++ 11 mode. llvm-svn: 148642
* Change the diagnostics which said 'accepted as an extension' to instead sayRichard Smith2011-12-291-1/+1
| | | | | | | 'is an extension'. The former is inappropriate and confusing when building with -Werror/-pedantic-errors. llvm-svn: 147357
* Modify how the -verify flag works. Currently, the verification string andRichard Trieu2011-12-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | diagnostic message are compared. If either is a substring of the other, then no error is given. This gives rise to an unexpected case: // expect-error{{candidate function has different number of parameters}} will match the following error messages from Clang: candidate function has different number of parameters (expected 1 but has 2) candidate function has different number of parameters It will also match these other error messages: candidate function function has different number of parameters number of parameters This patch will change so that the verification string must be a substring of the diagnostic message before accepting. Also, all the failing tests from this change have been corrected. Some stats from this cleanup: 87 - removed extra spaces around verification strings 70 - wording updates to diagnostics 40 - extra leading or trailing characters (typos, unmatched parens or quotes) 35 - diagnostic level was included (error:, warning:, or note:) 18 - flag name put in the warning (-Wprotocol) llvm-svn: 146619
* Move "Unqualified lookup into dependent bases of class templates" Microsoft ↵Francois Pichet2011-11-111-19/+0
| | | | | | specific behavior from -fms-extensions to -fms-compatibility. llvm-svn: 144341
* Add -Wc++98-compat diagnostics for jumps which bypass initialization of non-PODRichard Smith2011-10-201-2/+2
| | | | | | | | but trivially constructible and destructible variables in C++11 mode. Also incidentally improve the precision of the wording for jump diagnostics in C++98 mode. llvm-svn: 142619
* [Microsoft] If -fms-compatibility, then downgrade missing typename error to ↵Francois Pichet2011-10-111-2/+2
| | | | | | warning at function prototype scope. llvm-svn: 141630
* [microsoft] In Microsoft mode, if we are inside a template class member ↵Francois Pichet2011-09-241-0/+22
| | | | | | | | | function and we can't resolve an identifier then assume the identifier is type dependent. The goal is to postpone name lookup to instantiation time to be able to search into type dependent base classes. This fixes a few errors when parsing MFC code with clang. BTW clang trunk is now about 5 patches away to be able the parse the default wizard-generated MFC project. llvm-svn: 140452
* [microsoft] Move missing typename warning from -fms-extensions to ↵Francois Pichet2011-09-211-0/+44
| | | | | | -fms-compatibility. Also allow the missing typename warning at function scope. llvm-svn: 140240
* Move Microsoft access specifier bug emulation from -fms-extensions to ↵Francois Pichet2011-09-201-0/+20
| | | | | | -fm-compatibility. llvm-svn: 140189
* Move the "jump bypasses variable initialization" error -> warning downgrade ↵Francois Pichet2011-09-181-1/+55
| | | | | | from -fms-extensions to -fms-compatibility. llvm-svn: 140008
* In Microsoft mode(-fms-compatibility), prefer an integral conversion to a ↵Francois Pichet2011-09-181-0/+18
floating-to-integral conversion if the integral conversion is between types of the same size. For example: void f(float); void f(int); int main { long a; f(a); } Here, MSVC will call f(int) instead of generating a compile error as clang will do in standard mode. This fixes a few errors when parsing MFC code with clang. llvm-svn: 140007
OpenPOWER on IntegriCloud