Commit Graph

387 Commits

Author SHA1 Message Date
Fariborz Jahanian ea7a133775 Improve on diagnostics when an objc class is used as
a stand-alone type declaration.

llvm-svn: 100588
2010-04-07 00:22:00 +00:00
Chris Lattner 005fc1bbcf fix PR6782, an accept invalid. We weren't emitting the diagnostic
returned by SetTypeSpecType.

llvm-svn: 100443
2010-04-05 18:18:31 +00:00
Fariborz Jahanian d077f719be Improve diagnosing when a method type does not start with '-'|'+'
when parsing. Fixes radar 7822196.

llvm-svn: 100248
2010-04-02 23:15:40 +00:00
Fariborz Jahanian 083712fbb7 Issue better syntax error when objc's messaging
ares are not separated by ':' (radar 7030268).

llvm-svn: 100040
2010-03-31 20:22:35 +00:00
Argyrios Kyrtzidis 90ab3b7779 Don't skip past the '}' if an expression has error and is not followed by ';'.
llvm-svn: 99972
2010-03-31 00:37:59 +00:00
Argyrios Kyrtzidis 998d51b98f When "delayed parsing" C++ default arguments, if there is an error, there may be tokens left in the token stream
that will interfere (they will be parsed as if they are after the class' '}') and a crash will occur because
the CachedTokens that holds them will be deleted while the lexer is still using them.

Make sure that the tokens of default args are removed from the token stream.
Fixes PR6647.

llvm-svn: 99939
2010-03-30 22:14:32 +00:00
Douglas Gregor 00a0cf70d9 Don't consume tokens past the end-of-file in an @interface. Fixes
<rdar://problem/7735566>.

llvm-svn: 98613
2010-03-16 06:04:47 +00:00
Chris Lattner 0a65574ccb implement support for -Wno-deprecated, PR6534. While
I'm in there, change the altivec diagnostics to use 'double' 
instead of "double" for consistency.

llvm-svn: 97919
2010-03-07 18:50:21 +00:00
John McCall 8bc2a70dfe Don't infinite-loop if TryAnnotateCXXScopeToken fails to annotate but doesn't
signal an error.  This can happen even when the current token is '::' if
this is a ::new or ::delete expression.

This was an oversight in my recent parser refactor;  fixes PR 5825.

llvm-svn: 97462
2010-03-01 18:20:46 +00:00
John McCall 1f476a1783 Fix an assertion-on-error during tentative constructor parsing by
propagating error conditions out of the various annotate-me-a-snowflake
routines.  Generally (but not universally) removes redundant diagnostics
as well as, you know, not crashing on bad code.  On the other hand,
I have just signed myself up to fix fiddly parser errors for the next
week.  Again.

llvm-svn: 97221
2010-02-26 08:45:28 +00:00
Richard Pennington 14cc983d86 Retain attributes for K&R style parameter declarations.
llvm-svn: 96941
2010-02-23 12:22:13 +00:00
Charles Davis 163855f46d dllimport and dllexport are declspec attributes, too. They're also
Win32-specific.

Also, fix a test to use FileCheck instead of grepping LLVM IR.

llvm-svn: 96364
2010-02-16 18:27:26 +00:00
Fariborz Jahanian 8efe0ec899 Issue a bettter diagnostics for incorrect property setter name.
(radar 7647953).

llvm-svn: 96284
2010-02-15 22:20:11 +00:00
John McCall 38200b081a Improve the diagnostic given when referring to a tag type without a tag (in C)
or that's been hidden by a non-type (in C++).

The ideal C++ diagnostic here would note the hiding declaration, but this
is a good start.

llvm-svn: 96141
2010-02-14 01:03:10 +00:00
Douglas Gregor 3ce7493c35 Teach C++ name lookup that it's okay to look in a scope without a
context. This happens fairly rarely (which is why we got away with
this bug). Fixes PR6184, where we skipped over the template parameter
scope while tentatively parsing.

