Commit Graph

35 Commits

Author SHA1 Message Date
Charles Li 234233dd76 Lit C++11 Compatibility Patch #8
24 tests have been updated for C++11 compatibility.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@266387 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-14 23:47:07 +00:00
Richard Smith 7ee27b7c76 PR23942: a pure-specifier's integer literal must be spelled '0'
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241019 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-29 23:19:23 +00:00
Richard Trieu 8a70ee0e8e Add a new error for unexpected semi-colon before closing delimiter.
Previously, if a semi-colon is unexpectedly added before a closing ')', ']' or
'}', two errors and one note would emitted, and the parsing would get confused
to which scope it was in.  This change consumes the semi-colon, recovers
parsing better, and emits only one error with a fix-it.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@237192 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-12 21:36:35 +00:00
Benjamin Kramer 3b4d720f29 [Parse] Don't crash on ~A::{
Found by clang-fuzz.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233492 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-29 14:35:39 +00:00
Nico Weber f794b6635f Follow-up to r217302: Don't crash on ~A::A in a postfix expr suffix followed by '<'.
This used to crash, complaining "ObjectType and scope specifier cannot coexist":

    struct A { } b = b.~A::A <int>;

The only other caller of ParseOptionalCXXScopeSpecifier() that passes in a
non-empty ObjectType clears the ObjectType of the scope specifier comes back
non-empty (see the tok::period case in Parser::ParsePostfixExpressionSuffix()),
so do that here too.

Found by SLi's bot.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@227781 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-02 05:33:50 +00:00
Nico Weber d2a265184c Follow-up to r217302 and r227555: Don't crash on inline ~A::A() if A is an int.
Even with r227555, this still crashed:

  struct S {
    int A;
    ~A::A() {}
  };

That's because ParseOptionalCXXScopeSpecifier()'s call to
ActOnCXXNestedNameSpecifier() doesn't mark the scope spec as invalid if sema
thought it's a good idea to fixit-correct "::" to ":".  For the diagnostic
improvement done in r217302, we never want :: to be interpreted as :, so fix
this by setting ColonSacred to false temporarily.

Found by SLi's bot.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@227581 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-30 16:53:11 +00:00
Nico Weber 814aa7c5c3 Follow-up to r217302: Don't crash on ~A::A() if A is undeclared.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@227555 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-30 04:05:15 +00:00
Richard Smith 73e3217e76 Fix crash-on-invalid and name lookup when recovering from ~X::X() typo.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226067 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-15 00:48:52 +00:00
Richard Smith 12421c320c If we don't find a matching ) for a ( in an exception specification, keep the tokens around so we can diagnose an error rather than silently discarding them.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225755 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-13 02:24:58 +00:00
Nico Weber 98045aa38c Don't crash on access decls with invalid scope specifier, PR20887.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217472 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-10 00:59:37 +00:00
Richard Smith 7d14568fc6 Add error, recovery and fixit for "~A::A() {...}".
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217302 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-06 02:06:12 +00:00
Richard Smith ef86fa4d1f PR20760: Don't assert (and produce better diagnostics) if a default initializer
contains an unmatched closing bracket token.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216518 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-27 03:23:12 +00:00
Richard Smith b9df04cac9 Reject virt-specifiers on friend declarations. Give anonymous bitfields a
location so their diagnostics have somewhere to point.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215416 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-12 00:22:39 +00:00
Richard Smith 134c68d002 Improve diagnostics for malformed constructor declarations (where lookup for
the type of the first parameter fails, and it is the only, unnamed, parameter).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202759 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-03 21:12:53 +00:00
Serge Pavlov 13cd246821 Avoid extra error messages if method definition is inside function.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196757 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-09 05:25:47 +00:00
Richard Smith c7f811638f Add missing diagnostic for a nested-name-specifier on a free-standing type definition. Bump some related diagnostics from warning to extension in C++, since they're errors there. Add some missing checks for function specifiers on non-function declarations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177335 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-18 22:52:47 +00:00
Richard Smith 69e4826edc PR13775: When checking for a tag type being shadowed by some other declaration,
don't trample over the caller's LookupResult in the case where the check fails.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163281 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-06 01:37:56 +00:00
Richard Smith eab9d6f906 Add diagnostics for comma at end of enum and for extra semicolon at namespace
scope to -Wc++11-extensions. Move extra semicolon after member function
definition diagnostic out of -pedantic, since C++ allows a single semicolon
there. Keep it in -Wextra-semi, though, since it's still questionable.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160618 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-23 05:45:25 +00:00
Richard Trieu 4b0e6f1da3 Move the warnings for extra semi-colons under -Wextra-semi. Also, added
a warning for an extra semi-colon after function definitions.  Added logic
so that a block of semi-colons on a line will only get one warning instead
of a warning for each semi-colon.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156934 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-16 19:04:59 +00:00
Richard Smith 52f10d5f47 Don't try to parse a malformed parameter list after a constructor or operator
name as a direct initializer.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153628 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-29 01:46:00 +00:00
Richard Smith 412e0cc52e When we see 'Class(X' or 'Class::Class(X' and we suspect that it names a
constructor, but X is not a known typename, check whether the tokens could
possibly match the syntax of a declarator before concluding that it isn't
a constructor. If it's definitely ill-formed, assume it is a constructor.

