Commit Graph

698 Commits

Author SHA1 Message Date
Michael Han 84324357b8 [Sema] Semantic analysis for empty-declaration and attribute-declaration.
Introduce a new AST Decl node "EmptyDecl" to model empty-declaration. Have attributes from attribute-declaration appertain
to the EmptyDecl node by creating the AST representations of these attributes and attach them to the EmptyDecl node so these
attributes can be sema checked just as attributes attached to "normal" declarations.

llvm-svn: 175900
2013-02-22 17:15:32 +00:00
Richard Smith 4cabd04e75 Don't accidentally and silently accept C++11 attributes in decl-specifier-seqs
in C++98.

llvm-svn: 175879
2013-02-22 09:15:49 +00:00
Richard Smith 2386c8b221 Per the grammar in [dcl.dcl]p1, a simple-declaration can only have attributes
if it has declarators. We were missing the check for this in a couple of places.

llvm-svn: 175876
2013-02-22 09:06:26 +00:00
Richard Smith 434516c50c Don't skip '_Alignas' when disambiguating 'final'. '_Alignas' can't appear here,
and we used to assert if it did.

llvm-svn: 175866
2013-02-22 06:46:23 +00:00
Richard Smith b3a145293d Add -fbracket-depth=N, analogous to -ftemplate-depth= and -fconstexpr-depth=,
to control the check for the C 5.2.4.1 / C++ [implimits] restriction on nesting
levels for parentheses, brackets and braces.

Some code with heavy macro use exceeds the default limit of 256, but we don't
want to increase it generally to avoid stack overflow on stack-constrained
systems.

llvm-svn: 175855
2013-02-22 01:59:51 +00:00
Richard Smith b19337fbe4 PR15311: Finish implementation of the suggested resolution of core issue 1488,
which allows grouping parens in an abstract-pack-declarator. This was already
mostly implemented, but missed some cases. Add an ExtWarn for use of this
extension until CWG ratifies it.

llvm-svn: 175660
2013-02-20 20:19:27 +00:00
Richard Smith 54ecd9863f Process and handle attributes on conditions and for loop variables. Process and
diagnose attributes on alias declarations, using directives, and attribute
declarations.

llvm-svn: 175649
2013-02-20 19:22:51 +00:00
Richard Smith 4c96e99235 PR15300: Support C++11 attributes on base-specifiers. We don't support any such
attributes yet, so just issue the appropriate diagnostics. Also generalize the
fixit for attributes-in-the-wrong-place code and reuse it here, if attributes
are placed after the access-specifier or 'virtual' in a base specifier.

llvm-svn: 175575
2013-02-19 23:47:15 +00:00
Richard Smith c084bd2888 PR15132: Replace "address expression must be an lvalue or a function
designator" diagnostic with more correct and more human-friendly "cannot take
address of rvalue of type 'T'".

For the case of & &T::f, provide a custom diagnostic, rather than unhelpfully
saying "cannot take address of rvalue of type '<overloaded function type>'".

For the case of &array_temporary, treat it just like a class temporary
(including allowing it as an extension); the existing diagnostic wording
for the class temporary case works fine.

llvm-svn: 174262
2013-02-02 02:14:45 +00:00
Richard Smith 810ad3eb44 Downgrade 'attribute ignored when parsing type' from error to warning, to match
the diagnostic's warn_ name. Switch some places (notably C++11 attributes)
which really wanted an error over to a different diagnostic. Finally, suppress
the diagnostic entirely for __ptr32, __ptr64 and __w64, to avoid producing
diagnostics in important system headers.

llvm-svn: 173788
2013-01-29 10:02:16 +00:00
Richard Smith 1dba27cd49 Implement C++11 [dcl.align]p1 and C11 6.7.5/2 rules for alignas and _Alignas.
llvm-svn: 173779
2013-01-29 09:02:09 +00:00
Richard Smith 52c5b87cc9 PR15017: A '>' can appear after a type-specifier in a template-argument-list.
It turns out that there's no correctness bug here (because we can't have a type
definition in this location), but there was a diagnostic bug.

llvm-svn: 173766
2013-01-29 04:13:32 +00:00
Richard Smith d11c7a1628 Treat alignas and _Alignas as keyword attributes. This allows us to
pretty-print them properly (modulo the more general badness in alignment
attribute printing).

llvm-svn: 173752
2013-01-29 01:48:07 +00:00
Richard Trieu 9c67267a7b Give a more informative error message when the dot or arrow operator is used
on a type.  Currently, it gives a generic "expected unqualified-id" error.
The new error message is "cannot use (dot|arrow) operator on a type".