llvm-svn: 95376
2010-02-05 07:07:10 +00:00
John Thompson 2233460de6 First stage of adding AltiVec support
llvm-svn: 95335
2010-02-05 00:12:22 +00:00
Chris Lattner 5e854b95f3 Declarators can have grouping parens. This fixes rdar://7608537.
llvm-svn: 95246
2010-02-03 20:41:24 +00:00
Chris Lattner 35af0ab3eb fix PR6216
llvm-svn: 95185
2010-02-03 01:45:03 +00:00
Chris Lattner afe6a840d4 the declspec of a declaration can have storage-class specifiers,
type qualifiers and type specifiers in any order.   For example,
this is valid: struct x {...} typedef y;

This fixes PR6208.

llvm-svn: 95094
2010-02-02 17:32:27 +00:00
Chris Lattner 916dbf114a improve diagnostics for C++ struct ; issues. Before:
t.cc:4:3: error: expected ';' at end of declaration list
  int y;
  ^
t.cc:6:1: error: expected ';' at end of declaration list
};
^

After:

t.cc:3:8: error: expected ';' at end of declaration list
  int x
       ^
       ;
t.cc:5:8: error: expected ';' at end of declaration list
  int z
       ^
       ;

llvm-svn: 95039
2010-02-02 00:43:15 +00:00
Chris Lattner 245c5335b5 improve diagnostics on missing ; in a struct. Before:
t.c:4:3: error: expected ';' at end of declaration list
  int y;
  ^
t.c:4:8: warning: extra ';' inside a struct or union
  int y;
       ^
t.c:6:1: warning: expected ';' at end of declaration list
};
^

After:

t.c:3:8: error: expected ';' at end of declaration list
  int x  // expected-error {{expected ';' at end of declaration list}}
       ^
       ;
t.c:5:8: warning: expected ';' at end of declaration list
  int z
       ^
       ;

llvm-svn: 95038
2010-02-02 00:37:27 +00:00
Mike Stump 0978af83b3 Insulate these from changes to the default for -Wunreachable-code.
llvm-svn: 94326
2010-01-23 20:12:18 +00:00
Alexis Hunt c88db06565 Implement semantic checking for C++ literal operators.
This now rejects literal operators that don't meet the requirements.
Templates are not yet checked for.

llvm-svn: 93315
2010-01-13 09:01:02 +00:00
Eli Friedman affd5fdf37 Make sure to give an error for template argument lists followed by junk.
llvm-svn: 92177
2009-12-27 22:31:18 +00:00
Chris Lattner 3859c74b32 fix the microsoft "charify" extension to return the charified token
as a character literal, not a string literal.  This might fix
rdar://7486575

llvm-svn: 92025
2009-12-23 19:15:27 +00:00
Chris Lattner 1576850a76 fix PR5500: clang fails to parse inline asm with :: in C++ mode
llvm-svn: 91802
2009-12-20 23:08:04 +00:00
John McCall e2ade289be Teach TryAnnotateTypeOrScopeToken to deal with already-annotated
scope specifiers.  Fix a tentative parsing bug that came up in LLVM.
Incidentally fixes some random FIXMEs in an existing testcase.

llvm-svn: 91734
2009-12-19 00:35:18 +00:00
Daniel Dunbar 8fbe78f6fc Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.
- This is designed to make it obvious that %clang_cc1 is a "test variable"
   which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it
   can be useful to redefine what gets run as 'clang -cc1' (for example, to set
   a default target).

llvm-svn: 91446
2009-12-15 20:14:24 +00:00
Fariborz Jahanian 6ec5119b5f Make tests use the new clang cc1 flag.
llvm-svn: 91300
2009-12-14 17:51:07 +00:00
Chris Lattner 3c674cf804 If we enter parens, colons can become un-sacred, allowing us to emit
a better diagnostic in the second example.

llvm-svn: 91040
2009-12-10 02:08:07 +00:00
Chris Lattner 244b96ba0a fix a more evil case of : / :: confusion arising in ?:.
llvm-svn: 91039
2009-12-10 02:02:58 +00:00
Chris Lattner 17c3b1f278 fix incorrect parsing of bitfields pointed out by Doug. I chose
to use ColonProtectionRAIIObject in the C codepath even though it
won't matter for consistency.

