summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/MicrosoftExtensions.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [clang] Warning for non-final classes with final destructorsDavid Bolvansky2019-08-311-0/+5
| | | | | | | | | | | | Marking a class' destructor final prevents the class from being inherited from. However, it is a subtle and awkward way to express that at best, and unintended at worst. It may also generate worse code (in other compilers) than marking the class itself final. For these reasons, this revision adds a warning for nonfinal classes with final destructors, with a note to suggest marking the class final to silence the warning. See https://reviews.llvm.org/D66621 for more background. Patch by logan-5 (Logan Smith) Differential Revision: https://reviews.llvm.org/D66711 llvm-svn: 370594
* Move EH spec mismatches under -fms-compatibilityReid Kleckner2019-08-271-43/+0
| | | | | | | | | | | | | | | | | | | | | -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
* Fix for PR42089, regression from r362119Erich Keane2019-05-311-0/+9
| | | | | | | | | The implementation of the NoThrow ExceptionSpecificationType missed a switch statement for forming the diagnostic when an out-of-line member redeclaration misses the exception specification. This patch adds the correct case statement. llvm-svn: 362225
* Implement C++ DR727, which permits explicit specializations at class scope.Richard Smith2018-03-161-1/+0
| | | | | | | | | More generally, this permits a template to be specialized in any scope in which it could be defined, so this also supersedes DR44 and DR374 (the latter of which we previously only implemented in C++11 mode onwards due to unclarity as to whether it was a DR). llvm-svn: 327705
* Allow operator delete to be an invalid Decl.Richard Trieu2017-08-091-0/+14
| | | | | | | | Do not discard invalid Decl when searching for the operator delete function. The lookup for this function always expects to find a result, so sometimes the invalid Decl is the only choice possible. This fixes PR34109. llvm-svn: 310435
* [Sema] Avoid using a null type pointer (fixes PR32750)Vedant Kumar2017-04-261-0/+8
| | | | | | | | | | isMicrosoftMissingTypename() uses a Type pointer without first checking that it's non-null. PR32750 reports a case where the pointer is in fact null. This patch adds in a defensive check and a regression test. Differential Revision: https://reviews.llvm.org/D32519 llvm-svn: 301420
* [Lit Test] Make tests C++11 compatible - Microsoft diagnosticsCharles Li2017-02-061-5/+22
| | | | | | Differential Revision: https://reviews.llvm.org/D29520 llvm-svn: 294225
* [MS] Move hex long long sign compat hack to -fms-compatibilityReid Kleckner2016-10-041-11/+8
| | | | | | | | | 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
* [MSVC] Support for __unaligned qualifier in functionsAndrey Bokhanko2016-05-261-0/+4
| | | | | | | | | | | | | | | This implements support for MS-specific __unaligned qualifier in functions and makes the following test case both compile and mangle correctly: struct S { void f() __unaligned; }; void S::f() __unaligned { } Differential Revision: http://reviews.llvm.org/D20437 llvm-svn: 270834
* [MSVC] Implementation of __unaligned as a proper type qualifierAndrey Bokhanko2016-05-111-1/+77
| | | | | | | | | | | This patch implements __unaligned (MS extension) as a proper type qualifier (before that, it was implemented as an ignored attribute). It also fixes PR27367 and PR27666. Differential Revision: http://reviews.llvm.org/D20103 llvm-svn: 269220
* Revert r268727, it caused PR27666.Nico Weber2016-05-061-52/+1
| | | | llvm-svn: 268736
* [MSVC] Implementation of __unaligned as a proper type qualifierAndrey Bokhanko2016-05-061-1/+52
| | | | | | | | | | | This patch implements __unaligned (MS extension) as a proper type qualifier (before that, it was implemented as an ignored attribute). It also fixes PR27367. Differential Revision: http://reviews.llvm.org/D19654 llvm-svn: 268727
* Revert r266415, it broke parsing SDK headers (PR27367).Nico Weber2016-04-151-40/+1
| | | | llvm-svn: 266431
* [MSVC Compat] Implementation of __unaligned (MS extension) as a type qualifierAndrey Bokhanko2016-04-151-1/+40
| | | | | | | | | | | This patch implements __unaligned as a type qualifier; before that, it was modeled as an attribute. Proper mangling of __unaligned is implemented as well. Some OpenCL code/tests are tangenially affected, as they relied on existing number and sizes of type qualifiers. Differential Revision: http://reviews.llvm.org/D18596 llvm-svn: 266415
* [MSVC Compat] Permit conversions from pointer-to-function to ↵David Majnemer2015-10-311-10/+0
| | | | | | | | | | | pointer-to-object iff -fms-compatibility We permit implicit conversion from pointer-to-function to pointer-to-object when -fms-extensions is specified. This is rather unfortunate, move this into -fms-compatibility and only permit it within system headers unless -Wno-error=microsoft-cast is specified. llvm-svn: 251738
* [-fms-extensions] Allow missing exception specifications in redeclarations ↵David Majnemer2015-10-201-0/+8
| | | | | | | | | | | as an extension Microsoft's ATL headers make use of this MSVC extension, add support for it and issue a diagnostic under -Wmicrosoft-exception-spec. This fixes PR25265. llvm-svn: 250854
* Don't try to get a CXXRecordDecl from a non-class TemplateSpecializationType.Kaelyn Takata2015-10-011-0/+10
| | | | | | | | With -fms-extensions it is possible to have a non-class record that is a template specialization cause an assertion failure via the call to Type::getAsCXXRecordDecl. Fixes PR 24246. llvm-svn: 249090
* MS extensions: Properly diagnose address of MS property declReid Kleckner2015-02-241-0/+12
| | | | | | | | | | | | Summary: Fixes PR22671. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D7863 llvm-svn: 230362
* Recognize __unaligned keyword after type specifierNico Rieck2014-12-041-0/+1
| | | | | | | | The __unaligned keyword can appear after a struct definition: struct foo {...} __unaligned *x; llvm-svn: 223412
* c++11 patch to issue warning on missing 'override' on Fariborz Jahanian2014-10-271-3/+4
| | | | | | | overriding methods. Patch review by Richard Smith. rdar://18295240 llvm-svn: 220703
* Revert r218925 - "Patch to warn if 'override' is missing"Alexander Potapenko2014-10-031-2/+2
| | | | | | | | | | | | | | | | | | | | This CL has caused bootstrap failures on Linux and OSX buildbots running with -Werror. Example report from http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/13183/steps/bootstrap%20clang/logs/stdio: ================================================================ [ 91%] Building CXX object tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/ShowEnabledWarnings.cpp.o In file included from /home/dtoolsbot/build/sanitizer-x86_64-linux/build/llvm/lib/Target/R600/AMDGPUISelDAGToDAG.cpp:20: In file included from /home/dtoolsbot/build/sanitizer-x86_64-linux/build/llvm/lib/Target/R600/SIISelLowering.h:19: /home/dtoolsbot/build/sanitizer-x86_64-linux/build/llvm/lib/Target/R600/SIInstrInfo.h:71:8: error: 'getLdStBaseRegImmOfs' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override] bool getLdStBaseRegImmOfs(MachineInstr *LdSt, ^ /home/dtoolsbot/build/sanitizer-x86_64-linux/build/llvm/include/llvm/Target/TargetInstrInfo.h:815:16: note: overridden virtual function is here virtual bool getLdStBaseRegImmOfs(MachineInstr *LdSt, ^ ================================================================ llvm-svn: 218969
* Patch to warn if 'override' is missingFariborz Jahanian2014-10-021-2/+2
| | | | | | | | | | | | for an overriding method if class has at least one 'override' specified on one of its methods. Reviewed by Doug Gregor. rdar://18295240 (I have already checked in all llvm files with missing 'override' methods and Bob Wilson has fixed a TableGen of FastISel so no warnings are expected from build of llvm after this patch. I have already verified this). llvm-svn: 218925
* MSVC compat: Allow lookup of friend types in enclosing namespacesReid Kleckner2014-07-101-23/+0
| | | | | | | | | | | | | | | | | | | | | | | The relevant portion of C++ standard says [namespace.memdef]p3: If the name in a friend declaration is neither qualified nor a template-id and the declaration is a function or an elaborated-type-specifier, the lookup to determine whether the entity has been previously declared shall not consider any scopes outside the innermost enclosing namespace. MSVC does not implement that rule for types. If there is a type in an enclosing namespace, they consider an unqualified tag declaration with the same name to be a redeclaration of the type from another namespace. Implementing compatibility is a simple matter of disabling our implementation of this rule for types, which was added in r177473. Reviewers: rsmith Differential Revision: http://reviews.llvm.org/D4443 llvm-svn: 212784
* Sema: Static redeclaration after extern declarations is a Microsoft ExtensionDavid Majnemer2014-06-181-1/+4
| | | | | | | | | | | CL permits static redeclarations to follow extern declarations. The storage specifier on the latter declaration has no effect. This fixes PR20034. Differential Revision: http://reviews.llvm.org/D4149 llvm-svn: 211238
* Allow dllimport/dllexport on inline functions and adjust the linkage.Hans Wennborg2014-05-151-1/+1
| | | | | | | | This is a step towards handling these attributes on classes (PR11170). Differential Revision: http://reviews.llvm.org/D3772 llvm-svn: 208925
* Sema: Check dll attributes on redeclarationsNico Rieck2014-03-311-2/+3
| | | | | | | A redeclaration may not add dllimport or dllexport attributes. dllexport is sticky and can be omitted on redeclarations while dllimport cannot. llvm-svn: 205197
* Move the warning about unused relational comparison from -Wunused-value toRichard Trieu2014-03-111-1/+1
| | | | | | | -Wunused-comparison. Also, newly warn on unused result from overloaded relational comparisons, now also in -Wunused-comparison. llvm-svn: 203535
* Pre-declare '::type_info' in MicrosoftMode only, not MicrosoftExtAlp Toker2014-01-051-4/+0
| | | | | | | | 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
* Teach the diagnostics engine about the Attr type to make reporting on ↵Aaron Ballman2013-12-261-10/+10
| | | | | | semantic attributes easier (and not require hard-coded strings). This requires a getSpelling() function on the Attr class, which is table-driven. Updates a handful of cases where a hard-coded string was being used to test the functionality out. Updating associated test cases for the improved quoting. llvm-svn: 198055
* Parse Microsoft __declspec appearing after class bodyAlp Toker2013-11-241-0/+11
| | | | | | | | | | MSVC applies these to the following declaration only if present, otherwise silently ignores them whereas we'll issue a warning. Handling differs from ordinary attributes appearing in the same place, so add a Sema test to make sure we get it right. llvm-svn: 195577
* [-fms-extensions] Permit 'override' in C++98 and 'sealed' as a synonym for ↵David Majnemer2013-10-181-0/+25
| | | | | | | | | | | | | | 'final' Summary: Some MS headers use these features. Reviewers: rnk, rsmith CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1948 llvm-svn: 192936
* Under -fms-extensions, only inject a friend tag name when we didn't see a ↵Douglas Gregor2013-06-271-0/+20
| | | | | | | | | | | | | | tag with that name in an enclosing scope. r177473 made us correctly consider only those declarations in the enclosing namespace scope when looking for a friend declaration. Under ms-extensions mode, where we do some level of friend injection, this meant that we were introducing a new tag type into a different scope than what Microsoft actually does. Address this by only doing the friend injection when we didn't see any tag with that name in any outer scope. Fixes <rdar://problem/14250378>. llvm-svn: 185100
* This patch fixes PR16395, when HandleMSProperty returns null due to a ↵Aaron Ballman2013-06-261-0/+4
| | | | | | | | declaration with no name. Patch thanks to Robert Wilhelm. llvm-svn: 185022
* [Windows] Fix __declspec(property) when the getter returns a refReid Kleckner2013-06-191-0/+17
| | | | | | | | This fixes an issue when parsing atlbase.h. Patch by Will Wilson! llvm-svn: 184319
* Disallow reinterpret_cast from pointer to bool on WindowsHans Wennborg2013-06-061-1/+7
| | | | | | | | | | | | This became allowed by accident in r131201, but triggers an assert. That patch added an exception to allow conversion from pointers to narrow integral types for MSVC compatibility. However, a pointer can already be converted to bool in a civilized manner; allowing conversion via reinterpret_cast is a bad idea. Fixes PR16222. llvm-svn: 183394
* Microsoft has a language extension which allows union members to beAaron Ballman2013-05-301-0/+5
| | | | | | | references. What's more, they use this language extension in their ATL header files (which come as part of MFC and the Win32 SDK). This patch implements support for the Microsoft extension, and addresses PR13737. llvm-svn: 182936
* Don't put too much thought into whether or not to capture aJohn McCall2013-04-161-4/+5
| | | | | | | | | type-dependent intermediate result in a postfix ++ pseudo- object operation. Test case by Tong Shen. llvm-svn: 179637
* Basic support for Microsoft property declarations andJohn McCall2013-04-161-0/+124
| | | | | | | | references thereto. Patch by Tong Shen! llvm-svn: 179585
* Accept over-qualified constructor in MSVC emulation modeDmitri Gribenko2013-02-121-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MSVC accepts this: class A { A::A(); }; Clang accepts regular member functions with extra qualification as an MS extension, but not constructors. This changes the parser to defer rejecting qualified constructors so that the same Sema logic can apply to constructors as regular member functions. This also improves the error message when MS extensions are disabled (in my opinion). Before it was: /Users/jason/Desktop/test.cpp:2:8: error: expected member name or ';' after declaration specifiers A::A(); ~~~~ ^ 1 error generated. After: /Users/jason/Desktop/test.cpp:2:6: error: extra qualification on member 'A' A::A(); ~~~^ 1 error generated. Patch by Jason Haslam. llvm-svn: 174980
* Change diagnostics for enums with fixed underlying type so in C++98 mode, we ↵Eli Friedman2012-11-021-3/+3
| | | | | | cite C++11. llvm-svn: 167273
* Promote the warning about extra qualification on a declaration from aDouglas Gregor2012-09-131-0/+1
| | | | | | | | warning to an error. C++ bans it, and both GCC and EDG diagnose it as an error. Microsoft allows it, so we still warn in Microsoft mode. Fixes <rdar://problem/11135644>. llvm-svn: 163831
* Shift Microsoft enum extensions from -fms-extensions to -fms-compatibility, ↵Eli Friedman2012-02-161-5/+0
| | | | | | so -fms-extensions doesn't affect enum semantics in incompatible ways. <rdar://problem/10657186>. llvm-svn: 150663
* In Microsoft Mode, disable the C++11 strict integral conversion rules for ↵Francois Pichet2012-01-211-5/+0
| | | | | | enumerator that were introduced with r148439. Otherwise MSVC headers won't compile in C++ 11 mode. llvm-svn: 148642
* Treat the Microsoft/Borland keyword "__except" as a context-sensitiveDouglas Gregor2011-10-211-0/+3
| | | | | | | keyword, because both libstdc++ and libc++ use "__except" as an identifier. Fixes <rdar://problem/10322555>. llvm-svn: 142636
* When we end up having to parse the initializer of a C++ member earlyDouglas Gregor2011-10-171-0/+7
| | | | | | | in -fms-extensions mode, make sure we actually use that initializer after having handled the declaration. Fixes PR11150. llvm-svn: 142195
* [microsoft] Move missing typename warning from -fms-extensions to ↵Francois Pichet2011-09-211-34/+0
| | | | | | -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-20/+0
| | | | | | -fm-compatibility. llvm-svn: 140189
* Move the "jump bypasses variable initialization" error -> warning downgrade ↵Francois Pichet2011-09-181-53/+0
| | | | | | from -fms-extensions to -fms-compatibility. llvm-svn: 140008
* In Microsoft mode, warn if an indirect goto jump over a variable initialization.Francois Pichet2011-09-161-8/+8
| | | | | | Also add a test case for the non Microsoft case because such test didn't exist. llvm-svn: 139971
* In Microsoft mode, downgrade "goto into protected scope" from error to ↵Francois Pichet2011-09-131-1/+55
| | | | | | | | warning if we are jumping over a variable initialization via a goto. This fixes a few errors when parsing MFC code with clang. llvm-svn: 139595
OpenPOWER on IntegriCloud