Commit Graph

871 Commits

Author SHA1 Message Date
Ehsan Akhgari 833ed943d6 Don't get confused on the number of braces when braces start after the first __asm
Summary:
Without this, we would not consume the closing brace which would cause
the parser to start consuming C++ and bad things would happen.

Reviewers: majnemer

Subscribers: cfe-commits

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

llvm-svn: 213032
2014-07-15 02:21:41 +00:00
Richard Smith 5a477c5e37 PR19751: (T())++ is not a cast-expression.
llvm-svn: 213022
2014-07-15 00:11:48 +00:00
Kaelyn Takata 22101f9689 Continue parsing an expression list even after an error is encountered.
Otherwise, multiple errors such as having unknown identifiers for two
arguments won't be diagnosed properly (e.g. only the first one would
have a diagnostic message if typo correction fails even though both
would be diagnosed if typo correction suggests a replacement).

llvm-svn: 213003
2014-07-14 22:48:10 +00:00
Aaron Ballman ee7d10b5aa Giving this test a triple to satisfy the build bots.
llvm-svn: 212418
2014-07-06 20:07:16 +00:00
Aaron Ballman 1c8a5d75f1 The MicrosoftExtensions.c test file should not rely on -x objective-c++. 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
2014-07-06 20:04:10 +00:00
Aaron Ballman f21ba37f1b This test case does not require -Wno-missing-declarations or -x objective-c++.
llvm-svn: 212416
2014-07-06 19:44:38 +00:00
Ehsan Akhgari 7e36a19b20 Move InterlockedBitTestAndSet into its own test file
Summary:
This gives us back the test coverage we lost when I made
MicrosoftExtensions.c x86-only.

Reviewers: majnemer

Subscribers: cfe-commits

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

llvm-svn: 212414
2014-07-06 18:45:44 +00:00
Ehsan Akhgari d2c3ba6fbe Fix the MicrosoftExtensions.c target
llvm-svn: 212393
2014-07-06 05:58:55 +00:00
Ehsan Akhgari d1e8abb1fb Enable the InterlockedBitTestAndSet test
llvm-svn: 212392
2014-07-06 05:50:19 +00:00
Ehsan Akhgari 0f89fac7a5 Add support for nested blocks in Microsoft inline assembly
This fixes http://llvm.org/PR20204.

llvm-svn: 212389
2014-07-06 05:26:54 +00:00
Hans Wennborg 82dd877e8a Don't allow dllimport variables in constant initializers
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
2014-06-25 22:19:48 +00:00
Reid Kleckner 6d8d22ae40 Fix parsing nested __if_exists blocks
Rather than having kw___if_exists be a special case of
ParseCompoundStatementBody, we can look for kw___if_exists in the big
switch over for valid statement tokens in ParseStatementOrDeclaration.

Nested __if_exists blocks are used in the DECLARE_REGISTRY_RESOURCEID
macro from atlcom.h.

llvm-svn: 211654
2014-06-25 00:28:35 +00:00
Reid Kleckner 6be648f047 Add a missing test for the __if_exists extension
MSVC does not create a new scope for the body of an __if_exists compound
statement.  Clang already gets this right today, but it was untested.

llvm-svn: 211650
2014-06-25 00:10:50 +00:00
Reid Kleckner 27e1473143 Split tests for __if_exists out into their own file
llvm-svn: 211649
2014-06-25 00:08:10 +00:00
Richard Trieu f4b81d0029 Provide a better diagnostic when braces are put before the identifier.
When a user types:
  int [4] foo;
assume that the user means:
  int foo[4];

Update the information for 'foo' to prevent additional errors, and provide
a fix-it hint to move the brackets to the correct location.

Additionally, suggest parens for types that require it, such as:
  int [4] *foo;
to:
  int (*foo)[4];

llvm-svn: 211641
2014-06-24 23:14:24 +00:00
Eli Bendersky 36a6193bf4 Fix PR20081: Parsing templates in the presence of -x cuda -std=c++11
http://reviews.llvm.org/D4222

llvm-svn: 211357
2014-06-20 13:09:59 +00:00
Eli Bendersky f637790102 Fix PR20069: bad loop pragma arguments crash FE
This patch fixes a crash when handling malformed arguments to loop pragmas such
as: "#pragma clang loop vectorize(()".  Essentially any argument which is not an
identifier or constant resulted in a crash.  This patch also changes a couple of
the error messages which weren't quite correct.  New behavior with this patch vs
old behavior:

#pragma clang loop vectorize(1)
OLD: error: missing keyword; expected 'enable' or 'disable'
NEW: error: invalid argument; expected 'enable' or 'disable'

#pragma clang loop vectorize()
OLD: error: expected ')'
NEW: error: missing argument to loop pragma 'vectorize'

#pragma clang loop vectorize_width(bad)
OLD: error: missing value; expected a positive integer value
NEW: error: invalid argument; expected a positive integer value