llvm-svn: 91037
2009-12-10 01:59:24 +00:00
Chris Lattner 125c0ee5c7 fix PR5740: a colon is sacred when parsing case statement expressions!
llvm-svn: 91016
2009-12-10 00:38:54 +00:00
Chris Lattner 793c75a28f rename testcase
llvm-svn: 91015
2009-12-10 00:37:13 +00:00
Fariborz Jahanian 26de2e594b Fixes a bogus error when declaring an extern "C" array.
(fixes radar 7457109).

llvm-svn: 90986
2009-12-09 21:39:38 +00:00
Chris Lattner 1c4280328d reapply my patch for PR4451, which improves diagnostics for :: vs : confusion.
This time with a fix to bail out when in a dependent context.

llvm-svn: 90730
2009-12-07 01:36:53 +00:00
Chris Lattner 045cbffb65 fix a crash on invalid I found when working on something unrelated.
llvm-svn: 90729
2009-12-07 00:48:47 +00:00
Chris Lattner ed085234dc revert my previous patch, it is breaking something and I don't have time
to fix it ATM.

llvm-svn: 90717
2009-12-06 20:58:07 +00:00
Chris Lattner 71d5bf1c5d implement PR4451, improving error recovery for a mistaken : where a :: was
intended.  On the first testcase in the bug, we now produce:

cxx-decl.cpp:12:2: error: unexpected ':' in nested name specifier
y:a a2;
 ^
 ::

instead of:

t.cc:8:1: error: C++ requires a type specifier for all declarations
x:a a2;
^
t.cc:8:2: error: invalid token after top level declarator
x:a a2;
 ^
 ;
t.cc:9:11: error: use of undeclared identifier 'a2'
x::a a3 = a2;
          ^

llvm-svn: 90713
2009-12-06 19:08:11 +00:00
John McCall 6e9f8f6374 Honor using declarations in overload resolution. Most of the code for
overloaded-operator resolution is wildly untested, but the parallel code for
methods seems to satisfy some trivial tests.

Also change some overload-resolution APIs to take a type instead of an expression,
which lets us avoid creating a spurious CXXThisExpr when resolving implicit
member accesses.

llvm-svn: 90410
2009-12-03 04:06:58 +00:00
Daniel Dunbar 4e7596cc3a Normalize options to use '-FOO' instead of '--FOO'.
llvm-svn: 90071
2009-11-29 09:33:10 +00:00
Daniel Dunbar f4a72b06c2 Use '-x' 'foo' instead of '-x=foo'.
llvm-svn: 90069
2009-11-29 09:32:31 +00:00
Daniel Dunbar 7427fe28dc Remove unnecessary -fms-extensions=0 from tests (this command line syntax is going away).
llvm-svn: 90066
2009-11-29 09:31:53 +00:00
Alexis Hunt 3d221f2fce Add DeclarationName support for C++0x operator literals. They should now work as
function names outside of templates - they'll probably cause some damage there as
they're largely untested.

llvm-svn: 90064
2009-11-29 07:34:05 +00:00
Alexis Hunt ed0530f694 Fix test and handle IK_LiteralOperatorId in a few more places.
llvm-svn: 90030
2009-11-28 08:58:14 +00:00
Alexis Hunt 344585006c Add Parser support for C++0x literal operators ('operator "" i').
DeclarationName can't handle them yet, so right now Parser just errors out on them.

llvm-svn: 90027
2009-11-28 04:44:28 +00:00
John Thompson 5bc5cbe2a2 Fix attribute between function decl ')' and '{' or '=0'
llvm-svn: 89894
2009-11-25 22:58:06 +00:00
Douglas Gregor 0bba2b6110 Tweak expected error to match what should happen, once using declarations work
llvm-svn: 89876
2009-11-25 19:28:08 +00:00
Douglas Gregor 5c80a27ba2 Implement support for default template arguments of function templates.
llvm-svn: 89874
2009-11-25 18:55:14 +00:00
Alexis Hunt 96d5c76498 Added rudimentary C++0x attribute support.
The following attributes are currently supported in C++0x attribute
lists (and in GNU ones as well):
 - align() - semantics believed to be conformant to n3000, except for
   redeclarations and what entities it may apply to
 - final - semantics believed to be conformant to CWG issue 817's proposed
   wording, except for redeclarations
 - noreturn - semantics believed to be conformant to n3000, except for
   redeclarations
 - carries_dependency - currently ignored (this is an optimization hint)

