Commit Graph

387 Commits

Author SHA1 Message Date
John McCall c162d1bbe4 ...I forgot to check my new test after adding it, and lo, there's slightly different
behavior in C than in C++ (which is what the original test case was).

llvm-svn: 112199
2010-08-26 17:42:30 +00:00
John McCall a3707cc7e2 Make sure we clear TypeSpecOwned when setting TypeSpecType to something when
it might previously have been a tag TST.

llvm-svn: 112196
2010-08-26 17:22:34 +00:00
John McCall 3669c80de9 Preserve invalidity of typeof operands in C++.
llvm-svn: 111999
2010-08-24 23:41:43 +00:00
Fariborz Jahanian 055068df4a Fix a crash when parsing malformed out-of-line member function
definition. radar 8307865.

llvm-svn: 111163
2010-08-16 17:58:53 +00:00
John Thompson 46667afccd Fix for pr7869, inline asm mult-alt constraints.
llvm-svn: 110764
2010-08-11 00:58:20 +00:00
John Thompson cdb847ba16 Added vecreturn attribute parsing.
llvm-svn: 110609
2010-08-09 21:53:52 +00:00
Argyrios Kyrtzidis c0dc36b213 Change warning about incomplete parsing of C++ default arg to error and provide a test case; thanks Doug!
llvm-svn: 110603
2010-08-09 21:08:13 +00:00
Argyrios Kyrtzidis 249179cd73 Introduce a new token kind 'cxx_defaultarg_end' to mark the end of C++ default arguments that were part of
lexed method declarations.

This avoid interference with tokens coming after the point where the default arg tokens were 'injected', e.g. for

typedef struct Inst {
  void m(int x=0);
} *InstPtr;

when parsing '0' the next token would be '*' and things would be messed up.

llvm-svn: 110436
2010-08-06 09:47:24 +00:00
John McCall 0f8ccc4938 Allow multiple __declspec attributes after a class-key.
Patch by Francois Pichet!

llvm-svn: 110344
2010-08-05 17:13:11 +00:00
Eli Friedman d986fc8b48 Tests for #pragma GCC visibility.
llvm-svn: 110316
2010-08-05 07:00:53 +00:00
Chandler Carruth a12b9deea0 Convert this file to not have Windows line endings -- likely committed from
Windows without svn:eol-style=native.

llvm-svn: 110308
2010-08-05 03:16:33 +00:00
Daniel Dunbar cb82acb884 Parser: Add support for #pragma align, which is just another spelling of #pragma
options align.

llvm-svn: 109952
2010-07-31 19:17:07 +00:00
Douglas Gregor 5dc055350e The grammar for GNU typeof in C requires an expression to be
parenthesized, unlike in C++, e.g.,

  C has: typeof ( expression) 
  C++ has: typeof unary-expression

So, once we've parsed a parenthesized expression after typeof, we
should only go on to parse the postfix expression suffix if we're in
C++. Fixes <rdar://problem/8237491>.

llvm-svn: 109606
2010-07-28 18:22:12 +00:00
Douglas Gregor 67ca40c419 Eliminate the "minimal" and printing parser actions, which only ever
worked for C anyway. Also kills the -cc1 options -parse-noop and
-parse-print-callbacks.

llvm-svn: 109392
2010-07-26 04:08:02 +00:00
Chandler Carruth 3c31aa3a44 Fix PR7673 by allowing an empty clobbers section in an ASM statement.
llvm-svn: 109087
2010-07-22 07:11:21 +00:00
Douglas Gregor 3a8e0d7d57 Revert Microsoft-specific override of the "typedef requires a name"
diagnostic. Instead, put it and the "declaration does not declare
anything" warning into -Wmissing-declarations.

llvm-svn: 108527
2010-07-16 15:40:40 +00:00
Douglas Gregor 5692680e0e Suppress the "typedef requires a name" warning in Microsoft-extensions mode
llvm-svn: 108526
2010-07-16 15:18:19 +00:00
Douglas Gregor dc9361876c When we're performing tentative parsing to determine whether the
parser is looking at a declaration or an expression, use a '=' to
conclude that we are parsing a declaration.

This is wrong. However, our previous approach of finding a comma after
the '=' is also wrong, because the ',' could be part of a
template-argument-list. So, for now we're going to use the same wrong
heuristic as GCC and Visual C++, because less real-world code is
likely to be broken this way. I've opened PR7655 to keep track of our
wrongness; note also the XFAIL'd test.

Fixes <rdar://problem/8193163>.

llvm-svn: 108459
2010-07-15 21:05:01 +00:00
Douglas Gregor aa8c97262a Complain when an unnamed enumeration has no enumerations (in
C++). Fixes PR7466.

llvm-svn: 108231
2010-07-13 06:24:26 +00:00
Chris Lattner 5a503e9f70 we do in fact have to cache the EOF token returned by the preprocessor.
In the case of backtracking, the cached token lexer will be the only 
lexer on the stack, without this the token stack will be empty and EOF
won't be returned.

This fixes PR7072.

