diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2009-10-10 12:04:10 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2009-10-10 12:04:10 +0000 |
commit | 2c7588f1260c6655cfb73126b695d2f79ae170bb (patch) | |
tree | abd2ec9ba0168a9f0d4197ca1e55725e4b6d6270 /lib/Sema/SemaType.cpp | |
parent | 6e24726524c2b51b31bb4b622aa678a46b024f42 (diff) |
Implement the core checking for compatible exception specifications in assignment and initialization.
The exception specification of the assignee must be the same or a subset of the target. In addition, exception specifications on arguments and return types must be equivalent, but this is not implemented yet.
This currently produces two diagnostics for every invalid assignment/initialization, due to the diagnostic produced outside PerformImplicitConversion, e.g. in CheckSingleInitializer. I don't know how to suppress this; in any case I think it is the wrong place for a diagnostic, since there are other diagnostics produced inside the function. So I'm leaving it as it is for the moment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83710 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaType.cpp')
-rw-r--r-- | lib/Sema/SemaType.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 6a5db5f2ad..5c7bbd0441 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -1512,6 +1512,9 @@ bool Sema::CheckExceptionSpecSubset(unsigned DiagID, unsigned NoteID, // FIXME: As usual, we could be more specific in our error messages, but // that better waits until we've got types with source locations. + if (!SubLoc.isValid()) + SubLoc = SuperLoc; + // If superset contains everything, we're done. if (!Superset->hasExceptionSpec() || Superset->hasAnyExceptionSpec()) return false; @@ -1519,7 +1522,8 @@ bool Sema::CheckExceptionSpecSubset(unsigned DiagID, unsigned NoteID, // It does not. If the subset contains everything, we've failed. if (!Subset->hasExceptionSpec() || Subset->hasAnyExceptionSpec()) { Diag(SubLoc, DiagID); - Diag(SuperLoc, NoteID); + if (NoteID != 0) + Diag(SuperLoc, NoteID); return true; } @@ -1584,7 +1588,8 @@ bool Sema::CheckExceptionSpecSubset(unsigned DiagID, unsigned NoteID, } if (!Contained) { Diag(SubLoc, DiagID); - Diag(SuperLoc, NoteID); + if (NoteID != 0) + Diag(SuperLoc, NoteID); return true; } } |