llvm-svn: 89543
2009-11-21 08:43:09 +00:00
Douglas Gregor 11f3050141 Test case for parsing-recovery change to @synthesized
llvm-svn: 89260
2009-11-18 22:37:38 +00:00
Fariborz Jahanian 1bc0f9affc This patch fixes a bug in misdiagnosing correct
use of pointer to data member.

llvm-svn: 89251
2009-11-18 21:54:48 +00:00
Daniel Dunbar feedba68b5 Don't #include <stdio.h> when tests don't need it, or use clang instead of clang-cc when they do.
llvm-svn: 89070
2009-11-17 08:57:36 +00:00
Daniel Dunbar 9d5118a69c Fix broken tests, exposed by improved -verify.
llvm-svn: 88749
2009-11-14 03:24:04 +00:00
Daniel Dunbar 34546ce43d Remove RUN: true lines.
llvm-svn: 86432
2009-11-08 01:47:25 +00:00
Daniel Dunbar 8b57697954 Eliminate &&s in tests.
- 'for i in $(find . -type f); do sed -e 's#\(RUN:.*[^ ]\) *&& *$#\1#g' $i | FileUpdate $i; done', for the curious.

llvm-svn: 86430
2009-11-08 01:45:36 +00:00
Fariborz Jahanian 2f487126ce Make fragile-abi test run happy.
llvm-svn: 86293
2009-11-06 22:15:27 +00:00
Fariborz Jahanian 95239110cd Fix a bogus objective-c warning with -pedantic.
(radar 7370882).

llvm-svn: 86291
2009-11-06 21:48:47 +00:00
John McCall 644a4181c9 Implement -Wsign-compare, or at least the actual comparison part of it.
Conditional operands are next.

Fixes part of rdar://problem/7289584.

llvm-svn: 86083
2009-11-05 00:40:04 +00:00
Douglas Gregor 916462b2f7 Improve diagnostics when parsing something like
template<> struct foo<int> { ... };

where "foo" does not refer to a template. Fixes PR3844.

llvm-svn: 85616
2009-10-30 21:46:58 +00:00
John Thompson ec87bb5c46 Disabling some MS extensions which cause these tests to fail
llvm-svn: 85236
2009-10-27 14:31:53 +00:00
Fariborz Jahanian 9a14b84ac5 Diagnose misuse of '.*' and '->*' operators during parse
instead of crashing in code gen.

llvm-svn: 84968
2009-10-23 21:01:39 +00:00
John Thompson 9f2a365fe2 test commit
llvm-svn: 83945
2009-10-13 05:45:19 +00:00
Douglas Gregor bbe8f46621 Improve checking for specializations of member classes of class
templates, and keep track of how those member classes were
instantiated or specialized. 

Make sure that we don't try to instantiate an explicitly-specialized
member class of a class template, when that explicit specialization
was a declaration rather than a definition.

llvm-svn: 83547
2009-10-08 15:14:33 +00:00
Douglas Gregor 3dad842b35 Rework the Parse-Sema interaction for friends to better support friend
class templates. We now treat friend class templates much more like
normal class templates, except that they still get special name lookup
rules. Fixes PR5057 and eliminates a bunch of spurious diagnostics in
<iostream>.

llvm-svn: 82848
2009-09-26 06:47:28 +00:00
Douglas Gregor 450f0084a2 WIP implementation of explicit instantiation of function templates,
member functions of class template specializations, and static data
members. The mechanics are (mostly) present, but the semantic analysis
is very weak.