#pragma clang loop vectorize(bad)
OLD: invalid keyword 'bad'; expected 'enable' or 'disable'
NEW: error: invalid argument; expected 'enable' or 'disable'

http://reviews.llvm.org/D4197

Patch by Mark Heffernan

llvm-svn: 211292
2014-06-19 18:30:15 +00:00
Richard Smith 78e1ca692b [C++1z] Implement N4051: 'typename' is permitted instead of 'class' when declaring a template template parameter.
llvm-svn: 211031
2014-06-16 15:51:22 +00:00
Bill Schmidt 1cf7c64fa5 [PPC64LE] Run some existing Altivec tests on powerpc64le as well
There are several Altivec tests that formerly ran only on big-endian
targets (and in some cases only on 32-bit targets).  It is useful to
verify these on little-endian targets as well.

While testing these, I discovered a typo in <altivec.h>.  This is also
fixed by this patch.

llvm-svn: 210928
2014-06-13 18:30:06 +00:00
Eli Bendersky 86483b3a0c Add loop unroll pragma support
http://reviews.llvm.org/D4089

Patch by Mark Heffernan.

llvm-svn: 210667
2014-06-11 17:56:26 +00:00
Richard Smith edcb26e61b PR19993: don't assert/crash if a static data member is initialized by '= delete;'.
llvm-svn: 210617
2014-06-11 00:49:52 +00:00
Reid Kleckner 4173f6aff9 *Really* fix DOS newlines introduced in r210330
r210369 didn't quite catch all of them.

llvm-svn: 210593
2014-06-10 21:35:24 +00:00
Aaron Ballman b06b15aa28 Adding a new #pragma for the vectorize and interleave optimization hints.
Patch thanks to Tyler Nowicki!

llvm-svn: 210330
2014-06-06 12:40:24 +00:00
Alp Toker e03e9e15f2 Preprocessor: make C++ operator names as macro identifiers a compatible 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
2014-05-31 16:32:22 +00:00
Alp Toker 6b0beb0cbd Add a PR reference for XFAILed test
llvm-svn: 209730
2014-05-28 12:26:32 +00:00
Dario Domizioli 13a0a38fe0 Implemented support for "pragma clang optimize on/off", based on attribute 'optnone'.
This patch implements support for selectively disabling optimizations on a
range of function definitions through a pragma. The implementation is that
all function definitions in the range are decorated with attribute
'optnone'.

    #pragma clang optimize off
    // All function definitions in here are decorated with 'optnone'.
    #pragma clang optimize on
    // Compilation resumes as normal.

llvm-svn: 209510
2014-05-23 12:13:25 +00:00
Serge Pavlov 921c2ba18b Improved recovery of switch statement
Make better diagnostic produced by erroneous switch statement.
It fixes PR19022.

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

llvm-svn: 209302
2014-05-21 14:48:43 +00:00
Alp Toker b05e0b53b9 Preprocessor: support defined() with operator names for MS compatibility
Also flesh out missing tests, improve diagnostic QOI and fix a couple of corner
cases found in the process.

Fixes PR10606.

llvm-svn: 209276
2014-05-21 06:13:51 +00:00
Richard Smith aba8b36abf Replace completely bogus ambiguous-compound-literal-in-C++ code with something
that isn't always wrong.

llvm-svn: 208844
2014-05-15 02:51:15 +00:00
Richard Smith 87e11a426d PR19748: Make sure we don't lose colon protection after the parenthesized type-id in a cast-expression.
llvm-svn: 208843
2014-05-15 02:43:47 +00:00
Ismail Pazarbasi 77c456be3e Revised wording for diagnostics in r208299
llvm-svn: 208401
2014-05-09 09:49:29 +00:00
Ismail Pazarbasi 49ff754d4b Suggest fix-it ':' when '=' used in for-range-declaration
Fix for PR19176. Clang will suggest a fix-it hint for cases like:
  int arr[] = {1, 2, 3, 4};
  for (auto i = arr)
              ^
              :

llvm-svn: 208299
2014-05-08 11:28:25 +00:00
Richard Trieu a1342406f2 Fix PR 19630, don't crash when file ends with whitespace.
llvm-svn: 207883
2014-05-02 23:40:32 +00:00
Hans Wennborg b6d4e8cd4e Handle -fdelayed-template-parsing of out-of-line definitions of
class template member classes (PR19613)

Also improve this code in general by implementing suggestions
from Richard.

Differential Revision: http://reviews.llvm.org/D3555?id=9020

llvm-svn: 207822
2014-05-02 02:01:07 +00:00
Benjamin Kramer 1adc8c3391 Print detailed vector type information on diagnostics.
We never aka vector types because our attributed syntax for it is less
comprehensible than the typedefs. This leaves the user in the dark when
the typedef isn't named that well.

Example:
  v2s v; v4f w;
  w = v;