llvm-svn: 173556
2013-01-26 02:31:38 +00:00
Renato Golin 7b80076b79 Temporarily disabling ms-asm test
llvm-svn: 173510
2013-01-25 22:13:50 +00:00
Chad Rosier 879edcd1a4 Fail these tests in a way that doesn't cause unexpected successes, per Daniel's
suggestion.

llvm-svn: 173367
2013-01-24 20:46:39 +00:00
Chad Rosier 10280a5ef4 Add a triple, per Ben's suggestion.
llvm-svn: 173198
2013-01-22 21:39:58 +00:00
Chad Rosier 163ca0e95e Second attempt to fix ppc bots.
llvm-svn: 173193
2013-01-22 20:57:10 +00:00
Chad Rosier 0c0c02c479 Add x86 requirement to hopefully fix ppc bots.
llvm-svn: 173190
2013-01-22 20:16:41 +00:00
Chad Rosier 33a6e11c21 [ms-inline asm] Remove a warning about ms-style inline assembly not being
supported.

llvm-svn: 173177
2013-01-22 18:18:22 +00:00
Richard Smith 1ac67d1530 Fix five more cases of tokens which can legally follow a type specifier.
llvm-svn: 172886
2013-01-19 03:48:05 +00:00
Nico Weber 0bba2d11d0 Fix parsing of class specifiers before '\n' 'operator'.
r159549 / r159164 regressed clang to reject

  struct s {};
  struct s
  operator++(struct s a)
  { return a; }

This fixes the regression. Richard, pleas check if this looks right.

llvm-svn: 172834
2013-01-18 18:41:42 +00:00
Richard Smith 0015f09877 Parsing support for C11's _Noreturn keyword. No semantics yet.
llvm-svn: 172761
2013-01-17 22:16:11 +00:00
Richard Smith 10876ef571 Implement C++11 semantics for [[noreturn]] attribute. This required splitting
it apart from [[gnu::noreturn]] / __attribute__((noreturn)), since their
semantics are not equivalent (for instance, we treat [[gnu::noreturn]] as
affecting the function type, whereas [[noreturn]] does not).

llvm-svn: 172691
2013-01-17 01:30:42 +00:00
Dmitri Gribenko 29360247c5 Add a test for -Wsemicolon-before-method-body fixit
llvm-svn: 172545
2013-01-15 18:29:04 +00:00
Richard Smith da1f933e12 PR14918: Don't confuse braced-init-lists after template variable declarations
with function definitions.

We really should remove Parser::isDeclarationAfterDeclarator entirely, since
it's meaningless in C++11 (an open brace could be either a function definition
or an initializer, which is what it's trying to differentiate between). The
other caller of it happens to be correct right now...

llvm-svn: 172510
2013-01-15 06:49:38 +00:00
Richard Smith 0faa2b1ae4 Fix behavior of [[gnu::]] function attributes. Per g++'s behavior, these
attributes appertain to a declaration, even though they would be much more
naturally modelled as appertaining to a function type. Previously, we would
try to distribute them from the declarator to the function type, then
reject them for being at an incorrect location. Now, we just distribute them
as far as the declarator; the existing attribute handling code can actually
apply them there just fine.

llvm-svn: 172504
2013-01-15 02:48:13 +00:00
Richard Smith 368ca52cd9 Accept [[gnu::*]] for all __attribute__((*))s which are:
1) Supported by Clang, and
 2) Supported by GCC, and
 3) Documented in GCC's manual.

g++ allows its C++11-style attributes to appertain only to the entity being
declared, and never to a type (even for a type attribute), so we do the same.

llvm-svn: 172382
2013-01-14 07:53:01 +00:00
Richard Smith 01141a95a5 *this is const in a trailing-return-type for a constexpr member function.
llvm-svn: 172375
2013-01-14 01:55:13 +00:00
Richard Smith 5f044ad5f0 PR14855: don't silently swallow a nested-name-specifier after a type name.
llvm-svn: 171908
2013-01-08 22:43:49 +00:00
Michael Han 309af291ef Add fixit hints for misplaced C++11 attributes around class specifiers.
Following r168626, in class declaration or definition, there are a combination of syntactic locations 
where C++11 attributes could appear, and among those the only valid location permitted by standard is
between class-key and class-name. So for those attributes appear at wrong locations, fixit is used to 
move them to expected location and we recover by applying them to the class specifier.
 

llvm-svn: 171757
2013-01-07 16:57:11 +00:00
Guy Benyei d8a08ea98d Re-commit r170428 changes with Linux style file endings.
Add OpenCL images as clang builtin types.