llvm-svn: 82789
2009-09-25 18:43:00 +00:00
Daniel Dunbar e9266a3ee1 Add RUN line.
llvm-svn: 81654
2009-09-12 23:06:30 +00:00
Anders Carlsson 085af1fd29 Add a test for PR3733.
llvm-svn: 81622
2009-09-12 19:35:43 +00:00
Mike Stump 11289f4280 Remove tabs, and whitespace cleanups.
llvm-svn: 81346
2009-09-09 15:08:12 +00:00
Douglas Gregor 684582b632 Improve top-level-semicolon test a bit
llvm-svn: 79913
2009-08-24 12:20:57 +00:00
Douglas Gregor 8b9575f27e Top-level semicolons are allowed in C++0x. Fixes PR4755.
llvm-svn: 79912
2009-08-24 12:17:54 +00:00
John McCall 07e91c04ba First pass at friend semantics.
llvm-svn: 78274
2009-08-06 02:15:43 +00:00
Daniel Dunbar 769f940655 Ok, ok, I give in. Fix tests for unused result warning.
llvm-svn: 77780
2009-08-01 06:07:15 +00:00
Ryan Flynn 7d470f3466 PR3679 - handle #pragma weak
llvm-svn: 77573
2009-07-30 03:15:39 +00:00
Sebastian Redl 9f831dbbcd Implement C++ semantics for C-style and functional-style casts. This regresses Clang extension conversions, like vectors, but allows conversions via constructors and conversion operators.
Add custom conversions to static_cast.

llvm-svn: 77076
2009-07-25 15:41:38 +00:00
Daniel Dunbar 14d9d2fb78 Disable this test: cxx-using-declaration.cpp
Something strange is going on here; this test randomly started failing after
unrelated changes to TestRunner.py (even though it runs the same
script).

Argiris or Doug, can one of you investigate?

llvm-svn: 77063
2009-07-25 11:55:03 +00:00
Daniel Dunbar 34169976d0 Fix test case, which has a control-reaches-end-of-non-void warning that was
being masked by previous bug.

llvm-svn: 76858
2009-07-23 05:06:51 +00:00
Douglas Gregor e93e46c690 Implement support for out-of-line definitions of the class members of class
templates, e.g.,

  template<typename T>
  struct Outer {
    struct Inner;
  };

  template<typename T>
  struct Outer<T>::Inner {
    // ...
  };

Implementing this feature required some extensions to ActOnTag, which
now takes a set of template parameter lists, and is the precursor to
removing the ActOnClassTemplate function from the parser Action
interface. The reason for this approach is simple: the parser cannot
tell the difference between a class template definition and the
definition of a member of a class template; both have template
parameter lists, and semantic analysis determines what that template
parameter list means.

There is still some cleanup to do with ActOnTag and
ActOnClassTemplate. This commit provides the basic functionality we
need, however.

llvm-svn: 76820
2009-07-22 23:48:44 +00:00
Douglas Gregor b09f3d82cc Implement parsing and semantic analysis for out-of-line definitions of static
data members of class templates. We don't instantiate the definitions yet,
however.

llvm-svn: 76756
2009-07-22 17:18:37 +00:00
Mike Stump 753d120975 Prep for new warning.
llvm-svn: 76709
2009-07-22 00:43:08 +00:00
Eli Friedman 5e774b1333 Fix the parser error hanlding for __builtin_offsetof to actually print
out an error for a malformed __builtin_offsetof.

llvm-svn: 74388
2009-06-27 20:38:33 +00:00
Douglas Gregor ad3f2fcf43 Improved semantic analysis and AST respresentation for function
templates.

For example, this now type-checks (but does not instantiate the body
of deref<int>):

  template<typename T> T& deref(T* t) { return *t; }

  void test(int *ip) {
    int &ir = deref(ip);
  }

Specific changes/additions:
  * Template argument deduction from a call to a function template.
  * Instantiation of a function template specializations (just the
  declarations) from the template arguments deduced from a call.
  * FunctionTemplateDecls are stored directly in declaration contexts
  and found via name lookup (all forms), rather than finding the
  FunctionDecl and then realizing it is a template. This is
  responsible for most of the churn, since some of the core
  declaration matching and lookup code assumes that all functions are
  FunctionDecls.

llvm-svn: 74213
2009-06-25 22:08:12 +00:00
Fariborz Jahanian 6e9e4f3436 Fix a clang crash caused by incorrect user code.
llvm-svn: 74080
2009-06-24 17:00:18 +00:00
Douglas Gregor 17a7c1297a Make sure that the template parameter lists get from the parser down to ActOnFunctionDeclarator for function template definitions
llvm-svn: 74040
2009-06-24 00:54:41 +00:00
Douglas Gregor fec52635f0 Parsing and AST support for using declarations, from John Thompson!
llvm-svn: 73812
2009-06-20 00:51:54 +00:00
Douglas Gregor f187420feb Diagnose class members that shadow a template parameter. Fixes
<rdar://problem/6952203>. 

