Commit Graph

26 Commits

Author SHA1 Message Date
Richard Smith 63168c7533 PR11684, core issue 1417:
o Correct the handling of the restrictions on usage of cv-qualified and
  ref-qualified function types.
o Fix a bug where such types were rejected in template type parameter default
  arguments, due to such arguments not being treated as a template type arg
  context.
o Remove the ExtWarn for usage of such types as template arguments; that was
  a standard defect, not a GCC extension.
o Improve the wording and unify the code for diagnosing cv-qualifiers with the
  code for diagnosing ref-qualifiers.

llvm-svn: 150244
2012-02-10 11:05:11 +00:00
Richard Trieu 4972a6dd08 Extend the error of invalid token after declarations to include fixits for
!=, %=, ^=, &=, *=, -=, |=, /=, <<=, <=, >=, and >>= to =.

llvm-svn: 148499
2012-01-19 22:01:51 +00:00
Richard Trieu c64d3230d2 Change the error when a '+=' follows a declaration to suggest a fixit to '=' instead of just suggesting a ';'.
Old error:
plusequaldeclare1.cc:3:8: error: expected ';' at end of declaration
  int x += 6;
       ^
       ;

New error:
plusequaldeclare1.cc:3:9: error: invalid '+=' at end of declaration; did you
      mean '='?
  int x += 6;
        ^~
        =

llvm-svn: 148433
2012-01-18 22:54:52 +00:00
Richard Smith c8a79033ba Extend the diagnostic for a ',' at the end of a declaration where a ';' was
intended to cover C++ class definitions.

llvm-svn: 147808
2012-01-09 22:31:44 +00:00
Richard Smith b3041feaf7 Revert most of r145372 for now. Lookahead beyond the ';' in a function
declaration tickles a bug in the way we handle visibility pragmas.

The improvement to error recovery for template function definitions declared
with the 'typedef' specifier in r145372 is unrelated and not reverted here.

llvm-svn: 145541
2011-11-30 23:45:35 +00:00
Richard Smith 53711607a0 Add fix-it to remove 'typedef' from function template definitions. Such a token
was probably meant to be 'typename', which we will have already suggested if it
is appropriate.

llvm-svn: 145395
2011-11-29 09:09:06 +00:00
Richard Smith 675ea99a2a PR10101: Recover better from a common copy-paste error: if a function
declaration at namespace scope is followed by a semicolon and an open-brace
(or in C++, a 'try', ':' or '='), then the error is probably a function
definition with a spurious ';', rather than a mysterious '{'.

llvm-svn: 145372
2011-11-29 05:27:40 +00:00
Richard Smith 4e9ea71dab Make the -verify bits in this test actually test something, and fix a few cases
where the test didn't work.

llvm-svn: 142563
2011-10-20 01:41:28 +00:00
Richard Smith 09f76ee63c Improve the diagnostic when a comma ends up at the end of a declarator group
instead of a semicolon (as sometimes happens during refactorings). When such a
comma is seen at the end of a line, and is followed by something which can't
possibly be a declarator (or even something which might be a plausible typo for
a declarator), suggest that a semicolon was intended.

llvm-svn: 142544
2011-10-19 21:33:05 +00:00
Douglas Gregor e248eea214 Improve the warning for cv-qualifiers on free functions, from Ahmed Charles!
llvm-svn: 142478
2011-10-19 06:04:55 +00:00
Richard Smith 3ab15558d7 PR10867: Work around a bug in lit. Multiple RUN: lines are joined with &&, so:
RUN: foo
  RUN: bar || true

is equivalent to:

  RUN: foo && bar || true

which is equivalent to:

  RUN: (foo && bar) || true

This resulted in several of the fixit tests not really testing anything.

llvm-svn: 139132
2011-09-06 03:01:15 +00:00
Anna Zaks 3b402716b1 Add */& mismatch fixit generation to the Sema::DiagnoseAssignmentResult().
llvm-svn: 136379
2011-07-28 19:51:27 +00:00
Francois Pichet 4e7a2c09b2 Improve recovery (error + fix-it) when parsing type dependent template name without the "template" keyword.
For example:
   typename C1<T>:: /*template*/ Iterator<0> pos; 

Also the error is downgraded to an ExtWarn in Microsoft mode.

llvm-svn: 128387
2011-03-27 19:41:34 +00:00
Douglas Gregor f05c0958e2 Remove the Fix-It for "main must return 'int'", which is not always
correct and is not worth fixing. Fixes PR8396.

llvm-svn: 126035
2011-02-19 19:04:23 +00:00
Argyrios Kyrtzidis b5c7c51392 When we encounter a '==' in a context expecting a '=', assume the user made a typo:
t.c:1:7: error: invalid '==' at end of declaration; did you mean '='?
int x == 0;
      ^~
      =

Implements rdar://8488464.

llvm-svn: 116035
2010-10-08 02:39:23 +00:00
Francois Pichet 6d76e6cd92 Better diagnostic for superfluous scope specifier inside a class definition for member functions. + Fixit.
Example: 
class A {
   void A::foo(); //warning: extra qualification on member 'foo'
};

llvm-svn: 115347
2010-10-01 21:19:28 +00:00
Gabor Greif 80c218386f add a fixit when 'main' does ot return 'int'; review welcome
llvm-svn: 113324
2010-09-08 00:31:13 +00:00
Douglas Gregor 3465e26102 Improve diagnostic and recovery when missing a comma between base or
member initializers in a C++ constructor. Fixes <rdar://problem/7796492>.

llvm-svn: 113199
2010-09-07 14:35:10 +00:00
Nick Lewycky 784fad7a41 Teach clang -fixit to modify files in-place, or -fixit=suffix to create new
files with the additional suffix in the middle.

llvm-svn: 102230
2010-04-24 01:30:46 +00:00
Douglas Gregor 2fb18b746f Thread a Scope pointer into BuildRecoveryCallExpr to help typo
correction find names when a call failed. Fixes
<rdar://problem/7853795>.

llvm-svn: 101278
2010-04-14 20:27:54 +00:00
Douglas Gregor d6bc5e6bbc When a declaration of a function is missing an exception specification
that was present in a prior declaration, emit a warning rather than a
hard error (which we did before, and still do with mismatched
exception specifications). Moreover, provide a fix-it hint with the
throw() clause that should be added, e.g.,

t.C:10:7: warning: 'operator new' is missing exception specification
      'throw(std::bad_alloc)'
void *operator new(unsigned long sz)
      ^
                                     throw(std::bad_alloc)

As part of this, disable the warning when we're missing an exception
specification on operator new, operator new[], operator delete, or
operator delete[] when exceptions are turned off (-fno-exceptions).

Fixes PR5957.

llvm-svn: 99388
2010-03-24 07:14:45 +00:00
Douglas Gregor f1d70adfd1 Make this fix-it test case actually fail when there is a problem; add
a test for access declarations and remove a (broken) test for removal
of default arguments.

llvm-svn: 95032
2010-02-01 23:46:27 +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
Daniel Dunbar 6c39d457fa Update FixIt tests to make it more obvious they use a separate mode.
llvm-svn: 88758
2009-11-14 04:39:42 +00:00
Anders Carlsson 0b8ea554e5 If a function with a default argument is redefined and the new function also has a defualt argument then add a fixit hint that removes the default argument. Fixes PR5444.
llvm-svn: 86659
2009-11-10 03:24:44 +00:00
Douglas Gregor 68bc53967e Move the fix-it tests into their own subdirectory
llvm-svn: 68325
2009-04-02 17:19:13 +00:00