Empirical evidence suggests that this pattern is much more often a
constructor with a typoed (or not-yet-declared) type name than any of the
other possibilities, so the extra cost of the check is not expected to be
problematic.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153488 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-27 00:56:56 +00:00
Richard Trieu 65ba94814f Fix code so that a SkipUntil will ignore semicolons when skipping a
function body.  This keeps the brace count accurate to prevent
additional errors.  Also, moved the caret from the brace to the function
name.

Code:
class F{ int Foo{ return 1; } };

Fixed error:
parameters.cc:1:14: error: function definition does not declare parameters
class F{ int Foo{ return 1; } };
             ^
1 error generated.

Old errors:
parameters.cc:1:17: error: function definition does not declare parameters
class F{ int Foo{ return 1; } };
                ^
parameters.cc:1:30: error: expected ';' after class
class F{ int Foo{ return 1; } };
                             ^
                             ;
parameters.cc:1:31: error: expected external declaration
class F{ int Foo{ return 1; } };
                              ^
3 errors generated.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148621 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-21 02:59:18 +00:00
David Blaikie 13f8daf706 Fix crash-on-invalid, improve error recovery, and test coverage for missing colon after access specifiers in C++
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141852 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-13 06:08:43 +00:00
Douglas Gregor 9ea416e598 Parse the optional semicolon after a C++ in-class member function
definition, rather than complaining about it. Problem reported by
Marshall Clow.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123835 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-19 16:41:58 +00:00
Douglas Gregor a131d0fc0a Complain when an unnamed enumeration has no enumerations (in
C++). Fixes PR7466.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108231 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-13 06:24:26 +00:00
Douglas Gregor cb821d045f 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100814 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-08 21:33:23 +00:00
Daniel Dunbar a5728872c7 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).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91446 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-15 20:14:24 +00:00
Daniel Dunbar d7d5f0223b Rename clang to clang-cc.
Tests and drivers updated, still need to shuffle dirs.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67602 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-24 02:24:46 +00:00
Douglas Gregor ddc29e116d Semantic checking for class template declarations and
redeclarations. For example, checks that a class template
redeclaration has the same template parameters as previous
declarations.

Detangled class-template checking from ActOnTag, whose logic was
getting rather convoluted because it tried to handle C, C++, and C++
template semantics in one shot.

Made some inroads toward eliminating extraneous "declaration does not
declare anything" errors by adding an "error" type specifier.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63973 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-06 22:42:48 +00:00
Douglas Gregor 4920f1ffb6 Implement support for anonymous structs and unions in C. Both C and
C++ handle anonymous structs/unions in the same way. Addresses several
bugs:

  <rdar://problem/6259534>
  <rdar://problem/6481130>
  <rdar://problem/6483159>

The test case in PR clang/1750 now passes with -fsyntax-only, but
CodeGen for inline assembler still fails.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62112 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-12 22:49:06 +00:00
Chris Lattner bc8d56496a implement PR3177 - "__extension__ union" not supported in C++ mode
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61180 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-18 01:12:00 +00:00
Sebastian Redl 669d5d74b8 Implement parsing and semantic checking of the 'mutable' keyword.
Thanks to Doug for the review. Actual effects of mutable to follow.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59331 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-14 23:42:31 +00:00
Sebastian Redl ab963c6221 Update C++ status to reflect parser capabilities for chapter 9 (classes). Slightly extend the class parser test.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58909 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-08 15:40:37 +00:00
Argyrios Kyrtzidis 3a9fdb4742 Handle unnamed bitfields when parsing C++ classes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52855 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-28 08:10:48 +00:00
Argyrios Kyrtzidis 4cc18a4d52 Add parsing support for C++ classes.
Note that Parser::ParseCXXMemberSpecification is temporarily disabled until the Sema support is in place.
Once ParseCXXMemberSpecification is enabled, the Parser/cxx-class.cpp test will pass.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52694 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-24 22:12:16 +00:00