llvm-svn: 108124
2010-07-12 04:25:32 +00:00
Chris Lattner 0931644922 revert a hunk of code that Argiris added in r106213, which is the
root cause of PR7481 and probably more, and has no apparent 
testcases.  I don't understand the logic here so I can't repair it.

llvm-svn: 108119
2010-07-12 01:48:28 +00:00
Chris Lattner ef74e2b2a8 change the 'invalid token after top level declarator' message to be
'expected ';' after top level declarator' which is much less vague.

llvm-svn: 108106
2010-07-11 22:46:04 +00:00
Chris Lattner 1390134c18 Fix PR7617 by not entering ParseFunctionDefinition when
a function prototype is followed by a declarator if we
aren't parsing a K&R style identifier list.

Also, avoid skipping randomly after a declaration if a
semicolon is missing.  Before we'd get:

t.c:3:1: error: expected function body after function declarator
void bar();
^

Now we get:

t.c:1:11: error: invalid token after top level declarator
void foo()
          ^
          ;

llvm-svn: 108105
2010-07-11 22:42:07 +00:00
John Thompson 781ad17ba9 Fix vector literal/cast confusion - bug 6895.
llvm-svn: 107347
2010-06-30 22:55:51 +00:00
Argyrios Kyrtzidis 639ffb0c07 Fix rdar://8139785 "implement warning on dead expression in comma operator"
As a bonus, fix the warning for || and && operators; it was emitted even if one of the operands had side effects, e.g:

x || test_logical_foo1();

emitted a bogus "expression result unused" for 'x'.

llvm-svn: 107274
2010-06-30 10:53:14 +00:00
Chris Lattner 37141f4fb4 improve altivec vector bool/pixel support, patch by Anton Yartsev
with several tweaks by me.

llvm-svn: 106619
2010-06-23 06:00:24 +00:00
Argyrios Kyrtzidis 75000b6814 Fix PR7180.
For

void f( a:🅱️:c );

we would cache the tokens "a:🅱️:" but then we would try to annotate them using the range "a::".
Before annotating them with the (invalid) C++ scope spec, set it to the range of "a:🅱️:".

llvm-svn: 106536
2010-06-22 11:30:04 +00:00
Chris Lattner f3d3b36870 Allow an asm label specifier on C++ methods, like GCC does.
Patch by David Majnemer!

llvm-svn: 105909
2010-06-13 05:34:18 +00:00
Douglas Gregor d5a479cbb5 Don't try to parse class template specializations in C. It can only
lead to heartache. Fixes <rdar://problem/8044088>.

llvm-svn: 105178
2010-05-30 22:30:21 +00:00
Daniel Dunbar 5794c6fa43 Sema: Just ignore '#pragma options align=power' for now, this is no worse than
what we used to be doing, and makes sure that paired '#pragma options
align=reset' won't fail.

llvm-svn: 104998
2010-05-28 19:43:33 +00:00
Daniel Dunbar 6da1098b4b Sema: Add initial support for '#pragma options align=mac68k'.
- Docs are fairly sketchy, if someone wants to pore through gcc to look for
   holes I'd appreciate any failing test cases!

llvm-svn: 104809
2010-05-27 05:45:51 +00:00
Daniel Dunbar bd60652ace Sema: Reject '#pragma options align=mac68k' everywhere except i386-apple-darwin.
llvm-svn: 104789
2010-05-27 00:35:16 +00:00
Daniel Dunbar 69dac58e7d Sema: Support for #pragma options align={reset,natural}. '#pragma options align'
shares the stack with '#pragma pack', who knew!?

llvm-svn: 104786
2010-05-27 00:04:40 +00:00
Douglas Gregor 4abc32d033 Improve parser recovery when a switch condition is invalid; fixes
<rdar://problem/7971948>.

llvm-svn: 104291
2010-05-20 23:20:59 +00:00
Fariborz Jahanian 862fac958b Patch to fix a crash on incomplete class declaration.
Radar 7923673.

llvm-svn: 103812
2010-05-14 21:35:02 +00:00
Chris Lattner ff895c140c Improve error recovery in C/ObjC when the first argument of a function
declarator is incorrect.  Not being a typename causes the parser to 
dive down into the K&R identifier list handling stuff, which is almost
never the right thing to do.

Before:

r.c:3:17: error: expected ')'
void bar(intptr y);
                ^
r.c:3:9: note: to match this '('
void bar(intptr y);
        ^
r.c:3:10: error: a parameter list without types is only allowed in a function definition
void bar(intptr y);
         ^

After:

r.c:3:10: error: unknown type name 'intptr'; did you mean 'intptr_t'?
void bar(intptr y);
         ^~~~~~
         intptr_t
r.c:1:13: note: 'intptr_t' declared here
typedef int intptr_t;
            ^

This fixes rdar://7980651 - poor recovery for bad type in the first arg of a C function