To do this, we actually remove a not-quite-correct optimization in the
C++ name lookup routines. We'll revisit this optimization for the
general case once more C++ is working.

llvm-svn: 73659
2009-06-17 23:37:01 +00:00
Douglas Gregor 6b6bba4a20 Diagnose the use of attributes on namespace aliases, from Anis Ahmad
llvm-svn: 73626
2009-06-17 19:49:00 +00:00
Chris Lattner 8e3eed0890 change ParseStatementOrDeclaration to emit the 'missing ;' with
ExpectAndConsume instead of custom diag logic.  This gets us an
insertion hint and positions the ; at the end of the line 
instead of on the next token.  Before:

t.c:5:1: error: expected ';' after return statement
}
^

after:

t.c:4:11: error: expected ';' after return statement
  return 4
          ^
          ;

llvm-svn: 73315
2009-06-14 00:23:56 +00:00
Eli Friedman 3c1291d384 Update test to work with the limited Sema for #pragma weak.
llvm-svn: 72914
2009-06-05 02:49:06 +00:00
Eli Friedman 8df7462f69 Test for parsing #pragma weak.
llvm-svn: 72908
2009-06-05 00:50:43 +00:00
Argyrios Kyrtzidis b1d51aa18a Use "()" instead of "(void)" when pretty-printing a parameter-less function type for C++.
llvm-svn: 72747
2009-06-03 02:06:50 +00:00
Eli Friedman cf7530ff43 PR4122: Tweak the ambiguity handling to handle (S())() correctly. I've
left out handling for stuff like (S())++ for the moment.

llvm-svn: 72394
2009-05-25 19:41:42 +00:00
Argyrios Kyrtzidis 4a6dad68a3 Add a test case to make sure that an ambiguous paren expression is only parsed once.
llvm-svn: 72298
2009-05-22 23:05:39 +00:00
Argyrios Kyrtzidis 12179bc014 Handle correctly a very ugly part of the C++ syntax. We cannot disambiguate between a parenthesized type-id and
a paren expression without considering the context past the parentheses.

Behold:
  (T())x;  - type-id
  (T())*x; - type-id
  (T())/x; - expression
  (T());   - expression

llvm-svn: 72260
2009-05-22 10:24:42 +00:00
Argyrios Kyrtzidis f5cc7ac4d5 Parse typeof-specifier the same way as sizeof/alignof are parsed.
-Makes typeof consistent with sizeof/alignof
-Fixes a bug when '>' is in a typeof expression, inside a template type param:
  A<typeof(x>1)> a;

llvm-svn: 72255
2009-05-22 10:22:18 +00:00
Eli Friedman 15af3ee6a9 Make the RAII extension warning silencing for __extension__ a bit
narrower, so it doesn't catch expresions that aren't sub-expressions of
__extension__ operator.

llvm-svn: 71967
2009-05-16 23:40:44 +00:00
Mike Stump b9075ae9f7 Fixup __extension__ i = 1 parsing. Thanks Eli!
llvm-svn: 71927
2009-05-16 04:31:34 +00:00
Mike Stump 76b824c388 Fixup parsing for (throw,throw) and __extension__ throw 1.
llvm-svn: 71897
2009-05-15 21:47:08 +00:00
Douglas Gregor 2399628cea Refactor the parsing of declarations so that template declarations can
parse just a single declaration and provide a reasonable diagnostic
when the "only one declarator per template declaration" rule is
violated. This eliminates some ugly, ugly hackery where we used to
require thatn the layout of a DeclGroup of a single element be the
same as the layout of a single declaration.

llvm-svn: 71596
2009-05-12 21:31:51 +00:00
Anders Carlsson 22e3784c79 For friend class decls, always use TK_Reference so we'll try to look up existing class decls first.
llvm-svn: 71481
2009-05-11 22:25:03 +00:00