The naming in this cases isn't even that bad, but the error we give is
useless without looking up the actual typedefs.
t.c:6:5: error: assigning to 'v4f' from incompatible type 'v2s'

Now:
t.c:6:5: error: assigning to 'v4f' (vector of 4 'float' values) from
    incompatible type 'v2s' (vector of 2 'int' values)

We do this for all diagnostics that print a vector type.

llvm-svn: 207267
2014-04-25 20:41:38 +00:00
Argyrios Kyrtzidis ec328b8e6f [Parser] Remove "add -fmodules" from the "use of '@import' when modules are disabled, add -fmodules" error.
We disable modules for C++, at which point this is confusing.
rdar://16641918

llvm-svn: 206440
2014-04-17 02:32:52 +00:00
Aaron Ballman ef5d94caf0 Fixing a typo, updating the diagnostic wording and logic based on post-commit review feedback. Amends r206186.
llvm-svn: 206229
2014-04-15 00:36:39 +00:00
Aaron Ballman 95d570335c Properly diagnose Microsoft __declspec attributes which have optional argument lists when the arguments are elided. eg)
__declspec(deprecated()) // error
__declspec(deprecated) // OK
__declspec(deprecated("")) // OK

llvm-svn: 206191
2014-04-14 16:44:26 +00:00
Aaron Ballman 35f9421c55 Properly diagnose standard C++ attributes which have optional argument lists when the arguments are elided. eg)
[[deprecated()]] // error
[[deprecated]] // OK
[[deprecated("")]] // OK
[[gnu::deprecated()]] // OK

llvm-svn: 206186
2014-04-14 16:03:22 +00:00
Serge Pavlov 6a7ffbed8a Improve error recovery around colon.
Parse of nested name spacifier is modified so that it properly recovers
if colon is mistyped as double colon in case statement.
This patch fixes PR15133.

Differential Revision: http://llvm-reviews.chandlerc.com/D2870

llvm-svn: 206135
2014-04-13 16:52:03 +00:00
Richard Smith 9e2f0a4f62 PR19339: Disambiguate lambdas with init-captures from designated initializers
properly.

llvm-svn: 206128
2014-04-13 04:31:48 +00:00
Saleem Abdulrasool f4c9e49f94 Driver: add target definition for Windows on ARM
This introduces the definitions needed for the Windows on ARM target.  Add
target definitions for both the MSVC environment and the MSVC + Itanium C++ ABI
environment.  The Visual Studio definitions correspond to the definitions
provided by Visual Studio 2012.

llvm-svn: 205650
2014-04-04 20:31:19 +00:00
David Blaikie abe1a398e3 Render anonymous entities as '(anonymous <thing>)' (and lambdas as '(lambda at ... )')
For namespaces, this is consistent with mangling and GCC's debug info
behavior. For structs, GCC uses <anonymous struct> but we prefer
consistency between all anonymous entities but don't want to confuse
them with template arguments, etc, so we'll just go with parens in all
cases.

llvm-svn: 205398
2014-04-02 05:58:29 +00:00
Aaron Ballman fdd783a501 Unify __declspec attribute argument parsing with the common attribute argument parsing code.
This removes a diagnostic that is no longer required (the semantic engine now properly handles attribute syntax so __declspec and __attribute__ spellings no longer get mismatched). This caused several testcases to need updating for a slightly different wording.

llvm-svn: 205234
2014-03-31 18:18:43 +00:00
Aaron Ballman b8e203939e Introduced an attribute syntax-neutral method for parsing attribute arguments that is currently being used by GNU and C++-style attributes. This allows C++11 attributes with argument lists to be handled properly, fixing the "deprecated", "type_visibility", and capability-related attributes with arguments.
llvm-svn: 205226
2014-03-31 17:32:39 +00:00
David Majnemer ee4f4025c3 Sema: Implement DR317
Summary:
Declaring a function as inline after it has been defined is in violation
of [dcl.fct.spec]p4.  The program would get a strong definition instead
of getting a function with linkonce_odr linkage.

Reviewers: rsmith

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D3220

llvm-svn: 205129
2014-03-30 06:44:54 +00:00
Fariborz Jahanian a773d08618 Objective-C. Improve diagnostic error for '@import'
when modules are disabled. // rdar://15505492

llvm-svn: 204862
2014-03-26 22:02:43 +00:00
Richard Smith 997ff02c7b Fix a typo in r204164 that made *all* keywords available in OpenCL mode.
llvm-svn: 204196
2014-03-18 22:43:19 +00:00
Richard Smith ae385084c5 Implement the MS extension __identifier properly: take a token and strip it of
its keywordliness.

llvm-svn: 203987
2014-03-15 00:06:08 +00:00
Richard Smith 8e6002f3bd Fix crash if delayed template parsing meets an erroneous trailing return type.
Based on a patch and test by Stephan Tolksdorf! Refactoring and fixing adjacent
brokenness by me.

llvm-svn: 203733
2014-03-12 23:14:33 +00:00