llvm-svn: 103783
2010-05-14 17:44:56 +00:00
Douglas Gregor 05cfc295f4 Namespaces can only be defined at global or namespace scope. Fixes PR6596.
llvm-svn: 103767
2010-05-14 05:08:22 +00:00
John McCall e7db86ddb0 Fix a tentative-parse error with unqualified template ids in cast expressions.
Also resolve a long-working FIXME in the test case I modified.

llvm-svn: 102688
2010-04-30 03:11:01 +00:00
Fariborz Jahanian 65654df92c Cleanup error recovery for a missing '-'|'+'
on a method declaration (radar 7822196).

llvm-svn: 102383
2010-04-26 21:18:08 +00:00
Douglas Gregor 8d4de67e1d Implement parsing for message sends in Objective-C++. Message sends in
Objective-C++ have a more complex grammar than in Objective-C
(surprise!), because

  (1) The receiver of an instance message can be a qualified name such
  as ::I or identity<I>::type.
  (2) Expressions in C++ can start with a type.

The receiver grammar isn't actually ambiguous; it just takes a bit of
work to parse past the type before deciding whether we have a type or
expression. We do this in two places within the grammar: once for
message sends and once when we're determining whether a []'d clause in
an initializer list is a message send or a C99 designated initializer.

This implementation of Objective-C++ message sends contains one known
extension beyond GCC's implementation, which is to permit a
typename-specifier as the receiver type for a class message, e.g.,

  [typename compute_receiver_type<T>::type method];

Note that the same effect can be achieved in GCC by way of a typedef,
e.g.,

  typedef typename computed_receiver_type<T>::type Computed;
  [Computed method];

so this is merely a convenience.

Note also that message sends still cannot involve dependent types or
values.

llvm-svn: 102031
2010-04-21 22:36:40 +00:00
Chris Lattner b596ac718e reapply john's patch, he broke mainline again by changing the test.
llvm-svn: 101871
2010-04-20 05:19:10 +00:00
Chris Lattner 3da9a2a3a9 revert r101863, whcih is causing Sema/altivec-init.c to fail on a ton
of buildbots with:

error: 'error' diagnostics expected but not seen: 
  Line 9: too few elements in vector initialization (expected 8 elements, have 2)
1 warning and 1 error generated.

llvm-svn: 101864
2010-04-20 04:31:55 +00:00
John Thompson f351b2c2b4 Altivec vector literal initializer count mismatch error removed.
llvm-svn: 101863
2010-04-20 03:58:33 +00:00
Chris Lattner dd6697b4fa improve altivec c++ support by adding casts, patch by
Anton Yartsev!

llvm-svn: 101281
2010-04-14 20:35:39 +00:00
Chris Lattner dad4062b4d implement altivec.h and a bunch of support code, patch by Anton Yartsev!
llvm-svn: 101215
2010-04-14 03:54:58 +00:00
Chris Lattner 37c75af0f8 fix PR6287 by accepting and ignoring the returns_twice attribute.
llvm-svn: 101005
2010-04-12 02:18:38 +00:00
Chris Lattner a36ec4243b fix PR6811 by not parsing 'super' as a magic expression in
LookupInObjCMethod.  Doing so allows all sorts of invalid code
to slip through to codegen.  This patch does not change the 
AST representation of super, though that would now be a natural
thing to do since it can only be in the receiver position and
in the base of a ObjCPropertyRefExpr.

There are still several ugly areas handling super in the parser,
but this is definitely a step in the right direction.

llvm-svn: 100959
2010-04-11 08:28:14 +00:00
Douglas Gregor c68e140657 Improve diagnostics when we fail to convert from a source type to a
destination type for initialization, assignment, parameter-passing,
etc. The main issue fixed here is that we used rather confusing
wording for diagnostics such as

t.c:2:9: warning: initializing 'char const [2]' discards qualifiers,
      expected 'char *' [-pedantic]
  char *name = __func__;
        ^      ~~~~~~~~

We're not initializing a 'char const [2]', we're initializing a 'char
*' with an expression of type 'char const [2]'. Similar problems
existed for other diagnostics in this area, so I've normalized them all
with more precise descriptive text to say what we're
initializing/converting/assigning/etc. from and to. The warning for
the code above is now:

t.c:2:9: warning: initializing 'char *' from an expression of type
      'char const [2]' discards qualifiers [-pedantic]
  char *name = __func__;
        ^      ~~~~~~~~

Fixes <rdar://problem/7447179>.

llvm-svn: 100832
2010-04-09 00:35:39 +00:00
Douglas Gregor f19ac0ede9 Downgrade the "declaration does not declare anything" error to a
warning. It's not harmful to have such pointless declarations, and GCC
does not diagnose this issue consistently.

llvm-svn: 100814
2010-04-08 21:33:23 +00:00
Douglas Gregor 3b4abb6792 Improve handling of friend types in several ways:
- When instantiating a friend type template, perform semantic
  analysis on the resulting type.
  - Downgrade the errors concerning friend type declarations that do
  not refer to classes to ExtWarns in C++98/03. C++0x allows
  practically any type to be befriended, and ignores the friend
  declaration if the type is not a class.

llvm-svn: 100635
2010-04-07 17:57:12 +00:00