summaryrefslogtreecommitdiffstats
path: root/clang/test/Parser/MicrosoftExtensions.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Refactor constant evaluation of typeid(T) to track a symbolic type_infoRichard Smith2019-05-171-0/+2
| | | | | | | | | | | | | | object rather than tracking the originating expression. This is groundwork for supporting polymorphic typeid expressions. (Note that this somewhat regresses our support for DR1968, but it turns out that that never actually worked anyway, at least in non-trivial cases.) This reinstates r360974, reverted in r360988, with a fix for a static_assert failure on 32-bit builds: force Type base class to have 8-byte alignment like the rest of Clang's AST nodes. llvm-svn: 360995
* Revert Refactor constant evaluation of typeid(T) to track a symbolic ↵Chris Bieneman2019-05-171-2/+0
| | | | | | | | type_info object rather than tracking the originating expression. This reverts r360974 (git commit 7ee4307bd4450022c3c8777f43a40cc4f0ccc009) llvm-svn: 360988
* Refactor constant evaluation of typeid(T) to track a symbolic type_infoRichard Smith2019-05-171-0/+2
| | | | | | | | | | object rather than tracking the originating expression. This is groundwork for supporting polymorphic typeid expressions. (Note that this somewhat regresses our support for DR1968, but it turns out that that never actually worked anyway, at least in non-trivial cases.) llvm-svn: 360974
* [Sema][MSVC] Fix bogus microsoft-pure-definition warning on member function ↵Bruno Ricci2019-04-211-0/+12
| | | | | | | | | | | | | | | | | | | | | | of class template Clang emits a warning when using a pure specifier =0 in a function definition at class scope (a MS-specific construct), when using -fms-extensions. However, to detect this, it was using FD->isCanonicalDecl() on function declaration, which was also detecting out-of-class definition of member functions of class templates. Fix this by using !FD->isOutOfLine() instead. Fixes PR21334. Differential Revision: https://reviews.llvm.org/D29707 Reviewed By: riccibruno Reviewers: rnk, riccibruno Patch By: Rudy Pons llvm-svn: 358849
* [MS] Accept __unaligned as a qualifier on member function pointersReid Kleckner2018-03-071-0/+7
| | | | | | | | | | We need to treat __unaligned like the other 'cvr' qualifiers when it appears at the end of a function prototype. We weren't doing that in some tentative parsing. Fixes PR36638. llvm-svn: 326962
* Determine the attribute subject for diagnostics based on declarative ↵Aaron Ballman2017-11-261-2/+2
| | | | | | | | | | information in DeclNodes.td. This greatly reduces the number of enumerated values used for more complex diagnostics; these are now only required when the "attribute only applies to" diagnostic needs to be generated manually as part of semantic processing. This also clarifies some terminology used by the diagnostic (methods -> Objective-C methods, fields -> non-static data members, etc). Many of the tests needed to be updated in multiple places for the diagnostic wording tweaks. The first instance of the diagnostic for that attribute is fully specified and subsequent instances cut off the complete list (to make it easier if additional subjects are added in the future for the attribute). llvm-svn: 319002
* Keep the IdentifierInfo in the Token for alternative operator keywordOlivier Goffart2017-07-141-3/+1
| | | | | | | | | | | | | | | | | | | The goal of this commit is to fix clang-format so it does not merge tokens when using the alternative spelling keywords. (eg: "not foo" should not become "notfoo") The problem is that Preprocessor::HandleIdentifier used to drop the identifier info from the token for these keyword. This means the first condition of TokenAnnotator::spaceRequiredBefore is not met. We could add explicit check for the spelling in that condition, but I think it is better to keep the IdentifierInfo and handle the operator keyword explicitly when needed. That actually leads to simpler code, and probably slightly more efficient as well. Another side effect of this change is that __identifier(and) will now work as one would expect, removing a FIXME from the MicrosoftExtensions.cpp test Differential Revision: https://reviews.llvm.org/D35172 llvm-svn: 308008
* Revert MSVC CXXOperatorNames patch due to issues with ChromiumErich Keane2017-05-251-2/+4
| | | | llvm-svn: 303882
* For Microsoft compatibility, set fno_operator_namesErich Keane2017-05-241-4/+2
| | | | | | | | | | | | | | | | | | | | | There's a Microsoft header in the Windows SDK which won't compile with clang because it uses an operator name (and) as a field name. This patch allows that file to compile by setting the option which disables operator names. The header which doesn't compile <Query.h> C:/Program Files (x86)/ Windows Kits/10/include/10.0.14393.0/um\Query.h:259:40: error: expected member name or ';' after declaration specifiers /* [case()] */ NODERESTRICTION or; ~~~~~~~~~~~~~~~ ^ 1 error generated. Contributed for Melanie Blower Differential Revision:https://reviews.llvm.org/D33505 llvm-svn: 303798
* Warn that the [] spelling of uuid(...) is deprecated.Nico Weber2017-05-051-1/+1
| | | | | | https://reviews.llvm.org/D32879 llvm-svn: 302255
* __uuidof() and declspec(uuid("...")) should be allowed on enumeration typesReid Kleckner2016-12-131-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Although not specifically mentioned in the documentation, MSVC accepts __uuidof(…) and declspec(uuid("…")) attributes on enumeration types in addition to structs/classes. This is meaningful, as such types *do* have associated UUIDs in ActiveX typelibs, and such attributes are included by default in the wrappers generated by their #import construct, so they are not particularly unusual. clang currently rejects the declspec with a –Wignored-attributes warning, and errors on __uuidof() with “cannot call operator __uuidof on a type with no GUID” (because it rejected the uuid attribute, and therefore finds no value). This is causing problems for us while trying to use clang-tidy on a codebase that makes heavy use of ActiveX. I believe I have found the relevant places to add this functionality, this patch adds this case to clang’s implementation of these MS extensions. patch is against r285994 (or actually the git mirror 80464680ce). Both include an update to test/Parser/MicrosoftExtensions.cpp to exercise the new functionality. This is my first time contributing to LLVM, so if I’ve missed anything else needed to prepare this for review just let me know! __uuidof: https://msdn.microsoft.com/en-us/library/zaah6a61.aspx declspec(uuid("…")): https://msdn.microsoft.com/en-us/library/3b6wkewa.aspx #import: https://msdn.microsoft.com/en-us/library/8etzzkb6.aspx Reviewers: aaron.ballman, majnemer, rnk Differential Revision: https://reviews.llvm.org/D26846 llvm-svn: 289567
* [ms] Add support for parsing uuid as a Microsoft attribute.Nico Weber2016-09-031-0/+4
| | | | | | | | | | | | | | | | | Some Windows SDK classes, for example Windows::Storage::Streams::IBufferByteAccess, use the ATL way of spelling attributes: [uuid("....")] class IBufferByteAccess {}; To be able to use __uuidof() to grab the uuid off these types, clang needs to support uuid as a Microsoft attribute. There was already code to skip Microsoft attributes, extend that to look for uuid and parse it. Use the new "Microsoft" attribute type added in r280575 (and r280574, r280576) for this. Final part of https://reviews.llvm.org/D23895 llvm-svn: 280578
* Ignore the "novtable" declspec when not using the Microsoft C++ ABI.Bob Wilson2015-07-201-1/+1
| | | | | | | | | | | | | | Clang used to silently ignore __declspec(novtable). It is implemented now, but leaving the vtable uninitialized does not work when using the Itanium ABI, where the class layout for complex class hierarchies is stored in the vtable. It might be possible to honor the novtable attribute in some simple cases and either report an error or ignore it in more complex situations, but it’s not clear if that would be worthwhile. There is also value in having a simple and predictable behavior, so this changes clang to simply ignore novtable when not using the Microsoft C++ ABI. llvm-svn: 242730
* Revert "parser: wordsmith diagnostic message" and "parser: diagnose empty ↵David Majnemer2015-07-081-0/+7
| | | | | | | | | | | | attribute blocks" This reverts commit r239846 and r239879. They caused clang's -fms-extensions behavior to incorrectly parse lambdas and includes a testcase to ensure we don't regress again. This issue was found in PR24027. llvm-svn: 241668
* [MS ABI] Correctly associate align attrs before the class-keyDavid Majnemer2015-04-191-0/+9
| | | | | | | | | | | | __declspec(align(...)) is unlike all other attributes in that it is not applied to a variable if it appears before the class-key. If the tag in question isn't part of a variable declaration, it is not ignored. Instead, the alignment attribute is applied to the tag. This fixes PR18024. llvm-svn: 235272
* Sema: __assume with side effects shouldn't result in invalid AST nodesDavid Majnemer2015-02-261-1/+17
| | | | | | | | We'd diagnose an __assume expression which contained a function call. This would result in us wrongly returning ExprError, causing mysterious failures later on. llvm-svn: 230597
* MS ABI: Implement support for 'novtable'David Majnemer2015-02-021-1/+1
| | | | | | | | | | It is common for COM interface classes to be marked as 'novtable' to tell the compiler that constructors and destructors should not reference virtual function tables. This commit implements this feature in clang. llvm-svn: 227796
* [Objective-C]. Modern property getters have side-effects.Fariborz Jahanian2014-12-181-1/+1
| | | | | | | | So, place warning about property getter should not be used for side-effect under its own group so warning can be turned off. rdar://19137815 llvm-svn: 224479
* Parse: MS property members cannot have an in-class initializerDavid Majnemer2014-12-131-0/+1
| | | | | | | | | We would crash trying to treat a property member as a field. These shoudl be forbidden anyway, reject programs which contain them. This fixes PR21840. llvm-svn: 224193
* Parse qualifiers after comma in declarator lists as a Microsoft extensionNico Rieck2014-12-041-0/+8
| | | | | | MSVC parses and ignores these with a warning. llvm-svn: 223413
* c++11 patch to issue warning on missing 'override' on Fariborz Jahanian2014-10-271-2/+2
| | | | | | | 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
* -fms-extensions: Alias _intNN to __intNNReid Kleckner2014-08-221-0/+5
| | | | | | | | | | Fixes build for SPEC 2000 CPU. MSVC disables these aliases under /Za, which enables stricter standards compliance. We don't currently have any way to disable them. Patch by Kevin Smith! llvm-svn: 216270
* Sema: Permit nullptr template args in MSVC compat modeDavid Majnemer2014-08-141-1/+5
| | | | | | This fixes a regression I caused back in r211766. llvm-svn: 215609
* Giving this test a triple to satisfy the build bots.Aaron Ballman2014-07-061-1/+1
| | | | llvm-svn: 212418
* The MicrosoftExtensions.c test file should not rely on -x objective-c++. ↵Aaron Ballman2014-07-061-0/+25
| | | | | | Removed that from the RUN line, fixed obvious C++isms in the code, and moved some C++ tests into MicrosoftExtensions.cpp instead. As a drive-by, changed the line endings for MicrosoftExtensions.c to be LF instead of CRLF. llvm-svn: 212417
* Don't allow dllimport variables in constant initializersHans Wennborg2014-06-251-1/+1
| | | | | | | | | | | | | | | | | This is a follow-up to David's r211677. For the following code, we would end up referring to 'foo' in the initializer for 'arr', and then fail to link, because 'foo' is dllimport and needs to be accessed through the __imp_?foo. __declspec(dllimport) extern const char foo[]; const char* f() { static const char* const arr[] = { foo }; return arr[0]; } Differential Revision: http://reviews.llvm.org/D4299 llvm-svn: 211736
* Split tests for __if_exists out into their own fileReid Kleckner2014-06-251-97/+0
| | | | llvm-svn: 211649
* Preprocessor: make C++ operator names as macro identifiers a compatible ↵Alp Toker2014-05-311-0/+3
| | | | | | | | | | | extension With recent changes, this is now a compatible language extension and can be safely enabled with -ms-extensions instead of requiring the full -ms-compatibility MSVC drop-in mode. As such we can now also emit an extension warning under -Wmicrosoft to help users port their code. llvm-svn: 209978
* Implement the MS extension __identifier properly: take a token and strip it ofRichard Smith2014-03-151-0/+23
| | | | | | its keywordliness. llvm-svn: 203987
* Correct hyphenations in comments and assert messagesAlp Toker2013-12-051-8/+8
| | | | | | | This patch tries to avoid unrelated changes other than fixing a few hyphen-related ambiguities in nearby lines. llvm-svn: 196466
* __declspec(uuid) is only allowed on a class according to MSDN; this makes ↵Aaron Ballman2013-11-241-1/+1
| | | | | | the semantic checking consistent with what the attribute specifies in Attr.td. Also adds a test case. llvm-svn: 195579
* -Wmicrosoft: Don't warn on non-inline pure virtual method definitionsReid Kleckner2013-10-081-0/+9
| | | | | | | | | | | | | | | MSVC and clang with -fms-extensions allow pure virtual methods to be defined inline after the "= 0" tokens. Clang warns on these because it is not standard, but incorrectly warns on out-of-line definitions, which are standard. With this change, clang will only warn on inline definitions of pure virtual methods. Fixes some self-host warnings on out-of-line definitions of pure virtual destructors. llvm-svn: 192244
* AST: Handle multidimensional arrays inside of __uuidof()David Majnemer2013-09-271-0/+4
| | | | | | | | We previously handled one-dimensional arrays but didn't consider the general case. The fix is simple: keep going through subsequent dimensions until we get to the base element. llvm-svn: 191493
* AST: __uuidof should leak through templated typesDavid Majnemer2013-09-071-0/+19
| | | | | | | | | | | | | | | Summary: __uuidof on templated types should exmaine if any of its template parameters have a uuid declspec. If exactly one does, then take it. Otherwise, issue an appropriate error. Reviewers: rsmith, thakis, rnk CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1419 llvm-svn: 190240
* Parser: support Microsoft syntax for 'typename typedef'David Majnemer2013-09-031-1/+9
| | | | | | | | | | | | | | | | | | | | | | Summary: Transform the token sequence for: typename typedef T U; to: typename T typedef U; Raise a diagnostic when this happens but only if we succeeded handling the typename. Reviewers: rsmith, rnk Reviewed By: rsmith CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1433 llvm-svn: 189867
* Sema: Properly support Microsoft-mode template argumentsDavid Majnemer2013-08-231-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | Summary: There were two things known to be wrong with our implementation of MSVC mode template arguments: - We didn't properly handle __uuidof/CXXUuidofExpr and skipped all type checking completely. - We didn't allow for MSVC's extension of allowing certain constant "foldable" expressions from showing up in template arguments. They allow various casts dereference and address-of operations. We can make it more general as we find further peculiarities but this is the known extent. Reviewers: rsmith, doug.gregor, rjmccall Reviewed By: doug.gregor CC: cfe-commits, rnk Differential Revision: http://llvm-reviews.chandlerc.com/D1444 llvm-svn: 189087
* err_attribute_not_string has been subsumed by err_attribute_argument_type.Aaron Ballman2013-07-301-17/+17
| | | | llvm-svn: 187400
* Basic support for Microsoft property declarations andJohn McCall2013-04-161-0/+29
| | | | | | | | references thereto. Patch by Tong Shen! llvm-svn: 179585
* Normalize line endings of r163013 (part 2).Joao Matos2012-08-311-44/+44
| | | | llvm-svn: 163032
* Improved MSVC __interface support by adding first class support for it, ↵Joao Matos2012-08-311-13/+21
| | | | | | instead of aliasing to "struct" which had some incorrect behaviour. Patch by David Robins. llvm-svn: 163013
* Recognize the MS inheritance attributes and turn them into attributesJohn McCall2012-05-221-0/+6
| | | | | | | | | on the RecordDecl. Persist the MS portability type attributes and ignore them in Sema rather than the parser. Patch by João Matos! llvm-svn: 157288
* Fix line endings.John McCall2012-05-221-23/+18
| | | | llvm-svn: 157287
* Recover properly from a redundant 'typename' before a non-nested name. This isRichard Smith2012-05-141-0/+13
| | | | | | | permitted as a Microsoft extension. Patch by William Wilson! (Plus some minor tweaking by me.) llvm-svn: 156786
* Emulate a MSVC bug where the creation of pointer-to-member to protected ↵Francois Pichet2012-04-171-1/+26
| | | | | | | | member of base class is allowed but only from a static function. This fixes a regression when parsing MFC code with clang. llvm-svn: 154924
* The result of the Microsoft __uuidof operator must be considered a global ↵Francois Pichet2012-04-161-2/+2
| | | | | | | | | | | | | lvalue during constant expression evaluation. Otherwise we would get this error in C++11 mode (because of a recent change): error: non-type template argument of type 'const _GUID *' is not a constant expression For code like: template <const GUID* g = &__uuidof(struct_with_uuid)> class COM_CLASS { }; llvm-svn: 154790
* Implement the Microsoft __if_exists/if_not_exists extension in initializer-list.Francois Pichet2011-12-121-0/+29
| | | | | | | | | | | | | | | Necessary to parse Microsoft ATL code. Example: int array[] = { 0, __if_exists(CLASS::Type) {2, } 3 }; will declare an array of 2 or 3 elements depending on if CLASS::Type exists or not. llvm-svn: 146447
* Change the Microsoft __interface keyword to be an alias for struct (not ↵Francois Pichet2011-12-011-0/+5
| | | | | | class) since members are public by default. llvm-svn: 145580
* Add support for Microsoft __if_exists, __if_not_exists extension at class scope.Francois Pichet2011-05-251-1/+26
| | | | | | | | | | | | | | | | Example: typedef int TYPE; class C { __if_exists(TYPE) { TYPE a; } __if_not_exists(TYPE) { this will never be parsed. } }; llvm-svn: 132052
OpenPOWER on IntegriCloud