llvm-svn: 170432
2012-12-18 14:38:23 +00:00
Guy Benyei 11169dded0 Revert changes from r170428, as I accidentally changed the line endings of these files to Windows style.
llvm-svn: 170431
2012-12-18 14:30:41 +00:00
Guy Benyei b13abb952a Add OpenCL images as clang builtin types.
llvm-svn: 170428
2012-12-18 12:30:03 +00:00
Nico Weber 7aa4a881e6 Don't require a space between the two ">" in "vector<id<protocol>>" in objc++11.
C++11 allowed writing "vector<vector<int>>" without a space between the two ">".
This change allows this for protocols in template lists too in -std=c++11 mode,
and improves the diagnostic in c++98 mode.

llvm-svn: 170223
2012-12-14 18:22:38 +00:00
Richard Smith c88e40450d PR14549. Don't assert if we see an incomplete decltype specifier at the end of the file.
llvm-svn: 169688
2012-12-09 04:17:57 +00:00
Chad Rosier 636386753a [driver, ms-inline asm] Have -fms-extensions enable the AsmBlocks language
option.  MS-style inline asm can now be enabled by either -fasm-blocks or
-fms-extensions.
rdar://12808010

llvm-svn: 169445
2012-12-05 23:08:09 +00:00
Chad Rosier c8e56e8931 [driver, ms-inline asm] MS-Style inline assembly is controlled by the
-fasm-blocks flag, not the -fms-extensions flag.
rdar://12808010

llvm-svn: 169422
2012-12-05 21:08:21 +00:00
Richard Smith 3e284699d9 In C++, if we hit an error in the class-head, don't try to parse the class body.
Our error recovery path may have made the class anonymous, and that has a pretty
disastrous impact on any attempt to parse a class body containing constructors.

llvm-svn: 169374
2012-12-05 11:34:06 +00:00
Michael Han ddc016d4d7 Implement C++11 [dcl.attr.grammar] p4: If an attribute-specifier-seq appertains to a friend declaration, that declaration shall be a definition.
llvm-svn: 168826
2012-11-28 23:17:40 +00:00
Michael Han 9407e50b04 Improve diagnostic on C++11 attribute specifiers that appear at wrong syntactic locations around class specifiers.
This change list implemented logic that explicitly detects several combinations of locations where C++11 attribute
specifiers might be incorrectly placed within a class specifier. Previously we emit generic diagnostics like 
"expected identifier" for such cases; now we emit specific diagnostic against the misplaced attributes, this also 
fixed a bug in old code where attributes appear at legitimate locations were incorrectly rejected.

Thanks to Richard Smith for reviewing!

llvm-svn: 168626
2012-11-26 22:54:45 +00:00
Andy Gibbs a8df57a962 Made the "expected string literal" diagnostic more expressive
llvm-svn: 168267
2012-11-17 19:16:52 +00:00
Richard Smith 2603b096df PR9903: Recover from a member functon declared with the 'typedef' specifier by
dropping the specifier, just like we do for non-member functions and function
templates declared 'typedef'. Patch by Brian Brooks!

llvm-svn: 168108
2012-11-15 22:54:20 +00:00
Michael Han 64536a6d25 Teach Clang parser to reject C++11 attributes that appertain to declaration specifiers.
We don't support any C++11 attributes that appertain to declaration specifiers so reject 
the attributes in parser until we support them; this also conforms to what g++ 4.8 is doing.

llvm-svn: 167481
2012-11-06 19:34:54 +00:00
Matt Beaumont-Gay 825b9ad2fb Our style for diagnostic messages is to not include a trailing dot.
llvm-svn: 167379
2012-11-05 05:32:00 +00:00
Lang Hames 080b01e622 Test case for r167363.
llvm-svn: 167369
2012-11-04 05:08:08 +00:00
Richard Trieu 7104af04ac Fix test cases I broken when fixing grammar in diagnostic message.
llvm-svn: 167320
2012-11-02 21:41:42 +00:00
Richard Trieu 1f3ea7b6b5 When finding a '(' after '::', emit error with hint to remove '(' and matching
')', if found.  Don't crash.
Fixes PR11852.

llvm-svn: 167268
2012-11-02 01:08:58 +00:00
Nico Weber 729f1e2a1c Fix crash on missing namespace name in namespace alias definition -- PR14085.
Patch from Brian Brooks <brooks.brian@gmail.com>!

llvm-svn: 166893
2012-10-27 23:44:27 +00:00
David Tweed d8bb236e18 Correct test inovocations to use %clang_cc1 rather than direct invocation (so that it can have additional options set when trying to debug issues causing regressions).
llvm-svn: 166681
2012-10-25 13:56:30 +00:00