Douglas Gregor [Tue, 2 Mar 2010 01:29:43 +0000 (01:29 +0000)]
Fix an amusing typo that completely the re-introduction of parameters
for the purposes of parsing default arguments. In effect, we would
re-introduce the parameter with a default argument N times (where N is
the number of parameters preceding the parameter with a default
argument). This showed up when a defaulted parameter of a member
function of a local class shadowed a parameter of the enclosing
function. Fixes PR6383.
Douglas Gregor [Mon, 1 Mar 2010 23:49:23 +0000 (23:49 +0000)]
When we're parsing template names as part of base-specifiers, we are
*not* entering the context of the nested-name-specifier. This was
causing us to look into an uninstantiated template that we shouldn't
look into. Fixes PR6376.
John McCall [Mon, 1 Mar 2010 23:49:17 +0000 (23:49 +0000)]
Split out types that are non-canonical unless dependent as their own
category. Use this in a few places to eliminate unnecessary TST cases and
do some future-proofing. Provide terrible manglings for typeof. Mangle
decltype with some hope of accuracy.
Our manglings for some of the cases covered in the testcase are different
from gcc's, which I've raised as an issue with the ABI list.
Douglas Gregor [Mon, 1 Mar 2010 23:15:13 +0000 (23:15 +0000)]
Keep an explicit stack of function and block scopes, each element of
which has the label map, switch statement stack, etc. Previously, we
had a single set of maps in Sema (for the function) along with a stack
of block scopes. However, this lead to funky behavior with nested
functions, e.g., in the member functions of local classes.
The explicit-stack approach is far cleaner, and we retain a 1-element
cache so that we're not malloc/free'ing every time we enter a
function. Fixes PR6382.
Also, tweaked the unused-variable warning suppression logic to look at
errors within a given Scope rather than within a given function. The
prior code wasn't looking at the right number-of-errors count when
dealing with blocks, since the block's count would be deallocated
before we got to ActOnPopScope. This approach works with nested
blocks/functions, and gives tighter error recovery.
Fix the lookup of names used in a friend declaration to not attempt to
re-declare them. This fixes PR6317. Also add the beginnings of an interesting
test case for p1 of [class.friend] which also covers PR6317.
Chris Lattner [Mon, 1 Mar 2010 20:56:44 +0000 (20:56 +0000)]
avoid issues with the new scope protector. Previously we'd error
with "address taken of label in protected scope, jump to it would have unknown effect on scope"
Douglas Gregor [Mon, 1 Mar 2010 19:00:07 +0000 (19:00 +0000)]
When instantiating a function-scoped enum, make sure that it and its
enumeration constants get placed into the local instantiation hash
table. Fixes PR6375.
Douglas Gregor [Mon, 1 Mar 2010 18:27:54 +0000 (18:27 +0000)]
Robustify instantiation of templates when there are errors in the
template definition. Do this both by being more tolerant of errors in
our asserts and by not dropping a variable declaration completely when
its initializer is ill-formed. Fixes the crash-on-invalid in PR6375,
but not the original issue.
John McCall [Mon, 1 Mar 2010 18:20:46 +0000 (18:20 +0000)]
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.
Douglas Gregor [Mon, 1 Mar 2010 15:56:25 +0000 (15:56 +0000)]
When looking for the instantiated declaration that corresponds to a
given declaration in a template, make sure that the context we're
searching through is complete. Fixes PR6376.
Douglas Gregor [Mon, 1 Mar 2010 01:04:55 +0000 (01:04 +0000)]
Don't warn about case-value conversions from a negative value to a
larger unsigned value, since this is implementation-defined
behavior. (We previously suppressed this warning when converting from
a signed value to an unsigned value of the same size).
Chris Lattner [Sun, 28 Feb 2010 18:18:36 +0000 (18:18 +0000)]
Implement PR6423 by using one token of lookahead to disambiguate
an *almost* always incorrect case. This only does the lookahead
in the insanely unlikely case, so it shouldn't impact performance.
On this testcase:
struct foo {
}
typedef int x;
Before:
t.c:3:9: error: cannot combine with previous 'struct' declaration specifier
typedef int x;
^
John McCall [Sun, 28 Feb 2010 13:00:19 +0000 (13:00 +0000)]
Support constant-evaluation of __builtin_nans* as well as the correct constant
evaluation of __builtin_nan*. Most of the work to make this work is in LLVM.
Fixes <rdar://problem/7696712> and part of PR 5255.
Anders Carlsson [Sat, 27 Feb 2010 20:02:53 +0000 (20:02 +0000)]
Enable the new vtable layout code for vtables that aren't construction vtables. (This doesn't mean that we emit LLVM IR using it yet, it just means that it's running and hopefully not crashing or asserting).
Douglas Gregor [Sat, 27 Feb 2010 02:42:25 +0000 (02:42 +0000)]
Robustify SourceManager::getLocation(), so that it returns an
end-of-line source location when given a column number beyond the
length of the line, or an end-of-file source location when given a
line number beyond the length of the file. Previously, we would return
an invalid location.
Douglas Gregor [Sat, 27 Feb 2010 01:32:48 +0000 (01:32 +0000)]
When given unsaved files in clang_createTranslationUnitFromSourceFile,
copy the source buffers provided rather than referencing them
directly, so that the caller can free those buffers immediately after
calling clang_createTranslationUnitFromSourceFile(). Otherwise, we
risk hitting those buffers later (when building source ranges, forming
diagnostics, etc.).
Ted Kremenek [Fri, 26 Feb 2010 19:18:41 +0000 (19:18 +0000)]
For printf format string checking, move the tracking of the data argument index out of
Sema and into analyze_printf::ParseFormatString(). Also use a bitvector to determine
what arguments have been covered (instead of just checking to see if the last argument consumed is the max argument). This is prep. for support positional arguments (an IEEE extension).
Zhongxing Xu [Fri, 26 Feb 2010 15:43:34 +0000 (15:43 +0000)]
Use a GDM to record the returned expression in the state when VisitReturnStmt.
Use this information to find the returned value and bind it to CallExpr in
ProcessCallExit.
And there is no need to remove dead bindings in ProcessCallExit, because
a. it would clean up the return value bound to CallExpr
b. we still would do it in the next ProcessStmt(), where we would not misclean
up the return value.
John McCall [Fri, 26 Feb 2010 08:45:28 +0000 (08:45 +0000)]
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.
Douglas Gregor [Fri, 26 Feb 2010 06:03:23 +0000 (06:03 +0000)]
An explicit specialization is allowed following an explicit
instantiation so long as that explicit specialization was declared
previously. Fixes PR6160.
Douglas Gregor [Fri, 26 Feb 2010 05:06:18 +0000 (05:06 +0000)]
Implement semantic analysis for C++ [expr.new]p18-20, which describe
how we find the operator delete that matches withe operator new we
found in a C++ new-expression.
This will also need CodeGen support. On a happy note, we're now a
"nans" away from building tramp3d-v4.
Douglas Gregor [Fri, 26 Feb 2010 00:38:10 +0000 (00:38 +0000)]
Make sure to mark constructors, operator new, and operator delete as
used when we instantiate C++ new expressions, delete expressions, and
object-construction expressions. Fixes PR6424, although we can't test
all of it until we finish implementing lookup of "operator delete" for
new expressions (!).
Douglas Gregor [Fri, 26 Feb 2010 00:01:57 +0000 (00:01 +0000)]
When we decide to re-use an existing CXXConstructExpr node, make sure
to mark the constructor as referenced. Fixes the narrow issue reported
in PR6424, but there are a few other places that I'll fix before
closing out that PR.