forked from universal-ctags/ctags
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request universal-ctags#1747 from masatake/cxx-handling-fu…
…nction-try-block C++: handle function-try-block
- Loading branch information
Showing
4 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--sort=no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
S input.cxx /^struct S {$/;" s file: | ||
m input.cxx /^ std::string m;$/;" m struct:S typeref:typename:std::string file: | ||
S input.cxx /^ S(const std::string& arg) try : m(arg, 100) {$/;" f struct:S file: | ||
f input.cxx /^int f(int n = 2) try {$/;" f typeref:typename:int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* Taken from | ||
* http://en.cppreference.com/w/cpp/language/function-try-block */ | ||
|
||
struct S { | ||
std::string m; | ||
S(const std::string& arg) try : m(arg, 100) { | ||
std::cout << "constructed, mn = " << m << '\n'; | ||
} catch(const std::exception& e) { | ||
std::cerr << "arg=" << arg << " failed: " << e.what() << '\n'; | ||
} // implicit throw; here | ||
}; | ||
|
||
int f(int n = 2) try { | ||
++n; // increments the function parameter | ||
throw n; | ||
} catch(...) { | ||
++n; // n is in scope and still refers to the function parameter | ||
assert(n == 4); | ||
return n; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters