Commit Graph

54 Commits

Author SHA1 Message Date
David Majnemer 5b63fa02b2 Sema: Static redeclaration after extern declarations is a Microsoft Extension
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
2014-06-18 23:26:25 +00:00
Hans Wennborg b0f2f146bb Allow dllimport/dllexport on inline functions and adjust the linkage.
This is a step towards handling these attributes on classes (PR11170).

Differential Revision: http://reviews.llvm.org/D3772

llvm-svn: 208925
2014-05-15 22:07:49 +00:00
Nico Rieck 82f0b06749 Sema: Check dll attributes on redeclarations
A redeclaration may not add dllimport or dllexport attributes. dllexport is
sticky and can be omitted on redeclarations while dllimport cannot.

llvm-svn: 205197
2014-03-31 14:56:15 +00:00
Richard Trieu 99e1c9515a Move the warning about unused relational comparison from -Wunused-value to
-Wunused-comparison.  Also, newly warn on unused result from overloaded
relational comparisons, now also in -Wunused-comparison.

llvm-svn: 203535
2014-03-11 03:11:08 +00:00
Alp Toker ab1b1dcea7 Pre-declare '::type_info' in MicrosoftMode only, not MicrosoftExt
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
2014-01-05 06:38:18 +00:00
Aaron Ballman 3e424b5070 Teach the diagnostics engine about the Attr type to make reporting on 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
2013-12-26 18:30:57 +00:00
Alp Toker d3f79c5446 Parse Microsoft __declspec appearing after class body
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
2013-11-24 20:24:54 +00:00
David Majnemer a543308ce5 [-fms-extensions] Permit 'override' in C++98 and 'sealed' as a synonym for '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
2013-10-18 00:33:31 +00:00
Douglas Gregor f83b4ea8b6 Under -fms-extensions, only inject a friend tag name when we didn't see a 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
2013-06-27 20:42:30 +00:00
Aaron Ballman 2a6febc0c5 This patch fixes PR16395, when HandleMSProperty returns null due to a declaration with no name.
Patch thanks to Robert Wilhelm.

llvm-svn: 185022
2013-06-26 21:28:44 +00:00
Reid Kleckner 0a0c8895ea [Windows] Fix __declspec(property) when the getter returns a ref
This fixes an issue when parsing atlbase.h.

Patch by Will Wilson!

llvm-svn: 184319
2013-06-19 16:37:23 +00:00
Hans Wennborg 15439bcf79 Disallow reinterpret_cast from pointer to bool on Windows
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
2013-06-06 09:16:36 +00:00
Aaron Ballman ed0ae1d70b Microsoft has a language extension which allows union members to be
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
2013-05-30 16:20:00 +00:00
John McCall 0d9dd73847 Don't put too much thought into whether or not to capture a
type-dependent intermediate result in a postfix ++ pseudo-
object operation.

Test case by Tong Shen.

llvm-svn: 179637
2013-04-16 22:32:04 +00:00
John McCall 5e77d76c95 Basic support for Microsoft property declarations and
references thereto.

Patch by Tong Shen!

llvm-svn: 179585
2013-04-16 07:28:30 +00:00
Dmitri Gribenko d1c91f1763 Accept over-qualified constructor in MSVC emulation mode
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
2013-02-12 17:27:41 +00:00
Eli Friedman 0d0355abfc Change diagnostics for enums with fixed underlying type so in C++98 mode, we cite C++11.
llvm-svn: 167273
2012-11-02 01:34:28 +00:00
Douglas Gregor 43bc036e8a Promote the warning about extra qualification on a declaration from a
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
2012-09-13 20:16:20 +00:00
Eli Friedman 59e41d046e Shift Microsoft enum extensions from -fms-extensions to -fms-compatibility, so -fms-extensions doesn't affect enum semantics in incompatible ways. <rdar://problem/10657186>.
llvm-svn: 150663
2012-02-16 05:20:44 +00:00
Francois Pichet 2056a69cb2 In Microsoft Mode, disable the C++11 strict integral conversion rules for enumerator that were introduced with r148439. Otherwise MSVC headers won't compile in C++ 11 mode.
llvm-svn: 148642
2012-01-21 23:26:50 +00:00
Douglas Gregor 60060d6f8f Treat the Microsoft/Borland keyword "__except" as a context-sensitive
keyword, because both libstdc++ and libc++ use "__except" as an
identifier. Fixes <rdar://problem/10322555>.

llvm-svn: 142636
2011-10-21 03:57:52 +00:00
Douglas Gregor 50cefbf212 When we end up having to parse the initializer of a C++ member early
in -fms-extensions mode, make sure we actually use that initializer
after having handled the declaration. Fixes PR11150.

llvm-svn: 142195
2011-10-17 17:09:53 +00:00
Francois Pichet 3b4de99158 [microsoft] Move missing typename warning from -fms-extensions to -fms-compatibility. Also allow the missing typename warning at function scope.
llvm-svn: 140240
2011-09-21 07:59:49 +00:00
Francois Pichet b3642c2c7a Move Microsoft access specifier bug emulation from -fms-extensions to -fm-compatibility.
llvm-svn: 140189
2011-09-20 22:08:26 +00:00
Francois Pichet 39cba5343d Move the "jump bypasses variable initialization" error -> warning downgrade from -fms-extensions to -fms-compatibility.
llvm-svn: 140008
2011-09-18 21:48:27 +00:00
Francois Pichet 2f55019bf0 In Microsoft mode, warn if an indirect goto jump over a variable initialization.
Also add a test case for the non Microsoft case because such test didn't exist.

llvm-svn: 139971
2011-09-16 23:15:32 +00:00
Francois Pichet 051f5e5cba In Microsoft mode, downgrade "goto into protected scope" from error to 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
2011-09-13 10:26:51 +00:00
Francois Pichet 17ed020569 Add support for MSVC __unaligned attribute. Necessary to parse MSVC headers in 64-bit mode (ie: when _M_IA64 or _M_AMD64 is defined)
more info: http://msdn.microsoft.com/en-us/library/ms177389.aspx

llvm-svn: 137935
2011-08-18 09:59:55 +00:00
Francois Pichet e37eebabe7 Microsoft friend acting as a forward declaration; try#2. Now only 2 lines.
llvm-svn: 132387
2011-06-01 04:14:20 +00:00
Francois Pichet a9f436b064 Revert 132332 (Microsoft friend as a forward declaration), John McCall pointed out a better/simpler way to do it.
llvm-svn: 132369
2011-05-31 22:36:05 +00:00
Francois Pichet 3fd47df366 For compatibility with MSVC, a friend declaration also act as a forward declaration if the tag name is not already declared. The tag name is declared in the next outermost non record scope.
Example:

class A {
  friend class B;
  B* b;
};
B* global_b;

llvm-svn: 132332
2011-05-31 11:44:00 +00:00
Francois Pichet a8032e96b5 MSVC doesn't do any validation regarding exception specification.
llvm-svn: 131950
2011-05-24 02:11:43 +00:00
Francois Pichet efb1af9ae8 Emulate a MSVC bug where if during an using declaration name lookup, the declaration found is unaccessible (private) and that declaration was bring into scope via another using declaration whose target declaration is accessible (public) then no error is generated.
Example:
class A { public: int f();  };
class B : public A { private: using A::f; };
class C : public B { private: using B::f; };

Here, B::f is private so this should fail in Standard C++, but because B::f refers to A::f which is public MSVC accepts it.

This fixes 1 error when parsing MFC code with clang.

llvm-svn: 131896
2011-05-23 03:43:44 +00:00
Francois Pichet c2fac71c75 Revert 131347. It asserts if the specialization in within a class template:
template<class U> 
struct X1 {
  template<class T> void f(T*);
  template<> void f(int*) { } 
};

Won't be so simple. I need to think more about it.

llvm-svn: 131362
2011-05-14 19:17:07 +00:00
Francois Pichet 6744e14d9c In Microsoft mode, allow template function explicit specialization at class scope.
Necessary to parse MFC and MSVC standard lib code.

Example:
struct X {
  template<class T> void f(T) { }
  template<> void f(int) { } 
}

llvm-svn: 131347
2011-05-14 17:46:46 +00:00
Francois Pichet b796b632a8 In Microsoft mode, allow conversion from pointer to integral type no matter what size the integral type is. Necessary to parse MFC code.
Example:
void f(char *ptr) {
  char var = (char)ptr;
}

llvm-svn: 131201
2011-05-11 22:13:54 +00:00
Francois Pichet a7c8da40a8 Fix test.
llvm-svn: 131077
2011-05-08 23:15:10 +00:00
Francois Pichet bc6ebb5b76 Allow implicit conversion from function pointer to void* in Microsoft mode.
Necessary to parse MFC code.

llvm-svn: 131076
2011-05-08 22:52:41 +00:00
Francois Pichet e900b10a29 Downgrade error "static declaration of 'foo' follows non-static declaration" to a warning in Microsoft mode.
llvm-svn: 129985
2011-04-22 08:14:00 +00:00
Francois Pichet 48c946e5ef In Microsoft mode, within class scope, if a CXXScopeSpec's type is equal to the type of one of the base classes then downgrade the missing typename error to a warning. Up to now this is the only case I found where MSVC doesn't require "typename" at class scope. Really strange!
This fixes 1 error when parsing the MSVC 2008 header files.
Example:

template<class T> class A {
public:
  typedef int TYPE;
};
template<class T> class B : public A<T> {
public:
  A<T>::TYPE a; // no typename required because A<T> is a base class.
};

llvm-svn: 129425
2011-04-13 02:38:49 +00:00
Francois Pichet 53fe2bb29e MSVC accepts that default parameters be redefined for member functions
of template class. The new value is ignored.

This fixes 1 error when parsing MSVC 2010 header files with clang.

llvm-svn: 129240
2011-04-10 03:03:52 +00:00
Francois Pichet 117d23c5bc Add a triple to make the test friendly on no windows platform.
llvm-svn: 128459
2011-03-29 11:38:04 +00:00
Francois Pichet 3096d209bf Accept __declspec(dllimport) for function defined at class scope in Microsoft mode.
This fixes a bunch of errors when compiling MSVC header files with the -DDLL flag.

llvm-svn: 128457
2011-03-29 10:39:17 +00:00
Francois Pichet 13b4e68642 Downgrade err_mismatched_exception_spec to a ExtWarning in Microsoft mode. MSVC doesn't do any validation on exception specifications.
This remove 1 error when parsing MSVC stl lib with clang.

llvm-svn: 127961
2011-03-19 23:05:18 +00:00
John McCall 8feeb49662 Semantic checking for exception specifications should be triggered by
whether C++ exceptions are enabled, not exceptions in general.  PR9358.

llvm-svn: 126820
2011-03-02 02:04:40 +00:00
Douglas Gregor 996a735b88 We need a longer long when testing this pathe Microsoft fixed-underlying-type extension for enumeration types
llvm-svn: 126250
2011-02-22 21:42:31 +00:00
Douglas Gregor a1aec29a2d Enable enumeration types with a fixed underlying type, e.g.,
enum X : long { Value = 0x100000000 };

when in Microsoft-extension mode (-fms-extensions). This (now C++0x)
feature has been supported since Microsoft Visual Studio .NET 2003.

llvm-svn: 126243
2011-02-22 20:32:04 +00:00
Francois Pichet 7d92ee3852 Remove a c++ file test I inadvertently added in Sema last week.
llvm-svn: 123608
2011-01-17 01:08:01 +00:00
Francois Pichet a310806ae5 Microsoft enum extensions. 2 things will change on -fms-extensions:
1. enum underlying type is int by default.
2. Error "enumerator value is not representable in the underlying type"is a ExtWarning

llvm-svn: 116704
2010-10-18 15:01:13 +00:00
Francois Pichet 488b4a7d94 Add basic support for Microsoft enum forward declaration.
Assigning an underlying integral type to an enum forward declaration will come in a next patch.

llvm-svn: 113716
2010-09-12 05:06:55 +00:00